diff mbox series

[v3,01/11] pwm: atmel-hlcdc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions

Message ID 20231023174616.2282067-14-u.kleine-koenig@pengutronix.de
State Accepted
Delegated to: Uwe Kleine-König
Headers show
Series pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions | expand

Commit Message

Uwe Kleine-König Oct. 23, 2023, 5:46 p.m. UTC
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-atmel-hlcdc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Nicolas Ferre Oct. 24, 2023, 7:42 a.m. UTC | #1
On 23/10/2023 at 19:46, Uwe Kleine-König wrote:
> This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
> care about when the functions are actually used, so the corresponding
> #ifdef can be dropped.
> 
> Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
> isn't enabled.
> 
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>   drivers/pwm/pwm-atmel-hlcdc.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
> index 07920e034757..3f2c5031a3ba 100644
> --- a/drivers/pwm/pwm-atmel-hlcdc.c
> +++ b/drivers/pwm/pwm-atmel-hlcdc.c
> @@ -180,7 +180,6 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
>          .div1_clk_erratum = true,
>   };
> 
> -#ifdef CONFIG_PM_SLEEP
>   static int atmel_hlcdc_pwm_suspend(struct device *dev)
>   {
>          struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
> @@ -210,10 +209,9 @@ static int atmel_hlcdc_pwm_resume(struct device *dev)
>          return atmel_hlcdc_pwm_apply(&atmel->chip, &atmel->chip.pwms[0],
>                                       &state);
>   }
> -#endif
> 
> -static SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
> -                        atmel_hlcdc_pwm_suspend, atmel_hlcdc_pwm_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
> +                               atmel_hlcdc_pwm_suspend, atmel_hlcdc_pwm_resume);
> 
>   static const struct of_device_id atmel_hlcdc_dt_ids[] = {
>          {
> @@ -297,7 +295,7 @@ static struct platform_driver atmel_hlcdc_pwm_driver = {
>          .driver = {
>                  .name = "atmel-hlcdc-pwm",
>                  .of_match_table = atmel_hlcdc_pwm_dt_ids,
> -               .pm = &atmel_hlcdc_pwm_pm_ops,
> +               .pm = pm_ptr(&atmel_hlcdc_pwm_pm_ops),
>          },
>          .probe = atmel_hlcdc_pwm_probe,
>          .remove_new = atmel_hlcdc_pwm_remove,
> --
> 2.42.0
>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
index 07920e034757..3f2c5031a3ba 100644
--- a/drivers/pwm/pwm-atmel-hlcdc.c
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -180,7 +180,6 @@  static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
 	.div1_clk_erratum = true,
 };
 
-#ifdef CONFIG_PM_SLEEP
 static int atmel_hlcdc_pwm_suspend(struct device *dev)
 {
 	struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
@@ -210,10 +209,9 @@  static int atmel_hlcdc_pwm_resume(struct device *dev)
 	return atmel_hlcdc_pwm_apply(&atmel->chip, &atmel->chip.pwms[0],
 				     &state);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
-			 atmel_hlcdc_pwm_suspend, atmel_hlcdc_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
+				atmel_hlcdc_pwm_suspend, atmel_hlcdc_pwm_resume);
 
 static const struct of_device_id atmel_hlcdc_dt_ids[] = {
 	{
@@ -297,7 +295,7 @@  static struct platform_driver atmel_hlcdc_pwm_driver = {
 	.driver = {
 		.name = "atmel-hlcdc-pwm",
 		.of_match_table = atmel_hlcdc_pwm_dt_ids,
-		.pm = &atmel_hlcdc_pwm_pm_ops,
+		.pm = pm_ptr(&atmel_hlcdc_pwm_pm_ops),
 	},
 	.probe = atmel_hlcdc_pwm_probe,
 	.remove_new = atmel_hlcdc_pwm_remove,