Skip to content

Commit 8d74f1d

Browse files
raagjadavrafaeljw
authored andcommitted
PM: sleep: Fix symbol export for _SIMPLE_ variants of _PM_OPS()
Currently EXPORT_*_SIMPLE_DEV_PM_OPS() use EXPORT_*_DEV_PM_OPS() set of macros to export dev_pm_ops symbol, which export the symbol in case CONFIG_PM=y but don't take CONFIG_PM_SLEEP into consideration. Since _SIMPLE_ variants of _PM_OPS() do not include runtime PM handles and are only used in case CONFIG_PM_SLEEP=y, we should not be exporting dev_pm_ops symbol for them in case CONFIG_PM_SLEEP=n. This can be fixed by having two distinct set of export macros for both _RUNTIME_ and _SIMPLE_ variants of _PM_OPS(), such that the export of dev_pm_ops symbol used in each variant depends on CONFIG_PM and CONFIG_PM_SLEEP respectively. Introduce _DEV_SLEEP_PM_OPS() set of export macros for _SIMPLE_ variants of _PM_OPS(), which export dev_pm_ops symbol only in case CONFIG_PM_SLEEP=y and discard it otherwise. Fixes: 34e1ed1 ("PM: Improve EXPORT_*_DEV_PM_OPS macros") Signed-off-by: Raag Jadav <[email protected]> Reviewed-by: Paul Cercueil <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f0c7183 commit 8d74f1d

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

include/linux/pm.h

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -374,24 +374,39 @@ const struct dev_pm_ops name = { \
374374
RUNTIME_PM_OPS(runtime_suspend_fn, runtime_resume_fn, idle_fn) \
375375
}
376376

377-
#ifdef CONFIG_PM
378-
#define _EXPORT_DEV_PM_OPS(name, license, ns) \
377+
#define _EXPORT_PM_OPS(name, license, ns) \
379378
const struct dev_pm_ops name; \
380379
__EXPORT_SYMBOL(name, license, ns); \
381380
const struct dev_pm_ops name
382-
#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
383-
#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
384-
#else
385-
#define _EXPORT_DEV_PM_OPS(name, license, ns) \
381+
382+
#define _DISCARD_PM_OPS(name, license, ns) \
386383
static __maybe_unused const struct dev_pm_ops __static_##name
384+
385+
#ifdef CONFIG_PM
386+
#define _EXPORT_DEV_PM_OPS(name, license, ns) _EXPORT_PM_OPS(name, license, ns)
387+
#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
388+
#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
389+
#else
390+
#define _EXPORT_DEV_PM_OPS(name, license, ns) _DISCARD_PM_OPS(name, license, ns)
387391
#define EXPORT_PM_FN_GPL(name)
388392
#define EXPORT_PM_FN_NS_GPL(name, ns)
389393
#endif
390394

391-
#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
392-
#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "GPL", "")
393-
#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns)
394-
#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "GPL", #ns)
395+
#ifdef CONFIG_PM_SLEEP
396+
#define _EXPORT_DEV_SLEEP_PM_OPS(name, license, ns) _EXPORT_PM_OPS(name, license, ns)
397+
#else
398+
#define _EXPORT_DEV_SLEEP_PM_OPS(name, license, ns) _DISCARD_PM_OPS(name, license, ns)
399+
#endif
400+
401+
#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
402+
#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "GPL", "")
403+
#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns)
404+
#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "GPL", #ns)
405+
406+
#define EXPORT_DEV_SLEEP_PM_OPS(name) _EXPORT_DEV_SLEEP_PM_OPS(name, "", "")
407+
#define EXPORT_GPL_DEV_SLEEP_PM_OPS(name) _EXPORT_DEV_SLEEP_PM_OPS(name, "GPL", "")
408+
#define EXPORT_NS_DEV_SLEEP_PM_OPS(name, ns) _EXPORT_DEV_SLEEP_PM_OPS(name, "", #ns)
409+
#define EXPORT_NS_GPL_DEV_SLEEP_PM_OPS(name, ns) _EXPORT_DEV_SLEEP_PM_OPS(name, "GPL", #ns)
395410

396411
/*
397412
* Use this if you want to use the same suspend and resume callbacks for suspend
@@ -404,19 +419,19 @@ const struct dev_pm_ops name = { \
404419
_DEFINE_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL)
405420

406421
#define EXPORT_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
407-
EXPORT_DEV_PM_OPS(name) = { \
422+
EXPORT_DEV_SLEEP_PM_OPS(name) = { \
408423
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
409424
}
410425
#define EXPORT_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
411-
EXPORT_GPL_DEV_PM_OPS(name) = { \
426+
EXPORT_GPL_DEV_SLEEP_PM_OPS(name) = { \
412427
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
413428
}
414429
#define EXPORT_NS_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns) \
415-
EXPORT_NS_DEV_PM_OPS(name, ns) = { \
430+
EXPORT_NS_DEV_SLEEP_PM_OPS(name, ns) = { \
416431
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
417432
}
418433
#define EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns) \
419-
EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
434+
EXPORT_NS_GPL_DEV_SLEEP_PM_OPS(name, ns) = { \
420435
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
421436
}
422437

0 commit comments

Comments
 (0)