diff mbox series

[7/9] net: mdio: mdio-bcm-iproc: simplify getting .driver_data

Message ID 20210920090522.23784-8-wsa+renesas@sang-engineering.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series treewide: simplify getting .driver_data | expand

Commit Message

Wolfram Sang Sept. 20, 2021, 9:05 a.m. UTC
We should get 'driver_data' from 'struct device' directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Build tested only. buildbot is happy.

 drivers/net/mdio/mdio-bcm-iproc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Florian Fainelli Sept. 20, 2021, 9:56 p.m. UTC | #1
On 9/20/21 2:05 AM, Wolfram Sang wrote:
> We should get 'driver_data' from 'struct device' directly. Going via
> platform_device is an unneeded step back and forth.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Build tested only. buildbot is happy.
> 
>  drivers/net/mdio/mdio-bcm-iproc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mdio/mdio-bcm-iproc.c b/drivers/net/mdio/mdio-bcm-iproc.c
> index 77fc970cdfde..5666cfab15b9 100644
> --- a/drivers/net/mdio/mdio-bcm-iproc.c
> +++ b/drivers/net/mdio/mdio-bcm-iproc.c
> @@ -181,8 +181,7 @@ static int iproc_mdio_remove(struct platform_device *pdev)
>  #ifdef CONFIG_PM_SLEEP
>  static int iproc_mdio_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct iproc_mdio_priv *priv = platform_get_drvdata(pdev);
> +	struct iproc_mdio_priv *priv = dev_get_drvdata(dev);

The change looks good to me, however if you change from
platform_get_drvdata() to dev_get_drvdata(), you might also want to
change from using platform_set_drvdata() to dev_set_drvdata() for
symmetry no? If not, then maybe this patch should be dropped?
Wolfram Sang Sept. 21, 2021, 5:52 a.m. UTC | #2
> The change looks good to me, however if you change from
> platform_get_drvdata() to dev_get_drvdata(), you might also want to
> change from using platform_set_drvdata() to dev_set_drvdata() for
> symmetry no? If not, then maybe this patch should be dropped?

In theory, yes. However, I haven't finished the coccinelle script yet
because there are a lot more usage patterns. I can do this individually
for this driver first if you want.
diff mbox series

Patch

diff --git a/drivers/net/mdio/mdio-bcm-iproc.c b/drivers/net/mdio/mdio-bcm-iproc.c
index 77fc970cdfde..5666cfab15b9 100644
--- a/drivers/net/mdio/mdio-bcm-iproc.c
+++ b/drivers/net/mdio/mdio-bcm-iproc.c
@@ -181,8 +181,7 @@  static int iproc_mdio_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int iproc_mdio_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct iproc_mdio_priv *priv = platform_get_drvdata(pdev);
+	struct iproc_mdio_priv *priv = dev_get_drvdata(dev);
 
 	/* restore the mii clock configuration */
 	iproc_mdio_config_clk(priv->base);