From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750929AbcFCXtH (ORCPT ); Fri, 3 Jun 2016 19:49:07 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:36759 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750816AbcFCXtF (ORCPT ); Fri, 3 Jun 2016 19:49:05 -0400 From: Steve Muckle X-Google-Original-From: Steve Muckle Date: Fri, 3 Jun 2016 16:48:54 -0700 To: Viresh Kumar Cc: Rafael Wysocki , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, steve.muckle@linaro.org, linuxppc-dev@lists.ozlabs.org, Dmitry Eremin-Solenikov , Krzysztof Kozlowski , Kukjin Kim , Shawn Guo , Steven Miao Subject: Re: [PATCH V3 8/9] cpufreq: Keep policy->freq_table sorted in ascending order Message-ID: <20160603234854.GF14579@graphite.smuckle.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 03, 2016 at 07:05:14PM +0530, Viresh Kumar wrote: ... > @@ -468,20 +469,15 @@ 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_frequency_table_target(policy, target_freq, > + CPUFREQ_RELATION_L); Can we call cpufreq_find_index_l directly here? Seems like we could phase out cpufreq_frequency_table_target() for the most part and call the helpers directly. It would avoid some code bloat, an unnecessary switch statement and an error check for an invalid frequency table which seems unnecessary for every frequency table lookup. thanks, Steve