diff mbox

[10/61] gpio: simplify getting .drvdata

Message ID 20180419140641.27926-11-wsa+renesas@sang-engineering.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wolfram Sang April 19, 2018, 2:05 p.m. UTC
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(-)

Comments

Grygorii Strashko April 19, 2018, 3:14 p.m. UTC | #1
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);
>   }
>
Michal Simek April 20, 2018, 7:20 a.m. UTC | #2
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
Wolfram Sang April 21, 2018, 4:23 p.m. UTC | #3
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.
Michal Simek April 23, 2018, 6:04 a.m. UTC | #4
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
Linus Walleij April 30, 2018, 9:03 a.m. UTC | #5
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
Wolfram Sang April 30, 2018, 9:12 a.m. UTC | #6
> 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/
Thierry Reding April 30, 2018, 9:29 a.m. UTC | #7
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
Adam Ford March 7, 2019, 8:13 p.m. UTC | #8
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
Wolfram Sang March 7, 2019, 8:18 p.m. UTC | #9
> 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.
Enrico Weigelt, metux IT consult March 7, 2019, 8:53 p.m. UTC | #10
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
Wolfram Sang March 7, 2019, 8:58 p.m. UTC | #11
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.
Wolfram Sang March 19, 2019, 2:31 p.m. UTC | #12
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
diff mbox

Patch

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