From: Ulf Hansson <ulf.hansson@linaro.org> To: "Rafael J. Wysocki" <rjw@rjwysocki.net>, Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>, linux-pm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Kevin Hilman <khilman@linaro.org>, Alan Stern <stern@rowland.harvard.edu>, Mark Brown <broonie@kernel.org>, Russell King <linux@arm.linux.org.uk>, Linus Walleij <linus.walleij@linaro.org>, Wolfram Sang <wsa@the-dreams.de>, Alessandro Rubini <rubini@unipv.it>, Ulf Hansson <ulf.hansson@linaro.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [PATCH 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Date: Thu, 20 Feb 2014 16:31:13 +0100 [thread overview] Message-ID: <1392910280-12891-2-git-send-email-ulf.hansson@linaro.org> (raw) In-Reply-To: <1392910280-12891-1-git-send-email-ulf.hansson@linaro.org> While fetching the proper runtime PM callback, we walk the hierarchy of device's power domains, subsystems and drivers. This is common for rpm_suspend(), rpm_idle() and rpm_resume(). Let's clean up the code by using a macro that handles this. Cc: Kevin Hilman <khilman@linaro.org> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Mark Brown <broonie@kernel.org> Cc: Russell King <linux@arm.linux.org.uk> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Wolfram Sang <wsa@the-dreams.de> Cc: Alessandro Rubini <rubini@unipv.it> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> --- drivers/base/power/runtime.c | 59 ++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 72e00e6..dedbd64 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -13,6 +13,23 @@ #include <trace/events/rpm.h> #include "power.h" +#define RPM_GET_CALLBACK(dev, cb) \ +({ \ + if (dev->pm_domain) \ + callback = dev->pm_domain->ops.cb; \ + else if (dev->type && dev->type->pm) \ + callback = dev->type->pm->cb; \ + else if (dev->class && dev->class->pm) \ + callback = dev->class->pm->cb; \ + else if (dev->bus && dev->bus->pm) \ + callback = dev->bus->pm->cb; \ + else \ + callback = NULL; \ + \ + if (!callback && dev->driver && dev->driver->pm) \ + callback = dev->driver->pm->cb; \ +}) + static int rpm_resume(struct device *dev, int rpmflags); static int rpm_suspend(struct device *dev, int rpmflags); @@ -310,19 +327,7 @@ static int rpm_idle(struct device *dev, int rpmflags) dev->power.idle_notification = true; - if (dev->pm_domain) - callback = dev->pm_domain->ops.runtime_idle; - else if (dev->type && dev->type->pm) - callback = dev->type->pm->runtime_idle; - else if (dev->class && dev->class->pm) - callback = dev->class->pm->runtime_idle; - else if (dev->bus && dev->bus->pm) - callback = dev->bus->pm->runtime_idle; - else - callback = NULL; - - if (!callback && dev->driver && dev->driver->pm) - callback = dev->driver->pm->runtime_idle; + RPM_GET_CALLBACK(dev, runtime_idle); if (callback) retval = __rpm_callback(callback, dev); @@ -492,19 +497,7 @@ static int rpm_suspend(struct device *dev, int rpmflags) __update_runtime_status(dev, RPM_SUSPENDING); - if (dev->pm_domain) - callback = dev->pm_domain->ops.runtime_suspend; - else if (dev->type && dev->type->pm) - callback = dev->type->pm->runtime_suspend; - else if (dev->class && dev->class->pm) - callback = dev->class->pm->runtime_suspend; - else if (dev->bus && dev->bus->pm) - callback = dev->bus->pm->runtime_suspend; - else - callback = NULL; - - if (!callback && dev->driver && dev->driver->pm) - callback = dev->driver->pm->runtime_suspend; + RPM_GET_CALLBACK(dev, runtime_suspend); retval = rpm_callback(callback, dev); if (retval) @@ -724,19 +717,7 @@ static int rpm_resume(struct device *dev, int rpmflags) __update_runtime_status(dev, RPM_RESUMING); - if (dev->pm_domain) - callback = dev->pm_domain->ops.runtime_resume; - else if (dev->type && dev->type->pm) - callback = dev->type->pm->runtime_resume; - else if (dev->class && dev->class->pm) - callback = dev->class->pm->runtime_resume; - else if (dev->bus && dev->bus->pm) - callback = dev->bus->pm->runtime_resume; - else - callback = NULL; - - if (!callback && dev->driver && dev->driver->pm) - callback = dev->driver->pm->runtime_resume; + RPM_GET_CALLBACK(dev, runtime_resume); retval = rpm_callback(callback, dev); if (retval) { -- 1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: ulf.hansson@linaro.org (Ulf Hansson) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Date: Thu, 20 Feb 2014 16:31:13 +0100 [thread overview] Message-ID: <1392910280-12891-2-git-send-email-ulf.hansson@linaro.org> (raw) In-Reply-To: <1392910280-12891-1-git-send-email-ulf.hansson@linaro.org> While fetching the proper runtime PM callback, we walk the hierarchy of device's power domains, subsystems and drivers. This is common for rpm_suspend(), rpm_idle() and rpm_resume(). Let's clean up the code by using a macro that handles this. Cc: Kevin Hilman <khilman@linaro.org> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Mark Brown <broonie@kernel.org> Cc: Russell King <linux@arm.linux.org.uk> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Wolfram Sang <wsa@the-dreams.de> Cc: Alessandro Rubini <rubini@unipv.it> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> --- drivers/base/power/runtime.c | 59 ++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 72e00e6..dedbd64 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -13,6 +13,23 @@ #include <trace/events/rpm.h> #include "power.h" +#define RPM_GET_CALLBACK(dev, cb) \ +({ \ + if (dev->pm_domain) \ + callback = dev->pm_domain->ops.cb; \ + else if (dev->type && dev->type->pm) \ + callback = dev->type->pm->cb; \ + else if (dev->class && dev->class->pm) \ + callback = dev->class->pm->cb; \ + else if (dev->bus && dev->bus->pm) \ + callback = dev->bus->pm->cb; \ + else \ + callback = NULL; \ + \ + if (!callback && dev->driver && dev->driver->pm) \ + callback = dev->driver->pm->cb; \ +}) + static int rpm_resume(struct device *dev, int rpmflags); static int rpm_suspend(struct device *dev, int rpmflags); @@ -310,19 +327,7 @@ static int rpm_idle(struct device *dev, int rpmflags) dev->power.idle_notification = true; - if (dev->pm_domain) - callback = dev->pm_domain->ops.runtime_idle; - else if (dev->type && dev->type->pm) - callback = dev->type->pm->runtime_idle; - else if (dev->class && dev->class->pm) - callback = dev->class->pm->runtime_idle; - else if (dev->bus && dev->bus->pm) - callback = dev->bus->pm->runtime_idle; - else - callback = NULL; - - if (!callback && dev->driver && dev->driver->pm) - callback = dev->driver->pm->runtime_idle; + RPM_GET_CALLBACK(dev, runtime_idle); if (callback) retval = __rpm_callback(callback, dev); @@ -492,19 +497,7 @@ static int rpm_suspend(struct device *dev, int rpmflags) __update_runtime_status(dev, RPM_SUSPENDING); - if (dev->pm_domain) - callback = dev->pm_domain->ops.runtime_suspend; - else if (dev->type && dev->type->pm) - callback = dev->type->pm->runtime_suspend; - else if (dev->class && dev->class->pm) - callback = dev->class->pm->runtime_suspend; - else if (dev->bus && dev->bus->pm) - callback = dev->bus->pm->runtime_suspend; - else - callback = NULL; - - if (!callback && dev->driver && dev->driver->pm) - callback = dev->driver->pm->runtime_suspend; + RPM_GET_CALLBACK(dev, runtime_suspend); retval = rpm_callback(callback, dev); if (retval) @@ -724,19 +717,7 @@ static int rpm_resume(struct device *dev, int rpmflags) __update_runtime_status(dev, RPM_RESUMING); - if (dev->pm_domain) - callback = dev->pm_domain->ops.runtime_resume; - else if (dev->type && dev->type->pm) - callback = dev->type->pm->runtime_resume; - else if (dev->class && dev->class->pm) - callback = dev->class->pm->runtime_resume; - else if (dev->bus && dev->bus->pm) - callback = dev->bus->pm->runtime_resume; - else - callback = NULL; - - if (!callback && dev->driver && dev->driver->pm) - callback = dev->driver->pm->runtime_resume; + RPM_GET_CALLBACK(dev, runtime_resume); retval = rpm_callback(callback, dev); if (retval) { -- 1.7.9.5
next prev parent reply other threads:[~2014-02-20 15:31 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-02-20 15:31 [PATCH 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson [this message] 2014-02-20 15:31 ` [PATCH 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Ulf Hansson 2014-02-20 16:28 ` Josh Cartwright 2014-02-20 16:28 ` Josh Cartwright 2014-02-26 15:50 ` Kevin Hilman 2014-02-26 15:50 ` Kevin Hilman 2014-02-26 22:02 ` Ulf Hansson 2014-02-26 22:02 ` Ulf Hansson 2014-02-20 15:31 ` [PATCH 2/8] PM / Sleep / Runtime: Add pm_runtime_suspend|resume_force functions Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson 2014-02-20 15:31 ` [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson 2014-02-20 17:25 ` Josh Cartwright 2014-02-20 17:25 ` Josh Cartwright 2014-02-20 15:31 ` [PATCH 4/8] spi: pl022: Don't ignore power domain and amba bus at system suspend Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson 2014-02-20 15:31 ` [PATCH 5/8] i2c: nomadik: Fixup " Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson 2014-02-20 15:31 ` [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson 2014-02-20 15:31 ` [PATCH 7/8] mmc: mmci: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson 2014-02-20 15:31 ` [PATCH 8/8] mmc: mmci: Put the device into low power state at system suspend Ulf Hansson 2014-02-20 15:31 ` Ulf Hansson 2014-02-26 16:30 ` [PATCH 0/8] PM / Sleep / Runtime: Fixup some driver's " Kevin Hilman 2014-02-26 16:30 ` Kevin Hilman 2014-02-26 22:30 ` Ulf Hansson 2014-02-26 22:30 ` Ulf Hansson 2014-02-27 1:22 ` Rafael J. Wysocki 2014-02-27 1:22 ` Rafael J. Wysocki 2014-02-27 8:18 ` Ulf Hansson 2014-02-27 8:18 ` Ulf Hansson 2014-02-28 17:21 ` Kevin Hilman 2014-02-28 17:21 ` Kevin Hilman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1392910280-12891-2-git-send-email-ulf.hansson@linaro.org \ --to=ulf.hansson@linaro.org \ --cc=broonie@kernel.org \ --cc=gregkh@linuxfoundation.org \ --cc=khilman@linaro.org \ --cc=len.brown@intel.com \ --cc=linus.walleij@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-pm@vger.kernel.org \ --cc=linux@arm.linux.org.uk \ --cc=pavel@ucw.cz \ --cc=rjw@rjwysocki.net \ --cc=rubini@unipv.it \ --cc=stern@rowland.harvard.edu \ --cc=wsa@the-dreams.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.