linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13
@ 2013-08-10  6:43 Viresh Kumar
  2013-08-10  6:43 ` [PATCH 01/44] cpufreq: arm_big_little: call cpufreq_frequency_table_put_attr() Viresh Kumar
                   ` (44 more replies)
  0 siblings, 45 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:43 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Andrew Lunn, David S. Miller,
	Dmitry Eremin-Solenikov, Eric Miao, Guan Xuetao,
	Hans-Christian Egtvedt, Jesper Nilsson, John Crispin, Kukjin Kim,
	Linus Walleij, linux-cris-kernel, linux-sh, Mikael Starvik,
	Paul Mundt, Santosh Shilimkar, Sekhar Nori, Shawn Guo,
	sparclinux, spear-devel, Stephen Warren, Steven Miao, Tony Luck

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patchset first fixes all existing drivers to do
cpufreq_frequency_table_put_attr() corresponding to
cpufreq_frequency_table_get_attr() and then create generic routines which will
be used by most of the cpufreq drivers.

This is rebased on Rafael's bleeding edge + some more cleanup work that I posted
earlier:

https://lkml.org/lkml/2013/8/8/263

This patchset and its dependencies are pushed here:

https://git.linaro.org/gitweb?p=people/vireshk/linux.git;a=shortlog;h=refs/heads/for-v3.13

@Rafael: You would be very happy to see the changelog :)
 49 files changed, 287 insertions(+), 1215 deletions(-)

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: John Crispin <blogic@openwrt.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-cris-kernel@axis.com
Cc: linux-sh@vger.kernel.org
Cc: Mikael Starvik <starvik@axis.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: sparclinux@vger.kernel.org
Cc: spear-devel@list.st.com
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Steven Miao <realmz6@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>

Viresh Kumar (44):
  cpufreq: arm_big_little: call cpufreq_frequency_table_put_attr()
  cpufreq: blackfin: call cpufreq_frequency_table_put_attr()
  cpufreq: exynos: call cpufreq_frequency_table_put_attr()
  cpufreq: loongson2: call cpufreq_frequency_table_put_attr()
  cpufreq: omap: call cpufreq_frequency_table_put_attr()
  cpufreq: pxa: call cpufreq_frequency_table_put_attr()
  cpufreq: sparc: call cpufreq_frequency_table_put_attr()
  cpufreq: define generic .attr, .exit() and .verify() routines
  cpufreq: acpi: Use generic cpufreq routines
  cpufreq: arm_big_little: Use generic cpufreq routines
  cpufreq: at32ap: Use generic cpufreq routines
  cpufreq: blackfin: Use generic cpufreq routines
  cpufreq: cpu0: Use generic cpufreq routines
  cpufreq: cris: Use generic cpufreq routines
  cpufreq: davinci: Use generic cpufreq routines
  cpufreq: dbx500: Use generic cpufreq routines
  cpufreq: e_powersaver: Use generic cpufreq routines
  cpufreq: elanfreq: Use generic cpufreq routines
  cpufreq: exynos: Use generic cpufreq routines
  cpufreq: ia64-acpi: Use generic cpufreq routines
  cpufreq: imx6q: Use generic cpufreq routines
  cpufreq: kirkwood: Use generic cpufreq routines
  cpufreq: longhaul: Use generic cpufreq routines
  cpufreq: loongson2: Use generic cpufreq routines
  cpufreq: maple: Use generic cpufreq routines
  cpufreq: omap: Use generic cpufreq routines
  cpufreq: p4-clockmod: Use generic cpufreq routines
  cpufreq: pasemi: Use generic cpufreq routines
  cpufreq: pcc: Use generic cpufreq routines
  cpufreq: pmac: Use generic cpufreq routines
  cpufreq: powernow: Use generic cpufreq routines
  cpufreq: ppc-corenet: Use generic cpufreq routines
  cpufreq: ppc_cbe: Use generic cpufreq routines
  cpufreq: pxa: Use generic cpufreq routines
  cpufreq: s3cx4xx: Use generic cpufreq routines
  cpufreq: s5pv210: Use generic cpufreq routines
  cpufreq: sc520: Use generic cpufreq routines
  cpufreq: sh: Use generic cpufreq routines
  cpufreq: sparc: Use generic cpufreq routines
  cpufreq: spear: Use generic cpufreq routines
  cpufreq: speedstep: Use generic cpufreq routines
  cpufreq: tegra: Use generic cpufreq routines
  cpufreq: unicore2: Use generic cpufreq routines
  cpufreq: pass suitable index instead of freq to
    cpufreq_driver->target()

 drivers/cpufreq/acpi-cpufreq.c         | 30 ++++---------------
 drivers/cpufreq/arm_big_little.c       | 34 +++++-----------------
 drivers/cpufreq/at32ap-cpufreq.c       | 12 +-------
 drivers/cpufreq/blackfin-cpufreq.c     | 29 ++++---------------
 drivers/cpufreq/cpufreq-cpu0.c         | 37 +++---------------------
 drivers/cpufreq/cpufreq.c              | 30 +++++++++++++++++--
 drivers/cpufreq/cris-artpec3-cpufreq.c | 41 ++++----------------------
 drivers/cpufreq/cris-etraxfs-cpufreq.c | 38 ++++--------------------
 drivers/cpufreq/davinci-cpufreq.c      | 30 ++++---------------
 drivers/cpufreq/dbx500-cpufreq.c       | 27 +++--------------
 drivers/cpufreq/e_powersaver.c         | 28 +++---------------
 drivers/cpufreq/elanfreq.c             | 53 ++++------------------------------
 drivers/cpufreq/exynos-cpufreq.c       | 40 ++++---------------------
 drivers/cpufreq/exynos5440-cpufreq.c   | 18 +++---------
 drivers/cpufreq/freq_table.c           | 20 +++++++++++++
 drivers/cpufreq/ia64-acpi-cpufreq.c    | 41 +++-----------------------
 drivers/cpufreq/imx6q-cpufreq.c        | 38 ++++--------------------
 drivers/cpufreq/kirkwood-cpufreq.c     | 40 ++++---------------------
 drivers/cpufreq/longhaul.c             | 34 +++-------------------
 drivers/cpufreq/loongson2_cpufreq.c    | 34 +++++-----------------
 drivers/cpufreq/maple-cpufreq.c        | 28 ++++--------------
 drivers/cpufreq/omap-cpufreq.c         | 44 ++++------------------------
 drivers/cpufreq/p4-clockmod.c          | 37 ++++--------------------
 drivers/cpufreq/pasemi-cpufreq.c       | 23 ++-------------
 drivers/cpufreq/pcc-cpufreq.c          |  9 +-----
 drivers/cpufreq/pmac32-cpufreq.c       | 23 +++------------
 drivers/cpufreq/pmac64-cpufreq.c       | 28 ++++--------------
 drivers/cpufreq/powernow-k6.c          | 32 +++-----------------
 drivers/cpufreq/powernow-k7.c          | 36 +++++------------------
 drivers/cpufreq/powernow-k8.c          | 36 +++++------------------
 drivers/cpufreq/ppc-corenet-cpufreq.c  | 30 ++++---------------
 drivers/cpufreq/ppc_cbe_cpufreq.c      | 24 ++-------------
 drivers/cpufreq/pxa2xx-cpufreq.c       | 29 ++-----------------
 drivers/cpufreq/pxa3xx-cpufreq.c       | 21 +++-----------
 drivers/cpufreq/s3c2416-cpufreq.c      | 48 ++++++++++--------------------
 drivers/cpufreq/s3c24xx-cpufreq.c      | 37 +++---------------------
 drivers/cpufreq/s3c64xx-cpufreq.c      | 25 +++-------------
 drivers/cpufreq/s5pv210-cpufreq.c      | 24 ++-------------
 drivers/cpufreq/sc520_freq.c           | 43 ++++-----------------------
 drivers/cpufreq/sh-cpufreq.c           |  7 +----
 drivers/cpufreq/sparc-us2e-cpufreq.c   | 23 ++++-----------
 drivers/cpufreq/sparc-us3-cpufreq.c    | 25 ++++------------
 drivers/cpufreq/spear-cpufreq.c        | 32 ++++----------------
 drivers/cpufreq/speedstep-centrino.c   | 42 +++++----------------------
 drivers/cpufreq/speedstep-ich.c        | 48 +++++-------------------------
 drivers/cpufreq/speedstep-smi.c        | 46 +++++------------------------
 drivers/cpufreq/tegra-cpufreq.c        | 22 +++-----------
 drivers/cpufreq/unicore2-cpufreq.c     | 16 +---------
 include/linux/cpufreq.h                | 10 ++++++-
 49 files changed, 287 insertions(+), 1215 deletions(-)

-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply	[flat|nested] 67+ messages in thread

* [PATCH 01/44] cpufreq: arm_big_little: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
@ 2013-08-10  6:43 ` Viresh Kumar
  2013-08-10  6:43 ` [PATCH 02/44] cpufreq: blackfin: " Viresh Kumar
                   ` (43 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:43 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
they have called cpufreq_frequency_table_get_attr() in their init path.

This driver was missing this part and is fixed with this patch.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/arm_big_little.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 5070273..9acfb82 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -198,6 +198,7 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy)
 		return -ENODEV;
 	}
 
+	cpufreq_frequency_table_put_attr(policy->cpu);
 	put_cluster_clk_and_freq_table(cpu_dev);
 	dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu);
 
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 02/44] cpufreq: blackfin: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
  2013-08-10  6:43 ` [PATCH 01/44] cpufreq: arm_big_little: call cpufreq_frequency_table_put_attr() Viresh Kumar
@ 2013-08-10  6:43 ` Viresh Kumar
  2013-08-10  6:43 ` [PATCH 03/44] cpufreq: exynos: " Viresh Kumar
                   ` (42 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:43 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Steven Miao

Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
they have called cpufreq_frequency_table_get_attr() in their init path.

This driver was missing this part and is fixed with this patch.

Cc: Steven Miao <realmz6@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/blackfin-cpufreq.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index 54c0a0c..84d446a 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -213,6 +213,12 @@ static int __bfin_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, bfin_freq_table);
 }
 
+static int __bfin_cpu_exit(struct cpufreq_policy *policy)
+{
+
+	cpufreq_frequency_table_put_attr(policy->cpu);
+}
+
 static struct freq_attr *bfin_freq_attr[] = {
 	&cpufreq_freq_attr_scaling_available_freqs,
 	NULL,
@@ -223,6 +229,7 @@ static struct cpufreq_driver bfin_driver = {
 	.target = bfin_target,
 	.get = bfin_getfreq_khz,
 	.init = __bfin_cpu_init,
+	.exit = __bfin_cpu_exit,
 	.name = "bfin cpufreq",
 	.attr = bfin_freq_attr,
 };
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 03/44] cpufreq: exynos: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
  2013-08-10  6:43 ` [PATCH 01/44] cpufreq: arm_big_little: call cpufreq_frequency_table_put_attr() Viresh Kumar
  2013-08-10  6:43 ` [PATCH 02/44] cpufreq: blackfin: " Viresh Kumar
@ 2013-08-10  6:43 ` Viresh Kumar
  2013-08-12  6:18   ` Viresh Kumar
  2013-08-18 10:00   ` amit daniel kachhap
  2013-08-10  6:44 ` [PATCH 04/44] cpufreq: loongson2: " Viresh Kumar
                   ` (41 subsequent siblings)
  44 siblings, 2 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:43 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Kukjin Kim

Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
they have called cpufreq_frequency_table_get_attr() in their init path.

This driver was missing this part and is fixed with this patch.

Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/exynos5440-cpufreq.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index 1ac93e0..b9dfc91 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -336,12 +336,18 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
+static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
+{
+	cpufreq_frequency_table_put_attr(policy->cpu);
+}
+
 static struct cpufreq_driver exynos_driver = {
 	.flags		= CPUFREQ_STICKY,
 	.verify		= exynos_verify_speed,
 	.target		= exynos_target,
 	.get		= exynos_getspeed,
 	.init		= exynos_cpufreq_cpu_init,
+	.exit		= exynos_cpufreq_cpu_exit,
 	.name		= CPUFREQ_NAME,
 };
 
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 04/44] cpufreq: loongson2: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (2 preceding siblings ...)
  2013-08-10  6:43 ` [PATCH 03/44] cpufreq: exynos: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 05/44] cpufreq: omap: " Viresh Kumar
                   ` (40 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, John Crispin

Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
they have called cpufreq_frequency_table_get_attr() in their init path.

This driver was missing this part and is fixed with this patch.

Cc: John Crispin <blogic@openwrt.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/loongson2_cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index 5dd3692..cec4e72 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -145,6 +145,7 @@ static int loongson2_cpufreq_verify(struct cpufreq_policy *policy)
 
 static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
 {
+	cpufreq_frequency_table_put_attr(policy->cpu);
 	clk_put(cpuclk);
 	return 0;
 }
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 05/44] cpufreq: omap: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (3 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 04/44] cpufreq: loongson2: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 06/44] cpufreq: pxa: " Viresh Kumar
                   ` (39 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Santosh Shilimkar

Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
they have called cpufreq_frequency_table_get_attr() in their init path.

This driver was missing this part and is fixed with this patch.

Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/omap-cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index b68ce4e..091f233 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -221,6 +221,7 @@ fail_ck:
 
 static int omap_cpu_exit(struct cpufreq_policy *policy)
 {
+	cpufreq_frequency_table_put_attr(policy->cpu);
 	freq_table_free();
 	clk_put(mpu_clk);
 	return 0;
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 06/44] cpufreq: pxa: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (4 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 05/44] cpufreq: omap: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 07/44] cpufreq: sparc: " Viresh Kumar
                   ` (38 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Eric Miao

Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
they have called cpufreq_frequency_table_get_attr() in their init path.

This driver was missing this part and is fixed with this patch.

Cc: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/pxa2xx-cpufreq.c | 6 ++++++
 drivers/cpufreq/pxa3xx-cpufreq.c | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index a429d7c..06af29c 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -465,10 +465,16 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
+static int pxa_cpufreq_exit(struct cpufreq_policy *policy)
+{
+	cpufreq_frequency_table_put_attr(policy->cpu);
+}
+
 static struct cpufreq_driver pxa_cpufreq_driver = {
 	.verify	= pxa_verify_policy,
 	.target	= pxa_set_target,
 	.init	= pxa_cpufreq_init,
+	.exit	= pxa_cpufreq_exit,
 	.get	= pxa_cpufreq_get,
 	.name	= "PXA2xx",
 };
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 89841f5..1cc145a 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -227,10 +227,16 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
+static int pxa3xx_cpufreq_exit(struct cpufreq_policy *policy)
+{
+	cpufreq_frequency_table_put_attr(policy->cpu);
+}
+
 static struct cpufreq_driver pxa3xx_cpufreq_driver = {
 	.verify		= pxa3xx_cpufreq_verify,
 	.target		= pxa3xx_cpufreq_set,
 	.init		= pxa3xx_cpufreq_init,
+	.exit		= pxa3xx_cpufreq_exit,
 	.get		= pxa3xx_cpufreq_get,
 	.name		= "pxa3xx-cpufreq",
 };
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 07/44] cpufreq: sparc: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (5 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 06/44] cpufreq: pxa: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 08/44] cpufreq: define generic .attr, .exit() and .verify() routines Viresh Kumar
                   ` (37 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, David S. Miller, sparclinux

Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
they have called cpufreq_frequency_table_get_attr() in their init path.

This driver was missing this part and is fixed with this patch.

Cc: David S. Miller <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/sparc-us2e-cpufreq.c | 4 +++-
 drivers/cpufreq/sparc-us3-cpufreq.c  | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index e35840d..8db0c18 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -329,8 +329,10 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
 
 static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
 {
-	if (cpufreq_us2e_driver)
+	if (cpufreq_us2e_driver) {
+		cpufreq_frequency_table_put_attr(policy->cpu);
 		us2e_set_cpu_divider_index(policy, 0);
+	}
 
 	return 0;
 }
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index 23f2d3b..120a2df 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -186,8 +186,10 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
 
 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
 {
-	if (cpufreq_us3_driver)
+	if (cpufreq_us3_driver) {
+		cpufreq_frequency_table_put_attr(policy->cpu);
 		us3_set_cpu_divider_index(policy, 0);
+	}
 
 	return 0;
 }
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 08/44] cpufreq: define generic .attr, .exit() and .verify() routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (6 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 07/44] cpufreq: sparc: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 09/44] cpufreq: acpi: Use generic cpufreq routines Viresh Kumar
                   ` (36 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Andrew Lunn, David S. Miller,
	Dmitry Eremin-Solenikov, Eric Miao, Guan Xuetao,
	Hans-Christian Egtvedt, Jesper Nilsson, John Crispin, Kukjin Kim,
	Linus Walleij, linux-cris-kernel, linux-sh, Mikael Starvik,
	Paul Mundt, Santosh Shilimkar, Sekhar Nori, Shawn Guo,
	sparclinux, spear-devel, Stephen Warren, Steven Miao, Tony Luck

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch introduces generic .attr, .exit() and .verify() cpufreq drivers.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: John Crispin <blogic@openwrt.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-cris-kernel@axis.com
Cc: linux-sh@vger.kernel.org
Cc: Mikael Starvik <starvik@axis.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: sparclinux@vger.kernel.org
Cc: spear-devel@list.st.com
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Steven Miao <realmz6@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/freq_table.c | 20 ++++++++++++++++++++
 include/linux/cpufreq.h      |  8 ++++++++
 2 files changed, 28 insertions(+)

diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 11f6fa9..b198458 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -87,6 +87,20 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
 }
 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify);
 
+/*
+ * Generic routine to verify policy & frequency table, requires driver to call
+ * cpufreq_frequency_table_get_attr() prior to it.
+ */
+int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy)
+{
+	struct cpufreq_frequency_table *table =
+		cpufreq_frequency_get_table(policy->cpu);
+	if (!table)
+		return -ENODEV;
+
+	return cpufreq_frequency_table_verify(policy, table);
+}
+EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify);
 
 int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
 				   struct cpufreq_frequency_table *table,
@@ -200,6 +214,12 @@ struct freq_attr cpufreq_freq_attr_scaling_available_freqs = {
 };
 EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs);
 
+struct freq_attr *cpufreq_generic_attr[] = {
+	&cpufreq_freq_attr_scaling_available_freqs,
+	NULL,
+};
+EXPORT_SYMBOL_GPL(cpufreq_generic_attr);
+
 /*
  * if you use these, you must assure that the frequency table is valid
  * all the time between get_attr and put_attr!
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index c0297a6..4907eb2 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -393,6 +393,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
 
 int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
 				   struct cpufreq_frequency_table *table);
+int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy);
 
 int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
 				   struct cpufreq_frequency_table *table,
@@ -408,10 +409,17 @@ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
 
 /* the following are really really optional */
 extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
+extern struct freq_attr *cpufreq_generic_attr[];
 void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
 				      unsigned int cpu);
 void cpufreq_frequency_table_put_attr(unsigned int cpu);
 int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
 				      struct cpufreq_frequency_table *table);
 
+static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)
+{
+	cpufreq_frequency_table_put_attr(policy->cpu);
+	return 0;
+}
+
 #endif /* _LINUX_CPUFREQ_H */
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 09/44] cpufreq: acpi: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (7 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 08/44] cpufreq: define generic .attr, .exit() and .verify() routines Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 10/44] cpufreq: arm_big_little: " Viresh Kumar
                   ` (35 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/acpi-cpufreq.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 75e829d..cd5badb 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -516,15 +516,6 @@ out:
 	return result;
 }
 
-static int acpi_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);
-
-	pr_debug("acpi_cpufreq_verify\n");
-
-	return cpufreq_frequency_table_verify(policy, data->freq_table);
-}
-
 static unsigned long
 acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
 {
@@ -927,7 +918,7 @@ static struct freq_attr *acpi_cpufreq_attr[] = {
 };
 
 static struct cpufreq_driver acpi_cpufreq_driver = {
-	.verify		= acpi_cpufreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= acpi_cpufreq_target,
 	.bios_limit	= acpi_processor_get_bios_limit,
 	.init		= acpi_cpufreq_cpu_init,
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 10/44] cpufreq: arm_big_little: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (8 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 09/44] cpufreq: acpi: Use generic cpufreq routines Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 11/44] cpufreq: at32ap: " Viresh Kumar
                   ` (34 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/arm_big_little.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 9acfb82..7e92586 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -47,14 +47,6 @@ static unsigned int bL_cpufreq_get(unsigned int cpu)
 	return clk_get_rate(clk[cur_cluster]) / 1000;
 }
 
-/* Validate policy frequency range */
-static int bL_cpufreq_verify_policy(struct cpufreq_policy *policy)
-{
-	u32 cur_cluster = cpu_to_cluster(policy->cpu);
-
-	return cpufreq_frequency_table_verify(policy, freq_table[cur_cluster]);
-}
-
 /* Set clock frequency */
 static int bL_cpufreq_set_target(struct cpufreq_policy *policy,
 		unsigned int target_freq, unsigned int relation)
@@ -205,22 +197,16 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-/* Export freq_table to sysfs */
-static struct freq_attr *bL_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver bL_cpufreq_driver = {
 	.name			= "arm-big-little",
 	.flags			= CPUFREQ_STICKY,
-	.verify			= bL_cpufreq_verify_policy,
+	.verify			= cpufreq_generic_frequency_table_verify,
 	.target			= bL_cpufreq_set_target,
 	.get			= bL_cpufreq_get,
 	.init			= bL_cpufreq_init,
 	.exit			= bL_cpufreq_exit,
 	.have_governor_per_policy = true,
-	.attr			= bL_cpufreq_attr,
+	.attr			= cpufreq_generic_attr,
 };
 
 int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (9 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 10/44] cpufreq: arm_big_little: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  8:23   ` Hans-Christian Egtvedt
  2013-08-10  6:44 ` [PATCH 12/44] cpufreq: blackfin: " Viresh Kumar
                   ` (33 subsequent siblings)
  44 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Hans-Christian Egtvedt

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/at32ap-cpufreq.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
index e0c38d9..b27f750 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -22,16 +22,6 @@
 
 static struct clk *cpuclk;
 
-static int at32_verify_speed(struct cpufreq_policy *policy)
-{
-	if (policy->cpu != 0)
-		return -EINVAL;
-
-	cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
-			policy->cpuinfo.max_freq);
-	return 0;
-}
-
 static unsigned int at32_get_speed(unsigned int cpu)
 {
 	/* No SMP support */
@@ -109,7 +99,7 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
 static struct cpufreq_driver at32_driver = {
 	.name		= "at32ap",
 	.init		= at32_cpufreq_driver_init,
-	.verify		= at32_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= at32_set_target,
 	.get		= at32_get_speed,
 	.flags		= CPUFREQ_STICKY,
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 12/44] cpufreq: blackfin: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (10 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 11/44] cpufreq: at32ap: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 13/44] cpufreq: cpu0: " Viresh Kumar
                   ` (32 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Steven Miao

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Steven Miao <realmz6@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/blackfin-cpufreq.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index 84d446a..48888cf 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -191,11 +191,6 @@ static int bfin_target(struct cpufreq_policy *policy,
 	return ret;
 }
 
-static int bfin_verify_speed(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, bfin_freq_table);
-}
-
 static int __bfin_cpu_init(struct cpufreq_policy *policy)
 {
 
@@ -213,25 +208,14 @@ static int __bfin_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, bfin_freq_table);
 }
 
-static int __bfin_cpu_exit(struct cpufreq_policy *policy)
-{
-
-	cpufreq_frequency_table_put_attr(policy->cpu);
-}
-
-static struct freq_attr *bfin_freq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver bfin_driver = {
-	.verify = bfin_verify_speed,
+	.verify = cpufreq_generic_frequency_table_verify,
 	.target = bfin_target,
 	.get = bfin_getfreq_khz,
 	.init = __bfin_cpu_init,
-	.exit = __bfin_cpu_exit,
+	.exit = cpufreq_generic_exit,
 	.name = "bfin cpufreq",
-	.attr = bfin_freq_attr,
+	.attr = cpufreq_generic_attr,
 };
 
 static int __init bfin_cpu_init(void)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 13/44] cpufreq: cpu0: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (11 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 12/44] cpufreq: blackfin: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-12  7:58   ` Shawn Guo
  2013-08-10  6:44 ` [PATCH 14/44] cpufreq: cris: " Viresh Kumar
                   ` (31 subsequent siblings)
  44 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Shawn Guo

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

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

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 65d70a3..3d24e7b 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -29,11 +29,6 @@ static struct clk *cpu_clk;
 static struct regulator *cpu_reg;
 static struct cpufreq_frequency_table *freq_table;
 
-static int cpu0_verify_speed(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, freq_table);
-}
-
 static unsigned int cpu0_get_speed(unsigned int cpu)
 {
 	return clk_get_rate(cpu_clk) / 1000;
@@ -147,27 +142,15 @@ static int cpu0_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int cpu0_cpufreq_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-
-	return 0;
-}
-
-static struct freq_attr *cpu0_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver cpu0_cpufreq_driver = {
 	.flags = CPUFREQ_STICKY,
-	.verify = cpu0_verify_speed,
+	.verify = cpufreq_generic_frequency_table_verify,
 	.target = cpu0_set_target,
 	.get = cpu0_get_speed,
 	.init = cpu0_cpufreq_init,
-	.exit = cpu0_cpufreq_exit,
+	.exit = cpufreq_generic_exit,
 	.name = "generic_cpu0",
-	.attr = cpu0_cpufreq_attr,
+	.attr = cpufreq_generic_attr,
 };
 
 static int cpu0_cpufreq_probe(struct platform_device *pdev)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 14/44] cpufreq: cris: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (12 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 13/44] cpufreq: cpu0: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 15/44] cpufreq: davinci: " Viresh Kumar
                   ` (30 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Jesper Nilsson, Mikael Starvik, linux-cris-kernel

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: linux-cris-kernel@axis.com
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cris-artpec3-cpufreq.c | 23 +++--------------------
 drivers/cpufreq/cris-etraxfs-cpufreq.c | 22 +++-------------------
 2 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index 444fd96..d26f4e4 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -54,11 +54,6 @@ static void cris_freq_set_cpu_state(struct cpufreq_policy *policy,
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
 };
 
-static int cris_freq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, &cris_freq_table[0]);
-}
-
 static int cris_freq_target(struct cpufreq_policy *policy,
 			    unsigned int target_freq,
 			    unsigned int relation)
@@ -84,26 +79,14 @@ static int cris_freq_cpu_init(struct cpufreq_policy *policy)
 }
 
 
-static int cris_freq_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-
-static struct freq_attr *cris_freq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver cris_freq_driver = {
 	.get	= cris_freq_get_cpu_frequency,
-	.verify	= cris_freq_verify,
+	.verify	= cpufreq_generic_frequency_table_verify,
 	.target	= cris_freq_target,
 	.init	= cris_freq_cpu_init,
-	.exit	= cris_freq_cpu_exit,
+	.exit	= cpufreq_generic_exit,
 	.name	= "cris_freq",
-	.attr	= cris_freq_attr,
+	.attr	= cpufreq_generic_attr,
 };
 
 static int __init cris_freq_init(void)
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index 428395e..d384e63 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -54,11 +54,6 @@ static void cris_freq_set_cpu_state(struct cpufreq_policy *policy,
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
 };
 
-static int cris_freq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, &cris_freq_table[0]);
-}
-
 static int cris_freq_target(struct cpufreq_policy *policy,
 			    unsigned int target_freq, unsigned int relation)
 {
@@ -82,25 +77,14 @@ static int cris_freq_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, cris_freq_table);
 }
 
-static int cris_freq_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static struct freq_attr *cris_freq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver cris_freq_driver = {
 	.get = cris_freq_get_cpu_frequency,
-	.verify = cris_freq_verify,
+	.verify = cpufreq_generic_frequency_table_verify,
 	.target = cris_freq_target,
 	.init = cris_freq_cpu_init,
-	.exit = cris_freq_cpu_exit,
+	.exit = cpufreq_generic_exit,
 	.name = "cris_freq",
-	.attr = cris_freq_attr,
+	.attr = cpufreq_generic_attr,
 };
 
 static int __init cris_freq_init(void)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 15/44] cpufreq: davinci: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (13 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 14/44] cpufreq: cris: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 16/44] cpufreq: dbx500: " Viresh Kumar
                   ` (29 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Sekhar Nori

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/davinci-cpufreq.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index f67196e..33e9460 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -157,26 +157,15 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int davinci_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static struct freq_attr *davinci_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver davinci_driver = {
 	.flags		= CPUFREQ_STICKY,
 	.verify		= davinci_verify_speed,
 	.target		= davinci_target,
 	.get		= davinci_getspeed,
 	.init		= davinci_cpu_init,
-	.exit		= davinci_cpu_exit,
+	.exit		= cpufreq_generic_exit,
 	.name		= "davinci",
-	.attr		= davinci_cpufreq_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static int __init davinci_cpufreq_probe(struct platform_device *pdev)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 16/44] cpufreq: dbx500: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (14 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 15/44] cpufreq: davinci: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 17/44] cpufreq: e_powersaver: " Viresh Kumar
                   ` (28 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Linus Walleij

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/dbx500-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index ea03b92..7e2f9c0 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -19,16 +19,6 @@
 static struct cpufreq_frequency_table *freq_table;
 static struct clk *armss_clk;
 
-static struct freq_attr *dbx500_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
-static int dbx500_cpufreq_verify_speed(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, freq_table);
-}
-
 static int dbx500_cpufreq_target(struct cpufreq_policy *policy,
 				unsigned int target_freq,
 				unsigned int relation)
@@ -113,12 +103,12 @@ static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
 
 static struct cpufreq_driver dbx500_cpufreq_driver = {
 	.flags  = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS,
-	.verify = dbx500_cpufreq_verify_speed,
+	.verify = cpufreq_generic_frequency_table_verify,
 	.target = dbx500_cpufreq_target,
 	.get    = dbx500_cpufreq_getspeed,
 	.init   = dbx500_cpufreq_init,
 	.name   = "DBX500",
-	.attr   = dbx500_cpufreq_attr,
+	.attr   = cpufreq_generic_attr,
 };
 
 static int dbx500_cpufreq_probe(struct platform_device *pdev)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 17/44] cpufreq: e_powersaver: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (15 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 16/44] cpufreq: dbx500: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 18/44] cpufreq: elanfreq: " Viresh Kumar
                   ` (27 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/e_powersaver.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c
index c1b7c99..a8cbbd0 100644
--- a/drivers/cpufreq/e_powersaver.c
+++ b/drivers/cpufreq/e_powersaver.c
@@ -198,12 +198,6 @@ static int eps_target(struct cpufreq_policy *policy,
 	return ret;
 }
 
-static int eps_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy,
-			&eps_cpu[policy->cpu]->freq_table[0]);
-}
-
 static int eps_cpu_init(struct cpufreq_policy *policy)
 {
 	unsigned int i;
@@ -423,19 +417,14 @@ static int eps_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static struct freq_attr *eps_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver eps_driver = {
-	.verify		= eps_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= eps_target,
 	.init		= eps_cpu_init,
 	.exit		= eps_cpu_exit,
 	.get		= eps_get,
 	.name		= "e_powersaver",
-	.attr		= eps_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 18/44] cpufreq: elanfreq: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (16 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 17/44] cpufreq: e_powersaver: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 19/44] cpufreq: exynos: " Viresh Kumar
                   ` (26 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/elanfreq.c | 32 +++-----------------------------
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c
index 4000c34..fe7053c 100644
--- a/drivers/cpufreq/elanfreq.c
+++ b/drivers/cpufreq/elanfreq.c
@@ -165,19 +165,6 @@ static void elanfreq_set_cpu_state(struct cpufreq_policy *policy,
 };
 
 
-/**
- *	elanfreq_validatespeed: test if frequency range is valid
- *	@policy: the policy to validate
- *
- *	This function checks if a given frequency range in kHz is valid
- *	for the hardware supported by the driver.
- */
-
-static int elanfreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, &elanfreq_table[0]);
-}
-
 static int elanfreq_target(struct cpufreq_policy *policy,
 			    unsigned int target_freq,
 			    unsigned int relation)
@@ -226,13 +213,6 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
 }
 
 
-static int elanfreq_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-
 #ifndef MODULE
 /**
  * elanfreq_setup - elanfreq command line parameter parsing
@@ -255,20 +235,14 @@ __setup("elanfreq=", elanfreq_setup);
 #endif
 
 
-static struct freq_attr *elanfreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
-
 static struct cpufreq_driver elanfreq_driver = {
 	.get		= elanfreq_get_cpu_frequency,
-	.verify		= elanfreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= elanfreq_target,
 	.init		= elanfreq_cpu_init,
-	.exit		= elanfreq_cpu_exit,
+	.exit		= cpufreq_generic_exit,
 	.name		= "elanfreq",
-	.attr		= elanfreq_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static const struct x86_cpu_id elan_id[] = {
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 19/44] cpufreq: exynos: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (17 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 18/44] cpufreq: elanfreq: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-18 10:03   ` amit daniel kachhap
  2013-08-10  6:44 ` [PATCH 20/44] cpufreq: ia64-acpi: " Viresh Kumar
                   ` (25 subsequent siblings)
  44 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Kukjin Kim

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/exynos-cpufreq.c     | 23 +++--------------------
 drivers/cpufreq/exynos5440-cpufreq.c | 15 ++-------------
 2 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 71c4926..7663a96 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -31,12 +31,6 @@ static unsigned int locking_frequency;
 static bool frequency_locked;
 static DEFINE_MUTEX(cpufreq_lock);
 
-static int exynos_verify_speed(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy,
-					      exynos_info->freq_table);
-}
-
 static unsigned int exynos_getspeed(unsigned int cpu)
 {
 	return clk_get_rate(exynos_info->cpu_clk) / 1000;
@@ -257,26 +251,15 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, exynos_info->freq_table);
 }
 
-static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static struct freq_attr *exynos_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver exynos_driver = {
 	.flags		= CPUFREQ_STICKY,
-	.verify		= exynos_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= exynos_target,
 	.get		= exynos_getspeed,
 	.init		= exynos_cpufreq_cpu_init,
-	.exit		= exynos_cpufreq_cpu_exit,
+	.exit		= cpufreq_generic_exit,
 	.name		= "exynos_cpufreq",
-	.attr		= exynos_cpufreq_attr,
+	.attr		= cpufreq_generic_attr,
 #ifdef CONFIG_PM
 	.suspend	= exynos_cpufreq_suspend,
 	.resume		= exynos_cpufreq_resume,
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index b9dfc91..f139b3b 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -209,12 +209,6 @@ static void exynos_enable_dvfs(void)
 				dvfs_info->base + XMU_DVFS_CTRL);
 }
 
-static int exynos_verify_speed(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy,
-					      dvfs_info->freq_table);
-}
-
 static unsigned int exynos_getspeed(unsigned int cpu)
 {
 	return dvfs_info->cur_frequency;
@@ -336,18 +330,13 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-}
-
 static struct cpufreq_driver exynos_driver = {
 	.flags		= CPUFREQ_STICKY,
-	.verify		= exynos_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= exynos_target,
 	.get		= exynos_getspeed,
 	.init		= exynos_cpufreq_cpu_init,
-	.exit		= exynos_cpufreq_cpu_exit,
+	.exit		= cpufreq_generic_exit,
 	.name		= CPUFREQ_NAME,
 };
 
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 20/44] cpufreq: ia64-acpi: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (18 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 19/44] cpufreq: exynos: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 21/44] cpufreq: imx6q: " Viresh Kumar
                   ` (24 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Tony Luck

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/ia64-acpi-cpufreq.c | 26 ++------------------------
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
index 6cfad51..b958bdb 100644
--- a/drivers/cpufreq/ia64-acpi-cpufreq.c
+++ b/drivers/cpufreq/ia64-acpi-cpufreq.c
@@ -248,22 +248,6 @@ acpi_cpufreq_target (
 
 
 static int
-acpi_cpufreq_verify (
-	struct cpufreq_policy   *policy)
-{
-	unsigned int result = 0;
-	struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
-
-	pr_debug("acpi_cpufreq_verify\n");
-
-	result = cpufreq_frequency_table_verify(policy,
-			data->freq_table);
-
-	return (result);
-}
-
-
-static int
 acpi_cpufreq_cpu_init (
 	struct cpufreq_policy   *policy)
 {
@@ -394,20 +378,14 @@ acpi_cpufreq_cpu_exit (
 }
 
 
-static struct freq_attr* acpi_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
-
 static struct cpufreq_driver acpi_cpufreq_driver = {
-	.verify 	= acpi_cpufreq_verify,
+	.verify 	= cpufreq_generic_frequency_table_verify,
 	.target 	= acpi_cpufreq_target,
 	.get 		= acpi_cpufreq_get,
 	.init		= acpi_cpufreq_cpu_init,
 	.exit		= acpi_cpufreq_cpu_exit,
 	.name		= "acpi-cpufreq",
-	.attr           = acpi_cpufreq_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 21/44] cpufreq: imx6q: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (19 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 20/44] cpufreq: ia64-acpi: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-12  7:58   ` Shawn Guo
  2013-08-10  6:44 ` [PATCH 22/44] cpufreq: kirkwood: " Viresh Kumar
                   ` (23 subsequent siblings)
  44 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Shawn Guo

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

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

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index e6f40fa..81d1727 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -34,11 +34,6 @@ static struct device *cpu_dev;
 static struct cpufreq_frequency_table *freq_table;
 static unsigned int transition_latency;
 
-static int imx6q_verify_speed(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, freq_table);
-}
-
 static unsigned int imx6q_get_speed(unsigned int cpu)
 {
 	return clk_get_rate(arm_clk) / 1000;
@@ -190,25 +185,14 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int imx6q_cpufreq_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static struct freq_attr *imx6q_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver imx6q_cpufreq_driver = {
-	.verify = imx6q_verify_speed,
+	.verify = cpufreq_generic_frequency_table_verify,
 	.target = imx6q_set_target,
 	.get = imx6q_get_speed,
 	.init = imx6q_cpufreq_init,
-	.exit = imx6q_cpufreq_exit,
+	.exit = cpufreq_generic_exit,
 	.name = "imx6q-cpufreq",
-	.attr = imx6q_cpufreq_attr,
+	.attr = cpufreq_generic_attr,
 };
 
 static int imx6q_cpufreq_probe(struct platform_device *pdev)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 22/44] cpufreq: kirkwood: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (20 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 21/44] cpufreq: imx6q: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 23/44] cpufreq: longhaul: " Viresh Kumar
                   ` (22 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Andrew Lunn

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/kirkwood-cpufreq.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index 336f171..9018c4d 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -102,11 +102,6 @@ static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy,
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
 };
 
-static int kirkwood_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, kirkwood_freq_table);
-}
-
 static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
 			    unsigned int target_freq,
 			    unsigned int relation)
@@ -132,25 +127,14 @@ static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, kirkwood_freq_table);
 }
 
-static int kirkwood_cpufreq_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static struct freq_attr *kirkwood_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver kirkwood_cpufreq_driver = {
 	.get	= kirkwood_cpufreq_get_cpu_frequency,
-	.verify	= kirkwood_cpufreq_verify,
+	.verify	= cpufreq_generic_frequency_table_verify,
 	.target	= kirkwood_cpufreq_target,
 	.init	= kirkwood_cpufreq_cpu_init,
-	.exit	= kirkwood_cpufreq_cpu_exit,
+	.exit	= cpufreq_generic_exit,
 	.name	= "kirkwood-cpufreq",
-	.attr	= kirkwood_cpufreq_attr,
+	.attr	= cpufreq_generic_attr,
 };
 
 static int kirkwood_cpufreq_probe(struct platform_device *pdev)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 23/44] cpufreq: longhaul: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (21 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 22/44] cpufreq: kirkwood: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 24/44] cpufreq: loongson2: " Viresh Kumar
                   ` (21 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/longhaul.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index 70b66fd..57d7b02 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -625,12 +625,6 @@ static void longhaul_setup_voltagescaling(void)
 }
 
 
-static int longhaul_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, longhaul_table);
-}
-
-
 static int longhaul_target(struct cpufreq_policy *policy,
 			    unsigned int target_freq, unsigned int relation)
 {
@@ -924,25 +918,14 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, longhaul_table);
 }
 
-static int longhaul_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static struct freq_attr *longhaul_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver longhaul_driver = {
-	.verify	= longhaul_verify,
+	.verify	= cpufreq_generic_frequency_table_verify,
 	.target	= longhaul_target,
 	.get	= longhaul_get,
 	.init	= longhaul_cpu_init,
-	.exit	= longhaul_cpu_exit,
+	.exit	= cpufreq_generic_exit,
 	.name	= "longhaul",
-	.attr	= longhaul_attr,
+	.attr	= cpufreq_generic_attr,
 };
 
 static const struct x86_cpu_id longhaul_id[] = {
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 24/44] cpufreq: loongson2: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (22 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 23/44] cpufreq: longhaul: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 25/44] cpufreq: maple: " Viresh Kumar
                   ` (20 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, John Crispin

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: John Crispin <blogic@openwrt.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/loongson2_cpufreq.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index cec4e72..ed7fbe2 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -137,12 +137,6 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
 					    &loongson2_clockmod_table[0]);
 }
 
-static int loongson2_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy,
-					      &loongson2_clockmod_table[0]);
-}
-
 static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
 {
 	cpufreq_frequency_table_put_attr(policy->cpu);
@@ -150,19 +144,14 @@ static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static struct freq_attr *loongson2_table_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver loongson2_cpufreq_driver = {
 	.name = "loongson2",
 	.init = loongson2_cpufreq_cpu_init,
-	.verify = loongson2_cpufreq_verify,
+	.verify = cpufreq_generic_frequency_table_verify,
 	.target = loongson2_cpufreq_target,
 	.get = loongson2_cpufreq_get,
 	.exit = loongson2_cpufreq_exit,
-	.attr = loongson2_table_attr,
+	.attr = cpufreq_generic_attr,
 };
 
 static struct platform_device_id platform_device_ids[] = {
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 25/44] cpufreq: maple: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (23 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 24/44] cpufreq: loongson2: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 26/44] cpufreq: omap: " Viresh Kumar
                   ` (19 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Dmitry Eremin-Solenikov

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/maple-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index 19076cc..7720670 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -64,11 +64,6 @@ static struct cpufreq_frequency_table maple_cpu_freqs[] = {
 	{0,			CPUFREQ_TABLE_END},
 };
 
-static struct freq_attr *maple_cpu_freqs_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 /* Power mode data is an array of the 32 bits PCR values to use for
  * the various frequencies, retrieved from the device-tree
  */
@@ -135,11 +130,6 @@ static int maple_scom_query_freq(void)
  * Common interface to the cpufreq core
  */
 
-static int maple_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, maple_cpu_freqs);
-}
-
 static int maple_cpufreq_target(struct cpufreq_policy *policy,
 	unsigned int target_freq, unsigned int relation)
 {
@@ -190,10 +180,10 @@ static struct cpufreq_driver maple_cpufreq_driver = {
 	.name		= "maple",
 	.flags		= CPUFREQ_CONST_LOOPS,
 	.init		= maple_cpufreq_cpu_init,
-	.verify		= maple_cpufreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= maple_cpufreq_target,
 	.get		= maple_cpufreq_get_speed,
-	.attr		= maple_cpu_freqs_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static int __init maple_cpufreq_init(void)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 26/44] cpufreq: omap: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (24 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 25/44] cpufreq: maple: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 27/44] cpufreq: p4-clockmod: " Viresh Kumar
                   ` (18 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Santosh Shilimkar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/omap-cpufreq.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 091f233..48020b5 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -40,13 +40,6 @@ static struct clk *mpu_clk;
 static struct device *mpu_dev;
 static struct regulator *mpu_reg;
 
-static int omap_verify_speed(struct cpufreq_policy *policy)
-{
-	if (!freq_table)
-		return -EINVAL;
-	return cpufreq_frequency_table_verify(policy, freq_table);
-}
-
 static unsigned int omap_getspeed(unsigned int cpu)
 {
 	unsigned long rate;
@@ -227,20 +220,15 @@ static int omap_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static struct freq_attr *omap_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver omap_driver = {
 	.flags		= CPUFREQ_STICKY,
-	.verify		= omap_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= omap_target,
 	.get		= omap_getspeed,
 	.init		= omap_cpu_init,
 	.exit		= omap_cpu_exit,
 	.name		= "omap",
-	.attr		= omap_cpufreq_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static int omap_cpufreq_probe(struct platform_device *pdev)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 27/44] cpufreq: p4-clockmod: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (25 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 26/44] cpufreq: omap: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 28/44] cpufreq: pasemi: " Viresh Kumar
                   ` (17 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, David S. Miller

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/p4-clockmod.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 03478bf..4fe6d4c 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -140,12 +140,6 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
 }
 
 
-static int cpufreq_p4_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, &p4clockmod_table[0]);
-}
-
-
 static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
 {
 	if (c->x86 == 0x06) {
@@ -242,12 +236,6 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
 }
 
 
-static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
 static unsigned int cpufreq_p4_get(unsigned int cpu)
 {
 	u32 l, h;
@@ -266,19 +254,14 @@ static unsigned int cpufreq_p4_get(unsigned int cpu)
 	return stock_freq;
 }
 
-static struct freq_attr *p4clockmod_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver p4clockmod_driver = {
-	.verify		= cpufreq_p4_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= cpufreq_p4_target,
 	.init		= cpufreq_p4_cpu_init,
-	.exit		= cpufreq_p4_cpu_exit,
+	.exit		= cpufreq_generic_exit,
 	.get		= cpufreq_p4_get,
 	.name		= "p4-clockmod",
-	.attr		= p4clockmod_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static const struct x86_cpu_id cpufreq_p4_id[] = {
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 28/44] cpufreq: pasemi: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (26 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 27/44] cpufreq: p4-clockmod: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 29/44] cpufreq: pcc: " Viresh Kumar
                   ` (16 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/pasemi-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 23bc8a82..16f2508 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -69,11 +69,6 @@ static struct cpufreq_frequency_table pas_freqs[] = {
 	{0,	CPUFREQ_TABLE_END},
 };
 
-static struct freq_attr *pas_cpu_freqs_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 /*
  * hardware specific functions
  */
@@ -251,11 +246,6 @@ static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int pas_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, pas_freqs);
-}
-
 static int pas_cpufreq_target(struct cpufreq_policy *policy,
 			      unsigned int target_freq,
 			      unsigned int relation)
@@ -298,9 +288,9 @@ static struct cpufreq_driver pas_cpufreq_driver = {
 	.flags		= CPUFREQ_CONST_LOOPS,
 	.init		= pas_cpufreq_cpu_init,
 	.exit		= pas_cpufreq_cpu_exit,
-	.verify		= pas_cpufreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= pas_cpufreq_target,
-	.attr		= pas_cpu_freqs_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 /*
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 29/44] cpufreq: pcc: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (27 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 28/44] cpufreq: pasemi: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-12  6:08   ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 30/44] cpufreq: pmac: " Viresh Kumar
                   ` (15 subsequent siblings)
  44 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/pcc-cpufreq.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
index d81c4e5..90aa385 100644
--- a/drivers/cpufreq/pcc-cpufreq.c
+++ b/drivers/cpufreq/pcc-cpufreq.c
@@ -109,13 +109,6 @@ struct pcc_cpu {
 
 static struct pcc_cpu __percpu *pcc_cpu_info;
 
-static int pcc_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
-				     policy->cpuinfo.max_freq);
-	return 0;
-}
-
 static inline void pcc_cmd(void)
 {
 	u64 doorbell_value;
@@ -582,7 +575,7 @@ static int pcc_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 static struct cpufreq_driver pcc_cpufreq_driver = {
 	.flags = CPUFREQ_CONST_LOOPS,
 	.get = pcc_get_freq,
-	.verify = pcc_cpufreq_verify,
+	.verify = cpufreq_generic_frequency_table_verify,
 	.target = pcc_cpufreq_target,
 	.init = pcc_cpufreq_cpu_init,
 	.exit = pcc_cpufreq_cpu_exit,
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 30/44] cpufreq: pmac: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (28 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 29/44] cpufreq: pcc: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 31/44] cpufreq: powernow: " Viresh Kumar
                   ` (14 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/pmac32-cpufreq.c | 14 ++------------
 drivers/cpufreq/pmac64-cpufreq.c | 14 ++------------
 2 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index 0b3efdb..3f8efd2 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -85,11 +85,6 @@ static struct cpufreq_frequency_table pmac_cpu_freqs[] = {
 	{0,			CPUFREQ_TABLE_END},
 };
 
-static struct freq_attr* pmac_cpu_freqs_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static inline void local_delay(unsigned long ms)
 {
 	if (no_schedule)
@@ -377,11 +372,6 @@ static unsigned int pmac_cpufreq_get_speed(unsigned int cpu)
 	return cur_freq;
 }
 
-static int pmac_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, pmac_cpu_freqs);
-}
-
 static int pmac_cpufreq_target(	struct cpufreq_policy *policy,
 					unsigned int target_freq,
 					unsigned int relation)
@@ -467,14 +457,14 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver pmac_cpufreq_driver = {
-	.verify 	= pmac_cpufreq_verify,
+	.verify 	= cpufreq_generic_frequency_table_verify,
 	.target 	= pmac_cpufreq_target,
 	.get		= pmac_cpufreq_get_speed,
 	.init		= pmac_cpufreq_cpu_init,
 	.suspend	= pmac_cpufreq_suspend,
 	.resume		= pmac_cpufreq_resume,
 	.flags		= CPUFREQ_PM_NO_WARN,
-	.attr		= pmac_cpu_freqs_attr,
+	.attr		= cpufreq_generic_attr,
 	.name		= "powermac",
 };
 
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index 366be61..0eb9313 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -69,11 +69,6 @@ static struct cpufreq_frequency_table g5_cpu_freqs[] = {
 	{0,			CPUFREQ_TABLE_END},
 };
 
-static struct freq_attr* g5_cpu_freqs_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 /* Power mode data is an array of the 32 bits PCR values to use for
  * the various frequencies, retrieved from the device-tree
  */
@@ -316,11 +311,6 @@ static int g5_pfunc_query_freq(void)
  * Common interface to the cpufreq core
  */
 
-static int g5_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, g5_cpu_freqs);
-}
-
 static int g5_cpufreq_target(struct cpufreq_policy *policy,
 	unsigned int target_freq, unsigned int relation)
 {
@@ -371,10 +361,10 @@ static struct cpufreq_driver g5_cpufreq_driver = {
 	.name		= "powermac",
 	.flags		= CPUFREQ_CONST_LOOPS,
 	.init		= g5_cpufreq_cpu_init,
-	.verify		= g5_cpufreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= g5_cpufreq_target,
 	.get		= g5_cpufreq_get_speed,
-	.attr 		= g5_cpu_freqs_attr,
+	.attr 		= cpufreq_generic_attr,
 };
 
 
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 31/44] cpufreq: powernow: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (29 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 30/44] cpufreq: pmac: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 32/44] cpufreq: ppc-corenet: " Viresh Kumar
                   ` (13 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/powernow-k6.c | 22 ++--------------------
 drivers/cpufreq/powernow-k7.c | 14 ++------------
 drivers/cpufreq/powernow-k8.c | 20 ++------------------
 3 files changed, 6 insertions(+), 50 deletions(-)

diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index ab1de0d..ff05d28 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -105,19 +105,6 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy,
 
 
 /**
- * powernow_k6_verify - verifies a new CPUfreq policy
- * @policy: new policy
- *
- * Policy must be within lowest and highest possible CPU Frequency,
- * and at least one possible state must be within min and max.
- */
-static int powernow_k6_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, &clock_ratio[0]);
-}
-
-
-/**
  * powernow_k6_setpolicy - sets a new CPUFreq policy
  * @policy: new policy
  * @target_freq: the target frequency
@@ -188,19 +175,14 @@ static unsigned int powernow_k6_get(unsigned int cpu)
 	return ret;
 }
 
-static struct freq_attr *powernow_k6_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver powernow_k6_driver = {
-	.verify		= powernow_k6_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= powernow_k6_target,
 	.init		= powernow_k6_cpu_init,
 	.exit		= powernow_k6_cpu_exit,
 	.get		= powernow_k6_get,
 	.name		= "powernow-k6",
-	.attr		= powernow_k6_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static const struct x86_cpu_id powernow_k6_ids[] = {
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index c863c13..14cd98f 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -549,11 +549,6 @@ static int powernow_target(struct cpufreq_policy *policy,
 }
 
 
-static int powernow_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, powernow_table);
-}
-
 /*
  * We use the fact that the bus frequency is somehow
  * a multiple of 100000/3 khz, then we compute sgtc according
@@ -699,13 +694,8 @@ static int powernow_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static struct freq_attr *powernow_table_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver powernow_driver = {
-	.verify		= powernow_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= powernow_target,
 	.get		= powernow_get,
 #ifdef CONFIG_X86_POWERNOW_K7_ACPI
@@ -714,7 +704,7 @@ static struct cpufreq_driver powernow_driver = {
 	.init		= powernow_cpu_init,
 	.exit		= powernow_cpu_exit,
 	.name		= "powernow-k7",
-	.attr		= powernow_table_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static int __init powernow_init(void)
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 8d4114a..1e6f68a 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1053,17 +1053,6 @@ static int powernowk8_target(struct cpufreq_policy *pol,
 	return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
 }
 
-/* Driver entry point to verify the policy and range of frequencies */
-static int powernowk8_verify(struct cpufreq_policy *pol)
-{
-	struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
-
-	if (!data)
-		return -EINVAL;
-
-	return cpufreq_frequency_table_verify(pol, data->powernow_table);
-}
-
 struct init_on_cpu {
 	struct powernow_k8_data *data;
 	int rc;
@@ -1225,20 +1214,15 @@ out:
 	return khz;
 }
 
-static struct freq_attr *powernow_k8_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver cpufreq_amd64_driver = {
-	.verify		= powernowk8_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= powernowk8_target,
 	.bios_limit	= acpi_processor_get_bios_limit,
 	.init		= powernowk8_cpu_init,
 	.exit		= powernowk8_cpu_exit,
 	.get		= powernowk8_get,
 	.name		= "powernow-k8",
-	.attr		= powernow_k8_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static void __request_acpi_cpufreq(void)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 32/44] cpufreq: ppc-corenet: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (30 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 31/44] cpufreq: powernow: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 33/44] cpufreq: ppc_cbe: " Viresh Kumar
                   ` (12 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/ppc-corenet-cpufreq.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index 5716b44..befd489 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -252,14 +252,6 @@ static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int corenet_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	struct cpufreq_frequency_table *table =
-		per_cpu(cpu_data, policy->cpu)->table;
-
-	return cpufreq_frequency_table_verify(policy, table);
-}
-
 static int corenet_cpufreq_target(struct cpufreq_policy *policy,
 		unsigned int target_freq, unsigned int relation)
 {
@@ -292,20 +284,15 @@ static int corenet_cpufreq_target(struct cpufreq_policy *policy,
 	return ret;
 }
 
-static struct freq_attr *corenet_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver ppc_corenet_cpufreq_driver = {
 	.name		= "ppc_cpufreq",
 	.flags		= CPUFREQ_CONST_LOOPS,
 	.init		= corenet_cpufreq_cpu_init,
 	.exit		= __exit_p(corenet_cpufreq_cpu_exit),
-	.verify		= corenet_cpufreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= corenet_cpufreq_target,
 	.get		= corenet_cpufreq_get_speed,
-	.attr		= corenet_cpufreq_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static const struct of_device_id node_matches[] __initdata = {
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 33/44] cpufreq: ppc_cbe: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (31 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 32/44] cpufreq: ppc-corenet: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 34/44] cpufreq: pxa: " Viresh Kumar
                   ` (11 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/ppc_cbe_cpufreq.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
index 6c5be63..38540d1 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -128,17 +128,6 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, cbe_freqs);
 }
 
-static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static int cbe_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, cbe_freqs);
-}
-
 static int cbe_cpufreq_target(struct cpufreq_policy *policy,
 			      unsigned int target_freq,
 			      unsigned int relation)
@@ -174,10 +163,10 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy,
 }
 
 static struct cpufreq_driver cbe_cpufreq_driver = {
-	.verify		= cbe_cpufreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= cbe_cpufreq_target,
 	.init		= cbe_cpufreq_cpu_init,
-	.exit		= cbe_cpufreq_cpu_exit,
+	.exit		= cpufreq_generic_exit,
 	.name		= "cbe-cpufreq",
 	.flags		= CPUFREQ_CONST_LOOPS,
 };
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 34/44] cpufreq: pxa: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (32 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 33/44] cpufreq: ppc_cbe: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 35/44] cpufreq: s3cx4xx: " Viresh Kumar
                   ` (10 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Eric Miao

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/pxa2xx-cpufreq.c | 26 ++------------------------
 drivers/cpufreq/pxa3xx-cpufreq.c | 14 ++------------
 2 files changed, 4 insertions(+), 36 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 06af29c..5a72bf3 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -262,23 +262,6 @@ static u32 mdrefr_dri(unsigned int freq)
 	return (interval - (cpu_is_pxa27x() ? 31 : 0)) / 32;
 }
 
-/* find a valid frequency point */
-static int pxa_verify_policy(struct cpufreq_policy *policy)
-{
-	struct cpufreq_frequency_table *pxa_freqs_table;
-	pxa_freqs_t *pxa_freqs;
-	int ret;
-
-	find_freq_tables(&pxa_freqs_table, &pxa_freqs);
-	ret = cpufreq_frequency_table_verify(policy, pxa_freqs_table);
-
-	if (freq_debug)
-		pr_debug("Verified CPU policy: %dKhz min to %dKhz max\n",
-			 policy->min, policy->max);
-
-	return ret;
-}
-
 static unsigned int pxa_cpufreq_get(unsigned int cpu)
 {
 	return get_clk_frequency_khz(0);
@@ -465,16 +448,11 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int pxa_cpufreq_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-}
-
 static struct cpufreq_driver pxa_cpufreq_driver = {
-	.verify	= pxa_verify_policy,
+	.verify	= cpufreq_generic_frequency_table_verify,
 	.target	= pxa_set_target,
 	.init	= pxa_cpufreq_init,
-	.exit	= pxa_cpufreq_exit,
+	.exit	= cpufreq_generic_exit,
 	.get	= pxa_cpufreq_get,
 	.name	= "PXA2xx",
 };
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 1cc145a..2837fd6 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -150,11 +150,6 @@ static void __update_bus_freq(struct pxa3xx_freq_info *info)
 		cpu_relax();
 }
 
-static int pxa3xx_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, pxa3xx_freqs_table);
-}
-
 static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)
 {
 	return pxa3xx_get_clk_frequency_khz(0);
@@ -227,16 +222,11 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int pxa3xx_cpufreq_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-}
-
 static struct cpufreq_driver pxa3xx_cpufreq_driver = {
-	.verify		= pxa3xx_cpufreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= pxa3xx_cpufreq_set,
 	.init		= pxa3xx_cpufreq_init,
-	.exit		= pxa3xx_cpufreq_exit,
+	.exit		= cpufreq_generic_exit,
 	.get		= pxa3xx_cpufreq_get,
 	.name		= "pxa3xx-cpufreq",
 };
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 35/44] cpufreq: s3cx4xx: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (33 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 34/44] cpufreq: pxa: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 36/44] cpufreq: s5pv210: " Viresh Kumar
                   ` (9 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Kukjin Kim

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/s3c2416-cpufreq.c | 19 ++-----------------
 drivers/cpufreq/s3c24xx-cpufreq.c |  9 ---------
 drivers/cpufreq/s3c64xx-cpufreq.c | 10 +---------
 3 files changed, 3 insertions(+), 35 deletions(-)

diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index a7a4c61..8c57f10 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -87,16 +87,6 @@ static struct cpufreq_frequency_table s3c2450_freq_table[] = {
 	{ 0, CPUFREQ_TABLE_END },
 };
 
-static int s3c2416_cpufreq_verify_speed(struct cpufreq_policy *policy)
-{
-	struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;
-
-	if (policy->cpu != 0)
-		return -EINVAL;
-
-	return cpufreq_frequency_table_verify(policy, s3c_freq->freq_table);
-}
-
 static unsigned int s3c2416_cpufreq_get_speed(unsigned int cpu)
 {
 	struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;
@@ -516,19 +506,14 @@ err_hclk:
 	return ret;
 }
 
-static struct freq_attr *s3c2416_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver s3c2416_cpufreq_driver = {
 	.flags          = 0,
-	.verify		= s3c2416_cpufreq_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= s3c2416_cpufreq_set_target,
 	.get		= s3c2416_cpufreq_get_speed,
 	.init		= s3c2416_cpufreq_driver_init,
 	.name		= "s3c2416",
-	.attr		= s3c2416_cpufreq_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static int __init s3c2416_cpufreq_init(void)
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index 39c1d3e..93fcdde 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -416,14 +416,6 @@ static __init int s3c_cpufreq_initclks(void)
 	return 0;
 }
 
-static int s3c_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	if (policy->cpu != 0)
-		return -EINVAL;
-
-	return 0;
-}
-
 #ifdef CONFIG_PM
 static struct cpufreq_frequency_table suspend_pll;
 static unsigned int suspend_freq;
@@ -473,7 +465,6 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy)
 
 static struct cpufreq_driver s3c24xx_driver = {
 	.flags		= CPUFREQ_STICKY,
-	.verify		= s3c_cpufreq_verify,
 	.target		= s3c_cpufreq_target,
 	.get		= s3c_cpufreq_get,
 	.init		= s3c_cpufreq_init,
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 872f74d..99fbc49 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -54,14 +54,6 @@ static struct cpufreq_frequency_table s3c64xx_freq_table[] = {
 };
 #endif
 
-static int s3c64xx_cpufreq_verify_speed(struct cpufreq_policy *policy)
-{
-	if (policy->cpu != 0)
-		return -EINVAL;
-
-	return cpufreq_frequency_table_verify(policy, s3c64xx_freq_table);
-}
-
 static unsigned int s3c64xx_cpufreq_get_speed(unsigned int cpu)
 {
 	if (cpu != 0)
@@ -264,7 +256,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
 
 static struct cpufreq_driver s3c64xx_cpufreq_driver = {
 	.flags          = 0,
-	.verify		= s3c64xx_cpufreq_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= s3c64xx_cpufreq_set_target,
 	.get		= s3c64xx_cpufreq_get_speed,
 	.init		= s3c64xx_cpufreq_driver_init,
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 36/44] cpufreq: s5pv210: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (34 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 35/44] cpufreq: s3cx4xx: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 37/44] cpufreq: sc520: " Viresh Kumar
                   ` (8 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Kukjin Kim

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/s5pv210-cpufreq.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index c266a7e..0eafc52 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -174,14 +174,6 @@ static void s5pv210_set_refresh(enum s5pv210_dmc_port ch, unsigned long freq)
 	__raw_writel(tmp1, reg);
 }
 
-static int s5pv210_verify_speed(struct cpufreq_policy *policy)
-{
-	if (policy->cpu)
-		return -EINVAL;
-
-	return cpufreq_frequency_table_verify(policy, s5pv210_freq_table);
-}
-
 static unsigned int s5pv210_getspeed(unsigned int cpu)
 {
 	if (cpu)
@@ -603,7 +595,7 @@ static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this,
 
 static struct cpufreq_driver s5pv210_driver = {
 	.flags		= CPUFREQ_STICKY,
-	.verify		= s5pv210_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= s5pv210_target,
 	.get		= s5pv210_getspeed,
 	.init		= s5pv210_cpu_init,
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 37/44] cpufreq: sc520: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (35 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 36/44] cpufreq: s5pv210: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 38/44] cpufreq: sh: " Viresh Kumar
                   ` (7 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/sc520_freq.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c
index bb9c0de..8556225 100644
--- a/drivers/cpufreq/sc520_freq.c
+++ b/drivers/cpufreq/sc520_freq.c
@@ -78,11 +78,6 @@ static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy,
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
 };
 
-static int sc520_freq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, &sc520_freq_table[0]);
-}
-
 static int sc520_freq_target(struct cpufreq_policy *policy,
 			    unsigned int target_freq,
 			    unsigned int relation)
@@ -120,27 +115,14 @@ static int sc520_freq_cpu_init(struct cpufreq_policy *policy)
 }
 
 
-static int sc520_freq_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-
-static struct freq_attr *sc520_freq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
-
 static struct cpufreq_driver sc520_freq_driver = {
 	.get	= sc520_freq_get_cpu_frequency,
-	.verify	= sc520_freq_verify,
+	.verify	= cpufreq_generic_frequency_table_verify,
 	.target	= sc520_freq_target,
 	.init	= sc520_freq_cpu_init,
-	.exit	= sc520_freq_cpu_exit,
+	.exit	= cpufreq_generic_exit,
 	.name	= "sc520_freq",
-	.attr	= sc520_freq_attr,
+	.attr	= cpufreq_generic_attr,
 };
 
 static const struct x86_cpu_id sc520_ids[] = {
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 38/44] cpufreq: sh: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (36 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 37/44] cpufreq: sc520: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 39/44] cpufreq: sparc: " Viresh Kumar
                   ` (6 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Paul Mundt, linux-sh

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Paul Mundt <lethal@linux-sh.org>
Cc: linux-sh@vger.kernel.org
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/sh-cpufreq.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
index 1362e88..91c6446 100644
--- a/drivers/cpufreq/sh-cpufreq.c
+++ b/drivers/cpufreq/sh-cpufreq.c
@@ -154,11 +154,6 @@ static int sh_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static struct freq_attr *sh_freq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver sh_cpufreq_driver = {
 	.name		= "sh",
 	.get		= sh_cpufreq_get,
@@ -166,7 +161,7 @@ static struct cpufreq_driver sh_cpufreq_driver = {
 	.verify		= sh_cpufreq_verify,
 	.init		= sh_cpufreq_cpu_init,
 	.exit		= sh_cpufreq_cpu_exit,
-	.attr		= sh_freq_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static int __init sh_cpufreq_module_init(void)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 39/44] cpufreq: sparc: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (37 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 38/44] cpufreq: sh: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 40/44] cpufreq: spear: " Viresh Kumar
                   ` (5 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, David S. Miller, sparclinux

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: David S. Miller <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/sparc-us2e-cpufreq.c | 8 +-------
 drivers/cpufreq/sparc-us3-cpufreq.c  | 8 +-------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index 8db0c18..291688c 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -295,12 +295,6 @@ static int us2e_freq_target(struct cpufreq_policy *policy,
 	return 0;
 }
 
-static int us2e_freq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy,
-					      &us2e_freq_table[policy->cpu].table[0]);
-}
-
 static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
 {
 	unsigned int cpu = policy->cpu;
@@ -363,7 +357,7 @@ static int __init us2e_freq_init(void)
 			goto err_out;
 
 		driver->init = us2e_freq_cpu_init;
-		driver->verify = us2e_freq_verify;
+		driver->verify = cpufreq_generic_frequency_table_verify;
 		driver->target = us2e_freq_target;
 		driver->get = us2e_freq_get;
 		driver->exit = us2e_freq_cpu_exit;
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index 120a2df..9b3dbd3 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -156,12 +156,6 @@ static int us3_freq_target(struct cpufreq_policy *policy,
 	return 0;
 }
 
-static int us3_freq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy,
-					      &us3_freq_table[policy->cpu].table[0]);
-}
-
 static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
 {
 	unsigned int cpu = policy->cpu;
@@ -224,7 +218,7 @@ static int __init us3_freq_init(void)
 			goto err_out;
 
 		driver->init = us3_freq_cpu_init;
-		driver->verify = us3_freq_verify;
+		driver->verify = cpufreq_generic_frequency_table_verify;
 		driver->target = us3_freq_target;
 		driver->get = us3_freq_get;
 		driver->exit = us3_freq_cpu_exit;
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 40/44] cpufreq: spear: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (38 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 39/44] cpufreq: sparc: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 41/44] cpufreq: speedstep: " Viresh Kumar
                   ` (4 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, spear-devel

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: spear-devel@list.st.com
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/spear-cpufreq.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 1d619dd..d31accc 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -30,11 +30,6 @@ static struct {
 	u32 cnt;
 } spear_cpufreq;
 
-static int spear_cpufreq_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, spear_cpufreq.freq_tbl);
-}
-
 static unsigned int spear_cpufreq_get(unsigned int cpu)
 {
 	return clk_get_rate(spear_cpufreq.clk) / 1000;
@@ -192,26 +187,15 @@ static int spear_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int spear_cpufreq_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static struct freq_attr *spear_cpufreq_attr[] = {
-	 &cpufreq_freq_attr_scaling_available_freqs,
-	 NULL,
-};
-
 static struct cpufreq_driver spear_cpufreq_driver = {
 	.name		= "cpufreq-spear",
 	.flags		= CPUFREQ_STICKY,
-	.verify		= spear_cpufreq_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= spear_cpufreq_target,
 	.get		= spear_cpufreq_get,
 	.init		= spear_cpufreq_init,
-	.exit		= spear_cpufreq_exit,
-	.attr		= spear_cpufreq_attr,
+	.exit		= cpufreq_generic_exit,
+	.attr		= cpufreq_generic_attr,
 };
 
 static int spear_cpufreq_driver_init(void)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 41/44] cpufreq: speedstep: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (39 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 40/44] cpufreq: spear: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 42/44] cpufreq: tegra: " Viresh Kumar
                   ` (3 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, David S. Miller

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/speedstep-centrino.c | 22 ++--------------------
 drivers/cpufreq/speedstep-ich.c      | 30 +++---------------------------
 drivers/cpufreq/speedstep-smi.c      | 30 +++---------------------------
 3 files changed, 8 insertions(+), 74 deletions(-)

diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
index f180561..c7c14ae 100644
--- a/drivers/cpufreq/speedstep-centrino.c
+++ b/drivers/cpufreq/speedstep-centrino.c
@@ -420,19 +420,6 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
 }
 
 /**
- * centrino_verify - verifies a new CPUFreq policy
- * @policy: new policy
- *
- * Limit must be within this model's frequency range at least one
- * border included.
- */
-static int centrino_verify (struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy,
-			per_cpu(centrino_model, policy->cpu)->op_points);
-}
-
-/**
  * centrino_setpolicy - set a new CPUFreq policy
  * @policy: new policy
  * @target_freq: the target frequency
@@ -553,20 +540,15 @@ out:
 	return retval;
 }
 
-static struct freq_attr* centrino_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver centrino_driver = {
 	.name		= "centrino", /* should be speedstep-centrino,
 					 but there's a 16 char limit */
 	.init		= centrino_cpu_init,
 	.exit		= centrino_cpu_exit,
-	.verify		= centrino_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= centrino_target,
 	.get		= get_cur_freq,
-	.attr           = centrino_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 /*
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c
index 86a184e..929a4f0 100644
--- a/drivers/cpufreq/speedstep-ich.c
+++ b/drivers/cpufreq/speedstep-ich.c
@@ -289,18 +289,6 @@ static int speedstep_target(struct cpufreq_policy *policy,
 }
 
 
-/**
- * speedstep_verify - verifies a new CPUFreq policy
- * @policy: new policy
- *
- * Limit must be within speedstep_low_freq and speedstep_high_freq, with
- * at least one border included.
- */
-static int speedstep_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]);
-}
-
 struct get_freqs {
 	struct cpufreq_policy *policy;
 	int ret;
@@ -352,26 +340,14 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
 }
 
 
-static int speedstep_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
-static struct freq_attr *speedstep_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
-
 static struct cpufreq_driver speedstep_driver = {
 	.name	= "speedstep-ich",
-	.verify	= speedstep_verify,
+	.verify	= cpufreq_generic_frequency_table_verify,
 	.target	= speedstep_target,
 	.init	= speedstep_cpu_init,
-	.exit	= speedstep_cpu_exit,
+	.exit	= cpufreq_generic_exit,
 	.get	= speedstep_get,
-	.attr	= speedstep_attr,
+	.attr	= cpufreq_generic_attr,
 };
 
 static const struct x86_cpu_id ss_smi_ids[] = {
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
index f4d0318..b3dfba0 100644
--- a/drivers/cpufreq/speedstep-smi.c
+++ b/drivers/cpufreq/speedstep-smi.c
@@ -264,19 +264,6 @@ static int speedstep_target(struct cpufreq_policy *policy,
 }
 
 
-/**
- * speedstep_verify - verifies a new CPUFreq policy
- * @policy: new policy
- *
- * Limit must be within speedstep_low_freq and speedstep_high_freq, with
- * at least one border included.
- */
-static int speedstep_verify(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]);
-}
-
-
 static int speedstep_cpu_init(struct cpufreq_policy *policy)
 {
 	int result;
@@ -332,12 +319,6 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, speedstep_freqs);
 }
 
-static int speedstep_cpu_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_frequency_table_put_attr(policy->cpu);
-	return 0;
-}
-
 static unsigned int speedstep_get(unsigned int cpu)
 {
 	if (cpu)
@@ -356,20 +337,15 @@ static int speedstep_resume(struct cpufreq_policy *policy)
 	return result;
 }
 
-static struct freq_attr *speedstep_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver speedstep_driver = {
 	.name		= "speedstep-smi",
-	.verify		= speedstep_verify,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= speedstep_target,
 	.init		= speedstep_cpu_init,
-	.exit		= speedstep_cpu_exit,
+	.exit		= cpufreq_generic_exit,
 	.get		= speedstep_get,
 	.resume		= speedstep_resume,
-	.attr		= speedstep_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static const struct x86_cpu_id ss_smi_ids[] = {
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 42/44] cpufreq: tegra: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (40 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 41/44] cpufreq: speedstep: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 43/44] cpufreq: unicore2: " Viresh Kumar
                   ` (2 subsequent siblings)
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Stephen Warren

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/tegra-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index faf1ce5..affb294 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -51,11 +51,6 @@ static unsigned long target_cpu_speed[NUM_CPUS];
 static DEFINE_MUTEX(tegra_cpu_lock);
 static bool is_suspended;
 
-static int tegra_verify_speed(struct cpufreq_policy *policy)
-{
-	return cpufreq_frequency_table_verify(policy, freq_table);
-}
-
 static unsigned int tegra_getspeed(unsigned int cpu)
 {
 	unsigned long rate;
@@ -237,19 +232,14 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static struct freq_attr *tegra_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver tegra_cpufreq_driver = {
-	.verify		= tegra_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= tegra_target,
 	.get		= tegra_getspeed,
 	.init		= tegra_cpu_init,
 	.exit		= tegra_cpu_exit,
 	.name		= "tegra",
-	.attr		= tegra_cpufreq_attr,
+	.attr		= cpufreq_generic_attr,
 };
 
 static int __init tegra_cpufreq_init(void)
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 43/44] cpufreq: unicore2: Use generic cpufreq routines
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (41 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 42/44] cpufreq: tegra: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-12  6:08   ` Viresh Kumar
  2013-08-10  6:44 ` [PATCH 44/44] cpufreq: pass suitable index instead of freq to cpufreq_driver->target() Viresh Kumar
  2013-08-10  7:46 ` [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
  44 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Guan Xuetao

Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
and .attr. So its better if we have generic routines for them which can be used
by cpufreq drivers then.

This patch uses these generic routines for this driver.

Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/unicore2-cpufreq.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c
index 12fc904..b9f693c 100644
--- a/drivers/cpufreq/unicore2-cpufreq.c
+++ b/drivers/cpufreq/unicore2-cpufreq.c
@@ -21,20 +21,6 @@
 
 static struct cpufreq_driver ucv2_driver;
 
-/* make sure that only the "userspace" governor is run
- * -- anything else wouldn't make sense on this platform, anyway.
- */
-int ucv2_verify_speed(struct cpufreq_policy *policy)
-{
-	if (policy->cpu)
-		return -EINVAL;
-
-	cpufreq_verify_within_limits(policy,
-			policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
-
-	return 0;
-}
-
 static unsigned int ucv2_getspeed(unsigned int cpu)
 {
 	struct clk *mclk = clk_get(NULL, "MAIN_CLK");
@@ -77,7 +63,7 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
 
 static struct cpufreq_driver ucv2_driver = {
 	.flags		= CPUFREQ_STICKY,
-	.verify		= ucv2_verify_speed,
+	.verify		= cpufreq_generic_frequency_table_verify,
 	.target		= ucv2_target,
 	.get		= ucv2_getspeed,
 	.init		= ucv2_cpu_init,
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 44/44] cpufreq: pass suitable index instead of freq to cpufreq_driver->target()
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (42 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 43/44] cpufreq: unicore2: " Viresh Kumar
@ 2013-08-10  6:44 ` Viresh Kumar
  2013-08-10  7:45   ` Viresh Kumar
  2013-08-12  6:50   ` Viresh Kumar
  2013-08-10  7:46 ` [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
  44 siblings, 2 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  6:44 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

This tries to remove code redundancy from cpufreq driver by moving some common
part of them to the core. Each driver calls cpufreq_frequency_table_target() to
get a suitable index for a target frequency and then works on it. Its better to
do this at core level before calling cpufreq driver and hence passing "index"
instead of "target_freq and relation" to cpufreq_driver->target() routine.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/acpi-cpufreq.c         | 19 +++++--------------
 drivers/cpufreq/arm_big_little.c       | 15 ++++-----------
 drivers/cpufreq/blackfin-cpufreq.c     | 14 +++-----------
 drivers/cpufreq/cpufreq-cpu0.c         | 14 +-------------
 drivers/cpufreq/cpufreq.c              | 30 +++++++++++++++++++++++++++---
 drivers/cpufreq/cris-artpec3-cpufreq.c | 18 +++---------------
 drivers/cpufreq/cris-etraxfs-cpufreq.c | 16 ++--------------
 drivers/cpufreq/davinci-cpufreq.c      | 15 +++------------
 drivers/cpufreq/dbx500-cpufreq.c       | 13 ++-----------
 drivers/cpufreq/e_powersaver.c         | 13 ++-----------
 drivers/cpufreq/elanfreq.c             | 21 +++------------------
 drivers/cpufreq/exynos-cpufreq.c       | 17 ++---------------
 drivers/cpufreq/exynos5440-cpufreq.c   |  9 ++-------
 drivers/cpufreq/ia64-acpi-cpufreq.c    | 15 ++-------------
 drivers/cpufreq/imx6q-cpufreq.c        | 16 ++--------------
 drivers/cpufreq/kirkwood-cpufreq.c     | 18 +++---------------
 drivers/cpufreq/longhaul.c             | 11 +----------
 drivers/cpufreq/loongson2_cpufreq.c    | 18 ++++--------------
 drivers/cpufreq/maple-cpufreq.c        | 14 +++-----------
 drivers/cpufreq/omap-cpufreq.c         | 27 ++-------------------------
 drivers/cpufreq/p4-clockmod.c          | 14 +++-----------
 drivers/cpufreq/pasemi-cpufreq.c       |  9 +--------
 drivers/cpufreq/pmac32-cpufreq.c       |  9 ++-------
 drivers/cpufreq/pmac64-cpufreq.c       | 14 +++-----------
 drivers/cpufreq/powernow-k6.c          | 10 ++--------
 drivers/cpufreq/powernow-k7.c          | 22 +++++-----------------
 drivers/cpufreq/powernow-k8.c          | 16 ++++++----------
 drivers/cpufreq/ppc-corenet-cpufreq.c  | 13 +++----------
 drivers/cpufreq/ppc_cbe_cpufreq.c      |  9 +--------
 drivers/cpufreq/pxa2xx-cpufreq.c       |  9 +--------
 drivers/cpufreq/pxa3xx-cpufreq.c       | 13 ++-----------
 drivers/cpufreq/s3c2416-cpufreq.c      | 29 +++++++++++++----------------
 drivers/cpufreq/s3c24xx-cpufreq.c      | 28 ++++------------------------
 drivers/cpufreq/s3c64xx-cpufreq.c      | 15 +++------------
 drivers/cpufreq/s5pv210-cpufreq.c      | 14 ++------------
 drivers/cpufreq/sc520_freq.c           | 19 +++----------------
 drivers/cpufreq/sparc-us2e-cpufreq.c   | 11 ++---------
 drivers/cpufreq/sparc-us3-cpufreq.c    | 13 ++-----------
 drivers/cpufreq/spear-cpufreq.c        | 10 +++-------
 drivers/cpufreq/speedstep-centrino.c   | 20 ++++++--------------
 drivers/cpufreq/speedstep-ich.c        | 18 +++++-------------
 drivers/cpufreq/speedstep-smi.c        | 16 ++++------------
 drivers/cpufreq/tegra-cpufreq.c        |  8 ++------
 include/linux/cpufreq.h                |  2 +-
 44 files changed, 155 insertions(+), 519 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index cd5badb..a1adbb59 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -424,17 +424,17 @@ static unsigned int check_freqs(const struct cpumask *mask, unsigned int freq,
 }
 
 static int acpi_cpufreq_target(struct cpufreq_policy *policy,
-			       unsigned int target_freq, unsigned int relation)
+			       unsigned int index, unsigned int relation)
 {
 	struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);
 	struct acpi_processor_performance *perf;
 	struct cpufreq_freqs freqs;
 	struct drv_cmd cmd;
-	unsigned int next_state = 0; /* Index into freq_table */
 	unsigned int next_perf_state = 0; /* Index into perf table */
 	int result = 0;
 
-	pr_debug("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu);
+	pr_debug("acpi_cpufreq_target %d (%d)\n",
+			data->freq_table[index].frequency, policy->cpu);
 
 	if (unlikely(data == NULL ||
 	     data->acpi_data == NULL || data->freq_table == NULL)) {
@@ -442,16 +442,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
 	}
 
 	perf = data->acpi_data;
-	result = cpufreq_frequency_table_target(policy,
-						data->freq_table,
-						target_freq,
-						relation, &next_state);
-	if (unlikely(result)) {
-		result = -ENODEV;
-		goto out;
-	}
-
-	next_perf_state = data->freq_table[next_state].driver_data;
+	next_perf_state = data->freq_table[index].driver_data;
 	if (perf->state == next_perf_state) {
 		if (unlikely(data->resume)) {
 			pr_debug("Called after resume, resetting to P%d\n",
@@ -493,7 +484,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
 		cmd.mask = cpumask_of(policy->cpu);
 
 	freqs.old = perf->states[perf->state].core_frequency * 1000;
-	freqs.new = data->freq_table[next_state].frequency;
+	freqs.new = data->freq_table[index].frequency;
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
 	drv_write(&cmd);
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 7e92586..7ecb829 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -49,28 +49,21 @@ static unsigned int bL_cpufreq_get(unsigned int cpu)
 
 /* Set clock frequency */
 static int bL_cpufreq_set_target(struct cpufreq_policy *policy,
-		unsigned int target_freq, unsigned int relation)
+		unsigned int index, unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
-	u32 cpu = policy->cpu, freq_tab_idx, cur_cluster;
+	u32 cpu = policy->cpu, cur_cluster;
 	int ret = 0;
 
 	cur_cluster = cpu_to_cluster(policy->cpu);
 
 	freqs.old = bL_cpufreq_get(policy->cpu);
-
-	/* Determine valid target frequency using freq_table */
-	cpufreq_frequency_table_target(policy, freq_table[cur_cluster],
-			target_freq, relation, &freq_tab_idx);
-	freqs.new = freq_table[cur_cluster][freq_tab_idx].frequency;
+	freqs.new = freq_table[cur_cluster][index].frequency;
 
 	pr_debug("%s: cpu: %d, cluster: %d, oldfreq: %d, target freq: %d, new freq: %d\n",
-			__func__, cpu, cur_cluster, freqs.old, target_freq,
+			__func__, cpu, cur_cluster, freqs.old, freqs.new,
 			freqs.new);
 
-	if (freqs.old == freqs.new)
-		return 0;
-
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
 	ret = clk_set_rate(clk[cur_cluster], freqs.new * 1000);
diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index 48888cf..133ce85 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -128,13 +128,11 @@ unsigned long cpu_set_cclk(int cpu, unsigned long new)
 #endif
 
 static int bfin_target(struct cpufreq_policy *policy,
-			unsigned int target_freq, unsigned int relation)
+			unsigned int index, unsigned int relation)
 {
 #ifndef CONFIG_BF60x
 	unsigned int plldiv;
 #endif
-	unsigned int index;
-	unsigned long cclk_hz;
 	struct cpufreq_freqs freqs;
 	static unsigned long lpj_ref;
 	static unsigned int  lpj_ref_freq;
@@ -144,17 +142,11 @@ static int bfin_target(struct cpufreq_policy *policy,
 	cycles_t cycles;
 #endif
 
-	if (cpufreq_frequency_table_target(policy, bfin_freq_table, target_freq,
-				relation, &index))
-		return -EINVAL;
-
-	cclk_hz = bfin_freq_table[index].frequency;
-
 	freqs.old = bfin_getfreq_khz(0);
-	freqs.new = cclk_hz;
+	freqs.new = bfin_freq_table[index].frequency;
 
 	pr_debug("cpufreq: changing cclk to %lu; target = %u, oldfreq = %u\n",
-			cclk_hz, target_freq, freqs.old);
+			freqs.new, bfin_freq_table[index].frequency, freqs.old);
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 #ifndef CONFIG_BF60x
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 3d24e7b..5caecd0 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -35,23 +35,14 @@ static unsigned int cpu0_get_speed(unsigned int cpu)
 }
 
 static int cpu0_set_target(struct cpufreq_policy *policy,
-			   unsigned int target_freq, unsigned int relation)
+			   unsigned int index, unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
 	struct opp *opp;
 	unsigned long volt = 0, volt_old = 0, tol = 0;
 	long freq_Hz, freq_exact;
-	unsigned int index;
 	int ret;
 
-	ret = cpufreq_frequency_table_target(policy, freq_table, target_freq,
-					     relation, &index);
-	if (ret) {
-		pr_err("failed to match target freqency %d: %d\n",
-		       target_freq, ret);
-		return ret;
-	}
-
 	freq_Hz = clk_round_rate(cpu_clk, freq_table[index].frequency * 1000);
 	if (freq_Hz < 0)
 		freq_Hz = freq_table[index].frequency * 1000;
@@ -59,9 +50,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 	freqs.new = freq_Hz / 1000;
 	freqs.old = clk_get_rate(cpu_clk) / 1000;
 
-	if (freqs.old == freqs.new)
-		return 0;
-
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
 	if (cpu_reg) {
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 06f8671..4bf023d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1628,7 +1628,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
 			    unsigned int target_freq,
 			    unsigned int relation)
 {
-	int retval = -EINVAL;
+	int retval = -EINVAL, index;
 	unsigned int old_target_freq = target_freq;
 
 	if (cpufreq_disabled())
@@ -1645,11 +1645,35 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
 	pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
 			policy->cpu, target_freq, relation, old_target_freq);
 
+	/*
+	 * This might look like a redundant call as we are checking it again
+	 * after finding index. But it is left intentionally for cases where
+	 * same freq is called again and so we can save on few function calls.
+	 */
 	if (target_freq == policy->cur)
 		return 0;
 
-	if (cpufreq_driver->target)
-		retval = cpufreq_driver->target(policy, target_freq, relation);
+	if (cpufreq_driver->target) {
+		struct cpufreq_frequency_table *freq_table;
+
+		freq_table = cpufreq_frequency_get_table(policy->cpu);
+		if (unlikely(!freq_table)) {
+			pr_err("%s: Unable to find freq_table\n", __func__);
+			return retval;
+		}
+
+		retval = cpufreq_frequency_table_target(policy, freq_table,
+				target_freq, relation, &index);
+		if (unlikely(retval)) {
+			pr_err("%s: Unable to find matching freq\n", __func__);
+			return retval;
+		}
+
+		if (freq_table[index].frequency == policy->cur)
+			return 0;
+
+		retval = cpufreq_driver->target(policy, index, relation);
+	}
 
 	return retval;
 }
diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index d26f4e4..f1fc446 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -27,8 +27,9 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)
 	return clk_ctrl.pll ? 200000 : 6000;
 }
 
-static void cris_freq_set_cpu_state(struct cpufreq_policy *policy,
-		unsigned int state)
+static int cris_freq_target(struct cpufreq_policy *policy,
+			    unsigned int state,
+			    unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
 	reg_clkgen_rw_clk_ctrl clk_ctrl;
@@ -52,19 +53,6 @@ static void cris_freq_set_cpu_state(struct cpufreq_policy *policy,
 	local_irq_enable();
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-};
-
-static int cris_freq_target(struct cpufreq_policy *policy,
-			    unsigned int target_freq,
-			    unsigned int relation)
-{
-	unsigned int newstate = 0;
-
-	if (cpufreq_frequency_table_target(policy, cris_freq_table,
-			target_freq, relation, &newstate))
-		return -EINVAL;
-
-	cris_freq_set_cpu_state(policy, newstate);
 
 	return 0;
 }
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index d384e63..53f77a4 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -27,8 +27,8 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)
 	return clk_ctrl.pll ? 200000 : 6000;
 }
 
-static void cris_freq_set_cpu_state(struct cpufreq_policy *policy,
-		unsigned int state)
+static int cris_freq_target(struct cpufreq_policy *policy, unsigned int state,
+			    unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
 	reg_config_rw_clk_ctrl clk_ctrl;
@@ -52,18 +52,6 @@ static void cris_freq_set_cpu_state(struct cpufreq_policy *policy,
 	local_irq_enable();
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-};
-
-static int cris_freq_target(struct cpufreq_policy *policy,
-			    unsigned int target_freq, unsigned int relation)
-{
-	unsigned int newstate = 0;
-
-	if (cpufreq_frequency_table_target
-	    (policy, cris_freq_table, target_freq, relation, &newstate))
-		return -EINVAL;
-
-	cris_freq_set_cpu_state(policy, newstate);
 
 	return 0;
 }
diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index 33e9460..b08fe3f 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -68,28 +68,19 @@ static unsigned int davinci_getspeed(unsigned int cpu)
 	return clk_get_rate(cpufreq.armclk) / 1000;
 }
 
-static int davinci_target(struct cpufreq_policy *policy,
-				unsigned int target_freq, unsigned int relation)
+static int davinci_target(struct cpufreq_policy *policy, unsigned int idx,
+				unsigned int relation)
 {
 	int ret = 0;
-	unsigned int idx;
 	struct cpufreq_freqs freqs;
 	struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data;
 	struct clk *armclk = cpufreq.armclk;
 
 	freqs.old = davinci_getspeed(0);
-	freqs.new = clk_round_rate(armclk, target_freq * 1000) / 1000;
-
-	if (freqs.old == freqs.new)
-		return ret;
+	freqs.new = pdata->freq_table[idx].frequency;
 
 	dev_dbg(cpufreq.dev, "transition: %u --> %u\n", freqs.old, freqs.new);
 
-	ret = cpufreq_frequency_table_target(policy, pdata->freq_table,
-						freqs.new, relation, &idx);
-	if (ret)
-		return -EINVAL;
-
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
 	/* if moving to higher frequency, up the voltage beforehand */
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index 7e2f9c0..5d46a5e 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -20,23 +20,14 @@ static struct cpufreq_frequency_table *freq_table;
 static struct clk *armss_clk;
 
 static int dbx500_cpufreq_target(struct cpufreq_policy *policy,
-				unsigned int target_freq,
+				unsigned int index,
 				unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
-	unsigned int idx;
 	int ret;
 
-	/* Lookup the next frequency */
-	if (cpufreq_frequency_table_target(policy, freq_table, target_freq,
-					relation, &idx))
-		return -EINVAL;
-
 	freqs.old = policy->cur;
-	freqs.new = freq_table[idx].frequency;
-
-	if (freqs.old == freqs.new)
-		return 0;
+	freqs.new = freq_table[index].frequency;
 
 	/* pre-change notification */
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c
index a8cbbd0..460e4ed 100644
--- a/drivers/cpufreq/e_powersaver.c
+++ b/drivers/cpufreq/e_powersaver.c
@@ -169,11 +169,10 @@ postchange:
 }
 
 static int eps_target(struct cpufreq_policy *policy,
-			       unsigned int target_freq,
+			       unsigned int index,
 			       unsigned int relation)
 {
 	struct eps_cpu_data *centaur;
-	unsigned int newstate = 0;
 	unsigned int cpu = policy->cpu;
 	unsigned int dest_state;
 	int ret;
@@ -182,16 +181,8 @@ static int eps_target(struct cpufreq_policy *policy,
 		return -ENODEV;
 	centaur = eps_cpu[cpu];
 
-	if (unlikely(cpufreq_frequency_table_target(policy,
-			&eps_cpu[cpu]->freq_table[0],
-			target_freq,
-			relation,
-			&newstate))) {
-		return -EINVAL;
-	}
-
 	/* Make frequency transition */
-	dest_state = centaur->freq_table[newstate].driver_data & 0xffff;
+	dest_state = centaur->freq_table[index].driver_data & 0xffff;
 	ret = eps_set_state(centaur, policy, dest_state);
 	if (ret)
 		printk(KERN_ERR "eps: Timeout!\n");
diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c
index fe7053c..a50a700 100644
--- a/drivers/cpufreq/elanfreq.c
+++ b/drivers/cpufreq/elanfreq.c
@@ -117,8 +117,9 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
  *	There is no return value.
  */
 
-static void elanfreq_set_cpu_state(struct cpufreq_policy *policy,
-		unsigned int state)
+static int elanfreq_set_cpu_state(struct cpufreq_policy *policy,
+			    unsigned int state,
+			    unsigned int relation)
 {
 	struct cpufreq_freqs    freqs;
 
@@ -162,25 +163,9 @@ static void elanfreq_set_cpu_state(struct cpufreq_policy *policy,
 	local_irq_enable();
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-};
-
-
-static int elanfreq_target(struct cpufreq_policy *policy,
-			    unsigned int target_freq,
-			    unsigned int relation)
-{
-	unsigned int newstate = 0;
-
-	if (cpufreq_frequency_table_target(policy, &elanfreq_table[0],
-				target_freq, relation, &newstate))
-		return -EINVAL;
-
-	elanfreq_set_cpu_state(policy, newstate);
 
 	return 0;
 }
-
-
 /*
  *	Module init and exit code
  */
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 7663a96..5105bcd 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -65,9 +65,6 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
 	freqs.old = policy->cur;
 	freqs.new = target_freq;
 
-	if (freqs.new == freqs.old)
-		goto out;
-
 	/*
 	 * The policy max have been changed so that we cannot get proper
 	 * old_index with cpufreq_frequency_table_target(). Thus, ignore
@@ -152,12 +149,10 @@ out:
 }
 
 static int exynos_target(struct cpufreq_policy *policy,
-			  unsigned int target_freq,
+			  unsigned int index,
 			  unsigned int relation)
 {
 	struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
-	unsigned int index;
-	unsigned int new_freq;
 	int ret = 0;
 
 	mutex_lock(&cpufreq_lock);
@@ -165,15 +160,7 @@ static int exynos_target(struct cpufreq_policy *policy,
 	if (frequency_locked)
 		goto out;
 
-	if (cpufreq_frequency_table_target(policy, freq_table,
-					   target_freq, relation, &index)) {
-		ret = -EINVAL;
-		goto out;
-	}
-
-	new_freq = freq_table[index].frequency;
-
-	ret = exynos_cpufreq_scale(new_freq);
+	ret = exynos_cpufreq_scale(freq_table[index].frequency);
 
 out:
 	mutex_unlock(&cpufreq_lock);
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index f139b3b..359ddd8 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -215,20 +215,15 @@ static unsigned int exynos_getspeed(unsigned int cpu)
 }
 
 static int exynos_target(struct cpufreq_policy *policy,
-			  unsigned int target_freq,
+			  unsigned int index,
 			  unsigned int relation)
 {
-	unsigned int index, tmp;
+	unsigned int tmp;
 	int ret = 0, i;
 	struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table;
 
 	mutex_lock(&cpufreq_lock);
 
-	ret = cpufreq_frequency_table_target(policy, freq_table,
-					   target_freq, relation, &index);
-	if (ret)
-		goto out;
-
 	freqs.old = dvfs_info->cur_frequency;
 	freqs.new = freq_table[index].frequency;
 
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
index b958bdb..d2bce53 100644
--- a/drivers/cpufreq/ia64-acpi-cpufreq.c
+++ b/drivers/cpufreq/ia64-acpi-cpufreq.c
@@ -227,23 +227,12 @@ acpi_cpufreq_get (
 static int
 acpi_cpufreq_target (
 	struct cpufreq_policy   *policy,
-	unsigned int target_freq,
+	unsigned int index,
 	unsigned int relation)
 {
-	struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
-	unsigned int next_state = 0;
-	unsigned int result = 0;
-
 	pr_debug("acpi_cpufreq_setpolicy\n");
 
-	result = cpufreq_frequency_table_target(policy,
-			data->freq_table, target_freq, relation, &next_state);
-	if (result)
-		return (result);
-
-	result = processor_set_freq(data, policy, next_state);
-
-	return (result);
+	return processor_set_freq(acpi_io_data[policy->cpu], policy, index);
 }
 
 
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 81d1727..3076e3c 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -39,30 +39,18 @@ static unsigned int imx6q_get_speed(unsigned int cpu)
 	return clk_get_rate(arm_clk) / 1000;
 }
 
-static int imx6q_set_target(struct cpufreq_policy *policy,
-			    unsigned int target_freq, unsigned int relation)
+static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index,
+			    unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
 	struct opp *opp;
 	unsigned long freq_hz, volt, volt_old;
-	unsigned int index;
 	int ret;
 
-	ret = cpufreq_frequency_table_target(policy, freq_table, target_freq,
-					     relation, &index);
-	if (ret) {
-		dev_err(cpu_dev, "failed to match target frequency %d: %d\n",
-			target_freq, ret);
-		return ret;
-	}
-
 	freqs.new = freq_table[index].frequency;
 	freq_hz = freqs.new * 1000;
 	freqs.old = clk_get_rate(arm_clk) / 1000;
 
-	if (freqs.old == freqs.new)
-		return 0;
-
 	rcu_read_lock();
 	opp = opp_find_freq_ceil(cpu_dev, &freq_hz);
 	if (IS_ERR(opp)) {
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index 9018c4d..a38b0f9 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -55,8 +55,9 @@ static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)
 	return kirkwood_freq_table[0].frequency;
 }
 
-static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy,
-		unsigned int index)
+static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
+			    unsigned int index,
+			    unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
 	unsigned int state = kirkwood_freq_table[index].driver_data;
@@ -100,19 +101,6 @@ static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy,
 		local_irq_enable();
 	}
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-};
-
-static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
-			    unsigned int target_freq,
-			    unsigned int relation)
-{
-	unsigned int index = 0;
-
-	if (cpufreq_frequency_table_target(policy, kirkwood_freq_table,
-				target_freq, relation, &index))
-		return -EINVAL;
-
-	kirkwood_cpufreq_set_cpu_state(policy, index);
 
 	return 0;
 }
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index 57d7b02..926999a 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -626,21 +626,12 @@ static void longhaul_setup_voltagescaling(void)
 
 
 static int longhaul_target(struct cpufreq_policy *policy,
-			    unsigned int target_freq, unsigned int relation)
+			    unsigned int table_index, unsigned int relation)
 {
-	unsigned int table_index = 0;
 	unsigned int i;
 	unsigned int dir = 0;
 	u8 vid, current_vid;
 
-	if (cpufreq_frequency_table_target(policy, longhaul_table, target_freq,
-				relation, &table_index))
-		return -EINVAL;
-
-	/* Don't set same frequency again */
-	if (longhaul_index == table_index)
-		return 0;
-
 	if (!can_scale_voltage)
 		longhaul_setstate(policy, table_index);
 	else {
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index ed7fbe2..3e9480c 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -53,11 +53,10 @@ static unsigned int loongson2_cpufreq_get(unsigned int cpu)
  * Here we notify other drivers of the proposed change and the final change.
  */
 static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
-				     unsigned int target_freq,
+				     unsigned int index,
 				     unsigned int relation)
 {
 	unsigned int cpu = policy->cpu;
-	unsigned int newstate = 0;
 	cpumask_t cpus_allowed;
 	struct cpufreq_freqs freqs;
 	unsigned int freq;
@@ -65,26 +64,17 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
 	cpus_allowed = current->cpus_allowed;
 	set_cpus_allowed_ptr(current, cpumask_of(cpu));
 
-	if (cpufreq_frequency_table_target
-	    (policy, &loongson2_clockmod_table[0], target_freq, relation,
-	     &newstate))
-		return -EINVAL;
-
 	freq =
 	    ((cpu_clock_freq / 1000) *
-	     loongson2_clockmod_table[newstate].driver_data) / 8;
-	if (freq < policy->min || freq > policy->max)
-		return -EINVAL;
+	     loongson2_clockmod_table[index].driver_data) / 8;
 
-	pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000);
+	pr_debug("cpufreq: requested frequency %u Hz\n",
+			loongson2_clockmod_table[index].frequency * 1000);
 
 	freqs.old = loongson2_cpufreq_get(cpu);
 	freqs.new = freq;
 	freqs.flags = 0;
 
-	if (freqs.new == freqs.old)
-		return 0;
-
 	/* notifiers */
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index 7720670..384d83b 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -131,26 +131,18 @@ static int maple_scom_query_freq(void)
  */
 
 static int maple_cpufreq_target(struct cpufreq_policy *policy,
-	unsigned int target_freq, unsigned int relation)
+	unsigned int index, unsigned int relation)
 {
-	unsigned int newstate = 0;
 	struct cpufreq_freqs freqs;
 	int rc;
 
-	if (cpufreq_frequency_table_target(policy, maple_cpu_freqs,
-			target_freq, relation, &newstate))
-		return -EINVAL;
-
-	if (maple_pmode_cur == newstate)
-		return 0;
-
 	mutex_lock(&maple_switch_mutex);
 
 	freqs.old = maple_cpu_freqs[maple_pmode_cur].frequency;
-	freqs.new = maple_cpu_freqs[newstate].frequency;
+	freqs.new = maple_cpu_freqs[index].frequency;
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-	rc = maple_scom_switch_freq(newstate);
+	rc = maple_scom_switch_freq(index);
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
 
 	mutex_unlock(&maple_switch_mutex);
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 48020b5..4008494 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -52,39 +52,16 @@ static unsigned int omap_getspeed(unsigned int cpu)
 }
 
 static int omap_target(struct cpufreq_policy *policy,
-		       unsigned int target_freq,
+		       unsigned int index,
 		       unsigned int relation)
 {
-	unsigned int i;
 	int r, ret = 0;
 	struct cpufreq_freqs freqs;
 	struct opp *opp;
 	unsigned long freq, volt = 0, volt_old = 0, tol = 0;
 
-	if (!freq_table) {
-		dev_err(mpu_dev, "%s: cpu%d: no freq table!\n", __func__,
-				policy->cpu);
-		return -EINVAL;
-	}
-
-	ret = cpufreq_frequency_table_target(policy, freq_table, target_freq,
-			relation, &i);
-	if (ret) {
-		dev_dbg(mpu_dev, "%s: cpu%d: no freq match for %d(ret=%d)\n",
-			__func__, policy->cpu, target_freq, ret);
-		return ret;
-	}
-	freqs.new = freq_table[i].frequency;
-	if (!freqs.new) {
-		dev_err(mpu_dev, "%s: cpu%d: no match for freq %d\n", __func__,
-			policy->cpu, target_freq);
-		return -EINVAL;
-	}
-
 	freqs.old = omap_getspeed(policy->cpu);
-
-	if (freqs.old == freqs.new && policy->cur == freqs.new)
-		return ret;
+	freqs.new = freq_table[index].frequency;
 
 	freq = freqs.new * 1000;
 	ret = clk_round_rate(mpu_clk, freq);
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 4fe6d4c..06383c4 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -106,22 +106,14 @@ static struct cpufreq_frequency_table p4clockmod_table[] = {
 
 
 static int cpufreq_p4_target(struct cpufreq_policy *policy,
-			     unsigned int target_freq,
+			     unsigned int index,
 			     unsigned int relation)
 {
-	unsigned int    newstate = DC_RESV;
 	struct cpufreq_freqs freqs;
 	int i;
 
-	if (cpufreq_frequency_table_target(policy, &p4clockmod_table[0],
-				target_freq, relation, &newstate))
-		return -EINVAL;
-
 	freqs.old = cpufreq_p4_get(policy->cpu);
-	freqs.new = stock_freq * p4clockmod_table[newstate].driver_data / 8;
-
-	if (freqs.new == freqs.old)
-		return 0;
+	freqs.new = stock_freq * p4clockmod_table[index].driver_data / 8;
 
 	/* notifiers */
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
@@ -131,7 +123,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
 	 * Developer's Manual, Volume 3
 	 */
 	for_each_cpu(i, policy->cpus)
-		cpufreq_p4_setdc(i, p4clockmod_table[newstate].driver_data);
+		cpufreq_p4_setdc(i, p4clockmod_table[index].driver_data);
 
 	/* notifiers */
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 16f2508..5977d8c 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -247,19 +247,12 @@ static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 }
 
 static int pas_cpufreq_target(struct cpufreq_policy *policy,
-			      unsigned int target_freq,
+			      unsigned int pas_astate_new,
 			      unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
-	int pas_astate_new;
 	int i;
 
-	cpufreq_frequency_table_target(policy,
-				       pas_freqs,
-				       target_freq,
-				       relation,
-				       &pas_astate_new);
-
 	freqs.old = policy->cur;
 	freqs.new = pas_freqs[pas_astate_new].frequency;
 
diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index 3f8efd2..17bc3da 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -373,17 +373,12 @@ static unsigned int pmac_cpufreq_get_speed(unsigned int cpu)
 }
 
 static int pmac_cpufreq_target(	struct cpufreq_policy *policy,
-					unsigned int target_freq,
+					unsigned int index,
 					unsigned int relation)
 {
-	unsigned int    newstate = 0;
 	int		rc;
 
-	if (cpufreq_frequency_table_target(policy, pmac_cpu_freqs,
-			target_freq, relation, &newstate))
-		return -EINVAL;
-
-	rc = do_set_cpu_speed(policy, newstate, 1);
+	rc = do_set_cpu_speed(policy, index, 1);
 
 	ppc_proc_freq = cur_freq * 1000ul;
 	return rc;
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index 0eb9313..6a9c850 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -312,26 +312,18 @@ static int g5_pfunc_query_freq(void)
  */
 
 static int g5_cpufreq_target(struct cpufreq_policy *policy,
-	unsigned int target_freq, unsigned int relation)
+	unsigned int index, unsigned int relation)
 {
-	unsigned int newstate = 0;
 	struct cpufreq_freqs freqs;
 	int rc;
 
-	if (cpufreq_frequency_table_target(policy, g5_cpu_freqs,
-			target_freq, relation, &newstate))
-		return -EINVAL;
-
-	if (g5_pmode_cur == newstate)
-		return 0;
-
 	mutex_lock(&g5_switch_mutex);
 
 	freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency;
-	freqs.new = g5_cpu_freqs[newstate].frequency;
+	freqs.new = g5_cpu_freqs[index].frequency;
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-	rc = g5_switch_freq(newstate);
+	rc = g5_switch_freq(index);
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
 
 	mutex_unlock(&g5_switch_mutex);
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index ff05d28..984689e 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -114,16 +114,10 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy,
  * sets a new CPUFreq policy
  */
 static int powernow_k6_target(struct cpufreq_policy *policy,
-			       unsigned int target_freq,
+			       unsigned int index,
 			       unsigned int relation)
 {
-	unsigned int newstate = 0;
-
-	if (cpufreq_frequency_table_target(policy, &clock_ratio[0],
-				target_freq, relation, &newstate))
-		return -EINVAL;
-
-	powernow_k6_set_state(policy, newstate);
+	powernow_k6_set_state(policy, index);
 
 	return 0;
 }
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index 14cd98f..5b25d8d 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -248,7 +248,9 @@ static void change_VID(int vid)
 }
 
 
-static void change_speed(struct cpufreq_policy *policy, unsigned int index)
+static int powernow_target(struct cpufreq_policy *policy,
+			    unsigned int index,
+			    unsigned int relation)
 {
 	u8 fid, vid;
 	struct cpufreq_freqs freqs;
@@ -291,6 +293,8 @@ static void change_speed(struct cpufreq_policy *policy, unsigned int index)
 		local_irq_enable();
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
+
+	return 0;
 }
 
 
@@ -533,22 +537,6 @@ static int powernow_decode_bios(int maxfid, int startvid)
 }
 
 
-static int powernow_target(struct cpufreq_policy *policy,
-			    unsigned int target_freq,
-			    unsigned int relation)
-{
-	unsigned int newstate;
-
-	if (cpufreq_frequency_table_target(policy, powernow_table, target_freq,
-				relation, &newstate))
-		return -EINVAL;
-
-	change_speed(policy, newstate);
-
-	return 0;
-}
-
-
 /*
  * We use the fact that the bus frequency is somehow
  * a multiple of 100000/3 khz, then we compute sgtc according
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 1e6f68a..cdf0eb3 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -977,7 +977,7 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,
 
 struct powernowk8_target_arg {
 	struct cpufreq_policy		*pol;
-	unsigned			targfreq;
+	unsigned			newstate;
 	unsigned			relation;
 };
 
@@ -985,12 +985,11 @@ static long powernowk8_target_fn(void *arg)
 {
 	struct powernowk8_target_arg *pta = arg;
 	struct cpufreq_policy *pol = pta->pol;
-	unsigned targfreq = pta->targfreq;
+	unsigned newstate = pta->newstate;
 	unsigned relation = pta->relation;
 	struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
 	u32 checkfid;
 	u32 checkvid;
-	unsigned int newstate;
 	int ret;
 
 	if (!data)
@@ -1005,7 +1004,8 @@ static long powernowk8_target_fn(void *arg)
 	}
 
 	pr_debug("targ: cpu %d, %d kHz, min %d, max %d, relation %d\n",
-		pol->cpu, targfreq, pol->min, pol->max, relation);
+		pol->cpu, data->powernow_table[newstate].frequency, pol->min,
+		pol->max, relation);
 
 	if (query_current_values_with_pending_wait(data))
 		return -EIO;
@@ -1021,10 +1021,6 @@ static long powernowk8_target_fn(void *arg)
 		       checkvid, data->currvid);
 	}
 
-	if (cpufreq_frequency_table_target(pol, data->powernow_table,
-				targfreq, relation, &newstate))
-		return -EIO;
-
 	mutex_lock(&fidvid_mutex);
 
 	powernow_k8_acpi_pst_values(data, newstate);
@@ -1045,9 +1041,9 @@ static long powernowk8_target_fn(void *arg)
 
 /* Driver entry point to switch to the target frequency */
 static int powernowk8_target(struct cpufreq_policy *pol,
-		unsigned targfreq, unsigned relation)
+		unsigned index, unsigned relation)
 {
-	struct powernowk8_target_arg pta = { .pol = pol, .targfreq = targfreq,
+	struct powernowk8_target_arg pta = { .pol = pol, .newstate = index,
 					     .relation = relation };
 
 	return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index befd489..a7c1d98 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -253,27 +253,20 @@ static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 }
 
 static int corenet_cpufreq_target(struct cpufreq_policy *policy,
-		unsigned int target_freq, unsigned int relation)
+		unsigned int index, unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
-	unsigned int new;
 	struct clk *parent;
 	int ret;
 	struct cpu_data *data = per_cpu(cpu_data, policy->cpu);
 
-	cpufreq_frequency_table_target(policy, data->table,
-			target_freq, relation, &new);
-
-	if (policy->cur == data->table[new].frequency)
-		return 0;
-
 	freqs.old = policy->cur;
-	freqs.new = data->table[new].frequency;
+	freqs.new = data->table[index].frequency;
 
 	mutex_lock(&cpufreq_lock);
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
-	parent = of_clk_get(data->parent, data->table[new].driver_data);
+	parent = of_clk_get(data->parent, data->table[index].driver_data);
 	ret = clk_set_parent(data->clk, parent);
 	if (ret)
 		freqs.new = freqs.old;
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
index 38540d1..8dd1798 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -129,18 +129,11 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
 }
 
 static int cbe_cpufreq_target(struct cpufreq_policy *policy,
-			      unsigned int target_freq,
+			      unsigned int cbe_pmode_new,
 			      unsigned int relation)
 {
 	int rc;
 	struct cpufreq_freqs freqs;
-	unsigned int cbe_pmode_new;
-
-	cpufreq_frequency_table_target(policy,
-				       cbe_freqs,
-				       target_freq,
-				       relation,
-				       &cbe_pmode_new);
 
 	freqs.old = policy->cur;
 	freqs.new = cbe_freqs[cbe_pmode_new].frequency;
diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 5a72bf3..d7cd5ff 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -268,13 +268,12 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
 }
 
 static int pxa_set_target(struct cpufreq_policy *policy,
-			  unsigned int target_freq,
+			  unsigned int idx,
 			  unsigned int relation)
 {
 	struct cpufreq_frequency_table *pxa_freqs_table;
 	pxa_freqs_t *pxa_freq_settings;
 	struct cpufreq_freqs freqs;
-	unsigned int idx;
 	unsigned long flags;
 	unsigned int new_freq_cpu, new_freq_mem;
 	unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -283,12 +282,6 @@ static int pxa_set_target(struct cpufreq_policy *policy,
 	/* Get the current policy */
 	find_freq_tables(&pxa_freqs_table, &pxa_freq_settings);
 
-	/* Lookup the next frequency */
-	if (cpufreq_frequency_table_target(policy, pxa_freqs_table,
-					   target_freq, relation, &idx)) {
-		return -EINVAL;
-	}
-
 	new_freq_cpu = pxa_freq_settings[idx].khz;
 	new_freq_mem = pxa_freq_settings[idx].membus;
 	freqs.old = policy->cur;
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 2837fd6..ac35fba 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -156,23 +156,17 @@ static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)
 }
 
 static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy,
-			      unsigned int target_freq,
+			      unsigned int index,
 			      unsigned int relation)
 {
 	struct pxa3xx_freq_info *next;
 	struct cpufreq_freqs freqs;
 	unsigned long flags;
-	int idx;
 
 	if (policy->cpu != 0)
 		return -EINVAL;
 
-	/* Lookup the next frequency */
-	if (cpufreq_frequency_table_target(policy, pxa3xx_freqs_table,
-				target_freq, relation, &idx))
-		return -EINVAL;
-
-	next = &pxa3xx_freqs[idx];
+	next = &pxa3xx_freqs[index];
 
 	freqs.old = policy->cur;
 	freqs.new = next->cpufreq_mhz * 1000;
@@ -181,9 +175,6 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy,
 			freqs.old / 1000, freqs.new / 1000,
 			(freqs.old == freqs.new) ? " (skipped)" : "");
 
-	if (freqs.old == target_freq)
-		return 0;
-
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
 	local_irq_save(flags);
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index 8c57f10..77cb7c5 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -217,24 +217,19 @@ static int s3c2416_cpufreq_leave_dvs(struct s3c2416_data *s3c_freq, int idx)
 }
 
 static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy,
-				      unsigned int target_freq,
+				      unsigned int index,
 				      unsigned int relation)
 {
 	struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;
 	struct cpufreq_freqs freqs;
 	int idx, ret, to_dvs = 0;
-	unsigned int i;
 
 	mutex_lock(&cpufreq_lock);
 
-	pr_debug("cpufreq: to %dKHz, relation %d\n", target_freq, relation);
+	pr_debug("cpufreq: to %dKHz, relation %d\n",
+			s3c_freq->freq_table[index].frequency, relation);
 
-	ret = cpufreq_frequency_table_target(policy, s3c_freq->freq_table,
-					     target_freq, relation, &i);
-	if (ret != 0)
-		goto out;
-
-	idx = s3c_freq->freq_table[i].driver_data;
+	idx = s3c_freq->freq_table[index].driver_data;
 
 	if (idx == SOURCE_HCLK)
 		to_dvs = 1;
@@ -256,13 +251,10 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy,
 	 */
 	freqs.new = (s3c_freq->is_dvs && !to_dvs)
 				? clk_get_rate(s3c_freq->hclk) / 1000
-				: s3c_freq->freq_table[i].frequency;
+				: s3c_freq->freq_table[index].frequency;
 
 	pr_debug("cpufreq: Transition %d-%dkHz\n", freqs.old, freqs.new);
 
-	if (!to_dvs && freqs.old == freqs.new)
-		goto out;
-
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
 	if (to_dvs) {
@@ -330,7 +322,6 @@ static int s3c2416_cpufreq_reboot_notifier_evt(struct notifier_block *this,
 					       unsigned long event, void *ptr)
 {
 	struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;
-	int ret;
 
 	mutex_lock(&cpufreq_lock);
 
@@ -344,9 +335,15 @@ static int s3c2416_cpufreq_reboot_notifier_evt(struct notifier_block *this,
 	 * Therefore we always leave the DVS mode on reboot.
 	 */
 	if (s3c_freq->is_dvs) {
+		struct cpufreq_policy *policy = cpufreq_cpu_get(0);
+		int i;
+
+		cpufreq_cpu_put(policy);
 		pr_debug("cpufreq: leave dvs on reboot\n");
-		ret = cpufreq_driver_target(cpufreq_cpu_get(0), FREQ_SLEEP, 0);
-		if (ret < 0)
+
+		if (cpufreq_frequency_table_target(policy,
+				s3c_freq->freq_table, FREQ_SLEEP, 0, &i) ||
+				cpufreq_driver_target(policy, i, 0))
 			return NOTIFY_BAD;
 	}
 
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index 93fcdde..6204d2b 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -38,7 +38,6 @@ static struct cpufreq_driver s3c24xx_driver;
 static struct s3c_cpufreq_config cpu_cur;
 static struct s3c_iotimings s3c24xx_iotiming;
 static struct cpufreq_frequency_table *pll_reg;
-static unsigned int last_target = ~0;
 static unsigned int ftab_size;
 static struct cpufreq_frequency_table *ftab;
 
@@ -278,35 +277,18 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy,
  */
 
 static int s3c_cpufreq_target(struct cpufreq_policy *policy,
-			      unsigned int target_freq,
+			      unsigned int index,
 			      unsigned int relation)
 {
 	struct cpufreq_frequency_table *pll;
-	unsigned int index;
-
-	/* avoid repeated calls which cause a needless amout of duplicated
-	 * logging output (and CPU time as the calculation process is
-	 * done) */
-	if (target_freq == last_target)
-		return 0;
-
-	last_target = target_freq;
+	unsigned int target_freq = 0;
 
 	s3c_freq_dbg("%s: policy %p, target %u, relation %u\n",
 		     __func__, policy, target_freq, relation);
 
-	if (ftab) {
-		if (cpufreq_frequency_table_target(policy, ftab,
-						   target_freq, relation,
-						   &index)) {
-			s3c_freq_dbg("%s: table failed\n", __func__);
-			return -EINVAL;
-		}
-
-		s3c_freq_dbg("%s: adjust %d to entry %d (%u)\n", __func__,
-			     target_freq, index, ftab[index].frequency);
+	/* FIXME: When can ftab be NULL? */
+	if (ftab)
 		target_freq = ftab[index].frequency;
-	}
 
 	target_freq *= 1000;  /* convert target to Hz */
 
@@ -435,8 +417,6 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy)
 
 	s3c_freq_dbg("%s: resuming with policy %p\n", __func__, policy);
 
-	last_target = ~0;	/* invalidate last_target setting */
-
 	/* first, find out what speed we resumed at. */
 	s3c_cpufreq_resume_clocks();
 
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 99fbc49..7995886 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -63,26 +63,17 @@ static unsigned int s3c64xx_cpufreq_get_speed(unsigned int cpu)
 }
 
 static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
-				      unsigned int target_freq,
+				      unsigned int index,
 				      unsigned int relation)
 {
 	int ret;
-	unsigned int i;
 	struct cpufreq_freqs freqs;
 	struct s3c64xx_dvfs *dvfs;
 
-	ret = cpufreq_frequency_table_target(policy, s3c64xx_freq_table,
-					     target_freq, relation, &i);
-	if (ret != 0)
-		return ret;
-
 	freqs.old = clk_get_rate(armclk) / 1000;
-	freqs.new = s3c64xx_freq_table[i].frequency;
+	freqs.new = s3c64xx_freq_table[index].frequency;
 	freqs.flags = 0;
-	dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[i].driver_data];
-
-	if (freqs.old == freqs.new)
-		return 0;
+	dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[index].driver_data];
 
 	pr_debug("Transition %d-%dkHz\n", freqs.old, freqs.new);
 
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 0eafc52..5ac1dd4 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -183,11 +183,11 @@ static unsigned int s5pv210_getspeed(unsigned int cpu)
 }
 
 static int s5pv210_target(struct cpufreq_policy *policy,
-			  unsigned int target_freq,
+			  unsigned int index,
 			  unsigned int relation)
 {
 	unsigned long reg;
-	unsigned int index, priv_index;
+	unsigned int priv_index;
 	unsigned int pll_changing = 0;
 	unsigned int bus_speed_changing = 0;
 	int arm_volt, int_volt;
@@ -213,18 +213,8 @@ static int s5pv210_target(struct cpufreq_policy *policy,
 	relation &= ~(ENABLE_FURTHER_CPUFREQ | DISABLE_FURTHER_CPUFREQ);
 
 	freqs.old = s5pv210_getspeed(0);
-
-	if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
-					   target_freq, relation, &index)) {
-		ret = -EINVAL;
-		goto exit;
-	}
-
 	freqs.new = s5pv210_freq_table[index].frequency;
 
-	if (freqs.new == freqs.old)
-		goto exit;
-
 	/* Finding current running level index */
 	if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
 					   freqs.old, relation, &priv_index)) {
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c
index 8556225..1053111 100644
--- a/drivers/cpufreq/sc520_freq.c
+++ b/drivers/cpufreq/sc520_freq.c
@@ -53,8 +53,9 @@ static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu)
 	}
 }
 
-static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy,
-		unsigned int state)
+static int sc520_freq_target(struct cpufreq_policy *policy,
+			    unsigned int state,
+			    unsigned int relation)
 {
 
 	struct cpufreq_freqs	freqs;
@@ -76,24 +77,10 @@ static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy,
 	local_irq_enable();
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-};
-
-static int sc520_freq_target(struct cpufreq_policy *policy,
-			    unsigned int target_freq,
-			    unsigned int relation)
-{
-	unsigned int newstate = 0;
-
-	if (cpufreq_frequency_table_target(policy, sc520_freq_table,
-				target_freq, relation, &newstate))
-		return -EINVAL;
-
-	sc520_freq_set_cpu_state(policy, newstate);
 
 	return 0;
 }
 
-
 /*
  *	Module init and exit code
  */
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index 291688c..0e63736 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -280,17 +280,10 @@ static void us2e_set_cpu_divider_index(struct cpufreq_policy *policy,
 }
 
 static int us2e_freq_target(struct cpufreq_policy *policy,
-			  unsigned int target_freq,
+			  unsigned int index,
 			  unsigned int relation)
 {
-	unsigned int new_index = 0;
-
-	if (cpufreq_frequency_table_target(policy,
-					   &us2e_freq_table[policy->cpu].table[0],
-					   target_freq, relation, &new_index))
-		return -EINVAL;
-
-	us2e_set_cpu_divider_index(policy, new_index);
+	us2e_set_cpu_divider_index(policy, index);
 
 	return 0;
 }
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index 9b3dbd3..89e2cb0 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -139,19 +139,10 @@ static void us3_set_cpu_divider_index(struct cpufreq_policy *policy,
 }
 
 static int us3_freq_target(struct cpufreq_policy *policy,
-			  unsigned int target_freq,
+			  unsigned int index,
 			  unsigned int relation)
 {
-	unsigned int new_index = 0;
-
-	if (cpufreq_frequency_table_target(policy,
-					   &us3_freq_table[policy->cpu].table[0],
-					   target_freq,
-					   relation,
-					   &new_index))
-		return -EINVAL;
-
-	us3_set_cpu_divider_index(policy, new_index);
+	us3_set_cpu_divider_index(policy, index);
 
 	return 0;
 }
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index d31accc..dbac68c 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -105,20 +105,16 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq)
 }
 
 static int spear_cpufreq_target(struct cpufreq_policy *policy,
-		unsigned int target_freq, unsigned int relation)
+		unsigned int index, unsigned int relation)
 {
 	struct cpufreq_freqs freqs;
 	unsigned long newfreq;
 	struct clk *srcclk;
-	int index, ret, mult = 1;
-
-	if (cpufreq_frequency_table_target(policy, spear_cpufreq.freq_tbl,
-				target_freq, relation, &index))
-		return -EINVAL;
+	int ret, mult = 1;
 
 	freqs.old = spear_cpufreq_get(0);
-
 	newfreq = spear_cpufreq.freq_tbl[index].frequency * 1000;
+
 	if (of_machine_is_compatible("st,spear1340")) {
 		/*
 		 * SPEAr1340 is special in the sense that due to the possibility
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
index c7c14ae..4270548 100644
--- a/drivers/cpufreq/speedstep-centrino.c
+++ b/drivers/cpufreq/speedstep-centrino.c
@@ -422,21 +422,21 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
 /**
  * centrino_setpolicy - set a new CPUFreq policy
  * @policy: new policy
- * @target_freq: the target frequency
+ * @index: index of target frequency
  * @relation: how that frequency relates to achieved frequency
  *	(CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
  *
  * Sets a new CPUFreq policy.
  */
 static int centrino_target (struct cpufreq_policy *policy,
-			    unsigned int target_freq,
+			    unsigned int index,
 			    unsigned int relation)
 {
-	unsigned int    newstate = 0;
 	unsigned int	msr, oldmsr = 0, h = 0, cpu = policy->cpu;
 	struct cpufreq_freqs	freqs;
 	int			retval = 0;
 	unsigned int		j, first_cpu, tmp;
+	struct cpufreq_frequency_table *op_points;
 	cpumask_var_t covered_cpus;
 
 	if (unlikely(!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL)))
@@ -447,16 +447,8 @@ static int centrino_target (struct cpufreq_policy *policy,
 		goto out;
 	}
 
-	if (unlikely(cpufreq_frequency_table_target(policy,
-			per_cpu(centrino_model, cpu)->op_points,
-			target_freq,
-			relation,
-			&newstate))) {
-		retval = -EINVAL;
-		goto out;
-	}
-
 	first_cpu = 1;
+	op_points = &per_cpu(centrino_model, cpu)->op_points[index];
 	for_each_cpu(j, policy->cpus) {
 		int good_cpu;
 
@@ -480,7 +472,7 @@ static int centrino_target (struct cpufreq_policy *policy,
 			break;
 		}
 
-		msr = per_cpu(centrino_model, cpu)->op_points[newstate].driver_data;
+		msr = op_points->driver_data;
 
 		if (first_cpu) {
 			rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h);
@@ -495,7 +487,7 @@ static int centrino_target (struct cpufreq_policy *policy,
 			freqs.new = extract_clock(msr, cpu, 0);
 
 			pr_debug("target=%dkHz old=%d new=%d msr=%04x\n",
-				target_freq, freqs.old, freqs.new, msr);
+				op_points->frequency, freqs.old, freqs.new, msr);
 
 			cpufreq_notify_transition(policy, &freqs,
 					CPUFREQ_PRECHANGE);
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c
index 929a4f0..872347c 100644
--- a/drivers/cpufreq/speedstep-ich.c
+++ b/drivers/cpufreq/speedstep-ich.c
@@ -251,36 +251,28 @@ static unsigned int speedstep_get(unsigned int cpu)
 /**
  * speedstep_target - set a new CPUFreq policy
  * @policy: new policy
- * @target_freq: the target frequency
+ * @index: index of target frequency
  * @relation: how that frequency relates to achieved frequency
  *	(CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
  *
  * Sets a new CPUFreq policy.
  */
 static int speedstep_target(struct cpufreq_policy *policy,
-			     unsigned int target_freq,
+			     unsigned int index,
 			     unsigned int relation)
 {
-	unsigned int newstate = 0, policy_cpu;
+	unsigned int policy_cpu;
 	struct cpufreq_freqs freqs;
 
-	if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0],
-				target_freq, relation, &newstate))
-		return -EINVAL;
-
 	policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask);
 	freqs.old = speedstep_get(policy_cpu);
-	freqs.new = speedstep_freqs[newstate].frequency;
+	freqs.new = speedstep_freqs[index].frequency;
 
 	pr_debug("transiting from %u to %u kHz\n", freqs.old, freqs.new);
 
-	/* no transition necessary */
-	if (freqs.old == freqs.new)
-		return 0;
-
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
 
-	smp_call_function_single(policy_cpu, _speedstep_set_state, &newstate,
+	smp_call_function_single(policy_cpu, _speedstep_set_state, &index,
 				 true);
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
index b3dfba0..ec0951f 100644
--- a/drivers/cpufreq/speedstep-smi.c
+++ b/drivers/cpufreq/speedstep-smi.c
@@ -235,29 +235,21 @@ static void speedstep_set_state(unsigned int state)
 /**
  * speedstep_target - set a new CPUFreq policy
  * @policy: new policy
- * @target_freq: new freq
+ * @index: index of new freq
  * @relation:
  *
  * Sets a new CPUFreq policy/freq.
  */
 static int speedstep_target(struct cpufreq_policy *policy,
-			unsigned int target_freq, unsigned int relation)
+			unsigned int index, unsigned int relation)
 {
-	unsigned int newstate = 0;
 	struct cpufreq_freqs freqs;
 
-	if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0],
-				target_freq, relation, &newstate))
-		return -EINVAL;
-
 	freqs.old = speedstep_freqs[speedstep_get_state()].frequency;
-	freqs.new = speedstep_freqs[newstate].frequency;
-
-	if (freqs.old == freqs.new)
-		return 0;
+	freqs.new = speedstep_freqs[index].frequency;
 
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-	speedstep_set_state(newstate);
+	speedstep_set_state(index);
 	cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
 
 	return 0;
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index affb294..6eef51b 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -151,10 +151,9 @@ static unsigned long tegra_cpu_highest_speed(void)
 }
 
 static int tegra_target(struct cpufreq_policy *policy,
-		       unsigned int target_freq,
+		       unsigned int index,
 		       unsigned int relation)
 {
-	unsigned int idx;
 	unsigned int freq;
 	int ret = 0;
 
@@ -165,10 +164,7 @@ static int tegra_target(struct cpufreq_policy *policy,
 		goto out;
 	}
 
-	cpufreq_frequency_table_target(policy, freq_table, target_freq,
-		relation, &idx);
-
-	freq = freq_table[idx].frequency;
+	freq = freq_table[index].frequency;
 
 	target_cpu_speed[policy->cpu] = freq;
 
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 4907eb2..a0a9f38 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -196,7 +196,7 @@ struct cpufreq_driver {
 	/* define one out of two */
 	int	(*setpolicy)	(struct cpufreq_policy *policy);
 	int	(*target)	(struct cpufreq_policy *policy,
-				 unsigned int target_freq,
+				 unsigned int index,
 				 unsigned int relation);
 
 	/* should be defined, if possible */
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 67+ messages in thread

* Re: [PATCH 44/44] cpufreq: pass suitable index instead of freq to cpufreq_driver->target()
  2013-08-10  6:44 ` [PATCH 44/44] cpufreq: pass suitable index instead of freq to cpufreq_driver->target() Viresh Kumar
@ 2013-08-10  7:45   ` Viresh Kumar
  2013-08-12  6:50   ` Viresh Kumar
  1 sibling, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  7:45 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

On 10 August 2013 12:14, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> This tries to remove code redundancy from cpufreq driver by moving some common
> part of them to the core. Each driver calls cpufreq_frequency_table_target() to
> get a suitable index for a target frequency and then works on it. Its better to
> do this at core level before calling cpufreq driver and hence passing "index"
> instead of "target_freq and relation" to cpufreq_driver->target() routine.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---

This one is sent by mistake.. It isn't ready yet and will be sent separately
later. :(

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13
  2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
                   ` (43 preceding siblings ...)
  2013-08-10  6:44 ` [PATCH 44/44] cpufreq: pass suitable index instead of freq to cpufreq_driver->target() Viresh Kumar
@ 2013-08-10  7:46 ` Viresh Kumar
  44 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-10  7:46 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Andrew Lunn, David S. Miller,
	Dmitry Eremin-Solenikov, Eric Miao, Guan Xuetao,
	Hans-Christian Egtvedt, Jesper Nilsson, John Crispin, Kukjin Kim,
	Linus Walleij, linux-cris-kernel, linux-sh, Mikael Starvik,
	Paul Mundt, Santosh Shilimkar, Sekhar Nori, Shawn Guo,
	sparclinux, spear-devel, Stephen Warren, Steven Miao, Tony Luck

On 10 August 2013 12:13, Viresh Kumar <viresh.kumar@linaro.org> wrote:
>   cpufreq: pass suitable index instead of freq to
>     cpufreq_driver->target()

This one is sent by mistake.. It isn't ready yet and will be sent separately
later. :(

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-10  6:44 ` [PATCH 11/44] cpufreq: at32ap: " Viresh Kumar
@ 2013-08-10  8:23   ` Hans-Christian Egtvedt
  2013-08-12  6:07     ` Viresh Kumar
  0 siblings, 1 reply; 67+ messages in thread
From: Hans-Christian Egtvedt @ 2013-08-10  8:23 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

Around Sat 10 Aug 2013 12:14:07 +0530 or thereabout, Viresh Kumar wrote:
> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
> and .attr. So its better if we have generic routines for them which can be used
> by cpufreq drivers then.
> 
> This patch uses these generic routines for this driver.

Nice, thanks for cleaning up (-:

> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>

> ---
>  drivers/cpufreq/at32ap-cpufreq.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)

<snipp diff>

-- 
mvh
Hans-Christian Egtvedt

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-10  8:23   ` Hans-Christian Egtvedt
@ 2013-08-12  6:07     ` Viresh Kumar
  2013-08-12  7:10       ` Hans-Christian Egtvedt
  0 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-12  6:07 UTC (permalink / raw)
  To: Hans-Christian Egtvedt
  Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

On 10 August 2013 13:53, Hans-Christian Egtvedt <egtvedt@samfundet.no> wrote:
> Around Sat 10 Aug 2013 12:14:07 +0530 or thereabout, Viresh Kumar wrote:
>> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
>> and .attr. So its better if we have generic routines for them which can be used
>> by cpufreq drivers then.
>>
>> This patch uses these generic routines for this driver.
>
> Nice, thanks for cleaning up (-:
>
>> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
>> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>

Thanks for your Ack but I have to NACK it :)

My patch was wrong.. It was based on the assumption that everybody who
had implemented a .target() also implements a frequency table and exposes
it.. And the generic routines I have exposed depend on that frequency table.
And this cpufreq driver doesn't expose that freq table...

And so this patch is dropped :(

--
viresh

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 43/44] cpufreq: unicore2: Use generic cpufreq routines
  2013-08-10  6:44 ` [PATCH 43/44] cpufreq: unicore2: " Viresh Kumar
@ 2013-08-12  6:08   ` Viresh Kumar
  0 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-12  6:08 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Guan Xuetao

On 10 August 2013 12:14, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
> and .attr. So its better if we have generic routines for them which can be used
> by cpufreq drivers then.
>
> This patch uses these generic routines for this driver.
>
> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/unicore2-cpufreq.c | 16 +---------------
>  1 file changed, 1 insertion(+), 15 deletions(-)

My patch was wrong.. It was based on the assumption that everybody who
had implemented a .target() also implements a frequency table and exposes
it.. And the generic routines I have exposed depend on that frequency table.
And this cpufreq driver doesn't expose that freq table...

And so this patch is dropped :(

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 29/44] cpufreq: pcc: Use generic cpufreq routines
  2013-08-10  6:44 ` [PATCH 29/44] cpufreq: pcc: " Viresh Kumar
@ 2013-08-12  6:08   ` Viresh Kumar
  0 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-12  6:08 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

On 10 August 2013 12:14, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
> and .attr. So its better if we have generic routines for them which can be used
> by cpufreq drivers then.
>
> This patch uses these generic routines for this driver.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/pcc-cpufreq.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)

My patch was wrong.. It was based on the assumption that everybody who
had implemented a .target() also implements a frequency table and exposes
it.. And the generic routines I have exposed depend on that frequency table.
And this cpufreq driver doesn't expose that freq table...

And so this patch is dropped :(

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 03/44] cpufreq: exynos: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 ` [PATCH 03/44] cpufreq: exynos: " Viresh Kumar
@ 2013-08-12  6:18   ` Viresh Kumar
  2013-08-18 10:00   ` amit daniel kachhap
  1 sibling, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-12  6:18 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel,
	Viresh Kumar, Kukjin Kim

On 10 August 2013 12:13, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
> they have called cpufreq_frequency_table_get_attr() in their init path.
>
> This driver was missing this part and is fixed with this patch.
>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/exynos5440-cpufreq.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
> index 1ac93e0..b9dfc91 100644
> --- a/drivers/cpufreq/exynos5440-cpufreq.c
> +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> @@ -336,12 +336,18 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
>         return 0;
>  }
>
> +static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)

s/init/exit ..

fixed in my repo..

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 44/44] cpufreq: pass suitable index instead of freq to cpufreq_driver->target()
  2013-08-10  6:44 ` [PATCH 44/44] cpufreq: pass suitable index instead of freq to cpufreq_driver->target() Viresh Kumar
  2013-08-10  7:45   ` Viresh Kumar
@ 2013-08-12  6:50   ` Viresh Kumar
  1 sibling, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-12  6:50 UTC (permalink / raw)
  To: rjw; +Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, Viresh Kumar

On 10 August 2013 12:14, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> This tries to remove code redundancy from cpufreq driver by moving some common
> part of them to the core. Each driver calls cpufreq_frequency_table_target() to
> get a suitable index for a target frequency and then works on it. Its better to
> do this at core level before calling cpufreq driver and hence passing "index"
> instead of "target_freq and relation" to cpufreq_driver->target() routine.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---

> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 06f8671..4bf023d 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1628,7 +1628,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
>                             unsigned int target_freq,
>                             unsigned int relation)
>  {
> -       int retval = -EINVAL;
> +       int retval = -EINVAL, index;
>         unsigned int old_target_freq = target_freq;
>
>         if (cpufreq_disabled())
> @@ -1645,11 +1645,35 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
>         pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
>                         policy->cpu, target_freq, relation, old_target_freq);
>
> +       /*
> +        * This might look like a redundant call as we are checking it again
> +        * after finding index. But it is left intentionally for cases where
> +        * same freq is called again and so we can save on few function calls.
> +        */
>         if (target_freq == policy->cur)
>                 return 0;
>
> -       if (cpufreq_driver->target)
> -               retval = cpufreq_driver->target(policy, target_freq, relation);
> +       if (cpufreq_driver->target) {
> +               struct cpufreq_frequency_table *freq_table;
> +
> +               freq_table = cpufreq_frequency_get_table(policy->cpu);
> +               if (unlikely(!freq_table)) {
> +                       pr_err("%s: Unable to find freq_table\n", __func__);
> +                       return retval;
> +               }
> +
> +               retval = cpufreq_frequency_table_target(policy, freq_table,
> +                               target_freq, relation, &index);
> +               if (unlikely(retval)) {
> +                       pr_err("%s: Unable to find matching freq\n", __func__);
> +                       return retval;
> +               }
> +
> +               if (freq_table[index].frequency == policy->cur)
> +                       return 0;
> +
> +               retval = cpufreq_driver->target(policy, index, relation);
> +       }
>
>         return retval;
>  }

Hi Rafael,

This was sent earlier by mistake but lets take advantage of that mistake
now :)

I wanted to discuss what's the right way to get this patch in..

Idea: was to simplify ->target() routines of drivers by finding the right index
prior to calling ->target().. And so the parameters would be changed to:

        int     (*target)       (struct cpufreq_policy *policy,
-                                unsigned int target_freq,
-                                unsigned int relation);
+                                unsigned int index)

Problem: Some drivers that implement ->target() doesn't have a freq table
with them and so they never call cpufreq_frequency_table_target to get
index and so passing Index for them is irrelevant.

What can we do here?
Solution 1: Define two types of ->target() one with above mentioned
prototype and other with the older style, And so drivers can initialize
one of them..

Issues: Two pointers for same work, doesn't look clean enough

Solution 2: Change prototype to something like this:
        int     (*target)       (struct cpufreq_policy *policy,
                                 unsigned int target_freq,
+                                unsigned int index,
                                 unsigned int relation);

Here,
  - target_freq: will have the freq requested (not the freq from table)
  - index: index of table suitable for this freq (for drivers exposing
freq_table)
    and will be -1 for others, like: at32, pcc, unicore2..
  - relation will stay as it is..

Issues: Not all parameters are useful for everybody.. Most of the drivers
wouldn't use target_freq or relation..


Which one do you like?

--
viresh

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-12  6:07     ` Viresh Kumar
@ 2013-08-12  7:10       ` Hans-Christian Egtvedt
  2013-08-12  7:13         ` Viresh Kumar
  0 siblings, 1 reply; 67+ messages in thread
From: Hans-Christian Egtvedt @ 2013-08-12  7:10 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

Around Mon 12 Aug 2013 11:37:45 +0530 or thereabout, Viresh Kumar wrote:
> On 10 August 2013 13:53, Hans-Christian Egtvedt <egtvedt@samfundet.no> wrote:
>> Around Sat 10 Aug 2013 12:14:07 +0530 or thereabout, Viresh Kumar wrote:
>>> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
>>> and .attr. So its better if we have generic routines for them which can be used
>>> by cpufreq drivers then.
>>>
>>> This patch uses these generic routines for this driver.
>>
>> Nice, thanks for cleaning up (-:
>>
>>> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
>>> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>>
>> Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
> 
> Thanks for your Ack but I have to NACK it :)
> 
> My patch was wrong.. It was based on the assumption that everybody who
> had implemented a .target() also implements a frequency table and exposes
> it.. And the generic routines I have exposed depend on that frequency table.
> And this cpufreq driver doesn't expose that freq table...

Right, my bad, I just looked at the code flow and saw that the generic path
did pretty much the same as the AVR32 implementation. Didn't consider the
table part as missing.

> And so this patch is dropped :(
> 

Ok, AVR32 driver should expose a frequency table then, which is quite simple.

-- 
mvh
Hans-Christian Egtvedt

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-12  7:10       ` Hans-Christian Egtvedt
@ 2013-08-12  7:13         ` Viresh Kumar
  2013-08-12  7:30           ` Hans-Christian Egtvedt
  0 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-12  7:13 UTC (permalink / raw)
  To: Hans-Christian Egtvedt
  Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

On 12 August 2013 12:40, Hans-Christian Egtvedt <egtvedt@samfundet.no> wrote:
> Ok, AVR32 driver should expose a frequency table then, which is quite simple.

It would be really nice if you can provide that patch, that will make
my life simple :)

I thought I can get a table for it but wasn't able to find out
necessary information
for that.

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-12  7:13         ` Viresh Kumar
@ 2013-08-12  7:30           ` Hans-Christian Egtvedt
  2013-08-12  7:39             ` Viresh Kumar
  0 siblings, 1 reply; 67+ messages in thread
From: Hans-Christian Egtvedt @ 2013-08-12  7:30 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

Around Mon 12 Aug 2013 12:43:37 +0530 or thereabout, Viresh Kumar wrote:
> On 12 August 2013 12:40, Hans-Christian Egtvedt <egtvedt@samfundet.no> wrote:
>> Ok, AVR32 driver should expose a frequency table then, which is quite simple.
> 
> It would be really nice if you can provide that patch, that will make
> my life simple :)
> 
> I thought I can get a table for it but wasn't able to find out
> necessary information
> for that.

I'll add it on my todo-list and have a look at it in the evening (-:

How hard can it be™

-- 
mvh
Hans-Christian Egtvedt

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-12  7:30           ` Hans-Christian Egtvedt
@ 2013-08-12  7:39             ` Viresh Kumar
  2013-08-12 19:11               ` Hans-Christian Egtvedt
  0 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-12  7:39 UTC (permalink / raw)
  To: Hans-Christian Egtvedt
  Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

On 12 August 2013 13:00, Hans-Christian Egtvedt <egtvedt@samfundet.no> wrote:
> I'll add it on my todo-list and have a look at it in the evening (-:

Thanks.

> How hard can it be™

Its not about being hard but about knowing your platform well..

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 13/44] cpufreq: cpu0: Use generic cpufreq routines
  2013-08-10  6:44 ` [PATCH 13/44] cpufreq: cpu0: " Viresh Kumar
@ 2013-08-12  7:58   ` Shawn Guo
  0 siblings, 0 replies; 67+ messages in thread
From: Shawn Guo @ 2013-08-12  7:58 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

On Sat, Aug 10, 2013 at 12:14:09PM +0530, Viresh Kumar wrote:
> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
> and .attr. So its better if we have generic routines for them which can be used
> by cpufreq drivers then.
> 
> This patch uses these generic routines for this driver.
> 
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Acked-by: Shawn Guo <shawn.guo@linaro.org>


^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 21/44] cpufreq: imx6q: Use generic cpufreq routines
  2013-08-10  6:44 ` [PATCH 21/44] cpufreq: imx6q: " Viresh Kumar
@ 2013-08-12  7:58   ` Shawn Guo
  2013-08-12  8:10     ` Viresh Kumar
  0 siblings, 1 reply; 67+ messages in thread
From: Shawn Guo @ 2013-08-12  7:58 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

On Sat, Aug 10, 2013 at 12:14:17PM +0530, Viresh Kumar wrote:
> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
> and .attr. So its better if we have generic routines for them which can be used
> by cpufreq drivers then.
> 
> This patch uses these generic routines for this driver.
> 
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Shawn Guo <shawn.guo@linaro.org>


^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 21/44] cpufreq: imx6q: Use generic cpufreq routines
  2013-08-12  7:58   ` Shawn Guo
@ 2013-08-12  8:10     ` Viresh Kumar
  2013-08-12  8:34       ` Shawn Guo
  0 siblings, 1 reply; 67+ messages in thread
From: Viresh Kumar @ 2013-08-12  8:10 UTC (permalink / raw)
  To: Shawn Guo; +Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

On 12 August 2013 13:28, Shawn Guo <shawn.guo@linaro.org> wrote:
> On Sat, Aug 10, 2013 at 12:14:17PM +0530, Viresh Kumar wrote:
>> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
>> and .attr. So its better if we have generic routines for them which can be used
>> by cpufreq drivers then.
>>
>> This patch uses these generic routines for this driver.
>>
>> Cc: Shawn Guo <shawn.guo@linaro.org>
>> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> Shawn Guo <shawn.guo@linaro.org>

I assume you meant an Ack here :)

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 21/44] cpufreq: imx6q: Use generic cpufreq routines
  2013-08-12  8:10     ` Viresh Kumar
@ 2013-08-12  8:34       ` Shawn Guo
  0 siblings, 0 replies; 67+ messages in thread
From: Shawn Guo @ 2013-08-12  8:34 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

On Mon, Aug 12, 2013 at 01:40:36PM +0530, Viresh Kumar wrote:
> On 12 August 2013 13:28, Shawn Guo <shawn.guo@linaro.org> wrote:
> > On Sat, Aug 10, 2013 at 12:14:17PM +0530, Viresh Kumar wrote:
> >> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
> >> and .attr. So its better if we have generic routines for them which can be used
> >> by cpufreq drivers then.
> >>
> >> This patch uses these generic routines for this driver.
> >>
> >> Cc: Shawn Guo <shawn.guo@linaro.org>
> >> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> >
> > Shawn Guo <shawn.guo@linaro.org>
> 
> I assume you meant an Ack here :)

Ah, yeah.

Acked-by: Shawn Guo <shawn.guo@linaro.org>


^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-12  7:39             ` Viresh Kumar
@ 2013-08-12 19:11               ` Hans-Christian Egtvedt
  2013-08-13  4:54                 ` Viresh Kumar
  0 siblings, 1 reply; 67+ messages in thread
From: Hans-Christian Egtvedt @ 2013-08-12 19:11 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

Around Mon 12 Aug 2013 13:09:25 +0530 or thereabout, Viresh Kumar wrote:
> On 12 August 2013 13:00, Hans-Christian Egtvedt <egtvedt@samfundet.no> wrote:
>> I'll add it on my todo-list and have a look at it in the evening (-:
> 
> Thanks.
> 
>> How hard can it be™
> 
> Its not about being hard but about knowing your platform well..

Turned out to be quite easy, but I couldn't get around to test it on
hardware (excuse: just moved, all HW is still in a box somewhere).

I'll submit the patch to cpufreq@vger.kernel.org for a sanity check, perhaps
you'll pull it into your series?

-- 
mvh
Hans-Christian Egtvedt

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 11/44] cpufreq: at32ap: Use generic cpufreq routines
  2013-08-12 19:11               ` Hans-Christian Egtvedt
@ 2013-08-13  4:54                 ` Viresh Kumar
  0 siblings, 0 replies; 67+ messages in thread
From: Viresh Kumar @ 2013-08-13  4:54 UTC (permalink / raw)
  To: Hans-Christian Egtvedt
  Cc: rjw, linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

On 13 August 2013 00:41, Hans-Christian Egtvedt <egtvedt@samfundet.no> wrote:
> Around Mon 12 Aug 2013 13:09:25 +0530 or thereabout, Viresh Kumar wrote:
>> On 12 August 2013 13:00, Hans-Christian Egtvedt <egtvedt@samfundet.no> wrote:
>>> I'll add it on my todo-list and have a look at it in the evening (-:
>>
>> Thanks.
>>
>>> How hard can it be™
>>
>> Its not about being hard but about knowing your platform well..
>
> Turned out to be quite easy, but I couldn't get around to test it on
> hardware (excuse: just moved, all HW is still in a box somewhere).

I had a quick look at it and yes it is pretty much hadware specific :)
Thanks.

> I'll submit the patch to cpufreq@vger.kernel.org for a sanity check, perhaps
> you'll pull it into your series?

Yes, I will.

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 03/44] cpufreq: exynos: call cpufreq_frequency_table_put_attr()
  2013-08-10  6:43 ` [PATCH 03/44] cpufreq: exynos: " Viresh Kumar
  2013-08-12  6:18   ` Viresh Kumar
@ 2013-08-18 10:00   ` amit daniel kachhap
  2013-08-18 21:59     ` Kukjin Kim
  1 sibling, 1 reply; 67+ messages in thread
From: amit daniel kachhap @ 2013-08-18 10:00 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, linaro-kernel, patches, cpufreq, linux-pm,
	linux-kernel, Kukjin Kim

On Sat, Aug 10, 2013 at 12:13 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
> they have called cpufreq_frequency_table_get_attr() in their init path.
>
> This driver was missing this part and is fixed with this patch.
>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
The changes looks fine, please free to add
Acked-By: Amit Daniel Kachhap <amit.daniel@samsung.com>

Thanks.
Amit Daniel


> ---
>  drivers/cpufreq/exynos5440-cpufreq.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
> index 1ac93e0..b9dfc91 100644
> --- a/drivers/cpufreq/exynos5440-cpufreq.c
> +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> @@ -336,12 +336,18 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
>         return 0;
>  }
>
> +static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
> +{
> +       cpufreq_frequency_table_put_attr(policy->cpu);
> +}
> +
>  static struct cpufreq_driver exynos_driver = {
>         .flags          = CPUFREQ_STICKY,
>         .verify         = exynos_verify_speed,
>         .target         = exynos_target,
>         .get            = exynos_getspeed,
>         .init           = exynos_cpufreq_cpu_init,
> +       .exit           = exynos_cpufreq_cpu_exit,
>         .name           = CPUFREQ_NAME,
>  };
>
> --
> 1.7.12.rc2.18.g61b472e
>
> --
> 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

On Sat, Aug 10, 2013 at 12:13 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Drivers which have an exit path must call cpufreq_frequency_table_put_attr() if
> they have called cpufreq_frequency_table_get_attr() in their init path.
>
> This driver was missing this part and is fixed with this patch.
>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/exynos5440-cpufreq.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
> index 1ac93e0..b9dfc91 100644
> --- a/drivers/cpufreq/exynos5440-cpufreq.c
> +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> @@ -336,12 +336,18 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
>         return 0;
>  }
>
> +static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
> +{
> +       cpufreq_frequency_table_put_attr(policy->cpu);
> +}
> +
>  static struct cpufreq_driver exynos_driver = {
>         .flags          = CPUFREQ_STICKY,
>         .verify         = exynos_verify_speed,
>         .target         = exynos_target,
>         .get            = exynos_getspeed,
>         .init           = exynos_cpufreq_cpu_init,
> +       .exit           = exynos_cpufreq_cpu_exit,
>         .name           = CPUFREQ_NAME,
>  };
>
> --
> 1.7.12.rc2.18.g61b472e
>
> --
> 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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 19/44] cpufreq: exynos: Use generic cpufreq routines
  2013-08-10  6:44 ` [PATCH 19/44] cpufreq: exynos: " Viresh Kumar
@ 2013-08-18 10:03   ` amit daniel kachhap
  2013-08-18 22:00     ` Kukjin Kim
  0 siblings, 1 reply; 67+ messages in thread
From: amit daniel kachhap @ 2013-08-18 10:03 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, linaro-kernel, patches, cpufreq, linux-pm,
	linux-kernel, Kukjin Kim

On Sat, Aug 10, 2013 at 12:14 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Most of the CPUFreq drivers do similar things in .exit() and .verify() routines
> and .attr. So its better if we have generic routines for them which can be used
> by cpufreq drivers then.
>
> This patch uses these generic routines for this driver.
>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
The consolidation code looks fine,
Acked-By: Amit Daniel Kachhap <amit.daniel@samsung.com>

Thanks,
Amit Daniel
> ---
>  drivers/cpufreq/exynos-cpufreq.c     | 23 +++--------------------
>  drivers/cpufreq/exynos5440-cpufreq.c | 15 ++-------------
>  2 files changed, 5 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
> index 71c4926..7663a96 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -31,12 +31,6 @@ static unsigned int locking_frequency;
>  static bool frequency_locked;
>  static DEFINE_MUTEX(cpufreq_lock);
>
> -static int exynos_verify_speed(struct cpufreq_policy *policy)
> -{
> -       return cpufreq_frequency_table_verify(policy,
> -                                             exynos_info->freq_table);
> -}
> -
>  static unsigned int exynos_getspeed(unsigned int cpu)
>  {
>         return clk_get_rate(exynos_info->cpu_clk) / 1000;
> @@ -257,26 +251,15 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
>         return cpufreq_table_validate_and_show(policy, exynos_info->freq_table);
>  }
>
> -static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
> -{
> -       cpufreq_frequency_table_put_attr(policy->cpu);
> -       return 0;
> -}
> -
> -static struct freq_attr *exynos_cpufreq_attr[] = {
> -       &cpufreq_freq_attr_scaling_available_freqs,
> -       NULL,
> -};
> -
>  static struct cpufreq_driver exynos_driver = {
>         .flags          = CPUFREQ_STICKY,
> -       .verify         = exynos_verify_speed,
> +       .verify         = cpufreq_generic_frequency_table_verify,
>         .target         = exynos_target,
>         .get            = exynos_getspeed,
>         .init           = exynos_cpufreq_cpu_init,
> -       .exit           = exynos_cpufreq_cpu_exit,
> +       .exit           = cpufreq_generic_exit,
>         .name           = "exynos_cpufreq",
> -       .attr           = exynos_cpufreq_attr,
> +       .attr           = cpufreq_generic_attr,
>  #ifdef CONFIG_PM
>         .suspend        = exynos_cpufreq_suspend,
>         .resume         = exynos_cpufreq_resume,
> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
> index b9dfc91..f139b3b 100644
> --- a/drivers/cpufreq/exynos5440-cpufreq.c
> +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> @@ -209,12 +209,6 @@ static void exynos_enable_dvfs(void)
>                                 dvfs_info->base + XMU_DVFS_CTRL);
>  }
>
> -static int exynos_verify_speed(struct cpufreq_policy *policy)
> -{
> -       return cpufreq_frequency_table_verify(policy,
> -                                             dvfs_info->freq_table);
> -}
> -
>  static unsigned int exynos_getspeed(unsigned int cpu)
>  {
>         return dvfs_info->cur_frequency;
> @@ -336,18 +330,13 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
>         return 0;
>  }
>
> -static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
> -{
> -       cpufreq_frequency_table_put_attr(policy->cpu);
> -}
> -
>  static struct cpufreq_driver exynos_driver = {
>         .flags          = CPUFREQ_STICKY,
> -       .verify         = exynos_verify_speed,
> +       .verify         = cpufreq_generic_frequency_table_verify,
>         .target         = exynos_target,
>         .get            = exynos_getspeed,
>         .init           = exynos_cpufreq_cpu_init,
> -       .exit           = exynos_cpufreq_cpu_exit,
> +       .exit           = cpufreq_generic_exit,
>         .name           = CPUFREQ_NAME,
>  };
>
> --
> 1.7.12.rc2.18.g61b472e
>
> --
> 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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [PATCH 03/44] cpufreq: exynos: call cpufreq_frequency_table_put_attr()
  2013-08-18 10:00   ` amit daniel kachhap
@ 2013-08-18 21:59     ` Kukjin Kim
  0 siblings, 0 replies; 67+ messages in thread
From: Kukjin Kim @ 2013-08-18 21:59 UTC (permalink / raw)
  To: 'amit daniel kachhap', 'Viresh Kumar'
  Cc: 'Rafael J. Wysocki',
	linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

amit daniel kachhap wrote:
> 
> On Sat, Aug 10, 2013 at 12:13 PM, Viresh Kumar <viresh.kumar@linaro.org>
> wrote:
> > Drivers which have an exit path must call
> cpufreq_frequency_table_put_attr() if
> > they have called cpufreq_frequency_table_get_attr() in their init path.
> >
> > This driver was missing this part and is fixed with this patch.
> >
> > Cc: Kukjin Kim <kgene.kim@samsung.com>

Acked-by: Kukjin Kim <kgene.kim@samsung.com>

Thanks,
Kukjin

> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> The changes looks fine, please free to add
> Acked-By: Amit Daniel Kachhap <amit.daniel@samsung.com>
> 
> Thanks.
> Amit Daniel
> 
> 
> > ---
> >  drivers/cpufreq/exynos5440-cpufreq.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/cpufreq/exynos5440-cpufreq.c
> b/drivers/cpufreq/exynos5440-cpufreq.c
> > index 1ac93e0..b9dfc91 100644
> > --- a/drivers/cpufreq/exynos5440-cpufreq.c
> > +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> > @@ -336,12 +336,18 @@ static int exynos_cpufreq_cpu_init(struct
> cpufreq_policy *policy)
> >         return 0;
> >  }
> >
> > +static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
> > +{
> > +       cpufreq_frequency_table_put_attr(policy->cpu);
> > +}
> > +
> >  static struct cpufreq_driver exynos_driver = {
> >         .flags          = CPUFREQ_STICKY,
> >         .verify         = exynos_verify_speed,
> >         .target         = exynos_target,
> >         .get            = exynos_getspeed,
> >         .init           = exynos_cpufreq_cpu_init,
> > +       .exit           = exynos_cpufreq_cpu_exit,
> >         .name           = CPUFREQ_NAME,
> >  };
> >
> > --
> > 1.7.12.rc2.18.g61b472e
> >
> > --
> > 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
> 
> On Sat, Aug 10, 2013 at 12:13 PM, Viresh Kumar <viresh.kumar@linaro.org>
> wrote:
> > Drivers which have an exit path must call
> cpufreq_frequency_table_put_attr() if
> > they have called cpufreq_frequency_table_get_attr() in their init path.
> >
> > This driver was missing this part and is fixed with this patch.
> >
> > Cc: Kukjin Kim <kgene.kim@samsung.com>
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> > ---
> >  drivers/cpufreq/exynos5440-cpufreq.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/cpufreq/exynos5440-cpufreq.c
> b/drivers/cpufreq/exynos5440-cpufreq.c
> > index 1ac93e0..b9dfc91 100644
> > --- a/drivers/cpufreq/exynos5440-cpufreq.c
> > +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> > @@ -336,12 +336,18 @@ static int exynos_cpufreq_cpu_init(struct
> cpufreq_policy *policy)
> >         return 0;
> >  }
> >
> > +static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
> > +{
> > +       cpufreq_frequency_table_put_attr(policy->cpu);
> > +}
> > +
> >  static struct cpufreq_driver exynos_driver = {
> >         .flags          = CPUFREQ_STICKY,
> >         .verify         = exynos_verify_speed,
> >         .target         = exynos_target,
> >         .get            = exynos_getspeed,
> >         .init           = exynos_cpufreq_cpu_init,
> > +       .exit           = exynos_cpufreq_cpu_exit,
> >         .name           = CPUFREQ_NAME,
> >  };
> >
> > --
> > 1.7.12.rc2.18.g61b472e


^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [PATCH 19/44] cpufreq: exynos: Use generic cpufreq routines
  2013-08-18 10:03   ` amit daniel kachhap
@ 2013-08-18 22:00     ` Kukjin Kim
  0 siblings, 0 replies; 67+ messages in thread
From: Kukjin Kim @ 2013-08-18 22:00 UTC (permalink / raw)
  To: 'amit daniel kachhap', 'Viresh Kumar'
  Cc: 'Rafael J. Wysocki',
	linaro-kernel, patches, cpufreq, linux-pm, linux-kernel

amit daniel kachhap wrote:
> 
> On Sat, Aug 10, 2013 at 12:14 PM, Viresh Kumar <viresh.kumar@linaro.org>
> wrote:
> > Most of the CPUFreq drivers do similar things in .exit() and .verify()
> routines
> > and .attr. So its better if we have generic routines for them which can
> be used
> > by cpufreq drivers then.
> >
> > This patch uses these generic routines for this driver.
> >
> > Cc: Kukjin Kim <kgene.kim@samsung.com>

Looks good.

Acked-by: Kukjin Kim <kgene.kim@samsung.com>

Thanks,
Kukjin

> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> The consolidation code looks fine,
> Acked-By: Amit Daniel Kachhap <amit.daniel@samsung.com>
> 
> Thanks,
> Amit Daniel
> > ---
> >  drivers/cpufreq/exynos-cpufreq.c     | 23 +++--------------------
> >  drivers/cpufreq/exynos5440-cpufreq.c | 15 ++-------------
> >  2 files changed, 5 insertions(+), 33 deletions(-)
> >
> > diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-
> cpufreq.c
> > index 71c4926..7663a96 100644
> > --- a/drivers/cpufreq/exynos-cpufreq.c
> > +++ b/drivers/cpufreq/exynos-cpufreq.c
> > @@ -31,12 +31,6 @@ static unsigned int locking_frequency;
> >  static bool frequency_locked;
> >  static DEFINE_MUTEX(cpufreq_lock);
> >
> > -static int exynos_verify_speed(struct cpufreq_policy *policy)
> > -{
> > -       return cpufreq_frequency_table_verify(policy,
> > -                                             exynos_info->freq_table);
> > -}
> > -
> >  static unsigned int exynos_getspeed(unsigned int cpu)
> >  {
> >         return clk_get_rate(exynos_info->cpu_clk) / 1000;
> > @@ -257,26 +251,15 @@ static int exynos_cpufreq_cpu_init(struct
> cpufreq_policy *policy)
> >         return cpufreq_table_validate_and_show(policy, exynos_info-
> >freq_table);
> >  }
> >
> > -static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
> > -{
> > -       cpufreq_frequency_table_put_attr(policy->cpu);
> > -       return 0;
> > -}
> > -
> > -static struct freq_attr *exynos_cpufreq_attr[] = {
> > -       &cpufreq_freq_attr_scaling_available_freqs,
> > -       NULL,
> > -};
> > -
> >  static struct cpufreq_driver exynos_driver = {
> >         .flags          = CPUFREQ_STICKY,
> > -       .verify         = exynos_verify_speed,
> > +       .verify         = cpufreq_generic_frequency_table_verify,
> >         .target         = exynos_target,
> >         .get            = exynos_getspeed,
> >         .init           = exynos_cpufreq_cpu_init,
> > -       .exit           = exynos_cpufreq_cpu_exit,
> > +       .exit           = cpufreq_generic_exit,
> >         .name           = "exynos_cpufreq",
> > -       .attr           = exynos_cpufreq_attr,
> > +       .attr           = cpufreq_generic_attr,
> >  #ifdef CONFIG_PM
> >         .suspend        = exynos_cpufreq_suspend,
> >         .resume         = exynos_cpufreq_resume,
> > diff --git a/drivers/cpufreq/exynos5440-cpufreq.c
> b/drivers/cpufreq/exynos5440-cpufreq.c
> > index b9dfc91..f139b3b 100644
> > --- a/drivers/cpufreq/exynos5440-cpufreq.c
> > +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> > @@ -209,12 +209,6 @@ static void exynos_enable_dvfs(void)
> >                                 dvfs_info->base + XMU_DVFS_CTRL);
> >  }
> >
> > -static int exynos_verify_speed(struct cpufreq_policy *policy)
> > -{
> > -       return cpufreq_frequency_table_verify(policy,
> > -                                             dvfs_info->freq_table);
> > -}
> > -
> >  static unsigned int exynos_getspeed(unsigned int cpu)
> >  {
> >         return dvfs_info->cur_frequency;
> > @@ -336,18 +330,13 @@ static int exynos_cpufreq_cpu_init(struct
> cpufreq_policy *policy)
> >         return 0;
> >  }
> >
> > -static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
> > -{
> > -       cpufreq_frequency_table_put_attr(policy->cpu);
> > -}
> > -
> >  static struct cpufreq_driver exynos_driver = {
> >         .flags          = CPUFREQ_STICKY,
> > -       .verify         = exynos_verify_speed,
> > +       .verify         = cpufreq_generic_frequency_table_verify,
> >         .target         = exynos_target,
> >         .get            = exynos_getspeed,
> >         .init           = exynos_cpufreq_cpu_init,
> > -       .exit           = exynos_cpufreq_cpu_exit,
> > +       .exit           = cpufreq_generic_exit,
> >         .name           = CPUFREQ_NAME,
> >  };
> >
> > --
> > 1.7.12.rc2.18.g61b472e


^ permalink raw reply	[flat|nested] 67+ messages in thread

end of thread, other threads:[~2013-08-18 22:00 UTC | newest]

Thread overview: 67+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-10  6:43 [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar
2013-08-10  6:43 ` [PATCH 01/44] cpufreq: arm_big_little: call cpufreq_frequency_table_put_attr() Viresh Kumar
2013-08-10  6:43 ` [PATCH 02/44] cpufreq: blackfin: " Viresh Kumar
2013-08-10  6:43 ` [PATCH 03/44] cpufreq: exynos: " Viresh Kumar
2013-08-12  6:18   ` Viresh Kumar
2013-08-18 10:00   ` amit daniel kachhap
2013-08-18 21:59     ` Kukjin Kim
2013-08-10  6:44 ` [PATCH 04/44] cpufreq: loongson2: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 05/44] cpufreq: omap: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 06/44] cpufreq: pxa: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 07/44] cpufreq: sparc: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 08/44] cpufreq: define generic .attr, .exit() and .verify() routines Viresh Kumar
2013-08-10  6:44 ` [PATCH 09/44] cpufreq: acpi: Use generic cpufreq routines Viresh Kumar
2013-08-10  6:44 ` [PATCH 10/44] cpufreq: arm_big_little: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 11/44] cpufreq: at32ap: " Viresh Kumar
2013-08-10  8:23   ` Hans-Christian Egtvedt
2013-08-12  6:07     ` Viresh Kumar
2013-08-12  7:10       ` Hans-Christian Egtvedt
2013-08-12  7:13         ` Viresh Kumar
2013-08-12  7:30           ` Hans-Christian Egtvedt
2013-08-12  7:39             ` Viresh Kumar
2013-08-12 19:11               ` Hans-Christian Egtvedt
2013-08-13  4:54                 ` Viresh Kumar
2013-08-10  6:44 ` [PATCH 12/44] cpufreq: blackfin: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 13/44] cpufreq: cpu0: " Viresh Kumar
2013-08-12  7:58   ` Shawn Guo
2013-08-10  6:44 ` [PATCH 14/44] cpufreq: cris: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 15/44] cpufreq: davinci: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 16/44] cpufreq: dbx500: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 17/44] cpufreq: e_powersaver: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 18/44] cpufreq: elanfreq: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 19/44] cpufreq: exynos: " Viresh Kumar
2013-08-18 10:03   ` amit daniel kachhap
2013-08-18 22:00     ` Kukjin Kim
2013-08-10  6:44 ` [PATCH 20/44] cpufreq: ia64-acpi: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 21/44] cpufreq: imx6q: " Viresh Kumar
2013-08-12  7:58   ` Shawn Guo
2013-08-12  8:10     ` Viresh Kumar
2013-08-12  8:34       ` Shawn Guo
2013-08-10  6:44 ` [PATCH 22/44] cpufreq: kirkwood: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 23/44] cpufreq: longhaul: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 24/44] cpufreq: loongson2: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 25/44] cpufreq: maple: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 26/44] cpufreq: omap: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 27/44] cpufreq: p4-clockmod: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 28/44] cpufreq: pasemi: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 29/44] cpufreq: pcc: " Viresh Kumar
2013-08-12  6:08   ` Viresh Kumar
2013-08-10  6:44 ` [PATCH 30/44] cpufreq: pmac: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 31/44] cpufreq: powernow: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 32/44] cpufreq: ppc-corenet: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 33/44] cpufreq: ppc_cbe: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 34/44] cpufreq: pxa: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 35/44] cpufreq: s3cx4xx: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 36/44] cpufreq: s5pv210: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 37/44] cpufreq: sc520: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 38/44] cpufreq: sh: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 39/44] cpufreq: sparc: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 40/44] cpufreq: spear: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 41/44] cpufreq: speedstep: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 42/44] cpufreq: tegra: " Viresh Kumar
2013-08-10  6:44 ` [PATCH 43/44] cpufreq: unicore2: " Viresh Kumar
2013-08-12  6:08   ` Viresh Kumar
2013-08-10  6:44 ` [PATCH 44/44] cpufreq: pass suitable index instead of freq to cpufreq_driver->target() Viresh Kumar
2013-08-10  7:45   ` Viresh Kumar
2013-08-12  6:50   ` Viresh Kumar
2013-08-10  7:46 ` [PATCH 00/44] cpufreq: define generic routines for cpufreq drivers: for 3.13 Viresh Kumar

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).