From patchwork Wed Oct 30 22:52:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21292 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3E3A4244A4 for ; Wed, 30 Oct 2013 22:52:46 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id m4sf4111199qcy.11 for ; Wed, 30 Oct 2013 15:52:46 -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=TCKcjcdKsCPfyhQ9ubAZoXzc8r3S6e2+dARmJCx+kaE=; b=ie6Eef9QwDQxht54xD5Akh99Ib6l3McLoFFhqXG58/WyaOnfYufw8AiNvSizhU7muC 6x+xbU8YKBo7XHz6VNXFEEzKFupGEoz4g8eVAUDqBCX7Rozyt/jWuGjcV52Xz6xvM8o8 pGn+0IRkYEuAv7rqOTk16QsK0goKu7xwPRbs4G5+GchS8r+5UNk5PAORLhMlk7dKaROS 2SBVYcltxOI0Ou9YU/auWdZWlYOSuwFkrkEYWq9XfOBgruUfBh1MVBVTf2W1ayuhWL7y IpDWJMLBIzxJOokrBuKQa879uKzaFXXrBhb9GGj3YhcngNfJrA62ZtnFfJM4qaiw4Egz oRbg== X-Gm-Message-State: ALoCoQm+ZauTY7o+nsGBqyQnVzvOYLx6Xf4xGcJW6H4M/s1EgB0hHkl+yV9XnaLlQCFzYd6ZBtqa X-Received: by 10.236.13.36 with SMTP id a24mr113977yha.50.1383173566120; Wed, 30 Oct 2013 15:52:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.133.73 with SMTP id pa9ls724254qeb.70.gmail; Wed, 30 Oct 2013 15:52:46 -0700 (PDT) X-Received: by 10.52.34.109 with SMTP id y13mr55574vdi.8.1383173566007; Wed, 30 Oct 2013 15:52:46 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id j3si84357vcf.39.2013.10.30.15.52.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Oct 2013 15:52:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id if17so1434719vcb.27 for ; Wed, 30 Oct 2013 15:52:45 -0700 (PDT) X-Received: by 10.52.231.39 with SMTP id td7mr28912vdc.106.1383173565904; Wed, 30 Oct 2013 15:52:45 -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 u4csp316066vcz; Wed, 30 Oct 2013 15:52:45 -0700 (PDT) X-Received: by 10.182.233.228 with SMTP id tz4mr104664obc.56.1383173565326; Wed, 30 Oct 2013 15:52:45 -0700 (PDT) Received: from mail-oa0-f52.google.com (mail-oa0-f52.google.com [209.85.219.52]) by mx.google.com with ESMTPS id f9si114844obe.110.2013.10.30.15.52.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Oct 2013 15:52:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.219.52 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.219.52; Received: by mail-oa0-f52.google.com with SMTP id j1so2210415oag.39 for ; Wed, 30 Oct 2013 15:52:45 -0700 (PDT) X-Received: by 10.60.58.71 with SMTP id o7mr36515oeq.51.1383173565063; Wed, 30 Oct 2013 15:52:45 -0700 (PDT) Received: from localhost (sccc-66-78-236-243.smartcity.com. [66.78.236.243]) by mx.google.com with ESMTPSA id xq4sm759094oeb.3.2013.10.30.15.52.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 30 Oct 2013 15:52:44 -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 16/16] cpufreq: unicore2: use cpufreq_generic_get() routine Date: Thu, 31 Oct 2013 04:22:14 +0530 Message-Id: <6878a643df82272c18233c5e0328007f88cec024.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: 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.220.182 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 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", };