From: Kevin Hilman <khilman@linaro.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Alan Stern <stern@rowland.harvard.edu>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
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>,
Josh Cartwright <joshc@codeaurora.org>
Subject: Re: [PATCH V2 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro
Date: Wed, 26 Feb 2014 15:00:42 -0800 [thread overview]
Message-ID: <7hk3chwkbp.fsf@paris.lan> (raw)
In-Reply-To: <1393237368-15500-1-git-send-email-ulf.hansson@linaro.org> (Ulf Hansson's message of "Mon, 24 Feb 2014 11:22:48 +0100")
Ulf Hansson <ulf.hansson@linaro.org> writes:
> 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>
> ---
>
> Changes in v2:
> Updated the macro to return a callback instead.
> Suggested by Josh Cartwright.
>
> ---
> drivers/base/power/runtime.c | 63 ++++++++++++++++--------------------------
> 1 file changed, 24 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index 72e00e6..cc7d1ed 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -13,6 +13,27 @@
> #include <trace/events/rpm.h>
> #include "power.h"
>
> +#define RPM_GET_CALLBACK(dev, cb) \
> +({ \
> + int (*__rpm_cb)(struct device *__d); \
> + \
> + if (dev->pm_domain) \
> + __rpm_cb = dev->pm_domain->ops.cb; \
> + else if (dev->type && dev->type->pm) \
> + __rpm_cb = dev->type->pm->cb; \
> + else if (dev->class && dev->class->pm) \
> + __rpm_cb = dev->class->pm->cb; \
> + else if (dev->bus && dev->bus->pm) \
> + __rpm_cb = dev->bus->pm->cb; \
> + else \
> + __rpm_cb = NULL; \
> + \
> + if (!__rpm_cb && dev->driver && dev->driver->pm) \
> + __rpm_cb = dev->driver->pm->cb; \
> + \
> + __rpm_cb; \
> +})
So the main question from v1 remains: why use a macro, and not a function?
Kevin
WARNING: multiple messages have this Message-ID (diff)
From: khilman@linaro.org (Kevin Hilman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro
Date: Wed, 26 Feb 2014 15:00:42 -0800 [thread overview]
Message-ID: <7hk3chwkbp.fsf@paris.lan> (raw)
In-Reply-To: <1393237368-15500-1-git-send-email-ulf.hansson@linaro.org> (Ulf Hansson's message of "Mon, 24 Feb 2014 11:22:48 +0100")
Ulf Hansson <ulf.hansson@linaro.org> writes:
> 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>
> ---
>
> Changes in v2:
> Updated the macro to return a callback instead.
> Suggested by Josh Cartwright.
>
> ---
> drivers/base/power/runtime.c | 63 ++++++++++++++++--------------------------
> 1 file changed, 24 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index 72e00e6..cc7d1ed 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -13,6 +13,27 @@
> #include <trace/events/rpm.h>
> #include "power.h"
>
> +#define RPM_GET_CALLBACK(dev, cb) \
> +({ \
> + int (*__rpm_cb)(struct device *__d); \
> + \
> + if (dev->pm_domain) \
> + __rpm_cb = dev->pm_domain->ops.cb; \
> + else if (dev->type && dev->type->pm) \
> + __rpm_cb = dev->type->pm->cb; \
> + else if (dev->class && dev->class->pm) \
> + __rpm_cb = dev->class->pm->cb; \
> + else if (dev->bus && dev->bus->pm) \
> + __rpm_cb = dev->bus->pm->cb; \
> + else \
> + __rpm_cb = NULL; \
> + \
> + if (!__rpm_cb && dev->driver && dev->driver->pm) \
> + __rpm_cb = dev->driver->pm->cb; \
> + \
> + __rpm_cb; \
> +})
So the main question from v1 remains: why use a macro, and not a function?
Kevin
next prev parent reply other threads:[~2014-02-26 23:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-24 10:22 [PATCH V2 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Ulf Hansson
2014-02-24 10:22 ` Ulf Hansson
2014-02-26 23:00 ` Kevin Hilman [this message]
2014-02-26 23:00 ` Kevin Hilman
2014-02-26 23:13 ` Ulf Hansson
2014-02-26 23:13 ` Ulf Hansson
2014-02-27 15:04 ` Alan Stern
2014-02-27 15:04 ` Alan Stern
2014-02-27 15:26 ` Ulf Hansson
2014-02-27 15:26 ` Ulf Hansson
2014-02-27 16:22 ` Alan Stern
2014-02-27 16:22 ` Alan Stern
2014-02-27 21:13 ` Ulf Hansson
2014-02-27 21:13 ` Ulf Hansson
2014-02-27 21:25 ` Alan Stern
2014-02-27 21:25 ` Alan Stern
2014-02-27 22:36 ` Ulf Hansson
2014-02-27 22:36 ` Ulf Hansson
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=7hk3chwkbp.fsf@paris.lan \
--to=khilman@linaro.org \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=joshc@codeaurora.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=ulf.hansson@linaro.org \
--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: link
Be 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.