lkml.org 
[lkml]   [2017]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] PM / OPP: Add dev_pm_opp_{set|put}_clkname()
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

\
 
 \ /
  Last update: 2017-06-20 23:09    [W:0.048 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site