[PATCH 0/3] net: Use of_device_get_match_data to simplify code
STALE1808d
7 messages,
2 authors,
2021-08-23 · open the first message on its own page
Hi all:
This patch series replace 'of_match_device' with
'of_device_get_match_data', to make code cleaner and better.
Thanks
Tang Bin (3):
via-rhine: Use of_device_get_match_data to simplify code
via-velocity: Use of_device_get_match_data to simplify code
can: mscan: mpc5xxx_can: Use of_device_get_match_data to simplify code
drivers/net/can/mscan/mpc5xxx_can.c | 6 ++----
drivers/net/ethernet/via/via-rhine.c | 9 ++-------
drivers/net/ethernet/via/via-velocity.c | 6 ++----
3 files changed, 6 insertions(+), 15 deletions(-)
--
2.20.1.windows.1
Retrieve OF match data, it's better and cleaner to use
'of_device_get_match_data' over 'of_match_device'.
Signed-off-by: Tang Bin <redacted>
---
drivers/net/ethernet/via/via-rhine.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 961b623b7..3b73a9c55 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c @@ -1113,13 +1113,12 @@ static int rhine_init_one_pci(struct pci_dev *pdev,
static int rhine_init_one_platform ( struct platform_device * pdev )
{
- const struct of_device_id * match ;
const u32 * quirks ;
int irq ;
void __iomem * ioaddr ;
- match = of_match_device ( rhine_of_tbl , & pdev -> dev );
- if ( ! match )
+ quirks = of_device_get_match_data ( & pdev -> dev );
+ if ( ! quirks )
return - EINVAL ;
ioaddr = devm_platform_ioremap_resource ( pdev , 0 ); @@ -1130,10 +1129,6 @@ static int rhine_init_one_platform(struct platform_device *pdev)
if ( ! irq )
return - EINVAL ;
- quirks = match -> data ;
- if ( ! quirks )
- return - EINVAL ;
-
return rhine_init_one_common ( & pdev -> dev , * quirks ,
( long ) ioaddr , ioaddr , irq );
} --
2.20.1.windows.1
Retrieve OF match data, it's better and cleaner to use
'of_device_get_match_data' over 'of_match_device'.
Signed-off-by: Tang Bin <redacted>
---
drivers/net/can/mscan/mpc5xxx_can.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index e254e04ae..3b7465acd 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c @@ -279,7 +279,6 @@ static u32 mpc512x_can_get_clock(struct platform_device *ofdev,
static const struct of_device_id mpc5xxx_can_table [];
static int mpc5xxx_can_probe ( struct platform_device * ofdev )
{
- const struct of_device_id * match ;
const struct mpc5xxx_can_data * data ;
struct device_node * np = ofdev -> dev . of_node ;
struct net_device * dev ; @@ -289,10 +288,9 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
int irq , mscan_clksrc = 0 ;
int err = - ENOMEM ;
- match = of_match_device ( mpc5xxx_can_table , & ofdev -> dev );
- if ( ! match )
+ data = of_device_get_match_data ( & ofdev -> dev );
+ if ( ! data )
return - EINVAL ;
- data = match -> data ;
base = of_iomap ( np , 0 );
if ( ! base ) { --
2.20.1.windows.1
Retrieve OF match data, it's better and cleaner to use
'of_device_get_match_data' over 'of_match_device'.
Signed-off-by: Tang Bin <redacted>
---
drivers/net/ethernet/via/via-velocity.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
index 278f49518..6a08ea658 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c @@ -2943,14 +2943,12 @@ static void velocity_pci_remove(struct pci_dev *pdev)
static int velocity_platform_probe ( struct platform_device * pdev )
{
- const struct of_device_id * of_id ;
const struct velocity_info_tbl * info ;
int irq ;
- of_id = of_match_device ( velocity_of_ids , & pdev -> dev );
- if ( ! of_id )
+ info = of_device_get_match_data ( & pdev -> dev );
+ if ( ! info )
return - EINVAL ;
- info = of_id -> data ;
irq = irq_of_parse_and_map ( pdev -> dev . of_node , 0 );
if ( ! irq ) --
2.20.1.windows.1
On 23.08.2021 19:33:38, Tang Bin wrote: Retrieve OF match data, it's better and cleaner to use
'of_device_get_match_data' over 'of_match_device'.
Signed-off-by: Tang Bin <redacted>
Thanks for the patch!
LGTM, comment inside.
quoted hunk ---
drivers/net/can/mscan/mpc5xxx_can.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index e254e04ae..3b7465acd 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c @@ -279,7 +279,6 @@ static u32 mpc512x_can_get_clock(struct platform_device *ofdev,
static const struct of_device_id mpc5xxx_can_table [];
static int mpc5xxx_can_probe ( struct platform_device * ofdev )
{
- const struct of_device_id * match ;
const struct mpc5xxx_can_data * data ;
struct device_node * np = ofdev -> dev . of_node ;
struct net_device * dev ; @@ -289,10 +288,9 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
int irq , mscan_clksrc = 0 ;
int err = - ENOMEM ;
- match = of_match_device ( mpc5xxx_can_table , & ofdev -> dev );
- if ( ! match )
+ data = of_device_get_match_data ( & ofdev -> dev );
+ if ( ! data )
return - EINVAL ;
Please remove the "BUG_ON(!data)", which comes later.
- data = match->data;
base = of_iomap(np, 0);
if (!base) {
--
2.20.1.windows.1
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Marc:
On 2021/8/23 20:37, Marc Kleine-Budde wrote: On 23.08.2021 19:33:38, Tang Bin wrote: quoted Retrieve OF match data, it's better and cleaner to use
'of_device_get_match_data' over 'of_match_device'.
Signed-off-by: Tang Bin <redacted> Thanks for the patch!
LGTM, comment inside.
quoted ---
drivers/net/can/mscan/mpc5xxx_can.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index e254e04ae..3b7465acd 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c @@ -279,7 +279,6 @@ static u32 mpc512x_can_get_clock(struct platform_device *ofdev,
static const struct of_device_id mpc5xxx_can_table [];
static int mpc5xxx_can_probe ( struct platform_device * ofdev )
{
- const struct of_device_id * match ;
const struct mpc5xxx_can_data * data ;
struct device_node * np = ofdev -> dev . of_node ;
struct net_device * dev ; @@ -289,10 +288,9 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
int irq , mscan_clksrc = 0 ;
int err = - ENOMEM ;
- match = of_match_device ( mpc5xxx_can_table , & ofdev -> dev );
- if ( ! match )
+ data = of_device_get_match_data ( & ofdev -> dev );
+ if ( ! data )
return - EINVAL ; Please remove the "BUG_ON(!data)", which comes later.
For this place, may I send another patch to fix this 'BUG_ON()' by
itself, not in this patch series?
Thanks
Tang Bin
quoted - data = match->data;
base = of_iomap(np, 0);
if (!base) {
--
2.20.1.windows.1
regards,
Marc
On 23.08.2021 21:52:03, tangbin wrote: On 2021/8/23 20:37, Marc Kleine-Budde wrote: quoted On 23.08.2021 19:33:38, Tang Bin wrote: quoted Retrieve OF match data, it's better and cleaner to use
'of_device_get_match_data' over 'of_match_device'.
Signed-off-by: Tang Bin <redacted> Thanks for the patch!
LGTM, comment inside.
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
quoted quoted ---
drivers/net/can/mscan/mpc5xxx_can.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index e254e04ae..3b7465acd 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c @@ -279,7 +279,6 @@ static u32 mpc512x_can_get_clock(struct platform_device *ofdev,
static const struct of_device_id mpc5xxx_can_table [];
static int mpc5xxx_can_probe ( struct platform_device * ofdev )
{
- const struct of_device_id * match ;
const struct mpc5xxx_can_data * data ;
struct device_node * np = ofdev -> dev . of_node ;
struct net_device * dev ; @@ -289,10 +288,9 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
int irq , mscan_clksrc = 0 ;
int err = - ENOMEM ;
- match = of_match_device ( mpc5xxx_can_table , & ofdev -> dev );
- if ( ! match )
+ data = of_device_get_match_data ( & ofdev -> dev );
+ if ( ! data )
return - EINVAL ; Please remove the "BUG_ON(!data)", which comes later.
For this place, may I send another patch to fix this 'BUG_ON()' by itself,
not in this patch series?
Ok, fine with me.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |