netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/61] tree-wide: simplify getting .drvdata
@ 2018-04-19 14:05 Wolfram Sang
  2018-04-19 14:06 ` [PATCH 31/61] net: dsa: " Wolfram Sang
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-ide, alsa-devel, linux-iio, kernel-janitors, linux-fbdev,
	dri-devel, platform-driver-x86, Wolfram Sang, linux-mtd,
	linux-clk, ac100, devel, linux-samsung-soc, linux-rockchip,
	linux-serial, linux-input, linux-media, linux-pwm, linux-watchdog,
	linux-pm, linux-arm-msm, acpi4asus-user, greybus-dev,
	linux-mediatek, linux-tegra, linux-omap, linux-soc,
	linux-arm-kernel, linu

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);

I send this out as one patch per directory per subsystem. I think they should
be applied individually. If you prefer a broken out series per subsystem, I can
provide this as well. Just mail me.

A branch (tested by buildbot; only with all commits squashed into one commit
before) can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata

Open for other comments, suggestions, too, of course.

Here is the cocci-script I created (after <n> iterations by manually checking
samples):

@@
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
	...>

Kind regards,

   Wolfram


Wolfram Sang (61):
  ARM: plat-samsung: simplify getting .drvdata
  ata: simplify getting .drvdata
  auxdisplay: simplify getting .drvdata
  bus: simplify getting .drvdata
  clk: samsung: simplify getting .drvdata
  crypto: simplify getting .drvdata
  dma: simplify getting .drvdata
  dmaengine: dw: simplify getting .drvdata
  dmaengine: qcom: simplify getting .drvdata
  gpio: simplify getting .drvdata
  gpu: drm: msm: simplify getting .drvdata
  gpu: drm: msm: adreno: simplify getting .drvdata
  gpu: drm: msm: disp: mdp5: simplify getting .drvdata
  gpu: drm: msm: dsi: simplify getting .drvdata
  gpu: drm: omapdrm: displays: simplify getting .drvdata
  gpu: drm: vc4: simplify getting .drvdata
  hid: simplify getting .drvdata
  iio: common: cros_ec_sensors: simplify getting .drvdata
  iio: common: hid-sensors: simplify getting .drvdata
  input: keyboard: simplify getting .drvdata
  input: misc: simplify getting .drvdata
  input: mouse: simplify getting .drvdata
  input: touchscreen: simplify getting .drvdata
  iommu: simplify getting .drvdata
  media: platform: am437x: simplify getting .drvdata
  media: platform: exynos4-is: simplify getting .drvdata
  media: platform: s5p-mfc: simplify getting .drvdata
  mmc: host: simplify getting .drvdata
  mtd: devices: simplify getting .drvdata
  mtd: nand: onenand: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  net: ethernet: cadence: simplify getting .drvdata
  net: ethernet: davicom: simplify getting .drvdata
  net: ethernet: smsc: simplify getting .drvdata
  net: ethernet: ti: simplify getting .drvdata
  net: ethernet: wiznet: simplify getting .drvdata
  perf: simplify getting .drvdata
  pinctrl: simplify getting .drvdata
  pinctrl: intel: simplify getting .drvdata
  platform: x86: simplify getting .drvdata
  power: supply: simplify getting .drvdata
  ptp: simplify getting .drvdata
  pwm: simplify getting .drvdata
  rtc: simplify getting .drvdata
  slimbus: simplify getting .drvdata
  spi: simplify getting .drvdata
  staging: greybus: simplify getting .drvdata
  staging: iio: adc: simplify getting .drvdata
  staging: nvec: simplify getting .drvdata
  thermal: simplify getting .drvdata
  thermal: int340x_thermal: simplify getting .drvdata
  thermal: st: simplify getting .drvdata
  tty: serial: simplify getting .drvdata
  uio: simplify getting .drvdata
  usb: mtu3: simplify getting .drvdata
  usb: phy: simplify getting .drvdata
  video: fbdev: simplify getting .drvdata
  video: fbdev: omap2: omapfb: displays: simplify getting .drvdata
  watchdog: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  ASoC: atmel: simplify getting .drvdata

 arch/arm/plat-samsung/adc.c                        |  3 +-
 drivers/ata/pata_samsung_cf.c                      |  8 ++---
 drivers/auxdisplay/arm-charlcd.c                   |  6 ++--
 drivers/bus/brcmstb_gisb.c                         | 12 +++----
 drivers/clk/samsung/clk-s3c2410-dclk.c             |  6 ++--
 drivers/crypto/exynos-rng.c                        |  6 ++--
 drivers/crypto/picoxcell_crypto.c                  |  6 ++--
 drivers/dma/at_hdmac.c                             |  9 ++---
 drivers/dma/at_xdmac.c                             |  9 ++---
 drivers/dma/dw/platform.c                          |  6 ++--
 drivers/dma/fsldma.c                               |  6 ++--
 drivers/dma/idma64.c                               |  6 ++--
 drivers/dma/qcom/hidma.c                           |  3 +-
 drivers/dma/qcom/hidma_mgmt_sys.c                  |  6 ++--
 drivers/dma/ste_dma40.c                            | 12 +++----
 drivers/dma/txx9dmac.c                             |  8 ++---
 drivers/gpio/gpio-dwapb.c                          |  6 ++--
 drivers/gpio/gpio-lynxpoint.c                      |  3 +-
 drivers/gpio/gpio-omap.c                           | 12 +++----
 drivers/gpio/gpio-tegra.c                          |  6 ++--
 drivers/gpio/gpio-zynq.c                           |  6 ++--
 drivers/gpu/drm/msm/adreno/adreno_device.c         |  6 ++--
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c           |  6 ++--
 drivers/gpu/drm/msm/dsi/dsi_host.c                 |  6 ++--
 drivers/gpu/drm/msm/msm_drv.c                      |  3 +-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    | 18 ++++------
 drivers/gpu/drm/vc4/vc4_drv.c                      |  3 +-
 drivers/hid/hid-sensor-custom.c                    | 12 +++----
 .../common/cros_ec_sensors/cros_ec_sensors_core.c  |  6 ++--
 .../iio/common/hid-sensors/hid-sensor-trigger.c    |  9 ++---
 drivers/input/keyboard/ep93xx_keypad.c             | 10 +++---
 drivers/input/keyboard/imx_keypad.c                | 10 +++---
 drivers/input/keyboard/lpc32xx-keys.c              |  6 ++--
 drivers/input/keyboard/matrix_keypad.c             | 10 +++---
 drivers/input/keyboard/omap4-keypad.c              | 10 +++---
 drivers/input/keyboard/pmic8xxx-keypad.c           |  6 ++--
 drivers/input/keyboard/pxa27x_keypad.c             | 10 +++---
 drivers/input/keyboard/samsung-keypad.c            | 12 +++----
 drivers/input/keyboard/snvs_pwrkey.c               | 10 +++---
 drivers/input/keyboard/spear-keyboard.c            | 10 +++---
 drivers/input/keyboard/st-keyscan.c                |  6 ++--
 drivers/input/keyboard/tegra-kbc.c                 | 10 +++---
 drivers/input/misc/max77693-haptic.c               |  6 ++--
 drivers/input/misc/max8997_haptic.c                |  3 +-
 drivers/input/misc/palmas-pwrbutton.c              |  6 ++--
 drivers/input/misc/regulator-haptic.c              |  6 ++--
 drivers/input/misc/twl4030-vibra.c                 |  3 +-
 drivers/input/misc/twl6040-vibra.c                 |  3 +-
 drivers/input/mouse/navpoint.c                     |  6 ++--
 drivers/input/touchscreen/imx6ul_tsc.c             |  6 ++--
 drivers/iommu/qcom_iommu.c                         |  6 ++--
 drivers/media/platform/am437x/am437x-vpfe.c        |  6 ++--
 drivers/media/platform/exynos4-is/media-dev.c      |  6 ++--
 drivers/media/platform/exynos4-is/mipi-csis.c      |  6 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc.c           |  6 ++--
 drivers/mmc/host/davinci_mmc.c                     |  6 ++--
 drivers/mmc/host/sdhci-of-arasan.c                 |  6 ++--
 drivers/mmc/host/wmt-sdmmc.c                       |  6 ++--
 drivers/mtd/devices/docg3.c                        |  3 +-
 drivers/mtd/nand/onenand/samsung.c                 |  6 ++--
 drivers/net/dsa/bcm_sf2.c                          |  6 ++--
 drivers/net/dsa/qca8k.c                            |  6 ++--
 drivers/net/ethernet/cadence/macb_main.c           |  6 ++--
 drivers/net/ethernet/davicom/dm9000.c              |  6 ++--
 drivers/net/ethernet/smsc/smc91x.c                 |  3 +-
 drivers/net/ethernet/ti/cpsw.c                     |  6 ++--
 drivers/net/ethernet/ti/davinci_emac.c             |  6 ++--
 drivers/net/ethernet/wiznet/w5300.c                |  6 ++--
 drivers/perf/arm_spe_pmu.c                         |  6 ++--
 drivers/pinctrl/intel/pinctrl-baytrail.c           |  6 ++--
 drivers/pinctrl/intel/pinctrl-cherryview.c         |  6 ++--
 drivers/pinctrl/intel/pinctrl-intel.c              |  6 ++--
 drivers/pinctrl/pinctrl-amd.c                      |  6 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c                |  6 ++--
 drivers/platform/x86/asus-laptop.c                 |  3 +-
 drivers/platform/x86/asus-wmi.c                    |  3 +-
 drivers/platform/x86/samsung-laptop.c              |  3 +-
 drivers/power/supply/gpio-charger.c                |  3 +-
 drivers/ptp/ptp_dte.c                              |  6 ++--
 drivers/pwm/pwm-atmel-tcb.c                        |  6 ++--
 drivers/pwm/pwm-rcar.c                             |  3 +-
 drivers/rtc/rtc-bq4802.c                           |  6 ++--
 drivers/rtc/rtc-ds1216.c                           |  6 ++--
 drivers/rtc/rtc-ds1511.c                           |  9 ++---
 drivers/rtc/rtc-ds1553.c                           | 15 +++-----
 drivers/rtc/rtc-ds1685.c                           | 21 ++++-------
 drivers/rtc/rtc-ds1742.c                           |  6 ++--
 drivers/rtc/rtc-lpc32xx.c                          | 16 ++++-----
 drivers/rtc/rtc-m48t59.c                           | 41 +++++++++-------------
 drivers/rtc/rtc-mv.c                               |  3 +-
 drivers/rtc/rtc-mxc.c                              | 21 ++++-------
 drivers/rtc/rtc-pcap.c                             | 15 +++-----
 drivers/rtc/rtc-sh.c                               | 15 +++-----
 drivers/rtc/rtc-stk17ta8.c                         | 15 +++-----
 drivers/rtc/rtc-test.c                             |  3 +-
 drivers/rtc/rtc-zynqmp.c                           | 10 +++---
 drivers/slimbus/qcom-ctrl.c                        |  6 ++--
 drivers/spi/spi-cadence.c                          |  6 ++--
 drivers/spi/spi-zynqmp-gqspi.c                     |  6 ++--
 drivers/staging/greybus/arche-platform.c           |  3 +-
 drivers/staging/iio/adc/ad7606_par.c               |  6 ++--
 drivers/staging/nvec/nvec.c                        |  6 ++--
 drivers/thermal/int340x_thermal/int3400_thermal.c  |  9 ++---
 drivers/thermal/rockchip_thermal.c                 |  8 ++---
 drivers/thermal/spear_thermal.c                    |  8 ++---
 drivers/thermal/st/st_thermal.c                    |  6 ++--
 drivers/thermal/zx2967_thermal.c                   |  6 ++--
 drivers/tty/serial/imx.c                           | 18 ++++------
 drivers/tty/serial/qcom_geni_serial.c              |  6 ++--
 drivers/tty/serial/st-asc.c                        |  6 ++--
 drivers/tty/serial/xilinx_uartps.c                 |  6 ++--
 drivers/uio/uio_fsl_elbc_gpcm.c                    |  6 ++--
 drivers/usb/mtu3/mtu3_plat.c                       |  6 ++--
 drivers/usb/phy/phy-am335x.c                       |  6 ++--
 drivers/video/fbdev/auo_k190x.c                    | 12 +++----
 .../fbdev/omap2/omapfb/displays/panel-dsi-cm.c     | 18 ++++------
 drivers/video/fbdev/sh_mobile_lcdcfb.c             |  6 ++--
 drivers/video/fbdev/sh_mobile_meram.c              |  6 ++--
 drivers/watchdog/cadence_wdt.c                     |  6 ++--
 drivers/watchdog/of_xilinx_wdt.c                   |  6 ++--
 drivers/watchdog/wdat_wdt.c                        |  6 ++--
 net/dsa/legacy.c                                   |  6 ++--
 sound/soc/atmel/atmel_ssc_dai.c                    |  6 ++--
 123 files changed, 319 insertions(+), 607 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 31/61] net: dsa: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  2018-04-27  0:22   ` Florian Fainelli
  2018-04-19 14:06 ` [PATCH 32/61] net: ethernet: cadence: " Wolfram Sang
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Andrew Lunn,
	Vivien Didelot, Florian Fainelli, netdev

We should get drvdata 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. Please apply individually.

 drivers/net/dsa/bcm_sf2.c | 6 ++----
 drivers/net/dsa/qca8k.c   | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 0378eded31f2..a61b937d1a37 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1148,16 +1148,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 600d5ad1fbde..9f503e5db88a 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -910,8 +910,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);
 
@@ -920,8 +919,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);
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 32/61] net: ethernet: cadence: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
  2018-04-19 14:06 ` [PATCH 31/61] net: dsa: " Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  2018-04-19 14:06 ` [PATCH 33/61] net: ethernet: davicom: " Wolfram Sang
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Nicolas Ferre,
	netdev

We should get drvdata 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. Please apply individually.

 drivers/net/ethernet/cadence/macb_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index b4c9268100bb..136bfd5d0be9 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4056,8 +4056,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);
@@ -4079,8 +4078,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) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 33/61] net: ethernet: davicom: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
  2018-04-19 14:06 ` [PATCH 31/61] net: dsa: " Wolfram Sang
  2018-04-19 14:06 ` [PATCH 32/61] net: ethernet: cadence: " Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  2018-04-19 14:06 ` [PATCH 34/61] net: ethernet: smsc: " Wolfram Sang
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, netdev

We should get drvdata 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. Please apply individually.

 drivers/net/ethernet/davicom/dm9000.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

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 @@ dm9000_probe(struct platform_device *pdev)
 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) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 34/61] net: ethernet: smsc: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
                   ` (2 preceding siblings ...)
  2018-04-19 14:06 ` [PATCH 33/61] net: ethernet: davicom: " Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  2018-04-19 14:06 ` [PATCH 35/61] net: ethernet: ti: " Wolfram Sang
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Nicolas Pitre,
	netdev

We should get drvdata 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. Please apply individually.

 drivers/net/ethernet/smsc/smc91x.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 080428762858..3e84a499fe92 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2453,8 +2453,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)) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 35/61] net: ethernet: ti: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
                   ` (3 preceding siblings ...)
  2018-04-19 14:06 ` [PATCH 34/61] net: ethernet: smsc: " Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  2018-04-19 15:14   ` Grygorii Strashko
  2018-04-19 14:06 ` [PATCH 36/61] net: ethernet: wiznet: " Wolfram Sang
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang,
	Grygorii Strashko, linux-omap, netdev

We should get drvdata 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. Please apply individually.

 drivers/net/ethernet/ti/cpsw.c         | 6 ++----
 drivers/net/ethernet/ti/davinci_emac.c | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 30371274409d..ef0c88e71a71 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -3300,8 +3300,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) {
@@ -3324,8 +3323,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 abceea802ea1..ef223613114d 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1985,8 +1985,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);
@@ -1996,8 +1995,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);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 36/61] net: ethernet: wiznet: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
                   ` (4 preceding siblings ...)
  2018-04-19 14:06 ` [PATCH 35/61] net: ethernet: ti: " Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  2018-04-19 14:06 ` [PATCH 42/61] ptp: " Wolfram Sang
  2018-04-19 14:06 ` [PATCH 60/61] net: dsa: " Wolfram Sang
  7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, netdev

We should get drvdata 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. Please apply individually.

 drivers/net/ethernet/wiznet/w5300.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/wiznet/w5300.c b/drivers/net/ethernet/wiznet/w5300.c
index 56ae573001e8..692fc71d904d 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)) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 42/61] ptp: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
                   ` (5 preceding siblings ...)
  2018-04-19 14:06 ` [PATCH 36/61] net: ethernet: wiznet: " Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  2018-04-19 14:06 ` [PATCH 60/61] net: dsa: " Wolfram Sang
  7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Richard Cochran,
	netdev

We should get drvdata 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. Please apply individually.

 drivers/ptp/ptp_dte.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/ptp/ptp_dte.c b/drivers/ptp/ptp_dte.c
index 6edd3b9c7f01..5481a27d4fec 100644
--- a/drivers/ptp/ptp_dte.c
+++ b/drivers/ptp/ptp_dte.c
@@ -287,8 +287,7 @@ static int ptp_dte_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int ptp_dte_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct ptp_dte *ptp_dte = platform_get_drvdata(pdev);
+	struct ptp_dte *ptp_dte = dev_get_drvdata(dev);
 	u8 i;
 
 	for (i = 0; i < DTE_NUM_REGS_TO_RESTORE; i++) {
@@ -304,8 +303,7 @@ static int ptp_dte_suspend(struct device *dev)
 
 static int ptp_dte_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct ptp_dte *ptp_dte = platform_get_drvdata(pdev);
+	struct ptp_dte *ptp_dte = dev_get_drvdata(dev);
 	u8 i;
 
 	for (i = 0; i < DTE_NUM_REGS_TO_RESTORE; i++) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 60/61] net: dsa: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
                   ` (6 preceding siblings ...)
  2018-04-19 14:06 ` [PATCH 42/61] ptp: " Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  7 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Andrew Lunn,
	Vivien Didelot, Florian Fainelli, David S. Miller, netdev

We should get drvdata 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. Please apply individually.

 net/dsa/legacy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index 42a7b85b84e1..f8d6b212328f 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -687,8 +687,7 @@ static void dsa_shutdown(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int dsa_suspend(struct device *d)
 {
-	struct platform_device *pdev = to_platform_device(d);
-	struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
+	struct dsa_switch_tree *dst = dev_get_drvdata(d);
 	int i, ret = 0;
 
 	for (i = 0; i < dst->pd->nr_chips; i++) {
@@ -703,8 +702,7 @@ static int dsa_suspend(struct device *d)
 
 static int dsa_resume(struct device *d)
 {
-	struct platform_device *pdev = to_platform_device(d);
-	struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
+	struct dsa_switch_tree *dst = dev_get_drvdata(d);
 	int i, ret = 0;
 
 	for (i = 0; i < dst->pd->nr_chips; i++) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 35/61] net: ethernet: ti: simplify getting .drvdata
  2018-04-19 14:06 ` [PATCH 35/61] net: ethernet: ti: " Wolfram Sang
@ 2018-04-19 15:14   ` Grygorii Strashko
  0 siblings, 0 replies; 11+ messages in thread
From: Grygorii Strashko @ 2018-04-19 15:14 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, linux-omap, netdev



On 04/19/2018 09:06 AM, Wolfram Sang wrote:
> We should get drvdata 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. Please apply individually.

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

-- 
regards,
-grygorii

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 31/61] net: dsa: simplify getting .drvdata
  2018-04-19 14:06 ` [PATCH 31/61] net: dsa: " Wolfram Sang
@ 2018-04-27  0:22   ` Florian Fainelli
  0 siblings, 0 replies; 11+ messages in thread
From: Florian Fainelli @ 2018-04-27  0:22 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Andrew Lunn, Vivien Didelot,
	netdev

On 04/19/2018 07:06 AM, Wolfram Sang wrote:
> We should get drvdata 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. Please apply individually.

Similar to my other comment on patch 4, would not you want to use
dev_set_drvdata() to be consistent? This would be functionally equivalent.
--
Florian

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-04-27  0:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
2018-04-19 14:06 ` [PATCH 31/61] net: dsa: " Wolfram Sang
2018-04-27  0:22   ` Florian Fainelli
2018-04-19 14:06 ` [PATCH 32/61] net: ethernet: cadence: " Wolfram Sang
2018-04-19 14:06 ` [PATCH 33/61] net: ethernet: davicom: " Wolfram Sang
2018-04-19 14:06 ` [PATCH 34/61] net: ethernet: smsc: " Wolfram Sang
2018-04-19 14:06 ` [PATCH 35/61] net: ethernet: ti: " Wolfram Sang
2018-04-19 15:14   ` Grygorii Strashko
2018-04-19 14:06 ` [PATCH 36/61] net: ethernet: wiznet: " Wolfram Sang
2018-04-19 14:06 ` [PATCH 42/61] ptp: " Wolfram Sang
2018-04-19 14:06 ` [PATCH 60/61] net: dsa: " Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).