[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0gOZkXp3X3hNTAtyuFoBA2xUMX274qv=yaj0jYD8XRgBw@mail.gmail.com>
Date: Fri, 6 Aug 2021 15:27:51 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
Pavel Machek <pavel@....cz>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Stephen Boyd <sboyd@...nel.org>,
Taniya Das <tdas@...eaurora.org>,
Michael Turquette <mturquette@...libre.com>,
Andy Gross <agross@...nel.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Linux PM <linux-pm@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-clk <linux-clk@...r.kernel.org>,
linux-arm-msm <linux-arm-msm@...r.kernel.org>
Subject: Re: [PATCH v3 1/3] PM: runtime: add devm_pm_runtime_enable helper
On Wed, Aug 4, 2021 at 11:03 PM Dmitry Baryshkov
<dmitry.baryshkov@...aro.org> wrote:
>
> On Wed, 4 Aug 2021 at 21:07, Rafael J. Wysocki <rafael@...nel.org> wrote:
> >
> > On Sat, Jul 31, 2021 at 9:50 PM Dmitry Baryshkov
> > <dmitry.baryshkov@...aro.org> wrote:
> > >
> > > A typical code pattern for pm_runtime_enable() call is to call it in the
> > > _probe function and to call pm_runtime_disable() both from _probe error
> > > path and from _remove function. For some drivers the whole remove
> > > function would consist of the call to pm_remove_disable().
> > >
> > > Add helper function to replace this bolierplate piece of code. Calling
> > > devm_pm_runtime_enable() removes the need for calling
> > > pm_runtime_disable() both in the probe()'s error path and in the
> > > remove() function.
> > >
> > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
> > > ---
> > > drivers/base/power/runtime.c | 17 +++++++++++++++++
> > > include/linux/pm_runtime.h | 4 ++++
> > > 2 files changed, 21 insertions(+)
> > >
> > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> > > index 8a66eaf731e4..ec94049442b9 100644
> > > --- a/drivers/base/power/runtime.c
> > > +++ b/drivers/base/power/runtime.c
> > > @@ -1447,6 +1447,23 @@ void pm_runtime_enable(struct device *dev)
> > > }
> > > EXPORT_SYMBOL_GPL(pm_runtime_enable);
> > >
> > > +static void pm_runtime_disable_action(void *data)
> > > +{
> > > + pm_runtime_disable(data);
> > > +}
> > > +
> > > +/**
> > > + * devm_pm_runtime_enable - devres-enabled version of pm_runtime_enable.
> > > + * @dev: Device to handle.
> > > + */
> > > +int devm_pm_runtime_enable(struct device *dev)
> > > +{
> > > + pm_runtime_enable(dev);
> > > +
> > > + return devm_add_action_or_reset(dev, pm_runtime_disable_action, dev);
> >
> > When exactly is pm_runtime_disable_action() going to run by this rule?
> > When the device goes away or when the driver is unbound from it?
>
> When the driver is unbound (either because probe() returns an error or
> because __device_release_driver() is being called).
> This corresponds to a typical call to pm_runtime_disable() from the
> probe()'s error path or in the remove() callback.
OK, so
Acked-by: Rafael J. Wysocki <rafael@...nel.org>
for the PM-runtime framework changes in this series (patches [1-2/3])
and please feel free to route them in through whatever tree is most
suitable (or let me know if you want me to pick them up).
Powered by blists - more mailing lists