From patchwork Thu Jun 2 14:19:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9150075 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 8DB196082F for ; Thu, 2 Jun 2016 14:19:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E69928047 for ; Thu, 2 Jun 2016 14:19:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DA5328294; Thu, 2 Jun 2016 14:19:45 +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 CF5F428294 for ; Thu, 2 Jun 2016 14:19:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161170AbcFBOTi (ORCPT ); Thu, 2 Jun 2016 10:19:38 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35011 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161131AbcFBOTh (ORCPT ); Thu, 2 Jun 2016 10:19:37 -0400 Received: by mail-pf0-f170.google.com with SMTP id g64so31984823pfb.2 for ; Thu, 02 Jun 2016 07:19:36 -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=9r+ZZ9iQDYtWgtV6BaFP7O0BCpYWrHfoUmlXN6aqmrs=; b=bHis/qUADRuj7q+pclKXcKRAe3CsZet+tWZpVdIpAYjxd1eO5WSlfN5bB6T0Ss341H MjRRIxKNncM2untybh55lTmiRdx7gUSGt0KU3GGq0KX+R8UhrC0uaT+lcKu1s4JQusNZ oyaOjr5yEWDd68oFSKCZfP7aSvlByfYJ1tgOg= 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=9r+ZZ9iQDYtWgtV6BaFP7O0BCpYWrHfoUmlXN6aqmrs=; b=TJdTrbpW8fC+6l26aZ4sWMMbZUNAnwMgCzvx/PEYzwOgjmvOiPi0na5klkuF6mPkM1 +/Oz29rFIXUpYmGvUW8NlCkM1LzHDs5YP6EJybA0JkbJjDkp8YnhFbAwG8bVb3IxZYra sXKX9x9ndg4ru9z6tzy4m9TeUOcX/yIg8TO5UXwhIpzSv+LtcGlIPSTpzJc79bJO8YM1 wOy5H1RysDTqMqE76euj/nmtlsrKIqik6Qs2JhBUOC1R8KokqSGaCw0TUrVrvYYtpIrt mUKzGcjHEghqxfjyw26qO5Iy0iGhEUz78YPzBmuWDAT8VKrGBmWS/k7986DOMtCXlPIy VTkg== X-Gm-Message-State: ALyK8tKa5PK8yYL2ZVZLNbbvsrRNUHpra90INiH2ps6DQ3cXHWi0OQvuCkC3pY3Zk10YAkqm X-Received: by 10.98.24.68 with SMTP id 65mr4913819pfy.160.1464877176454; Thu, 02 Jun 2016 07:19:36 -0700 (PDT) Received: from localhost ([122.167.17.193]) by smtp.gmail.com with ESMTPSA id m75sm1369021pfj.31.2016.06.02.07.19.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jun 2016 07:19:35 -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, Dmitry Eremin-Solenikov , Kevin Hilman , Krzysztof Kozlowski , Kukjin Kim , Sekhar Nori , Shawn Guo , Steven Miao Subject: [PATCH 05/11] cpufreq: elanfreq: Use 'index' only to index into policy->freq_table Date: Thu, 2 Jun 2016 19:49:05 +0530 Message-Id: <9f63bf6fdb8b90b64e5423803f3b38b29a11646b.1464876460.git.viresh.kumar@linaro.org> 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. Signed-off-by: Viresh Kumar --- drivers/cpufreq/elanfreq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c index bfce11cba1df..bd4a51091986 100644 --- a/drivers/cpufreq/elanfreq.c +++ b/drivers/cpufreq/elanfreq.c @@ -108,9 +108,15 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu) static int elanfreq_target(struct cpufreq_policy *policy, - unsigned int state) + unsigned int index) { /* + * policy->freq_table may be sorted differently, get the index value we + * are concerned about. + */ + unsigned int state = policy->freq_table[index].driver_data; + + /* * Access to the Elan's internal registers is indexed via * 0x22: Chip Setup & Control Register Index Register (CSCI) * 0x23: Chip Setup & Control Register Data Register (CSCD)