From patchwork Fri Sep 13 13:02:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20276 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B23A220358 for ; Fri, 13 Sep 2013 13:29:28 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf1210653vbg.11 for ; Fri, 13 Sep 2013 06:29:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=/PS+94Uvv0oA7oYXKeWxcDD1Ro2+9kRKXa4/FJCLZNA=; b=ZvB+GJoYo/ALNJMN/Q0p82V92zk7ScwaSFvAuzgxb5GFTAKDgrZwwlU2bSqDX+k+h9 pMyYWFrwQI09pCAeRNCMvVnK73jlkIdFI3MdKQ7So90mILXnRp7n+GcVqYyQlVHVeS8Z LwLu4wJxoM7UlkqSPLIa8uUBuqA7+Hcmf6aCiHhw5IUHjQgy2IK5ooidY351YHhj5i9E oNKLKkvHD90GKElk72LCzk3MNJhzDmfAOoJSkEXN4R7q5Z2hHhOc5dOH4J74Vz/rlHMt lGcPyQ31ZwCWDshBJE8A63hAwgBqa+ErxAzDsG7Q+vNm4Hfne0cH+EAbsRpv0ZT02jax RiAA== X-Gm-Message-State: ALoCoQnTL0KEMWUASZ9b8cLUY8fNFQpqpLN752N8Ti6dKcGwKNTMpZ1lPN9vPmJIdIGUHPPVdPq7 X-Received: by 10.236.7.130 with SMTP id 2mr5136636yhp.4.1379078968317; Fri, 13 Sep 2013 06:29:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.236 with SMTP id 12ls1194482qeh.67.gmail; Fri, 13 Sep 2013 06:29:28 -0700 (PDT) X-Received: by 10.220.105.199 with SMTP id u7mr11760391vco.1.1379078968103; Fri, 13 Sep 2013 06:29:28 -0700 (PDT) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id gq10si3132668vdc.30.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:29:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id g17so940247vbg.28 for ; Fri, 13 Sep 2013 06:29:28 -0700 (PDT) X-Received: by 10.52.103.101 with SMTP id fv5mr1415858vdb.31.1379078968009; Fri, 13 Sep 2013 06:29:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp80809vcz; Fri, 13 Sep 2013 06:29:27 -0700 (PDT) X-Received: by 10.67.1.203 with SMTP id bi11mr15515239pad.137.1379078966825; Fri, 13 Sep 2013 06:29:26 -0700 (PDT) Received: from mail-pb0-f52.google.com (mail-pb0-f52.google.com [209.85.160.52]) by mx.google.com with ESMTPS id z4si687744paz.147.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:29:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.52 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.52; Received: by mail-pb0-f52.google.com with SMTP id wz12so1223836pbc.39 for ; Fri, 13 Sep 2013 06:29:26 -0700 (PDT) X-Received: by 10.66.230.233 with SMTP id tb9mr15607118pac.38.1379078966343; Fri, 13 Sep 2013 06:29:26 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id wp8sm11777200pbc.26.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:29:25 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Viresh Kumar , Santosh Shilimkar Subject: [PATCH 222/228] cpufreq: omap: use cpufreq_generic_get() routine Date: Fri, 13 Sep 2013 18:32:48 +0530 Message-Id: <60f6566be07a8b7c45fdce1757cca35499a95685.1379063063.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver. We don't need a global variable to hold clock anymore. Cc: Santosh Shilimkar Signed-off-by: Viresh Kumar --- drivers/cpufreq/omap-cpufreq.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index e92d72e..a94c4ef 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c @@ -36,21 +36,9 @@ static struct cpufreq_frequency_table *freq_table; static atomic_t freq_table_users = ATOMIC_INIT(0); -static struct clk *mpu_clk; static struct device *mpu_dev; static struct regulator *mpu_reg; -static unsigned int omap_getspeed(unsigned int cpu) -{ - unsigned long rate; - - if (cpu >= NR_CPUS) - return 0; - - rate = clk_get_rate(mpu_clk) / 1000; - return rate; -} - static int omap_target(struct cpufreq_policy *policy, unsigned int index) { int r, ret; @@ -58,11 +46,11 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index) unsigned long freq, volt = 0, volt_old = 0, tol = 0; unsigned int old_freq, new_freq; - old_freq = omap_getspeed(policy->cpu); + old_freq = policy->cur; new_freq = freq_table[index].frequency; freq = new_freq * 1000; - ret = clk_round_rate(mpu_clk, freq); + ret = clk_round_rate(policy->clk, freq); if (IS_ERR_VALUE(ret)) { dev_warn(mpu_dev, "CPUfreq: Cannot find matching frequency for %lu\n", @@ -100,7 +88,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index) } } - ret = clk_set_rate(mpu_clk, new_freq * 1000); + ret = clk_set_rate(policy->clk, new_freq * 1000); /* scaling down? scale voltage after frequency */ if (mpu_reg && (new_freq < old_freq)) { @@ -108,7 +96,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index) if (r < 0) { dev_warn(mpu_dev, "%s: unable to scale voltage down.\n", __func__); - clk_set_rate(mpu_clk, old_freq * 1000); + clk_set_rate(policy->clk, old_freq * 1000); return r; } } @@ -126,9 +114,9 @@ static int omap_cpu_init(struct cpufreq_policy *policy) { int result; - mpu_clk = clk_get(NULL, "cpufreq_ck"); - if (IS_ERR(mpu_clk)) - return PTR_ERR(mpu_clk); + policy->clk = clk_get(NULL, "cpufreq_ck"); + if (IS_ERR(policy->clk)) + return PTR_ERR(policy->clk); if (!freq_table) { result = opp_init_cpufreq_table(mpu_dev, &freq_table); @@ -149,7 +137,7 @@ static int omap_cpu_init(struct cpufreq_policy *policy) freq_table_free(); fail: - clk_put(mpu_clk); + clk_put(policy->clk); return result; } @@ -157,7 +145,7 @@ static int omap_cpu_exit(struct cpufreq_policy *policy) { cpufreq_frequency_table_put_attr(policy->cpu); freq_table_free(); - clk_put(mpu_clk); + clk_put(policy->clk); return 0; } @@ -165,7 +153,7 @@ static struct cpufreq_driver omap_driver = { .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, .target_index = omap_target, - .get = omap_getspeed, + .get = cpufreq_generic_get, .init = omap_cpu_init, .exit = omap_cpu_exit, .name = "omap",