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: 21285 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6B158244A4 for ; Wed, 30 Oct 2013 22:52:35 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rp8sf3459062pbb.5 for ; Wed, 30 Oct 2013 15:52:34 -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=KTuI7UsnOJ+2BWJtvzflMMLCs1fSSDdjzUO+uSQAhsM=; b=jN8rNdCc4MPDxIIgpfRfv9BvFAIcmuzGgfSkRKvapPeVWmKo/tp7FZej8mohaa/osH j7/ZOZDf0k1rTHsvG/hUTXnWO8KyslFiKtzNV8Bk6b0jKCMtMQQnG/WANkjC4rBAle/w T9CmpNilmHjqwaVikKwvPEThEdUMuc5pMKOPt8ySrftMTeUJ2fJTGKQkSaiE+10d8obc UchudeB2REENbfTgute1hV1zR3QUUn4t4fbVITbeGwG7xfXIuqBJZdiIhp4oz5Qnqg2c SKwSnwT8WCFWyHn/fPAkmBmriqloBKOmzCJXILyzLegPrftu0EvEcjAu07tdi9qnq0JF MouA== X-Gm-Message-State: ALoCoQleBbYLjpNjPNnv/0GfnOhgtuO/6KYblV/8nV1AMrr0kGMUlIU45GBlDQkQirjPGJ1855PI X-Received: by 10.66.5.226 with SMTP id v2mr367603pav.22.1383173554711; Wed, 30 Oct 2013 15:52:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.49.163 with SMTP id v3ls721845qen.53.gmail; Wed, 30 Oct 2013 15:52:34 -0700 (PDT) X-Received: by 10.52.244.34 with SMTP id xd2mr8104vdc.87.1383173554581; Wed, 30 Oct 2013 15:52:34 -0700 (PDT) Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50]) by mx.google.com with ESMTPS id wp10si72005vdb.123.2013.10.30.15.52.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Oct 2013 15:52:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.50 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.50; Received: by mail-vb0-f50.google.com with SMTP id x16so862846vbf.23 for ; Wed, 30 Oct 2013 15:52:34 -0700 (PDT) X-Received: by 10.58.255.233 with SMTP id at9mr60517ved.20.1383173554489; Wed, 30 Oct 2013 15:52:34 -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 u4csp316057vcz; Wed, 30 Oct 2013 15:52:34 -0700 (PDT) X-Received: by 10.182.165.67 with SMTP id yw3mr87248obb.84.1383173554058; Wed, 30 Oct 2013 15:52:34 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id f9si141552obe.6.2013.10.30.15.52.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Oct 2013 15:52:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.214.178; Received: by mail-ob0-f178.google.com with SMTP id wm4so2188250obc.23 for ; Wed, 30 Oct 2013 15:52:33 -0700 (PDT) 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: 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.50 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 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",