From patchwork Wed Oct 30 22:52:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 3117781 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CFC05BF924 for ; Wed, 30 Oct 2013 22:54:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4845A20336 for ; Wed, 30 Oct 2013 22:54:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C90820415 for ; Wed, 30 Oct 2013 22:54:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754766Ab3J3Wwh (ORCPT ); Wed, 30 Oct 2013 18:52:37 -0400 Received: from mail-oa0-f47.google.com ([209.85.219.47]:35115 "EHLO mail-oa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753351Ab3J3Wwe (ORCPT ); Wed, 30 Oct 2013 18:52:34 -0400 Received: by mail-oa0-f47.google.com with SMTP id i1so2222965oag.6 for ; Wed, 30 Oct 2013 15:52:33 -0700 (PDT) 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=KTuI7UsnOJ+2BWJtvzflMMLCs1fSSDdjzUO+uSQAhsM=; b=c14SX6VmbmSepq4RNGddFPFAtOwbILzYtyP4zS9b7hjnr4TPXWSKzi8YtuZXYsbn3Q MqiP/X2IvbO7kW2rjmq2o6fVNJI5ptgcMbG/hQI/1pnT1P0w0CfLmFrWB/haKQZd3ZXa dLWDyN6cwcMbR6N2ijXYzH66keCXiIo03YArFm/UtnvxizE+OY+0yKedlPJ+hVI3WoIV ZSmsAZfAB2HMaPIAEDSgkws1gvZGb0M7GKAiwEd0uTBQNBJofXtQJbUM0GQgip7ls+Oc UpLjO8SI+8HOIaSrzGBD3mzRryMKmZw24IyIXW0JDXQUTMWUJS6GhBo3+QgtfyDZLPEX opIA== X-Gm-Message-State: ALoCoQlPj/WA2QKTJ+FUS6CRxuryzNIVmMZOvn1t9cQQTv47NH5+IUTSRySi/ZQJH6qObu3R2Ix0 X-Received: by 10.60.155.166 with SMTP id vx6mr124802oeb.28.1383173553792; Wed, 30 Oct 2013 15:52:33 -0700 (PDT) Received: from localhost (sccc-66-78-236-243.smartcity.com. [66.78.236.243]) by mx.google.com with ESMTPSA id z5sm577346obg.13.2013.10.30.15.52.30 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 30 Oct 2013 15:52:30 -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, viresh.kumar@linaro.org Subject: [PATCH V2 Resend 09/16] cpufreq: omap: use cpufreq_generic_get() routine Date: Thu, 31 Oct 2013 04:22:07 +0530 Message-Id: <9f47e7f84d81272583215e6009ddf936bd8a669a.1383173230.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 be6d143..0c018dc 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c @@ -36,32 +36,20 @@ 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) { struct dev_pm_opp *opp; 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", @@ -99,7 +87,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)) { @@ -107,7 +95,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; } } @@ -125,9 +113,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 = dev_pm_opp_init_cpufreq_table(mpu_dev, &freq_table); @@ -148,7 +136,7 @@ static int omap_cpu_init(struct cpufreq_policy *policy) freq_table_free(); fail: - clk_put(mpu_clk); + clk_put(policy->clk); return result; } @@ -156,7 +144,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; } @@ -164,7 +152,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",