From patchwork Tue Aug 13 13:32:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19060 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f197.google.com (mail-gh0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D671B246B8 for ; Tue, 13 Aug 2013 13:33:46 +0000 (UTC) Received: by mail-gh0-f197.google.com with SMTP id r20sf637721ghr.8 for ; Tue, 13 Aug 2013 06:33:46 -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=IbAPfq3HgrCZ8CjWDHmf19uod1ZH1vKgBB+nGhJuOX4=; b=aUEJxlBJORtLhhoxbLrj2jRHh4nJzDN2ZpGrdU84Ca7I5hO9w9tFseB59LaW+ciQN0 hPnqdfK6ciofPb+ryVKENAOKO9c62yincR1+4iZfsbfMVK/SnUTQlzVTRoty+BF+CpKE LP8+J+q8lfkoc+Tr4UPSOcVnpI6qb1JjarIt2ZX+/+F/INV19C8Ke5IXzESUrqWQpZHH EK4g5Y/ymaw/bCBeFo+/M/7MTtdubvnDKkpZUA0BZKtsvcRoeqSi0c8uT24JmrPup28d VAmZQkxUEa2cHNTQIIYEa2cXkRvghUI6KLMmzweF0CIP/x7mi47Z5R3bT2kubkk1ns9C 5QIw== X-Received: by 10.236.79.67 with SMTP id h43mr1634493yhe.46.1376400826470; Tue, 13 Aug 2013 06:33:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.117.166 with SMTP id kf6ls2670873qeb.30.gmail; Tue, 13 Aug 2013 06:33:46 -0700 (PDT) X-Received: by 10.58.198.13 with SMTP id iy13mr4494037vec.11.1376400826326; Tue, 13 Aug 2013 06:33:46 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id x9si9749452vec.42.2013.08.13.06.33.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Aug 2013 06:33:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 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.178; Received: by mail-ve0-f178.google.com with SMTP id ox1so6659708veb.37 for ; Tue, 13 Aug 2013 06:33:46 -0700 (PDT) X-Gm-Message-State: ALoCoQkeAtdUkljMRwChm/BELUNlVB/7sB7KXkkrTQGznkQkUv7TcazlIv+4QphAYA6hd8XVwRAE X-Received: by 10.220.69.71 with SMTP id y7mr767517vci.40.1376400826247; Tue, 13 Aug 2013 06:33:46 -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 u4csp154134vcz; Tue, 13 Aug 2013 06:33:45 -0700 (PDT) X-Received: by 10.68.111.129 with SMTP id ii1mr4664609pbb.95.1376400825316; Tue, 13 Aug 2013 06:33:45 -0700 (PDT) Received: from mail-pb0-f45.google.com (mail-pb0-f45.google.com [209.85.160.45]) by mx.google.com with ESMTPS id mu18si26254163pab.118.2013.08.13.06.33.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Aug 2013 06:33:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.45 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.45; Received: by mail-pb0-f45.google.com with SMTP id mc17so7966674pbc.18 for ; Tue, 13 Aug 2013 06:33:44 -0700 (PDT) X-Received: by 10.66.159.132 with SMTP id xc4mr4688256pab.27.1376400824727; Tue, 13 Aug 2013 06:33:44 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id in2sm40722503pbc.37.2013.08.13.06.33.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 13 Aug 2013 06:33: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, linux-arm-kernel@lists.infradead.org, Viresh Kumar , Hans-Christian Egtvedt Subject: [PATCH V2 05/35] cpufreq: at32ap: Covert to light weight ->target_index() routine Date: Tue, 13 Aug 2013 19:02:18 +0530 Message-Id: <1e8023313384685c4f5488b5249423b066e8c133.1376392602.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.128.178 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. Cc: Hans-Christian Egtvedt Signed-off-by: Viresh Kumar Acked-by: Hans-Christian Egtvedt --- 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 788f7e7..2e964a7 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 %lu Hz\n", freqs.new * 1000); return 0; } @@ -143,7 +130,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, };