* [PATCH 0/5] pinctrl: simplify getting .driver_data
@ 2018-10-21 20:00 Wolfram Sang
2018-10-21 20:00 ` [PATCH 5/5] pinctrl: pinctrl-at91-pio4: " Wolfram Sang
0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2018-10-21 20:00 UTC (permalink / raw)
To: 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);
A branch, tested by buildbot, can be found here:
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata
I have been asked if it couldn't be done for dev_set_drvdata as well. I checked
it and did not find one occasion where it could be simplified like this. Not
much of a surprise because driver_data is usually set in probe() functions
which access struct platform_device in many other ways.
I am open for other comments, suggestions, too, of course.
Here is the cocci-script I created:
@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
- struct platform_device *pdev = to_platform_device(d);
|
- struct platform_device *pdev;
...
- pdev = to_platform_device(d);
)
<... when != pdev
- &pdev->dev
+ d
...>
ptr =
- platform_get_drvdata(pdev)
+ dev_get_drvdata(d)
<... when != pdev
- &pdev->dev
+ d
...>
Kind regards,
Wolfram
Wolfram Sang (5):
pinctrl: intel: pinctrl-baytrail: simplify getting .driver_data
pinctrl: intel: pinctrl-cherryview: simplify getting .driver_data
pinctrl: intel: pinctrl-intel: simplify getting .driver_data
pinctrl: pinctrl-amd: simplify getting .driver_data
pinctrl: pinctrl-at91-pio4: simplify getting .driver_data
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 ++----
5 files changed, 10 insertions(+), 20 deletions(-)
--
2.19.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 5/5] pinctrl: pinctrl-at91-pio4: simplify getting .driver_data
2018-10-21 20:00 [PATCH 0/5] pinctrl: simplify getting .driver_data Wolfram Sang
@ 2018-10-21 20:00 ` Wolfram Sang
2018-10-24 11:15 ` Alexandre Belloni
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wolfram Sang @ 2018-10-21 20:00 UTC (permalink / raw)
To: linux-arm-kernel
We should get 'driver_data' 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.
drivers/pinctrl/pinctrl-at91-pio4.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index 5a850491a5cb..4ee135d7b883 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -868,8 +868,7 @@ static struct pinctrl_desc atmel_pinctrl_desc = {
static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
+ struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(dev);
int i, j;
/*
@@ -897,8 +896,7 @@ static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
static int __maybe_unused atmel_pctrl_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
+ struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(dev);
int i, j;
for (i = 0; i < atmel_pioctrl->nbanks; i++) {
--
2.19.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/5] pinctrl: pinctrl-at91-pio4: simplify getting .driver_data
2018-10-21 20:00 ` [PATCH 5/5] pinctrl: pinctrl-at91-pio4: " Wolfram Sang
@ 2018-10-24 11:15 ` Alexandre Belloni
2018-10-29 14:32 ` Ludovic Desroches
2018-10-30 13:24 ` Linus Walleij
2 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2018-10-24 11:15 UTC (permalink / raw)
To: linux-arm-kernel
On 21/10/2018 22:00:31+0200, Wolfram Sang wrote:
> We should get 'driver_data' 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>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>
> Build tested only. buildbot is happy.
>
> drivers/pinctrl/pinctrl-at91-pio4.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
> index 5a850491a5cb..4ee135d7b883 100644
> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
> @@ -868,8 +868,7 @@ static struct pinctrl_desc atmel_pinctrl_desc = {
>
> static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
> {
> - struct platform_device *pdev = to_platform_device(dev);
> - struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
> + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(dev);
> int i, j;
>
> /*
> @@ -897,8 +896,7 @@ static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
>
> static int __maybe_unused atmel_pctrl_resume(struct device *dev)
> {
> - struct platform_device *pdev = to_platform_device(dev);
> - struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
> + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(dev);
> int i, j;
>
> for (i = 0; i < atmel_pioctrl->nbanks; i++) {
> --
> 2.19.0
>
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 5/5] pinctrl: pinctrl-at91-pio4: simplify getting .driver_data
2018-10-21 20:00 ` [PATCH 5/5] pinctrl: pinctrl-at91-pio4: " Wolfram Sang
2018-10-24 11:15 ` Alexandre Belloni
@ 2018-10-29 14:32 ` Ludovic Desroches
2018-10-30 13:24 ` Linus Walleij
2 siblings, 0 replies; 5+ messages in thread
From: Ludovic Desroches @ 2018-10-29 14:32 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Oct 21, 2018 at 10:00:31PM +0200, Wolfram Sang wrote:
> We should get 'driver_data' 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: Ludovic Desroches <ludovic.desroches@microchip.com>
Thanks
> ---
>
> Build tested only. buildbot is happy.
>
> drivers/pinctrl/pinctrl-at91-pio4.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
> index 5a850491a5cb..4ee135d7b883 100644
> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
> @@ -868,8 +868,7 @@ static struct pinctrl_desc atmel_pinctrl_desc = {
>
> static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
> {
> - struct platform_device *pdev = to_platform_device(dev);
> - struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
> + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(dev);
> int i, j;
>
> /*
> @@ -897,8 +896,7 @@ static int __maybe_unused atmel_pctrl_suspend(struct device *dev)
>
> static int __maybe_unused atmel_pctrl_resume(struct device *dev)
> {
> - struct platform_device *pdev = to_platform_device(dev);
> - struct atmel_pioctrl *atmel_pioctrl = platform_get_drvdata(pdev);
> + struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(dev);
> int i, j;
>
> for (i = 0; i < atmel_pioctrl->nbanks; i++) {
> --
> 2.19.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 5/5] pinctrl: pinctrl-at91-pio4: simplify getting .driver_data
2018-10-21 20:00 ` [PATCH 5/5] pinctrl: pinctrl-at91-pio4: " Wolfram Sang
2018-10-24 11:15 ` Alexandre Belloni
2018-10-29 14:32 ` Ludovic Desroches
@ 2018-10-30 13:24 ` Linus Walleij
2 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2018-10-30 13:24 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Oct 21, 2018 at 10:00 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> We should get 'driver_data' 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>
Patch applied with the acks.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-10-30 13:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-21 20:00 [PATCH 0/5] pinctrl: simplify getting .driver_data Wolfram Sang
2018-10-21 20:00 ` [PATCH 5/5] pinctrl: pinctrl-at91-pio4: " Wolfram Sang
2018-10-24 11:15 ` Alexandre Belloni
2018-10-29 14:32 ` Ludovic Desroches
2018-10-30 13:24 ` Linus Walleij
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).