* [PATCH 00/61] tree-wide: simplify getting .drvdata
@ 2018-04-19 14:05 Wolfram Sang
2018-04-19 14:05 ` [PATCH 17/61] hid: " Wolfram Sang
` (4 more replies)
0 siblings, 5 replies; 10+ 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] 10+ messages in thread
* [PATCH 17/61] hid: 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 14:05 ` [PATCH 20/61] input: keyboard: " Wolfram Sang
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ 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, Jiri Kosina,
Jonathan Cameron, Srinivas Pandruvada, Benjamin Tissoires,
linux-input, linux-iio
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/hid/hid-sensor-custom.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index e8a114157f87..cd0c2a7c8003 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -157,8 +157,7 @@ static int usage_id_cmp(const void *p1, const void *p2)
static ssize_t enable_sensor_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
+ struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", sensor_inst->enable);
}
@@ -237,8 +236,7 @@ static ssize_t enable_sensor_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
+ struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
int value;
int ret = -EINVAL;
@@ -283,8 +281,7 @@ static const struct attribute_group enable_sensor_attr_group = {
static ssize_t show_value(struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
+ struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
struct hid_sensor_hub_attribute_info *attribute;
int index, usage, field_index;
char name[HID_CUSTOM_NAME_LENGTH];
@@ -392,8 +389,7 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
static ssize_t store_value(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
+ struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
int index, field_index, usage;
char name[HID_CUSTOM_NAME_LENGTH];
int value;
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ 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 17/61] hid: " Wolfram Sang
@ 2018-04-19 14:05 ` Wolfram Sang
2018-04-26 19:19 ` Dmitry Torokhov
2018-04-19 14:05 ` [PATCH 21/61] input: misc: " Wolfram Sang
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ 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] 10+ messages in thread
* [PATCH 21/61] input: misc: simplify getting .drvdata
2018-04-19 14:05 [PATCH 00/61] tree-wide: simplify getting .drvdata Wolfram Sang
2018-04-19 14:05 ` [PATCH 17/61] hid: " Wolfram Sang
2018-04-19 14:05 ` [PATCH 20/61] input: keyboard: " Wolfram Sang
@ 2018-04-19 14:05 ` Wolfram Sang
2018-04-19 14:05 ` [PATCH 22/61] input: mouse: " Wolfram Sang
2018-04-19 14:05 ` [PATCH 23/61] input: touchscreen: " Wolfram Sang
4 siblings, 0 replies; 10+ 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,
linux-input
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/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 +--
6 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c
index 46b0f48fbf49..8968fd48e95c 100644
--- a/drivers/input/misc/max77693-haptic.c
+++ b/drivers/input/misc/max77693-haptic.c
@@ -381,8 +381,7 @@ static int max77693_haptic_probe(struct platform_device *pdev)
static int __maybe_unused max77693_haptic_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct max77693_haptic *haptic = platform_get_drvdata(pdev);
+ struct max77693_haptic *haptic = dev_get_drvdata(dev);
if (haptic->enabled) {
max77693_haptic_disable(haptic);
@@ -394,8 +393,7 @@ static int __maybe_unused max77693_haptic_suspend(struct device *dev)
static int __maybe_unused max77693_haptic_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct max77693_haptic *haptic = platform_get_drvdata(pdev);
+ struct max77693_haptic *haptic = dev_get_drvdata(dev);
if (haptic->suspend_state) {
max77693_haptic_enable(haptic);
diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c
index 99bc762881d5..5ffb0ac68d50 100644
--- a/drivers/input/misc/max8997_haptic.c
+++ b/drivers/input/misc/max8997_haptic.c
@@ -388,8 +388,7 @@ static int max8997_haptic_remove(struct platform_device *pdev)
static int __maybe_unused max8997_haptic_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct max8997_haptic *chip = platform_get_drvdata(pdev);
+ struct max8997_haptic *chip = dev_get_drvdata(dev);
max8997_haptic_disable(chip);
diff --git a/drivers/input/misc/palmas-pwrbutton.c b/drivers/input/misc/palmas-pwrbutton.c
index 1e1baed63929..27617868b292 100644
--- a/drivers/input/misc/palmas-pwrbutton.c
+++ b/drivers/input/misc/palmas-pwrbutton.c
@@ -270,8 +270,7 @@ static int palmas_pwron_remove(struct platform_device *pdev)
*/
static int __maybe_unused palmas_pwron_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+ struct palmas_pwron *pwron = dev_get_drvdata(dev);
cancel_delayed_work_sync(&pwron->input_work);
@@ -291,8 +290,7 @@ static int __maybe_unused palmas_pwron_suspend(struct device *dev)
*/
static int __maybe_unused palmas_pwron_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+ struct palmas_pwron *pwron = dev_get_drvdata(dev);
if (device_may_wakeup(dev))
disable_irq_wake(pwron->irq);
diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c
index a1db1e5040dc..0b78a87f3192 100644
--- a/drivers/input/misc/regulator-haptic.c
+++ b/drivers/input/misc/regulator-haptic.c
@@ -206,8 +206,7 @@ static int regulator_haptic_probe(struct platform_device *pdev)
static int __maybe_unused regulator_haptic_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct regulator_haptic *haptic = platform_get_drvdata(pdev);
+ struct regulator_haptic *haptic = dev_get_drvdata(dev);
int error;
error = mutex_lock_interruptible(&haptic->mutex);
@@ -225,8 +224,7 @@ static int __maybe_unused regulator_haptic_suspend(struct device *dev)
static int __maybe_unused regulator_haptic_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct regulator_haptic *haptic = platform_get_drvdata(pdev);
+ struct regulator_haptic *haptic = dev_get_drvdata(dev);
unsigned int magnitude;
mutex_lock(&haptic->mutex);
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
index c37aea9ac272..7b9104c058ca 100644
--- a/drivers/input/misc/twl4030-vibra.c
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -159,8 +159,7 @@ static void twl4030_vibra_close(struct input_dev *input)
/*** Module ***/
static int __maybe_unused twl4030_vibra_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct vibra_info *info = platform_get_drvdata(pdev);
+ struct vibra_info *info = dev_get_drvdata(dev);
if (info->enabled)
vibra_disable(info);
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 15e0d352c4cc..c8539a4a98c6 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -226,8 +226,7 @@ static void twl6040_vibra_close(struct input_dev *input)
static int __maybe_unused twl6040_vibra_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct vibra_info *info = platform_get_drvdata(pdev);
+ struct vibra_info *info = dev_get_drvdata(dev);
cancel_work_sync(&info->play_work);
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 22/61] input: mouse: 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:05 ` [PATCH 21/61] input: misc: " Wolfram Sang
@ 2018-04-19 14:05 ` Wolfram Sang
2018-04-19 14:05 ` [PATCH 23/61] input: touchscreen: " Wolfram Sang
4 siblings, 0 replies; 10+ 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,
linux-input
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/mouse/navpoint.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/input/mouse/navpoint.c b/drivers/input/mouse/navpoint.c
index d6e8f58a1de3..3d83a79e14d9 100644
--- a/drivers/input/mouse/navpoint.c
+++ b/drivers/input/mouse/navpoint.c
@@ -320,8 +320,7 @@ static int navpoint_remove(struct platform_device *pdev)
static int __maybe_unused navpoint_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct navpoint *navpoint = platform_get_drvdata(pdev);
+ struct navpoint *navpoint = dev_get_drvdata(dev);
struct input_dev *input = navpoint->input;
mutex_lock(&input->mutex);
@@ -334,8 +333,7 @@ static int __maybe_unused navpoint_suspend(struct device *dev)
static int __maybe_unused navpoint_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct navpoint *navpoint = platform_get_drvdata(pdev);
+ struct navpoint *navpoint = dev_get_drvdata(dev);
struct input_dev *input = navpoint->input;
mutex_lock(&input->mutex);
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 23/61] input: touchscreen: 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:05 ` [PATCH 22/61] input: mouse: " Wolfram Sang
@ 2018-04-19 14:05 ` Wolfram Sang
4 siblings, 0 replies; 10+ 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,
linux-input
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/touchscreen/imx6ul_tsc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
index ee82a975bfd2..da9e0a774e4b 100644
--- a/drivers/input/touchscreen/imx6ul_tsc.c
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -515,8 +515,7 @@ static int imx6ul_tsc_probe(struct platform_device *pdev)
static int __maybe_unused imx6ul_tsc_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct imx6ul_tsc *tsc = platform_get_drvdata(pdev);
+ struct imx6ul_tsc *tsc = dev_get_drvdata(dev);
struct input_dev *input_dev = tsc->input;
mutex_lock(&input_dev->mutex);
@@ -535,8 +534,7 @@ static int __maybe_unused imx6ul_tsc_suspend(struct device *dev)
static int __maybe_unused imx6ul_tsc_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct imx6ul_tsc *tsc = platform_get_drvdata(pdev);
+ struct imx6ul_tsc *tsc = dev_get_drvdata(dev);
struct input_dev *input_dev = tsc->input;
int retval = 0;
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ messages in thread
end of thread, other threads:[~2018-04-27 10:20 UTC | newest]
Thread overview: 10+ 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 17/61] hid: " Wolfram Sang
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:05 ` [PATCH 21/61] input: misc: " Wolfram Sang
2018-04-19 14:05 ` [PATCH 22/61] input: mouse: " Wolfram Sang
2018-04-19 14:05 ` [PATCH 23/61] input: touchscreen: " 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).