From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Ran Wang <ran.wang_1@nxp.com>
Cc: Mark Rutland <mark.rutland@arm.com>, Li Biwen <biwen.li@nxp.com>,
Len Brown <len.brown@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linux PM <linux-pm@vger.kernel.org>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Li Yang <leoyang.li@nxp.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Rob Herring <robh+dt@kernel.org>, Pavel Machek <pavel@ucw.cz>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v7 1/3] PM: wakeup: Add routine to help fetch wakeup source object.
Date: Mon, 21 Oct 2019 10:38:07 +0200 [thread overview]
Message-ID: <CAJZ5v0hO5Jtr_kyBbCawYc+fS0JQGcU-xfhS9S7DKiFQYJSJvQ@mail.gmail.com> (raw)
In-Reply-To: <20191021034927.19300-1-ran.wang_1@nxp.com>
On Mon, Oct 21, 2019 at 5:49 AM Ran Wang <ran.wang_1@nxp.com> wrote:
>
> Some user might want to go through all registered wakeup sources
> and doing things accordingly. For example, SoC PM driver might need to
> do HW programming to prevent powering down specific IP which wakeup
> source depending on. So add this API to help walk through all registered
> wakeup source objects on that list and return them one by one.
>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> Tested-by: Leonard Crestez <leonard.crestez@nxp.com>
> ---
> Change in v7:
> - Remove define of member *dev in wake_irq to fix conflict with commit
> c8377adfa781 ("PM / wakeup: Show wakeup sources stats in sysfs"), user
> will use ws->dev->parent instead.
> - Remove '#include <linux/of_device.h>' because it is not used.
>
> Change in v6:
> - Add wakeup_source_get_star() and wakeup_source_get_stop() to aligned
> with wakeup_sources_stats_seq_start/nex/stop.
>
> Change in v5:
> - Update commit message, add decription of walk through all wakeup
> source objects.
> - Add SCU protection in function wakeup_source_get_next().
> - Rename wakeup_source member 'attached_dev' to 'dev' and move it up
> (before wakeirq).
>
> Change in v4:
> - None.
>
> Change in v3:
> - Adjust indentation of *attached_dev;.
>
> Change in v2:
> - None.
>
> drivers/base/power/wakeup.c | 37 +++++++++++++++++++++++++++++++++++++
> include/linux/pm_wakeup.h | 3 +++
> 2 files changed, 40 insertions(+)
>
> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> index 5817b51..dee1b09 100644
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -248,6 +248,43 @@ void wakeup_source_unregister(struct wakeup_source *ws)
> EXPORT_SYMBOL_GPL(wakeup_source_unregister);
>
> /**
> + * wakeup_source_get_star - Begin a walk on wakeup source list
The "get" in the name suggests acquiring a reference of some kind
which doesn't happen here.
What about renaming it to wakeup_sources_walk_start()?
> + * @srcuidx: Lock index allocated for this caller.
> + */
> +struct wakeup_source *wakeup_source_get_start(int *srcuidx)
I don't quite like the calling convention here with passing an int
pointer to get the SRCU index back.
What about splitting this into, say, wakeup_sources_read_lock() (that
will return the SRCU index) and wakeup_sources_walk_start() (that will
return the first list entry)?
Then, you could do something like
idx = wakeup_sources_read_lock();
ws = wakeup_sources_walk_start();
while (ws) {
stuff
ws = wakeup_sources_walk_next();
}
wakeup_sources_read_unlock(idx);
Or even define for_each_wakeup_source(ws) as
for (ws = wakeup_sources_walk_start(); ws; ws = wakeup_sources_walk_next())
and use that under a _read_lock()/_read_unlock() pair?
prev parent reply other threads:[~2019-10-21 8:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 3:49 [PATCH v7 1/3] PM: wakeup: Add routine to help fetch wakeup source object Ran Wang
2019-10-21 3:49 ` [PATCH v7 2/3] Documentation: dt: binding: fsl: Add 'little-endian' and update Chassis define Ran Wang
2019-10-24 18:33 ` Scott Wood
2019-10-25 2:40 ` Ran Wang
2019-10-21 3:49 ` [PATCH v7 3/3] soc: fsl: add RCPM driver Ran Wang
2019-10-24 2:57 ` kbuild test robot
2019-10-21 8:38 ` 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=CAJZ5v0hO5Jtr_kyBbCawYc+fS0JQGcU-xfhS9S7DKiFQYJSJvQ@mail.gmail.com \
--to=rafael@kernel.org \
--cc=biwen.li@nxp.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=len.brown@intel.com \
--cc=leoyang.li@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=pavel@ucw.cz \
--cc=ran.wang_1@nxp.com \
--cc=rjw@rjwysocki.net \
--cc=robh+dt@kernel.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).