linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] Introduce pm_ptr() / pm_sleep_ptr()
@ 2020-02-11 16:03 Paul Cercueil
  2020-02-11 16:03 ` [RFC PATCH 1/3] PM: introduce pm_ptr() and pm_sleep_ptr() Paul Cercueil
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Paul Cercueil @ 2020-02-11 16:03 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown, Pavel Machek
  Cc: Ulf Hansson, od, linux-pm, linux-mmc, linux-kernel, Paul Cercueil

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(-)

-- 
2.25.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-02-24 15:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11 16:03 [RFC PATCH 0/3] Introduce pm_ptr() / pm_sleep_ptr() Paul Cercueil
2020-02-11 16:03 ` [RFC PATCH 1/3] PM: introduce pm_ptr() and pm_sleep_ptr() Paul Cercueil
2020-02-11 16:03 ` [RFC PATCH 2/3] PM: Make *_DEV_PM_OPS macros use __maybe_unused Paul Cercueil
2020-02-11 16:03 ` [RFC PATCH 3/3] mmc: jz4740: Use pm_sleep_ptr() macro Paul Cercueil
2020-02-20 13:38   ` Ulf Hansson
2020-02-20 13:42     ` Ulf Hansson
2020-02-24 15:41     ` Paul Cercueil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).