From patchwork Fri Aug 23 15:50:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19492 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 34BA6248E6 for ; Fri, 23 Aug 2013 15:55:40 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id n7sf623942qcx.2 for ; Fri, 23 Aug 2013 08:55:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state: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=hg9/wagmkDGLxKLuDGD1Nh5pYOT8AVfwuGHWb7TMFJI=; b=Cz7ghEZaHLfjmHYQnX9wN0jXfKaZnSVn0XM1NPDGywkX9tElgXQh4dFXnUBS0Kf4mK 99jnU3GiETwMlaAip1osAnpPcACirrjPHaFjItq7g9SjFgN9yJ+4ZWgyjX/931ToT5pS V9AJAEC3wzIEUsk1evo1Z/woQLDVpyYMzVAAznmhRHd6kcE8p5pe7zY8dMMAv3TBWO6w T+U5/KNzyHjVLddl/O8XSBnxrkgHZU2+7oY2M7fqufwSduHupOQHBBv9w72Gcmw38kFo 0r0/nXVw2LT2dlTWLUaPSjeCNsVS20TTUNQPqpHg8q/fKj1drMSs13W5YB9Eh85s5sdP cyPg== X-Received: by 10.236.172.34 with SMTP id s22mr117239yhl.25.1377273339763; Fri, 23 Aug 2013 08:55:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.107.200 with SMTP id he8ls1553916qeb.70.gmail; Fri, 23 Aug 2013 08:55:39 -0700 (PDT) X-Received: by 10.220.184.137 with SMTP id ck9mr128240vcb.56.1377273339668; Fri, 23 Aug 2013 08:55:39 -0700 (PDT) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by mx.google.com with ESMTPS id aa5si142117vdc.26.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:55:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.53 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.53; Received: by mail-vb0-f53.google.com with SMTP id i3so568523vbh.12 for ; Fri, 23 Aug 2013 08:55:39 -0700 (PDT) X-Gm-Message-State: ALoCoQm0L+SIr+M6OIdjIQaqxbbC7XwIKjAPy7+4mv+mOAfOfF0orCWvZl25uIz+NLUe94L9Ybkk X-Received: by 10.58.217.167 with SMTP id oz7mr161701vec.15.1377273339560; Fri, 23 Aug 2013 08:55:39 -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 u4csp100815vcz; Fri, 23 Aug 2013 08:55:39 -0700 (PDT) X-Received: by 10.66.193.98 with SMTP id hn2mr3705407pac.173.1377273338436; Fri, 23 Aug 2013 08:55:38 -0700 (PDT) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by mx.google.com with ESMTPS id bv1si252285pbb.114.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:55:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.42 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.42; Received: by mail-pa0-f42.google.com with SMTP id lj1so841094pab.1 for ; Fri, 23 Aug 2013 08:55:37 -0700 (PDT) X-Received: by 10.66.187.34 with SMTP id fp2mr21429614pac.12.1377273337904; Fri, 23 Aug 2013 08:55:37 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id 7sm1838343paf.22.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:55:37 -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 Subject: [PATCH 16/16] cpufreq: unicore2: use cpufreq_generic_get() routine Date: Fri, 23 Aug 2013 21:20:51 +0530 Message-Id: <15af21fe81a3bb3507f1832d3482c1df5ca0a3f7.1377272740.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.53 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 also do clk_get() once instead of doing it again and again in target & init. Signed-off-by: Viresh Kumar --- drivers/cpufreq/unicore2-cpufreq.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c index 79ca32e..5f7b393 100644 --- a/drivers/cpufreq/unicore2-cpufreq.c +++ b/drivers/cpufreq/unicore2-cpufreq.c @@ -11,6 +11,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -35,26 +36,16 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy) return 0; } -static unsigned int ucv2_getspeed(unsigned int cpu) -{ - struct clk *mclk = clk_get(NULL, "MAIN_CLK"); - - if (cpu) - return 0; - return clk_get_rate(mclk)/1000; -} - static int ucv2_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { - unsigned int cur = ucv2_getspeed(0); + unsigned int cur = policy->cur; struct cpufreq_freqs freqs; - struct clk *mclk = clk_get(NULL, "MAIN_CLK"); cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); - if (!clk_set_rate(mclk, target_freq * 1000)) { + if (!clk_set_rate(policy->clk, target_freq * 1000)) { freqs.old = cur; freqs.new = target_freq; } @@ -68,9 +59,13 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy) { if (policy->cpu != 0) return -EINVAL; + policy->min = policy->cpuinfo.min_freq = 250000; policy->max = policy->cpuinfo.max_freq = 1000000; policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; + policy->clk = clk_get(NULL, "MAIN_CLK"); + if (IS_ERR(policy->clk)) + return PTR_ERR(policy->clk); return 0; } @@ -78,7 +73,7 @@ static struct cpufreq_driver ucv2_driver = { .flags = CPUFREQ_STICKY, .verify = ucv2_verify_speed, .target = ucv2_target, - .get = ucv2_getspeed, + .get = cpufreq_generic_get, .init = ucv2_cpu_init, .name = "UniCore-II", };