2023-07-17 17:31:14

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 06/10] pinctrl: at91: Switch to use DEFINE_NOIRQ_DEV_PM_OPS() helper

Since pm.h provides a helper for system no-IRQ PM callbacks,
switch the driver to use it instead of open coded variant.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/pinctrl-at91.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 39956d821ad7..608f55c5ba5f 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1657,7 +1657,7 @@ static int gpio_irq_set_wake(struct irq_data *d, unsigned state)
return 0;
}

-static int __maybe_unused at91_gpio_suspend(struct device *dev)
+static int at91_gpio_suspend(struct device *dev)
{
struct at91_gpio_chip *at91_chip = dev_get_drvdata(dev);
void __iomem *pio = at91_chip->regbase;
@@ -1675,7 +1675,7 @@ static int __maybe_unused at91_gpio_suspend(struct device *dev)
return 0;
}

-static int __maybe_unused at91_gpio_resume(struct device *dev)
+static int at91_gpio_resume(struct device *dev)
{
struct at91_gpio_chip *at91_chip = dev_get_drvdata(dev);
void __iomem *pio = at91_chip->regbase;
@@ -1903,15 +1903,13 @@ static int at91_gpio_probe(struct platform_device *pdev)
return 0;
}

-static const struct dev_pm_ops at91_gpio_pm_ops = {
- NOIRQ_SYSTEM_SLEEP_PM_OPS(at91_gpio_suspend, at91_gpio_resume)
-};
+static DEFINE_NOIRQ_DEV_PM_OPS(at91_gpio_pm_ops, at91_gpio_suspend, at91_gpio_resume);

static struct platform_driver at91_gpio_driver = {
.driver = {
.name = "gpio-at91",
.of_match_table = at91_gpio_of_match,
- .pm = pm_ptr(&at91_gpio_pm_ops),
+ .pm = pm_sleep_ptr(&at91_gpio_pm_ops),
},
.probe = at91_gpio_probe,
};
--
2.40.0.1.gaa8946217a0b



2023-07-17 19:54:26

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 06/10] pinctrl: at91: Switch to use DEFINE_NOIRQ_DEV_PM_OPS() helper

On Mon, Jul 17, 2023 at 10:26 PM Paul Cercueil <[email protected]> wrote:
> Le lundi 17 juillet 2023 à 20:28 +0300, Andy Shevchenko a écrit :
> > Since pm.h provides a helper for system no-IRQ PM callbacks,
> > switch the driver to use it instead of open coded variant.
> >
> > Signed-off-by: Andy Shevchenko <[email protected]>
>
> Reviewed-by: Paul Cercueil <[email protected]>

Thank you!

> Although you could add a bit more info in the message of this patch, to
> explain why it's OK to remove the __maybe_unused tags (the code is
> always visible) and why switch from pm_ptr() to pm_sleep_ptr() (it's
> only used for system-PM callbacks).

Sure.

--
With Best Regards,
Andy Shevchenko

2023-07-17 20:18:04

by Paul Cercueil

[permalink] [raw]
Subject: Re: [PATCH v2 06/10] pinctrl: at91: Switch to use DEFINE_NOIRQ_DEV_PM_OPS() helper

Hi Andy,

Le lundi 17 juillet 2023 à 20:28 +0300, Andy Shevchenko a écrit :
> Since pm.h provides a helper for system no-IRQ PM callbacks,
> switch the driver to use it instead of open coded variant.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Paul Cercueil <[email protected]>

Although you could add a bit more info in the message of this patch, to
explain why it's OK to remove the __maybe_unused tags (the code is
always visible) and why switch from pm_ptr() to pm_sleep_ptr() (it's
only used for system-PM callbacks).

Cheers,
-Paul

> ---
>  drivers/pinctrl/pinctrl-at91.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-at91.c
> b/drivers/pinctrl/pinctrl-at91.c
> index 39956d821ad7..608f55c5ba5f 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1657,7 +1657,7 @@ static int gpio_irq_set_wake(struct irq_data
> *d, unsigned state)
>         return 0;
>  }
>  
> -static int __maybe_unused at91_gpio_suspend(struct device *dev)
> +static int at91_gpio_suspend(struct device *dev)
>  {
>         struct at91_gpio_chip *at91_chip = dev_get_drvdata(dev);
>         void __iomem *pio = at91_chip->regbase;
> @@ -1675,7 +1675,7 @@ static int __maybe_unused
> at91_gpio_suspend(struct device *dev)
>         return 0;
>  }
>  
> -static int __maybe_unused at91_gpio_resume(struct device *dev)
> +static int at91_gpio_resume(struct device *dev)
>  {
>         struct at91_gpio_chip *at91_chip = dev_get_drvdata(dev);
>         void __iomem *pio = at91_chip->regbase;
> @@ -1903,15 +1903,13 @@ static int at91_gpio_probe(struct
> platform_device *pdev)
>         return 0;
>  }
>  
> -static const struct dev_pm_ops at91_gpio_pm_ops = {
> -       NOIRQ_SYSTEM_SLEEP_PM_OPS(at91_gpio_suspend,
> at91_gpio_resume)
> -};
> +static DEFINE_NOIRQ_DEV_PM_OPS(at91_gpio_pm_ops, at91_gpio_suspend,
> at91_gpio_resume);
>  
>  static struct platform_driver at91_gpio_driver = {
>         .driver = {
>                 .name = "gpio-at91",
>                 .of_match_table = at91_gpio_of_match,
> -               .pm = pm_ptr(&at91_gpio_pm_ops),
> +               .pm = pm_sleep_ptr(&at91_gpio_pm_ops),
>         },
>         .probe = at91_gpio_probe,
>  };


2023-07-18 15:36:23

by Claudiu

[permalink] [raw]
Subject: Re: [PATCH v2 06/10] pinctrl: at91: Switch to use DEFINE_NOIRQ_DEV_PM_OPS() helper

On 17.07.2023 20:28, Andy Shevchenko wrote:
> Since pm.h provides a helper for system no-IRQ PM callbacks,
> switch the driver to use it instead of open coded variant.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Claudiu Beznea <[email protected]>

> ---
> drivers/pinctrl/pinctrl-at91.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index 39956d821ad7..608f55c5ba5f 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1657,7 +1657,7 @@ static int gpio_irq_set_wake(struct irq_data *d, unsigned state)
> return 0;
> }
>
> -static int __maybe_unused at91_gpio_suspend(struct device *dev)
> +static int at91_gpio_suspend(struct device *dev)
> {
> struct at91_gpio_chip *at91_chip = dev_get_drvdata(dev);
> void __iomem *pio = at91_chip->regbase;
> @@ -1675,7 +1675,7 @@ static int __maybe_unused at91_gpio_suspend(struct device *dev)
> return 0;
> }
>
> -static int __maybe_unused at91_gpio_resume(struct device *dev)
> +static int at91_gpio_resume(struct device *dev)
> {
> struct at91_gpio_chip *at91_chip = dev_get_drvdata(dev);
> void __iomem *pio = at91_chip->regbase;
> @@ -1903,15 +1903,13 @@ static int at91_gpio_probe(struct platform_device *pdev)
> return 0;
> }
>
> -static const struct dev_pm_ops at91_gpio_pm_ops = {
> - NOIRQ_SYSTEM_SLEEP_PM_OPS(at91_gpio_suspend, at91_gpio_resume)
> -};
> +static DEFINE_NOIRQ_DEV_PM_OPS(at91_gpio_pm_ops, at91_gpio_suspend, at91_gpio_resume);
>
> static struct platform_driver at91_gpio_driver = {
> .driver = {
> .name = "gpio-at91",
> .of_match_table = at91_gpio_of_match,
> - .pm = pm_ptr(&at91_gpio_pm_ops),
> + .pm = pm_sleep_ptr(&at91_gpio_pm_ops),
> },
> .probe = at91_gpio_probe,
> };