From patchwork Fri Oct 18 13:59:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21160 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 F4227202FF for ; Fri, 18 Oct 2013 14:03:54 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id x19sf6351915qcw.4 for ; Fri, 18 Oct 2013 07:03:54 -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=7RhUFTjYM8zNJBf+5pU9f1BveBSsO83c0+cWCmE+lhY=; b=c1OjjdZcgft0g6t17ydCRl38Xs37Gp1LNFiORAICnW480b1KGROaU8cgh7qbbgGrJl i+kQE9/JpOE+wVySuX+5zLv70InWU36d3QxqiMPbnaV2p3BtEwZNkPCEwpWZE4I4e0mn Oknvx+cwVC/whxoaOApj+vAaIs/zTJWjk3gJ+mHj5mcJLplUiQv3yK51WxPukPAfS+MB PG+uIuNh57RkFeVulpg+mtCtK6IWjMJT+iDQyctJOX9iPDVcnt1ir88LZUhtvqkCGGHR PjzgnWjsMC0osr/pBwqosgSJFJGhEPRHP+/swQNZ7djs/DvNSw+uzqEPdTKF5+DIEqZ8 4gBA== X-Received: by 10.236.20.114 with SMTP id o78mr2736310yho.8.1382105034789; Fri, 18 Oct 2013 07:03:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.40 with SMTP id h8ls1342620qeo.28.gmail; Fri, 18 Oct 2013 07:03:54 -0700 (PDT) X-Received: by 10.58.54.69 with SMTP id h5mr230266vep.25.1382105034673; Fri, 18 Oct 2013 07:03:54 -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 fx15si338547vec.34.2013.10.18.07.03.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 07:03:54 -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 jy13so1980848veb.23 for ; Fri, 18 Oct 2013 07:03:54 -0700 (PDT) X-Gm-Message-State: ALoCoQkNE0Ubip9uqy4Kw2Rb+UOEnMi6j6Uu5fO1YQz9tW/CiRSRjFkkN4HxS65TtH6LbtOqAWXb X-Received: by 10.52.52.137 with SMTP id t9mr1282081vdo.22.1382105034565; Fri, 18 Oct 2013 07:03:54 -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 u4csp38162vcz; Fri, 18 Oct 2013 07:03:53 -0700 (PDT) X-Received: by 10.66.27.201 with SMTP id v9mr3633054pag.15.1382105033483; Fri, 18 Oct 2013 07:03:53 -0700 (PDT) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id n5si1572544pav.185.2013.10.18.07.03.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 07:03:53 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.46; Received: by mail-pa0-f46.google.com with SMTP id fa1so4614584pad.33 for ; Fri, 18 Oct 2013 07:03:53 -0700 (PDT) X-Received: by 10.68.190.103 with SMTP id gp7mr3308397pbc.74.1382105033039; Fri, 18 Oct 2013 07:03:53 -0700 (PDT) Received: from localhost ([120.56.197.189]) by mx.google.com with ESMTPSA id fb3sm2621928pbc.29.2013.10.18.07.03.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 18 Oct 2013 07:03:52 -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 , Russell King Subject: [PATCH V2 Resend 29/34] cpufreq: sa11x0: Convert to light weight ->target_index() routine Date: Fri, 18 Oct 2013 19:29:52 +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.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. Some existing routines are no more required and so are removed now. Cc: Russell King Signed-off-by: Viresh Kumar --- arch/arm/mach-sa1100/generic.c | 20 -------------------- arch/arm/mach-sa1100/generic.h | 2 -- drivers/cpufreq/sa1100-cpufreq.c | 24 ++++-------------------- drivers/cpufreq/sa1110-cpufreq.c | 26 ++++---------------------- 4 files changed, 8 insertions(+), 64 deletions(-) diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index cb4b2ca..d4ea142 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c @@ -62,26 +62,6 @@ struct cpufreq_frequency_table sa11x0_freq_table[NR_FREQS+1] = { { .frequency = CPUFREQ_TABLE_END, }, }; -/* rounds up(!) */ -unsigned int sa11x0_freq_to_ppcr(unsigned int khz) -{ - int i; - - for (i = 0; i < NR_FREQS; i++) - if (sa11x0_freq_table[i].frequency >= khz) - break; - - return i; -} - -unsigned int sa11x0_ppcr_to_freq(unsigned int idx) -{ - unsigned int freq = 0; - if (idx < NR_FREQS) - freq = sa11x0_freq_table[idx].frequency; - return freq; -} - unsigned int sa11x0_getspeed(unsigned int cpu) { if (cpu) diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h index cbdfae7..0d92e11 100644 --- a/arch/arm/mach-sa1100/generic.h +++ b/arch/arm/mach-sa1100/generic.h @@ -21,9 +21,7 @@ extern void sa1110_mb_enable(void); extern void sa1110_mb_disable(void); extern struct cpufreq_frequency_table sa11x0_freq_table[]; -extern unsigned int sa11x0_freq_to_ppcr(unsigned int khz); extern unsigned int sa11x0_getspeed(unsigned int cpu); -extern unsigned int sa11x0_ppcr_to_freq(unsigned int idx); struct flash_platform_data; struct resource; diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c index b282cea..b0da1fe 100644 --- a/drivers/cpufreq/sa1100-cpufreq.c +++ b/drivers/cpufreq/sa1100-cpufreq.c @@ -177,36 +177,20 @@ static void sa1100_update_dram_timings(int current_speed, int new_speed) } } -static int sa1100_target(struct cpufreq_policy *policy, - unsigned int target_freq, - unsigned int relation) +static int sa1100_target(struct cpufreq_policy *policy, unsigned int ppcr) { unsigned int cur = sa11x0_getspeed(0); - unsigned int new_ppcr; struct cpufreq_freqs freqs; - new_ppcr = sa11x0_freq_to_ppcr(target_freq); - switch (relation) { - case CPUFREQ_RELATION_L: - if (sa11x0_ppcr_to_freq(new_ppcr) > policy->max) - new_ppcr--; - break; - case CPUFREQ_RELATION_H: - if ((sa11x0_ppcr_to_freq(new_ppcr) > target_freq) && - (sa11x0_ppcr_to_freq(new_ppcr - 1) >= policy->min)) - new_ppcr--; - break; - } - freqs.old = cur; - freqs.new = sa11x0_ppcr_to_freq(new_ppcr); + freqs.new = sa11x0_freq_table[ppcr].frequency; cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); if (freqs.new > cur) sa1100_update_dram_timings(cur, freqs.new); - PPCR = new_ppcr; + PPCR = ppcr; if (freqs.new < cur) sa1100_update_dram_timings(cur, freqs.new); @@ -224,7 +208,7 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy) static struct cpufreq_driver sa1100_driver __refdata = { .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, - .target = sa1100_target, + .target_index = sa1100_target, .get = sa11x0_getspeed, .init = sa1100_cpu_init, .name = "sa1100", diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c index bca04c0..55b1818c 100644 --- a/drivers/cpufreq/sa1110-cpufreq.c +++ b/drivers/cpufreq/sa1110-cpufreq.c @@ -229,34 +229,16 @@ sdram_update_refresh(u_int cpu_khz, struct sdram_params *sdram) /* * Ok, set the CPU frequency. */ -static int sa1110_target(struct cpufreq_policy *policy, - unsigned int target_freq, - unsigned int relation) +static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr) { struct sdram_params *sdram = &sdram_params; struct cpufreq_freqs freqs; struct sdram_info sd; unsigned long flags; - unsigned int ppcr, unused; - - switch (relation) { - case CPUFREQ_RELATION_L: - ppcr = sa11x0_freq_to_ppcr(target_freq); - if (sa11x0_ppcr_to_freq(ppcr) > policy->max) - ppcr--; - break; - case CPUFREQ_RELATION_H: - ppcr = sa11x0_freq_to_ppcr(target_freq); - if (ppcr && (sa11x0_ppcr_to_freq(ppcr) > target_freq) && - (sa11x0_ppcr_to_freq(ppcr-1) >= policy->min)) - ppcr--; - break; - default: - return -EINVAL; - } + unsigned int unused; freqs.old = sa11x0_getspeed(0); - freqs.new = sa11x0_ppcr_to_freq(ppcr); + freqs.new = sa11x0_freq_table[ppcr].frequency; sdram_calculate_timing(&sd, freqs.new, sdram); @@ -340,7 +322,7 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy) static struct cpufreq_driver sa1110_driver __refdata = { .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, - .target = sa1110_target, + .target_index = sa1110_target, .get = sa11x0_getspeed, .init = sa1110_cpu_init, .name = "sa1110",