diff mbox series

[v2,2/6] drivers: net: davinci_mdio: Use of_device_get_match_data()

Message ID 20210123034428.2841052-3-swboyd@chromium.org (mailing list archive)
State New, archived
Headers show
Series Stop NULLifying match pointer in of_match_device() | expand

Commit Message

Stephen Boyd Jan. 23, 2021, 3:44 a.m. UTC
Use the more modern API to get the match data out of the of match table.
This saves some code, lines, and nicely avoids referencing the match
table when it is undefined with configurations where CONFIG_OF=n.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-omap@vger.kernel.org>
---

Please ack so Rob can apply.

 drivers/net/ethernet/ti/davinci_mdio.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Grygorii Strashko Jan. 26, 2021, 1:11 p.m. UTC | #1
On 23/01/2021 05:44, Stephen Boyd wrote:
> Use the more modern API to get the match data out of the of match table.
> This saves some code, lines, and nicely avoids referencing the match
> table when it is undefined with configurations where CONFIG_OF=n.
> 
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Grygorii Strashko <grygorii.strashko@ti.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: <linux-omap@vger.kernel.org>
> ---
> 
> Please ack so Rob can apply.
> 
>   drivers/net/ethernet/ti/davinci_mdio.c | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
> index cfff3d48807a..a4efd5e35158 100644
> --- a/drivers/net/ethernet/ti/davinci_mdio.c
> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
> @@ -358,20 +358,16 @@ static int davinci_mdio_probe(struct platform_device *pdev)
>   	}
>   
>   	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
> -		const struct of_device_id	*of_id;
> +		const struct davinci_mdio_of_param *of_mdio_data;
>   
>   		ret = davinci_mdio_probe_dt(&data->pdata, pdev);
>   		if (ret)
>   			return ret;
>   		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s", pdev->name);
>   
> -		of_id = of_match_device(davinci_mdio_of_mtable, &pdev->dev);
> -		if (of_id) {
> -			const struct davinci_mdio_of_param *of_mdio_data;
> -
> -			of_mdio_data = of_id->data;
> -			if (of_mdio_data)
> -				autosuspend_delay_ms =
> +		of_mdio_data = of_device_get_match_data(&pdev->dev);
> +		if (of_mdio_data) {
> +			autosuspend_delay_ms =
>   					of_mdio_data->autosuspend_delay_ms;
>   		}
>   	} else {
> 

Thank you.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index cfff3d48807a..a4efd5e35158 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -358,20 +358,16 @@  static int davinci_mdio_probe(struct platform_device *pdev)
 	}
 
 	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
-		const struct of_device_id	*of_id;
+		const struct davinci_mdio_of_param *of_mdio_data;
 
 		ret = davinci_mdio_probe_dt(&data->pdata, pdev);
 		if (ret)
 			return ret;
 		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s", pdev->name);
 
-		of_id = of_match_device(davinci_mdio_of_mtable, &pdev->dev);
-		if (of_id) {
-			const struct davinci_mdio_of_param *of_mdio_data;
-
-			of_mdio_data = of_id->data;
-			if (of_mdio_data)
-				autosuspend_delay_ms =
+		of_mdio_data = of_device_get_match_data(&pdev->dev);
+		if (of_mdio_data) {
+			autosuspend_delay_ms =
 					of_mdio_data->autosuspend_delay_ms;
 		}
 	} else {