* [PATCH] PM: Add EXPORT macros for exporting PM functions
@ 2023-02-13 13:20 Richard Fitzgerald
2023-02-13 15:43 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Richard Fitzgerald @ 2023-02-13 13:20 UTC (permalink / raw)
To: rafael, pavel, len.brown
Cc: linux-pm, linux-kernel, patches, Richard Fitzgerald
Add a set of macros for exporting functions only if CONFIG_PM
is enabled.
The naming follows the style of the standard EXPORT_SYMBOL_*()
macros that they replace.
Sometimes a module wants to export PM functions directly to other
drivers, not a complete struct dev_pm_ops. A typical example is
where a core library exports the generic (shared) implementation
and calling code wraps one or more of these in custom code.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
include/linux/pm.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 93cd34f00822..21618f7087f8 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -379,9 +379,17 @@ const struct dev_pm_ops name = { \
const struct dev_pm_ops name; \
__EXPORT_SYMBOL(name, sec, ns); \
const struct dev_pm_ops name
+#define EXPORT_PM_FN(name) EXPORT_SYMBOL(name)
+#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
+#define EXPORT_PM_FN_NS(name, ns) EXPORT_SYMBOL_NS(name, ns)
+#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
#else
#define _EXPORT_DEV_PM_OPS(name, sec, ns) \
static __maybe_unused const struct dev_pm_ops __static_##name
+#define EXPORT_PM_FN(name)
+#define EXPORT_PM_FN_GPL(name)
+#define EXPORT_PM_FN_NS(name, ns)
+#define EXPORT_PM_FN_NS_GPL(name, ns)
#endif
#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: Add EXPORT macros for exporting PM functions
2023-02-13 13:20 [PATCH] PM: Add EXPORT macros for exporting PM functions Richard Fitzgerald
@ 2023-02-13 15:43 ` Rafael J. Wysocki
2023-02-13 15:50 ` Richard Fitzgerald
0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2023-02-13 15:43 UTC (permalink / raw)
To: Richard Fitzgerald
Cc: rafael, pavel, len.brown, linux-pm, linux-kernel, patches
On Mon, Feb 13, 2023 at 2:20 PM Richard Fitzgerald
<rf@opensource.cirrus.com> wrote:
>
> Add a set of macros for exporting functions only if CONFIG_PM
> is enabled.
>
> The naming follows the style of the standard EXPORT_SYMBOL_*()
> macros that they replace.
>
> Sometimes a module wants to export PM functions directly to other
> drivers, not a complete struct dev_pm_ops. A typical example is
> where a core library exports the generic (shared) implementation
> and calling code wraps one or more of these in custom code.
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> ---
> include/linux/pm.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/include/linux/pm.h b/include/linux/pm.h
> index 93cd34f00822..21618f7087f8 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -379,9 +379,17 @@ const struct dev_pm_ops name = { \
> const struct dev_pm_ops name; \
> __EXPORT_SYMBOL(name, sec, ns); \
> const struct dev_pm_ops name
> +#define EXPORT_PM_FN(name) EXPORT_SYMBOL(name)
> +#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
> +#define EXPORT_PM_FN_NS(name, ns) EXPORT_SYMBOL_NS(name, ns)
> +#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
Why are the non-GPL variants needed?
> #else
> #define _EXPORT_DEV_PM_OPS(name, sec, ns) \
> static __maybe_unused const struct dev_pm_ops __static_##name
> +#define EXPORT_PM_FN(name)
> +#define EXPORT_PM_FN_GPL(name)
> +#define EXPORT_PM_FN_NS(name, ns)
> +#define EXPORT_PM_FN_NS_GPL(name, ns)
> #endif
>
> #define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: Add EXPORT macros for exporting PM functions
2023-02-13 15:43 ` Rafael J. Wysocki
@ 2023-02-13 15:50 ` Richard Fitzgerald
2023-02-13 15:57 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Richard Fitzgerald @ 2023-02-13 15:50 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: pavel, len.brown, linux-pm, linux-kernel, patches
On 13/02/2023 15:43, Rafael J. Wysocki wrote:
> On Mon, Feb 13, 2023 at 2:20 PM Richard Fitzgerald
> <rf@opensource.cirrus.com> wrote:
>>
>> Add a set of macros for exporting functions only if CONFIG_PM
>> is enabled.
>>
>> The naming follows the style of the standard EXPORT_SYMBOL_*()
>> macros that they replace.
>>
>> Sometimes a module wants to export PM functions directly to other
>> drivers, not a complete struct dev_pm_ops. A typical example is
>> where a core library exports the generic (shared) implementation
>> and calling code wraps one or more of these in custom code.
>>
>> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
>> ---
>> include/linux/pm.h | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/include/linux/pm.h b/include/linux/pm.h
>> index 93cd34f00822..21618f7087f8 100644
>> --- a/include/linux/pm.h
>> +++ b/include/linux/pm.h
>> @@ -379,9 +379,17 @@ const struct dev_pm_ops name = { \
>> const struct dev_pm_ops name; \
>> __EXPORT_SYMBOL(name, sec, ns); \
>> const struct dev_pm_ops name
>> +#define EXPORT_PM_FN(name) EXPORT_SYMBOL(name)
>> +#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
>> +#define EXPORT_PM_FN_NS(name, ns) EXPORT_SYMBOL_NS(name, ns)
>> +#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
>
> Why are the non-GPL variants needed?
>
I did all four because there are all four variants of EXPORT_DEV_PM_OPS.
Why are the non-GPL variants of EXPORT_DEV_PM_OPS needed?
I can remove the non-GPL variants of my macros.
>> #else
>> #define _EXPORT_DEV_PM_OPS(name, sec, ns) \
>> static __maybe_unused const struct dev_pm_ops __static_##name
>> +#define EXPORT_PM_FN(name)
>> +#define EXPORT_PM_FN_GPL(name)
>> +#define EXPORT_PM_FN_NS(name, ns)
>> +#define EXPORT_PM_FN_NS_GPL(name, ns)
>> #endif
>>
>> #define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
>> --
>> 2.30.2
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: Add EXPORT macros for exporting PM functions
2023-02-13 15:50 ` Richard Fitzgerald
@ 2023-02-13 15:57 ` Rafael J. Wysocki
0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2023-02-13 15:57 UTC (permalink / raw)
To: Richard Fitzgerald
Cc: Rafael J. Wysocki, pavel, len.brown, linux-pm, linux-kernel, patches
On Mon, Feb 13, 2023 at 4:50 PM Richard Fitzgerald
<rf@opensource.cirrus.com> wrote:
>
> On 13/02/2023 15:43, Rafael J. Wysocki wrote:
> > On Mon, Feb 13, 2023 at 2:20 PM Richard Fitzgerald
> > <rf@opensource.cirrus.com> wrote:
> >>
> >> Add a set of macros for exporting functions only if CONFIG_PM
> >> is enabled.
> >>
> >> The naming follows the style of the standard EXPORT_SYMBOL_*()
> >> macros that they replace.
> >>
> >> Sometimes a module wants to export PM functions directly to other
> >> drivers, not a complete struct dev_pm_ops. A typical example is
> >> where a core library exports the generic (shared) implementation
> >> and calling code wraps one or more of these in custom code.
> >>
> >> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> >> ---
> >> include/linux/pm.h | 8 ++++++++
> >> 1 file changed, 8 insertions(+)
> >>
> >> diff --git a/include/linux/pm.h b/include/linux/pm.h
> >> index 93cd34f00822..21618f7087f8 100644
> >> --- a/include/linux/pm.h
> >> +++ b/include/linux/pm.h
> >> @@ -379,9 +379,17 @@ const struct dev_pm_ops name = { \
> >> const struct dev_pm_ops name; \
> >> __EXPORT_SYMBOL(name, sec, ns); \
> >> const struct dev_pm_ops name
> >> +#define EXPORT_PM_FN(name) EXPORT_SYMBOL(name)
> >> +#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
> >> +#define EXPORT_PM_FN_NS(name, ns) EXPORT_SYMBOL_NS(name, ns)
> >> +#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
> >
> > Why are the non-GPL variants needed?
> >
>
> I did all four because there are all four variants of EXPORT_DEV_PM_OPS.
> Why are the non-GPL variants of EXPORT_DEV_PM_OPS needed?
They aren't or at least they should not be needed in the mainline.
> I can remove the non-GPL variants of my macros.
Yes, please!
> >> #else
> >> #define _EXPORT_DEV_PM_OPS(name, sec, ns) \
> >> static __maybe_unused const struct dev_pm_ops __static_##name
> >> +#define EXPORT_PM_FN(name)
> >> +#define EXPORT_PM_FN_GPL(name)
> >> +#define EXPORT_PM_FN_NS(name, ns)
> >> +#define EXPORT_PM_FN_NS_GPL(name, ns)
> >> #endif
> >>
> >> #define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
> >> --
> >> 2.30.2
> >>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-13 15:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13 13:20 [PATCH] PM: Add EXPORT macros for exporting PM functions Richard Fitzgerald
2023-02-13 15:43 ` Rafael J. Wysocki
2023-02-13 15:50 ` Richard Fitzgerald
2023-02-13 15:57 ` Rafael J. Wysocki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.