From patchwork Fri Jun 3 13:35: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: 69248 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp268816qgf; Fri, 3 Jun 2016 06:35:52 -0700 (PDT) X-Received: by 10.36.69.82 with SMTP id y79mr4977514ita.78.1464960952007; 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.51; Fri, 03 Jun 2016 06:35:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932946AbcFCNfi (ORCPT + 14 others); Fri, 3 Jun 2016 09:35:38 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:32820 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932909AbcFCNfg (ORCPT ); Fri, 3 Jun 2016 09:35:36 -0400 Received: by mail-pf0-f169.google.com with SMTP id b124so43926694pfb.0 for ; Fri, 03 Jun 2016 06:35:35 -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=AKnKv4zN07XQ1/4FVeZCCQnqYBQWN1lYee5CzYkW5SU=; b=CMs+qTnRX11/a9EXFlZsjzGc+j5LZM0yNFkNEFpGbEqj1KNYn8gOEoIrTcTVrHZaZe AkRhTP9bt+M6cw2PltAsPVScHKLRzN5MooF8LUKODBDWj540I22zkV/IaXkKR9EXDaZI 9YZSCnuoFa+XJuP4LCVKINSVQaVkcDvMYcFew= 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=AKnKv4zN07XQ1/4FVeZCCQnqYBQWN1lYee5CzYkW5SU=; b=AnpiYIg3RnwvDORyEN1NNAqudU4WgTuLcswKzoCjMxGMQ9enx6DpgxVraf9/0Sg5iK RskE9aHf6Y0DMbjvuDXcC0AXfXB3xcWPvh5d1BvmPXIM0A6LV3O+YQrHG+wSxBG444tq GlZ/dJH6nbsz3ktNfE6SgLZacFwzxHXu7IjgC49E673C5Fw1OuMpznYGgOskfy9WCPZE ThmLp9kzF59YOAF9fQhPtE3Q0pHWoeH4oy5vSFCNXn3diW0LGm0etRyoP4Skq7D2vTOv gJmuAl65s1rss7Ms/hWUyQt5mrbNfXGFYBlX4rVipn3WYcIWlCj9itUKFnr6FxSx/mRy eDaQ== X-Gm-Message-State: ALyK8tJICn3INDWEl3zZBoaseeTRnYa/EbuVI+JM3s7uNUuL6UnsjygBtCJ/7s/Wof20QOMV X-Received: by 10.98.73.214 with SMTP id r83mr6205622pfi.114.1464960935104; Fri, 03 Jun 2016 06:35:35 -0700 (PDT) Received: from localhost ([122.167.17.193]) by smtp.gmail.com with ESMTPSA id vb6sm6239863pac.16.2016.06.03.06.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jun 2016 06:35:34 -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, Steven Miao , Dmitry Eremin-Solenikov , Krzysztof Kozlowski , Kukjin Kim , Shawn Guo Subject: [PATCH V3 2/9] cpufreq: blackfin: Use 'index' only to index into policy->freq_table Date: Fri, 3 Jun 2016 19:05:08 +0530 Message-Id: <9d97ad7c5eb1263cfa27778ed0f30ba564d969c8.1464960877.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 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: Steven Miao Signed-off-by: Viresh Kumar --- drivers/cpufreq/blackfin-cpufreq.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) -- 2.7.1.410.g6faf27b -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c index 1650c213f465..101daa851c81 100644 --- a/drivers/cpufreq/blackfin-cpufreq.c +++ b/drivers/cpufreq/blackfin-cpufreq.c @@ -135,6 +135,7 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index) static unsigned long lpj_ref; static unsigned int lpj_ref_freq; unsigned int old_freq, new_freq; + int dpm_index; int ret = 0; #if defined(CONFIG_CYCLES_CLOCKSOURCE) @@ -144,8 +145,14 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index) old_freq = bfin_getfreq_khz(0); new_freq = policy->freq_table[index].frequency; + /* + * policy->freq_table may be sorted differently, get the index value we + * are concerned about. + */ + dpm_index = policy->freq_table[index].driver_data; + #ifndef CONFIG_BF60x - plldiv = (bfin_read_PLL_DIV() & SSEL) | dpm_state_table[index].csel; + plldiv = (bfin_read_PLL_DIV() & SSEL) | dpm_state_table[dpm_index].csel; bfin_write_PLL_DIV(plldiv); #else ret = cpu_set_cclk(policy->cpu, new_freq * 1000); @@ -154,13 +161,13 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index) return ret; } #endif - on_each_cpu(bfin_adjust_core_timer, &index, 1); + on_each_cpu(bfin_adjust_core_timer, &dpm_index, 1); #if defined(CONFIG_CYCLES_CLOCKSOURCE) cycles = get_cycles(); SSYNC(); cycles += 10; /* ~10 cycles we lose after get_cycles() */ - __bfin_cycles_off += (cycles << __bfin_cycles_mod) - (cycles << index); - __bfin_cycles_mod = index; + __bfin_cycles_off += (cycles << __bfin_cycles_mod) - (cycles << dpm_index); + __bfin_cycles_mod = dpm_index; #endif if (!lpj_ref_freq) { lpj_ref = loops_per_jiffy;