mbox series

[RFC,0/3] Introduce pm_ptr() / pm_sleep_ptr()

Message ID 20200211160321.22124-1-paul@crapouillou.net (mailing list archive)
Headers show
Series Introduce pm_ptr() / pm_sleep_ptr() | expand

Message

Paul Cercueil Feb. 11, 2020, 4:03 p.m. UTC
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(-)