diff mbox series

[v1,1/3] pm: Introduce DEFINE_NOIRQ_DEV_PM_OPS() helper

Message ID 20221229125957.45923-2-andriy.shevchenko@linux.intel.com
State New
Headers show
Series pinctrl: intel: Provide NOIRQ PM helper and use it | expand

Commit Message

Andy Shevchenko Dec. 29, 2022, 12:59 p.m. UTC
There are a few drivers and might be more in the future that
open code the functionality of proposed DEFINE_NOIRQ_DEV_PM_OPS()
helper. From now on they may switch to the new helper and save
a few lines of code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/pm.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Rafael J. Wysocki Dec. 30, 2022, 6:43 p.m. UTC | #1
On Thu, Dec 29, 2022 at 1:59 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> There are a few drivers and might be more in the future that
> open code the functionality of proposed DEFINE_NOIRQ_DEV_PM_OPS()
> helper. From now on they may switch to the new helper and save
> a few lines of code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/pm.h | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/include/linux/pm.h b/include/linux/pm.h
> index 93cd34f00822..eba96822b1d9 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -444,6 +444,11 @@ const struct dev_pm_ops __maybe_unused name = { \
>         SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
>  }
>
> +#define DEFINE_NOIRQ_DEV_PM_OPS(name, suspend_fn, resume_fn) \
> +const struct dev_pm_ops name = { \
> +       NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
> +}

There is NOIRQ_SYSTEM_SLEEP_PM_OPS(), so why is the above needed in addition?

> +
>  #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
>  #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
>
> --
Andy Shevchenko Dec. 30, 2022, 7:23 p.m. UTC | #2
On Fri, Dec 30, 2022 at 8:43 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> On Thu, Dec 29, 2022 at 1:59 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > There are a few drivers and might be more in the future that
> > open code the functionality of proposed DEFINE_NOIRQ_DEV_PM_OPS()
> > helper. From now on they may switch to the new helper and save
> > a few lines of code.

...

> > +#define DEFINE_NOIRQ_DEV_PM_OPS(name, suspend_fn, resume_fn) \
> > +const struct dev_pm_ops name = { \
> > +       NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
> > +}
>
> There is NOIRQ_SYSTEM_SLEEP_PM_OPS(), so why is the above needed in addition?

It defines the constant object of struct dev_pm_ops type with this
included and as the commit message says, allows to save a few lines of
code in each of the drivers that uses NOIRQ_SYSTEM_SLEEP_PM_OPS()
currently. The examples on how to convert are provided in the patches
2 and 3.
Rafael J. Wysocki Dec. 30, 2022, 7:32 p.m. UTC | #3
On Fri, Dec 30, 2022 at 8:23 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Fri, Dec 30, 2022 at 8:43 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > On Thu, Dec 29, 2022 at 1:59 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > There are a few drivers and might be more in the future that
> > > open code the functionality of proposed DEFINE_NOIRQ_DEV_PM_OPS()
> > > helper. From now on they may switch to the new helper and save
> > > a few lines of code.
>
> ...
>
> > > +#define DEFINE_NOIRQ_DEV_PM_OPS(name, suspend_fn, resume_fn) \
> > > +const struct dev_pm_ops name = { \
> > > +       NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
> > > +}
> >
> > There is NOIRQ_SYSTEM_SLEEP_PM_OPS(), so why is the above needed in addition?
>
> It defines the constant object of struct dev_pm_ops type with this
> included and as the commit message says, allows to save a few lines of
> code in each of the drivers that uses NOIRQ_SYSTEM_SLEEP_PM_OPS()
> currently. The examples on how to convert are provided in the patches
> 2 and 3.

So this is in analogy with _DEFINE_DEV_PM_OPS(), isn't it?  It would
be good to mention this in the changelog.

IMO the changelog is rather hard to follow in general and it should
not refer to the changes made in order to understand what's going on.
diff mbox series

Patch

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 93cd34f00822..eba96822b1d9 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -444,6 +444,11 @@  const struct dev_pm_ops __maybe_unused name = { \
 	SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
 }
 
+#define DEFINE_NOIRQ_DEV_PM_OPS(name, suspend_fn, resume_fn) \
+const struct dev_pm_ops name = { \
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+}
+
 #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
 #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))