From patchwork Fri Aug 23 15:50:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19486 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 639E6248E6 for ; Fri, 23 Aug 2013 15:53:57 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id l13sf558235qcy.4 for ; Fri, 23 Aug 2013 08:53:57 -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=nLxvu9Nsuhtlcy+9JUUGvoaf9qQS8gUIKqTigItYFmc=; b=hemHFOGP7SYYe3XBEypFpRz133VhiU/x/MgtoEwdEEg2OUL5NM5JIAULD7X5wQYoBi Q0/e8yWSaBReF1VzDr5XQGOYEKMhU8AhXD3fG1aVnkxmsgDa4RTGal+YvTx9RXtF+XOb Y2bPF2VFDKXGBvbSZJPQGe+vuAZl9Gd8pE5jkdKCIo2gD4HO2+J/MohRPKCLcmVp/DyQ wrTJVizZkgOsWGWDhv9FjNhfTdjQvVQzEycImqH5znqq4Yahk5uXYRaG7yPBYdy1jmx0 XKtiajkLkXSLzOueblpVp1eYev0tTFPXDTDAIWeqNr/VA1GhpMhD683lsLdqjnrbghyw RMdw== X-Received: by 10.236.191.233 with SMTP id g69mr89471yhn.54.1377273237220; Fri, 23 Aug 2013 08:53:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.76.33 with SMTP id h1ls1699732qew.29.gmail; Fri, 23 Aug 2013 08:53:57 -0700 (PDT) X-Received: by 10.58.200.73 with SMTP id jq9mr129830vec.53.1377273237063; Fri, 23 Aug 2013 08:53:57 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id bk8si140760vec.18.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:53:57 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so559661veb.16 for ; Fri, 23 Aug 2013 08:53:57 -0700 (PDT) X-Gm-Message-State: ALoCoQkZi/r20JgK0uyYYyDgGajjE+C64b7axpZUT6JoySAKSakE6yOnf6Ddt7kqBpd5uUhRwJO9 X-Received: by 10.52.165.239 with SMTP id zb15mr117787vdb.44.1377273236981; Fri, 23 Aug 2013 08:53:56 -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 u4csp100726vcz; Fri, 23 Aug 2013 08:53:56 -0700 (PDT) X-Received: by 10.68.110.98 with SMTP id hz2mr412257pbb.94.1377273235694; Fri, 23 Aug 2013 08:53:55 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id c10si795110pav.200.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:53:55 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.50; Received: by mail-pb0-f50.google.com with SMTP id uo5so837986pbc.9 for ; Fri, 23 Aug 2013 08:53:55 -0700 (PDT) X-Received: by 10.66.253.40 with SMTP id zx8mr21803775pac.71.1377273234997; Fri, 23 Aug 2013 08:53:54 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id br3sm524277pbd.31.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:53:54 -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 , Santosh Shilimkar Subject: [PATCH 10/16] cpufreq: omap: use cpufreq_generic_get() routine Date: Fri, 23 Aug 2013 21:20:45 +0530 Message-Id: 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.128.171 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 97610a3..09150fc 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c @@ -36,21 +36,9 @@ 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) { int r, ret; @@ -58,11 +46,11 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index) 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", @@ -100,7 +88,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)) { @@ -108,7 +96,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; } } @@ -126,9 +114,9 @@ static int omap_cpu_init(struct cpufreq_policy *policy) { int result = 0; - 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 (policy->cpu >= NR_CPUS) { result = -EINVAL; @@ -168,7 +156,7 @@ static int omap_cpu_init(struct cpufreq_policy *policy) fail_table: freq_table_free(); fail_ck: - clk_put(mpu_clk); + clk_put(policy->clk); return result; } @@ -176,7 +164,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; } @@ -184,7 +172,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",