mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dikshita Agarwal <quic_dikshita@quicinc.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@ucw.cz>, "Len Brown" <len.brown@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Stanimir Varbanov <stanimir.k.varbanov@gmail.com>,
	Vikash Garodia <quic_vgarodia@quicinc.com>,
	Bjorn Andersson <andersson@kernel.org>,
	"Konrad Dybcio" <konrad.dybcio@linaro.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-media@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] PM: domains: add device managed version of dev_pm_domain_attach|detach_list()
Date: Tue, 13 Aug 2024 17:53:50 +0530	[thread overview]
Message-ID: <efb17431-82a6-bcc9-cade-896d0dca958e@quicinc.com> (raw)
In-Reply-To: <CAPDyKFpUMmveKQ2Pi33VwcvG9tsMQHEcAg88icf7v9mzzm+k4Q@mail.gmail.com>



On 8/13/2024 4:22 PM, Ulf Hansson wrote:
> On Wed, 7 Aug 2024 at 09:16, Dikshita Agarwal <quic_dikshita@quicinc.com> wrote:
>>
>> Add the devres-enabled version of dev_pm_domain_attach|detach_list.
>> If client drivers use devm_pm_domain_attach_list() to attach the
>> PM domains, devm_pm_domain_detach_list() will be invoked implicitly
>> during remove phase.
>>
>> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
>> ---
>>  drivers/base/power/common.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>  include/linux/pm_domain.h   | 13 +++++++++++++
>>  2 files changed, 57 insertions(+)
>>
>> diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
>> index 327d168..729d6c2 100644
>> --- a/drivers/base/power/common.c
>> +++ b/drivers/base/power/common.c
>> @@ -277,6 +277,50 @@ int dev_pm_domain_attach_list(struct device *dev,
>>  EXPORT_SYMBOL_GPL(dev_pm_domain_attach_list);
>>
>>  /**
>> + * devm_pm_domain_detach_list - devres-enabled version of dev_pm_domain_detach_list.
>> + * @_list: The list of PM domains to detach.
>> + *
>> + * This function reverse the actions from devm_pm_domain_attach_list().
>> + * it will be invoked during the remove phase from drivers implicitly if driver
>> + * uses devm_pm_domain_attach_list() to attach the PM domains.
>> + */
>> +void devm_pm_domain_detach_list(void *_list)
>> +{
>> +       struct dev_pm_domain_list *list = _list;
>> +
>> +       dev_pm_domain_detach_list(list);
>> +}
>> +EXPORT_SYMBOL_GPL(devm_pm_domain_detach_list);
> 
> I think this function should be internal and hence made static -
> unless there is a good reason to export it?
Yeah, it should be static and no need of exporting it.
Will make the changes.
> 
>> +
>> +/**
>> + * devm_pm_domain_attach_list - devres-enabled version of dev_pm_domain_attach_list
>> + * @dev: The device used to lookup the PM domains for.
>> + * @data: The data used for attaching to the PM domains.
>> + * @list: An out-parameter with an allocated list of attached PM domains.
>> + *
>> + * NOTE: this will also handle calling devm_pm_domain_detach_list() for
>> + * you during remove phase.
>> + *
>> + * Returns the number of attached PM domains or a negative error code in case of
>> + * a failure.
>> + */
>> +int devm_pm_domain_attach_list(struct device *dev,
>> +                              const struct dev_pm_domain_attach_data *data,
>> +                              struct dev_pm_domain_list **list)
>> +{
>> +       int ret, num_pds = 0;
> 
> There is no need to initialize num_pds to 0 here, as the below calls
> take care of it.
> 
Right, will be fixed in next revision.
>> +
>> +       num_pds = dev_pm_domain_attach_list(dev, data, list);
>> +
> 
> We should add a check if num_pds is zero here, as in that case there
> is no reason to add a devres callback for it.
> 
Sure, will add the below check.
if (!num_pds)
    return 0;

Thanks,
Dikshita
>> +       ret = devm_add_action_or_reset(dev, devm_pm_domain_detach_list, *list);
>> +       if (ret)
>> +               return ret;
>> +
>> +       return num_pds;
>> +}
>> +EXPORT_SYMBOL_GPL(devm_pm_domain_attach_list);
> 
> [...]
> 
> Kind regards
> Uffe

  reply	other threads:[~2024-08-13 12:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  7:15 [PATCH v2 0/2] " Dikshita Agarwal
2024-08-07  7:15 ` [PATCH v2 1/2] PM: domains: " Dikshita Agarwal
2024-08-08 10:41   ` Dhruva Gole
2024-08-08 10:55     ` Dikshita Agarwal
2024-08-08 10:59       ` Dikshita Agarwal
2024-08-09  4:19         ` Dhruva Gole
2024-08-09  9:27           ` Dikshita Agarwal
2024-08-09  9:49             ` Dhruva Gole
2024-08-13 10:52   ` Ulf Hansson
2024-08-13 12:23     ` Dikshita Agarwal [this message]
2024-08-07  7:15 ` [PATCH v2 2/2] media: venus: use device managed APIs for power domains Dikshita Agarwal

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=efb17431-82a6-bcc9-cade-896d0dca958e@quicinc.com \
    --to=quic_dikshita@quicinc.com \
    --cc=andersson@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=len.brown@intel.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=quic_vgarodia@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=stanimir.k.varbanov@gmail.com \
    --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

all inboxes | Powered by JetHome®