diff options
author | David S. Miller <davem@davemloft.net> | 2018-10-22 07:10:12 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-10-22 07:10:12 +0300 |
commit | 92303c86b7e9b7d3895ccafb441a0354143e2a18 (patch) | |
tree | 0ac0480f6c4131437de72933de2adb0132d4be0c | |
parent | 21ea1d36f6dfcb1d59184937c672022d5d01902a (diff) | |
parent | 2c67e33de2d3f2350cff2e131f5aa8d7f1ff6f9f (diff) | |
download | linux-92303c86b7e9b7d3895ccafb441a0354143e2a18.tar.xz |
Merge branch 'net-simplify-getting-driver_data'
Wolfram Sang says:
====================
net: simplify getting .driver_data
I got tired of fixing this in Renesas drivers manually, so I took the big
hammer. Remove this cumbersome code pattern which got copy-pasted too much
already:
- struct platform_device *pdev = to_platform_device(dev);
- struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+ struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
A branch, tested by buildbot, can be found here:
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata
I have been asked if it couldn't be done for dev_set_drvdata as well. I checked
it and did not find one occasion where it could be simplified like this. Not
much of a surprise because driver_data is usually set in probe() functions
which access struct platform_device in many other ways.
I am open for other comments, suggestions, too, of course.
Here is the cocci-script I created:
@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
- struct platform_device *pdev = to_platform_device(d);
|
- struct platform_device *pdev;
...
- pdev = to_platform_device(d);
)
<... when != pdev
- &pdev->dev
+ d
...>
ptr =
- platform_get_drvdata(pdev)
+ dev_get_drvdata(d)
<... when != pdev
- &pdev->dev
+ d
...>
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/dsa/bcm_sf2.c | 6 | ||||
-rw-r--r-- | drivers/net/dsa/qca8k.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/cadence/macb_main.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/davicom/dm9000.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/smsc/smc91x.c | 3 | ||||
-rw-r--r-- | drivers/net/ethernet/ti/cpsw.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/ti/davinci_emac.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/wiznet/w5300.c | 6 | ||||
-rw-r--r-- | drivers/net/phy/mdio-mux-bcm-iproc.c | 6 |
9 files changed, 17 insertions, 34 deletions
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index 3017ecf82ca5..2eb68769562c 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c @@ -1190,16 +1190,14 @@ static void bcm_sf2_sw_shutdown(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int bcm_sf2_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct bcm_sf2_priv *priv = platform_get_drvdata(pdev); + struct bcm_sf2_priv *priv = dev_get_drvdata(dev); return dsa_switch_suspend(priv->dev->ds); } static int bcm_sf2_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct bcm_sf2_priv *priv = platform_get_drvdata(pdev); + struct bcm_sf2_priv *priv = dev_get_drvdata(dev); return dsa_switch_resume(priv->dev->ds); } diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index cdcde7f8e0b2..7e97e620bd44 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -955,8 +955,7 @@ qca8k_set_pm(struct qca8k_priv *priv, int enable) static int qca8k_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct qca8k_priv *priv = platform_get_drvdata(pdev); + struct qca8k_priv *priv = dev_get_drvdata(dev); qca8k_set_pm(priv, 0); @@ -965,8 +964,7 @@ static int qca8k_suspend(struct device *dev) static int qca8k_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct qca8k_priv *priv = platform_get_drvdata(pdev); + struct qca8k_priv *priv = dev_get_drvdata(dev); qca8k_set_pm(priv, 1); diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 0acaef3ef548..8f5bf9166c11 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -4156,8 +4156,7 @@ static int macb_remove(struct platform_device *pdev) static int __maybe_unused macb_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *netdev = platform_get_drvdata(pdev); + struct net_device *netdev = dev_get_drvdata(dev); struct macb *bp = netdev_priv(netdev); netif_carrier_off(netdev); @@ -4179,8 +4178,7 @@ static int __maybe_unused macb_suspend(struct device *dev) static int __maybe_unused macb_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *netdev = platform_get_drvdata(pdev); + struct net_device *netdev = dev_get_drvdata(dev); struct macb *bp = netdev_priv(netdev); if (bp->wol & MACB_WOL_ENABLED) { diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c index 50222b7b81f3..0a82fcf16d35 100644 --- a/drivers/net/ethernet/davicom/dm9000.c +++ b/drivers/net/ethernet/davicom/dm9000.c @@ -1722,8 +1722,7 @@ out: static int dm9000_drv_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); struct board_info *db; if (ndev) { @@ -1745,8 +1744,7 @@ dm9000_drv_suspend(struct device *dev) static int dm9000_drv_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); struct board_info *db = netdev_priv(ndev); if (ndev) { diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c index 8d6cff8bd162..4823b6a51134 100644 --- a/drivers/net/ethernet/smsc/smc91x.c +++ b/drivers/net/ethernet/smsc/smc91x.c @@ -2447,8 +2447,7 @@ static int smc_drv_remove(struct platform_device *pdev) static int smc_drv_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); if (ndev) { if (netif_running(ndev)) { diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 226be2a56c1f..6cf4d4cb152e 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -3669,8 +3669,7 @@ static int cpsw_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int cpsw_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); struct cpsw_common *cpsw = ndev_to_cpsw(ndev); if (cpsw->data.dual_emac) { @@ -3693,8 +3692,7 @@ static int cpsw_suspend(struct device *dev) static int cpsw_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); struct cpsw_common *cpsw = ndev_to_cpsw(ndev); /* Select default pin state */ diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index f270beebb428..9153db120352 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -2002,8 +2002,7 @@ static int davinci_emac_remove(struct platform_device *pdev) static int davinci_emac_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); if (netif_running(ndev)) emac_dev_stop(ndev); @@ -2013,8 +2012,7 @@ static int davinci_emac_suspend(struct device *dev) static int davinci_emac_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); if (netif_running(ndev)) emac_dev_open(ndev); diff --git a/drivers/net/ethernet/wiznet/w5300.c b/drivers/net/ethernet/wiznet/w5300.c index 80fdbff67d82..f9da5d6172e3 100644 --- a/drivers/net/ethernet/wiznet/w5300.c +++ b/drivers/net/ethernet/wiznet/w5300.c @@ -661,8 +661,7 @@ static int w5300_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int w5300_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); struct w5300_priv *priv = netdev_priv(ndev); if (netif_running(ndev)) { @@ -676,8 +675,7 @@ static int w5300_suspend(struct device *dev) static int w5300_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); struct w5300_priv *priv = netdev_priv(ndev); if (!netif_running(ndev)) { diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c index c017486e9b86..696bdf1e4576 100644 --- a/drivers/net/phy/mdio-mux-bcm-iproc.c +++ b/drivers/net/phy/mdio-mux-bcm-iproc.c @@ -289,8 +289,7 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int mdio_mux_iproc_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct iproc_mdiomux_desc *md = platform_get_drvdata(pdev); + struct iproc_mdiomux_desc *md = dev_get_drvdata(dev); clk_disable_unprepare(md->core_clk); @@ -299,8 +298,7 @@ static int mdio_mux_iproc_suspend(struct device *dev) static int mdio_mux_iproc_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct iproc_mdiomux_desc *md = platform_get_drvdata(pdev); + struct iproc_mdiomux_desc *md = dev_get_drvdata(dev); clk_prepare_enable(md->core_clk); mdio_mux_iproc_config(md); |