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: 2843654 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 92873BF546 for ; Tue, 13 Aug 2013 13:35:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E4AE320200 for ; Tue, 13 Aug 2013 13:35:34 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9412B2015B for ; Tue, 13 Aug 2013 13:35:33 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9EkS-0006VZ-V3; Tue, 13 Aug 2013 13:34:57 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9EkC-0007ms-M8; Tue, 13 Aug 2013 13:34:40 +0000 Received: from mail-pd0-f175.google.com ([209.85.192.175]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9Ejf-0007dl-0f for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2013 13:34:09 +0000 Received: by mail-pd0-f175.google.com with SMTP id q10so931688pdj.34 for ; Tue, 13 Aug 2013 06:33:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=IbAPfq3HgrCZ8CjWDHmf19uod1ZH1vKgBB+nGhJuOX4=; b=Zcq992/ORep11dcVJtK4RU18KaqB4nJDFEbHzBEDTdqOl/nR9fEI8DBHa3yUeeBykC bfdzBfZ4u+Skg+xK7Sp1aZLhElPDRwWJOPVqOqi1BChicBfzeFakz/qBYz2QiaSXaZ7Z +bFEfC+ktnHktUZYdPdgSPhk3YfAnfs6nwGbruZPZnXoiOqH6aQg9NSPXmf1W2Ky4NPx nuwAl9sM7fXO6aT8QG5XsqyL3RkkKD6quxIRPBSDoMMRjRi0OBFkz0neP0PTwni7/k9b MHugJAg99wBWlx4sfWQ+W1OdH44yHAgO2gRwB+l+YvxjW5UhGdy3s26uY+uQjbEQFTcj 0rkQ== X-Gm-Message-State: ALoCoQmy1Sc3T4qYauUSgQ2EyCrLHow2qqYdPZ88xQi8o+RAIEI+QmOtmDSJymyUvvAvK48ylL6J 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130813_093407_265973_B0B7DF33 X-CRM114-Status: GOOD ( 11.68 ) X-Spam-Score: -1.9 (-) Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar , patches@linaro.org, linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Hans-Christian Egtvedt X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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, };