Skip to contentSkip to conversation

Input: imx_keypad - use dev_get_drvdata()

PATCH In review Fabio Estevam 2 participants 2 messages Aug 7, 2014

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 Input: imx_keypad - use dev_get_drvdata()

From: Fabio Estevam <[email protected]>

There is no need to first get a platform_device structure in the suspend/resume functions.

Make the code simpler by calling dev_get_drvdata() directly.

---
 drivers/input/keyboard/imx_keypad.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/input/keyboard/imx_keypad.c +4 -6
index 20a99c3..56f6e99 100644
@@ -533,8 +533,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 */
@@ -545,7 +544,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;
@@ -553,12 +552,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);
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Hi Fabio,

Quoted 6 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

There is no need to first get a platform_device structure in the suspend/resume functions.

Make the code simpler by calling dev_get_drvdata() directly.

I actually believe that we should be using the proper accessors fro the type. The fact that they resolve to the same data object is implementation detail, as far as I am concerned (unless driver core folks want to deprecate or get rid of everything but dev_{get|set}_drvdata()).

Thanks.

Signature · 1 line
Dmitry