From: Josh Cartwright <joshc@codeaurora.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, Kevin Hilman <khilman@linaro.org>,
Russell King <linux@arm.linux.org.uk>,
Wolfram Sang <wsa@the-dreams.de>,
Linus Walleij <linus.walleij@linaro.org>,
Mark Brown <broonie@kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
linux-arm-kernel@lists.infradead.org,
Alessandro Rubini <rubini@unipv.it>
Subject: Re: [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM
Date: Thu, 20 Feb 2014 11:25:24 -0600 [thread overview]
Message-ID: <20140220172523.GE31820@joshc.qualcomm.com> (raw)
In-Reply-To: <1392910280-12891-4-git-send-email-ulf.hansson@linaro.org>
(comments below only marginally related to this change)
On Thu, Feb 20, 2014 at 04:31:15PM +0100, Ulf Hansson wrote:
> Convert to the SET_PM_RUNTIME_PM macro while defining the runtime PM
> callbacks. This means the callbacks becomes available for both
> CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME, which is needed to handle the
> combinations of these scenarios.
>
> Cc: Mark Brown <broonie@kernel.org>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> drivers/spi/spi-pl022.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
> index 74a0729..6dfcabf 100644
> --- a/drivers/spi/spi-pl022.c
> +++ b/drivers/spi/spi-pl022.c
> @@ -2277,7 +2277,7 @@ pl022_remove(struct amba_device *adev)
> return 0;
> }
>
> -#if defined(CONFIG_SUSPEND) || defined(CONFIG_PM_RUNTIME)
> +#ifdef CONFIG_PM
I wish we could get rid of PM-related #ifdefery in drivers...
For what it's worth, while working on another project, I discovered that
using a ternary operator in initializers might actually be able to help
out a bit:
/*
* Intended for use in static object initializers,
* assign_if(const_expr, function) evaluates to 'function' if
* 'const_expr', otherwise NULL.
*
* The type of the assign_if() expression is typeof(function),
* and therefore can provide typechecking regardless of
* 'const_expr'.
*
* gcc considers 'function' to be used and will not generate a
* 'defined but not used' when not 'const_expr', however, gcc is
* smart enough to eliminate 'function' if assign_if() is the
* only reference.
*/
#define assign_if(const_expr, function) \
((const_expr) ? function : NULL)
#define assign_if_enabled(option, function) \
assign_if(IS_ENABLED(option), function)
#define assign_if_rpm(function) \
assign_if_enabled(CONFIG_PM_RUNTIME, function)
static int foo_runtime_suspend(struct device *dev)
{
return 0;
}
static struct dev_pm_ops foo_pm_ops = {
.runtime_suspend = assign_if_rpm(foo_runtime_suspend),
};
So, in this example, wrapping the definition of foo_runtime_suspend in
#ifdef CONFIG_PM_RUNTIME is unnecessary, as gcc will not emit it if
!CONFIG_PM_RUNTIME is not set (at least from my experiments).
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
WARNING: multiple messages have this Message-ID (diff)
From: joshc@codeaurora.org (Josh Cartwright)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM
Date: Thu, 20 Feb 2014 11:25:24 -0600 [thread overview]
Message-ID: <20140220172523.GE31820@joshc.qualcomm.com> (raw)
In-Reply-To: <1392910280-12891-4-git-send-email-ulf.hansson@linaro.org>
(comments below only marginally related to this change)
On Thu, Feb 20, 2014 at 04:31:15PM +0100, Ulf Hansson wrote:
> Convert to the SET_PM_RUNTIME_PM macro while defining the runtime PM
> callbacks. This means the callbacks becomes available for both
> CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME, which is needed to handle the
> combinations of these scenarios.
>
> Cc: Mark Brown <broonie@kernel.org>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> drivers/spi/spi-pl022.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
> index 74a0729..6dfcabf 100644
> --- a/drivers/spi/spi-pl022.c
> +++ b/drivers/spi/spi-pl022.c
> @@ -2277,7 +2277,7 @@ pl022_remove(struct amba_device *adev)
> return 0;
> }
>
> -#if defined(CONFIG_SUSPEND) || defined(CONFIG_PM_RUNTIME)
> +#ifdef CONFIG_PM
I wish we could get rid of PM-related #ifdefery in drivers...
For what it's worth, while working on another project, I discovered that
using a ternary operator in initializers might actually be able to help
out a bit:
/*
* Intended for use in static object initializers,
* assign_if(const_expr, function) evaluates to 'function' if
* 'const_expr', otherwise NULL.
*
* The type of the assign_if() expression is typeof(function),
* and therefore can provide typechecking regardless of
* 'const_expr'.
*
* gcc considers 'function' to be used and will not generate a
* 'defined but not used' when not 'const_expr', however, gcc is
* smart enough to eliminate 'function' if assign_if() is the
* only reference.
*/
#define assign_if(const_expr, function) \
((const_expr) ? function : NULL)
#define assign_if_enabled(option, function) \
assign_if(IS_ENABLED(option), function)
#define assign_if_rpm(function) \
assign_if_enabled(CONFIG_PM_RUNTIME, function)
static int foo_runtime_suspend(struct device *dev)
{
return 0;
}
static struct dev_pm_ops foo_pm_ops = {
.runtime_suspend = assign_if_rpm(foo_runtime_suspend),
};
So, in this example, wrapping the definition of foo_runtime_suspend in
#ifdef CONFIG_PM_RUNTIME is unnecessary, as gcc will not emit it if
!CONFIG_PM_RUNTIME is not set (at least from my experiments).
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2014-02-20 17:27 UTC|newest]
Thread overview: 40+ 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 ` [PATCH 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Ulf Hansson
2014-02-20 15:31 ` 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 [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2014-03-01 10:56 [PATCH V3 " Ulf Hansson
2014-03-01 10:56 ` [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
2014-03-01 10:56 ` Ulf Hansson
2014-03-06 4:45 ` Mark Brown
2014-03-06 4:45 ` Mark Brown
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=20140220172523.GE31820@joshc.qualcomm.com \
--to=joshc@codeaurora.org \
--cc=broonie@kernel.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=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.