From: Stephen Boyd <sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Rafael Wysocki <rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org>,
Viresh Kumar <vireshk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Nishanth Menon <nm-l0cyMroinI0@public.gmane.org>,
linaro-kernel-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Vincent Guittot
<vincent.guittot-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
d-gerlach-l0cyMroinI0@public.gmane.org,
broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH V6 06/10] PM / OPP: Add infrastructure to manage multiple regulators
Date: Wed, 30 Nov 2016 14:37:12 -0800 [thread overview]
Message-ID: <20161130223712.GM6095@codeaurora.org> (raw)
In-Reply-To: <3b3ce1dac198fb668b97e81490bcbcf03d31e40d.1480481312.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
On 11/30, Viresh Kumar wrote:
> @@ -1337,26 +1408,44 @@ struct opp_table *dev_pm_opp_set_regulator(struct device *dev, const char *name)
> goto err;
> }
>
> - /* Already have a regulator set */
> - if (WARN_ON(!IS_ERR(opp_table->regulator))) {
> + /* Already have regulators set */
> + if (WARN_ON(opp_table->regulators)) {
> opp_table = ERR_PTR(-EBUSY);
> goto err;
> }
> - /* Allocate the regulator */
> - reg = regulator_get_optional(dev, name);
> - if (IS_ERR(reg)) {
> - opp_table = (struct opp_table *)reg;
> - if (PTR_ERR(reg) != -EPROBE_DEFER)
> - dev_err(dev, "%s: no regulator (%s) found: %ld\n",
> - __func__, name, PTR_ERR(reg));
> +
> + opp_table->regulators = kmalloc_array(count,
> + sizeof(*opp_table->regulators),
> + GFP_KERNEL);
> + if (!opp_table->regulators) {
> + opp_table = ERR_PTR(-ENOMEM);
> goto err;
> }
>
> - opp_table->regulator = reg;
> + for (i = 0; i < count; i++) {
> + reg = regulator_get_optional(dev, names[i]);
> + if (IS_ERR(reg)) {
> + opp_table = (struct opp_table *)reg;
This should be an ERR_CAST() instead. But this is not based on
the correct patch anyway so this should be rebased.
> + if (PTR_ERR(reg) != -EPROBE_DEFER)
> + dev_err(dev, "%s: no regulator (%s) found: %ld\n",
> + __func__, names[i], PTR_ERR(reg));
> + goto free_regulators;
> + }
> +
> + opp_table->regulators[i] = reg;
> + }
> +
> + opp_table->regulator_count = count;
>
> mutex_unlock(&opp_table_lock);
> return opp_table;
>
> +free_regulators:
> + while (i != 0)
> + regulator_put(opp_table->regulators[--i]);
> +
> + kfree(opp_table->regulators);
> + opp_table->regulators = NULL;
> err:
> _remove_opp_table(opp_table);
> unlock:
> @@ -1364,10 +1453,10 @@ struct opp_table *dev_pm_opp_set_regulator(struct device *dev, const char *name)
>
> return opp_table;
> }
> -EXPORT_SYMBOL_GPL(dev_pm_opp_set_regulator);
> +EXPORT_SYMBOL_GPL(dev_pm_opp_set_regulators);
>
> /**
> - * dev_pm_opp_put_regulator() - Releases resources blocked for regulator
> + * dev_pm_opp_put_regulators() - Releases resources blocked for regulators
> * @opp_table: opp_table returned from dev_pm_opp_set_regulator
This needs an update too ^
> *
> * Locking: The internal opp_table and opp structures are RCU protected.
> diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c
> index c897676ca35f..95f433db4ac7 100644
> --- a/drivers/base/power/opp/debugfs.c
> +++ b/drivers/base/power/opp/debugfs.c
> @@ -34,6 +35,46 @@ void opp_debug_remove_one(struct dev_pm_opp *opp)
> debugfs_remove_recursive(opp->dentry);
> }
>
> +static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
> + struct opp_table *opp_table,
> + struct dentry *pdentry)
> +{
> + struct dentry *d;
> + int i = 0;
> + char *name;
> +
> + /* Always create at least supply-0 directory */
> + do {
> + name = kasprintf(GFP_KERNEL, "supply-%d", i);
Sorry I haven't noticed this before. Wouldn't we want to put the
supply name here instead of a number?
> +
> + /* Create per-opp directory */
> + d = debugfs_create_dir(name, pdentry);
> +
> + kfree(name);
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index 4d3ec92cbabf..1cd1fcfe835a 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -188,7 +188,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)
> */
> name = find_supply_name(cpu_dev);
> if (name) {
> - opp_table = dev_pm_opp_set_regulator(cpu_dev, name);
> + const char *names[] = {name};
> +
> + opp_table = dev_pm_opp_set_regulators(cpu_dev, names,
> + ARRAY_SIZE(names));
This can be simplified to:
opp_table = dev_pm_opp_set_regulators(cpu_dev, &name, 1);
> if (IS_ERR(opp_table)) {
> ret = PTR_ERR(opp_table);
> dev_err(cpu_dev, "Failed to set regulator for cpu%d: %d\n",
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-11-30 22:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-30 5:14 [PATCH V6 00/10] PM / OPP: Multiple regulator support Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 02/10] PM / OPP: Reword binding supporting multiple regulators per device Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 04/10] PM / OPP: Manage supply's voltage/current in a separate structure Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 05/10] PM / OPP: Pass struct dev_pm_opp_supply to _set_opp_voltage() Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 07/10] PM / OPP: Separate out _generic_set_opp() Viresh Kumar
[not found] ` <cover.1480481312.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-11-30 5:14 ` [PATCH V6 01/10] PM / OPP: Fix incorrect cpu-supply property in binding Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 03/10] PM / OPP: Don't use OPP structure outside of rcu protected section Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 06/10] PM / OPP: Add infrastructure to manage multiple regulators Viresh Kumar
[not found] ` <3b3ce1dac198fb668b97e81490bcbcf03d31e40d.1480481312.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-11-30 22:37 ` Stephen Boyd [this message]
2016-12-01 0:51 ` Viresh Kumar
2016-12-01 10:59 ` Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 08/10] PM / OPP: Allow platform specific custom set_opp() callbacks Viresh Kumar
2016-11-30 22:04 ` Stephen Boyd
[not found] ` <20161130220419.GL6095-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-12-01 0:27 ` Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 09/10] PM / OPP: Don't WARN on multiple calls to dev_pm_opp_set_regulators() Viresh Kumar
2016-11-30 5:14 ` [PATCH V6 10/10] PM / OPP: Don't assume platform doesn't have regulators Viresh Kumar
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=20161130223712.GM6095@codeaurora.org \
--to=sboyd-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=d-gerlach-l0cyMroinI0@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linaro-kernel-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
--cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nm-l0cyMroinI0@public.gmane.org \
--cc=rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org \
--cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=vincent.guittot-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=vireshk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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).