diff mbox series

[05/18] hwmon: (gpio-fan) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()

Message ID 20220925172759.3573439-6-jic23@kernel.org (mailing list archive)
State Accepted
Headers show
Series hwmon: Move to new PM macros reducing driver complexity | expand

Commit Message

Jonathan Cameron Sept. 25, 2022, 5:27 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

These newer PM macros allow the compiler to see what code it can remove
if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst
achieving the same result.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/hwmon/gpio-fan.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Guenter Roeck Sept. 25, 2022, 6:49 p.m. UTC | #1
On Sun, Sep 25, 2022 at 06:27:46PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> These newer PM macros allow the compiler to see what code it can remove
> if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst
> achieving the same result.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>

This patch resulted in build errors.

Building m68k:allmodconfig ... failed
--------------
Error log:
drivers/hwmon/gpio-fan.c: In function 'gpio_fan_suspend':
drivers/hwmon/gpio-fan.c:565:27: error: 'struct gpio_fan_data' has no member named 'resume_speed'

There was an #ifdef CONFIG_PM_SLEEP in struct gpio_fan_data which had
to be dropped. I took care of that.

Guenter

> ---
>  drivers/hwmon/gpio-fan.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
> index fbf3f5a4ecb6..b05aedd20b4f 100644
> --- a/drivers/hwmon/gpio-fan.c
> +++ b/drivers/hwmon/gpio-fan.c
> @@ -557,7 +557,6 @@ static void gpio_fan_shutdown(struct platform_device *pdev)
>  		set_fan_speed(fan_data, 0);
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int gpio_fan_suspend(struct device *dev)
>  {
>  	struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
> @@ -580,18 +579,14 @@ static int gpio_fan_resume(struct device *dev)
>  	return 0;
>  }
>  
> -static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
> -#define GPIO_FAN_PM	(&gpio_fan_pm)
> -#else
> -#define GPIO_FAN_PM	NULL
> -#endif
> +static DEFINE_SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
>  
>  static struct platform_driver gpio_fan_driver = {
>  	.probe		= gpio_fan_probe,
>  	.shutdown	= gpio_fan_shutdown,
>  	.driver	= {
>  		.name	= "gpio-fan",
> -		.pm	= GPIO_FAN_PM,
> +		.pm	= pm_sleep_ptr(&gpio_fan_pm),
>  		.of_match_table = of_match_ptr(of_gpio_fan_match),
>  	},
>  };
Jonathan Cameron Sept. 26, 2022, 8:32 a.m. UTC | #2
On Sun, 25 Sep 2022 11:49:54 -0700
Guenter Roeck <linux@roeck-us.net> wrote:

> On Sun, Sep 25, 2022 at 06:27:46PM +0100, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > These newer PM macros allow the compiler to see what code it can remove
> > if !CONFIG_PM_SLEEP. This allows the removal of messy #ifdef barriers whilst
> > achieving the same result.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Linus Walleij <linus.walleij@linaro.org>  
> 
> This patch resulted in build errors.
> 
> Building m68k:allmodconfig ... failed
> --------------
> Error log:
> drivers/hwmon/gpio-fan.c: In function 'gpio_fan_suspend':
> drivers/hwmon/gpio-fan.c:565:27: error: 'struct gpio_fan_data' has no member named 'resume_speed'
> 
> There was an #ifdef CONFIG_PM_SLEEP in struct gpio_fan_data which had
> to be dropped. I took care of that.

Thanks!  I clearly missed some tests I should have done.
Sorry about that.

Jonathan


> 
> Guenter
> 
> > ---
> >  drivers/hwmon/gpio-fan.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
> > index fbf3f5a4ecb6..b05aedd20b4f 100644
> > --- a/drivers/hwmon/gpio-fan.c
> > +++ b/drivers/hwmon/gpio-fan.c
> > @@ -557,7 +557,6 @@ static void gpio_fan_shutdown(struct platform_device *pdev)
> >  		set_fan_speed(fan_data, 0);
> >  }
> >  
> > -#ifdef CONFIG_PM_SLEEP
> >  static int gpio_fan_suspend(struct device *dev)
> >  {
> >  	struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
> > @@ -580,18 +579,14 @@ static int gpio_fan_resume(struct device *dev)
> >  	return 0;
> >  }
> >  
> > -static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
> > -#define GPIO_FAN_PM	(&gpio_fan_pm)
> > -#else
> > -#define GPIO_FAN_PM	NULL
> > -#endif
> > +static DEFINE_SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
> >  
> >  static struct platform_driver gpio_fan_driver = {
> >  	.probe		= gpio_fan_probe,
> >  	.shutdown	= gpio_fan_shutdown,
> >  	.driver	= {
> >  		.name	= "gpio-fan",
> > -		.pm	= GPIO_FAN_PM,
> > +		.pm	= pm_sleep_ptr(&gpio_fan_pm),
> >  		.of_match_table = of_match_ptr(of_gpio_fan_match),
> >  	},
> >  };
diff mbox series

Patch

diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index fbf3f5a4ecb6..b05aedd20b4f 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -557,7 +557,6 @@  static void gpio_fan_shutdown(struct platform_device *pdev)
 		set_fan_speed(fan_data, 0);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int gpio_fan_suspend(struct device *dev)
 {
 	struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
@@ -580,18 +579,14 @@  static int gpio_fan_resume(struct device *dev)
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
-#define GPIO_FAN_PM	(&gpio_fan_pm)
-#else
-#define GPIO_FAN_PM	NULL
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
 
 static struct platform_driver gpio_fan_driver = {
 	.probe		= gpio_fan_probe,
 	.shutdown	= gpio_fan_shutdown,
 	.driver	= {
 		.name	= "gpio-fan",
-		.pm	= GPIO_FAN_PM,
+		.pm	= pm_sleep_ptr(&gpio_fan_pm),
 		.of_match_table = of_match_ptr(of_gpio_fan_match),
 	},
 };