linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: rjw@sisk.pl
Cc: linaro-kernel@lists.linaro.org, patches@linaro.org,
	cpufreq@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Shawn Guo <shawn.guo@linaro.org>
Subject: [PATCH 15/34] cpufreq: imx6q: remove calls to cpufreq_notify_transition()
Date: Fri, 16 Aug 2013 07:55:12 +0530	[thread overview]
Message-ID: <91e60ba4e81b89fbdbf2ff495ccfbf8dc7cb6a04.1376619363.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1376619363.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1376619363.git.viresh.kumar@linaro.org>

Most of the drivers do following in their ->target_index() routines:

	struct cpufreq_freqs freqs;
	freqs.old = old freq...
	freqs.new = new freq...

	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

	/* Change rate here */

	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

This is replicated over all cpufreq drivers today and there doesn't exists a
good enough reason why this shouldn't be moved to cpufreq core instead.

Earlier patches have added support in cpufreq core to do cpufreq notification on
frequency change, this one removes it from this driver.

Some related minor cleanups are also done along with it.

Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/imx6q-cpufreq.c | 39 ++++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 04a32fb..f35c674 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -41,14 +41,14 @@ static unsigned int imx6q_get_speed(unsigned int cpu)
 
 static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
 {
-	struct cpufreq_freqs freqs;
 	struct opp *opp;
 	unsigned long freq_hz, volt, volt_old;
+	unsigned int old_freq, new_freq;
 	int ret;
 
-	freqs.new = freq_table[index].frequency;
-	freq_hz = freqs.new * 1000;
-	freqs.old = clk_get_rate(arm_clk) / 1000;
+	new_freq = freq_table[index].frequency;
+	freq_hz = new_freq * 1000;
+	old_freq = clk_get_rate(arm_clk) / 1000;
 
 	rcu_read_lock();
 	opp = opp_find_freq_ceil(cpu_dev, &freq_hz);
@@ -63,26 +63,23 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
 	volt_old = regulator_get_voltage(arm_reg);
 
 	dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
-		freqs.old / 1000, volt_old / 1000,
-		freqs.new / 1000, volt / 1000);
-
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+		old_freq / 1000, volt_old / 1000,
+		new_freq / 1000, volt / 1000);
 
 	/* scaling up?  scale voltage before frequency */
-	if (freqs.new > freqs.old) {
+	if (new_freq > old_freq) {
 		ret = regulator_set_voltage_tol(arm_reg, volt, 0);
 		if (ret) {
 			dev_err(cpu_dev,
 				"failed to scale vddarm up: %d\n", ret);
-			freqs.new = freqs.old;
-			goto post_notify;
+			return ret;
 		}
 
 		/*
 		 * Need to increase vddpu and vddsoc for safety
 		 * if we are about to run at 1.2 GHz.
 		 */
-		if (freqs.new == FREQ_1P2_GHZ / 1000) {
+		if (new_freq == FREQ_1P2_GHZ / 1000) {
 			regulator_set_voltage_tol(pu_reg,
 					PU_SOC_VOLTAGE_HIGH, 0);
 			regulator_set_voltage_tol(soc_reg,
@@ -103,13 +100,13 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
 	clk_set_parent(step_clk, pll2_pfd2_396m_clk);
 	clk_set_parent(pll1_sw_clk, step_clk);
 	if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) {
-		clk_set_rate(pll1_sys_clk, freqs.new * 1000);
+		clk_set_rate(pll1_sys_clk, new_freq * 1000);
 		/*
 		 * If we are leaving 396 MHz set-point, we need to enable
 		 * pll1_sys_clk and disable pll2_pfd2_396m_clk to keep
 		 * their use count correct.
 		 */
-		if (freqs.old * 1000 <= clk_get_rate(pll2_pfd2_396m_clk)) {
+		if (old_freq * 1000 <= clk_get_rate(pll2_pfd2_396m_clk)) {
 			clk_prepare_enable(pll1_sys_clk);
 			clk_disable_unprepare(pll2_pfd2_396m_clk);
 		}
@@ -124,16 +121,15 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
 	}
 
 	/* Ensure the arm clock divider is what we expect */
-	ret = clk_set_rate(arm_clk, freqs.new * 1000);
+	ret = clk_set_rate(arm_clk, new_freq * 1000);
 	if (ret) {
 		dev_err(cpu_dev, "failed to set clock rate: %d\n", ret);
 		regulator_set_voltage_tol(arm_reg, volt_old, 0);
-		freqs.new = freqs.old;
-		goto post_notify;
+		return ret;
 	}
 
 	/* scaling down?  scale voltage after frequency */
-	if (freqs.new < freqs.old) {
+	if (new_freq < old_freq) {
 		ret = regulator_set_voltage_tol(arm_reg, volt, 0);
 		if (ret) {
 			dev_warn(cpu_dev,
@@ -141,7 +137,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
 			ret = 0;
 		}
 
-		if (freqs.old == FREQ_1P2_GHZ / 1000) {
+		if (old_freq == FREQ_1P2_GHZ / 1000) {
 			regulator_set_voltage_tol(pu_reg,
 					PU_SOC_VOLTAGE_NORMAL, 0);
 			regulator_set_voltage_tol(soc_reg,
@@ -149,10 +145,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
 		}
 	}
 
-post_notify:
-	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
-	return ret;
+	return 0;
 }
 
 static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
-- 
1.7.12.rc2.18.g61b472e

  parent reply	other threads:[~2013-08-16  2:25 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16  2:24 [PATCH 00/34] CPUFreq: Move freq change notifications out of drivers Viresh Kumar
2013-08-16  2:24 ` [PATCH 01/34] cpufreq: move freq change notifications to cpufreq core Viresh Kumar
2013-08-16  2:24 ` [PATCH 02/34] cpufreq: acpi: remove calls to cpufreq_notify_transition() Viresh Kumar
     [not found]   ` <CAOLK0pz7e8nQVnZY0a-j_Fd_kFOqF8ZS4tRfYw1S+25Lv8GoFQ@mail.gmail.com>
     [not found]     ` <CAOLK0pyVDSc6x1u8Ro6ng1dH8ELqc3P9jPHamgiXBn6sWDgm8w@mail.gmail.com>
2013-08-16  7:59       ` Viresh Kumar
2013-08-16 15:30         ` Lan Tianyu
2013-08-16  2:25 ` [PATCH 03/34] cpufreq: arm_big_little: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 04/34] cpufreq: at32ap: " Viresh Kumar
2013-08-16  5:58   ` Hans-Christian Egtvedt
2013-08-16  2:25 ` [PATCH 05/34] cpufreq: blackfin: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 06/34] cpufreq: cpu0: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 07/34] cpufreq: cris: " Viresh Kumar
2017-10-10  7:57   ` Jesper Nilsson
2017-10-10  9:13     ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 08/34] cpufreq: davinci: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 09/34] cpufreq: dbx500: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 10/34] cpufreq: e_powersaver: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 11/34] cpufreq: elanfreq: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 12/34] cpufreq: exynos: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 13/34] cpufreq: exynos5440: set CPUFREQ_NO_NOTIFICATION flag Viresh Kumar
2013-08-18 10:54   ` amit daniel kachhap
2013-08-18 21:57     ` Kukjin Kim
2013-08-19  3:42     ` amit daniel kachhap
2013-08-19  4:40       ` Viresh Kumar
2013-08-16  2:25 ` [PATCH 14/34] cpufreq: ia64-acpi: remove calls to cpufreq_notify_transition() Viresh Kumar
2013-08-16  2:25 ` Viresh Kumar [this message]
2013-08-16  2:25 ` [PATCH 16/34] cpufreq: kirkwood: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 17/34] cpufreq: longhaul: set CPUFREQ_NO_NOTIFICATION flag Viresh Kumar
2013-08-16  2:25 ` [PATCH 18/34] cpufreq: loongson2: remove calls to cpufreq_notify_transition() Viresh Kumar
2013-08-16  2:25 ` [PATCH 19/34] cpufreq: maple: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 20/34] cpufreq: omap: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 21/34] cpufreq: p4-clockmod: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 22/34] cpufreq: pasemi: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 23/34] cpufreq: pmac: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 24/34] cpufreq: powernow: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 25/34] cpufreq: ppc: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 26/34] cpufreq: pxa: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 27/34] cpufreq: s3c: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 28/34] cpufreq: s5pv210: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 29/34] cpufreq: sa11x0: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 30/34] cpufreq: sc520: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 31/34] cpufreq: sparc: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 32/34] cpufreq: SPEAr: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 33/34] cpufreq: speedstep: " Viresh Kumar
2013-08-16  2:25 ` [PATCH 34/34] cpufreq: tegra: " Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91e60ba4e81b89fbdbf2ff495ccfbf8dc7cb6a04.1376619363.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=cpufreq@vger.kernel.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=rjw@sisk.pl \
    --cc=shawn.guo@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).