linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rafael Wysocki <rjw@rjwysocki.net>,
	Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
	linux-pm@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Rajendra Nayak <rnayak@codeaurora.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PM / OPP: Add dev_pm_opp_{set|put}_clkname()
Date: Tue, 20 Jun 2017 14:08:20 -0700	[thread overview]
Message-ID: <20170620210820.GU4493@codeaurora.org> (raw)
In-Reply-To: <e1ae46672cc137bf375349a6b9f7a5a3c9823e74.1497953043.git.viresh.kumar@linaro.org>

On 06/20, Viresh Kumar wrote:
> + */
> +struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name)
> +{
> +	struct opp_table *opp_table;
> +	int ret;
> +
> +	opp_table = dev_pm_opp_get_opp_table(dev);
> +	if (!opp_table)
> +		return ERR_PTR(-ENOMEM);
> +
> +	/* This should be called before OPPs are initialized */
> +	if (WARN_ON(!list_empty(&opp_table->opp_list))) {
> +		ret = -EBUSY;
> +		goto err;
> +	}
> +
> +	/* Already have clkname set */
> +	if (opp_table->clk_name) {
> +		ret = -EBUSY;
> +		goto err;
> +	}
> +
> +	opp_table->clk_name = kstrdup(name, GFP_KERNEL);
> +	if (!opp_table->clk_name) {

Is there a reason to duplicate clk_name instead of using the clk
structure returned from clk_get()? Is it because we may already
have opp_table->clk set from default init? Why can't we always
clk_put() the clk structure if it's !IS_ERR() and then allow
dev_pm_opp_set_clkname() to be called many times in succession?
Long story short, I don't see the benefit to allocating the name
again here just to use it as a mechanism to know if the APIs have
been called symmetrically.

> +		ret = -ENOMEM;
> +		goto err;
> +	}
> +
> +	/* Already have default clk set, free it */
> +	if (!IS_ERR(opp_table->clk))
> +		clk_put(opp_table->clk);
> +

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2017-06-20 21:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 10:05 [PATCH] PM / OPP: Add dev_pm_opp_{set|put}_clkname() Viresh Kumar
2017-06-20 21:08 ` Stephen Boyd [this message]
2017-06-21  5:00   ` Viresh Kumar
2017-06-21  4:59 ` [PATCH V2] " Viresh Kumar
2017-06-21 17:38   ` Stephen Boyd

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=20170620210820.GU4493@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rjw@rjwysocki.net \
    --cc=rnayak@codeaurora.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=vireshk@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).