From patchwork Tue Feb 9 05:00:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61496 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1831300lbl; Mon, 8 Feb 2016 21:02:40 -0800 (PST) X-Received: by 10.66.255.70 with SMTP id ao6mr47549499pad.64.1454994160370; Mon, 08 Feb 2016 21:02:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fg8si51355154pad.227.2016.02.08.21.02.40; Mon, 08 Feb 2016 21:02: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 S1756533AbcBIFCg (ORCPT + 30 others); Tue, 9 Feb 2016 00:02:36 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:36116 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756327AbcBIFCb (ORCPT ); Tue, 9 Feb 2016 00:02:31 -0500 Received: by mail-pf0-f178.google.com with SMTP id e127so25980969pfe.3 for ; Mon, 08 Feb 2016 21:02:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=dn3wMi6ms9+ha5ckfXCM5iothkr60jqvG8FLJvLeXiY=; b=OlVmMWRnFF46k2WOlZudQ2SJExj0p9/4KPbYiRZC4h6B0Zf7nl7cJqXASAuYhewIKj vspKfwMNB337LnnNcuK1qmwc5Nw4056mC0CYuusYJhQpVvhZG1LS8owVPD5xzZu46ZFj 8gkamwZZd9tQRBYbcVkyQeW1i54njX9QJXs/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=dn3wMi6ms9+ha5ckfXCM5iothkr60jqvG8FLJvLeXiY=; b=QeIx0ikbH34j0KJD/JTVvqudjQkhMXBily+6nHG8xJsrQoZZGsvCVQJ64IOVf880e6 6+Bde3fIQcVPr2k+6kb/6bWpgc+qRaO4ln/T4qpTAC7dKWKGYf34WHhqZmb/lZHKk99q 6/hBItb3AKhsUvBjOTgfC8Bevo/SW8x0Lu4VdWnhZLFHvOsxa3q7a0XCtbauiTpFGWB1 5lk/21XfsugU7IqOfDc3MtNNEZ2jj9nJQZqH52R2Tuukia/Q+XWM0LH+wWNk1ENfe7VF jxSStb0w+tPMDbjUf+M5I3Sp1qCm4WNXoPiHWBMk+kCYyVvwJxcoBvWEpMHzl8rca8gh Z7+A== X-Gm-Message-State: AG10YOQI+EFGu04kk/AmTM5tBqrFjhnsmTvoKYWZxtzOclwxq9w9a30j/Y62qzPWAgZzzmow X-Received: by 10.98.15.19 with SMTP id x19mr48118426pfi.60.1454994150744; Mon, 08 Feb 2016 21:02:30 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id q16sm46810272pfi.80.2016.02.08.21.02.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 21:02:30 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Stephen Boyd , nm@ti.com, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V3 15/16] cpufreq: dt: No need to fetch voltage-tolerance Date: Tue, 9 Feb 2016 10:30:47 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Stephen Boyd --- drivers/cpufreq/cpufreq-dt.c | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) -- 2.7.1.370.gb2aa7f8 diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 150a172c7d0a..bbafd7b63d1a 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); + + /* This must be valid for sure */ + if (WARN_ON(!np)) + return NULL; /* 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,20 +186,20 @@ 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 (name) { ret = dev_pm_opp_set_regulator(cpu_dev, name); 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; } } @@ -244,7 +249,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) { @@ -286,8 +290,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: @@ -298,8 +300,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))