From patchwork Mon Jun 27 04:29:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 70891 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp882102qgy; Sun, 26 Jun 2016 21:30:05 -0700 (PDT) X-Received: by 10.66.26.136 with SMTP id l8mr29950471pag.49.1467001802834; Sun, 26 Jun 2016 21:30:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x72si24020935pff.224.2016.06.26.21.30.02; Sun, 26 Jun 2016 21:30:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751790AbcF0E3w (ORCPT + 30 others); Mon, 27 Jun 2016 00:29:52 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:32860 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751677AbcF0E3t (ORCPT ); Mon, 27 Jun 2016 00:29:49 -0400 Received: by mail-pf0-f180.google.com with SMTP id i123so57662259pfg.0 for ; Sun, 26 Jun 2016 21:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=cfWS112L8+Xt3fjbaqWRj+1vSap5MqTM2fLQGyfni6I=; b=Ey2HDgvIlYhvAbC1A3Ukcz9xEEsMGbq4g2LYshl2cMrA33oYh6/aBcrV75n7aanPxL atsabEPO0E02WkOcZbE3jUCpJLD6swUJLTp4RxuBHS4Xrbn5Dq7mWmbH7OM9vYp/HMb5 BWoqBQJRcEVxl1Lyw+gKMDA+hPQo0WnD5dLAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=cfWS112L8+Xt3fjbaqWRj+1vSap5MqTM2fLQGyfni6I=; b=DfCZEBAEuDVNj7KzwS6nj0C2vF3SFkRyL5EdnMzFarmP+fb8lRfulxprnJQxhr+qmx 7LcDEgt4pHWoLItu3mIJLJLf7WemZV9tHdiRBhO9RK/sYgDCmWRe/ACOI2/hJBmjATaJ sv1zz49Q5ATF0c+oqf8zmzr+pXzohS3qpRHoDrqKz4D4Gt0aLqu7MPCdngZgeMLlsaVy Xv46KS4H+1T6cP+ajU/HOPN/tEj9TvtdGPiIzWn3tHYcB4RlAop+xs68NtC2vsFsVq22 leUOJtvwmEleGJ0dAxCH8DUFGW13GSB8VPn2BVlrIIbZxZ5FrLAlWtd6eIkk9qwQ/HYm 3pfw== X-Gm-Message-State: ALyK8tK8E4l3uHjGVkaAojNxQCXgAehbfac+xYEX9qH3AAwcKPUOPXR5fDearBCQvkEAB7ep X-Received: by 10.98.88.5 with SMTP id m5mr29552743pfb.27.1467001789128; Sun, 26 Jun 2016 21:29:49 -0700 (PDT) Received: from localhost ([122.172.147.234]) by smtp.gmail.com with ESMTPSA id v126sm2781081pfb.60.2016.06.26.21.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jun 2016 21:29:48 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, steve.muckle@linaro.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH V5 2/2] cpufreq: Reuse new freq-table helpers Date: Mon, 27 Jun 2016 09:59:34 +0530 Message-Id: <29326603f17249f7636fc4ada43b96ad455fecbb.1467001203.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch migrates few users of cpufreq tables to the new helpers that work on sorted freq-tables. Signed-off-by: Viresh Kumar --- drivers/cpufreq/acpi-cpufreq.c | 14 ++++---------- drivers/cpufreq/amd_freq_sensitivity.c | 4 ++-- drivers/cpufreq/cpufreq_ondemand.c | 6 ++---- drivers/cpufreq/powernv-cpufreq.c | 3 +-- drivers/cpufreq/s5pv210-cpufreq.c | 3 +-- 5 files changed, 10 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 32a15052f363..11c9a078e0fd 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -468,20 +468,14 @@ unsigned int acpi_cpufreq_fast_switch(struct cpufreq_policy *policy, struct acpi_cpufreq_data *data = policy->driver_data; struct acpi_processor_performance *perf; struct cpufreq_frequency_table *entry; - unsigned int next_perf_state, next_freq, freq; + unsigned int next_perf_state, next_freq, index; /* * Find the closest frequency above target_freq. - * - * The table is sorted in the reverse order with respect to the - * frequency and all of the entries are valid (see the initialization). */ - entry = policy->freq_table; - do { - entry++; - freq = entry->frequency; - } while (freq >= target_freq && freq != CPUFREQ_TABLE_END); - entry--; + index = cpufreq_table_find_index_dl(policy, target_freq); + + entry = &policy->freq_table[index]; next_freq = entry->frequency; next_perf_state = entry->driver_data; diff --git a/drivers/cpufreq/amd_freq_sensitivity.c b/drivers/cpufreq/amd_freq_sensitivity.c index 6d5dc04c3a37..042023bbbf62 100644 --- a/drivers/cpufreq/amd_freq_sensitivity.c +++ b/drivers/cpufreq/amd_freq_sensitivity.c @@ -91,8 +91,8 @@ static unsigned int amd_powersave_bias_target(struct cpufreq_policy *policy, else { unsigned int index; - index = cpufreq_frequency_table_target(policy, - policy->cur - 1, CPUFREQ_RELATION_H); + index = cpufreq_table_find_index_h(policy, + policy->cur - 1); freq_next = policy->freq_table[index].frequency; } diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 0c93cd9dee99..3a1f49f5f4c6 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -85,11 +85,9 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, freq_avg = freq_req - freq_reduc; /* Find freq bounds for freq_avg in freq_table */ - index = cpufreq_frequency_table_target(policy, freq_avg, - CPUFREQ_RELATION_H); + index = cpufreq_table_find_index_h(policy, freq_avg); freq_lo = freq_table[index].frequency; - index = cpufreq_frequency_table_target(policy, freq_avg, - CPUFREQ_RELATION_L); + index = cpufreq_table_find_index_l(policy, freq_avg); freq_hi = freq_table[index].frequency; /* Find out how long we have to be in hi and lo freqs */ diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index b29c5c20c3a1..2a2920c4fdf9 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -760,8 +760,7 @@ void powernv_cpufreq_work_fn(struct work_struct *work) struct cpufreq_policy policy; cpufreq_get_policy(&policy, cpu); - index = cpufreq_frequency_table_target(&policy, policy.cur, - CPUFREQ_RELATION_C); + index = cpufreq_table_find_index_c(&policy, policy.cur); powernv_cpufreq_target_index(&policy, index); cpumask_andnot(&mask, &mask, policy.cpus); } diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index 4f4e9df9b7fc..9e07588ea9f5 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c @@ -246,8 +246,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index) new_freq = s5pv210_freq_table[index].frequency; /* Finding current running level index */ - priv_index = cpufreq_frequency_table_target(policy, old_freq, - CPUFREQ_RELATION_H); + priv_index = cpufreq_table_find_index_h(policy, old_freq); arm_volt = dvs_conf[index].arm_volt; int_volt = dvs_conf[index].int_volt;