diff mbox series

[1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own.

Message ID 20220807192038.1039771-2-jic23@kernel.org
State New
Headers show
Series PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO. | expand

Commit Message

Jonathan Cameron Aug. 7, 2022, 7:20 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

A driver wishing to export a struct dev_pm_ops with both suspend and
runtime ops provided could use _EXPORT_DEV_PM_OPS() directly but
that macro is not intended for use in drivers and requires non
intuitive aspect such as passing "_gpl" as one parameter and the
namespace as a string.  As such just provide a macro to cover
the GPL and NS case in a fashion that is in line with similar macros.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 include/linux/pm.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Paul Cercueil Aug. 8, 2022, 11:22 a.m. UTC | #1
Hi Jonathan,

If you can wait a day or two - I would like to submit my own version of 
EXPORT_NS_GPL_DEV_PM_OPS, which should be more versatile than your 
version.

Cheers,
-Paul


Le dim., août 7 2022 at 20:20:34 +0100, Jonathan Cameron 
<jic23@kernel.org> a écrit :
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> A driver wishing to export a struct dev_pm_ops with both suspend and
> runtime ops provided could use _EXPORT_DEV_PM_OPS() directly but
> that macro is not intended for use in drivers and requires non
> intuitive aspect such as passing "_gpl" as one parameter and the
> namespace as a string.  As such just provide a macro to cover
> the GPL and NS case in a fashion that is in line with similar macros.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Paul Cercueil <paul@crapouillou.net>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@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 871c9c49ec9d..18856e0d23ac 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -407,6 +407,11 @@ static __maybe_unused 
> _DEFINE_DEV_PM_OPS(__static_##name, suspend_fn, \
>  #define EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, 
> ns)	\
>  	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, 
> "_gpl", #ns)
> 
> +#define EXPORT_NS_GPL_DEV_PM_OPS(name, suspend_fn, resume_fn, 
> runtime_suspend_fn, \
> +			   runtime_resume_fn, idle_fn, ns) \
> +	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, 
> \
> +			   runtime_resume_fn, idle_fn, "_gpl", #ns)
> +
>  /* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */
>  #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
>  const struct dev_pm_ops __maybe_unused name = { \
> --
> 2.37.1
>
Jonathan Cameron Aug. 13, 2022, 4:14 p.m. UTC | #2
On Mon, 08 Aug 2022 13:22:37 +0200
Paul Cercueil <paul@crapouillou.net> wrote:

> Hi Jonathan,
> 
> If you can wait a day or two - I would like to submit my own version of 
> EXPORT_NS_GPL_DEV_PM_OPS, which should be more versatile than your 
> version.
Thanks. Yours approach is indeed preferable, I'll respin this on top of your
patch.

Its a bit enough change I'll probably not take any of the
existing tags forwards to v2.

Jonathan
 
> 
> Cheers,
> -Paul
> 
> 
> Le dim., ao_t 7 2022 at 20:20:34 +0100, Jonathan Cameron 
> <jic23@kernel.org> a _crit :
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > A driver wishing to export a struct dev_pm_ops with both suspend and
> > runtime ops provided could use _EXPORT_DEV_PM_OPS() directly but
> > that macro is not intended for use in drivers and requires non
> > intuitive aspect such as passing "_gpl" as one parameter and the
> > namespace as a string.  As such just provide a macro to cover
> > the GPL and NS case in a fashion that is in line with similar macros.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Paul Cercueil <paul@crapouillou.net>
> > Cc: Rafael J. Wysocki <rafael.j.wysocki@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 871c9c49ec9d..18856e0d23ac 100644
> > --- a/include/linux/pm.h
> > +++ b/include/linux/pm.h
> > @@ -407,6 +407,11 @@ static __maybe_unused 
> > _DEFINE_DEV_PM_OPS(__static_##name, suspend_fn, \
> >  #define EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, 
> > ns)	\
> >  	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, 
> > "_gpl", #ns)
> > 
> > +#define EXPORT_NS_GPL_DEV_PM_OPS(name, suspend_fn, resume_fn, 
> > runtime_suspend_fn, \
> > +			   runtime_resume_fn, idle_fn, ns) \
> > +	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, 
> > \
> > +			   runtime_resume_fn, idle_fn, "_gpl", #ns)
> > +
> >  /* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */
> >  #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
> >  const struct dev_pm_ops __maybe_unused name = { \
> > --
> > 2.37.1
> >   
> 
>
diff mbox series

Patch

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 871c9c49ec9d..18856e0d23ac 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -407,6 +407,11 @@  static __maybe_unused _DEFINE_DEV_PM_OPS(__static_##name, suspend_fn, \
 #define EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns)	\
 	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, "_gpl", #ns)
 
+#define EXPORT_NS_GPL_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
+			   runtime_resume_fn, idle_fn, ns) \
+	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
+			   runtime_resume_fn, idle_fn, "_gpl", #ns)
+
 /* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */
 #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
 const struct dev_pm_ops __maybe_unused name = { \