From patchwork Fri Jun 3 13:35:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 69249 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp268833qgf; Fri, 3 Jun 2016 06:35:54 -0700 (PDT) X-Received: by 10.98.103.220 with SMTP id t89mr6089151pfj.125.1464960952445; Fri, 03 Jun 2016 06:35:52 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ce1si5842876pad.166.2016.06.03.06.35.52; Fri, 03 Jun 2016 06:35:52 -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 S1422655AbcFCNfn (ORCPT + 31 others); Fri, 3 Jun 2016 09:35:43 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:33577 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932873AbcFCNfj (ORCPT ); Fri, 3 Jun 2016 09:35:39 -0400 Received: by mail-pa0-f53.google.com with SMTP id ec8so8955908pac.0 for ; Fri, 03 Jun 2016 06:35:39 -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=Hp7bGYOBGTE/ng6pJp7MlLQlJBRkKcs4j9wj6Io7HnCrR91eD6sXVtf3fpQR5DPorT ViMDMqe/gQiePzHtcbzqMPWdoGdYwWKHOf0TNLMoycf5f3PqEIWNi3NGKKwhDgJpe+ng 64oOWaWq3RqO1e34g0AI3W4su3HQp739aDpvY= 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=DTYWLxeBLBBoUnua58rNA3zIgTp0teOp23GAXHK6zx8ARohMgOTho/yH7zYMaXwUxb EkG7JeQTgVF6zXtvJW9rL6UwT/KYXDqO5vDdguWyHwPj2fZ75qHVKm7ctbGWn0Urr+KY 1azeOs7RWqURcK5IjnGyYqYrzMm2KgJk8SrNA+I+RQr6Uzy5g66qc7SwV0pwJ+4cf/Km wbH/eMLHOWhqichYAhiEitNxsBtMLzPJi91t1dW17T0mrr7WchUsc3reVGDrI4kkOtSN iY9OO8s3h8uMSZj31ZEcrxbF3xFcVjRMVIN1q8lKYnfPisotqFzwCk689fOyUycZKLFa vFww== X-Gm-Message-State: ALyK8tLqC25vcxKbTK+pIw+9p8z2AGhQd3uua/MBtP6HlUwRiAOJcFM5MO7PfhbHwtjQDFMy X-Received: by 10.67.15.72 with SMTP id fm8mr5358045pad.50.1464960938836; Fri, 03 Jun 2016 06:35:38 -0700 (PDT) Received: from localhost ([122.167.17.193]) by smtp.gmail.com with ESMTPSA id 7sm8699740pfn.30.2016.06.03.06.35.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jun 2016 06:35:38 -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, steve.muckle@linaro.org, Dmitry Eremin-Solenikov , Krzysztof Kozlowski , Kukjin Kim , Shawn Guo , Steven Miao Subject: [PATCH V3 3/9] cpufreq: elanfreq: Use 'index' only to index into policy->freq_table Date: Fri, 3 Jun 2016 19:05:09 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b 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 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(-) -- 2.7.1.410.g6faf27b 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)