From patchwork Thu Jun 2 14:19:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9150113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 21FED607D9 for ; Thu, 2 Jun 2016 14:21:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1278A1FF45 for ; Thu, 2 Jun 2016 14:21:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07702282F9; Thu, 2 Jun 2016 14:21:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8245F282ED for ; Thu, 2 Jun 2016 14:21:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932883AbcFBOVm (ORCPT ); Thu, 2 Jun 2016 10:21:42 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:36178 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161205AbcFBOTq (ORCPT ); Thu, 2 Jun 2016 10:19:46 -0400 Received: by mail-pf0-f173.google.com with SMTP id f144so31940689pfa.3 for ; Thu, 02 Jun 2016 07:19:46 -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=9v5cV/NGzm3SN9b0LPEgkEF2ivLFXm0tt1/liithe8Q=; b=WKyYh+KydchHenz1T7zZSwvJAX5DDXjtsLJEuVDzWgtv9OLjlU2bu9q3AfFMaCtvrW E4/LZFgNfuiO4t+Lp3qEanmLBYw5xYyKwZm+khz5tGzp1zeYXltLF7hEt/u6d+BpMIYx +d1r/4xXhPTQx/qv9gxn79IFGJXt2LzcyQuGQ= 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=9v5cV/NGzm3SN9b0LPEgkEF2ivLFXm0tt1/liithe8Q=; b=C5pCVwiAPTM9domx7Yzz0C5QIBbYb7ftBYAsrmtK0hBRrAufPf3fZT1cFtU/+KqMcH O4LMtPMd8fvq5sEKCOD5eeg5maFUYmQs1ne5gUQDBQ0CVx9gIKU5sCuVpSUSL5jVuJqx a4LeJjmhK2N+/1HuO4uS1Xbe0RWUtNrRkW0iFkf1xxXFVye3gMDuST5YP0EpVCqkPv7A IOaoyYjt1n43UN10MU3IuZVN185myfFioflP4VT9RGzaDzKaZMitfyLwERRjTaJdLBO9 +Pw2eKL1K8y3VUlMn20izJQGMLTKpQICBBjG2f0XnL7MO4JMP/4Mj0TLsyoapfNfDtsP STTw== X-Gm-Message-State: ALyK8tK12j4jZT28d2fVeu2jrb4t05/JpyNP2lDx7Wg+bcrWc2Fh5xwjYckcBN+fePvojlK0 X-Received: by 10.98.94.194 with SMTP id s185mr5043942pfb.32.1464877186072; Thu, 02 Jun 2016 07:19:46 -0700 (PDT) Received: from localhost ([122.167.17.193]) by smtp.gmail.com with ESMTPSA id vy8sm70720499pab.22.2016.06.02.07.19.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jun 2016 07:19:45 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Guo , Dmitry Eremin-Solenikov , Kevin Hilman , Krzysztof Kozlowski , Kukjin Kim , Sekhar Nori , Steven Miao Subject: [PATCH 08/11] cpufreq: imx: Use 'index' only to index into policy->freq_table Date: Thu, 2 Jun 2016 19:49:08 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Later patches would make changes in cpufreq core, after which policy->freq_table may be reordered by cpufreq core and it wouldn't be safe anymore to use 'index' for any other local arrays. To prepare for that, use policy->freq_table[index].driver_data for other driver specific usage of 'index'. The 'driver_data' fields are already set properly by the driver. Cc: Shawn Guo Signed-off-by: Viresh Kumar --- drivers/cpufreq/imx6q-cpufreq.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 3858dc7e617b..e7da85890e8c 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -42,14 +42,21 @@ static unsigned int transition_latency; static u32 *imx6_soc_volt; static u32 soc_opp_count; -static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) +static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int pindex) { struct dev_pm_opp *opp; unsigned long freq_hz, volt, volt_old; - unsigned int old_freq, new_freq; + unsigned int old_freq, new_freq, index; int ret; - new_freq = policy->freq_table[index].frequency; + new_freq = policy->freq_table[pindex].frequency; + + /* + * policy->freq_table may be sorted differently, get the index value we + * are concerned about. + */ + index = policy->freq_table[pindex].driver_data; + freq_hz = new_freq * 1000; old_freq = clk_get_rate(arm_clk) / 1000;