From patchwork Fri Sep 13 13:02:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 2890921 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AAEA69F1BF for ; Fri, 13 Sep 2013 16:42:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE35320299 for ; Fri, 13 Sep 2013 16:42:43 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E0E3320295 for ; Fri, 13 Sep 2013 16:42:42 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKTej-00069o-FH; Fri, 13 Sep 2013 13:43:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKTdt-0002JR-IF; Fri, 13 Sep 2013 13:42:37 +0000 Received: from mail-pa0-f54.google.com ([209.85.220.54]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKTS8-0000os-Si for linux-arm-kernel@lists.infradead.org; Fri, 13 Sep 2013 13:30:30 +0000 Received: by mail-pa0-f54.google.com with SMTP id kx10so2549603pab.27 for ; Fri, 13 Sep 2013 06:30:07 -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=TCKcjcdKsCPfyhQ9ubAZoXzc8r3S6e2+dARmJCx+kaE=; b=ZK3b5tAga0/Utp4bCzByJX8aMejU8cUDRlKHI6tSkq/on3B73GcEc9GxGMSN+XRJpu CKV/jWn6PMwTHntQ6Qbl9VYG2IYzy3XKENYfoLkJJcLMXN7o7Lz+mB6C1hC7iNpHbGmp plvA/PcxD3gUK/lItrfYwQcRMFb3xgw2DrrQqm2bCqEvrzdW+hwS+y68ydvHdhOFF/kl EGHqbckkqtNR9TxM43kPqlgjpLkkYLfwTcI7IE+Abf/pqd6XvVPXzdWlja0MwiwlZgMd dNIn7SQQKuKHQqs3YDK9v+iqInLfmYf7755zlXVMUimMfA8AFN5/ycK2cI651F07mSf7 jIsw== X-Gm-Message-State: ALoCoQkfU4Tx1tBsgmVFAsnvmuM12EGsW4wIvhcEGp6RFl2TuStvQr3nL5VadjxBMxFogXgrl1RX X-Received: by 10.68.211.233 with SMTP id nf9mr13706522pbc.26.1379079007584; Fri, 13 Sep 2013 06:30:07 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id yg3sm18114263pab.16.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:30:07 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Subject: [PATCH 228/228] cpufreq: unicore2: use cpufreq_generic_get() routine Date: Fri, 13 Sep 2013 18:32:54 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130913_093029_088439_D66435F3 X-CRM114-Status: GOOD ( 13.22 ) X-Spam-Score: -2.6 (--) Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar , patches@linaro.org, linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 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 653ae29..951152f 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 @@ -33,26 +34,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; } @@ -66,9 +57,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; } @@ -76,7 +71,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", };