From patchwork Tue Feb 2 06:11:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 60994 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp529792lbb; Mon, 1 Feb 2016 22:11:40 -0800 (PST) X-Received: by 10.98.71.130 with SMTP id p2mr44528270pfi.99.1454393500461; Mon, 01 Feb 2016 22:11:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jj2si29180251pac.179.2016.02.01.22.11.40; Mon, 01 Feb 2016 22:11:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753112AbcBBGLi (ORCPT + 30 others); Tue, 2 Feb 2016 01:11:38 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:36159 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752949AbcBBGLg (ORCPT ); Tue, 2 Feb 2016 01:11:36 -0500 Received: by mail-pa0-f52.google.com with SMTP id yy13so95316100pab.3 for ; Mon, 01 Feb 2016 22:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=Q9TlfbgUCQNhwncqi/UVBotdnDLgUlny72spTVJ5d2I=; b=I+uPxF8PbpXpV05clE4EWJ7uuqaQPMnfhM7DIVORVe7RAcbzocGsOnYkyAalrPpmdF /sY5gdCl8Jpst/hU4/2DI8zdHMwXZri7Hv3xD9eClbD4sqdRXlr+2JCTYxYsxqbyViT4 1C5IE0g5Rv58rEHtQZaPu0WIWwYK31vnq6fVI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=Q9TlfbgUCQNhwncqi/UVBotdnDLgUlny72spTVJ5d2I=; b=lOtIDvMuQw3GTV6EvBImSkFbg3PKIdMfxHSXrN1eaQB/e4WpD7dJa2hZ2bm1ZiOW+p DAsSNW7cYOuYAW768Kh66feL+tpUYv7uV1ybnDfDcvD9JsxOCpXDK0C1CWpnaHCDrxvb 9lXNmZu7If1njdhSMpql93h+/N0LR/nHO9D7XAJaEJVoMqr2L8nKC2FMG6Opx8YGAVNS Koc10UswwQpmvdV0pltCSQoKm2DsOULF9glIc7PkNXgP18ErZXeGjTU0mWUjdBOUQjQ4 i+HzWgUEjrN4q1HTcztUFm2HSlaEVZoPzgxHDRk3W1iz5h4UEOzBoATwBOJUWVVRDT/N pZQQ== X-Gm-Message-State: AG10YORwFrbtw9/8OwGqPj1ohXwjU08dke63OE1ISqCwJuTTbtJrTzCjNm5V8j/I7OoNYjQ4 X-Received: by 10.66.62.195 with SMTP id a3mr45110322pas.8.1454393495412; Mon, 01 Feb 2016 22:11:35 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id o73sm36555419pfa.37.2016.02.01.22.11.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Feb 2016 22:11:34 -0800 (PST) Date: Tue, 2 Feb 2016 11:41:32 +0530 From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Stephen Boyd , nm@ti.com, open list Subject: Re: [PATCH V2 15/16] cpufreq: dt: drop references to DT node Message-ID: <20160202061132.GD31828@vireshk> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28-01-16, 13:50, Viresh Kumar wrote: > We don't need to get reference to DT node now, lets drop it. > > Signed-off-by: Viresh Kumar > Reviewed-by: Stephen Boyd And because of changes in 11/16, this got updated as well: -------------------------8<------------------------- From: Viresh Kumar Date: Tue, 8 Sep 2015 17:34:26 +0530 Subject: [PATCH 08/20] cpufreq: dt: No need to fetch voltage-tolerance Its already done by core and we don't need to get it anymore. And so, we don't need to get of node in cpufreq_init() anymore, move that to find_supply_name() instead. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq-dt.c | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 35c5ec3b333c..3c43fda48bdf 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -33,7 +33,6 @@ struct private_data { struct device *cpu_dev; struct regulator *cpu_reg; struct thermal_cooling_device *cdev; - unsigned int voltage_tolerance; /* in percentage */ const char *reg_name; }; @@ -55,24 +54,38 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index) * An earlier version of opp-v1 bindings used to name the regulator * "cpu0-supply", we still need to handle that for backwards compatibility. */ -static const char *find_supply_name(struct device *dev, struct device_node *np) +static const char *find_supply_name(struct device *dev) { + struct device_node *np; struct property *pp; int cpu = dev->id; + const char *name = NULL; + + np = of_node_get(dev->of_node); + if (!np) { + dev_err(dev, "failed to find cpu%d node\n", cpu); + return ERR_PTR(-ENOENT); + } /* Try "cpu0" for older DTs */ if (!cpu) { pp = of_find_property(np, "cpu0-supply", NULL); - if (pp) - return "cpu0"; + if (pp) { + name = "cpu0"; + goto node_put; + } } pp = of_find_property(np, "cpu-supply", NULL); - if (pp) - return "cpu"; + if (pp) { + name = "cpu"; + goto node_put; + } dev_dbg(dev, "no regulator for cpu%d\n", cpu); - return NULL; +node_put: + of_node_put(np); + return name; } static int allocate_resources(int cpu, struct device **cdev, @@ -147,7 +160,6 @@ static int allocate_resources(int cpu, struct device **cdev, static int cpufreq_init(struct cpufreq_policy *policy) { struct cpufreq_frequency_table *freq_table; - struct device_node *np; struct private_data *priv; struct device *cpu_dev; struct regulator *cpu_reg; @@ -164,13 +176,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) return ret; } - np = of_node_get(cpu_dev->of_node); - if (!np) { - dev_err(cpu_dev, "failed to find cpu%d node\n", policy->cpu); - ret = -ENOENT; - goto out_put_reg_clk; - } - /* Get OPP-sharing information from "operating-points-v2" bindings */ ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus); if (ret) { @@ -181,17 +186,17 @@ static int cpufreq_init(struct cpufreq_policy *policy) if (ret == -ENOENT) opp_v1 = true; else - goto out_node_put; + goto out_put_reg_clk; } /* * OPP layer will be taking care of regulators now, but it needs to know * the name of the regulator first. */ - name = find_supply_name(cpu_dev, np); + name = find_supply_name(cpu_dev); if (IS_ERR(name)) { ret = PTR_ERR(name); - goto out_node_put; + goto out_put_reg_clk; } if (name) { @@ -199,7 +204,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) if (ret) { dev_err(cpu_dev, "Failed to set regulator for cpu%d: %d\n", policy->cpu, ret); - goto out_node_put; + goto out_put_reg_clk; } } @@ -249,7 +254,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) } priv->reg_name = name; - of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance); ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); if (ret) { @@ -291,8 +295,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = transition_latency; - of_node_put(np); - return 0; out_free_cpufreq_table: @@ -303,8 +305,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) dev_pm_opp_of_cpumask_remove_table(policy->cpus); if (name) dev_pm_opp_put_regulator(cpu_dev); -out_node_put: - of_node_put(np); out_put_reg_clk: clk_put(cpu_clk); if (!IS_ERR(cpu_reg))