Skip to content

RFC Introduce pm_ptr() / pm_sleep_ptr()

Paul Cercueil linux-mmc linux-pm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3PM: introduce pm_ptr() and pm_sleep_ptr()include/linux/pm.h+12 -00 replies
2/3PM: Make *_DEV_PM_OPS macros use __maybe_unusedinclude/linux/pm.h+2 -20 replies
3/3mmc: jz4740: Use pm_sleep_ptr() macrodrivers/mmc/host/jz4740_mmc.c+3 -93 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/3] Introduce pm_ptr() / pm_sleep_ptr()

Hi,

I've seen many times things like:

#ifdef CONFIG_PM_SLEEP
static SIMPLE_DEV_PM_OPS(foo_pm_ops, foo_suspend, foo_resume); #define FOO_PM_OPS (&foo_pm_ops)
#else
#define FOO_PM_OPS NULL
#endif
static struct platform_driver foo_driver = {
.driver.pm = FOO_PM_OPS,
};

And always wondered why there was no of-match-ptr-like macro to make things cleaner.

So this RFC adds two macros, pm_ptr() and pm_sleep_ptr(), which resolve to their argument when CONFIG_PM or CONFIG_PM_SLEEP (respectively) are enabled, or NULL otherwise.

Patch 3/3 is an example of what it would look like when used in a driver.

Comments welcome.

Cheers,
-Paul

Paul Cercueil (3):
PM: introduce pm_ptr() and pm_sleep_ptr()
PM: Make *_DEV_PM_OPS macros use __maybe_unused
mmc: jz4740: Use pm_sleep_ptr() macro

 drivers/mmc/host/jz4740_mmc.c | 12 +++---------
 include/linux/pm.h            | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 11 deletions(-)
Signature · 1 line
2.25.0