From patchwork Fri Oct 18 13:59:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21135 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 503AA202FF for ; Fri, 18 Oct 2013 14:00:40 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id x16sf5002737vbf.2 for ; Fri, 18 Oct 2013 07:00:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; 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=wXW3BY3M8GVKnL4W0J4nWeS1pmV0thXyp65HFLjRt1E=; b=RNom70i4lOKLVhQfH/mWzuF7tLx0Ae35GiUxPdTeoQ2QsFIlphnZnqhiXwXKYtzEy5 //Jgx32HahVsZkYhWQzasXPu6fLQudRL9zqSlaTb4YncvI74K8pjWkJeQ9taucCXCKRU r0EzMr0eOLPBK+8y2Xpen2gfZoo3k3S1Lnf+gmjdaiZkw+Epfxxt/YDG4YjoWJDbpSVX ARxkIS6/FIUXC0u4NbJ9A+kEtLWhewBeFjbCa/adcFFDOAQJ3zKAj4PBdBTUw1cv33Vn o+kBA/HUdL3026OlKus8YiYwJyeIWfOMygleiUHlX28nw1OlJIOwdKdfbWS4WsQvCsXx iesA== X-Received: by 10.236.142.38 with SMTP id h26mr1493281yhj.57.1382104840132; Fri, 18 Oct 2013 07:00:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.30.37 with SMTP id p5ls1269033qeh.51.gmail; Fri, 18 Oct 2013 07:00:40 -0700 (PDT) X-Received: by 10.220.1.203 with SMTP id 11mr2184793vcg.15.1382104840009; Fri, 18 Oct 2013 07:00:40 -0700 (PDT) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id gu4si327982vdc.98.2013.10.18.07.00.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 07:00:40 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.47 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.47; Received: by mail-vb0-f47.google.com with SMTP id h10so1829564vbh.20 for ; Fri, 18 Oct 2013 07:00:39 -0700 (PDT) X-Gm-Message-State: ALoCoQl+jDQ5ndUgKD+TmCFabNj8mX4hYAL+TBfO4wHuDe3OhfAyP0qm9JPGvgXPTqAUbue2O4ko X-Received: by 10.58.64.202 with SMTP id q10mr633869ves.22.1382104839920; Fri, 18 Oct 2013 07:00: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 u4csp37893vcz; Fri, 18 Oct 2013 07:00:39 -0700 (PDT) X-Received: by 10.67.11.103 with SMTP id eh7mr3630919pad.153.1382104838634; Fri, 18 Oct 2013 07:00:38 -0700 (PDT) Received: from mail-pb0-f51.google.com (mail-pb0-f51.google.com [209.85.160.51]) by mx.google.com with ESMTPS id z1si963435pbw.309.2013.10.18.07.00.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 07:00:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.51 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.51; Received: by mail-pb0-f51.google.com with SMTP id jt11so3852009pbb.38 for ; Fri, 18 Oct 2013 07:00:38 -0700 (PDT) X-Received: by 10.66.161.138 with SMTP id xs10mr3800122pab.56.1382104838220; Fri, 18 Oct 2013 07:00:38 -0700 (PDT) Received: from localhost ([120.56.197.189]) by mx.google.com with ESMTPSA id yh1sm2612898pbc.21.2013.10.18.07.00.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 18 Oct 2013 07:00: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 V2 Resend 04/34] cpufreq: at32ap: Convert to light weight ->target_index() routine Date: Fri, 18 Oct 2013 19:29:27 +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.212.47 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: , This patch converts existing .target() to newly defined light weight .target_index() routine for this driver. CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it. Acked-by: Hans-Christian Egtvedt Signed-off-by: Viresh Kumar --- drivers/cpufreq/at32ap-cpufreq.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c index 7439ded..81d0752 100644 --- a/drivers/cpufreq/at32ap-cpufreq.c +++ b/drivers/cpufreq/at32ap-cpufreq.c @@ -35,25 +35,12 @@ static unsigned int at32_get_speed(unsigned int cpu) static unsigned int ref_freq; static unsigned long loops_per_jiffy_ref; -static int at32_set_target(struct cpufreq_policy *policy, - unsigned int target_freq, - unsigned int relation) +static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) { struct cpufreq_freqs freqs; - long freq; - - /* Convert target_freq from kHz to Hz */ - freq = clk_round_rate(cpuclk, target_freq * 1000); - - /* Check if policy->min <= new_freq <= policy->max */ - if(freq < (policy->min * 1000) || freq > (policy->max * 1000)) - return -EINVAL; - - pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000); freqs.old = at32_get_speed(0); - freqs.new = (freq + 500) / 1000; - freqs.flags = 0; + freqs.new = freq_table[index].frequency; if (!ref_freq) { ref_freq = freqs.old; @@ -64,13 +51,13 @@ static int at32_set_target(struct cpufreq_policy *policy, if (freqs.old < freqs.new) boot_cpu_data.loops_per_jiffy = cpufreq_scale( loops_per_jiffy_ref, ref_freq, freqs.new); - clk_set_rate(cpuclk, freq); + clk_set_rate(cpuclk, freqs.new * 1000); if (freqs.new < freqs.old) boot_cpu_data.loops_per_jiffy = cpufreq_scale( loops_per_jiffy_ref, ref_freq, freqs.new); cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); - pr_debug("cpufreq: set frequency %lu Hz\n", freq); + pr_debug("cpufreq: set frequency %u Hz\n", freqs.new * 1000); return 0; } @@ -139,7 +126,7 @@ static struct cpufreq_driver at32_driver = { .name = "at32ap", .init = at32_cpufreq_driver_init, .verify = cpufreq_generic_frequency_table_verify, - .target = at32_set_target, + .target_index = at32_set_target, .get = at32_get_speed, .flags = CPUFREQ_STICKY, };