From: "Rafael J. Wysocki" <rafael@kernel.org>
To: patrice.chotard@st.com
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Linux PM <linux-pm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
Kevin Hilman <khilman@kernel.org>,
Erwan Le Ray <erwan.leray@st.com>,
Alexandre TORGUE <alexandre.torgue@st.com>,
Fabrice Gasnier <fabrice.gasnier@st.com>,
Pierre-Yves MORDRET <pierre-yves.mordret@st.com>,
amelie.delaunay@st.com, alain.volmat@st.com
Subject: Re: [PATCH v2] PM: Add dev_wakeup_path() helper
Date: Mon, 23 Nov 2020 18:36:42 +0100 [thread overview]
Message-ID: <CAJZ5v0hUGt5O7zS7yRVC-3tk2fqVOYt2=bV_D0521A09p-S4-g@mail.gmail.com> (raw)
In-Reply-To: <20201119072539.5673-1-patrice.chotard@st.com>
On Thu, Nov 19, 2020 at 8:26 AM <patrice.chotard@st.com> wrote:
>
> From: Patrice Chotard <patrice.chotard@st.com>
>
> Add dev_wakeup_path() helper to avoid to spread
> dev->power.wakeup_path test in drivers.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>
> Changes from v1:
> - Fold the 4 v1 patches into one
> - Add Ulf's Reviewed-by
>
> drivers/base/power/domain.c | 4 ++--
> drivers/base/power/main.c | 4 ++--
> drivers/i2c/busses/i2c-stm32f7.c | 4 ++--
> include/linux/pm_wakeup.h | 10 ++++++++++
> 4 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 743268996336..e0894ef8457c 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1142,7 +1142,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff)
> if (ret)
> return ret;
>
> - if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd))
> + if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd))
> return 0;
>
> if (genpd->dev_ops.stop && genpd->dev_ops.start &&
> @@ -1196,7 +1196,7 @@ static int genpd_resume_noirq(struct device *dev)
> if (IS_ERR(genpd))
> return -EINVAL;
>
> - if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd))
> + if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd))
> return pm_generic_resume_noirq(dev);
>
> genpd_lock(genpd);
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index c7ac49042cee..921c5b2ec30a 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -1359,7 +1359,7 @@ static void dpm_propagate_wakeup_to_parent(struct device *dev)
>
> spin_lock_irq(&parent->power.lock);
>
> - if (dev->power.wakeup_path && !parent->power.ignore_children)
> + if (device_wakeup_path(dev) && !parent->power.ignore_children)
> parent->power.wakeup_path = true;
>
> spin_unlock_irq(&parent->power.lock);
> @@ -1627,7 +1627,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
> goto Complete;
>
> /* Avoid direct_complete to let wakeup_path propagate. */
> - if (device_may_wakeup(dev) || dev->power.wakeup_path)
> + if (device_may_wakeup(dev) || device_wakeup_path(dev))
> dev->power.direct_complete = false;
>
> if (dev->power.direct_complete) {
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index f41f51a176a1..9aa8e65b511e 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -2322,7 +2322,7 @@ static int stm32f7_i2c_suspend(struct device *dev)
>
> i2c_mark_adapter_suspended(&i2c_dev->adap);
>
> - if (!device_may_wakeup(dev) && !dev->power.wakeup_path) {
> + if (!device_may_wakeup(dev) && !device_wakeup_path(dev)) {
> ret = stm32f7_i2c_regs_backup(i2c_dev);
> if (ret < 0) {
> i2c_mark_adapter_resumed(&i2c_dev->adap);
> @@ -2341,7 +2341,7 @@ static int stm32f7_i2c_resume(struct device *dev)
> struct stm32f7_i2c_dev *i2c_dev = dev_get_drvdata(dev);
> int ret;
>
> - if (!device_may_wakeup(dev) && !dev->power.wakeup_path) {
> + if (!device_may_wakeup(dev) && !device_wakeup_path(dev)) {
> ret = pm_runtime_force_resume(dev);
> if (ret < 0)
> return ret;
> diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h
> index aa3da6611533..196a157456aa 100644
> --- a/include/linux/pm_wakeup.h
> +++ b/include/linux/pm_wakeup.h
> @@ -84,6 +84,11 @@ static inline bool device_may_wakeup(struct device *dev)
> return dev->power.can_wakeup && !!dev->power.wakeup;
> }
>
> +static inline bool device_wakeup_path(struct device *dev)
> +{
> + return dev->power.wakeup_path;
> +}
> +
> static inline void device_set_wakeup_path(struct device *dev)
> {
> dev->power.wakeup_path = true;
> @@ -174,6 +179,11 @@ static inline bool device_may_wakeup(struct device *dev)
> return dev->power.can_wakeup && dev->power.should_wakeup;
> }
>
> +static inline bool device_wakeup_path(struct device *dev)
> +{
> + return false;
> +}
> +
> static inline void device_set_wakeup_path(struct device *dev) {}
>
> static inline void __pm_stay_awake(struct wakeup_source *ws) {}
> --
Applied as 5.11 material, thanks!
prev parent reply other threads:[~2020-11-23 17:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 7:25 [PATCH v2] PM: Add dev_wakeup_path() helper patrice.chotard
2020-11-23 17:36 ` Rafael J. Wysocki [this message]
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='CAJZ5v0hUGt5O7zS7yRVC-3tk2fqVOYt2=bV_D0521A09p-S4-g@mail.gmail.com' \
--to=rafael@kernel.org \
--cc=alain.volmat@st.com \
--cc=alexandre.torgue@st.com \
--cc=amelie.delaunay@st.com \
--cc=erwan.leray@st.com \
--cc=fabrice.gasnier@st.com \
--cc=khilman@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=patrice.chotard@st.com \
--cc=pierre-yves.mordret@st.com \
--cc=rjw@rjwysocki.net \
--cc=ulf.hansson@linaro.org \
/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 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).