public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/61] tree-wide: simplify getting .drvdata
@ 2018-04-19 14:05 Wolfram Sang
  2018-04-19 14:05 ` [PATCH 10/61] gpio: " Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ 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

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] 21+ messages in thread

* [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
@ 2018-04-19 14:05 ` Wolfram Sang
  2018-04-19 15:14   ` Grygorii Strashko
  2018-04-20  7:20   ` Michal Simek
  2018-04-19 14:05 ` [PATCH 20/61] input: keyboard: " Wolfram Sang
  2018-04-19 14:06 ` [PATCH 49/61] staging: nvec: " Wolfram Sang
  2 siblings, 2 replies; 21+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: Grygorii Strashko, Kevin Hilman, Linus Walleij, Hoan Tran,
	kernel-janitors, Michal Simek, Jonathan Hunter, linux-renesas-soc,
	Wolfram Sang, Thierry Reding, linux-gpio, Santosh Shilimkar,
	linux-tegra, linux-omap, linux-arm-kernel

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/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 ++----
 5 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index 226977f78482..caaabb79e31f 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -732,8 +732,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int dwapb_gpio_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct dwapb_gpio *gpio = platform_get_drvdata(pdev);
+	struct dwapb_gpio *gpio = dev_get_drvdata(dev);
 	struct gpio_chip *gc	= &gpio->ports[0].gc;
 	unsigned long flags;
 	int i;
@@ -777,8 +776,7 @@ static int dwapb_gpio_suspend(struct device *dev)
 
 static int dwapb_gpio_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct dwapb_gpio *gpio = platform_get_drvdata(pdev);
+	struct dwapb_gpio *gpio = dev_get_drvdata(dev);
 	struct gpio_chip *gc	= &gpio->ports[0].gc;
 	unsigned long flags;
 	int i;
diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c
index 1e557b10d73e..55fa33b7209f 100644
--- a/drivers/gpio/gpio-lynxpoint.c
+++ b/drivers/gpio/gpio-lynxpoint.c
@@ -408,8 +408,7 @@ static int lp_gpio_runtime_resume(struct device *dev)
 
 static int lp_gpio_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct lp_gpio *lg = platform_get_drvdata(pdev);
+	struct lp_gpio *lg = dev_get_drvdata(dev);
 	unsigned long reg;
 	int i;
 
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 35971a341c40..b4f8a048a2a1 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -856,8 +856,7 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
 
 static int omap_mpuio_suspend_noirq(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct gpio_bank	*bank = platform_get_drvdata(pdev);
+	struct gpio_bank	*bank = dev_get_drvdata(dev);
 	void __iomem		*mask_reg = bank->base +
 					OMAP_MPUIO_GPIO_MASKIT / bank->stride;
 	unsigned long		flags;
@@ -871,8 +870,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
 
 static int omap_mpuio_resume_noirq(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct gpio_bank	*bank = platform_get_drvdata(pdev);
+	struct gpio_bank	*bank = dev_get_drvdata(dev);
 	void __iomem		*mask_reg = bank->base +
 					OMAP_MPUIO_GPIO_MASKIT / bank->stride;
 	unsigned long		flags;
@@ -1284,8 +1282,7 @@ static void omap_gpio_restore_context(struct gpio_bank *bank);
 
 static int omap_gpio_runtime_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct gpio_bank *bank = platform_get_drvdata(pdev);
+	struct gpio_bank *bank = dev_get_drvdata(dev);
 	u32 l1 = 0, l2 = 0;
 	unsigned long flags;
 	u32 wake_low, wake_hi;
@@ -1352,8 +1349,7 @@ static void omap_gpio_init_context(struct gpio_bank *p);
 
 static int omap_gpio_runtime_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct gpio_bank *bank = platform_get_drvdata(pdev);
+	struct gpio_bank *bank = dev_get_drvdata(dev);
 	u32 l = 0, gen, gen0, gen1;
 	unsigned long flags;
 	int c;
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 94396caaca75..04c963f03b68 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -403,8 +403,7 @@ static void tegra_gpio_irq_handler(struct irq_desc *desc)
 #ifdef CONFIG_PM_SLEEP
 static int tegra_gpio_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct tegra_gpio_info *tgi = platform_get_drvdata(pdev);
+	struct tegra_gpio_info *tgi = dev_get_drvdata(dev);
 	unsigned long flags;
 	unsigned int b, p;
 
@@ -443,8 +442,7 @@ static int tegra_gpio_resume(struct device *dev)
 
 static int tegra_gpio_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct tegra_gpio_info *tgi = platform_get_drvdata(pdev);
+	struct tegra_gpio_info *tgi = dev_get_drvdata(dev);
 	unsigned long flags;
 	unsigned int b, p;
 
diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index 75ee877e5cd5..49534241bb1e 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -697,8 +697,7 @@ static int __maybe_unused zynq_gpio_resume(struct device *dev)
 
 static int __maybe_unused zynq_gpio_runtime_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct zynq_gpio *gpio = platform_get_drvdata(pdev);
+	struct zynq_gpio *gpio = dev_get_drvdata(dev);
 
 	clk_disable_unprepare(gpio->clk);
 
@@ -707,8 +706,7 @@ static int __maybe_unused zynq_gpio_runtime_suspend(struct device *dev)
 
 static int __maybe_unused zynq_gpio_runtime_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct zynq_gpio *gpio = platform_get_drvdata(pdev);
+	struct zynq_gpio *gpio = dev_get_drvdata(dev);
 
 	return clk_prepare_enable(gpio->clk);
 }
-- 
2.11.0

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

* [PATCH 20/61] input: keyboard: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
  2018-04-19 14:05 ` [PATCH 10/61] gpio: " Wolfram Sang
@ 2018-04-19 14:05 ` Wolfram Sang
  2018-04-26 19:19   ` Dmitry Torokhov
  2018-04-19 14:06 ` [PATCH 49/61] staging: nvec: " Wolfram Sang
  2 siblings, 1 reply; 21+ messages in thread
From: Wolfram Sang @ 2018-04-19 14:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Wolfram Sang, Dmitry Torokhov,
	Vladimir Zapolskiy, Sylvain Lemieux, Rakesh Iyer, Laxman Dewangan,
	Thierry Reding, Jonathan Hunter, linux-input, linux-arm-kernel,
	linux-tegra

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/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 ++++------
 12 files changed, 42 insertions(+), 68 deletions(-)

diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index f77b295e0123..7584a03db4b3 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -185,8 +185,7 @@ static void ep93xx_keypad_close(struct input_dev *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int ep93xx_keypad_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
 	struct input_dev *input_dev = keypad->input_dev;
 
 	mutex_lock(&input_dev->mutex);
@@ -198,7 +197,7 @@ static int ep93xx_keypad_suspend(struct device *dev)
 
 	mutex_unlock(&input_dev->mutex);
 
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		enable_irq_wake(keypad->irq);
 
 	return 0;
@@ -206,11 +205,10 @@ static int ep93xx_keypad_suspend(struct device *dev)
 
 static int ep93xx_keypad_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
 	struct input_dev *input_dev = keypad->input_dev;
 
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		disable_irq_wake(keypad->irq);
 
 	mutex_lock(&input_dev->mutex);
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 25d61d8d4fc4..56328ced81e2 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -532,8 +532,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
 
 static int __maybe_unused imx_kbd_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct imx_keypad *kbd = platform_get_drvdata(pdev);
+	struct imx_keypad *kbd = dev_get_drvdata(dev);
 	struct input_dev *input_dev = kbd->input_dev;
 
 	/* imx kbd can wake up system even clock is disabled */
@@ -544,7 +543,7 @@ static int __maybe_unused imx_kbd_suspend(struct device *dev)
 
 	mutex_unlock(&input_dev->mutex);
 
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		enable_irq_wake(kbd->irq);
 
 	return 0;
@@ -552,12 +551,11 @@ static int __maybe_unused imx_kbd_suspend(struct device *dev)
 
 static int __maybe_unused imx_kbd_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct imx_keypad *kbd = platform_get_drvdata(pdev);
+	struct imx_keypad *kbd = dev_get_drvdata(dev);
 	struct input_dev *input_dev = kbd->input_dev;
 	int ret = 0;
 
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		disable_irq_wake(kbd->irq);
 
 	mutex_lock(&input_dev->mutex);
diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c
index 1dd57ac0e7a2..0831a6f2a9d4 100644
--- a/drivers/input/keyboard/lpc32xx-keys.c
+++ b/drivers/input/keyboard/lpc32xx-keys.c
@@ -279,8 +279,7 @@ static int lpc32xx_kscan_probe(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int lpc32xx_kscan_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
+	struct lpc32xx_kscan_drv *kscandat = dev_get_drvdata(dev);
 	struct input_dev *input = kscandat->input;
 
 	mutex_lock(&input->mutex);
@@ -297,8 +296,7 @@ static int lpc32xx_kscan_suspend(struct device *dev)
 
 static int lpc32xx_kscan_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
+	struct lpc32xx_kscan_drv *kscandat = dev_get_drvdata(dev);
 	struct input_dev *input = kscandat->input;
 	int retval = 0;
 
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 41614c185918..73ca55e4babe 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -276,12 +276,11 @@ static void matrix_keypad_disable_wakeup(struct matrix_keypad *keypad)
 
 static int matrix_keypad_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct matrix_keypad *keypad = platform_get_drvdata(pdev);
+	struct matrix_keypad *keypad = dev_get_drvdata(dev);
 
 	matrix_keypad_stop(keypad->input_dev);
 
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		matrix_keypad_enable_wakeup(keypad);
 
 	return 0;
@@ -289,10 +288,9 @@ static int matrix_keypad_suspend(struct device *dev)
 
 static int matrix_keypad_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct matrix_keypad *keypad = platform_get_drvdata(pdev);
+	struct matrix_keypad *keypad = dev_get_drvdata(dev);
 
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		matrix_keypad_disable_wakeup(keypad);
 
 	matrix_keypad_start(keypad->input_dev);
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 940d38b08e6b..13578b884ace 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -422,11 +422,10 @@ MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
 #ifdef CONFIG_PM_SLEEP
 static int omap4_keypad_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
+	struct omap4_keypad *keypad_data = dev_get_drvdata(dev);
 	int error;
 
-	if (device_may_wakeup(&pdev->dev)) {
+	if (device_may_wakeup(dev)) {
 		error = enable_irq_wake(keypad_data->irq);
 		if (!error)
 			keypad_data->irq_wake_enabled = true;
@@ -437,10 +436,9 @@ static int omap4_keypad_suspend(struct device *dev)
 
 static int omap4_keypad_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
+	struct omap4_keypad *keypad_data = dev_get_drvdata(dev);
 
-	if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) {
+	if (device_may_wakeup(dev) && keypad_data->irq_wake_enabled) {
 		disable_irq_wake(keypad_data->irq);
 		keypad_data->irq_wake_enabled = false;
 	}
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
index 98b24ed18752..048a39321298 100644
--- a/drivers/input/keyboard/pmic8xxx-keypad.c
+++ b/drivers/input/keyboard/pmic8xxx-keypad.c
@@ -636,8 +636,7 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int pmic8xxx_kp_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
+	struct pmic8xxx_kp *kp = dev_get_drvdata(dev);
 	struct input_dev *input_dev = kp->input;
 
 	if (device_may_wakeup(dev)) {
@@ -656,8 +655,7 @@ static int pmic8xxx_kp_suspend(struct device *dev)
 
 static int pmic8xxx_kp_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
+	struct pmic8xxx_kp *kp = dev_get_drvdata(dev);
 	struct input_dev *input_dev = kp->input;
 
 	if (device_may_wakeup(dev)) {
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index d0bdaeadf86d..1f54a3162124 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -666,14 +666,13 @@ static void pxa27x_keypad_close(struct input_dev *dev)
 #ifdef CONFIG_PM_SLEEP
 static int pxa27x_keypad_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
+	struct pxa27x_keypad *keypad = dev_get_drvdata(dev);
 
 	/*
 	 * If the keypad is used a wake up source, clock can not be disabled.
 	 * Or it can not detect the key pressing.
 	 */
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		enable_irq_wake(keypad->irq);
 	else
 		clk_disable_unprepare(keypad->clk);
@@ -683,8 +682,7 @@ static int pxa27x_keypad_suspend(struct device *dev)
 
 static int pxa27x_keypad_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
+	struct pxa27x_keypad *keypad = dev_get_drvdata(dev);
 	struct input_dev *input_dev = keypad->input_dev;
 	int ret = 0;
 
@@ -692,7 +690,7 @@ static int pxa27x_keypad_resume(struct device *dev)
 	 * If the keypad is used as wake up source, the clock is not turned
 	 * off. So do not need configure it again.
 	 */
-	if (device_may_wakeup(&pdev->dev)) {
+	if (device_may_wakeup(dev)) {
 		disable_irq_wake(keypad->irq);
 	} else {
 		mutex_lock(&input_dev->mutex);
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 316414465c77..27790a8a44f5 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -466,8 +466,7 @@ static int samsung_keypad_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM
 static int samsung_keypad_runtime_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct samsung_keypad *keypad = platform_get_drvdata(pdev);
+	struct samsung_keypad *keypad = dev_get_drvdata(dev);
 	unsigned int val;
 	int error;
 
@@ -490,8 +489,7 @@ static int samsung_keypad_runtime_suspend(struct device *dev)
 
 static int samsung_keypad_runtime_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct samsung_keypad *keypad = platform_get_drvdata(pdev);
+	struct samsung_keypad *keypad = dev_get_drvdata(dev);
 	unsigned int val;
 
 	if (keypad->stopped)
@@ -535,8 +533,7 @@ static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad,
 
 static int samsung_keypad_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct samsung_keypad *keypad = platform_get_drvdata(pdev);
+	struct samsung_keypad *keypad = dev_get_drvdata(dev);
 	struct input_dev *input_dev = keypad->input_dev;
 
 	mutex_lock(&input_dev->mutex);
@@ -553,8 +550,7 @@ static int samsung_keypad_suspend(struct device *dev)
 
 static int samsung_keypad_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct samsung_keypad *keypad = platform_get_drvdata(pdev);
+	struct samsung_keypad *keypad = dev_get_drvdata(dev);
 	struct input_dev *input_dev = keypad->input_dev;
 
 	mutex_lock(&input_dev->mutex);
diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index 53c768b95939..f439f7bd2f5f 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -180,10 +180,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 
 static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
+	struct pwrkey_drv_data *pdata = dev_get_drvdata(dev);
 
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		enable_irq_wake(pdata->irq);
 
 	return 0;
@@ -191,10 +190,9 @@ static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
 
 static int __maybe_unused imx_snvs_pwrkey_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
+	struct pwrkey_drv_data *pdata = dev_get_drvdata(dev);
 
-	if (device_may_wakeup(&pdev->dev))
+	if (device_may_wakeup(dev))
 		disable_irq_wake(pdata->irq);
 
 	return 0;
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 7d25fa338ab4..a0276a3376d2 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -288,8 +288,7 @@ static int spear_kbd_remove(struct platform_device *pdev)
 
 static int __maybe_unused spear_kbd_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct spear_kbd *kbd = platform_get_drvdata(pdev);
+	struct spear_kbd *kbd = dev_get_drvdata(dev);
 	struct input_dev *input_dev = kbd->input;
 	unsigned int rate = 0, mode_ctl_reg, val;
 
@@ -300,7 +299,7 @@ static int __maybe_unused spear_kbd_suspend(struct device *dev)
 
 	mode_ctl_reg = readl_relaxed(kbd->io_base + MODE_CTL_REG);
 
-	if (device_may_wakeup(&pdev->dev)) {
+	if (device_may_wakeup(dev)) {
 		if (!enable_irq_wake(kbd->irq))
 			kbd->irq_wake_enabled = true;
 
@@ -341,13 +340,12 @@ static int __maybe_unused spear_kbd_suspend(struct device *dev)
 
 static int __maybe_unused spear_kbd_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct spear_kbd *kbd = platform_get_drvdata(pdev);
+	struct spear_kbd *kbd = dev_get_drvdata(dev);
 	struct input_dev *input_dev = kbd->input;
 
 	mutex_lock(&input_dev->mutex);
 
-	if (device_may_wakeup(&pdev->dev)) {
+	if (device_may_wakeup(dev)) {
 		if (kbd->irq_wake_enabled) {
 			kbd->irq_wake_enabled = false;
 			disable_irq_wake(kbd->irq);
diff --git a/drivers/input/keyboard/st-keyscan.c b/drivers/input/keyboard/st-keyscan.c
index babcfb165e4f..3b4727e4b411 100644
--- a/drivers/input/keyboard/st-keyscan.c
+++ b/drivers/input/keyboard/st-keyscan.c
@@ -218,8 +218,7 @@ static int keyscan_probe(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int keyscan_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct st_keyscan *keypad = platform_get_drvdata(pdev);
+	struct st_keyscan *keypad = dev_get_drvdata(dev);
 	struct input_dev *input = keypad->input_dev;
 
 	mutex_lock(&input->mutex);
@@ -235,8 +234,7 @@ static int keyscan_suspend(struct device *dev)
 
 static int keyscan_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct st_keyscan *keypad = platform_get_drvdata(pdev);
+	struct st_keyscan *keypad = dev_get_drvdata(dev);
 	struct input_dev *input = keypad->input_dev;
 	int retval = 0;
 
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index 875205f445b5..861bfcbd817d 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -744,11 +744,10 @@ static void tegra_kbc_set_keypress_interrupt(struct tegra_kbc *kbc, bool enable)
 
 static int tegra_kbc_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct tegra_kbc *kbc = platform_get_drvdata(pdev);
+	struct tegra_kbc *kbc = dev_get_drvdata(dev);
 
 	mutex_lock(&kbc->idev->mutex);
-	if (device_may_wakeup(&pdev->dev)) {
+	if (device_may_wakeup(dev)) {
 		disable_irq(kbc->irq);
 		del_timer_sync(&kbc->timer);
 		tegra_kbc_set_fifo_interrupt(kbc, false);
@@ -781,12 +780,11 @@ static int tegra_kbc_suspend(struct device *dev)
 
 static int tegra_kbc_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct tegra_kbc *kbc = platform_get_drvdata(pdev);
+	struct tegra_kbc *kbc = dev_get_drvdata(dev);
 	int err = 0;
 
 	mutex_lock(&kbc->idev->mutex);
-	if (device_may_wakeup(&pdev->dev)) {
+	if (device_may_wakeup(dev)) {
 		disable_irq_wake(kbc->irq);
 		tegra_kbc_setup_wakekeys(kbc, false);
 		/* We will use fifo interrupts for key detection. */
-- 
2.11.0

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

* [PATCH 49/61] staging: nvec: simplify getting .drvdata
  2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
  2018-04-19 14:05 ` [PATCH 10/61] gpio: " Wolfram Sang
  2018-04-19 14:05 ` [PATCH 20/61] input: keyboard: " Wolfram Sang
@ 2018-04-19 14:06 ` Wolfram Sang
  2018-04-20  8:45   ` Marc Dietrich
  2 siblings, 1 reply; 21+ 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, Marc Dietrich,
	Greg Kroah-Hartman, ac100, linux-tegra, devel

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/staging/nvec/nvec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 52054a528723..2a5e0dcf4162 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -925,8 +925,7 @@ static int tegra_nvec_remove(struct platform_device *pdev)
 static int nvec_suspend(struct device *dev)
 {
 	int err;
-	struct platform_device *pdev = to_platform_device(dev);
-	struct nvec_chip *nvec = platform_get_drvdata(pdev);
+	struct nvec_chip *nvec = dev_get_drvdata(dev);
 	struct nvec_msg *msg;
 	char ap_suspend[] = { NVEC_SLEEP, AP_SUSPEND };
 
@@ -946,8 +945,7 @@ static int nvec_suspend(struct device *dev)
 
 static int nvec_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct nvec_chip *nvec = platform_get_drvdata(pdev);
+	struct nvec_chip *nvec = dev_get_drvdata(dev);
 
 	dev_dbg(nvec->dev, "resuming\n");
 	tegra_init_i2c_slave(nvec);
-- 
2.11.0

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-19 14:05 ` [PATCH 10/61] gpio: " Wolfram Sang
@ 2018-04-19 15:14   ` Grygorii Strashko
  2018-04-30  9:03     ` Linus Walleij
  2018-04-20  7:20   ` Michal Simek
  1 sibling, 1 reply; 21+ 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, Hoan Tran, Linus Walleij,
	Santosh Shilimkar, Kevin Hilman, Thierry Reding, Jonathan Hunter,
	Michal Simek, linux-gpio, linux-omap, linux-tegra,
	linux-arm-kernel



On 04/19/2018 09:05 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.

for gpio-omap.c:
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> 
>   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 ++----
>   5 files changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
> index 226977f78482..caaabb79e31f 100644
> --- a/drivers/gpio/gpio-dwapb.c
> +++ b/drivers/gpio/gpio-dwapb.c
> @@ -732,8 +732,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
>   #ifdef CONFIG_PM_SLEEP
>   static int dwapb_gpio_suspend(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct dwapb_gpio *gpio = platform_get_drvdata(pdev);
> +	struct dwapb_gpio *gpio = dev_get_drvdata(dev);
>   	struct gpio_chip *gc	= &gpio->ports[0].gc;
>   	unsigned long flags;
>   	int i;
> @@ -777,8 +776,7 @@ static int dwapb_gpio_suspend(struct device *dev)
>   
>   static int dwapb_gpio_resume(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct dwapb_gpio *gpio = platform_get_drvdata(pdev);
> +	struct dwapb_gpio *gpio = dev_get_drvdata(dev);
>   	struct gpio_chip *gc	= &gpio->ports[0].gc;
>   	unsigned long flags;
>   	int i;
> diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c
> index 1e557b10d73e..55fa33b7209f 100644
> --- a/drivers/gpio/gpio-lynxpoint.c
> +++ b/drivers/gpio/gpio-lynxpoint.c
> @@ -408,8 +408,7 @@ static int lp_gpio_runtime_resume(struct device *dev)
>   
>   static int lp_gpio_resume(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct lp_gpio *lg = platform_get_drvdata(pdev);
> +	struct lp_gpio *lg = dev_get_drvdata(dev);
>   	unsigned long reg;
>   	int i;
>   
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 35971a341c40..b4f8a048a2a1 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -856,8 +856,7 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
>   
>   static int omap_mpuio_suspend_noirq(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct gpio_bank	*bank = platform_get_drvdata(pdev);
> +	struct gpio_bank	*bank = dev_get_drvdata(dev);
>   	void __iomem		*mask_reg = bank->base +
>   					OMAP_MPUIO_GPIO_MASKIT / bank->stride;
>   	unsigned long		flags;
> @@ -871,8 +870,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
>   
>   static int omap_mpuio_resume_noirq(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct gpio_bank	*bank = platform_get_drvdata(pdev);
> +	struct gpio_bank	*bank = dev_get_drvdata(dev);
>   	void __iomem		*mask_reg = bank->base +
>   					OMAP_MPUIO_GPIO_MASKIT / bank->stride;
>   	unsigned long		flags;
> @@ -1284,8 +1282,7 @@ static void omap_gpio_restore_context(struct gpio_bank *bank);
>   
>   static int omap_gpio_runtime_suspend(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct gpio_bank *bank = platform_get_drvdata(pdev);
> +	struct gpio_bank *bank = dev_get_drvdata(dev);
>   	u32 l1 = 0, l2 = 0;
>   	unsigned long flags;
>   	u32 wake_low, wake_hi;
> @@ -1352,8 +1349,7 @@ static void omap_gpio_init_context(struct gpio_bank *p);
>   
>   static int omap_gpio_runtime_resume(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct gpio_bank *bank = platform_get_drvdata(pdev);
> +	struct gpio_bank *bank = dev_get_drvdata(dev);
>   	u32 l = 0, gen, gen0, gen1;
>   	unsigned long flags;
>   	int c;
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 94396caaca75..04c963f03b68 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -403,8 +403,7 @@ static void tegra_gpio_irq_handler(struct irq_desc *desc)
>   #ifdef CONFIG_PM_SLEEP
>   static int tegra_gpio_resume(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct tegra_gpio_info *tgi = platform_get_drvdata(pdev);
> +	struct tegra_gpio_info *tgi = dev_get_drvdata(dev);
>   	unsigned long flags;
>   	unsigned int b, p;
>   
> @@ -443,8 +442,7 @@ static int tegra_gpio_resume(struct device *dev)
>   
>   static int tegra_gpio_suspend(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct tegra_gpio_info *tgi = platform_get_drvdata(pdev);
> +	struct tegra_gpio_info *tgi = dev_get_drvdata(dev);
>   	unsigned long flags;
>   	unsigned int b, p;
>   
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index 75ee877e5cd5..49534241bb1e 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -697,8 +697,7 @@ static int __maybe_unused zynq_gpio_resume(struct device *dev)
>   
>   static int __maybe_unused zynq_gpio_runtime_suspend(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct zynq_gpio *gpio = platform_get_drvdata(pdev);
> +	struct zynq_gpio *gpio = dev_get_drvdata(dev);
>   
>   	clk_disable_unprepare(gpio->clk);
>   
> @@ -707,8 +706,7 @@ static int __maybe_unused zynq_gpio_runtime_suspend(struct device *dev)
>   
>   static int __maybe_unused zynq_gpio_runtime_resume(struct device *dev)
>   {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct zynq_gpio *gpio = platform_get_drvdata(pdev);
> +	struct zynq_gpio *gpio = dev_get_drvdata(dev);
>   
>   	return clk_prepare_enable(gpio->clk);
>   }
> 

-- 
regards,
-grygorii

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-19 14:05 ` [PATCH 10/61] gpio: " Wolfram Sang
  2018-04-19 15:14   ` Grygorii Strashko
@ 2018-04-20  7:20   ` Michal Simek
  2018-04-21 16:23     ` Wolfram Sang
  1 sibling, 1 reply; 21+ messages in thread
From: Michal Simek @ 2018-04-20  7:20 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: linux-renesas-soc, kernel-janitors, Hoan Tran, Linus Walleij,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Thierry Reding, Jonathan Hunter, Michal Simek, linux-gpio,
	linux-omap, linux-tegra, linux-arm-kernel

Hi Wolfram,

On 19.4.2018 16:05, 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.
> 
>  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 ++----
>  5 files changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
> index 226977f78482..caaabb79e31f 100644
> --- a/drivers/gpio/gpio-dwapb.c
> +++ b/drivers/gpio/gpio-dwapb.c
> @@ -732,8 +732,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
>  #ifdef CONFIG_PM_SLEEP
>  static int dwapb_gpio_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct dwapb_gpio *gpio = platform_get_drvdata(pdev);
> +	struct dwapb_gpio *gpio = dev_get_drvdata(dev);
>  	struct gpio_chip *gc	= &gpio->ports[0].gc;
>  	unsigned long flags;
>  	int i;
> @@ -777,8 +776,7 @@ static int dwapb_gpio_suspend(struct device *dev)
>  
>  static int dwapb_gpio_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct dwapb_gpio *gpio = platform_get_drvdata(pdev);
> +	struct dwapb_gpio *gpio = dev_get_drvdata(dev);
>  	struct gpio_chip *gc	= &gpio->ports[0].gc;
>  	unsigned long flags;
>  	int i;
> diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c
> index 1e557b10d73e..55fa33b7209f 100644
> --- a/drivers/gpio/gpio-lynxpoint.c
> +++ b/drivers/gpio/gpio-lynxpoint.c
> @@ -408,8 +408,7 @@ static int lp_gpio_runtime_resume(struct device *dev)
>  
>  static int lp_gpio_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct lp_gpio *lg = platform_get_drvdata(pdev);
> +	struct lp_gpio *lg = dev_get_drvdata(dev);
>  	unsigned long reg;
>  	int i;
>  
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 35971a341c40..b4f8a048a2a1 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -856,8 +856,7 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
>  
>  static int omap_mpuio_suspend_noirq(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct gpio_bank	*bank = platform_get_drvdata(pdev);
> +	struct gpio_bank	*bank = dev_get_drvdata(dev);
>  	void __iomem		*mask_reg = bank->base +
>  					OMAP_MPUIO_GPIO_MASKIT / bank->stride;
>  	unsigned long		flags;
> @@ -871,8 +870,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
>  
>  static int omap_mpuio_resume_noirq(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct gpio_bank	*bank = platform_get_drvdata(pdev);
> +	struct gpio_bank	*bank = dev_get_drvdata(dev);
>  	void __iomem		*mask_reg = bank->base +
>  					OMAP_MPUIO_GPIO_MASKIT / bank->stride;
>  	unsigned long		flags;
> @@ -1284,8 +1282,7 @@ static void omap_gpio_restore_context(struct gpio_bank *bank);
>  
>  static int omap_gpio_runtime_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct gpio_bank *bank = platform_get_drvdata(pdev);
> +	struct gpio_bank *bank = dev_get_drvdata(dev);
>  	u32 l1 = 0, l2 = 0;
>  	unsigned long flags;
>  	u32 wake_low, wake_hi;
> @@ -1352,8 +1349,7 @@ static void omap_gpio_init_context(struct gpio_bank *p);
>  
>  static int omap_gpio_runtime_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct gpio_bank *bank = platform_get_drvdata(pdev);
> +	struct gpio_bank *bank = dev_get_drvdata(dev);
>  	u32 l = 0, gen, gen0, gen1;
>  	unsigned long flags;
>  	int c;
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 94396caaca75..04c963f03b68 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -403,8 +403,7 @@ static void tegra_gpio_irq_handler(struct irq_desc *desc)
>  #ifdef CONFIG_PM_SLEEP
>  static int tegra_gpio_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct tegra_gpio_info *tgi = platform_get_drvdata(pdev);
> +	struct tegra_gpio_info *tgi = dev_get_drvdata(dev);
>  	unsigned long flags;
>  	unsigned int b, p;
>  
> @@ -443,8 +442,7 @@ static int tegra_gpio_resume(struct device *dev)
>  
>  static int tegra_gpio_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct tegra_gpio_info *tgi = platform_get_drvdata(pdev);
> +	struct tegra_gpio_info *tgi = dev_get_drvdata(dev);
>  	unsigned long flags;
>  	unsigned int b, p;
>  
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index 75ee877e5cd5..49534241bb1e 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -697,8 +697,7 @@ static int __maybe_unused zynq_gpio_resume(struct device *dev)
>  
>  static int __maybe_unused zynq_gpio_runtime_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct zynq_gpio *gpio = platform_get_drvdata(pdev);
> +	struct zynq_gpio *gpio = dev_get_drvdata(dev);
>  
>  	clk_disable_unprepare(gpio->clk);
>  
> @@ -707,8 +706,7 @@ static int __maybe_unused zynq_gpio_runtime_suspend(struct device *dev)
>  
>  static int __maybe_unused zynq_gpio_runtime_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct zynq_gpio *gpio = platform_get_drvdata(pdev);
> +	struct zynq_gpio *gpio = dev_get_drvdata(dev);
>  
>  	return clk_prepare_enable(gpio->clk);
>  }
> 

There are two more occurences in this gpio-zynq driver.
zynq_gpio_resume, zynq_gpio_suspend. It wasn't detected because these
two lines are not together. But the same change can be applied for them too.

Thanks,
Michal

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

* Re: [PATCH 49/61] staging: nvec: simplify getting .drvdata
  2018-04-19 14:06 ` [PATCH 49/61] staging: nvec: " Wolfram Sang
@ 2018-04-20  8:45   ` Marc Dietrich
  0 siblings, 0 replies; 21+ messages in thread
From: Marc Dietrich @ 2018-04-20  8:45 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: devel, Greg Kroah-Hartman, kernel-janitors, linux-kernel,
	linux-renesas-soc, linux-tegra, ac100

Am Donnerstag, 19. April 2018, 16:06:19 CEST schrieb Wolfram Sang:
> 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>

Acked-by: Marc Dietrich <marvin24@gmx.de>

> ---
> 
> Build tested only. buildbot is happy. Please apply individually.
> 
>  drivers/staging/nvec/nvec.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index 52054a528723..2a5e0dcf4162 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -925,8 +925,7 @@ static int tegra_nvec_remove(struct platform_device
> *pdev) static int nvec_suspend(struct device *dev)
>  {
>  	int err;
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct nvec_chip *nvec = platform_get_drvdata(pdev);
> +	struct nvec_chip *nvec = dev_get_drvdata(dev);
>  	struct nvec_msg *msg;
>  	char ap_suspend[] = { NVEC_SLEEP, AP_SUSPEND };
> 
> @@ -946,8 +945,7 @@ static int nvec_suspend(struct device *dev)
> 
>  static int nvec_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct nvec_chip *nvec = platform_get_drvdata(pdev);
> +	struct nvec_chip *nvec = dev_get_drvdata(dev);
> 
>  	dev_dbg(nvec->dev, "resuming\n");
>  	tegra_init_i2c_slave(nvec);

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-20  7:20   ` Michal Simek
@ 2018-04-21 16:23     ` Wolfram Sang
  2018-04-23  6:04       ` Michal Simek
  0 siblings, 1 reply; 21+ messages in thread
From: Wolfram Sang @ 2018-04-21 16:23 UTC (permalink / raw)
  To: Michal Simek
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, kernel-janitors,
	Hoan Tran, Linus Walleij, Grygorii Strashko, Santosh Shilimkar,
	Kevin Hilman, Thierry Reding, Jonathan Hunter, linux-gpio,
	linux-omap, linux-tegra, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 852 bytes --]

Hi Michal,

Thanks for the reviews!

> There are two more occurences in this gpio-zynq driver.
> zynq_gpio_resume, zynq_gpio_suspend. It wasn't detected because these
> two lines are not together. But the same change can be applied for them too.

Not really. The rule would have matched if there was just "something"
inbetween. It did not match because the "something" involves the
variable 'pdev', so we can't remove it. And just changing towards
'dev_get_drvdata' and keeping 'pdev' was not worth the hazzle in my
book. Especially since I think the code should probably get refactored.
Calling platform_get_irq() in suspend/resume paths in order to get the
irq_data looks a little expensive to me, but I haven't tested it.

Best wishes,

   Wolfram

PS: Please quote only relevant parts of the message, it is a lot easier
to find comments then IMO.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-21 16:23     ` Wolfram Sang
@ 2018-04-23  6:04       ` Michal Simek
  0 siblings, 0 replies; 21+ messages in thread
From: Michal Simek @ 2018-04-23  6:04 UTC (permalink / raw)
  To: Wolfram Sang, Michal Simek
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, kernel-janitors,
	Hoan Tran, Linus Walleij, Grygorii Strashko, Santosh Shilimkar,
	Kevin Hilman, Thierry Reding, Jonathan Hunter, linux-gpio,
	linux-omap, linux-tegra, linux-arm-kernel

Hi Wolfram,

On 21.4.2018 18:23, Wolfram Sang wrote:
> Hi Michal,
> 
> Thanks for the reviews!
> 
>> There are two more occurences in this gpio-zynq driver.
>> zynq_gpio_resume, zynq_gpio_suspend. It wasn't detected because these
>> two lines are not together. But the same change can be applied for them too.
> 
> Not really. The rule would have matched if there was just "something"
> inbetween. It did not match because the "something" involves the
> variable 'pdev', so we can't remove it. And just changing towards
> 'dev_get_drvdata' and keeping 'pdev' was not worth the hazzle in my
> book. Especially since I think the code should probably get refactored.
> Calling platform_get_irq() in suspend/resume paths in order to get the
> irq_data looks a little expensive to me, but I haven't tested it.
> 

ok. Thanks. I have overlooked that.

Thanks,
Michal

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

* Re: [PATCH 20/61] input: keyboard: simplify getting .drvdata
  2018-04-19 14:05 ` [PATCH 20/61] input: keyboard: " Wolfram Sang
@ 2018-04-26 19:19   ` Dmitry Torokhov
  2018-04-26 20:04     ` Wolfram Sang
  0 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2018-04-26 19:19 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, linux-renesas-soc, kernel-janitors,
	Vladimir Zapolskiy, Sylvain Lemieux, Rakesh Iyer, Laxman Dewangan,
	Thierry Reding, Jonathan Hunter, linux-input, linux-arm-kernel,
	linux-tegra

Hi Wolfram,

On Thu, Apr 19, 2018 at 04:05:50PM +0200, Wolfram Sang wrote:
> We should get drvdata from struct device directly. Going via
> platform_device is an unneeded step back and forth.

I consider the fact that platform device's driver data is accessible via
device driver data being implementation detail that may or may not change
in the future, so I'd prefer keep using the proper accessors for the
objects we are dealing with.

Thanks.

> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Build tested only. buildbot is happy. Please apply individually.
> 
>  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 ++++------
>  12 files changed, 42 insertions(+), 68 deletions(-)
> 
> diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
> index f77b295e0123..7584a03db4b3 100644
> --- a/drivers/input/keyboard/ep93xx_keypad.c
> +++ b/drivers/input/keyboard/ep93xx_keypad.c
> @@ -185,8 +185,7 @@ static void ep93xx_keypad_close(struct input_dev *pdev)
>  #ifdef CONFIG_PM_SLEEP
>  static int ep93xx_keypad_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
> +	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = keypad->input_dev;
>  
>  	mutex_lock(&input_dev->mutex);
> @@ -198,7 +197,7 @@ static int ep93xx_keypad_suspend(struct device *dev)
>  
>  	mutex_unlock(&input_dev->mutex);
>  
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		enable_irq_wake(keypad->irq);
>  
>  	return 0;
> @@ -206,11 +205,10 @@ static int ep93xx_keypad_suspend(struct device *dev)
>  
>  static int ep93xx_keypad_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
> +	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = keypad->input_dev;
>  
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		disable_irq_wake(keypad->irq);
>  
>  	mutex_lock(&input_dev->mutex);
> diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
> index 25d61d8d4fc4..56328ced81e2 100644
> --- a/drivers/input/keyboard/imx_keypad.c
> +++ b/drivers/input/keyboard/imx_keypad.c
> @@ -532,8 +532,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
>  
>  static int __maybe_unused imx_kbd_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct imx_keypad *kbd = platform_get_drvdata(pdev);
> +	struct imx_keypad *kbd = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = kbd->input_dev;
>  
>  	/* imx kbd can wake up system even clock is disabled */
> @@ -544,7 +543,7 @@ static int __maybe_unused imx_kbd_suspend(struct device *dev)
>  
>  	mutex_unlock(&input_dev->mutex);
>  
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		enable_irq_wake(kbd->irq);
>  
>  	return 0;
> @@ -552,12 +551,11 @@ static int __maybe_unused imx_kbd_suspend(struct device *dev)
>  
>  static int __maybe_unused imx_kbd_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct imx_keypad *kbd = platform_get_drvdata(pdev);
> +	struct imx_keypad *kbd = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = kbd->input_dev;
>  	int ret = 0;
>  
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		disable_irq_wake(kbd->irq);
>  
>  	mutex_lock(&input_dev->mutex);
> diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c
> index 1dd57ac0e7a2..0831a6f2a9d4 100644
> --- a/drivers/input/keyboard/lpc32xx-keys.c
> +++ b/drivers/input/keyboard/lpc32xx-keys.c
> @@ -279,8 +279,7 @@ static int lpc32xx_kscan_probe(struct platform_device *pdev)
>  #ifdef CONFIG_PM_SLEEP
>  static int lpc32xx_kscan_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
> +	struct lpc32xx_kscan_drv *kscandat = dev_get_drvdata(dev);
>  	struct input_dev *input = kscandat->input;
>  
>  	mutex_lock(&input->mutex);
> @@ -297,8 +296,7 @@ static int lpc32xx_kscan_suspend(struct device *dev)
>  
>  static int lpc32xx_kscan_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
> +	struct lpc32xx_kscan_drv *kscandat = dev_get_drvdata(dev);
>  	struct input_dev *input = kscandat->input;
>  	int retval = 0;
>  
> diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
> index 41614c185918..73ca55e4babe 100644
> --- a/drivers/input/keyboard/matrix_keypad.c
> +++ b/drivers/input/keyboard/matrix_keypad.c
> @@ -276,12 +276,11 @@ static void matrix_keypad_disable_wakeup(struct matrix_keypad *keypad)
>  
>  static int matrix_keypad_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct matrix_keypad *keypad = platform_get_drvdata(pdev);
> +	struct matrix_keypad *keypad = dev_get_drvdata(dev);
>  
>  	matrix_keypad_stop(keypad->input_dev);
>  
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		matrix_keypad_enable_wakeup(keypad);
>  
>  	return 0;
> @@ -289,10 +288,9 @@ static int matrix_keypad_suspend(struct device *dev)
>  
>  static int matrix_keypad_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct matrix_keypad *keypad = platform_get_drvdata(pdev);
> +	struct matrix_keypad *keypad = dev_get_drvdata(dev);
>  
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		matrix_keypad_disable_wakeup(keypad);
>  
>  	matrix_keypad_start(keypad->input_dev);
> diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
> index 940d38b08e6b..13578b884ace 100644
> --- a/drivers/input/keyboard/omap4-keypad.c
> +++ b/drivers/input/keyboard/omap4-keypad.c
> @@ -422,11 +422,10 @@ MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
>  #ifdef CONFIG_PM_SLEEP
>  static int omap4_keypad_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
> +	struct omap4_keypad *keypad_data = dev_get_drvdata(dev);
>  	int error;
>  
> -	if (device_may_wakeup(&pdev->dev)) {
> +	if (device_may_wakeup(dev)) {
>  		error = enable_irq_wake(keypad_data->irq);
>  		if (!error)
>  			keypad_data->irq_wake_enabled = true;
> @@ -437,10 +436,9 @@ static int omap4_keypad_suspend(struct device *dev)
>  
>  static int omap4_keypad_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
> +	struct omap4_keypad *keypad_data = dev_get_drvdata(dev);
>  
> -	if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) {
> +	if (device_may_wakeup(dev) && keypad_data->irq_wake_enabled) {
>  		disable_irq_wake(keypad_data->irq);
>  		keypad_data->irq_wake_enabled = false;
>  	}
> diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
> index 98b24ed18752..048a39321298 100644
> --- a/drivers/input/keyboard/pmic8xxx-keypad.c
> +++ b/drivers/input/keyboard/pmic8xxx-keypad.c
> @@ -636,8 +636,7 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)
>  #ifdef CONFIG_PM_SLEEP
>  static int pmic8xxx_kp_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
> +	struct pmic8xxx_kp *kp = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = kp->input;
>  
>  	if (device_may_wakeup(dev)) {
> @@ -656,8 +655,7 @@ static int pmic8xxx_kp_suspend(struct device *dev)
>  
>  static int pmic8xxx_kp_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
> +	struct pmic8xxx_kp *kp = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = kp->input;
>  
>  	if (device_may_wakeup(dev)) {
> diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
> index d0bdaeadf86d..1f54a3162124 100644
> --- a/drivers/input/keyboard/pxa27x_keypad.c
> +++ b/drivers/input/keyboard/pxa27x_keypad.c
> @@ -666,14 +666,13 @@ static void pxa27x_keypad_close(struct input_dev *dev)
>  #ifdef CONFIG_PM_SLEEP
>  static int pxa27x_keypad_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
> +	struct pxa27x_keypad *keypad = dev_get_drvdata(dev);
>  
>  	/*
>  	 * If the keypad is used a wake up source, clock can not be disabled.
>  	 * Or it can not detect the key pressing.
>  	 */
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		enable_irq_wake(keypad->irq);
>  	else
>  		clk_disable_unprepare(keypad->clk);
> @@ -683,8 +682,7 @@ static int pxa27x_keypad_suspend(struct device *dev)
>  
>  static int pxa27x_keypad_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
> +	struct pxa27x_keypad *keypad = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = keypad->input_dev;
>  	int ret = 0;
>  
> @@ -692,7 +690,7 @@ static int pxa27x_keypad_resume(struct device *dev)
>  	 * If the keypad is used as wake up source, the clock is not turned
>  	 * off. So do not need configure it again.
>  	 */
> -	if (device_may_wakeup(&pdev->dev)) {
> +	if (device_may_wakeup(dev)) {
>  		disable_irq_wake(keypad->irq);
>  	} else {
>  		mutex_lock(&input_dev->mutex);
> diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
> index 316414465c77..27790a8a44f5 100644
> --- a/drivers/input/keyboard/samsung-keypad.c
> +++ b/drivers/input/keyboard/samsung-keypad.c
> @@ -466,8 +466,7 @@ static int samsung_keypad_remove(struct platform_device *pdev)
>  #ifdef CONFIG_PM
>  static int samsung_keypad_runtime_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct samsung_keypad *keypad = platform_get_drvdata(pdev);
> +	struct samsung_keypad *keypad = dev_get_drvdata(dev);
>  	unsigned int val;
>  	int error;
>  
> @@ -490,8 +489,7 @@ static int samsung_keypad_runtime_suspend(struct device *dev)
>  
>  static int samsung_keypad_runtime_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct samsung_keypad *keypad = platform_get_drvdata(pdev);
> +	struct samsung_keypad *keypad = dev_get_drvdata(dev);
>  	unsigned int val;
>  
>  	if (keypad->stopped)
> @@ -535,8 +533,7 @@ static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad,
>  
>  static int samsung_keypad_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct samsung_keypad *keypad = platform_get_drvdata(pdev);
> +	struct samsung_keypad *keypad = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = keypad->input_dev;
>  
>  	mutex_lock(&input_dev->mutex);
> @@ -553,8 +550,7 @@ static int samsung_keypad_suspend(struct device *dev)
>  
>  static int samsung_keypad_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct samsung_keypad *keypad = platform_get_drvdata(pdev);
> +	struct samsung_keypad *keypad = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = keypad->input_dev;
>  
>  	mutex_lock(&input_dev->mutex);
> diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
> index 53c768b95939..f439f7bd2f5f 100644
> --- a/drivers/input/keyboard/snvs_pwrkey.c
> +++ b/drivers/input/keyboard/snvs_pwrkey.c
> @@ -180,10 +180,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
>  
>  static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
> +	struct pwrkey_drv_data *pdata = dev_get_drvdata(dev);
>  
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		enable_irq_wake(pdata->irq);
>  
>  	return 0;
> @@ -191,10 +190,9 @@ static int __maybe_unused imx_snvs_pwrkey_suspend(struct device *dev)
>  
>  static int __maybe_unused imx_snvs_pwrkey_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev);
> +	struct pwrkey_drv_data *pdata = dev_get_drvdata(dev);
>  
> -	if (device_may_wakeup(&pdev->dev))
> +	if (device_may_wakeup(dev))
>  		disable_irq_wake(pdata->irq);
>  
>  	return 0;
> diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
> index 7d25fa338ab4..a0276a3376d2 100644
> --- a/drivers/input/keyboard/spear-keyboard.c
> +++ b/drivers/input/keyboard/spear-keyboard.c
> @@ -288,8 +288,7 @@ static int spear_kbd_remove(struct platform_device *pdev)
>  
>  static int __maybe_unused spear_kbd_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct spear_kbd *kbd = platform_get_drvdata(pdev);
> +	struct spear_kbd *kbd = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = kbd->input;
>  	unsigned int rate = 0, mode_ctl_reg, val;
>  
> @@ -300,7 +299,7 @@ static int __maybe_unused spear_kbd_suspend(struct device *dev)
>  
>  	mode_ctl_reg = readl_relaxed(kbd->io_base + MODE_CTL_REG);
>  
> -	if (device_may_wakeup(&pdev->dev)) {
> +	if (device_may_wakeup(dev)) {
>  		if (!enable_irq_wake(kbd->irq))
>  			kbd->irq_wake_enabled = true;
>  
> @@ -341,13 +340,12 @@ static int __maybe_unused spear_kbd_suspend(struct device *dev)
>  
>  static int __maybe_unused spear_kbd_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct spear_kbd *kbd = platform_get_drvdata(pdev);
> +	struct spear_kbd *kbd = dev_get_drvdata(dev);
>  	struct input_dev *input_dev = kbd->input;
>  
>  	mutex_lock(&input_dev->mutex);
>  
> -	if (device_may_wakeup(&pdev->dev)) {
> +	if (device_may_wakeup(dev)) {
>  		if (kbd->irq_wake_enabled) {
>  			kbd->irq_wake_enabled = false;
>  			disable_irq_wake(kbd->irq);
> diff --git a/drivers/input/keyboard/st-keyscan.c b/drivers/input/keyboard/st-keyscan.c
> index babcfb165e4f..3b4727e4b411 100644
> --- a/drivers/input/keyboard/st-keyscan.c
> +++ b/drivers/input/keyboard/st-keyscan.c
> @@ -218,8 +218,7 @@ static int keyscan_probe(struct platform_device *pdev)
>  #ifdef CONFIG_PM_SLEEP
>  static int keyscan_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct st_keyscan *keypad = platform_get_drvdata(pdev);
> +	struct st_keyscan *keypad = dev_get_drvdata(dev);
>  	struct input_dev *input = keypad->input_dev;
>  
>  	mutex_lock(&input->mutex);
> @@ -235,8 +234,7 @@ static int keyscan_suspend(struct device *dev)
>  
>  static int keyscan_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct st_keyscan *keypad = platform_get_drvdata(pdev);
> +	struct st_keyscan *keypad = dev_get_drvdata(dev);
>  	struct input_dev *input = keypad->input_dev;
>  	int retval = 0;
>  
> diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
> index 875205f445b5..861bfcbd817d 100644
> --- a/drivers/input/keyboard/tegra-kbc.c
> +++ b/drivers/input/keyboard/tegra-kbc.c
> @@ -744,11 +744,10 @@ static void tegra_kbc_set_keypress_interrupt(struct tegra_kbc *kbc, bool enable)
>  
>  static int tegra_kbc_suspend(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct tegra_kbc *kbc = platform_get_drvdata(pdev);
> +	struct tegra_kbc *kbc = dev_get_drvdata(dev);
>  
>  	mutex_lock(&kbc->idev->mutex);
> -	if (device_may_wakeup(&pdev->dev)) {
> +	if (device_may_wakeup(dev)) {
>  		disable_irq(kbc->irq);
>  		del_timer_sync(&kbc->timer);
>  		tegra_kbc_set_fifo_interrupt(kbc, false);
> @@ -781,12 +780,11 @@ static int tegra_kbc_suspend(struct device *dev)
>  
>  static int tegra_kbc_resume(struct device *dev)
>  {
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct tegra_kbc *kbc = platform_get_drvdata(pdev);
> +	struct tegra_kbc *kbc = dev_get_drvdata(dev);
>  	int err = 0;
>  
>  	mutex_lock(&kbc->idev->mutex);
> -	if (device_may_wakeup(&pdev->dev)) {
> +	if (device_may_wakeup(dev)) {
>  		disable_irq_wake(kbc->irq);
>  		tegra_kbc_setup_wakekeys(kbc, false);
>  		/* We will use fifo interrupts for key detection. */
> -- 
> 2.11.0
> 

-- 
Dmitry

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

* Re: [PATCH 20/61] input: keyboard: simplify getting .drvdata
  2018-04-26 19:19   ` Dmitry Torokhov
@ 2018-04-26 20:04     ` Wolfram Sang
  2018-04-26 21:23       ` Dmitry Torokhov
  0 siblings, 1 reply; 21+ messages in thread
From: Wolfram Sang @ 2018-04-26 20:04 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, kernel-janitors,
	Vladimir Zapolskiy, Sylvain Lemieux, Rakesh Iyer, Laxman Dewangan,
	Thierry Reding, Jonathan Hunter, linux-input, linux-arm-kernel,
	linux-tegra

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

Hi Dmitry,

> > We should get drvdata from struct device directly. Going via
> > platform_device is an unneeded step back and forth.
> 
> I consider the fact that platform device's driver data is accessible via
> device driver data being implementation detail that may or may not change

Isn't it actually the other way around? platform_get_drvdata() is a
convenience function to access driver_data which is embedded in struct
device?

> in the future, so I'd prefer keep using the proper accessors for the
> objects we are dealing with.

Exactly. I'd just argue, the object we are dealing with, declared in the
PM functions, is a struct device.

Thanks for the comment,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 20/61] input: keyboard: simplify getting .drvdata
  2018-04-26 20:04     ` Wolfram Sang
@ 2018-04-26 21:23       ` Dmitry Torokhov
  2018-04-27 10:20         ` Wolfram Sang
  0 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2018-04-26 21:23 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, kernel-janitors,
	Vladimir Zapolskiy, Sylvain Lemieux, Rakesh Iyer, Laxman Dewangan,
	Thierry Reding, Jonathan Hunter, linux-input, linux-arm-kernel,
	linux-tegra

On Thu, Apr 26, 2018 at 10:04:01PM +0200, Wolfram Sang wrote:
> Hi Dmitry,
> 
> > > We should get drvdata from struct device directly. Going via
> > > platform_device is an unneeded step back and forth.
> > 
> > I consider the fact that platform device's driver data is accessible via
> > device driver data being implementation detail that may or may not change
> 
> Isn't it actually the other way around? platform_get_drvdata() is a
> convenience function to access driver_data which is embedded in struct
> device?

I guess it depends on how you read it. I always considered it separate
because none (?) of the bus implementation assert this in comments to
XXX_get_drvdata().

> 
> > in the future, so I'd prefer keep using the proper accessors for the
> > objects we are dealing with.
> 
> Exactly. I'd just argue, the object we are dealing with, declared in the
> PM functions, is a struct device.

No, the driver does not create a generic device, it actually creates a
platform device, or i2c client, or spi, or something else. The fact that
suspend and resume routines have generic device as their argument has
more to do with the language limitation rather than reflection of true
type of the objects we are dealing with.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 20/61] input: keyboard: simplify getting .drvdata
  2018-04-26 21:23       ` Dmitry Torokhov
@ 2018-04-27 10:20         ` Wolfram Sang
  0 siblings, 0 replies; 21+ messages in thread
From: Wolfram Sang @ 2018-04-27 10:20 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Wolfram Sang, linux-kernel, linux-renesas-soc, kernel-janitors,
	Vladimir Zapolskiy, Sylvain Lemieux, Rakesh Iyer, Laxman Dewangan,
	Thierry Reding, Jonathan Hunter, linux-input, linux-arm-kernel,
	linux-tegra

[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]

Hi Dmitry,

> > Isn't it actually the other way around? platform_get_drvdata() is a
> > convenience function to access driver_data which is embedded in struct
> > device?
> 
> I guess it depends on how you read it. I always considered it separate
> because none (?) of the bus implementation assert this in comments to
> XXX_get_drvdata().

Well, even in the case somebody will implement a custom driver_data for
platform_devices, this person will need to convert all current users to
'dev_get_drvdata(&pdev->dev);' first in order to avoid regressions, I'd
think. This is what my patch does right now (but merely for overhead
reasons). Or?

> > > in the future, so I'd prefer keep using the proper accessors for the
> > > objects we are dealing with.
> > 
> > Exactly. I'd just argue, the object we are dealing with, declared in the
> > PM functions, is a struct device.
> 
> No, the driver does not create a generic device, it actually creates a
> platform device, or i2c client, or spi, or something else. The fact that

True.

> suspend and resume routines have generic device as their argument has
> more to do with the language limitation rather than reflection of true
> type of the objects we are dealing with.

Ok, can be argued. I'd personally still go for the gain, but I won't
push harder than this mail.

Regards,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-19 15:14   ` Grygorii Strashko
@ 2018-04-30  9:03     ` Linus Walleij
  2018-04-30  9:12       ` Wolfram Sang
  2018-04-30  9:29       ` Thierry Reding
  0 siblings, 2 replies; 21+ messages in thread
From: Linus Walleij @ 2018-04-30  9:03 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: Wolfram Sang, linux-kernel@vger.kernel.org, Linux-Renesas,
	kernel-janitors, Hoan Tran, Santosh Shilimkar, Kevin Hilman,
	Thierry Reding, Jonathan Hunter, Michal Simek,
	open list:GPIO SUBSYSTEM, Linux-OMAP, linux-tegra, Linux ARM

On Thu, Apr 19, 2018 at 5:14 PM, Grygorii Strashko
<grygorii.strashko@ti.com> wrote:
> On 04/19/2018 09:05 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.
>
>
> for gpio-omap.c:
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

Hm I only see the responses not the actual patch, I guess I will find it
sooner or later.

Wolfram: if I don't find it, poke me with something sharp so I get to apply it.

Yours,
Linus Walleij

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-30  9:03     ` Linus Walleij
@ 2018-04-30  9:12       ` Wolfram Sang
  2018-04-30  9:29       ` Thierry Reding
  1 sibling, 0 replies; 21+ messages in thread
From: Wolfram Sang @ 2018-04-30  9:12 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Grygorii Strashko, Wolfram Sang, linux-kernel@vger.kernel.org,
	Linux-Renesas, kernel-janitors, Hoan Tran, Santosh Shilimkar,
	Kevin Hilman, Thierry Reding, Jonathan Hunter, Michal Simek,
	open list:GPIO SUBSYSTEM, Linux-OMAP, linux-tegra, Linux ARM

[-- Attachment #1: Type: text/plain, Size: 205 bytes --]


> Wolfram: if I don't find it, poke me with something sharp so I get to apply it.

I just bounced it again. Otherwise, it is here, too, downloadable as
mbox: https://patchwork.kernel.org/patch/10350759/


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-30  9:03     ` Linus Walleij
  2018-04-30  9:12       ` Wolfram Sang
@ 2018-04-30  9:29       ` Thierry Reding
  2019-03-07 20:13         ` Adam Ford
  1 sibling, 1 reply; 21+ messages in thread
From: Thierry Reding @ 2018-04-30  9:29 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Grygorii Strashko, Wolfram Sang, linux-kernel@vger.kernel.org,
	Linux-Renesas, kernel-janitors, Hoan Tran, Santosh Shilimkar,
	Kevin Hilman, Jonathan Hunter, Michal Simek,
	open list:GPIO SUBSYSTEM, Linux-OMAP, linux-tegra, Linux ARM

[-- Attachment #1: Type: text/plain, Size: 912 bytes --]

On Mon, Apr 30, 2018 at 11:03:25AM +0200, Linus Walleij wrote:
> On Thu, Apr 19, 2018 at 5:14 PM, Grygorii Strashko
> <grygorii.strashko@ti.com> wrote:
> > On 04/19/2018 09:05 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.
> >
> >
> > for gpio-omap.c:
> > Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> 
> Hm I only see the responses not the actual patch, I guess I will find it
> sooner or later.
> 
> Wolfram: if I don't find it, poke me with something sharp so I get to apply it.

I had the same problem, turned out this got classified as spam by Google
for some reason. Maybe try your spam folder?

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2018-04-30  9:29       ` Thierry Reding
@ 2019-03-07 20:13         ` Adam Ford
  2019-03-07 20:18           ` Wolfram Sang
  0 siblings, 1 reply; 21+ messages in thread
From: Adam Ford @ 2019-03-07 20:13 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Linus Walleij, Grygorii Strashko, Wolfram Sang,
	linux-kernel@vger.kernel.org, Linux-Renesas, kernel-janitors,
	Hoan Tran, Santosh Shilimkar, Kevin Hilman, Jonathan Hunter,
	Michal Simek, open list:GPIO SUBSYSTEM, Linux-OMAP, linux-tegra,
	Linux ARM

On Mon, Apr 30, 2018 at 4:30 AM Thierry Reding <thierry.reding@gmail.com> wrote:
>
> On Mon, Apr 30, 2018 at 11:03:25AM +0200, Linus Walleij wrote:
> > On Thu, Apr 19, 2018 at 5:14 PM, Grygorii Strashko
> > <grygorii.strashko@ti.com> wrote:
> > > On 04/19/2018 09:05 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.
> > >
> > >
> > > for gpio-omap.c:
> > > Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> >
> > Hm I only see the responses not the actual patch, I guess I will find it
> > sooner or later.
> >
> > Wolfram: if I don't find it, poke me with something sharp so I get to apply it.
>
> I had the same problem, turned out this got classified as spam by Google
> for some reason. Maybe try your spam folder?

It's been almost a year later, and several Linux revisions, and this
still seems stuck somewhere/somehow.

adam
>
> Thierry

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2019-03-07 20:13         ` Adam Ford
@ 2019-03-07 20:18           ` Wolfram Sang
  2019-03-07 20:53             ` Enrico Weigelt, metux IT consult
  0 siblings, 1 reply; 21+ messages in thread
From: Wolfram Sang @ 2019-03-07 20:18 UTC (permalink / raw)
  To: Adam Ford
  Cc: Thierry Reding, Linus Walleij, Grygorii Strashko, Wolfram Sang,
	linux-kernel@vger.kernel.org, Linux-Renesas, kernel-janitors,
	Hoan Tran, Santosh Shilimkar, Kevin Hilman, Jonathan Hunter,
	Michal Simek, open list:GPIO SUBSYSTEM, Linux-OMAP, linux-tegra,
	Linux ARM

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]


> It's been almost a year later, and several Linux revisions, and this
> still seems stuck somewhere/somehow.

I wanted to respin this series once rc1 is released.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2019-03-07 20:18           ` Wolfram Sang
@ 2019-03-07 20:53             ` Enrico Weigelt, metux IT consult
  2019-03-07 20:58               ` Wolfram Sang
  0 siblings, 1 reply; 21+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-03-07 20:53 UTC (permalink / raw)
  To: Wolfram Sang, Adam Ford
  Cc: Grygorii Strashko, Kevin Hilman, Linus Walleij, Hoan Tran,
	kernel-janitors, linux-kernel@vger.kernel.org, Jonathan Hunter,
	Linux-Renesas, Wolfram Sang, Thierry Reding,
	open list:GPIO SUBSYSTEM, Santosh Shilimkar, linux-tegra,
	Linux-OMAP, Michal Simek, Linux ARM

On 07.03.19 21:18, Wolfram Sang wrote:
> 
>> It's been almost a year later, and several Linux revisions, and this
>> still seems stuck somewhere/somehow.
> 
> I wanted to respin this series once rc1 is released.
> 
Maybe just rebase and repost ?


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2019-03-07 20:53             ` Enrico Weigelt, metux IT consult
@ 2019-03-07 20:58               ` Wolfram Sang
  2019-03-19 14:31                 ` Wolfram Sang
  0 siblings, 1 reply; 21+ messages in thread
From: Wolfram Sang @ 2019-03-07 20:58 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: Adam Ford, Thierry Reding, Linus Walleij, Grygorii Strashko,
	Wolfram Sang, linux-kernel@vger.kernel.org, Linux-Renesas,
	kernel-janitors, Hoan Tran, Santosh Shilimkar, Kevin Hilman,
	Jonathan Hunter, Michal Simek, open list:GPIO SUBSYSTEM,
	Linux-OMAP, linux-tegra, Linux ARM

[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

On Thu, Mar 07, 2019 at 09:53:50PM +0100, Enrico Weigelt, metux IT consult wrote:
> On 07.03.19 21:18, Wolfram Sang wrote:
> > 
> >> It's been almost a year later, and several Linux revisions, and this
> >> still seems stuck somewhere/somehow.
> > 
> > I wanted to respin this series once rc1 is released.
> > 
> Maybe just rebase and repost ?

Then I'd miss all the new drivers which may need this fixed. Coccinelle
makes respinning a breeze, so no problem with that.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 10/61] gpio: simplify getting .drvdata
  2019-03-07 20:58               ` Wolfram Sang
@ 2019-03-19 14:31                 ` Wolfram Sang
  0 siblings, 0 replies; 21+ messages in thread
From: Wolfram Sang @ 2019-03-19 14:31 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: Adam Ford, Thierry Reding, Linus Walleij, Grygorii Strashko,
	Wolfram Sang, linux-kernel@vger.kernel.org, Linux-Renesas,
	kernel-janitors, Hoan Tran, Santosh Shilimkar, Kevin Hilman,
	Jonathan Hunter, Michal Simek, open list:GPIO SUBSYSTEM,
	Linux-OMAP, linux-tegra, Linux ARM

[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]

On Thu, Mar 07, 2019 at 09:58:14PM +0100, Wolfram Sang wrote:
> On Thu, Mar 07, 2019 at 09:53:50PM +0100, Enrico Weigelt, metux IT consult wrote:
> > On 07.03.19 21:18, Wolfram Sang wrote:
> > > 
> > >> It's been almost a year later, and several Linux revisions, and this
> > >> still seems stuck somewhere/somehow.
> > > 
> > > I wanted to respin this series once rc1 is released.
> > > 
> > Maybe just rebase and repost ?
> 
> Then I'd miss all the new drivers which may need this fixed. Coccinelle
> makes respinning a breeze, so no problem with that.

Because coccinelle didn't find anything in drivers/gpio, I wondered what
case you are referring to? Invoking this (as of v5.1-rc1) gives:

$ git log --oneline --grep "simplify getting" drivers/gpio
7ddb7dce0ab6 gpio: gpio-tegra: simplify getting .driver_data
38ccad0243f9 gpio: gpio-zynq: simplify getting .driver_data
a3f4f728d3bb gpio: gpio-omap: simplify getting .driver_data
11868645c5b5 gpio: gpio-mxc: simplify getting .driver_data
ea5ec5e3aeab gpio: gpio-lynxpoint: simplify getting .driver_data
deb19ac533ac gpio: gpio-dwapb: simplify getting .driver_data


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-03-19 14:31 UTC | newest]

Thread overview: 21+ 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:05 ` [PATCH 10/61] gpio: " Wolfram Sang
2018-04-19 15:14   ` Grygorii Strashko
2018-04-30  9:03     ` Linus Walleij
2018-04-30  9:12       ` Wolfram Sang
2018-04-30  9:29       ` Thierry Reding
2019-03-07 20:13         ` Adam Ford
2019-03-07 20:18           ` Wolfram Sang
2019-03-07 20:53             ` Enrico Weigelt, metux IT consult
2019-03-07 20:58               ` Wolfram Sang
2019-03-19 14:31                 ` Wolfram Sang
2018-04-20  7:20   ` Michal Simek
2018-04-21 16:23     ` Wolfram Sang
2018-04-23  6:04       ` Michal Simek
2018-04-19 14:05 ` [PATCH 20/61] input: keyboard: " Wolfram Sang
2018-04-26 19:19   ` Dmitry Torokhov
2018-04-26 20:04     ` Wolfram Sang
2018-04-26 21:23       ` Dmitry Torokhov
2018-04-27 10:20         ` Wolfram Sang
2018-04-19 14:06 ` [PATCH 49/61] staging: nvec: " Wolfram Sang
2018-04-20  8:45   ` Marc Dietrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox