2013-09-13 13:03:07

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 000/228] CPUFreq: cleanup stuff for 3.13

This is my biggest patchset ever and it might not happen again in my entire
career. I hope I haven't screwed up here :)

CPUFreq cleanup patches are ready to hit linux-next (I hope it doesn't turn out
into horror stories, where it broke all possible architectures where Linux runs
:))

Most of these are build tested only, Also done by: Fengguang Wu's build bot.

All of these were sent separately in smaller patchsets earlier and now merged
together as a single set. Some parts are reviewed by platform maintainers and
their Acks are included in the patches (Sorry if I missed any)..

These are rebased over today's pm/linux-next:
f74a274 Merge branch 'pm-cpufreq-next' into linux-next

with following patches over it, which I expect to get into Rafael's tree before
these:
cpufreq: use correct values of cpus in __cpufreq_remove_dev_finish()
cpufreq: distinguish drivers that do asynchronous notifications
cpufreq: make sure frequency transitions are serialized
cpufreq: Create cpufreq_transition_complete()
cpufreq: powernow-k8: mark freq transition complete on error cases

There are few new patches here which haven't been sent yet and only came out
after discussions with Maintainers about their platforms:
cpufreq: loongson2: use cpufreq_generic_init() routine
cpufreq: davinci: use cpufreq_generic_init() routine
cpufreq: cris: use cpufreq_generic_init() routine
cpufreq: omap: use cpufreq_generic_init() routine

As suggested by Rafael earlier, he might not apply all at once and will give
people some chance to test sets one by one.. So, first set now, next one after
few days. So, I am marking different sets with patch numbers to make it easier
for Rafael.

- Patch 1->8: Generic cleanup of cpufreq core (First batch)
- Patch 9->54: Mostly about cpufreq_table_validate_and_show() helper (First batch)
- Patch 55->89: New generic routines for cpufreq drivers (First/Second batch)
- Patch 90->126: About calling cpufreq_driver->get() from core (First/Second batch)
- Patch 127->146: Generic init() routine (First/Second batch)
- Patch 147->180: Light weight ->target() routine (Third batch)
- Patch 181->211: Call notifiers from core instead of target() (Third/Fourth batch)
- Patch 212->228: Generic get() (Fifth batch)

As suggested by Amit here, Linaro may try to test linux-next with these patches
on Linaro's board farm (Mostly ARM and X86)..

https://lkml.org/lkml/2013/9/11/346

--
viresh

Hans-Christian Egtvedt (1):
cpufreq: at32ap: add frequency table

Viresh Kumar (227):
cpufreq: Remove extra blank line
cpufreq: don't break string in print statements
cpufreq: remove __cpufreq_remove_dev()
cpufreq: Optimize cpufreq_frequency_table_verify()
cpufreq: rename __cpufreq_set_policy() as cpufreq_set_policy()
cpufreq: rewrite cpufreq_driver->flags using shift operator
cpufreq: use cpufreq_driver->flags to mark
CPUFREQ_HAVE_GOVERNOR_PER_POLICY
cpufreq: add new routine cpufreq_verify_within_cpu_limits()
cpufreq: Add new helper cpufreq_table_validate_and_show()
cpufreq: pxa: call cpufreq_frequency_table_get_attr()
cpufreq: s3cx4xx: call cpufreq_frequency_table_get_attr()
cpufreq: sparc: call cpufreq_frequency_table_get_attr()
cpufreq: acpi-cpufreq: use cpufreq_table_validate_and_show()
cpufreq: arm_big_little: use cpufreq_table_validate_and_show()
cpufreq: blackfin: use cpufreq_table_validate_and_show()
cpufreq: cpufreq-cpu0: use cpufreq_table_validate_and_show()
cpufreq: cris: use cpufreq_table_validate_and_show()
cpufreq: davinci: use cpufreq_table_validate_and_show()
cpufreq: dbx500: use cpufreq_table_validate_and_show()
cpufreq: e_powersaver: use cpufreq_table_validate_and_show()
cpufreq: elanfreq: use cpufreq_table_validate_and_show()
cpufreq: exynos: use cpufreq_table_validate_and_show()
cpufreq: ia64-acpi: use cpufreq_table_validate_and_show()
cpufreq: imx6q: use cpufreq_table_validate_and_show()
cpufreq: kirkwood: use cpufreq_table_validate_and_show()
cpufreq: longhaul: use cpufreq_table_validate_and_show()
cpufreq: loongson2: use cpufreq_table_validate_and_show()
cpufreq: maple: use cpufreq_table_validate_and_show()
cpufreq: omap: use cpufreq_table_validate_and_show()
cpufreq: p4-clockmod: use cpufreq_table_validate_and_show()
cpufreq: pasemi: use cpufreq_table_validate_and_show()
cpufreq: pmac: use cpufreq_table_validate_and_show()
cpufreq: powernow: use cpufreq_table_validate_and_show()
cpufreq: ppc: use cpufreq_table_validate_and_show()
cpufreq: pxa: use cpufreq_table_validate_and_show()
cpufreq: s3cx4xx: use cpufreq_table_validate_and_show()
cpufreq: s5pv210: use cpufreq_table_validate_and_show()
cpufreq: sa11x0: Expose frequency table
cpufreq: sa11x0: let cpufreq core initialize struct policy fields
cpufreq: sc520: use cpufreq_table_validate_and_show()
cpufreq: sh: use cpufreq_table_validate_and_show()
cpufreq: sparc: use cpufreq_table_validate_and_show()
cpufreq: spear: use cpufreq_table_validate_and_show()
cpufreq: speedstep: use cpufreq_table_validate_and_show()
cpufreq: tegra: use cpufreq_table_validate_and_show()
cpufreq: tegra: fix implementation of ->exit()
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: 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: sa11x0: 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: call cpufreq_driver->get() after calling ->init()
cpufreq: acpi: don't initialize part of policy that is set by core
too
cpufreq: arm_big_little: don't initialize part of policy that is set
by core too
cpufreq: at32ap: don't initialize part of policy that is set by core
too
cpufreq: blackfin: don't initialize part of policy that is set by
core too
cpufreq: cpu0: don't initialize part of policy that is set by core
too
cpufreq: nforce2: don't initialize part of policy that is set by core
too
cpufreq: cris: don't initialize part of policy that is set by core
too
cpufreq: davinci: don't initialize part of policy that is set by core
too
cpufreq: dbx500: don't initialize part of policy that is set by core
too
cpufreq: e_powersaver: don't initialize part of policy that is set by
core too
cpufreq: elanfreq: don't initialize part of policy that is set by
core too
cpufreq: exynos: don't initialize part of policy that is set by core
too
cpufreq: gx: don't initialize part of policy that is set by core too
cpufreq: ia64-acpi: don't initialize part of policy that is set by
core too
cpufreq: imx6q: don't initialize part of policy that is set by core
too
cpufreq: integrator: don't initialize part of policy that is set by
core too
cpufreq: kirkwood: don't initialize part of policy that is set by
core too
cpufreq: longhaul: don't initialize part of policy that is set by
core too
cpufreq: loongson2: don't initialize part of policy that is set by
core too
cpufreq: maple: don't initialize part of policy that is set by core
too
cpufreq: omap: don't initialize part of policy that is set by core
too
cpufreq: p4: don't initialize part of policy that is set by core too
cpufreq: pcc: don't initialize part of policy that is set by core too
cpufreq: pmac: don't initialize part of policy that is set by core
too
cpufreq: powernow: don't initialize part of policy that is set by
core too
cpufreq: ppc: don't initialize part of policy that is set by core too
cpufreq: pxa: don't initialize part of policy that is set by core too
cpufreq: s3c: don't initialize part of policy that is set by core too
cpufreq: s5pv210: don't initialize part of policy that is set by core
too
cpufreq: sa11x0: don't initialize part of policy that is set by core
too
cpufreq: sc520_freq: don't initialize part of policy that is set by
core too
cpufreq: sh: don't initialize part of policy that is set by core too
cpufreq: spear: don't initialize part of policy that is set by core
too
cpufreq: speedstep: don't initialize part of policy that is set by
core too
cpufreq: tegra: don't initialize part of policy that is set by core
too
cpufreq: unicore2: don't initialize part of policy that is set by
core too
cpufreq: create cpufreq_generic_init() routine
cpufreq: remove CONFIG_CPU_FREQ_TABLE
cpufreq: cpu0: use cpufreq_generic_init() routine
cpufreq: cris: use cpufreq_generic_init() routine
cpufreq: davinci: use cpufreq_generic_init() routine
cpufreq: dbx500: use cpufreq_generic_init() routine
cpufreq: exynos: use cpufreq_generic_init() routine
cpufreq: imx6q: use cpufreq_generic_init() routine
cpufreq: kirkwood: use cpufreq_generic_init() routine
cpufreq: loongson2: use cpufreq_generic_init() routine
cpufreq: maple: use cpufreq_generic_init() routine
cpufreq: omap: use cpufreq_generic_init() routine
cpufreq: pasemi: use cpufreq_generic_init() routine
cpufreq: pmac32: use cpufreq_generic_init() routine
cpufreq: pmac64: use cpufreq_generic_init() routine
cpufreq: s3c: use cpufreq_generic_init() routine
cpufreq: s5pv210: use cpufreq_generic_init() routine
cpufreq: sa11x0: use cpufreq_generic_init() routine
cpufreq: spear: use cpufreq_generic_init() routine
cpufreq: tegra: use cpufreq_generic_init() routine
cpufreq: Implement light weight ->target_index() routine
cpufreq: acpi: Convert to light weight ->target_index() routine
cpufreq: arm_big_little: Convert to light weight ->target_index()
routine
cpufreq: at32ap: Convert to light weight ->target_index() routine
cpufreq: blackfin: Convert to light weight ->target_index() routine
cpufreq: cpu0: Convert to light weight ->target_index() routine
cpufreq: cris: Convert to light weight ->target_index() routine
cpufreq: davinci: Convert to light weight ->target_index() routine
cpufreq: dbx500: Convert to light weight ->target_index() routine
cpufreq: e_powersaver: Convert to light weight ->target_index()
routine
cpufreq: elanfreq: Convert to light weight ->target_index() routine
cpufreq: exynos: Convert to light weight ->target_index() routine
cpufreq: ia64: Convert to light weight ->target_index() routine
cpufreq: imx6q: Convert to light weight ->target_index() routine
cpufreq: kirkwood: Convert to light weight ->target_index() routine
cpufreq: longhaul: Convert to light weight ->target_index() routine
cpufreq: loongson2: Convert to light weight ->target_index() routine
cpufreq: maple: Convert to light weight ->target_index() routine
cpufreq: omap: Convert to light weight ->target_index() routine
cpufreq: p4: Convert to light weight ->target_index() routine
cpufreq: pasemi: Convert to light weight ->target_index() routine
cpufreq: pmac32: Convert to light weight ->target_index() routine
cpufreq: powernow: Convert to light weight ->target_index() routine
cpufreq: ppc: Convert to light weight ->target_index() routine
cpufreq: pxa: Convert to light weight ->target_index() routine
cpufreq: s3c2416: Convert to light weight ->target_index() routine
cpufreq: s3c64xx: Convert to light weight ->target_index() routine
cpufreq: s5pv210: Convert to light weight ->target_index() routine
cpufreq: sa11x0: Convert to light weight ->target_index() routine
cpufreq: sc520: Convert to light weight ->target_index() routine
cpufreq: sparc: Convert to light weight ->target_index() routine
cpufreq: SPEAr: Convert to light weight ->target_index() routine
cpufreq: speedstep: Convert to light weight ->target_index() routine
cpufreq: tegra: Convert to light weight ->target_index() routine
cpufreq: move freq change notifications to cpufreq core
cpufreq: acpi: remove calls to cpufreq_notify_transition()
cpufreq: arm_big_little: remove calls to cpufreq_notify_transition()
cpufreq: at32ap: remove calls to cpufreq_notify_transition()
cpufreq: blackfin: remove calls to cpufreq_notify_transition()
cpufreq: cpu0: remove calls to cpufreq_notify_transition()
cpufreq: cris: remove calls to cpufreq_notify_transition()
cpufreq: davinci: remove calls to cpufreq_notify_transition()
cpufreq: dbx500: remove calls to cpufreq_notify_transition()
cpufreq: e_powersaver: remove calls to cpufreq_notify_transition()
cpufreq: elanfreq: remove calls to cpufreq_notify_transition()
cpufreq: exynos: remove calls to cpufreq_notify_transition()
cpufreq: ia64-acpi: remove calls to cpufreq_notify_transition()
cpufreq: imx6q: remove calls to cpufreq_notify_transition()
cpufreq: kirkwood: remove calls to cpufreq_notify_transition()
cpufreq: loongson2: remove calls to cpufreq_notify_transition()
cpufreq: maple: remove calls to cpufreq_notify_transition()
cpufreq: omap: remove calls to cpufreq_notify_transition()
cpufreq: p4-clockmod: remove calls to cpufreq_notify_transition()
cpufreq: pasemi: remove calls to cpufreq_notify_transition()
cpufreq: pmac: remove calls to cpufreq_notify_transition()
cpufreq: ppc: remove calls to cpufreq_notify_transition()
cpufreq: pxa: remove calls to cpufreq_notify_transition()
cpufreq: s3c: remove calls to cpufreq_notify_transition()
cpufreq: s5pv210: remove calls to cpufreq_notify_transition()
cpufreq: sa11x0: remove calls to cpufreq_notify_transition()
cpufreq: sc520: remove calls to cpufreq_notify_transition()
cpufreq: sparc: remove calls to cpufreq_notify_transition()
cpufreq: SPEAr: remove calls to cpufreq_notify_transition()
cpufreq: speedstep: remove calls to cpufreq_notify_transition()
cpufreq: tegra: remove calls to cpufreq_notify_transition()
cpufreq: tegra: remove target_cpu_speed[] array
cpufreq: create cpufreq_generic_get() routine
cpufreq: arm_big_little: use cpufreq_generic_get() routine
cpufreq: at32ap: use cpufreq_generic_get() routine
cpufreq: cpu0: use cpufreq_generic_get() routine
cpufreq: davinci: use cpufreq_generic_get() routine
cpufreq: dbx500: use cpufreq_generic_get() routine
cpufreq: exynos: use cpufreq_generic_get() routine
cpufreq: imx6q: use cpufreq_generic_get() routine
cpufreq: loongson2: use cpufreq_generic_get() routine
cpufreq: omap: use cpufreq_generic_get() routine
cpufreq: ppc: use cpufreq_generic_get() routine
cpufreq: s3c: use cpufreq_generic_get() routine
cpufreq: s5pv210: use cpufreq_generic_get() routine
cpufreq: spear: use cpufreq_generic_get() routine
cpufreq: tegra: use cpufreq_generic_get() routine
cpufreq: unicore2: use cpufreq_generic_get() routine

Documentation/cpu-freq/cpu-drivers.txt | 27 ++--
Documentation/cpu-freq/governors.txt | 4 +-
arch/arm/mach-davinci/Kconfig | 1 -
arch/arm/mach-pxa/Kconfig | 3 -
arch/arm/mach-sa1100/generic.c | 81 +++---------
arch/arm/mach-sa1100/generic.h | 4 +-
arch/arm/mach-ux500/Kconfig | 1 -
arch/blackfin/Kconfig | 1 -
arch/cris/Kconfig | 2 -
drivers/cpufreq/Kconfig | 11 --
drivers/cpufreq/Kconfig.arm | 11 --
drivers/cpufreq/Kconfig.powerpc | 6 -
drivers/cpufreq/Kconfig.x86 | 13 --
drivers/cpufreq/Makefile | 5 +-
drivers/cpufreq/acpi-cpufreq.c | 45 ++-----
drivers/cpufreq/arm_big_little.c | 75 ++----------
drivers/cpufreq/at32ap-cpufreq.c | 119 +++++++++---------
drivers/cpufreq/blackfin-cpufreq.c | 54 ++------
drivers/cpufreq/cpufreq-cpu0.c | 103 +++-------------
drivers/cpufreq/cpufreq-nforce2.c | 5 +-
drivers/cpufreq/cpufreq.c | 217 +++++++++++++++++++++++++--------
drivers/cpufreq/cpufreq_governor.h | 5 +-
drivers/cpufreq/cris-artpec3-cpufreq.c | 64 +---------
drivers/cpufreq/cris-etraxfs-cpufreq.c | 61 +--------
drivers/cpufreq/davinci-cpufreq.c | 87 +++----------
drivers/cpufreq/dbx500-cpufreq.c | 97 ++-------------
drivers/cpufreq/e_powersaver.c | 59 ++-------
drivers/cpufreq/elanfreq.c | 88 ++-----------
drivers/cpufreq/exynos-cpufreq.c | 93 +++-----------
drivers/cpufreq/exynos5440-cpufreq.c | 84 ++++---------
drivers/cpufreq/freq_table.c | 59 ++++++---
drivers/cpufreq/gx-suspmod.c | 5 +-
drivers/cpufreq/ia64-acpi-cpufreq.c | 71 +----------
drivers/cpufreq/imx6q-cpufreq.c | 99 ++++-----------
drivers/cpufreq/integrator-cpufreq.c | 14 +--
drivers/cpufreq/intel_pstate.c | 4 +-
drivers/cpufreq/kirkwood-cpufreq.c | 107 ++++------------
drivers/cpufreq/longhaul.c | 45 +------
drivers/cpufreq/longrun.c | 4 +-
drivers/cpufreq/loongson2_cpufreq.c | 72 ++---------
drivers/cpufreq/maple-cpufreq.c | 56 +--------
drivers/cpufreq/omap-cpufreq.c | 158 ++++++------------------
drivers/cpufreq/p4-clockmod.c | 53 ++------
drivers/cpufreq/pasemi-cpufreq.c | 51 +-------
drivers/cpufreq/pcc-cpufreq.c | 10 +-
drivers/cpufreq/pmac32-cpufreq.c | 53 ++------
drivers/cpufreq/pmac64-cpufreq.c | 57 +--------
drivers/cpufreq/powernow-k6.c | 67 ++--------
drivers/cpufreq/powernow-k7.c | 42 ++-----
drivers/cpufreq/powernow-k8.c | 53 ++------
drivers/cpufreq/ppc-corenet-cpufreq.c | 69 ++---------
drivers/cpufreq/ppc_cbe_cpufreq.c | 50 +-------
drivers/cpufreq/pxa2xx-cpufreq.c | 70 +++--------
drivers/cpufreq/pxa3xx-cpufreq.c | 46 ++-----
drivers/cpufreq/s3c2416-cpufreq.c | 67 ++--------
drivers/cpufreq/s3c24xx-cpufreq.c | 37 +-----
drivers/cpufreq/s3c64xx-cpufreq.c | 108 +++++-----------
drivers/cpufreq/s5pv210-cpufreq.c | 105 ++++------------
drivers/cpufreq/sa1100-cpufreq.c | 49 ++------
drivers/cpufreq/sa1110-cpufreq.c | 46 ++-----
drivers/cpufreq/sc520_freq.c | 64 +---------
drivers/cpufreq/sh-cpufreq.c | 22 +---
drivers/cpufreq/sparc-us2e-cpufreq.c | 42 ++-----
drivers/cpufreq/sparc-us3-cpufreq.c | 44 ++-----
drivers/cpufreq/spear-cpufreq.c | 72 ++---------
drivers/cpufreq/speedstep-centrino.c | 81 ++----------
drivers/cpufreq/speedstep-ich.c | 85 ++-----------
drivers/cpufreq/speedstep-smi.c | 76 ++----------
drivers/cpufreq/tegra-cpufreq.c | 114 ++++-------------
drivers/cpufreq/unicore2-cpufreq.c | 26 ++--
drivers/thermal/Kconfig | 1 -
include/linux/cpufreq.h | 59 ++++++---
72 files changed, 922 insertions(+), 2917 deletions(-)

--
1.7.12.rc2.18.g61b472e


2013-09-13 13:03:14

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 001/228] cpufreq: Remove extra blank line

We don't need a blank line just at start of a block, lets remove it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 005eb73..3d5e6d6 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1240,7 +1240,6 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
if (!frozen)
sysfs_remove_link(&dev->kobj, "cpufreq");
} else if (cpus > 1) {
-
new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen);
if (new_cpu >= 0) {
WARN_ON(lock_policy_rwsem_write(cpu));
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:03:20

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 002/228] cpufreq: don't break string in print statements

As a rule its better not to break string (quoted inside "") in a print statement
even if it crosses 80 column boundary as that may introduce unwanted bugs and so
this patch rewrites one of the print statements..

Reviewed-by: Srivatsa S. Bhat <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 3d5e6d6..6a8cae9 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1247,8 +1247,8 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
unlock_policy_rwsem_write(cpu);

if (!frozen) {
- pr_debug("%s: policy Kobject moved to cpu: %d "
- "from: %d\n",__func__, new_cpu, cpu);
+ pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n",
+ __func__, new_cpu, cpu);
}
}
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:03:29

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 003/228] cpufreq: remove __cpufreq_remove_dev()

Nobody except cpufreq_remove_dev() is calling __cpufreq_remove_dev() and so we
don't need separate routines here. Lets merge code from __cpufreq_remove_dev()
to cpufreq_remove_dev() and get rid of __cpufreq_remove_dev().

Reviewed-by: Srivatsa S. Bhat <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6a8cae9..e217d8f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1343,36 +1343,26 @@ static int __cpufreq_remove_dev_finish(struct device *dev,
}

/**
- * __cpufreq_remove_dev - remove a CPU device
+ * cpufreq_remove_dev - remove a CPU device
*
* Removes the cpufreq interface for a CPU device.
* Caller should already have policy_rwsem in write mode for this CPU.
* This routine frees the rwsem before returning.
*/
-static inline int __cpufreq_remove_dev(struct device *dev,
- struct subsys_interface *sif,
- bool frozen)
-{
- int ret;
-
- ret = __cpufreq_remove_dev_prepare(dev, sif, frozen);
-
- if (!ret)
- ret = __cpufreq_remove_dev_finish(dev, sif, frozen);
-
- return ret;
-}
-
static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
{
unsigned int cpu = dev->id;
- int retval;
+ int ret;

if (cpu_is_offline(cpu))
return 0;

- retval = __cpufreq_remove_dev(dev, sif, false);
- return retval;
+ ret = __cpufreq_remove_dev_prepare(dev, sif, false);
+
+ if (!ret)
+ ret = __cpufreq_remove_dev_finish(dev, sif, false);
+
+ return ret;
}

static void handle_update(struct work_struct *work)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:03:33

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 004/228] cpufreq: Optimize cpufreq_frequency_table_verify()

cpufreq_frequency_table_verify() is a bit rewritten here to make it more logical
and optimal.
- merge multiple lines for variable declarations together.
- quit early if any frequency between min/max is found.
- don't call cpufreq_verify_within_limits() in case any valid freq is found as
it is of no use.
- count renamed as found and made a boolean.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/freq_table.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index f111454a..53a2f1a 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -54,9 +54,8 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo);
int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table)
{
- unsigned int next_larger = ~0;
- unsigned int i;
- unsigned int count = 0;
+ unsigned int next_larger = ~0, freq, i = 0;
+ bool found = false;

pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n",
policy->min, policy->max, policy->cpu);
@@ -64,21 +63,23 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
policy->cpuinfo.max_freq);

- for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
- unsigned int freq = table[i].frequency;
+ for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) {
if (freq == CPUFREQ_ENTRY_INVALID)
continue;
- if ((freq >= policy->min) && (freq <= policy->max))
- count++;
- else if ((next_larger > freq) && (freq > policy->max))
+ if ((freq >= policy->min) && (freq <= policy->max)) {
+ found = true;
+ break;
+ }
+
+ if ((next_larger > freq) && (freq > policy->max))
next_larger = freq;
}

- if (!count)
+ if (!found) {
policy->max = next_larger;
-
- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
+ cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
+ policy->cpuinfo.max_freq);
+ }

pr_debug("verification lead to (%u - %u kHz) for cpu %u\n",
policy->min, policy->max, policy->cpu);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:03:42

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 005/228] cpufreq: rename __cpufreq_set_policy() as cpufreq_set_policy()

Earlier there used to be two functions named __cpufreq_set_policy() and
cpufreq_set_policy(), but now we only have a single routine lets name it
cpufreq_set_policy() instead of __cpufreq_set_policy().

This also removes some invalid comments or fixes some incorrect comments.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index e217d8f..d5fb343 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -457,7 +457,7 @@ show_one(scaling_min_freq, min);
show_one(scaling_max_freq, max);
show_one(scaling_cur_freq, cur);

-static int __cpufreq_set_policy(struct cpufreq_policy *policy,
+static int cpufreq_set_policy(struct cpufreq_policy *policy,
struct cpufreq_policy *new_policy);

/**
@@ -478,7 +478,7 @@ static ssize_t store_##file_name \
if (ret != 1) \
return -EINVAL; \
\
- ret = __cpufreq_set_policy(policy, &new_policy); \
+ ret = cpufreq_set_policy(policy, &new_policy); \
policy->user_policy.object = policy->object; \
\
return ret ? ret : count; \
@@ -536,11 +536,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
&new_policy.governor))
return -EINVAL;

- /*
- * Do not use cpufreq_set_policy here or the user_policy.max
- * will be wrongly overridden
- */
- ret = __cpufreq_set_policy(policy, &new_policy);
+ ret = cpufreq_set_policy(policy, &new_policy);

policy->user_policy.policy = policy->policy;
policy->user_policy.governor = policy->governor;
@@ -887,11 +883,11 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy)
int ret = 0;

memcpy(&new_policy, policy, sizeof(*policy));
- /* assure that the starting sequence is run in __cpufreq_set_policy */
+ /* assure that the starting sequence is run in cpufreq_set_policy */
policy->governor = NULL;

/* set default policy */
- ret = __cpufreq_set_policy(policy, &new_policy);
+ ret = cpufreq_set_policy(policy, &new_policy);
policy->user_policy.policy = policy->policy;
policy->user_policy.governor = policy->governor;

@@ -1932,10 +1928,10 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
EXPORT_SYMBOL(cpufreq_get_policy);

/*
- * data : current policy.
- * policy : policy to be set.
+ * policy : current policy.
+ * new_policy: policy to be set.
*/
-static int __cpufreq_set_policy(struct cpufreq_policy *policy,
+static int cpufreq_set_policy(struct cpufreq_policy *policy,
struct cpufreq_policy *new_policy)
{
int ret = 0, failed = 1;
@@ -2084,7 +2080,7 @@ int cpufreq_update_policy(unsigned int cpu)
}
}

- ret = __cpufreq_set_policy(policy, &new_policy);
+ ret = cpufreq_set_policy(policy, &new_policy);

unlock_policy_rwsem_write(cpu);

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:03:49

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 006/228] cpufreq: rewrite cpufreq_driver->flags using shift operator

Currently cpufreq_driver's flags are defined directly using 0x1, 0x2, 0x4, 0x8,
etc.. As the list grows it doesn't stays much readable..

Lets use bitwise shift operator << to generate these numbers for respective
positions.

Signed-off-by: Viresh Kumar <[email protected]>
---
include/linux/cpufreq.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 10ab22d..0eda235 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -212,19 +212,20 @@ struct cpufreq_driver {
};

/* flags */
-#define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
- * all ->init() calls failed */
-#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel
- * "constants" aren't affected by
- * frequency transitions */
-#define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed
- * mismatches */
+#define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
+ all ->init() calls failed */
+#define CPUFREQ_CONST_LOOPS (1 << 1) /* loops_per_jiffy or other
+ kernel "constants" aren't
+ affected by frequency
+ transitions */
+#define CPUFREQ_PM_NO_WARN (1 << 2) /* don't warn on suspend/resume
+ speed mismatches */
/*
* Driver will do POSTCHANGE notifications from outside of their ->target()
* routine and so must set cpufreq_driver->flags with this flag, so that core
* can handle them specially.
*/
-#define CPUFREQ_ASYNC_NOTIFICATION 0x08
+#define CPUFREQ_ASYNC_NOTIFICATION (1 << 3)

int cpufreq_register_driver(struct cpufreq_driver *driver_data);
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:03:54

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 007/228] cpufreq: use cpufreq_driver->flags to mark CPUFREQ_HAVE_GOVERNOR_PER_POLICY

Lets use cpufreq_driver->flags to mark CPUFREQ_HAVE_GOVERNOR_PER_POLICY instead
of a separate field within cpufreq_driver. This will save some bytes for us.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/arm_big_little.c | 4 ++--
drivers/cpufreq/cpufreq.c | 2 +-
drivers/cpufreq/cpufreq_governor.h | 5 ++++-
include/linux/cpufreq.h | 15 ++++++++-------
4 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 3549f07..768aa9c 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -214,13 +214,13 @@ static struct freq_attr *bL_cpufreq_attr[] = {

static struct cpufreq_driver bL_cpufreq_driver = {
.name = "arm-big-little",
- .flags = CPUFREQ_STICKY,
+ .flags = CPUFREQ_STICKY |
+ CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
.verify = bL_cpufreq_verify_policy,
.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,
};

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d5fb343..c7274e6 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -135,7 +135,7 @@ static DEFINE_MUTEX(cpufreq_governor_mutex);

bool have_governor_per_policy(void)
{
- return cpufreq_driver->have_governor_per_policy;
+ return !!(cpufreq_driver->flags & CPUFREQ_HAVE_GOVERNOR_PER_POLICY);
}
EXPORT_SYMBOL_GPL(have_governor_per_policy);

diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index 88cd39f..b5f2b86 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -191,7 +191,10 @@ struct common_dbs_data {
struct attribute_group *attr_group_gov_sys; /* one governor - system */
struct attribute_group *attr_group_gov_pol; /* one governor - policy */

- /* Common data for platforms that don't set have_governor_per_policy */
+ /*
+ * Common data for platforms that don't set
+ * CPUFREQ_HAVE_GOVERNOR_PER_POLICY
+ */
struct dbs_data *gdbs_data;

struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 0eda235..fef5f3c 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -181,13 +181,6 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
struct cpufreq_driver {
char name[CPUFREQ_NAME_LEN];
u8 flags;
- /*
- * This should be set by platforms having multiple clock-domains, i.e.
- * supporting multiple policies. With this sysfs directories of governor
- * would be created in cpu/cpu<num>/cpufreq/ directory and so they can
- * use the same governor with different tunables for different clusters.
- */
- bool have_governor_per_policy;

/* needed by all drivers */
int (*init) (struct cpufreq_policy *policy);
@@ -227,6 +220,14 @@ struct cpufreq_driver {
*/
#define CPUFREQ_ASYNC_NOTIFICATION (1 << 3)

+/*
+ * This should be set by platforms having multiple clock-domains, i.e.
+ * supporting multiple policies. With this sysfs directories of governor would
+ * be created in cpu/cpu<num>/cpufreq/ directory and so they can use the same
+ * governor with different tunables for different clusters.
+ */
+#define CPUFREQ_HAVE_GOVERNOR_PER_POLICY (1 << 4)
+
int cpufreq_register_driver(struct cpufreq_driver *driver_data);
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:04:11

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 009/228] cpufreq: Add new helper cpufreq_table_validate_and_show()

Almost every cpufreq driver is required to validate its frequency table with:
cpufreq_frequency_table_cpuinfo() and then expose it to cpufreq core with:
cpufreq_frequency_table_get_attr().

This patch creates another helper routine cpufreq_table_validate_and_show() that
will do both these steps in a single call and will return 0 for success, error
otherwise.

This also fixes potential bugs in cpufreq drivers where people have called
cpufreq_frequency_table_get_attr() before calling
cpufreq_frequency_table_cpuinfo(), as the later may fail.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/freq_table.c | 12 ++++++++++++
include/linux/cpufreq.h | 2 ++
2 files changed, 14 insertions(+)

diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 29ff77f..b9336ed 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -218,6 +218,18 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu)
}
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);

+int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table)
+{
+ int ret = cpufreq_frequency_table_cpuinfo(policy, table);
+
+ if (!ret)
+ cpufreq_frequency_table_get_attr(table, policy->cpu);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show);
+
void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy)
{
pr_debug("Updating show_table for new_cpu %u from last_cpu %u\n",
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 21f6543..e257407 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -433,5 +433,7 @@ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
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);

#endif /* _LINUX_CPUFREQ_H */
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:04:05

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 008/228] cpufreq: add new routine cpufreq_verify_within_cpu_limits()

Most of the users of cpufreq_verify_within_limits() calls it for limiting with
min/max from policy->cpuinfo. We can make that code simple by introducing
another routine which will do this for them automatically.

This patch adds another routine cpufreq_verify_within_cpu_limits() and updates
others to use it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq-nforce2.c | 4 +---
drivers/cpufreq/davinci-cpufreq.c | 4 +---
drivers/cpufreq/freq_table.c | 6 ++----
drivers/cpufreq/integrator-cpufreq.c | 9 ++-------
drivers/cpufreq/intel_pstate.c | 4 +---
drivers/cpufreq/longrun.c | 4 +---
drivers/cpufreq/pcc-cpufreq.c | 3 +--
drivers/cpufreq/sh-cpufreq.c | 7 ++-----
drivers/cpufreq/unicore2-cpufreq.c | 4 +---
include/linux/cpufreq.h | 7 +++++++
10 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c
index b83d45f6..56c964c 100644
--- a/drivers/cpufreq/cpufreq-nforce2.c
+++ b/drivers/cpufreq/cpufreq-nforce2.c
@@ -303,9 +303,7 @@ static int nforce2_verify(struct cpufreq_policy *policy)
if (policy->min < (fsb_pol_max * fid * 100))
policy->max = (fsb_pol_max + 1) * fid * 100;

- cpufreq_verify_within_limits(policy,
- policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
+ cpufreq_verify_within_cpu_limits(policy);
return 0;
}

diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index 551dd65..d049937 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -50,9 +50,7 @@ static int davinci_verify_speed(struct cpufreq_policy *policy)
if (policy->cpu)
return -EINVAL;

- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
-
+ cpufreq_verify_within_cpu_limits(policy);
policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000;
policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000;
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 53a2f1a..29ff77f 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -60,8 +60,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n",
policy->min, policy->max, policy->cpu);

- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
+ cpufreq_verify_within_cpu_limits(policy);

for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) {
if (freq == CPUFREQ_ENTRY_INVALID)
@@ -77,8 +76,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,

if (!found) {
policy->max = next_larger;
- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
+ cpufreq_verify_within_cpu_limits(policy);
}

pr_debug("verification lead to (%u - %u kHz) for cpu %u\n",
diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c
index f7c99df..8152a9b 100644
--- a/drivers/cpufreq/integrator-cpufreq.c
+++ b/drivers/cpufreq/integrator-cpufreq.c
@@ -59,9 +59,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy)
{
struct icst_vco vco;

- cpufreq_verify_within_limits(policy,
- policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
+ cpufreq_verify_within_cpu_limits(policy);

vco = icst_hz_to_vco(&cclk_params, policy->max * 1000);
policy->max = icst_hz(&cclk_params, vco) / 1000;
@@ -69,10 +67,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy)
vco = icst_hz_to_vco(&cclk_params, policy->min * 1000);
policy->min = icst_hz(&cclk_params, vco) / 1000;

- cpufreq_verify_within_limits(policy,
- policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
-
+ cpufreq_verify_within_cpu_limits(policy);
return 0;
}

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 9733f29..a02bd77 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -611,9 +611,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)

static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
{
- cpufreq_verify_within_limits(policy,
- policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
+ cpufreq_verify_within_cpu_limits(policy);

if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) &&
(policy->policy != CPUFREQ_POLICY_PERFORMANCE))
diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c
index 5aa0316..074971b 100644
--- a/drivers/cpufreq/longrun.c
+++ b/drivers/cpufreq/longrun.c
@@ -129,9 +129,7 @@ static int longrun_verify_policy(struct cpufreq_policy *policy)
return -EINVAL;

policy->cpu = 0;
- cpufreq_verify_within_limits(policy,
- policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
+ cpufreq_verify_within_cpu_limits(policy);

if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) &&
(policy->policy != CPUFREQ_POLICY_PERFORMANCE))
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
index d81c4e5..78787e9 100644
--- a/drivers/cpufreq/pcc-cpufreq.c
+++ b/drivers/cpufreq/pcc-cpufreq.c
@@ -111,8 +111,7 @@ 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);
+ cpufreq_verify_within_cpu_limits(policy);
return 0;
}

diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
index ffc6d24..f671aa1 100644
--- a/drivers/cpufreq/sh-cpufreq.c
+++ b/drivers/cpufreq/sh-cpufreq.c
@@ -87,15 +87,12 @@ static int sh_cpufreq_verify(struct cpufreq_policy *policy)
if (freq_table)
return cpufreq_frequency_table_verify(policy, freq_table);

- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
+ cpufreq_verify_within_cpu_limits(policy);

policy->min = (clk_round_rate(cpuclk, 1) + 500) / 1000;
policy->max = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;

- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
- policy->cpuinfo.max_freq);
-
+ cpufreq_verify_within_cpu_limits(policy);
return 0;
}

diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c
index b225f04..14e6d31 100644
--- a/drivers/cpufreq/unicore2-cpufreq.c
+++ b/drivers/cpufreq/unicore2-cpufreq.c
@@ -29,9 +29,7 @@ static 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);
-
+ cpufreq_verify_within_cpu_limits(policy);
return 0;
}

diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index fef5f3c..21f6543 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -256,6 +256,13 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
return;
}

+static inline void
+cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)
+{
+ cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
+ policy->cpuinfo.max_freq);
+}
+
/*********************************************************************
* CPUFREQ NOTIFIER INTERFACE *
*********************************************************************/
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:04:17

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 010/228] cpufreq: pxa: call cpufreq_frequency_table_get_attr()

This exposes frequency table of driver to cpufreq core and is required for core
to guess what the index for a target frequency is, when it calls
cpufreq_frequency_table_target(). And so this driver needs to expose it.

Cc: Eric Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pxa2xx-cpufreq.c | 6 +++++-
drivers/cpufreq/pxa3xx-cpufreq.c | 8 ++++++--
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 8749eaf18..5b8ce9a 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -453,10 +453,14 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
find_freq_tables(&pxa255_freq_table, &pxa255_freqs);
pr_info("PXA255 cpufreq using %s frequency table\n",
pxa255_turbo_table ? "turbo" : "run");
+
cpufreq_frequency_table_cpuinfo(policy, pxa255_freq_table);
+ cpufreq_frequency_table_get_attr(pxa255_freq_table, policy->cpu);
}
- else if (cpu_is_pxa27x())
+ else if (cpu_is_pxa27x()) {
cpufreq_frequency_table_cpuinfo(policy, pxa27x_freq_table);
+ cpufreq_frequency_table_get_attr(pxa27x_freq_table, policy->cpu);
+ }

printk(KERN_INFO "PXA CPU frequency change support initialized\n");

diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index d26306f..8f14234 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -91,7 +91,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy,
struct pxa3xx_freq_info *freqs, int num)
{
struct cpufreq_frequency_table *table;
- int i;
+ int i, ret;

table = kzalloc((num + 1) * sizeof(*table), GFP_KERNEL);
if (table == NULL)
@@ -108,7 +108,11 @@ static int setup_freqs_table(struct cpufreq_policy *policy,
pxa3xx_freqs_num = num;
pxa3xx_freqs_table = table;

- return cpufreq_frequency_table_cpuinfo(policy, table);
+ ret = cpufreq_frequency_table_cpuinfo(policy, table);
+ if (!ret)
+ cpufreq_frequency_table_get_attr(table, policy->cpu);
+
+ return ret;
}

static void __update_core_freq(struct pxa3xx_freq_info *info)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:04:31

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 012/228] cpufreq: sparc: call cpufreq_frequency_table_get_attr()

This exposes frequency table of driver to cpufreq core and is required for core
to guess what the index for a target frequency is, when it calls
cpufreq_frequency_table_target(). And so this driver needs to expose it.

Cc: David S. Miller <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sparc-us2e-cpufreq.c | 6 +++++-
drivers/cpufreq/sparc-us3-cpufreq.c | 7 ++++++-
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index cf5bc2c..80e6d92 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -307,6 +307,7 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
struct cpufreq_frequency_table *table =
&us2e_freq_table[cpu].table[0];
+ int ret;

table[0].driver_data = 0;
table[0].frequency = clock_tick / 1;
@@ -324,7 +325,10 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 0;
policy->cur = clock_tick;

- return cpufreq_frequency_table_cpuinfo(policy, table);
+ ret = cpufreq_frequency_table_cpuinfo(policy, table);
+ if (!ret)
+ cpufreq_frequency_table_get_attr(table, policy->cpu);
+ return ret;
}

static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index ac76b48..73a90de 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -168,6 +168,7 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
struct cpufreq_frequency_table *table =
&us3_freq_table[cpu].table[0];
+ int ret;

table[0].driver_data = 0;
table[0].frequency = clock_tick / 1;
@@ -181,7 +182,11 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 0;
policy->cur = clock_tick;

- return cpufreq_frequency_table_cpuinfo(policy, table);
+ ret = cpufreq_frequency_table_cpuinfo(policy, table);
+ if (!ret)
+ cpufreq_frequency_table_get_attr(table, policy->cpu);
+
+ return ret;
}

static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:04:26

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 011/228] cpufreq: s3cx4xx: call cpufreq_frequency_table_get_attr()

This exposes frequency table of driver to cpufreq core and is required for core
to guess what the index for a target frequency is, when it calls
cpufreq_frequency_table_target(). And so this driver needs to expose it.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s3c24xx-cpufreq.c | 4 +++-
drivers/cpufreq/s3c64xx-cpufreq.c | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index b0f343f..f2c872c 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -386,8 +386,10 @@ static int s3c_cpufreq_init(struct cpufreq_policy *policy)
/* feed the latency information from the cpu driver */
policy->cpuinfo.transition_latency = cpu_cur.info->latency;

- if (ftab)
+ if (ftab) {
cpufreq_frequency_table_cpuinfo(policy, ftab);
+ cpufreq_frequency_table_get_attr(ftab, policy->cpu);
+ }

return 0;
}
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 8a72b0c..9024043 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -257,6 +257,9 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
ret);
regulator_put(vddarm);
clk_put(armclk);
+ } else {
+ cpufreq_frequency_table_get_attr(s3c64xx_freq_table,
+ policy->cpu);
}

return ret;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:04:38

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 013/228] cpufreq: acpi-cpufreq: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/acpi-cpufreq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index a1260b4..71f8e15 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -837,7 +837,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
perf->state = 0;

- result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
+ result = cpufreq_table_validate_and_show(policy, data->freq_table);
if (result)
goto err_freqfree;

@@ -868,8 +868,6 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
(u32) perf->states[i].power,
(u32) perf->states[i].transition_latency);

- cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);
-
/*
* the first call to ->target() should result in us actually
* writing something to the appropriate registers.
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:04:57

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 015/228] cpufreq: blackfin: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Steven Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/blackfin-cpufreq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index ef05978..54c0a0c 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -210,8 +210,7 @@ static int __bfin_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 50000; /* 50us assumed */

policy->cur = cclk;
- cpufreq_frequency_table_get_attr(bfin_freq_table, policy->cpu);
- return cpufreq_frequency_table_cpuinfo(policy, bfin_freq_table);
+ return cpufreq_table_validate_and_show(policy, bfin_freq_table);
}

static struct freq_attr *bfin_freq_attr[] = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:04:48

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 014/228] cpufreq: arm_big_little: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/arm_big_little.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 768aa9c..8cb6dbc 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -165,7 +165,7 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)
if (ret)
return ret;

- ret = cpufreq_frequency_table_cpuinfo(policy, freq_table[cur_cluster]);
+ ret = cpufreq_table_validate_and_show(policy, freq_table[cur_cluster]);
if (ret) {
dev_err(cpu_dev, "CPU %d, cluster: %d invalid freq table\n",
policy->cpu, cur_cluster);
@@ -173,8 +173,6 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)
return ret;
}

- cpufreq_frequency_table_get_attr(freq_table[cur_cluster], policy->cpu);
-
if (arm_bL_ops->get_transition_latency)
policy->cpuinfo.transition_latency =
arm_bL_ops->get_transition_latency(cpu_dev);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:05:08

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 017/228] cpufreq: cris: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Jesper Nilsson <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cris-artpec3-cpufreq.c | 10 +---------
drivers/cpufreq/cris-etraxfs-cpufreq.c | 10 +---------
2 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index cb8276d..444fd96 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -76,19 +76,11 @@ static int cris_freq_target(struct cpufreq_policy *policy,

static int cris_freq_cpu_init(struct cpufreq_policy *policy)
{
- int result;
-
/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = 1000000; /* 1ms */
policy->cur = cris_freq_get_cpu_frequency(0);

- result = cpufreq_frequency_table_cpuinfo(policy, cris_freq_table);
- if (result)
- return (result);
-
- cpufreq_frequency_table_get_attr(cris_freq_table, policy->cpu);
-
- return 0;
+ return cpufreq_table_validate_and_show(policy, cris_freq_table);
}


diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index 72328f7..428395e 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -75,19 +75,11 @@ static int cris_freq_target(struct cpufreq_policy *policy,

static int cris_freq_cpu_init(struct cpufreq_policy *policy)
{
- int result;
-
/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = 1000000; /* 1ms */
policy->cur = cris_freq_get_cpu_frequency(0);

- result = cpufreq_frequency_table_cpuinfo(policy, cris_freq_table);
- if (result)
- return (result);
-
- cpufreq_frequency_table_get_attr(cris_freq_table, policy->cpu);
-
- return 0;
+ return cpufreq_table_validate_and_show(policy, cris_freq_table);
}

static int cris_freq_cpu_exit(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:05:13

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 018/228] cpufreq: davinci: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Sekhar Nori <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/davinci-cpufreq.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index d049937..ba03e6f 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -138,15 +138,13 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)

policy->cur = davinci_getspeed(0);

- result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
+ result = cpufreq_table_validate_and_show(policy, freq_table);
if (result) {
- pr_err("%s: cpufreq_frequency_table_cpuinfo() failed",
+ pr_err("%s: cpufreq_table_validate_and_show() failed",
__func__);
return result;
}

- cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
-
/*
* Time measurement across the target() function yields ~1500-1800us
* time taken with no drivers on notification list.
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:05:22

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 019/228] cpufreq: dbx500: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/dbx500-cpufreq.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index 26321cd..8a484e9 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -87,10 +87,8 @@ static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
int res;

/* get policy fields based on the table */
- res = cpufreq_frequency_table_cpuinfo(policy, freq_table);
- if (!res)
- cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
- else {
+ res = cpufreq_table_validate_and_show(policy, freq_table);
+ if (res) {
pr_err("dbx500-cpufreq: Failed to read policy table\n");
return res;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:05:30

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 020/228] cpufreq: e_powersaver: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/e_powersaver.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c
index 09f64cc..c1b7c99 100644
--- a/drivers/cpufreq/e_powersaver.c
+++ b/drivers/cpufreq/e_powersaver.c
@@ -403,13 +403,12 @@ static int eps_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 140000; /* 844mV -> 700mV in ns */
policy->cur = fsb * current_multiplier;

- ret = cpufreq_frequency_table_cpuinfo(policy, &centaur->freq_table[0]);
+ ret = cpufreq_table_validate_and_show(policy, &centaur->freq_table[0]);
if (ret) {
kfree(centaur);
return ret;
}

- cpufreq_frequency_table_get_attr(&centaur->freq_table[0], policy->cpu);
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:05:36

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 021/228] cpufreq: elanfreq: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/elanfreq.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c
index 823a400..4000c34 100644
--- a/drivers/cpufreq/elanfreq.c
+++ b/drivers/cpufreq/elanfreq.c
@@ -202,7 +202,6 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
{
struct cpuinfo_x86 *c = &cpu_data(0);
unsigned int i;
- int result;

/* capability check */
if ((c->x86_vendor != X86_VENDOR_AMD) ||
@@ -223,12 +222,7 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = elanfreq_get_cpu_frequency(0);

- result = cpufreq_frequency_table_cpuinfo(policy, elanfreq_table);
- if (result)
- return result;
-
- cpufreq_frequency_table_get_attr(elanfreq_table, policy->cpu);
- return 0;
+ return cpufreq_table_validate_and_show(policy, elanfreq_table);
}


--
1.7.12.rc2.18.g61b472e

2013-09-13 13:05:43

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 022/228] cpufreq: exynos: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/exynos-cpufreq.c | 4 +---
drivers/cpufreq/exynos5440-cpufreq.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 0fac344..954baed 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -249,14 +249,12 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
policy->cur = policy->min = policy->max = exynos_getspeed(policy->cpu);

- cpufreq_frequency_table_get_attr(exynos_info->freq_table, policy->cpu);
-
/* set the transition latency value */
policy->cpuinfo.transition_latency = 100000;

cpumask_setall(policy->cpus);

- return cpufreq_frequency_table_cpuinfo(policy, exynos_info->freq_table);
+ return cpufreq_table_validate_and_show(policy, exynos_info->freq_table);
}

static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index 1e391ac..83bd700 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -329,7 +329,7 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
int ret;

- ret = cpufreq_frequency_table_cpuinfo(policy, dvfs_info->freq_table);
+ ret = cpufreq_table_validate_and_show(policy, dvfs_info->freq_table);
if (ret) {
dev_err(dvfs_info->dev, "Invalid frequency table: %d\n", ret);
return ret;
@@ -339,8 +339,6 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = dvfs_info->latency;
cpumask_setall(policy->cpus);

- cpufreq_frequency_table_get_attr(dvfs_info->freq_table, policy->cpu);
-
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:05:52

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 023/228] cpufreq: ia64-acpi: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Tony Luck <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ia64-acpi-cpufreq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
index 3e14f03..6cfad51 100644
--- a/drivers/cpufreq/ia64-acpi-cpufreq.c
+++ b/drivers/cpufreq/ia64-acpi-cpufreq.c
@@ -335,7 +335,7 @@ acpi_cpufreq_cpu_init (
}
}

- result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
+ result = cpufreq_table_validate_and_show(policy, data->freq_table);
if (result) {
goto err_freqfree;
}
@@ -356,8 +356,6 @@ acpi_cpufreq_cpu_init (
(u32) data->acpi_data.states[i].status,
(u32) data->acpi_data.states[i].control);

- cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);
-
/* the first call to ->target() should result in us actually
* writing something to the appropriate registers. */
data->resume = 1;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:05:59

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 024/228] cpufreq: imx6q: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/imx6q-cpufreq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 3e39654..cd9489f 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -160,7 +160,7 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
{
int ret;

- ret = cpufreq_frequency_table_cpuinfo(policy, freq_table);
+ ret = cpufreq_table_validate_and_show(policy, freq_table);
if (ret) {
dev_err(cpu_dev, "invalid frequency table: %d\n", ret);
return ret;
@@ -169,7 +169,6 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = transition_latency;
policy->cur = clk_get_rate(arm_clk) / 1000;
cpumask_setall(policy->cpus);
- cpufreq_frequency_table_get_attr(freq_table, policy->cpu);

return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:06:09

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 025/228] cpufreq: kirkwood: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/kirkwood-cpufreq.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index ba10658..59cbb35 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -125,19 +125,11 @@ static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
/* Module init and exit code */
static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
- int result;
-
/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = 5000; /* 5uS */
policy->cur = kirkwood_cpufreq_get_cpu_frequency(0);

- result = cpufreq_frequency_table_cpuinfo(policy, kirkwood_freq_table);
- if (result)
- return result;
-
- cpufreq_frequency_table_get_attr(kirkwood_freq_table, policy->cpu);
-
- return 0;
+ return cpufreq_table_validate_and_show(policy, kirkwood_freq_table);
}

static int kirkwood_cpufreq_cpu_exit(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:06:18

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 026/228] cpufreq: longhaul: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/longhaul.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index 4ada1cc..70b66fd 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -921,13 +921,7 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 200000; /* nsec */
policy->cur = calc_speed(longhaul_get_cpu_mult());

- ret = cpufreq_frequency_table_cpuinfo(policy, longhaul_table);
- if (ret)
- return ret;
-
- cpufreq_frequency_table_get_attr(longhaul_table, policy->cpu);
-
- return 0;
+ return cpufreq_table_validate_and_show(policy, longhaul_table);
}

static int longhaul_cpu_exit(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:06:26

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 027/228] cpufreq: loongson2: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: John Crispin <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/loongson2_cpufreq.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index 7bc3c44..5dd3692 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -133,10 +133,7 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)

policy->cur = loongson2_cpufreq_get(policy->cpu);

- cpufreq_frequency_table_get_attr(&loongson2_clockmod_table[0],
- policy->cpu);
-
- return cpufreq_frequency_table_cpuinfo(policy,
+ return cpufreq_table_validate_and_show(policy,
&loongson2_clockmod_table[0]);
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:06:55

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 031/228] cpufreq: pasemi: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pasemi-cpufreq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 534e43a..23bc8a82 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -219,12 +219,10 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)

ppc_proc_freq = policy->cur * 1000ul;

- cpufreq_frequency_table_get_attr(pas_freqs, policy->cpu);
-
/* this ensures that policy->cpuinfo_min and policy->cpuinfo_max
* are set correctly
*/
- return cpufreq_frequency_table_cpuinfo(policy, pas_freqs);
+ return cpufreq_table_validate_and_show(policy, pas_freqs);

out_unmap_sdcpwr:
iounmap(sdcpwr_mapbase);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:07:13

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 034/228] cpufreq: ppc: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ppc-corenet-cpufreq.c | 3 +--
drivers/cpufreq/ppc_cbe_cpufreq.c | 4 +---
2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index 60e81d5..5716b44 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -202,7 +202,7 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
table[i].frequency = CPUFREQ_TABLE_END;

/* set the min and max frequency properly */
- ret = cpufreq_frequency_table_cpuinfo(policy, table);
+ ret = cpufreq_table_validate_and_show(policy, table);
if (ret) {
pr_err("invalid frequency table: %d\n", ret);
goto err_nomem1;
@@ -219,7 +219,6 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = corenet_cpufreq_get_speed(policy->cpu);

- cpufreq_frequency_table_get_attr(table, cpu);
of_node_put(np);

return 0;
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
index 2e448f0..6c5be63 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -123,11 +123,9 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu));
#endif

- cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
-
/* this ensures that policy->cpuinfo_min
* and policy->cpuinfo_max are set correctly */
- return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs);
+ return cpufreq_table_validate_and_show(policy, cbe_freqs);
}

static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:07:04

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 033/228] cpufreq: powernow: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/powernow-k6.c | 9 +--------
drivers/cpufreq/powernow-k7.c | 4 +---
drivers/cpufreq/powernow-k8.c | 4 +---
3 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index 85f1c8c..ab1de0d 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -145,7 +145,6 @@ static int powernow_k6_target(struct cpufreq_policy *policy,
static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
{
unsigned int i, f;
- int result;

if (policy->cpu != 0)
return -ENODEV;
@@ -167,13 +166,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 200000;
policy->cur = busfreq * max_multiplier;

- result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio);
- if (result)
- return result;
-
- cpufreq_frequency_table_get_attr(clock_ratio, policy->cpu);
-
- return 0;
+ return cpufreq_table_validate_and_show(policy, clock_ratio);
}


diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index 14ce480..c863c13 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -680,9 +680,7 @@ static int powernow_cpu_init(struct cpufreq_policy *policy)

policy->cur = powernow_get(0);

- cpufreq_frequency_table_get_attr(powernow_table, policy->cpu);
-
- return cpufreq_frequency_table_cpuinfo(policy, powernow_table);
+ return cpufreq_table_validate_and_show(policy, powernow_table);
}

static int powernow_cpu_exit(struct cpufreq_policy *policy)
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 8215bbc..8bd8cdb 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1176,7 +1176,7 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol)
pr_debug("policy current frequency %d kHz\n", pol->cur);

/* min/max the cpu is capable of */
- if (cpufreq_frequency_table_cpuinfo(pol, data->powernow_table)) {
+ if (cpufreq_table_validate_and_show(pol, data->powernow_table)) {
printk(KERN_ERR FW_BUG PFX "invalid powernow_table\n");
powernow_k8_cpu_exit_acpi(data);
kfree(data->powernow_table);
@@ -1184,8 +1184,6 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol)
return -EINVAL;
}

- cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu);
-
pr_debug("cpu_init done, current fid 0x%x, vid 0x%x\n",
data->currfid, data->currvid);

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:07:20

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 035/228] cpufreq: pxa: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Eric Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pxa2xx-cpufreq.c | 6 ++----
drivers/cpufreq/pxa3xx-cpufreq.c | 8 ++------
2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 5b8ce9a..b3bfb57 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -454,12 +454,10 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
pr_info("PXA255 cpufreq using %s frequency table\n",
pxa255_turbo_table ? "turbo" : "run");

- cpufreq_frequency_table_cpuinfo(policy, pxa255_freq_table);
- cpufreq_frequency_table_get_attr(pxa255_freq_table, policy->cpu);
+ cpufreq_table_validate_and_show(policy, pxa255_freq_table);
}
else if (cpu_is_pxa27x()) {
- cpufreq_frequency_table_cpuinfo(policy, pxa27x_freq_table);
- cpufreq_frequency_table_get_attr(pxa27x_freq_table, policy->cpu);
+ cpufreq_table_validate_and_show(policy, pxa27x_freq_table);
}

printk(KERN_INFO "PXA CPU frequency change support initialized\n");
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 8f14234..3f4986e 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -91,7 +91,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy,
struct pxa3xx_freq_info *freqs, int num)
{
struct cpufreq_frequency_table *table;
- int i, ret;
+ int i;

table = kzalloc((num + 1) * sizeof(*table), GFP_KERNEL);
if (table == NULL)
@@ -108,11 +108,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy,
pxa3xx_freqs_num = num;
pxa3xx_freqs_table = table;

- ret = cpufreq_frequency_table_cpuinfo(policy, table);
- if (!ret)
- cpufreq_frequency_table_get_attr(table, policy->cpu);
-
- return ret;
+ return cpufreq_table_validate_and_show(policy, table);
}

static void __update_core_freq(struct pxa3xx_freq_info *info)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:07:34

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 037/228] cpufreq: s5pv210: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s5pv210-cpufreq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 5c77570..c266a7e 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -553,11 +553,9 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)

policy->cur = policy->min = policy->max = s5pv210_getspeed(0);

- cpufreq_frequency_table_get_attr(s5pv210_freq_table, policy->cpu);
-
policy->cpuinfo.transition_latency = 40000;

- return cpufreq_frequency_table_cpuinfo(policy, s5pv210_freq_table);
+ return cpufreq_table_validate_and_show(policy, s5pv210_freq_table);

out_dmc1:
clk_put(dmc0_clk);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:07:55

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 040/228] cpufreq: sc520: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sc520_freq.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c
index d6f6c6f..bb9c0de 100644
--- a/drivers/cpufreq/sc520_freq.c
+++ b/drivers/cpufreq/sc520_freq.c
@@ -106,7 +106,6 @@ static int sc520_freq_target(struct cpufreq_policy *policy,
static int sc520_freq_cpu_init(struct cpufreq_policy *policy)
{
struct cpuinfo_x86 *c = &cpu_data(0);
- int result;

/* capability check */
if (c->x86_vendor != X86_VENDOR_AMD ||
@@ -117,13 +116,7 @@ static int sc520_freq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 1000000; /* 1ms */
policy->cur = sc520_freq_get_cpu_frequency(0);

- result = cpufreq_frequency_table_cpuinfo(policy, sc520_freq_table);
- if (result)
- return result;
-
- cpufreq_frequency_table_get_attr(sc520_freq_table, policy->cpu);
-
- return 0;
+ return cpufreq_table_validate_and_show(policy, sc520_freq_table);
}


--
1.7.12.rc2.18.g61b472e

2013-09-13 13:08:07

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 042/228] cpufreq: sparc: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: David S. Miller <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sparc-us2e-cpufreq.c | 6 +-----
drivers/cpufreq/sparc-us3-cpufreq.c | 7 +------
2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index 80e6d92..e35840d 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -307,7 +307,6 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
struct cpufreq_frequency_table *table =
&us2e_freq_table[cpu].table[0];
- int ret;

table[0].driver_data = 0;
table[0].frequency = clock_tick / 1;
@@ -325,10 +324,7 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 0;
policy->cur = clock_tick;

- ret = cpufreq_frequency_table_cpuinfo(policy, table);
- if (!ret)
- cpufreq_frequency_table_get_attr(table, policy->cpu);
- return ret;
+ return cpufreq_table_validate_and_show(policy, table);
}

static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index 73a90de..23f2d3b 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -168,7 +168,6 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
struct cpufreq_frequency_table *table =
&us3_freq_table[cpu].table[0];
- int ret;

table[0].driver_data = 0;
table[0].frequency = clock_tick / 1;
@@ -182,11 +181,7 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 0;
policy->cur = clock_tick;

- ret = cpufreq_frequency_table_cpuinfo(policy, table);
- if (!ret)
- cpufreq_frequency_table_get_attr(table, policy->cpu);
-
- return ret;
+ return cpufreq_table_validate_and_show(policy, table);
}

static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:08:14

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 043/228] cpufreq: spear: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/spear-cpufreq.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 19e364fa..b86be6b 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -178,13 +178,12 @@ static int spear_cpufreq_init(struct cpufreq_policy *policy)
{
int ret;

- ret = cpufreq_frequency_table_cpuinfo(policy, spear_cpufreq.freq_tbl);
+ ret = cpufreq_table_validate_and_show(policy, spear_cpufreq.freq_tbl);
if (ret) {
- pr_err("cpufreq_frequency_table_cpuinfo() failed");
+ pr_err("cpufreq_table_validate_and_show() failed");
return ret;
}

- cpufreq_frequency_table_get_attr(spear_cpufreq.freq_tbl, policy->cpu);
policy->cpuinfo.transition_latency = spear_cpufreq.transition_latency;
policy->cur = spear_cpufreq_get(0);

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:08:20

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 044/228] cpufreq: speedstep: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: David S. Miller <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/speedstep-centrino.c | 10 +---------
drivers/cpufreq/speedstep-ich.c | 9 +--------
drivers/cpufreq/speedstep-smi.c | 8 +-------
3 files changed, 3 insertions(+), 24 deletions(-)

diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
index f897d51..f180561 100644
--- a/drivers/cpufreq/speedstep-centrino.c
+++ b/drivers/cpufreq/speedstep-centrino.c
@@ -345,7 +345,6 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
struct cpuinfo_x86 *cpu = &cpu_data(policy->cpu);
unsigned freq;
unsigned l, h;
- int ret;
int i;

/* Only Intel makes Enhanced Speedstep-capable CPUs */
@@ -402,15 +401,8 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)

pr_debug("centrino_cpu_init: cur=%dkHz\n", policy->cur);

- ret = cpufreq_frequency_table_cpuinfo(policy,
+ return cpufreq_table_validate_and_show(policy,
per_cpu(centrino_model, policy->cpu)->op_points);
- if (ret)
- return (ret);
-
- cpufreq_frequency_table_get_attr(
- per_cpu(centrino_model, policy->cpu)->op_points, policy->cpu);
-
- return 0;
}

static int centrino_cpu_exit(struct cpufreq_policy *policy)
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c
index 5355abb..86a184e 100644
--- a/drivers/cpufreq/speedstep-ich.c
+++ b/drivers/cpufreq/speedstep-ich.c
@@ -320,7 +320,6 @@ static void get_freqs_on_cpu(void *_get_freqs)

static int speedstep_cpu_init(struct cpufreq_policy *policy)
{
- int result;
unsigned int policy_cpu, speed;
struct get_freqs gf;

@@ -349,13 +348,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
/* cpuinfo and default policy values */
policy->cur = speed;

- result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs);
- if (result)
- return result;
-
- cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu);
-
- return 0;
+ return cpufreq_table_validate_and_show(policy, speedstep_freqs);
}


diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
index abfba4f..f4d0318 100644
--- a/drivers/cpufreq/speedstep-smi.c
+++ b/drivers/cpufreq/speedstep-smi.c
@@ -329,13 +329,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = speed;

- result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs);
- if (result)
- return result;
-
- cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu);
-
- return 0;
+ return cpufreq_table_validate_and_show(policy, speedstep_freqs);
}

static int speedstep_cpu_exit(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:08:28

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 045/228] cpufreq: tegra: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Acked-by: Stephen Warren <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/tegra-cpufreq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index a7b876f..d45c1d8 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -215,8 +215,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
clk_prepare_enable(emc_clk);
clk_prepare_enable(cpu_clk);

- cpufreq_frequency_table_cpuinfo(policy, freq_table);
- cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
+ cpufreq_table_validate_and_show(policy, freq_table);
policy->cur = tegra_getspeed(policy->cpu);
target_cpu_speed[policy->cpu] = policy->cur;

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:08:34

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 046/228] cpufreq: tegra: fix implementation of ->exit()

->exit() of drivers should call cpufreq_frequency_table_put_attr() if they have
called cpufreq_frequency_table_get_attr() earlier in init() and they aren't
required to validate their cpufreq table in exit by calling
cpufreq_frequency_table_cpuinfo(). Tegra's driver wasn't calling
cpufreq_frequency_table_put_attr() and was calling
cpufreq_frequency_table_cpuinfo() in exit.

Fix both these issues in it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/tegra-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index d45c1d8..e014077 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -232,7 +232,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)

static int tegra_cpu_exit(struct cpufreq_policy *policy)
{
- cpufreq_frequency_table_cpuinfo(policy, freq_table);
+ cpufreq_frequency_table_put_attr(policy->cpu);
clk_disable_unprepare(emc_clk);
return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:08:41

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 047/228] cpufreq: at32ap: add frequency table

From: Hans-Christian Egtvedt <[email protected]>

This patch adds a dynamically calculated frequency table to the at32ap driver.
In short the architecture can scale in power of two between a maximum and
minimum frequency. Min, max, and the steps in between are added to the table.

Signed-off-by: Hans-Christian Egtvedt <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/at32ap-cpufreq.c | 49 +++++++++++++++++++++++++++++++++++++---
1 file changed, 46 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
index e0c38d9..1d19fa5 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -19,8 +19,10 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/export.h>
+#include <linux/slab.h>

static struct clk *cpuclk;
+static struct cpufreq_frequency_table *freq_table;

static int at32_verify_speed(struct cpufreq_policy *policy)
{
@@ -85,13 +87,17 @@ static int at32_set_target(struct cpufreq_policy *policy,

static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
{
+ unsigned int frequency, rate;
+ int retval, steps, i;
+
if (policy->cpu != 0)
return -EINVAL;

cpuclk = clk_get(NULL, "cpu");
if (IS_ERR(cpuclk)) {
pr_debug("cpufreq: could not get CPU clk\n");
- return PTR_ERR(cpuclk);
+ retval = PTR_ERR(cpuclk);
+ goto out_err;
}

policy->cpuinfo.min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000;
@@ -101,9 +107,46 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
policy->min = policy->cpuinfo.min_freq;
policy->max = policy->cpuinfo.max_freq;

- printk("cpufreq: AT32AP CPU frequency driver\n");
+ /*
+ * AVR32 CPU frequency rate scales in power of two between maximum and
+ * minimum, also add space for the table end marker.
+ *
+ * Further validate that the frequency is usable, and append it to the
+ * frequency table.
+ */
+ steps = fls(policy->cpuinfo.max_freq / policy->cpuinfo.min_freq) + 1;
+ freq_table = kzalloc(steps * sizeof(struct cpufreq_frequency_table),
+ GFP_KERNEL);
+ if (!freq_table) {
+ retval = -ENOMEM;
+ goto out_err_put_clk;
+ }

- return 0;
+ frequency = policy->cpuinfo.max_freq;
+ for (i = 0; i < (steps - 1); i++) {
+ rate = clk_round_rate(cpuclk, frequency * 1000) / 1000;
+
+ if (rate != frequency)
+ freq_table[i].frequency = CPUFREQ_ENTRY_INVALID;
+ else
+ freq_table[i].frequency = frequency;
+
+ frequency /= 2;
+ }
+
+ freq_table[steps - 1].frequency = CPUFREQ_TABLE_END;
+
+ retval = cpufreq_table_validate_and_show(policy, freq_table);
+ if (!retval) {
+ printk("cpufreq: AT32AP CPU frequency driver\n");
+ return 0;
+ }
+
+ kfree(freq_table);
+out_err_put_clk:
+ clk_put(cpuclk);
+out_err:
+ return retval;
}

static struct cpufreq_driver at32_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:08:48

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 048/228] cpufreq: arm_big_little: call cpufreq_frequency_table_put_attr()

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 <[email protected]>
---
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 8cb6dbc..2c7c134 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

2013-09-13 13:08:54

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 049/228] cpufreq: blackfin: call cpufreq_frequency_table_put_attr()

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:09:03

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 050/228] cpufreq: exynos: call cpufreq_frequency_table_put_attr()

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.

Acked-By: Amit Daniel Kachhap <[email protected]>
Acked-by: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 83bd700..e041f5e 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -342,12 +342,18 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
return 0;
}

+static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
+{
+ cpufreq_frequency_table_put_attr(policy->cpu);
+}
+
static struct cpufreq_driver exynos_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_ASYNC_NOTIFICATION,
.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

2013-09-13 13:09:15

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 052/228] cpufreq: omap: call cpufreq_frequency_table_put_attr()

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:09:08

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 051/228] cpufreq: loongson2: call cpufreq_frequency_table_put_attr()

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:09:24

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 053/228] cpufreq: pxa: call cpufreq_frequency_table_put_attr()

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 b3bfb57..9e8a6b4 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 3f4986e..085a27d 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -229,10 +229,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

2013-09-13 13:09:44

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 055/228] cpufreq: define generic .attr, .exit() and .verify() routines

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.

Signed-off-by: Viresh Kumar <[email protected]>
---
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 b9336ed..3458d27 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -86,6 +86,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,
@@ -199,6 +213,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 e257407..57d2907 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -415,6 +415,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,
@@ -430,10 +431,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

2013-09-13 13:09:33

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 054/228] cpufreq: sparc: call cpufreq_frequency_table_put_attr()

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 <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:09:52

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 057/228] cpufreq: arm_big_little: Use generic cpufreq routines

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 <[email protected]>
---
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 2c7c134..132c966 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 |
CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
- .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,
- .attr = bL_cpufreq_attr,
+ .attr = cpufreq_generic_attr,
};

int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:09:59

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 058/228] cpufreq: at32ap: Use generic cpufreq routines

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.

Acked-by: Hans-Christian Egtvedt <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 1d19fa5..788f7e7 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -24,16 +24,6 @@
static struct clk *cpuclk;
static struct cpufreq_frequency_table *freq_table;

-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 */
@@ -152,7 +142,7 @@ out_err:
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

2013-09-13 13:10:14

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 060/228] cpufreq: cpu0: Use generic cpufreq routines

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.

Acked-by: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 ce4fa47..2847ae6 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

2013-09-13 13:10:23

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 061/228] cpufreq: cris: Use generic cpufreq routines

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 <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:10:27

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 062/228] cpufreq: davinci: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 ba03e6f..f228642 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -155,26 +155,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

2013-09-13 13:10:36

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 063/228] cpufreq: dbx500: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 8a484e9..2d70637 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

2013-09-13 13:10:42

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 064/228] cpufreq: e_powersaver: Use generic cpufreq routines

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 <[email protected]>
---
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

2013-09-13 13:10:52

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 065/228] cpufreq: elanfreq: Use generic cpufreq routines

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 <[email protected]>
---
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

2013-09-13 13:10:55

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 066/228] cpufreq: exynos: Use generic cpufreq routines

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.

Acked-By: Amit Daniel Kachhap <[email protected]>
Acked-by: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 954baed..08338d4 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 e041f5e..e33896f 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;
@@ -342,18 +336,13 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
return 0;
}

-static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
-{
- cpufreq_frequency_table_put_attr(policy->cpu);
-}
-
static struct cpufreq_driver exynos_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_ASYNC_NOTIFICATION,
- .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

2013-09-13 13:11:09

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 067/228] cpufreq: ia64-acpi: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:11:24

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 070/228] cpufreq: longhaul: Use generic cpufreq routines

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 <[email protected]>
---
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

2013-09-13 13:11:31

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 071/228] cpufreq: loongson2: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:11:41

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 072/228] cpufreq: maple: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 b3fb661..b23d1d8 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

2013-09-13 13:11:46

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 073/228] cpufreq: omap: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:11:58

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 075/228] cpufreq: pasemi: Use generic cpufreq routines

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 <[email protected]>
---
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

2013-09-13 13:12:06

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 076/228] cpufreq: pmac: Use generic cpufreq routines

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 <[email protected]>
---
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 470b555..8715ab9 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -86,11 +86,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)
@@ -378,11 +373,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)
@@ -468,14 +458,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 41fa89e..e853b85 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -70,11 +70,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
*/
@@ -317,11 +312,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)
{
@@ -372,10 +362,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

2013-09-13 13:12:14

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 077/228] cpufreq: powernow: Use generic cpufreq routines

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 <[email protected]>
---
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 8bd8cdb..f054d5b 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1073,17 +1073,6 @@ static int powernowk8_target(struct cpufreq_policy *pol,
return ret;
}

-/* 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;
@@ -1245,21 +1234,16 @@ out:
return khz;
}

-static struct freq_attr *powernow_k8_attr[] = {
- &cpufreq_freq_attr_scaling_available_freqs,
- NULL,
-};
-
static struct cpufreq_driver cpufreq_amd64_driver = {
.flags = CPUFREQ_ASYNC_NOTIFICATION,
- .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

2013-09-13 13:12:20

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 078/228] cpufreq: ppc-corenet: Use generic cpufreq routines

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 <[email protected]>
---
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

2013-09-13 13:12:27

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 079/228] cpufreq: ppc_cbe: Use generic cpufreq routines

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 <[email protected]>
---
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

2013-09-13 13:12:35

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 080/228] cpufreq: pxa: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 9e8a6b4..82905fe 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 085a27d..ae3ac08 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);
@@ -229,16 +224,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

2013-09-13 13:12:44

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 081/228] cpufreq: s3cx4xx: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 73856d1..027dec1 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -416,14 +416,6 @@ static int __init 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

2013-09-13 13:12:50

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 082/228] cpufreq: s5pv210: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:12:59

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 083/228] cpufreq: sa11x0: Use generic cpufreq routines

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 <[email protected]>
---
arch/arm/mach-sa1100/generic.c | 22 ----------------------
arch/arm/mach-sa1100/generic.h | 1 -
drivers/cpufreq/sa1100-cpufreq.c | 2 +-
drivers/cpufreq/sa1110-cpufreq.c | 2 +-
4 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 5c8167b..cb4b2ca 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -82,28 +82,6 @@ unsigned int sa11x0_ppcr_to_freq(unsigned int idx)
return freq;
}

-
-/* make sure that only the "userspace" governor is run -- anything else wouldn't make sense on
- * this platform, anyway.
- */
-int sa11x0_verify_speed(struct cpufreq_policy *policy)
-{
- unsigned int tmp;
- if (policy->cpu)
- return -EINVAL;
-
- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
-
- /* make sure that at least one frequency is within the policy */
- tmp = sa11x0_freq_table[sa11x0_freq_to_ppcr(policy->min)].frequency;
- if (tmp > policy->max)
- policy->max = tmp;
-
- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
-
- return 0;
-}
-
unsigned int sa11x0_getspeed(unsigned int cpu)
{
if (cpu)
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index f5214ce..39d56a67 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -23,7 +23,6 @@ struct cpufreq_policy;

extern struct cpufreq_frequency_table sa11x0_freq_table[];
extern unsigned int sa11x0_freq_to_ppcr(unsigned int khz);
-extern int sa11x0_verify_speed(struct cpufreq_policy *policy);
extern unsigned int sa11x0_getspeed(unsigned int cpu);
extern unsigned int sa11x0_ppcr_to_freq(unsigned int idx);

diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c
index 37fce2f..80a4fde 100644
--- a/drivers/cpufreq/sa1100-cpufreq.c
+++ b/drivers/cpufreq/sa1100-cpufreq.c
@@ -228,7 +228,7 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)

static struct cpufreq_driver sa1100_driver __refdata = {
.flags = CPUFREQ_STICKY,
- .verify = sa11x0_verify_speed,
+ .verify = cpufreq_generic_frequency_table_verify,
.target = sa1100_target,
.get = sa11x0_getspeed,
.init = sa1100_cpu_init,
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c
index 13760fc..a38d904 100644
--- a/drivers/cpufreq/sa1110-cpufreq.c
+++ b/drivers/cpufreq/sa1110-cpufreq.c
@@ -344,7 +344,7 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
* it with cpufreq_register_driver() */
static struct cpufreq_driver sa1110_driver __refdata = {
.flags = CPUFREQ_STICKY,
- .verify = sa11x0_verify_speed,
+ .verify = cpufreq_generic_frequency_table_verify,
.target = sa1110_target,
.get = sa11x0_getspeed,
.init = sa1110_cpu_init,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:13:09

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 084/228] cpufreq: sc520: Use generic cpufreq routines

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 <[email protected]>
---
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

2013-09-13 13:13:19

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 086/228] cpufreq: sparc: Use generic cpufreq routines

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 <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:13:24

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 087/228] cpufreq: spear: Use generic cpufreq routines

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: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
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 b86be6b..e9657e3 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

2013-09-13 13:13:32

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 088/228] cpufreq: speedstep: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:13:43

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 089/228] cpufreq: tegra: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 e014077..c36a8e7 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

2013-09-13 13:13:52

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 091/228] cpufreq: acpi: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/acpi-cpufreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index d67023d..372febf 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -842,7 +842,6 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
- policy->cur = get_cur_freq_on_cpu(cpu);
break;
default:
break;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:13:58

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 092/228] cpufreq: arm_big_little: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/arm_big_little.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 132c966..f7717ef 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -171,8 +171,6 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)
else
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

- policy->cur = bL_cpufreq_get(policy->cpu);
-
cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu));

dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:14:09

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 093/228] cpufreq: at32ap: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Acked-by: Hans-Christian Egtvedt <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/at32ap-cpufreq.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
index 788f7e7..7439ded 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -77,7 +77,7 @@ static int at32_set_target(struct cpufreq_policy *policy,

static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
{
- unsigned int frequency, rate;
+ unsigned int frequency, rate, min_freq;
int retval, steps, i;

if (policy->cpu != 0)
@@ -90,12 +90,9 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
goto out_err;
}

- policy->cpuinfo.min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000;
- policy->cpuinfo.max_freq = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
+ min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000;
+ frequency = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
policy->cpuinfo.transition_latency = 0;
- policy->cur = at32_get_speed(0);
- policy->min = policy->cpuinfo.min_freq;
- policy->max = policy->cpuinfo.max_freq;

/*
* AVR32 CPU frequency rate scales in power of two between maximum and
@@ -104,7 +101,7 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
* Further validate that the frequency is usable, and append it to the
* frequency table.
*/
- steps = fls(policy->cpuinfo.max_freq / policy->cpuinfo.min_freq) + 1;
+ steps = fls(frequency / min_freq) + 1;
freq_table = kzalloc(steps * sizeof(struct cpufreq_frequency_table),
GFP_KERNEL);
if (!freq_table) {
@@ -112,7 +109,6 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
goto out_err_put_clk;
}

- frequency = policy->cpuinfo.max_freq;
for (i = 0; i < (steps - 1); i++) {
rate = clk_round_rate(cpuclk, frequency * 1000) / 1000;

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:14:18

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 095/228] cpufreq: cpu0: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq-cpu0.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 2847ae6..2486c13 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -130,7 +130,6 @@ static int cpu0_cpufreq_init(struct cpufreq_policy *policy)
}

policy->cpuinfo.transition_latency = transition_latency;
- policy->cur = clk_get_rate(cpu_clk) / 1000;

/*
* The driver only supports the SMP configuartion where all processors
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:14:29

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 096/228] cpufreq: nforce2: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq-nforce2.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c
index 56c964c..a05b876 100644
--- a/drivers/cpufreq/cpufreq-nforce2.c
+++ b/drivers/cpufreq/cpufreq-nforce2.c
@@ -360,7 +360,6 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy)
policy->min = policy->cpuinfo.min_freq = min_fsb * fid * 100;
policy->max = policy->cpuinfo.max_freq = max_fsb * fid * 100;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
- policy->cur = nforce2_get(policy->cpu);

return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:14:34

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 097/228] cpufreq: cris: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Jesper Nilsson <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cris-artpec3-cpufreq.c | 1 -
drivers/cpufreq/cris-etraxfs-cpufreq.c | 1 -
2 files changed, 2 deletions(-)

diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index d26f4e4..4d88e4f 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -73,7 +73,6 @@ static int cris_freq_cpu_init(struct cpufreq_policy *policy)
{
/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = 1000000; /* 1ms */
- policy->cur = cris_freq_get_cpu_frequency(0);

return cpufreq_table_validate_and_show(policy, cris_freq_table);
}
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index d384e63..f7d2d49 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -72,7 +72,6 @@ static int cris_freq_cpu_init(struct cpufreq_policy *policy)
{
/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = 1000000; /* 1ms */
- policy->cur = cris_freq_get_cpu_frequency(0);

return cpufreq_table_validate_and_show(policy, cris_freq_table);
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:14:45

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 098/228] cpufreq: davinci: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Sekhar Nori <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/davinci-cpufreq.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index f228642..55cf094 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -136,8 +136,6 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)
return result;
}

- policy->cur = davinci_getspeed(0);
-
result = cpufreq_table_validate_and_show(policy, freq_table);
if (result) {
pr_err("%s: cpufreq_table_validate_and_show() failed",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:14:55

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 099/228] cpufreq: dbx500: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Linus Walleij <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/dbx500-cpufreq.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index 2d70637..ae1aa60 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -83,11 +83,6 @@ static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
return res;
}

- policy->min = policy->cpuinfo.min_freq;
- policy->max = policy->cpuinfo.max_freq;
- policy->cur = dbx500_cpufreq_getspeed(policy->cpu);
- policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
-
/*
* FIXME : Need to take time measurement across the target()
* function with no/some/all drivers in the notification
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:14:59

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 100/228] cpufreq: e_powersaver: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/e_powersaver.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c
index a8cbbd0..2c11ce3 100644
--- a/drivers/cpufreq/e_powersaver.c
+++ b/drivers/cpufreq/e_powersaver.c
@@ -395,7 +395,6 @@ static int eps_cpu_init(struct cpufreq_policy *policy)
}

policy->cpuinfo.transition_latency = 140000; /* 844mV -> 700mV in ns */
- policy->cur = fsb * current_multiplier;

ret = cpufreq_table_validate_and_show(policy, &centaur->freq_table[0]);
if (ret) {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:15:05

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 101/228] cpufreq: elanfreq: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/elanfreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c
index fe7053c..d91a645 100644
--- a/drivers/cpufreq/elanfreq.c
+++ b/drivers/cpufreq/elanfreq.c
@@ -207,7 +207,6 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)

/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
- policy->cur = elanfreq_get_cpu_frequency(0);

return cpufreq_table_validate_and_show(policy, elanfreq_table);
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:15:13

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 102/228] cpufreq: exynos: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Acked-By: Amit Daniel Kachhap <[email protected]>
Acked-by: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/exynos-cpufreq.c | 2 --
drivers/cpufreq/exynos5440-cpufreq.c | 1 -
2 files changed, 3 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 08338d4..5244086 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -241,8 +241,6 @@ static struct notifier_block exynos_cpufreq_nb = {

static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
- policy->cur = policy->min = policy->max = exynos_getspeed(policy->cpu);
-
/* set the transition latency value */
policy->cpuinfo.transition_latency = 100000;

diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index e33896f..a7d272b 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -329,7 +329,6 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
return ret;
}

- policy->cur = dvfs_info->cur_frequency;
policy->cpuinfo.transition_latency = dvfs_info->latency;
cpumask_setall(policy->cpus);

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:15:22

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 103/228] cpufreq: gx: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/gx-suspmod.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/cpufreq/gx-suspmod.c b/drivers/cpufreq/gx-suspmod.c
index 70442c7..d83e826 100644
--- a/drivers/cpufreq/gx-suspmod.c
+++ b/drivers/cpufreq/gx-suspmod.c
@@ -401,7 +401,7 @@ static int cpufreq_gx_target(struct cpufreq_policy *policy,

static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
{
- unsigned int maxfreq, curfreq;
+ unsigned int maxfreq;

if (!policy || policy->cpu != 0)
return -ENODEV;
@@ -415,10 +415,8 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
maxfreq = 30000 * gx_freq_mult[getCx86(CX86_DIR1) & 0x0f];

stock_freq = maxfreq;
- curfreq = gx_get_cpuspeed(0);

pr_debug("cpu max frequency is %d.\n", maxfreq);
- pr_debug("cpu current frequency is %dkHz.\n", curfreq);

/* setup basic struct for cpufreq API */
policy->cpu = 0;
@@ -428,7 +426,6 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
else
policy->min = maxfreq / POLICY_MIN_DIV;
policy->max = maxfreq;
- policy->cur = curfreq;
policy->cpuinfo.min_freq = maxfreq / max_duration;
policy->cpuinfo.max_freq = maxfreq;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:15:33

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 105/228] cpufreq: imx6q: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/imx6q-cpufreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 29767bb..649547f 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -162,7 +162,6 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
}

policy->cpuinfo.transition_latency = transition_latency;
- policy->cur = clk_get_rate(arm_clk) / 1000;
cpumask_setall(policy->cpus);

return 0;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:15:44

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 106/228] cpufreq: integrator: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Russell King <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/integrator-cpufreq.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c
index 8152a9b..babf3e4 100644
--- a/drivers/cpufreq/integrator-cpufreq.c
+++ b/drivers/cpufreq/integrator-cpufreq.c
@@ -181,10 +181,9 @@ static int integrator_cpufreq_init(struct cpufreq_policy *policy)
{

/* set default policy and cpuinfo */
- policy->cpuinfo.max_freq = 160000;
- policy->cpuinfo.min_freq = 12000;
+ policy->max = policy->cpuinfo.max_freq = 160000;
+ policy->min = policy->cpuinfo.min_freq = 12000;
policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */
- policy->cur = policy->min = policy->max = integrator_get(policy->cpu);

return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:15:55

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 108/228] cpufreq: longhaul: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/longhaul.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index 57d7b02..14df497 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -913,7 +913,6 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy)
longhaul_setup_voltagescaling();

policy->cpuinfo.transition_latency = 200000; /* nsec */
- policy->cur = calc_speed(longhaul_get_cpu_mult());

return cpufreq_table_validate_and_show(policy, longhaul_table);
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:16:04

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 109/228] cpufreq: loongson2: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: John Crispin <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/loongson2_cpufreq.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index ed7fbe2..dd4f3e4 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -131,8 +131,6 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
return ret;
}

- policy->cur = loongson2_cpufreq_get(policy->cpu);
-
return cpufreq_table_validate_and_show(policy,
&loongson2_clockmod_table[0]);
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:16:18

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 111/228] cpufreq: omap: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Santosh Shilimkar <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/omap-cpufreq.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 48020b5..a8c3f90 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -171,8 +171,6 @@ static int omap_cpu_init(struct cpufreq_policy *policy)
goto fail_ck;
}

- policy->cur = omap_getspeed(policy->cpu);
-
if (!freq_table)
result = opp_init_cpufreq_table(mpu_dev, &freq_table);

@@ -188,8 +186,6 @@ static int omap_cpu_init(struct cpufreq_policy *policy)
if (result)
goto fail_table;

- policy->cur = omap_getspeed(policy->cpu);
-
/*
* On OMAP SMP configuartion, both processors share the voltage
* and clock. So both CPUs needs to be scaled together and hence
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:16:25

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 112/228] cpufreq: p4: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: David S. Miller <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/p4-clockmod.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 4fe6d4c..6164c1c 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -230,7 +230,6 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
/* the transition latency is set to be 1 higher than the maximum
* transition latency of the ondemand governor */
policy->cpuinfo.transition_latency = 10000001;
- policy->cur = stock_freq;

return cpufreq_table_validate_and_show(policy, &p4clockmod_table[0]);
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:16:38

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 114/228] cpufreq: pmac: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pmac32-cpufreq.c | 1 -
drivers/cpufreq/pmac64-cpufreq.c | 1 -
2 files changed, 2 deletions(-)

diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index 8715ab9..672b7f4 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -396,7 +396,6 @@ static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
return -ENODEV;

policy->cpuinfo.transition_latency = transition_latency;
- policy->cur = cur_freq;

return cpufreq_table_validate_and_show(policy, pmac_cpu_freqs);
}
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index e853b85..79e40c9 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -348,7 +348,6 @@ static unsigned int g5_cpufreq_get_speed(unsigned int cpu)
static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
policy->cpuinfo.transition_latency = transition_latency;
- policy->cur = g5_cpu_freqs[g5_query_freq()].frequency;
/* secondary CPUs are tied to the primary one by the
* cpufreq core if in the secondary policy we tell it that
* it actually must be one policy together with all others. */
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:16:40

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 113/228] cpufreq: pcc: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pcc-cpufreq.c | 7 -------
1 file changed, 7 deletions(-)

diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
index 78787e9..ef66347 100644
--- a/drivers/cpufreq/pcc-cpufreq.c
+++ b/drivers/cpufreq/pcc-cpufreq.c
@@ -559,13 +559,6 @@ static int pcc_cpufreq_cpu_init(struct cpufreq_policy *policy)
ioread32(&pcch_hdr->nominal) * 1000;
policy->min = policy->cpuinfo.min_freq =
ioread32(&pcch_hdr->minimum_frequency) * 1000;
- policy->cur = pcc_get_freq(cpu);
-
- if (!policy->cur) {
- pr_debug("init: Unable to get current CPU frequency\n");
- result = -EINVAL;
- goto out;
- }

pr_debug("init: policy->max is %d, policy->min is %d\n",
policy->max, policy->min);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:16:50

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 116/228] cpufreq: ppc: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ppc-corenet-cpufreq.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index befd489..a0f562c 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -217,8 +217,6 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
per_cpu(cpu_data, i) = data;

policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
- policy->cur = corenet_cpufreq_get_speed(policy->cpu);
-
of_node_put(np);

return 0;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:16:57

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 117/228] cpufreq: pxa: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Eric Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pxa2xx-cpufreq.c | 2 --
drivers/cpufreq/pxa3xx-cpufreq.c | 7 +++----
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 82905fe..29aca57 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -397,8 +397,6 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)

/* set default policy and cpuinfo */
policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
- policy->cur = get_clk_frequency_khz(0); /* current freq */
- policy->min = policy->max = policy->cur;

/* Generate pxa25x the run cpufreq_frequency_table struct */
for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) {
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index ae3ac08..47fbee4 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -201,11 +201,10 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)
int ret = -EINVAL;

/* set default policy and cpuinfo */
- policy->cpuinfo.min_freq = 104000;
- policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000;
+ policy->min = policy->cpuinfo.min_freq = 104000;
+ policy->max = policy->cpuinfo.max_freq =
+ (cpu_is_pxa320()) ? 806000 : 624000;
policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
- policy->max = pxa3xx_get_clk_frequency_khz(0);
- policy->cur = policy->min = policy->max;

if (cpu_is_pxa300() || cpu_is_pxa310())
ret = setup_freqs_table(policy, pxa300_freqs,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:17:07

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 118/228] cpufreq: s3c: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s3c2416-cpufreq.c | 2 --
drivers/cpufreq/s3c24xx-cpufreq.c | 5 -----
drivers/cpufreq/s3c64xx-cpufreq.c | 2 --
3 files changed, 9 deletions(-)

diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index 8c57f10..22c4c2d 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -476,8 +476,6 @@ static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)
freq++;
}

- policy->cur = clk_get_rate(s3c_freq->armclk) / 1000;
-
/* Datasheet says PLL stabalisation time must be at least 300us,
* so but add some fudge. (reference in LOCKCON0 register description)
*/
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index 027dec1..e0fbaef 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -378,11 +378,6 @@ static int s3c_cpufreq_init(struct cpufreq_policy *policy)
if (policy->cpu != 0)
return -EINVAL;

- policy->cur = s3c_cpufreq_get(0);
- policy->min = policy->cpuinfo.min_freq = 0;
- policy->max = policy->cpuinfo.max_freq = cpu_cur.info->max.fclk / 1000;
- policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
-
/* feed the latency information from the cpu driver */
policy->cpuinfo.transition_latency = cpu_cur.info->latency;

diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 99fbc49..a66cfa3 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -235,8 +235,6 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
freq++;
}

- policy->cur = clk_get_rate(armclk) / 1000;
-
/* Datasheet says PLL stabalisation time (if we were to use
* the PLLs, which we don't currently) is ~300us worst case,
* but add some fudge.
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:17:13

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 119/228] cpufreq: s5pv210: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s5pv210-cpufreq.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 0eafc52..30d9bb7 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -543,8 +543,6 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000);
s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk);

- policy->cur = policy->min = policy->max = s5pv210_getspeed(0);
-
policy->cpuinfo.transition_latency = 40000;

return cpufreq_table_validate_and_show(policy, s5pv210_freq_table);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:17:20

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 120/228] cpufreq: sa11x0: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Russell King <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sa1100-cpufreq.c | 1 -
drivers/cpufreq/sa1110-cpufreq.c | 1 -
2 files changed, 2 deletions(-)

diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c
index 80a4fde..a1d1bb7 100644
--- a/drivers/cpufreq/sa1100-cpufreq.c
+++ b/drivers/cpufreq/sa1100-cpufreq.c
@@ -220,7 +220,6 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
{
if (policy->cpu != 0)
return -EINVAL;
- policy->cur = sa11x0_getspeed(0);
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

return cpufreq_table_validate_and_show(policy, sa11x0_freq_table);
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c
index a38d904..9da940e 100644
--- a/drivers/cpufreq/sa1110-cpufreq.c
+++ b/drivers/cpufreq/sa1110-cpufreq.c
@@ -334,7 +334,6 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
{
if (policy->cpu != 0)
return -EINVAL;
- policy->cur = sa11x0_getspeed(0);
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

return cpufreq_table_validate_and_show(policy, sa11x0_freq_table);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:17:28

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 121/228] cpufreq: sc520_freq: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sc520_freq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c
index 8556225..9047ab1 100644
--- a/drivers/cpufreq/sc520_freq.c
+++ b/drivers/cpufreq/sc520_freq.c
@@ -109,7 +109,6 @@ static int sc520_freq_cpu_init(struct cpufreq_policy *policy)

/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = 1000000; /* 1ms */
- policy->cur = sc520_freq_get_cpu_frequency(0);

return cpufreq_table_validate_and_show(policy, sc520_freq_table);
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:17:34

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 122/228] cpufreq: sh: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Paul Mundt <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sh-cpufreq.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
index c681b86..387af12 100644
--- a/drivers/cpufreq/sh-cpufreq.c
+++ b/drivers/cpufreq/sh-cpufreq.c
@@ -111,8 +111,6 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy)
return PTR_ERR(cpuclk);
}

- policy->cur = sh_cpufreq_get(cpu);
-
freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL;
if (freq_table) {
int result;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:17:40

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 123/228] cpufreq: spear: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/spear-cpufreq.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index e9657e3..aacdb61 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -180,8 +180,6 @@ static int spear_cpufreq_init(struct cpufreq_policy *policy)
}

policy->cpuinfo.transition_latency = spear_cpufreq.transition_latency;
- policy->cur = spear_cpufreq_get(0);
-
cpumask_setall(policy->cpus);

return 0;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:17:51

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 124/228] cpufreq: speedstep: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: David S. Miller <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/speedstep-centrino.c | 5 -----
drivers/cpufreq/speedstep-ich.c | 15 +--------------
drivers/cpufreq/speedstep-smi.c | 13 -------------
3 files changed, 1 insertion(+), 32 deletions(-)

diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
index c7c14ae..6b882c7 100644
--- a/drivers/cpufreq/speedstep-centrino.c
+++ b/drivers/cpufreq/speedstep-centrino.c
@@ -343,7 +343,6 @@ static unsigned int get_cur_freq(unsigned int cpu)
static int centrino_cpu_init(struct cpufreq_policy *policy)
{
struct cpuinfo_x86 *cpu = &cpu_data(policy->cpu);
- unsigned freq;
unsigned l, h;
int i;

@@ -394,12 +393,8 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
}
}

- freq = get_cur_freq(policy->cpu);
policy->cpuinfo.transition_latency = 10000;
/* 10uS transition latency */
- policy->cur = freq;
-
- pr_debug("centrino_cpu_init: cur=%dkHz\n", policy->cur);

return cpufreq_table_validate_and_show(policy,
per_cpu(centrino_model, policy->cpu)->op_points);
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c
index 929a4f0..1a8b01b 100644
--- a/drivers/cpufreq/speedstep-ich.c
+++ b/drivers/cpufreq/speedstep-ich.c
@@ -308,7 +308,7 @@ static void get_freqs_on_cpu(void *_get_freqs)

static int speedstep_cpu_init(struct cpufreq_policy *policy)
{
- unsigned int policy_cpu, speed;
+ unsigned int policy_cpu;
struct get_freqs gf;

/* only run on CPU to be set, or on its sibling */
@@ -323,19 +323,6 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
if (gf.ret)
return gf.ret;

- /* get current speed setting */
- speed = speedstep_get(policy_cpu);
- if (!speed)
- return -EIO;
-
- pr_debug("currently at %s speed setting - %i MHz\n",
- (speed == speedstep_freqs[SPEEDSTEP_LOW].frequency)
- ? "low" : "high",
- (speed / 1000));
-
- /* cpuinfo and default policy values */
- policy->cur = speed;
-
return cpufreq_table_validate_and_show(policy, speedstep_freqs);
}

diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
index b3dfba0..a02b649 100644
--- a/drivers/cpufreq/speedstep-smi.c
+++ b/drivers/cpufreq/speedstep-smi.c
@@ -267,7 +267,6 @@ static int speedstep_target(struct cpufreq_policy *policy,
static int speedstep_cpu_init(struct cpufreq_policy *policy)
{
int result;
- unsigned int speed, state;
unsigned int *low, *high;

/* capability check */
@@ -303,19 +302,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
pr_debug("workaround worked.\n");
}

- /* get current speed setting */
- state = speedstep_get_state();
- speed = speedstep_freqs[state].frequency;
-
- pr_debug("currently at %s speed setting - %i MHz\n",
- (speed == speedstep_freqs[SPEEDSTEP_LOW].frequency)
- ? "low" : "high",
- (speed / 1000));
-
- /* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
- policy->cur = speed;
-
return cpufreq_table_validate_and_show(policy, speedstep_freqs);
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:18:08

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 127/228] cpufreq: create cpufreq_generic_init() routine

Many CPUFreq drivers for SMP system (where all cores share same clock lines), do
similar stuff in their ->init() part.

This patch creates a generic routine in cpufreq core which can be used by these
so that we can remove some redundant code.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/Kconfig | 1 +
drivers/cpufreq/cpufreq.c | 31 +++++++++++++++++++++++++++++++
include/linux/cpufreq.h | 3 +++
3 files changed, 35 insertions(+)

diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 534fcb8..2d06754 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -2,6 +2,7 @@ menu "CPU Frequency scaling"

config CPU_FREQ
bool "CPU Frequency scaling"
+ select CPU_FREQ_TABLE
help
CPU Frequency scaling allows you to change the clock speed of
CPUs on the fly. This is a nice method to save power, because
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 1e6b602..c4d89c5 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -183,6 +183,37 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy)
}
EXPORT_SYMBOL_GPL(get_cpu_idle_time);

+/*
+ * This is a generic cpufreq init() routine which can be used by cpufreq
+ * drivers of SMP systems. It will do following:
+ * - validate & show freq table passed
+ * - set policies transition latency
+ * - policy->cpus with all possible CPUs
+ */
+int cpufreq_generic_init(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table,
+ unsigned int transition_latency)
+{
+ int ret;
+
+ ret = cpufreq_table_validate_and_show(policy, table);
+ if (ret) {
+ pr_err("%s: invalid frequency table: %d\n", __func__, ret);
+ return ret;
+ }
+
+ policy->cpuinfo.transition_latency = transition_latency;
+
+ /*
+ * The driver only supports the SMP configuartion where all processors
+ * share the clock and voltage and clock.
+ */
+ cpumask_setall(policy->cpus);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(cpufreq_generic_init);
+
struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
{
struct cpufreq_policy *policy = NULL;
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 57d2907..c2184c6 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -438,6 +438,9 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu);
int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table);

+int cpufreq_generic_init(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table,
+ unsigned int transition_latency);
static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)
{
cpufreq_frequency_table_put_attr(policy->cpu);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:18:18

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 128/228] cpufreq: remove CONFIG_CPU_FREQ_TABLE

CONFIG_CPU_FREQ_TABLE will be always enabled when cpufreq framework is used, as
cpufreq core depends on it. So, we don't need this CONFIG option anymore as it
is not configurable. Remove CONFIG_CPU_FREQ_TABLE and update its users.

Signed-off-by: Viresh Kumar <[email protected]>
---
arch/arm/mach-davinci/Kconfig | 1 -
arch/arm/mach-pxa/Kconfig | 3 ---
arch/arm/mach-ux500/Kconfig | 1 -
arch/blackfin/Kconfig | 1 -
arch/cris/Kconfig | 2 --
drivers/cpufreq/Kconfig | 12 ------------
drivers/cpufreq/Kconfig.arm | 11 -----------
drivers/cpufreq/Kconfig.powerpc | 6 ------
drivers/cpufreq/Kconfig.x86 | 13 -------------
drivers/cpufreq/Makefile | 5 +----
drivers/cpufreq/cpufreq.c | 2 --
drivers/thermal/Kconfig | 1 -
12 files changed, 1 insertion(+), 57 deletions(-)

diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index e026b19..a075b3e 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -40,7 +40,6 @@ config ARCH_DAVINCI_DA850
bool "DA850/OMAP-L138/AM18x based system"
select ARCH_DAVINCI_DA8XX
select ARCH_HAS_CPUFREQ
- select CPU_FREQ_TABLE
select CP_INTC

config ARCH_DAVINCI_DA8XX
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index a842711..96100db 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -615,14 +615,12 @@ endmenu
config PXA25x
bool
select CPU_XSCALE
- select CPU_FREQ_TABLE if CPU_FREQ
help
Select code specific to PXA21x/25x/26x variants

config PXA27x
bool
select CPU_XSCALE
- select CPU_FREQ_TABLE if CPU_FREQ
help
Select code specific to PXA27x variants

@@ -635,7 +633,6 @@ config CPU_PXA26x
config PXA3xx
bool
select CPU_XSC3
- select CPU_FREQ_TABLE if CPU_FREQ
help
Select code specific to PXA3xx variants

diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index b19b072..e6eaefa 100644
--- a/arch/arm/mach-ux500/Kconfig
+++ b/arch/arm/mach-ux500/Kconfig
@@ -34,7 +34,6 @@ config UX500_SOC_COMMON

config UX500_SOC_DB8500
bool
- select CPU_FREQ_TABLE if CPU_FREQ
select MFD_DB8500_PRCMU
select PINCTRL_DB8500
select PINCTRL_DB8540
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 3b6abc5..1ac474a 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -1430,7 +1430,6 @@ source "drivers/cpufreq/Kconfig"
config BFIN_CPU_FREQ
bool
depends on CPU_FREQ
- select CPU_FREQ_TABLE
default y

config CPU_VOLTAGE
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 3201ddb..9f3c5436 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -134,13 +134,11 @@ config SVINTO_SIM

config ETRAXFS
bool "ETRAX-FS-V32"
- select CPU_FREQ_TABLE if CPU_FREQ
help
Support CRIS V32.

config CRIS_MACH_ARTPEC3
bool "ARTPEC-3"
- select CPU_FREQ_TABLE if CPU_FREQ
help
Support Axis ARTPEC-3.

diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 2d06754..38093e2 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -2,7 +2,6 @@ menu "CPU Frequency scaling"

config CPU_FREQ
bool "CPU Frequency scaling"
- select CPU_FREQ_TABLE
help
CPU Frequency scaling allows you to change the clock speed of
CPUs on the fly. This is a nice method to save power, because
@@ -18,15 +17,11 @@ config CPU_FREQ

if CPU_FREQ

-config CPU_FREQ_TABLE
- tristate
-
config CPU_FREQ_GOV_COMMON
bool

config CPU_FREQ_STAT
tristate "CPU frequency translation statistics"
- select CPU_FREQ_TABLE
default y
help
This driver exports CPU frequency statistics information through sysfs
@@ -144,7 +139,6 @@ config CPU_FREQ_GOV_USERSPACE

config CPU_FREQ_GOV_ONDEMAND
tristate "'ondemand' cpufreq policy governor"
- select CPU_FREQ_TABLE
select CPU_FREQ_GOV_COMMON
help
'ondemand' - This driver adds a dynamic cpufreq policy governor.
@@ -188,7 +182,6 @@ config CPU_FREQ_GOV_CONSERVATIVE
config GENERIC_CPUFREQ_CPU0
tristate "Generic CPU0 cpufreq driver"
depends on HAVE_CLK && REGULATOR && PM_OPP && OF
- select CPU_FREQ_TABLE
help
This adds a generic cpufreq driver for CPU0 frequency management.
It supports both uniprocessor (UP) and symmetric multiprocessor (SMP)
@@ -224,7 +217,6 @@ depends on IA64

config IA64_ACPI_CPUFREQ
tristate "ACPI Processor P-States driver"
- select CPU_FREQ_TABLE
depends on ACPI_PROCESSOR
help
This driver adds a CPUFreq driver which utilizes the ACPI
@@ -241,7 +233,6 @@ depends on MIPS

config LOONGSON2_CPUFREQ
tristate "Loongson2 CPUFreq Driver"
- select CPU_FREQ_TABLE
help
This option adds a CPUFreq driver for loongson processors which
support software configurable cpu frequency.
@@ -263,7 +254,6 @@ menu "SPARC CPU frequency scaling drivers"
depends on SPARC64
config SPARC_US3_CPUFREQ
tristate "UltraSPARC-III CPU Frequency driver"
- select CPU_FREQ_TABLE
help
This adds the CPUFreq driver for UltraSPARC-III processors.

@@ -273,7 +263,6 @@ config SPARC_US3_CPUFREQ

config SPARC_US2E_CPUFREQ
tristate "UltraSPARC-IIe CPU Frequency driver"
- select CPU_FREQ_TABLE
help
This adds the CPUFreq driver for UltraSPARC-IIe processors.

@@ -286,7 +275,6 @@ menu "SH CPU Frequency scaling"
depends on SUPERH
config SH_CPU_FREQ
tristate "SuperH CPU Frequency driver"
- select CPU_FREQ_TABLE
help
This adds the cpufreq driver for SuperH. Any CPU that supports
clock rate rounding through the clock framework can use this
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 0fa204b..701ec95 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -5,7 +5,6 @@
config ARM_BIG_LITTLE_CPUFREQ
tristate "Generic ARM big LITTLE CPUfreq driver"
depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK
- select CPU_FREQ_TABLE
help
This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.

@@ -18,7 +17,6 @@ config ARM_DT_BL_CPUFREQ

config ARM_EXYNOS_CPUFREQ
bool
- select CPU_FREQ_TABLE

config ARM_EXYNOS4210_CPUFREQ
bool "SAMSUNG EXYNOS4210"
@@ -58,7 +56,6 @@ config ARM_EXYNOS5440_CPUFREQ
depends on SOC_EXYNOS5440
depends on HAVE_CLK && PM_OPP && OF
default y
- select CPU_FREQ_TABLE
help
This adds the CPUFreq driver for Samsung EXYNOS5440
SoC. The nature of exynos5440 clock controller is
@@ -85,7 +82,6 @@ config ARM_IMX6Q_CPUFREQ
tristate "Freescale i.MX6Q cpufreq support"
depends on SOC_IMX6Q
depends on REGULATOR_ANATOP
- select CPU_FREQ_TABLE
help
This adds cpufreq driver support for Freescale i.MX6Q SOC.

@@ -101,7 +97,6 @@ config ARM_INTEGRATOR

config ARM_KIRKWOOD_CPUFREQ
def_bool ARCH_KIRKWOOD && OF
- select CPU_FREQ_TABLE
help
This adds the CPUFreq driver for Marvell Kirkwood
SoCs.
@@ -110,7 +105,6 @@ config ARM_OMAP2PLUS_CPUFREQ
bool "TI OMAP2+"
depends on ARCH_OMAP2PLUS
default ARCH_OMAP2PLUS
- select CPU_FREQ_TABLE

config ARM_S3C_CPUFREQ
bool
@@ -165,7 +159,6 @@ config ARM_S3C2412_CPUFREQ
config ARM_S3C2416_CPUFREQ
bool "S3C2416 CPU Frequency scaling support"
depends on CPU_S3C2416
- select CPU_FREQ_TABLE
help
This adds the CPUFreq driver for the Samsung S3C2416 and
S3C2450 SoC. The S3C2416 supports changing the rate of the
@@ -196,7 +189,6 @@ config ARM_S3C2440_CPUFREQ
config ARM_S3C64XX_CPUFREQ
bool "Samsung S3C64XX"
depends on CPU_S3C6410
- select CPU_FREQ_TABLE
default y
help
This adds the CPUFreq driver for Samsung S3C6410 SoC.
@@ -206,7 +198,6 @@ config ARM_S3C64XX_CPUFREQ
config ARM_S5PV210_CPUFREQ
bool "Samsung S5PV210 and S5PC110"
depends on CPU_S5PV210
- select CPU_FREQ_TABLE
default y
help
This adds the CPUFreq driver for Samsung S5PV210 and
@@ -223,7 +214,6 @@ config ARM_SA1110_CPUFREQ
config ARM_SPEAR_CPUFREQ
bool "SPEAr CPUFreq support"
depends on PLAT_SPEAR
- select CPU_FREQ_TABLE
default y
help
This adds the CPUFreq driver support for SPEAr SOCs.
@@ -231,7 +221,6 @@ config ARM_SPEAR_CPUFREQ
config ARM_TEGRA_CPUFREQ
bool "TEGRA CPUFreq support"
depends on ARCH_TEGRA
- select CPU_FREQ_TABLE
default y
help
This adds the CPUFreq driver support for TEGRA SOCs.
diff --git a/drivers/cpufreq/Kconfig.powerpc b/drivers/cpufreq/Kconfig.powerpc
index 25ca9db..ca0021a 100644
--- a/drivers/cpufreq/Kconfig.powerpc
+++ b/drivers/cpufreq/Kconfig.powerpc
@@ -1,7 +1,6 @@
config CPU_FREQ_CBE
tristate "CBE frequency scaling"
depends on CBE_RAS && PPC_CELL
- select CPU_FREQ_TABLE
default m
help
This adds the cpufreq driver for Cell BE processors.
@@ -20,7 +19,6 @@ config CPU_FREQ_CBE_PMI
config CPU_FREQ_MAPLE
bool "Support for Maple 970FX Evaluation Board"
depends on PPC_MAPLE
- select CPU_FREQ_TABLE
help
This adds support for frequency switching on Maple 970FX
Evaluation Board and compatible boards (IBM JS2x blades).
@@ -28,7 +26,6 @@ config CPU_FREQ_MAPLE
config PPC_CORENET_CPUFREQ
tristate "CPU frequency scaling driver for Freescale E500MC SoCs"
depends on PPC_E500MC && OF && COMMON_CLK
- select CPU_FREQ_TABLE
select CLK_PPC_CORENET
help
This adds the CPUFreq driver support for Freescale e500mc,
@@ -38,7 +35,6 @@ config PPC_CORENET_CPUFREQ
config CPU_FREQ_PMAC
bool "Support for Apple PowerBooks"
depends on ADB_PMU && PPC32
- select CPU_FREQ_TABLE
help
This adds support for frequency switching on Apple PowerBooks,
this currently includes some models of iBook & Titanium
@@ -47,7 +43,6 @@ config CPU_FREQ_PMAC
config CPU_FREQ_PMAC64
bool "Support for some Apple G5s"
depends on PPC_PMAC && PPC64
- select CPU_FREQ_TABLE
help
This adds support for frequency switching on Apple iMac G5,
and some of the more recent desktop G5 machines as well.
@@ -55,7 +50,6 @@ config CPU_FREQ_PMAC64
config PPC_PASEMI_CPUFREQ
bool "Support for PA Semi PWRficient"
depends on PPC_PASEMI
- select CPU_FREQ_TABLE
default y
help
This adds the support for frequency switching on PA Semi
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86
index e2b6eab..6897ad8 100644
--- a/drivers/cpufreq/Kconfig.x86
+++ b/drivers/cpufreq/Kconfig.x86
@@ -31,7 +31,6 @@ config X86_PCC_CPUFREQ

config X86_ACPI_CPUFREQ
tristate "ACPI Processor P-States driver"
- select CPU_FREQ_TABLE
depends on ACPI_PROCESSOR
help
This driver adds a CPUFreq driver which utilizes the ACPI
@@ -60,7 +59,6 @@ config X86_ACPI_CPUFREQ_CPB

config ELAN_CPUFREQ
tristate "AMD Elan SC400 and SC410"
- select CPU_FREQ_TABLE
depends on MELAN
---help---
This adds the CPUFreq driver for AMD Elan SC400 and SC410
@@ -76,7 +74,6 @@ config ELAN_CPUFREQ

config SC520_CPUFREQ
tristate "AMD Elan SC520"
- select CPU_FREQ_TABLE
depends on MELAN
---help---
This adds the CPUFreq driver for AMD Elan SC520 processor.
@@ -88,7 +85,6 @@ config SC520_CPUFREQ

config X86_POWERNOW_K6
tristate "AMD Mobile K6-2/K6-3 PowerNow!"
- select CPU_FREQ_TABLE
depends on X86_32
help
This adds the CPUFreq driver for mobile AMD K6-2+ and mobile
@@ -100,7 +96,6 @@ config X86_POWERNOW_K6

config X86_POWERNOW_K7
tristate "AMD Mobile Athlon/Duron PowerNow!"
- select CPU_FREQ_TABLE
depends on X86_32
help
This adds the CPUFreq driver for mobile AMD K7 mobile processors.
@@ -118,7 +113,6 @@ config X86_POWERNOW_K7_ACPI

config X86_POWERNOW_K8
tristate "AMD Opteron/Athlon64 PowerNow!"
- select CPU_FREQ_TABLE
depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ
help
This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors.
@@ -132,7 +126,6 @@ config X86_POWERNOW_K8
config X86_AMD_FREQ_SENSITIVITY
tristate "AMD frequency sensitivity feedback powersave bias"
depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD
- select CPU_FREQ_TABLE
help
This adds AMD-specific powersave bias function to the ondemand
governor, which allows it to make more power-conscious frequency
@@ -160,7 +153,6 @@ config X86_GX_SUSPMOD

config X86_SPEEDSTEP_CENTRINO
tristate "Intel Enhanced SpeedStep (deprecated)"
- select CPU_FREQ_TABLE
select X86_SPEEDSTEP_CENTRINO_TABLE if X86_32
depends on X86_32 || (X86_64 && ACPI_PROCESSOR)
help
@@ -190,7 +182,6 @@ config X86_SPEEDSTEP_CENTRINO_TABLE

config X86_SPEEDSTEP_ICH
tristate "Intel Speedstep on ICH-M chipsets (ioport interface)"
- select CPU_FREQ_TABLE
depends on X86_32
help
This adds the CPUFreq driver for certain mobile Intel Pentium III
@@ -204,7 +195,6 @@ config X86_SPEEDSTEP_ICH

config X86_SPEEDSTEP_SMI
tristate "Intel SpeedStep on 440BX/ZX/MX chipsets (SMI interface)"
- select CPU_FREQ_TABLE
depends on X86_32
help
This adds the CPUFreq driver for certain mobile Intel Pentium III
@@ -217,7 +207,6 @@ config X86_SPEEDSTEP_SMI

config X86_P4_CLOCKMOD
tristate "Intel Pentium 4 clock modulation"
- select CPU_FREQ_TABLE
help
This adds the CPUFreq driver for Intel Pentium 4 / XEON
processors. When enabled it will lower CPU temperature by skipping
@@ -259,7 +248,6 @@ config X86_LONGRUN

config X86_LONGHAUL
tristate "VIA Cyrix III Longhaul"
- select CPU_FREQ_TABLE
depends on X86_32 && ACPI_PROCESSOR
help
This adds the CPUFreq driver for VIA Samuel/CyrixIII,
@@ -272,7 +260,6 @@ config X86_LONGHAUL

config X86_E_POWERSAVER
tristate "VIA C7 Enhanced PowerSaver (DANGEROUS)"
- select CPU_FREQ_TABLE
depends on X86_32 && ACPI_PROCESSOR
help
This adds the CPUFreq driver for VIA C7 processors. However, this driver
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index ad5866c..b7948bb 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -1,5 +1,5 @@
# CPUfreq core
-obj-$(CONFIG_CPU_FREQ) += cpufreq.o
+obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o
# CPUfreq stats
obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o

@@ -11,9 +11,6 @@ obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o
obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o
obj-$(CONFIG_CPU_FREQ_GOV_COMMON) += cpufreq_governor.o

-# CPUfreq cross-arch helpers
-obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o
-
obj-$(CONFIG_GENERIC_CPUFREQ_CPU0) += cpufreq-cpu0.o

##################################################################################
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index c4d89c5..5295694 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1025,9 +1025,7 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)
policy->last_cpu = policy->cpu;
policy->cpu = cpu;

-#ifdef CONFIG_CPU_FREQ_TABLE
cpufreq_frequency_table_update_policy_cpu(policy);
-#endif
blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
CPUFREQ_UPDATE_POLICY_CPU, policy);
}
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index e988c81..6a5b948 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -69,7 +69,6 @@ config THERMAL_GOV_USER_SPACE
config CPU_THERMAL
bool "generic cpu cooling support"
depends on CPU_FREQ
- select CPU_FREQ_TABLE
help
This implements the generic cpu cooling mechanism through frequency
reduction. An ACPI version of this already exists
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:18:27

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 129/228] cpufreq: cpu0: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Cc: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq-cpu0.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 2486c13..d8756e7 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -121,24 +121,7 @@ post_notify:

static int cpu0_cpufreq_init(struct cpufreq_policy *policy)
{
- int ret;
-
- ret = cpufreq_table_validate_and_show(policy, freq_table);
- if (ret) {
- pr_err("invalid frequency table: %d\n", ret);
- return ret;
- }
-
- policy->cpuinfo.transition_latency = transition_latency;
-
- /*
- * The driver only supports the SMP configuartion where all processors
- * share the clock and voltage and clock. Use cpufreq affected_cpus
- * interface to have all CPUs scaled together.
- */
- cpumask_setall(policy->cpus);
-
- return 0;
+ return cpufreq_generic_init(policy, freq_table, transition_latency);
}

static struct cpufreq_driver cpu0_cpufreq_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:18:37

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 131/228] cpufreq: davinci: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Cc: Sekhar Nori <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/davinci-cpufreq.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index 55cf094..972583b 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -136,21 +136,13 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)
return result;
}

- result = cpufreq_table_validate_and_show(policy, freq_table);
- if (result) {
- pr_err("%s: cpufreq_table_validate_and_show() failed",
- __func__);
- return result;
- }
-
/*
* Time measurement across the target() function yields ~1500-1800us
* time taken with no drivers on notification list.
* Setting the latency to 2000 us to accommodate addition of drivers
* to pre/post change notification list.
*/
- policy->cpuinfo.transition_latency = 2000 * 1000;
- return 0;
+ return cpufreq_generic_init(policy, freq_table, 2000 * 1000);
}

static struct cpufreq_driver davinci_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:18:43

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 132/228] cpufreq: dbx500: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/dbx500-cpufreq.c | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index ae1aa60..a60f769 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -74,26 +74,7 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu)

static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
{
- int res;
-
- /* get policy fields based on the table */
- res = cpufreq_table_validate_and_show(policy, freq_table);
- if (res) {
- pr_err("dbx500-cpufreq: Failed to read policy table\n");
- return res;
- }
-
- /*
- * FIXME : Need to take time measurement across the target()
- * function with no/some/all drivers in the notification
- * list.
- */
- policy->cpuinfo.transition_latency = 20 * 1000; /* in ns */
-
- /* policy sharing between dual CPUs */
- cpumask_setall(policy->cpus);
-
- return 0;
+ return cpufreq_generic_init(policy, freq_table, 20 * 1000);
}

static struct cpufreq_driver dbx500_cpufreq_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:18:52

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 133/228] cpufreq: exynos: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/exynos-cpufreq.c | 7 +------
drivers/cpufreq/exynos5440-cpufreq.c | 14 ++------------
2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 5244086..b96fcc8 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -241,12 +241,7 @@ static struct notifier_block exynos_cpufreq_nb = {

static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
- /* set the transition latency value */
- policy->cpuinfo.transition_latency = 100000;
-
- cpumask_setall(policy->cpus);
-
- return cpufreq_table_validate_and_show(policy, exynos_info->freq_table);
+ return cpufreq_generic_init(policy, exynos_info->freq_table, 100000);
}

static struct cpufreq_driver exynos_driver = {
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index a7d272b..e6fae7f 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -321,18 +321,8 @@ static void exynos_sort_descend_freq_table(void)

static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
- int ret;
-
- ret = cpufreq_table_validate_and_show(policy, dvfs_info->freq_table);
- if (ret) {
- dev_err(dvfs_info->dev, "Invalid frequency table: %d\n", ret);
- return ret;
- }
-
- policy->cpuinfo.transition_latency = dvfs_info->latency;
- cpumask_setall(policy->cpus);
-
- return 0;
+ return cpufreq_generic_init(policy, dvfs_info->freq_table,
+ dvfs_info->latency);
}

static struct cpufreq_driver exynos_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:19:01

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 134/228] cpufreq: imx6q: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/imx6q-cpufreq.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 649547f..3fb3f59 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -153,18 +153,7 @@ post_notify:

static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
{
- int ret;
-
- ret = cpufreq_table_validate_and_show(policy, freq_table);
- if (ret) {
- dev_err(cpu_dev, "invalid frequency table: %d\n", ret);
- return ret;
- }
-
- policy->cpuinfo.transition_latency = transition_latency;
- cpumask_setall(policy->cpus);
-
- return 0;
+ return cpufreq_generic_init(policy, freq_table, transition_latency);
}

static struct cpufreq_driver imx6q_cpufreq_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:19:14

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 136/228] cpufreq: loongson2: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here. This driver wasn't setting transition_latency and so is getting set to 0
by default. Lets mark it explicitly by calling the generic routine with
transition_latency as 0.

Cc: Aaro Koskinen <[email protected]>
Cc: John Crispin <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/loongson2_cpufreq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index dd4f3e4..2c8ec8e 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -131,8 +131,7 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
return ret;
}

- return cpufreq_table_validate_and_show(policy,
- &loongson2_clockmod_table[0]);
+ return cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0);
}

static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:19:30

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 138/228] cpufreq: omap: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

This also rearranges the code a bit to make it more sensible. Also removes some
unnecessary checks.

Cc: Santosh Shilimkar <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/omap-cpufreq.c | 41 +++++++++++------------------------------
1 file changed, 11 insertions(+), 30 deletions(-)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index a8c3f90..58b2200 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -160,50 +160,31 @@ static inline void freq_table_free(void)

static int omap_cpu_init(struct cpufreq_policy *policy)
{
- int result = 0;
+ int result;

mpu_clk = clk_get(NULL, "cpufreq_ck");
if (IS_ERR(mpu_clk))
return PTR_ERR(mpu_clk);

- if (policy->cpu >= NR_CPUS) {
- result = -EINVAL;
- goto fail_ck;
- }
-
- if (!freq_table)
+ if (!freq_table) {
result = opp_init_cpufreq_table(mpu_dev, &freq_table);
-
- if (result) {
- dev_err(mpu_dev, "%s: cpu%d: failed creating freq table[%d]\n",
+ if (result) {
+ dev_err(mpu_dev,
+ "%s: cpu%d: failed creating freq table[%d]\n",
__func__, policy->cpu, result);
- goto fail_ck;
+ goto fail;
+ }
}

atomic_inc_return(&freq_table_users);

- result = cpufreq_table_validate_and_show(policy, freq_table);
- if (result)
- goto fail_table;
-
- /*
- * On OMAP SMP configuartion, both processors share the voltage
- * and clock. So both CPUs needs to be scaled together and hence
- * needs software co-ordination. Use cpufreq affected_cpus
- * interface to handle this scenario. Additional is_smp() check
- * is to keep SMP_ON_UP build working.
- */
- if (is_smp())
- cpumask_setall(policy->cpus);
-
/* FIXME: what's the actual transition time? */
- policy->cpuinfo.transition_latency = 300 * 1000;
-
- return 0;
+ result = cpufreq_generic_init(policy, freq_table, 300 * 1000);
+ if (!result)
+ return 0;

-fail_table:
freq_table_free();
-fail_ck:
+fail:
clk_put(mpu_clk);
return result;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:19:35

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 137/228] cpufreq: maple: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/maple-cpufreq.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index 1c0cec1..eb1e176 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -165,16 +165,9 @@ static unsigned int maple_cpufreq_get_speed(unsigned int cpu)

static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
- policy->cpuinfo.transition_latency = 12000;
- /* secondary CPUs are tied to the primary one by the
- * cpufreq core if in the secondary policy we tell it that
- * it actually must be one policy together with all others. */
- cpumask_setall(policy->cpus);
-
- return cpufreq_table_validate_and_show(policy, maple_cpu_freqs);
+ return cpufreq_generic_init(policy, maple_cpu_freqs, 12000);
}

-
static struct cpufreq_driver maple_cpufreq_driver = {
.name = "maple",
.flags = CPUFREQ_CONST_LOOPS,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:19:43

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 140/228] cpufreq: pmac32: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Cc: Benjamin Herrenschmidt <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pmac32-cpufreq.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index 672b7f4..6eac1e2 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -392,12 +392,7 @@ static int pmac_cpufreq_target( struct cpufreq_policy *policy,

static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
- if (policy->cpu != 0)
- return -ENODEV;
-
- policy->cpuinfo.transition_latency = transition_latency;
-
- return cpufreq_table_validate_and_show(policy, pmac_cpu_freqs);
+ return cpufreq_generic_init(policy, pmac_cpu_freqs, transition_latency);
}

static u32 read_gpio(struct device_node *np)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:19:52

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 142/228] cpufreq: s3c: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s3c2416-cpufreq.c | 6 ++----
drivers/cpufreq/s3c24xx-cpufreq.c | 13 +------------
drivers/cpufreq/s3c64xx-cpufreq.c | 5 ++---
3 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index 22c4c2d..26a35d1 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -479,10 +479,8 @@ static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)
/* Datasheet says PLL stabalisation time must be at least 300us,
* so but add some fudge. (reference in LOCKCON0 register description)
*/
- policy->cpuinfo.transition_latency = (500 * 1000) +
- s3c_freq->regulator_latency;
-
- ret = cpufreq_table_validate_and_show(policy, s3c_freq->freq_table);
+ ret = cpufreq_generic_init(policy, s3c_freq->freq_table,
+ (500 * 1000) + s3c_freq->regulator_latency);
if (ret)
goto err_freq_table;

diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index e0fbaef..4850882 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -373,18 +373,7 @@ struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name)

static int s3c_cpufreq_init(struct cpufreq_policy *policy)
{
- printk(KERN_INFO "%s: initialising policy %p\n", __func__, policy);
-
- if (policy->cpu != 0)
- return -EINVAL;
-
- /* feed the latency information from the cpu driver */
- policy->cpuinfo.transition_latency = cpu_cur.info->latency;
-
- if (ftab)
- return cpufreq_table_validate_and_show(policy, ftab);
-
- return 0;
+ return cpufreq_generic_init(policy, ftab, cpu_cur.info->latency);
}

static int __init s3c_cpufreq_initclks(void)
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index a66cfa3..16dc315 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -239,9 +239,8 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
* the PLLs, which we don't currently) is ~300us worst case,
* but add some fudge.
*/
- policy->cpuinfo.transition_latency = (500 * 1000) + regulator_latency;
-
- ret = cpufreq_table_validate_and_show(policy, s3c64xx_freq_table);
+ ret = cpufreq_generic_init(policy, s3c64xx_freq_table,
+ (500 * 1000) + regulator_latency);
if (ret != 0) {
pr_err("Failed to configure frequency table: %d\n",
ret);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:20:02

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 143/228] cpufreq: s5pv210: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s5pv210-cpufreq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 30d9bb7..600b4f4 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -543,9 +543,7 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000);
s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk);

- policy->cpuinfo.transition_latency = 40000;
-
- return cpufreq_table_validate_and_show(policy, s5pv210_freq_table);
+ return cpufreq_generic_init(policy, s5pv210_freq_table, 40000);

out_dmc1:
clk_put(dmc0_clk);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:20:08

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 144/228] cpufreq: sa11x0: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sa1100-cpufreq.c | 6 +-----
drivers/cpufreq/sa1110-cpufreq.c | 6 +-----
2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c
index a1d1bb7..b282cea 100644
--- a/drivers/cpufreq/sa1100-cpufreq.c
+++ b/drivers/cpufreq/sa1100-cpufreq.c
@@ -218,11 +218,7 @@ static int sa1100_target(struct cpufreq_policy *policy,

static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
{
- if (policy->cpu != 0)
- return -EINVAL;
- policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
-
- return cpufreq_table_validate_and_show(policy, sa11x0_freq_table);
+ return cpufreq_generic_init(policy, sa11x0_freq_table, CPUFREQ_ETERNAL);
}

static struct cpufreq_driver sa1100_driver __refdata = {
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c
index 9da940e..bca04c0 100644
--- a/drivers/cpufreq/sa1110-cpufreq.c
+++ b/drivers/cpufreq/sa1110-cpufreq.c
@@ -332,11 +332,7 @@ static int sa1110_target(struct cpufreq_policy *policy,

static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
{
- if (policy->cpu != 0)
- return -EINVAL;
- policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
-
- return cpufreq_table_validate_and_show(policy, sa11x0_freq_table);
+ return cpufreq_generic_init(policy, sa11x0_freq_table, CPUFREQ_ETERNAL);
}

/* sa1110_driver needs __refdata because it must remain after init registers
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:20:14

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 145/228] cpufreq: spear: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/spear-cpufreq.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index aacdb61..2a03158 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -171,18 +171,8 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,

static int spear_cpufreq_init(struct cpufreq_policy *policy)
{
- int ret;
-
- ret = cpufreq_table_validate_and_show(policy, spear_cpufreq.freq_tbl);
- if (ret) {
- pr_err("cpufreq_table_validate_and_show() failed");
- return ret;
- }
-
- policy->cpuinfo.transition_latency = spear_cpufreq.transition_latency;
- cpumask_setall(policy->cpus);
-
- return 0;
+ return cpufreq_generic_init(policy, spear_cpufreq.freq_tbl,
+ spear_cpufreq.transition_latency);
}

static struct cpufreq_driver spear_cpufreq_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:20:27

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 147/228] cpufreq: Implement light weight ->target_index() routine

Currently prototype of cpufreq_drivers target routines is:

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

And most of the drivers call cpufreq_frequency_table_target() to get a valid
index of their frequency table which is closest to the target_freq. And they
don't use target_freq and relation after it.

So, it makes sense to just do this work in cpufreq core before calling
cpufreq_frequency_table_target() and simply pass index instead. But this can be
done only with drivers which expose their frequency table with cpufreq core. For
others we need to stick with the old prototype of target() until those drivers
are converted to expose frequency tables.

This patch implements the new light weight prototype for target_index() routine.
It looks like this:

int target_index(struct cpufreq_policy *policy, unsigned int index);

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and pass index to it. Because CPUFreq core now requires to call routines
present in freq_table.c CONFIG_CPU_FREQ_TABLE must be enabled all the time.

This also marks target() interface as deprecated. So, that new drivers avoid
using it. And Documentation is updated accordingly.

Signed-off-by: Viresh Kumar <[email protected]>
---
Documentation/cpu-freq/cpu-drivers.txt | 27 ++++++++++------
Documentation/cpu-freq/governors.txt | 4 +--
drivers/cpufreq/cpufreq.c | 59 +++++++++++++++++++++++++++-------
include/linux/cpufreq.h | 4 ++-
4 files changed, 71 insertions(+), 23 deletions(-)

diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt
index 40282e6..8b1a445 100644
--- a/Documentation/cpu-freq/cpu-drivers.txt
+++ b/Documentation/cpu-freq/cpu-drivers.txt
@@ -23,8 +23,8 @@ Contents:
1.1 Initialization
1.2 Per-CPU Initialization
1.3 verify
-1.4 target or setpolicy?
-1.5 target
+1.4 target/target_index or setpolicy?
+1.5 target/target_index
1.6 setpolicy
2. Frequency Table Helpers

@@ -56,7 +56,8 @@ cpufreq_driver.init - A pointer to the per-CPU initialization
cpufreq_driver.verify - A pointer to a "verification" function.

cpufreq_driver.setpolicy _or_
-cpufreq_driver.target - See below on the differences.
+cpufreq_driver.target/
+target_index - See below on the differences.

And optionally

@@ -66,7 +67,7 @@ cpufreq_driver.resume - A pointer to a per-CPU resume function
which is called with interrupts disabled
and _before_ the pre-suspend frequency
and/or policy is restored by a call to
- ->target or ->setpolicy.
+ ->target/target_index or ->setpolicy.

cpufreq_driver.attr - A pointer to a NULL-terminated list of
"struct freq_attr" which allow to
@@ -103,8 +104,8 @@ policy->governor must contain the "default policy" for
this CPU. A few moments later,
cpufreq_driver.verify and either
cpufreq_driver.setpolicy or
- cpufreq_driver.target is called with
- these values.
+ cpufreq_driver.target/target_index is called
+ with these values.

For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the
frequency table helpers might be helpful. See the section 2 for more information
@@ -133,20 +134,28 @@ range) is within policy->min and policy->max. If necessary, increase
policy->max first, and only if this is no solution, decrease policy->min.


-1.4 target or setpolicy?
+1.4 target/target_index or setpolicy?
----------------------------

Most cpufreq drivers or even most cpu frequency scaling algorithms
only allow the CPU to be set to one frequency. For these, you use the
-->target call.
+->target/target_index call.

Some cpufreq-capable processors switch the frequency between certain
limits on their own. These shall use the ->setpolicy call


-1.4. target
+1.4. target/target_index
-------------

+The target_index call has two arguments: struct cpufreq_policy *policy,
+and unsigned int index (into the exposed frequency table).
+
+The CPUfreq driver must set the new frequency when called here. The
+actual frequency must be determined by freq_table[index].frequency.
+
+Deprecated:
+----------
The target call has three arguments: struct cpufreq_policy *policy,
unsigned int target_frequency, unsigned int relation.

diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt
index 219970b..77ec215 100644
--- a/Documentation/cpu-freq/governors.txt
+++ b/Documentation/cpu-freq/governors.txt
@@ -40,7 +40,7 @@ Most cpufreq drivers (in fact, all except one, longrun) or even most
cpu frequency scaling algorithms only offer the CPU to be set to one
frequency. In order to offer dynamic frequency scaling, the cpufreq
core must be able to tell these drivers of a "target frequency". So
-these specific drivers will be transformed to offer a "->target"
+these specific drivers will be transformed to offer a "->target/target_index"
call instead of the existing "->setpolicy" call. For "longrun", all
stays the same, though.

@@ -71,7 +71,7 @@ CPU can be set to switch independently | CPU can only be set
/ the limits of policy->{min,max}
/ \
/ \
- Using the ->setpolicy call, Using the ->target call,
+ Using the ->setpolicy call, Using the ->target/target_index call,
the limits and the the frequency closest
"policy" is set. to target_freq is set.
It is assured that it
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 5295694..3fd24b1 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -47,6 +47,11 @@ static LIST_HEAD(cpufreq_policy_list);
static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
#endif

+static inline bool has_target(void)
+{
+ return cpufreq_driver->target_index || cpufreq_driver->target;
+}
+
/*
* cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure
* all cpufreq/hotplug/workqueue/etc related lock issues.
@@ -437,7 +442,7 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
*policy = CPUFREQ_POLICY_POWERSAVE;
err = 0;
}
- } else if (cpufreq_driver->target) {
+ } else if (has_target()) {
struct cpufreq_governor *t;

mutex_lock(&cpufreq_governor_mutex);
@@ -595,7 +600,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
ssize_t i = 0;
struct cpufreq_governor *t;

- if (!cpufreq_driver->target) {
+ if (!has_target()) {
i += sprintf(buf, "performance powersave");
goto out;
}
@@ -885,7 +890,7 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy,
if (ret)
goto err_out_kobj_put;
}
- if (cpufreq_driver->target) {
+ if (has_target()) {
ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
if (ret)
goto err_out_kobj_put;
@@ -934,10 +939,10 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy,
unsigned int cpu, struct device *dev,
bool frozen)
{
- int ret = 0, has_target = !!cpufreq_driver->target;
+ int ret = 0;
unsigned long flags;

- if (has_target) {
+ if (has_target()) {
ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
if (ret) {
pr_err("%s: Failed to stop governor\n", __func__);
@@ -955,7 +960,7 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy,

unlock_policy_rwsem_write(policy->cpu);

- if (has_target) {
+ if (has_target()) {
if ((ret = __cpufreq_governor(policy, CPUFREQ_GOV_START)) ||
(ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))) {
pr_err("%s: Failed to start governor\n", __func__);
@@ -1254,7 +1259,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
return -EINVAL;
}

- if (cpufreq_driver->target) {
+ if (has_target()) {
ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
if (ret) {
pr_err("%s: Failed to stop governor\n", __func__);
@@ -1321,7 +1326,7 @@ static int __cpufreq_remove_dev_finish(struct device *dev,

/* If cpu is last user of policy, free policy */
if (cpus == 1) {
- if (cpufreq_driver->target) {
+ if (has_target()) {
ret = __cpufreq_governor(policy,
CPUFREQ_GOV_POLICY_EXIT);
if (ret) {
@@ -1364,7 +1369,7 @@ static int __cpufreq_remove_dev_finish(struct device *dev,
if (!frozen)
cpufreq_policy_free(policy);
} else {
- if (cpufreq_driver->target) {
+ if (has_target()) {
if ((ret = __cpufreq_governor(policy, CPUFREQ_GOV_START)) ||
(ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))) {
pr_err("%s: Failed to start governor\n",
@@ -1761,6 +1766,12 @@ 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
+ * exactly same freq is called again and so we can save on few function
+ * calls.
+ */
if (target_freq == policy->cur)
return 0;

@@ -1774,7 +1785,32 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,

if (cpufreq_driver->target)
retval = cpufreq_driver->target(policy, target_freq, relation);
+ else if (cpufreq_driver->target_index) {
+ struct cpufreq_frequency_table *freq_table;
+ int index;
+
+ freq_table = cpufreq_frequency_get_table(policy->cpu);
+ if (unlikely(!freq_table)) {
+ pr_err("%s: Unable to find freq_table\n", __func__);
+ goto out;
+ }

+ 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__);
+ goto out;
+ }
+
+ if (freq_table[index].frequency == policy->cur) {
+ retval = 0;
+ goto out;
+ }
+
+ retval = cpufreq_driver->target_index(policy, index);
+ }
+
+out:
/*
* For drivers with CPUFREQ_ASYNC_NOTIFICATION flag set, we decrement
* transition_ongoing from POSTCHANGE notifiers.
@@ -2114,7 +2150,7 @@ int cpufreq_update_policy(unsigned int cpu)
pr_debug("Driver did not initialize current freq");
policy->cur = new_policy.cur;
} else {
- if (policy->cur != new_policy.cur && cpufreq_driver->target)
+ if (policy->cur != new_policy.cur && has_target())
cpufreq_out_of_sync(cpu, policy->cur,
new_policy.cur);
}
@@ -2193,7 +2229,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
return -ENODEV;

if (!driver_data || !driver_data->verify || !driver_data->init ||
- ((!driver_data->setpolicy) && (!driver_data->target)))
+ !(driver_data->setpolicy || driver_data->target_index ||
+ driver_data->target))
return -EINVAL;

pr_debug("trying to register driver %s\n", driver_data->name);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index c2184c6..f13beec 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -188,9 +188,11 @@ struct cpufreq_driver {

/* define one out of two */
int (*setpolicy) (struct cpufreq_policy *policy);
- int (*target) (struct cpufreq_policy *policy,
+ int (*target) (struct cpufreq_policy *policy, /* Deprecated */
unsigned int target_freq,
unsigned int relation);
+ int (*target_index) (struct cpufreq_policy *policy,
+ unsigned int index);

/* should be defined, if possible */
unsigned int (*get) (unsigned int cpu);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:20:21

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 146/228] cpufreq: tegra: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/tegra-cpufreq.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index 9c32b23..32483ef 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -204,19 +204,23 @@ static struct notifier_block tegra_cpu_pm_notifier = {

static int tegra_cpu_init(struct cpufreq_policy *policy)
{
+ int ret;
+
if (policy->cpu >= NUM_CPUS)
return -EINVAL;

clk_prepare_enable(emc_clk);
clk_prepare_enable(cpu_clk);

- cpufreq_table_validate_and_show(policy, freq_table);
target_cpu_speed[policy->cpu] = tegra_getspeed(policy->cpu);

/* FIXME: what's the actual transition time? */
- policy->cpuinfo.transition_latency = 300 * 1000;
-
- cpumask_copy(policy->cpus, cpu_possible_mask);
+ ret = cpufreq_generic_init(policy, freq_table, 300 * 1000);
+ if (ret) {
+ clk_disable_unprepare(cpu_clk);
+ clk_disable_unprepare(emc_clk);
+ return ret;
+ }

if (policy->cpu == 0)
register_pm_notifier(&tegra_cpu_pm_notifier);
@@ -227,6 +231,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
static int tegra_cpu_exit(struct cpufreq_policy *policy)
{
cpufreq_frequency_table_put_attr(policy->cpu);
+ clk_disable_unprepare(cpu_clk);
clk_disable_unprepare(emc_clk);
return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:20:37

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 148/228] cpufreq: acpi: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/acpi-cpufreq.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 372febf..7536e7d 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)
{
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);
@@ -918,7 +909,7 @@ static struct freq_attr *acpi_cpufreq_attr[] = {

static struct cpufreq_driver acpi_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = acpi_cpufreq_target,
+ .target_index = acpi_cpufreq_target,
.bios_limit = acpi_processor_get_bios_limit,
.init = acpi_cpufreq_cpu_init,
.exit = acpi_cpufreq_cpu_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:20:45

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 149/228] cpufreq: arm_big_little: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/arm_big_little.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index f7717ef..c3936ef 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)
{
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);
@@ -200,7 +193,7 @@ static struct cpufreq_driver bL_cpufreq_driver = {
.flags = CPUFREQ_STICKY |
CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
.verify = cpufreq_generic_frequency_table_verify,
- .target = bL_cpufreq_set_target,
+ .target_index = bL_cpufreq_set_target,
.get = bL_cpufreq_get,
.init = bL_cpufreq_init,
.exit = bL_cpufreq_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:20:55

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 151/228] cpufreq: blackfin: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Steven Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/blackfin-cpufreq.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index 0bc9e8c..12528b2 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -127,14 +127,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)
+static int bfin_target(struct cpufreq_policy *policy, unsigned int index)
{
#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 +141,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, freqs.new, freqs.old);

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
#ifndef CONFIG_BF60x
@@ -209,7 +200,7 @@ static int __bfin_cpu_init(struct cpufreq_policy *policy)

static struct cpufreq_driver bfin_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = bfin_target,
+ .target_index = bfin_target,
.get = bfin_getfreq_khz,
.init = __bfin_cpu_init,
.exit = cpufreq_generic_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:03

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 152/228] cpufreq: cpu0: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq-cpu0.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index d8756e7..22a358f 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -34,24 +34,14 @@ static unsigned int cpu0_get_speed(unsigned int cpu)
return clk_get_rate(cpu_clk) / 1000;
}

-static int cpu0_set_target(struct cpufreq_policy *policy,
- unsigned int target_freq, unsigned int relation)
+static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)
{
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 +49,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 (!IS_ERR(cpu_reg)) {
@@ -127,7 +114,7 @@ static int cpu0_cpufreq_init(struct cpufreq_policy *policy)
static struct cpufreq_driver cpu0_cpufreq_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
- .target = cpu0_set_target,
+ .target_index = cpu0_set_target,
.get = cpu0_get_speed,
.init = cpu0_cpufreq_init,
.exit = cpufreq_generic_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:11

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 153/228] cpufreq: cris: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Jesper Nilsson <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cris-artpec3-cpufreq.c | 18 ++----------------
drivers/cpufreq/cris-etraxfs-cpufreq.c | 17 ++---------------
2 files changed, 4 insertions(+), 31 deletions(-)

diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index 05fdc7e..841857c 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -27,8 +27,7 @@ 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)
{
struct cpufreq_freqs freqs;
reg_clkgen_rw_clk_ctrl clk_ctrl;
@@ -52,19 +51,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;
}
@@ -77,7 +63,7 @@ static int cris_freq_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver cris_freq_driver = {
.get = cris_freq_get_cpu_frequency,
.verify = cpufreq_generic_frequency_table_verify,
- .target = cris_freq_target,
+ .target_index = cris_freq_target,
.init = cris_freq_cpu_init,
.exit = cpufreq_generic_exit,
.name = "cris_freq",
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index fac2b26..c58811a 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -27,8 +27,7 @@ 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)
{
struct cpufreq_freqs freqs;
reg_config_rw_clk_ctrl clk_ctrl;
@@ -52,18 +51,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;
}
@@ -76,7 +63,7 @@ static int cris_freq_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver cris_freq_driver = {
.get = cris_freq_get_cpu_frequency,
.verify = cpufreq_generic_frequency_table_verify,
- .target = cris_freq_target,
+ .target_index = cris_freq_target,
.init = cris_freq_cpu_init,
.exit = cpufreq_generic_exit,
.name = "cris_freq",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:18

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 154/228] cpufreq: davinci: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Sekhar Nori <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/davinci-cpufreq.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index 972583b..1f5d8a5 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -66,28 +66,18 @@ 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)
{
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 */
@@ -148,7 +138,7 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver davinci_driver = {
.flags = CPUFREQ_STICKY,
.verify = davinci_verify_speed,
- .target = davinci_target,
+ .target_index = davinci_target,
.get = davinci_getspeed,
.init = davinci_cpu_init,
.exit = cpufreq_generic_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:23

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 155/228] cpufreq: dbx500: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/dbx500-cpufreq.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index a60f769..238b169 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -20,23 +20,13 @@ 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 relation)
+ unsigned int index)
{
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);
@@ -80,7 +70,7 @@ static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
static struct cpufreq_driver dbx500_cpufreq_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS,
.verify = cpufreq_generic_frequency_table_verify,
- .target = dbx500_cpufreq_target,
+ .target_index = dbx500_cpufreq_target,
.get = dbx500_cpufreq_getspeed,
.init = dbx500_cpufreq_init,
.name = "DBX500",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:30

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 156/228] cpufreq: e_powersaver: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/e_powersaver.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c
index 2c11ce3..b39c4ef 100644
--- a/drivers/cpufreq/e_powersaver.c
+++ b/drivers/cpufreq/e_powersaver.c
@@ -168,12 +168,9 @@ postchange:
return err;
}

-static int eps_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int eps_target(struct cpufreq_policy *policy, unsigned int index)
{
struct eps_cpu_data *centaur;
- unsigned int newstate = 0;
unsigned int cpu = policy->cpu;
unsigned int dest_state;
int ret;
@@ -182,16 +179,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");
@@ -418,7 +407,7 @@ static int eps_cpu_exit(struct cpufreq_policy *policy)

static struct cpufreq_driver eps_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = eps_target,
+ .target_index = eps_target,
.init = eps_cpu_init,
.exit = eps_cpu_exit,
.get = eps_get,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:38

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 157/228] cpufreq: elanfreq: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/elanfreq.c | 34 +++-------------------------------
1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c
index d91a645..4ab4153 100644
--- a/drivers/cpufreq/elanfreq.c
+++ b/drivers/cpufreq/elanfreq.c
@@ -105,20 +105,8 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
}


-/**
- * elanfreq_set_cpu_frequency: Change the CPU core frequency
- * @cpu: cpu number
- * @freq: frequency in kHz
- *
- * This function takes a frequency value and changes the CPU frequency
- * according to this. Note that the frequency has to be checked by
- * elanfreq_validatespeed() for correctness!
- *
- * There is no return value.
- */
-
-static void elanfreq_set_cpu_state(struct cpufreq_policy *policy,
- unsigned int state)
+static int elanfreq_target(struct cpufreq_policy *policy,
+ unsigned int state)
{
struct cpufreq_freqs freqs;

@@ -162,25 +150,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
*/
@@ -237,7 +209,7 @@ __setup("elanfreq=", elanfreq_setup);
static struct cpufreq_driver elanfreq_driver = {
.get = elanfreq_get_cpu_frequency,
.verify = cpufreq_generic_frequency_table_verify,
- .target = elanfreq_target,
+ .target_index = elanfreq_target,
.init = elanfreq_cpu_init,
.exit = cpufreq_generic_exit,
.name = "elanfreq",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:44

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 158/228] cpufreq: exynos: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/exynos-cpufreq.c | 21 +++------------------
drivers/cpufreq/exynos5440-cpufreq.c | 25 +++++++------------------
2 files changed, 10 insertions(+), 36 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index b96fcc8..c178e73 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
@@ -151,13 +148,9 @@ out:
return ret;
}

-static int exynos_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int exynos_target(struct cpufreq_policy *policy, unsigned int index)
{
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 +158,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);
@@ -247,7 +232,7 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver exynos_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
- .target = exynos_target,
+ .target_index = exynos_target,
.get = exynos_getspeed,
.init = exynos_cpufreq_cpu_init,
.exit = cpufreq_generic_exit,
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index e6fae7f..340b53e 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -214,27 +214,17 @@ static unsigned int exynos_getspeed(unsigned int cpu)
return dvfs_info->cur_frequency;
}

-static int exynos_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int exynos_target(struct cpufreq_policy *policy, unsigned int index)
{
- unsigned int index, tmp;
- int ret = 0, i;
+ unsigned int tmp;
+ int 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;

- if (freqs.old == freqs.new)
- goto out;
-
cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Set the target frequency in all C0_3_PSTATE register */
@@ -246,11 +236,10 @@ static int exynos_target(struct cpufreq_policy *policy,
__raw_writel(tmp, dvfs_info->base + XMU_C0_3_PSTATE + i * 4);
}

- /* Mark transition as In-progress */
- ret = -EINPROGRESS;
-out:
mutex_unlock(&cpufreq_lock);
- return ret;
+
+ /* Mark transition as In-progress */
+ return -EINPROGRESS;
}

static void exynos_cpufreq_work(struct work_struct *work)
@@ -328,7 +317,7 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver exynos_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_ASYNC_NOTIFICATION,
.verify = cpufreq_generic_frequency_table_verify,
- .target = exynos_target,
+ .target_index = exynos_target,
.get = exynos_getspeed,
.init = exynos_cpufreq_cpu_init,
.exit = cpufreq_generic_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:54

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 159/228] cpufreq: ia64: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Tony Luck <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ia64-acpi-cpufreq.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
index 90c6598..4695fa2 100644
--- a/drivers/cpufreq/ia64-acpi-cpufreq.c
+++ b/drivers/cpufreq/ia64-acpi-cpufreq.c
@@ -227,26 +227,11 @@ acpi_cpufreq_get (
static int
acpi_cpufreq_target (
struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+ unsigned int index)
{
- 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);
}

-
static int
acpi_cpufreq_cpu_init (
struct cpufreq_policy *policy)
@@ -379,7 +364,7 @@ acpi_cpufreq_cpu_exit (

static struct cpufreq_driver acpi_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = acpi_cpufreq_target,
+ .target_index = acpi_cpufreq_target,
.get = acpi_cpufreq_get,
.init = acpi_cpufreq_cpu_init,
.exit = acpi_cpufreq_cpu_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:21:59

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 160/228] cpufreq: imx6q: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/imx6q-cpufreq.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 3fb3f59..e8846d7 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -39,30 +39,17 @@ 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)
{
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)) {
@@ -158,7 +145,7 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy)

static struct cpufreq_driver imx6q_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = imx6q_set_target,
+ .target_index = imx6q_set_target,
.get = imx6q_get_speed,
.init = imx6q_cpufreq_init,
.exit = cpufreq_generic_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:22:07

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 161/228] cpufreq: kirkwood: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Andrew Lunn <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/kirkwood-cpufreq.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index fff8653..0ae4dd7 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -55,8 +55,8 @@ 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)
{
struct cpufreq_freqs freqs;
unsigned int state = kirkwood_freq_table[index].driver_data;
@@ -100,19 +100,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;
}
@@ -126,7 +113,7 @@ static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver kirkwood_cpufreq_driver = {
.get = kirkwood_cpufreq_get_cpu_frequency,
.verify = cpufreq_generic_frequency_table_verify,
- .target = kirkwood_cpufreq_target,
+ .target_index = kirkwood_cpufreq_target,
.init = kirkwood_cpufreq_cpu_init,
.exit = cpufreq_generic_exit,
.name = "kirkwood-cpufreq",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:22:12

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 162/228] cpufreq: longhaul: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/longhaul.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index 14df497..45bafdd 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 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 {
@@ -919,7 +910,7 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy)

static struct cpufreq_driver longhaul_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = longhaul_target,
+ .target_index = longhaul_target,
.get = longhaul_get,
.init = longhaul_cpu_init,
.exit = cpufreq_generic_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:22:22

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 163/228] cpufreq: loongson2: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: John Crispin <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/loongson2_cpufreq.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index 2c8ec8e..41a8e2c 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -53,11 +53,9 @@ 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 relation)
+ unsigned int index)
{
unsigned int cpu = policy->cpu;
- unsigned int newstate = 0;
cpumask_t cpus_allowed;
struct cpufreq_freqs freqs;
unsigned int freq;
@@ -65,26 +63,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);

@@ -145,7 +134,7 @@ static struct cpufreq_driver loongson2_cpufreq_driver = {
.name = "loongson2",
.init = loongson2_cpufreq_cpu_init,
.verify = cpufreq_generic_frequency_table_verify,
- .target = loongson2_cpufreq_target,
+ .target_index = loongson2_cpufreq_target,
.get = loongson2_cpufreq_get,
.exit = loongson2_cpufreq_exit,
.attr = cpufreq_generic_attr,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:22:30

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 164/228] cpufreq: maple: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Dmitry Eremin-Solenikov <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/maple-cpufreq.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index eb1e176..4e2da08 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 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);
@@ -173,7 +165,7 @@ static struct cpufreq_driver maple_cpufreq_driver = {
.flags = CPUFREQ_CONST_LOOPS,
.init = maple_cpufreq_cpu_init,
.verify = cpufreq_generic_frequency_table_verify,
- .target = maple_cpufreq_target,
+ .target_index = maple_cpufreq_target,
.get = maple_cpufreq_get_speed,
.attr = cpufreq_generic_attr,
};
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:22:44

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 165/228] cpufreq: omap: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Santosh Shilimkar <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/omap-cpufreq.c | 31 +++----------------------------
1 file changed, 3 insertions(+), 28 deletions(-)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 58b2200..0653887 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -51,40 +51,15 @@ static unsigned int omap_getspeed(unsigned int cpu)
return rate;
}

-static int omap_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int omap_target(struct cpufreq_policy *policy, unsigned int index)
{
- 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);
@@ -200,7 +175,7 @@ static int omap_cpu_exit(struct cpufreq_policy *policy)
static struct cpufreq_driver omap_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
- .target = omap_target,
+ .target_index = omap_target,
.get = omap_getspeed,
.init = omap_cpu_init,
.exit = omap_cpu_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:22:50

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 166/228] cpufreq: p4: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: David S. Miller <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/p4-clockmod.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 6164c1c..3c23053 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -105,23 +105,13 @@ static struct cpufreq_frequency_table p4clockmod_table[] = {
};


-static int cpufreq_p4_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int cpufreq_p4_target(struct cpufreq_policy *policy, unsigned int index)
{
- 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 +121,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);
@@ -255,7 +245,7 @@ static unsigned int cpufreq_p4_get(unsigned int cpu)

static struct cpufreq_driver p4clockmod_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = cpufreq_p4_target,
+ .target_index = cpufreq_p4_target,
.init = cpufreq_p4_cpu_init,
.exit = cpufreq_generic_exit,
.get = cpufreq_p4_get,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:22:58

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 167/228] cpufreq: pasemi: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pasemi-cpufreq.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 1cca332..17424dd 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -240,19 +240,11 @@ 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 relation)
+ unsigned int pas_astate_new)
{
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;

@@ -282,7 +274,7 @@ static struct cpufreq_driver pas_cpufreq_driver = {
.init = pas_cpufreq_cpu_init,
.exit = pas_cpufreq_cpu_exit,
.verify = cpufreq_generic_frequency_table_verify,
- .target = pas_cpufreq_target,
+ .target_index = pas_cpufreq_target,
.attr = cpufreq_generic_attr,
};

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:23:08

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 168/228] cpufreq: pmac32: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pmac32-cpufreq.c | 12 +++---------
drivers/cpufreq/pmac64-cpufreq.c | 17 ++++-------------
2 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index 6eac1e2..9137fa9 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -374,17 +374,11 @@ 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 relation)
+ unsigned int index)
{
- 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;
@@ -453,7 +447,7 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)

static struct cpufreq_driver pmac_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = pmac_cpufreq_target,
+ .target_index = pmac_cpufreq_target,
.get = pmac_cpufreq_get_speed,
.init = pmac_cpufreq_cpu_init,
.suspend = pmac_cpufreq_suspend,
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index b977b9a..af970b7 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -312,27 +312,18 @@ static int g5_pfunc_query_freq(void)
* Common interface to the cpufreq core
*/

-static int g5_cpufreq_target(struct cpufreq_policy *policy,
- unsigned int target_freq, unsigned int relation)
+static int g5_cpufreq_target(struct cpufreq_policy *policy, unsigned int index)
{
- 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);
@@ -355,7 +346,7 @@ static struct cpufreq_driver g5_cpufreq_driver = {
.flags = CPUFREQ_CONST_LOOPS,
.init = g5_cpufreq_cpu_init,
.verify = cpufreq_generic_frequency_table_verify,
- .target = g5_cpufreq_target,
+ .target_index = g5_cpufreq_target,
.get = g5_cpufreq_get_speed,
.attr = cpufreq_generic_attr,
};
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:23:14

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 169/228] cpufreq: powernow: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/powernow-k6.c | 35 +++++------------------------------
drivers/cpufreq/powernow-k7.c | 22 ++++------------------
drivers/cpufreq/powernow-k8.c | 26 ++++++++------------------
3 files changed, 17 insertions(+), 66 deletions(-)

diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index eda1702..643e795 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -63,12 +63,12 @@ static int powernow_k6_get_cpu_multiplier(void)


/**
- * powernow_k6_set_state - set the PowerNow! multiplier
+ * powernow_k6_target - set the PowerNow! multiplier
* @best_i: clock_ratio[best_i] is the target multiplier
*
* Tries to change the PowerNow! multiplier
*/
-static void powernow_k6_set_state(struct cpufreq_policy *policy,
+static int powernow_k6_target(struct cpufreq_policy *policy,
unsigned int best_i)
{
unsigned long outvalue = 0, invalue = 0;
@@ -77,7 +77,7 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy,

if (clock_ratio[best_i].driver_data > max_multiplier) {
printk(KERN_ERR PFX "invalid target frequency\n");
- return;
+ return -EINVAL;
}

freqs.old = busfreq * powernow_k6_get_cpu_multiplier();
@@ -100,31 +100,6 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy,

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

- return;
-}
-
-
-/**
- * powernow_k6_setpolicy - sets a new CPUFreq policy
- * @policy: new policy
- * @target_freq: the target frequency
- * @relation: how that frequency relates to achieved frequency
- * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
- *
- * sets a new CPUFreq policy
- */
-static int powernow_k6_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- 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);
-
return 0;
}

@@ -161,7 +136,7 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
unsigned int i;
for (i = 0; i < 8; i++) {
if (i == max_multiplier)
- powernow_k6_set_state(policy, i);
+ powernow_k6_target(policy, i);
}
cpufreq_frequency_table_put_attr(policy->cpu);
return 0;
@@ -176,7 +151,7 @@ static unsigned int powernow_k6_get(unsigned int cpu)

static struct cpufreq_driver powernow_k6_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = powernow_k6_target,
+ .target_index = powernow_k6_target,
.init = powernow_k6_cpu_init,
.exit = powernow_k6_cpu_exit,
.get = powernow_k6_get,
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index 44d345b..946708a 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -248,7 +248,7 @@ 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)
{
u8 fid, vid;
struct cpufreq_freqs freqs;
@@ -291,6 +291,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 +535,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
@@ -694,7 +680,7 @@ static int powernow_cpu_exit(struct cpufreq_policy *policy)

static struct cpufreq_driver powernow_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = powernow_target,
+ .target_index = powernow_target,
.get = powernow_get,
#ifdef CONFIG_X86_POWERNOW_K7_ACPI
.bios_limit = acpi_processor_get_bios_limit,
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 8721744..612580a 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -977,20 +977,17 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,

struct powernowk8_target_arg {
struct cpufreq_policy *pol;
- unsigned targfreq;
- unsigned relation;
+ unsigned newstate;
};

static long powernowk8_target_fn(void *arg)
{
struct powernowk8_target_arg *pta = arg;
struct cpufreq_policy *pol = pta->pol;
- unsigned targfreq = pta->targfreq;
- unsigned relation = pta->relation;
+ unsigned newstate = pta->newstate;
struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
u32 checkfid;
u32 checkvid;
- unsigned int newstate;
int ret;

if (!data) {
@@ -1007,8 +1004,9 @@ static long powernowk8_target_fn(void *arg)
goto transition_complete;
}

- pr_debug("targ: cpu %d, %d kHz, min %d, max %d, relation %d\n",
- pol->cpu, targfreq, pol->min, pol->max, relation);
+ pr_debug("targ: cpu %d, %d kHz, min %d, max %d\n",
+ pol->cpu, data->powernow_table[newstate].frequency, pol->min,
+ pol->max);

if (query_current_values_with_pending_wait(data)) {
ret = -EIO;
@@ -1026,12 +1024,6 @@ static long powernowk8_target_fn(void *arg)
checkvid, data->currvid);
}

- if (cpufreq_frequency_table_target(pol, data->powernow_table,
- targfreq, relation, &newstate)) {
- ret = -EIO;
- goto transition_complete;
- }
-
mutex_lock(&fidvid_mutex);

powernow_k8_acpi_pst_values(data, newstate);
@@ -1060,11 +1052,9 @@ transition_complete:
}

/* Driver entry point to switch to the target frequency */
-static int powernowk8_target(struct cpufreq_policy *pol,
- unsigned targfreq, unsigned relation)
+static int powernowk8_target(struct cpufreq_policy *pol, unsigned index)
{
- struct powernowk8_target_arg pta = { .pol = pol, .targfreq = targfreq,
- .relation = relation };
+ struct powernowk8_target_arg pta = { .pol = pol, .newstate = index };
int ret;

ret = work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
@@ -1234,7 +1224,7 @@ out:
static struct cpufreq_driver cpufreq_amd64_driver = {
.flags = CPUFREQ_ASYNC_NOTIFICATION,
.verify = cpufreq_generic_frequency_table_verify,
- .target = powernowk8_target,
+ .target_index = powernowk8_target,
.bios_limit = acpi_processor_get_bios_limit,
.init = powernowk8_cpu_init,
.exit = powernowk8_cpu_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:23:24

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 170/228] cpufreq: ppc: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ppc-corenet-cpufreq.c | 15 ++++-----------
drivers/cpufreq/ppc_cbe_cpufreq.c | 12 ++----------
2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index a0f562c..79d8e9c 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -251,27 +251,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)
{
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;
@@ -288,7 +281,7 @@ static struct cpufreq_driver ppc_corenet_cpufreq_driver = {
.init = corenet_cpufreq_cpu_init,
.exit = __exit_p(corenet_cpufreq_cpu_exit),
.verify = cpufreq_generic_frequency_table_verify,
- .target = corenet_cpufreq_target,
+ .target_index = corenet_cpufreq_target,
.get = corenet_cpufreq_get_speed,
.attr = cpufreq_generic_attr,
};
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
index 38540d1..52f707d 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -129,18 +129,10 @@ 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 relation)
+ unsigned int cbe_pmode_new)
{
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;
@@ -164,7 +156,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy,

static struct cpufreq_driver cbe_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = cbe_cpufreq_target,
+ .target_index = cbe_cpufreq_target,
.init = cbe_cpufreq_cpu_init,
.exit = cpufreq_generic_exit,
.name = "cbe-cpufreq",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:23:34

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 172/228] cpufreq: s3c2416: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s3c2416-cpufreq.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index 26a35d1..4188acc 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -217,24 +217,15 @@ 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 relation)
+ unsigned int index)
{
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);
-
- 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,7 +247,7 @@ 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);

@@ -505,7 +496,7 @@ err_hclk:
static struct cpufreq_driver s3c2416_cpufreq_driver = {
.flags = 0,
.verify = cpufreq_generic_frequency_table_verify,
- .target = s3c2416_cpufreq_set_target,
+ .target_index = s3c2416_cpufreq_set_target,
.get = s3c2416_cpufreq_get_speed,
.init = s3c2416_cpufreq_driver_init,
.name = "s3c2416",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:23:42

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 173/228] cpufreq: s3c64xx: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s3c64xx-cpufreq.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 16dc315..34ae66b 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -63,26 +63,16 @@ 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 relation)
+ unsigned int index)
{
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);

@@ -254,7 +244,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
static struct cpufreq_driver s3c64xx_cpufreq_driver = {
.flags = 0,
.verify = cpufreq_generic_frequency_table_verify,
- .target = s3c64xx_cpufreq_set_target,
+ .target_index = s3c64xx_cpufreq_set_target,
.get = s3c64xx_cpufreq_get_speed,
.init = s3c64xx_cpufreq_driver_init,
.name = "s3c",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:23:49

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 174/228] cpufreq: s5pv210: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

This drivers wasn't as straight forward as other ones. It was doing some funny
stuff to disable driver while going into suspend mode. This part is simplified
as well to get this converted to ->target_index().

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s5pv210-cpufreq.c | 54 ++++++++++-----------------------------
1 file changed, 14 insertions(+), 40 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 600b4f4..5978b94 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -36,16 +36,7 @@ static DEFINE_MUTEX(set_freq_lock);
/* Use 800MHz when entering sleep mode */
#define SLEEP_FREQ (800 * 1000)

-/*
- * relation has an additional symantics other than the standard of cpufreq
- * DISALBE_FURTHER_CPUFREQ: disable further access to target
- * ENABLE_FURTUER_CPUFREQ: enable access to target
- */
-enum cpufreq_access {
- DISABLE_FURTHER_CPUFREQ = 0x10,
- ENABLE_FURTHER_CPUFREQ = 0x20,
-};
-
+/* Tracks if cpu freqency can be updated anymore */
static bool no_cpufreq_access;

/*
@@ -182,12 +173,10 @@ static unsigned int s5pv210_getspeed(unsigned int cpu)
return clk_get_rate(cpu_clk) / 1000;
}

-static int s5pv210_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
{
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;
@@ -195,9 +184,6 @@ static int s5pv210_target(struct cpufreq_policy *policy,

mutex_lock(&set_freq_lock);

- if (relation & ENABLE_FURTHER_CPUFREQ)
- no_cpufreq_access = false;
-
if (no_cpufreq_access) {
#ifdef CONFIG_PM_VERBOSE
pr_err("%s:%d denied access to %s as it is disabled"
@@ -207,27 +193,13 @@ static int s5pv210_target(struct cpufreq_policy *policy,
goto exit;
}

- if (relation & DISABLE_FURTHER_CPUFREQ)
- no_cpufreq_access = true;
-
- 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)) {
+ freqs.old, CPUFREQ_RELATION_H,
+ &priv_index)) {
ret = -EINVAL;
goto exit;
}
@@ -559,16 +531,18 @@ static int s5pv210_cpufreq_notifier_event(struct notifier_block *this,

switch (event) {
case PM_SUSPEND_PREPARE:
- ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ,
- DISABLE_FURTHER_CPUFREQ);
+ ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ, 0);
if (ret < 0)
return NOTIFY_BAD;

+ /* Disable updation of cpu frequency */
+ no_cpufreq_access = true;
return NOTIFY_OK;
case PM_POST_RESTORE:
case PM_POST_SUSPEND:
- cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ,
- ENABLE_FURTHER_CPUFREQ);
+ /* Enable updation of cpu frequency */
+ no_cpufreq_access = false;
+ cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ, 0);

return NOTIFY_OK;
}
@@ -581,18 +555,18 @@ static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this,
{
int ret;

- ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ,
- DISABLE_FURTHER_CPUFREQ);
+ ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ, 0);
if (ret < 0)
return NOTIFY_BAD;

+ no_cpufreq_access = true;
return NOTIFY_DONE;
}

static struct cpufreq_driver s5pv210_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
- .target = s5pv210_target,
+ .target_index = s5pv210_target,
.get = s5pv210_getspeed,
.init = s5pv210_cpu_init,
.name = "s5pv210",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:23:56

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 175/228] cpufreq: sa11x0: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Some existing routines are no more required and so are removed now.

Cc: Russell King <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
arch/arm/mach-sa1100/generic.c | 20 --------------------
arch/arm/mach-sa1100/generic.h | 2 --
drivers/cpufreq/sa1100-cpufreq.c | 24 ++++--------------------
drivers/cpufreq/sa1110-cpufreq.c | 26 ++++----------------------
4 files changed, 8 insertions(+), 64 deletions(-)

diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index cb4b2ca..d4ea142 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -62,26 +62,6 @@ struct cpufreq_frequency_table sa11x0_freq_table[NR_FREQS+1] = {
{ .frequency = CPUFREQ_TABLE_END, },
};

-/* rounds up(!) */
-unsigned int sa11x0_freq_to_ppcr(unsigned int khz)
-{
- int i;
-
- for (i = 0; i < NR_FREQS; i++)
- if (sa11x0_freq_table[i].frequency >= khz)
- break;
-
- return i;
-}
-
-unsigned int sa11x0_ppcr_to_freq(unsigned int idx)
-{
- unsigned int freq = 0;
- if (idx < NR_FREQS)
- freq = sa11x0_freq_table[idx].frequency;
- return freq;
-}
-
unsigned int sa11x0_getspeed(unsigned int cpu)
{
if (cpu)
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index 39d56a67..84505d5 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -22,9 +22,7 @@ extern void sa1110_mb_disable(void);
struct cpufreq_policy;

extern struct cpufreq_frequency_table sa11x0_freq_table[];
-extern unsigned int sa11x0_freq_to_ppcr(unsigned int khz);
extern unsigned int sa11x0_getspeed(unsigned int cpu);
-extern unsigned int sa11x0_ppcr_to_freq(unsigned int idx);

struct flash_platform_data;
struct resource;
diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c
index b282cea..b0da1fe 100644
--- a/drivers/cpufreq/sa1100-cpufreq.c
+++ b/drivers/cpufreq/sa1100-cpufreq.c
@@ -177,36 +177,20 @@ static void sa1100_update_dram_timings(int current_speed, int new_speed)
}
}

-static int sa1100_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int sa1100_target(struct cpufreq_policy *policy, unsigned int ppcr)
{
unsigned int cur = sa11x0_getspeed(0);
- unsigned int new_ppcr;
struct cpufreq_freqs freqs;

- new_ppcr = sa11x0_freq_to_ppcr(target_freq);
- switch (relation) {
- case CPUFREQ_RELATION_L:
- if (sa11x0_ppcr_to_freq(new_ppcr) > policy->max)
- new_ppcr--;
- break;
- case CPUFREQ_RELATION_H:
- if ((sa11x0_ppcr_to_freq(new_ppcr) > target_freq) &&
- (sa11x0_ppcr_to_freq(new_ppcr - 1) >= policy->min))
- new_ppcr--;
- break;
- }
-
freqs.old = cur;
- freqs.new = sa11x0_ppcr_to_freq(new_ppcr);
+ freqs.new = sa11x0_freq_table[ppcr].frequency;

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

if (freqs.new > cur)
sa1100_update_dram_timings(cur, freqs.new);

- PPCR = new_ppcr;
+ PPCR = ppcr;

if (freqs.new < cur)
sa1100_update_dram_timings(cur, freqs.new);
@@ -224,7 +208,7 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver sa1100_driver __refdata = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
- .target = sa1100_target,
+ .target_index = sa1100_target,
.get = sa11x0_getspeed,
.init = sa1100_cpu_init,
.name = "sa1100",
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c
index bca04c0..55b1818c 100644
--- a/drivers/cpufreq/sa1110-cpufreq.c
+++ b/drivers/cpufreq/sa1110-cpufreq.c
@@ -229,34 +229,16 @@ sdram_update_refresh(u_int cpu_khz, struct sdram_params *sdram)
/*
* Ok, set the CPU frequency.
*/
-static int sa1110_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr)
{
struct sdram_params *sdram = &sdram_params;
struct cpufreq_freqs freqs;
struct sdram_info sd;
unsigned long flags;
- unsigned int ppcr, unused;
-
- switch (relation) {
- case CPUFREQ_RELATION_L:
- ppcr = sa11x0_freq_to_ppcr(target_freq);
- if (sa11x0_ppcr_to_freq(ppcr) > policy->max)
- ppcr--;
- break;
- case CPUFREQ_RELATION_H:
- ppcr = sa11x0_freq_to_ppcr(target_freq);
- if (ppcr && (sa11x0_ppcr_to_freq(ppcr) > target_freq) &&
- (sa11x0_ppcr_to_freq(ppcr-1) >= policy->min))
- ppcr--;
- break;
- default:
- return -EINVAL;
- }
+ unsigned int unused;

freqs.old = sa11x0_getspeed(0);
- freqs.new = sa11x0_ppcr_to_freq(ppcr);
+ freqs.new = sa11x0_freq_table[ppcr].frequency;

sdram_calculate_timing(&sd, freqs.new, sdram);

@@ -340,7 +322,7 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver sa1110_driver __refdata = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
- .target = sa1110_target,
+ .target_index = sa1110_target,
.get = sa11x0_getspeed,
.init = sa1110_cpu_init,
.name = "sa1110",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:24:04

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 176/228] cpufreq: sc520: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sc520_freq.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c
index 9047ab1..6c86452 100644
--- a/drivers/cpufreq/sc520_freq.c
+++ b/drivers/cpufreq/sc520_freq.c
@@ -53,8 +53,7 @@ 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)
{

struct cpufreq_freqs freqs;
@@ -76,24 +75,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
*/
@@ -117,7 +102,7 @@ static int sc520_freq_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver sc520_freq_driver = {
.get = sc520_freq_get_cpu_frequency,
.verify = cpufreq_generic_frequency_table_verify,
- .target = sc520_freq_target,
+ .target_index = sc520_freq_target,
.init = sc520_freq_cpu_init,
.exit = cpufreq_generic_exit,
.name = "sc520_freq",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:24:13

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 177/228] cpufreq: sparc: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: David S. Miller <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sparc-us2e-cpufreq.c | 21 +++------------------
drivers/cpufreq/sparc-us3-cpufreq.c | 23 +++--------------------
2 files changed, 6 insertions(+), 38 deletions(-)

diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index 291688c..3bf5b8f 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -245,8 +245,7 @@ static unsigned int us2e_freq_get(unsigned int cpu)
return clock_tick / estar_to_divisor(estar);
}

-static void us2e_set_cpu_divider_index(struct cpufreq_policy *policy,
- unsigned int index)
+static int us2e_freq_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned int cpu = policy->cpu;
unsigned long new_bits, new_freq;
@@ -277,20 +276,6 @@ static void us2e_set_cpu_divider_index(struct cpufreq_policy *policy,
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

set_cpus_allowed_ptr(current, &cpus_allowed);
-}
-
-static int us2e_freq_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- 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);

return 0;
}
@@ -325,7 +310,7 @@ static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
{
if (cpufreq_us2e_driver) {
cpufreq_frequency_table_put_attr(policy->cpu);
- us2e_set_cpu_divider_index(policy, 0);
+ us2e_freq_target(policy, 0);
}

return 0;
@@ -358,7 +343,7 @@ static int __init us2e_freq_init(void)

driver->init = us2e_freq_cpu_init;
driver->verify = cpufreq_generic_frequency_table_verify;
- driver->target = us2e_freq_target;
+ driver->target_index = us2e_freq_target;
driver->get = us2e_freq_get;
driver->exit = us2e_freq_cpu_exit;
strcpy(driver->name, "UltraSPARC-IIe");
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index 9b3dbd3..2e54d55 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -93,8 +93,7 @@ static unsigned int us3_freq_get(unsigned int cpu)
return ret;
}

-static void us3_set_cpu_divider_index(struct cpufreq_policy *policy,
- unsigned int index)
+static int us3_freq_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned int cpu = policy->cpu;
unsigned long new_bits, new_freq, reg;
@@ -136,22 +135,6 @@ static void us3_set_cpu_divider_index(struct cpufreq_policy *policy,
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

set_cpus_allowed_ptr(current, &cpus_allowed);
-}
-
-static int us3_freq_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- 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);

return 0;
}
@@ -182,7 +165,7 @@ static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
{
if (cpufreq_us3_driver) {
cpufreq_frequency_table_put_attr(policy->cpu);
- us3_set_cpu_divider_index(policy, 0);
+ us3_freq_target(policy, 0);
}

return 0;
@@ -219,7 +202,7 @@ static int __init us3_freq_init(void)

driver->init = us3_freq_cpu_init;
driver->verify = cpufreq_generic_frequency_table_verify;
- driver->target = us3_freq_target;
+ driver->target_index = us3_freq_target;
driver->get = us3_freq_get;
driver->exit = us3_freq_cpu_exit;
strcpy(driver->name, "UltraSPARC-III");
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:24:29

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 178/228] cpufreq: SPEAr: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/spear-cpufreq.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 2a03158..0326040 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)
{
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
@@ -179,7 +175,7 @@ static struct cpufreq_driver spear_cpufreq_driver = {
.name = "cpufreq-spear",
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
- .target = spear_cpufreq_target,
+ .target_index = spear_cpufreq_target,
.get = spear_cpufreq_get,
.init = spear_cpufreq_init,
.exit = cpufreq_generic_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:24:35

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 180/228] cpufreq: tegra: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Stephen Warren <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/tegra-cpufreq.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index 32483ef..bd7d89c 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -150,11 +150,8 @@ static unsigned long tegra_cpu_highest_speed(void)
return rate;
}

-static int tegra_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
{
- unsigned int idx;
unsigned int freq;
int ret = 0;

@@ -165,10 +162,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;

@@ -238,7 +232,7 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy)

static struct cpufreq_driver tegra_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = tegra_target,
+ .target_index = tegra_target,
.get = tegra_getspeed,
.init = tegra_cpu_init,
.exit = tegra_cpu_exit,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:24:42

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 181/228] cpufreq: move freq change notifications to cpufreq core

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

There are few special cases though, like exynos5440, which doesn't do everything
on the call to ->target_index() routine and call some kind of bottom halves for
doing this work, work/tasklet/etc..

They may continue doing notification from their own code and so this patch
introduces another flag: CPUFREQ_ASYNC_NOTIFICATION, which will be set by such
drivers.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 3fd24b1..79f89c3 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1787,6 +1787,9 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
retval = cpufreq_driver->target(policy, target_freq, relation);
else if (cpufreq_driver->target_index) {
struct cpufreq_frequency_table *freq_table;
+ struct cpufreq_freqs freqs;
+ unsigned long flags;
+ bool notify;
int index;

freq_table = cpufreq_frequency_get_table(policy->cpu);
@@ -1807,7 +1810,39 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
goto out;
}

+ read_lock_irqsave(&cpufreq_driver_lock, flags);
+ notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION);
+ read_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+ if (notify) {
+ freqs.old = policy->cur;
+ freqs.new = freq_table[index].frequency;
+ freqs.flags = 0;
+
+ pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n",
+ __func__, policy->cpu, freqs.old,
+ freqs.new);
+
+ cpufreq_notify_transition(policy, &freqs,
+ CPUFREQ_PRECHANGE);
+ }
+
retval = cpufreq_driver->target_index(policy, index);
+ if (retval)
+ pr_err("%s: Failed to change cpu frequency: %d\n",
+ __func__, retval);
+
+ if (notify) {
+ /*
+ * Notify with old freq in case we failed to change
+ * frequency
+ */
+ if (retval)
+ freqs.new = freqs.old;
+
+ cpufreq_notify_transition(policy, &freqs,
+ CPUFREQ_POSTCHANGE);
+ }
}

out:
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:24:51

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 182/228] cpufreq: acpi: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Reviewed-by: Lan Tianyu <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/acpi-cpufreq.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 7536e7d..6b00cd8 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -428,14 +428,10 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
{
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_perf_state = 0; /* Index into perf table */
int result = 0;

- 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)) {
return -ENODEV;
@@ -483,23 +479,17 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
else
cmd.mask = cpumask_of(policy->cpu);

- freqs.old = perf->states[perf->state].core_frequency * 1000;
- freqs.new = data->freq_table[index].frequency;
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
drv_write(&cmd);

if (acpi_pstate_strict) {
- if (!check_freqs(cmd.mask, freqs.new, data)) {
+ if (!check_freqs(cmd.mask, data->freq_table[index].frequency,
+ data)) {
pr_debug("acpi_cpufreq_target failed (%d)\n",
policy->cpu);
result = -EAGAIN;
- freqs.new = freqs.old;
}
}

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
if (!result)
perf->state = next_perf_state;

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:25:04

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 184/228] cpufreq: at32ap: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Acked-by: Hans-Christian Egtvedt <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/at32ap-cpufreq.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
index 81d0752..856ad80 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -37,27 +37,23 @@ static unsigned long loops_per_jiffy_ref;

static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)
{
- struct cpufreq_freqs freqs;
+ unsigned int old_freq, new_freq;

- freqs.old = at32_get_speed(0);
- freqs.new = freq_table[index].frequency;
+ old_freq = at32_get_speed(0);
+ new_freq = freq_table[index].frequency;

if (!ref_freq) {
- ref_freq = freqs.old;
+ ref_freq = old_freq;
loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy;
}

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
- if (freqs.old < freqs.new)
+ if (old_freq < new_freq)
boot_cpu_data.loops_per_jiffy = cpufreq_scale(
- loops_per_jiffy_ref, ref_freq, freqs.new);
- clk_set_rate(cpuclk, freqs.new * 1000);
- if (freqs.new < freqs.old)
+ loops_per_jiffy_ref, ref_freq, new_freq);
+ clk_set_rate(cpuclk, new_freq * 1000);
+ if (new_freq < old_freq)
boot_cpu_data.loops_per_jiffy = cpufreq_scale(
- loops_per_jiffy_ref, ref_freq, freqs.new);
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- pr_debug("cpufreq: set frequency %u Hz\n", freqs.new * 1000);
+ loops_per_jiffy_ref, ref_freq, new_freq);

return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:25:19

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 186/228] cpufreq: cpu0: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq-cpu0.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 22a358f..7b5547f 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -36,20 +36,19 @@ static unsigned int cpu0_get_speed(unsigned int cpu)

static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)
{
- struct cpufreq_freqs freqs;
struct opp *opp;
unsigned long volt = 0, volt_old = 0, tol = 0;
+ unsigned int old_freq, new_freq;
long freq_Hz, freq_exact;
int ret;

freq_Hz = clk_round_rate(cpu_clk, freq_table[index].frequency * 1000);
if (freq_Hz < 0)
freq_Hz = freq_table[index].frequency * 1000;
- freq_exact = freq_Hz;
- freqs.new = freq_Hz / 1000;
- freqs.old = clk_get_rate(cpu_clk) / 1000;

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+ freq_exact = freq_Hz;
+ new_freq = freq_Hz / 1000;
+ old_freq = clk_get_rate(cpu_clk) / 1000;

if (!IS_ERR(cpu_reg)) {
rcu_read_lock();
@@ -57,9 +56,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)
if (IS_ERR(opp)) {
rcu_read_unlock();
pr_err("failed to find OPP for %ld\n", freq_Hz);
- freqs.new = freqs.old;
- ret = PTR_ERR(opp);
- goto post_notify;
+ return PTR_ERR(opp);
}
volt = opp_get_voltage(opp);
rcu_read_unlock();
@@ -68,16 +65,15 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)
}

pr_debug("%u MHz, %ld mV --> %u MHz, %ld mV\n",
- freqs.old / 1000, volt_old ? volt_old / 1000 : -1,
- freqs.new / 1000, volt ? volt / 1000 : -1);
+ old_freq / 1000, volt_old ? volt_old / 1000 : -1,
+ new_freq / 1000, volt ? volt / 1000 : -1);

/* scaling up? scale voltage before frequency */
- if (!IS_ERR(cpu_reg) && freqs.new > freqs.old) {
+ if (!IS_ERR(cpu_reg) && new_freq > old_freq) {
ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
if (ret) {
pr_err("failed to scale voltage up: %d\n", ret);
- freqs.new = freqs.old;
- goto post_notify;
+ return ret;
}
}

@@ -86,23 +82,18 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)
pr_err("failed to set clock rate: %d\n", ret);
if (!IS_ERR(cpu_reg))
regulator_set_voltage_tol(cpu_reg, volt_old, tol);
- freqs.new = freqs.old;
- goto post_notify;
+ return ret;
}

/* scaling down? scale voltage after frequency */
- if (!IS_ERR(cpu_reg) && freqs.new < freqs.old) {
+ if (!IS_ERR(cpu_reg) && new_freq < old_freq) {
ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
if (ret) {
pr_err("failed to scale voltage down: %d\n", ret);
- clk_set_rate(cpu_clk, freqs.old * 1000);
- freqs.new = freqs.old;
+ clk_set_rate(cpu_clk, old_freq * 1000);
}
}

-post_notify:
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return ret;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:25:29

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 188/228] cpufreq: davinci: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Sekhar Nori <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/davinci-cpufreq.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index 1f5d8a5..5e8a854 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -68,46 +68,36 @@ static unsigned int davinci_getspeed(unsigned int cpu)

static int davinci_target(struct cpufreq_policy *policy, unsigned int idx)
{
- int ret = 0;
- struct cpufreq_freqs freqs;
struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data;
struct clk *armclk = cpufreq.armclk;
+ unsigned int old_freq, new_freq;
+ int ret = 0;

- freqs.old = davinci_getspeed(0);
- freqs.new = pdata->freq_table[idx].frequency;
-
- dev_dbg(cpufreq.dev, "transition: %u --> %u\n", freqs.old, freqs.new);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+ old_freq = davinci_getspeed(0);
+ new_freq = pdata->freq_table[idx].frequency;

/* if moving to higher frequency, up the voltage beforehand */
- if (pdata->set_voltage && freqs.new > freqs.old) {
+ if (pdata->set_voltage && new_freq > old_freq) {
ret = pdata->set_voltage(idx);
if (ret)
- goto out;
+ return ret;
}

ret = clk_set_rate(armclk, idx);
if (ret)
- goto out;
+ return ret;

if (cpufreq.asyncclk) {
ret = clk_set_rate(cpufreq.asyncclk, cpufreq.asyncrate);
if (ret)
- goto out;
+ return ret;
}

/* if moving to lower freq, lower the voltage after lowering freq */
- if (pdata->set_voltage && freqs.new < freqs.old)
+ if (pdata->set_voltage && new_freq < old_freq)
pdata->set_voltage(idx);

-out:
- if (ret)
- freqs.new = freqs.old;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- return ret;
+ return 0;
}

static int davinci_cpu_init(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:25:36

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 189/228] cpufreq: dbx500: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Linus Walleij <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/dbx500-cpufreq.c | 22 +---------------------
1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index 238b169..0e67ab9 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -22,28 +22,8 @@ static struct clk *armss_clk;
static int dbx500_cpufreq_target(struct cpufreq_policy *policy,
unsigned int index)
{
- struct cpufreq_freqs freqs;
- int ret;
-
- freqs.old = policy->cur;
- freqs.new = freq_table[index].frequency;
-
- /* pre-change notification */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
/* update armss clk frequency */
- ret = clk_set_rate(armss_clk, freqs.new * 1000);
-
- if (ret) {
- pr_err("dbx500-cpufreq: Failed to set armss_clk to %d Hz: error %d\n",
- freqs.new * 1000, ret);
- freqs.new = freqs.old;
- }
-
- /* post change notification */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- return ret;
+ return clk_set_rate(armss_clk, freq_table[index].frequency * 1000);
}

static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:25:43

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 190/228] cpufreq: e_powersaver: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/e_powersaver.c | 23 +++--------------------
1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c
index b39c4ef..9012b8b 100644
--- a/drivers/cpufreq/e_powersaver.c
+++ b/drivers/cpufreq/e_powersaver.c
@@ -107,15 +107,9 @@ static int eps_set_state(struct eps_cpu_data *centaur,
struct cpufreq_policy *policy,
u32 dest_state)
{
- struct cpufreq_freqs freqs;
u32 lo, hi;
- int err = 0;
int i;

- freqs.old = eps_get(policy->cpu);
- freqs.new = centaur->fsb * ((dest_state >> 8) & 0xff);
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
/* Wait while CPU is busy */
rdmsr(MSR_IA32_PERF_STATUS, lo, hi);
i = 0;
@@ -124,8 +118,7 @@ static int eps_set_state(struct eps_cpu_data *centaur,
rdmsr(MSR_IA32_PERF_STATUS, lo, hi);
i++;
if (unlikely(i > 64)) {
- err = -ENODEV;
- goto postchange;
+ return -ENODEV;
}
}
/* Set new multiplier and voltage */
@@ -137,16 +130,10 @@ static int eps_set_state(struct eps_cpu_data *centaur,
rdmsr(MSR_IA32_PERF_STATUS, lo, hi);
i++;
if (unlikely(i > 64)) {
- err = -ENODEV;
- goto postchange;
+ return -ENODEV;
}
} while (lo & ((1 << 16) | (1 << 17)));

- /* Return current frequency */
-postchange:
- rdmsr(MSR_IA32_PERF_STATUS, lo, hi);
- freqs.new = centaur->fsb * ((lo >> 8) & 0xff);
-
#ifdef DEBUG
{
u8 current_multiplier, current_voltage;
@@ -161,11 +148,7 @@ postchange:
current_multiplier);
}
#endif
- if (err)
- freqs.new = freqs.old;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
- return err;
+ return 0;
}

static int eps_target(struct cpufreq_policy *policy, unsigned int index)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:25:50

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 191/228] cpufreq: elanfreq: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/elanfreq.c | 13 -------------
1 file changed, 13 deletions(-)

diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c
index 4ab4153..de08acf 100644
--- a/drivers/cpufreq/elanfreq.c
+++ b/drivers/cpufreq/elanfreq.c
@@ -108,17 +108,6 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
static int elanfreq_target(struct cpufreq_policy *policy,
unsigned int state)
{
- struct cpufreq_freqs freqs;
-
- freqs.old = elanfreq_get_cpu_frequency(0);
- freqs.new = elan_multiplier[state].clock;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
- printk(KERN_INFO "elanfreq: attempting to set frequency to %i kHz\n",
- elan_multiplier[state].clock);
-
-
/*
* Access to the Elan's internal registers is indexed via
* 0x22: Chip Setup & Control Register Index Register (CSCI)
@@ -149,8 +138,6 @@ static int elanfreq_target(struct cpufreq_policy *policy,
udelay(10000);
local_irq_enable();

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return 0;
}
/*
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:25:58

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 192/228] cpufreq: exynos: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/exynos-cpufreq.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index c178e73..c9ae7e6 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -25,7 +25,6 @@
static struct exynos_dvfs_info *exynos_info;

static struct regulator *arm_regulator;
-static struct cpufreq_freqs freqs;

static unsigned int locking_frequency;
static bool frequency_locked;
@@ -59,18 +58,18 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
struct cpufreq_policy *policy = cpufreq_cpu_get(0);
unsigned int arm_volt, safe_arm_volt = 0;
unsigned int mpll_freq_khz = exynos_info->mpll_freq_khz;
+ unsigned int old_freq;
int index, old_index;
int ret = 0;

- freqs.old = policy->cur;
- freqs.new = target_freq;
+ old_freq = policy->cur;

/*
* The policy max have been changed so that we cannot get proper
* old_index with cpufreq_frequency_table_target(). Thus, ignore
* policy and get the index from the raw freqeuncy table.
*/
- old_index = exynos_cpufreq_get_index(freqs.old);
+ old_index = exynos_cpufreq_get_index(old_freq);
if (old_index < 0) {
ret = old_index;
goto out;
@@ -95,17 +94,14 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
}
arm_volt = volt_table[index];

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
/* When the new frequency is higher than current frequency */
- if ((freqs.new > freqs.old) && !safe_arm_volt) {
+ if ((target_freq > old_freq) && !safe_arm_volt) {
/* Firstly, voltage up to increase frequency */
ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt);
if (ret) {
pr_err("%s: failed to set cpu voltage to %d\n",
__func__, arm_volt);
- freqs.new = freqs.old;
- goto post_notify;
+ return ret;
}
}

@@ -115,22 +111,15 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
if (ret) {
pr_err("%s: failed to set cpu voltage to %d\n",
__func__, safe_arm_volt);
- freqs.new = freqs.old;
- goto post_notify;
+ return ret;
}
}

exynos_info->set_freq(old_index, index);

-post_notify:
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- if (ret)
- goto out;
-
/* When the new frequency is lower than current frequency */
- if ((freqs.new < freqs.old) ||
- ((freqs.new > freqs.old) && safe_arm_volt)) {
+ if ((target_freq < old_freq) ||
+ ((target_freq > old_freq) && safe_arm_volt)) {
/* down the voltage after frequency change */
regulator_set_voltage(arm_regulator, arm_volt,
arm_volt);
@@ -142,7 +131,6 @@ post_notify:
}

out:
-
cpufreq_cpu_put(policy);

return ret;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:26:06

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 193/228] cpufreq: ia64-acpi: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Tony Luck <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ia64-acpi-cpufreq.c | 19 -------------------
1 file changed, 19 deletions(-)

diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
index 4695fa2..53c6ac6 100644
--- a/drivers/cpufreq/ia64-acpi-cpufreq.c
+++ b/drivers/cpufreq/ia64-acpi-cpufreq.c
@@ -141,7 +141,6 @@ processor_set_freq (
{
int ret = 0;
u32 value = 0;
- struct cpufreq_freqs cpufreq_freqs;
cpumask_t saved_mask;
int retval;

@@ -168,13 +167,6 @@ processor_set_freq (
pr_debug("Transitioning from P%d to P%d\n",
data->acpi_data.state, state);

- /* cpufreq frequency struct */
- cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency;
- cpufreq_freqs.new = data->freq_table[state].frequency;
-
- /* notify cpufreq */
- cpufreq_notify_transition(policy, &cpufreq_freqs, CPUFREQ_PRECHANGE);
-
/*
* First we write the target state's 'control' value to the
* control_register.
@@ -186,22 +178,11 @@ processor_set_freq (

ret = processor_set_pstate(value);
if (ret) {
- unsigned int tmp = cpufreq_freqs.new;
- cpufreq_notify_transition(policy, &cpufreq_freqs,
- CPUFREQ_POSTCHANGE);
- cpufreq_freqs.new = cpufreq_freqs.old;
- cpufreq_freqs.old = tmp;
- cpufreq_notify_transition(policy, &cpufreq_freqs,
- CPUFREQ_PRECHANGE);
- cpufreq_notify_transition(policy, &cpufreq_freqs,
- CPUFREQ_POSTCHANGE);
printk(KERN_WARNING "Transition failed with error %d\n", ret);
retval = -ENODEV;
goto migrate_end;
}

- cpufreq_notify_transition(policy, &cpufreq_freqs, CPUFREQ_POSTCHANGE);
-
data->acpi_data.state = state;

retval = 0;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:26:14

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 194/228] cpufreq: imx6q: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/imx6q-cpufreq.c | 37 +++++++++++++++----------------------
1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index e8846d7..a3829a0 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -41,14 +41,14 @@ static unsigned int imx6q_get_speed(unsigned int cpu)

static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
{
- struct cpufreq_freqs freqs;
struct opp *opp;
unsigned long freq_hz, volt, volt_old;
+ unsigned int old_freq, new_freq;
int ret;

- freqs.new = freq_table[index].frequency;
- freq_hz = freqs.new * 1000;
- freqs.old = clk_get_rate(arm_clk) / 1000;
+ new_freq = freq_table[index].frequency;
+ freq_hz = new_freq * 1000;
+ old_freq = clk_get_rate(arm_clk) / 1000;

rcu_read_lock();
opp = opp_find_freq_ceil(cpu_dev, &freq_hz);
@@ -63,26 +63,23 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
volt_old = regulator_get_voltage(arm_reg);

dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
- freqs.old / 1000, volt_old / 1000,
- freqs.new / 1000, volt / 1000);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+ old_freq / 1000, volt_old / 1000,
+ new_freq / 1000, volt / 1000);

/* scaling up? scale voltage before frequency */
- if (freqs.new > freqs.old) {
+ if (new_freq > old_freq) {
ret = regulator_set_voltage_tol(arm_reg, volt, 0);
if (ret) {
dev_err(cpu_dev,
"failed to scale vddarm up: %d\n", ret);
- freqs.new = freqs.old;
- goto post_notify;
+ return ret;
}

/*
* Need to increase vddpu and vddsoc for safety
* if we are about to run at 1.2 GHz.
*/
- if (freqs.new == FREQ_1P2_GHZ / 1000) {
+ if (new_freq == FREQ_1P2_GHZ / 1000) {
regulator_set_voltage_tol(pu_reg,
PU_SOC_VOLTAGE_HIGH, 0);
regulator_set_voltage_tol(soc_reg,
@@ -102,21 +99,20 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
clk_set_parent(step_clk, pll2_pfd2_396m_clk);
clk_set_parent(pll1_sw_clk, step_clk);
if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) {
- clk_set_rate(pll1_sys_clk, freqs.new * 1000);
+ clk_set_rate(pll1_sys_clk, new_freq * 1000);
clk_set_parent(pll1_sw_clk, pll1_sys_clk);
}

/* Ensure the arm clock divider is what we expect */
- ret = clk_set_rate(arm_clk, freqs.new * 1000);
+ ret = clk_set_rate(arm_clk, new_freq * 1000);
if (ret) {
dev_err(cpu_dev, "failed to set clock rate: %d\n", ret);
regulator_set_voltage_tol(arm_reg, volt_old, 0);
- freqs.new = freqs.old;
- goto post_notify;
+ return ret;
}

/* scaling down? scale voltage after frequency */
- if (freqs.new < freqs.old) {
+ if (new_freq < old_freq) {
ret = regulator_set_voltage_tol(arm_reg, volt, 0);
if (ret) {
dev_warn(cpu_dev,
@@ -124,7 +120,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
ret = 0;
}

- if (freqs.old == FREQ_1P2_GHZ / 1000) {
+ if (old_freq == FREQ_1P2_GHZ / 1000) {
regulator_set_voltage_tol(pu_reg,
PU_SOC_VOLTAGE_NORMAL, 0);
regulator_set_voltage_tol(soc_reg,
@@ -132,10 +128,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
}
}

-post_notify:
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- return ret;
+ return 0;
}

static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:26:27

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 196/228] cpufreq: loongson2: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: John Crispin <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/loongson2_cpufreq.c | 16 ----------------
1 file changed, 16 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index 41a8e2c..a436092 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -57,7 +57,6 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
{
unsigned int cpu = policy->cpu;
cpumask_t cpus_allowed;
- struct cpufreq_freqs freqs;
unsigned int freq;

cpus_allowed = current->cpus_allowed;
@@ -67,26 +66,11 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
((cpu_clock_freq / 1000) *
loongson2_clockmod_table[index].driver_data) / 8;

- 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;
-
- /* notifiers */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
set_cpus_allowed_ptr(current, &cpus_allowed);

/* setting the cpu frequency */
clk_set_rate(cpuclk, freq);

- /* notifiers */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- pr_debug("cpufreq: set frequency %u kHz\n", freq);
-
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:26:31

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 195/228] cpufreq: kirkwood: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Andrew Lunn <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/kirkwood-cpufreq.c | 54 ++++++++++++++------------------------
1 file changed, 20 insertions(+), 34 deletions(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index 0ae4dd7..0767a4e 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -58,48 +58,34 @@ static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)
static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
unsigned int index)
{
- struct cpufreq_freqs freqs;
unsigned int state = kirkwood_freq_table[index].driver_data;
unsigned long reg;

- freqs.old = kirkwood_cpufreq_get_cpu_frequency(0);
- freqs.new = kirkwood_freq_table[index].frequency;
+ local_irq_disable();

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+ /* Disable interrupts to the CPU */
+ reg = readl_relaxed(priv.base);
+ reg |= CPU_SW_INT_BLK;
+ writel_relaxed(reg, priv.base);

- dev_dbg(priv.dev, "Attempting to set frequency to %i KHz\n",
- kirkwood_freq_table[index].frequency);
- dev_dbg(priv.dev, "old frequency was %i KHz\n",
- kirkwood_cpufreq_get_cpu_frequency(0));
-
- if (freqs.old != freqs.new) {
- local_irq_disable();
-
- /* Disable interrupts to the CPU */
- reg = readl_relaxed(priv.base);
- reg |= CPU_SW_INT_BLK;
- writel_relaxed(reg, priv.base);
-
- switch (state) {
- case STATE_CPU_FREQ:
- clk_disable(priv.powersave_clk);
- break;
- case STATE_DDR_FREQ:
- clk_enable(priv.powersave_clk);
- break;
- }
+ switch (state) {
+ case STATE_CPU_FREQ:
+ clk_disable(priv.powersave_clk);
+ break;
+ case STATE_DDR_FREQ:
+ clk_enable(priv.powersave_clk);
+ break;
+ }

- /* Wait-for-Interrupt, while the hardware changes frequency */
- cpu_do_idle();
+ /* Wait-for-Interrupt, while the hardware changes frequency */
+ cpu_do_idle();

- /* Enable interrupts to the CPU */
- reg = readl_relaxed(priv.base);
- reg &= ~CPU_SW_INT_BLK;
- writel_relaxed(reg, priv.base);
+ /* Enable interrupts to the CPU */
+ reg = readl_relaxed(priv.base);
+ reg &= ~CPU_SW_INT_BLK;
+ writel_relaxed(reg, priv.base);

- local_irq_enable();
- }
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
+ local_irq_enable();

return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:26:40

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 198/228] cpufreq: omap: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Santosh Shilimkar <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/omap-cpufreq.c | 39 ++++++++++++++-------------------------
1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 0653887..e92d72e 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -53,15 +53,15 @@ static unsigned int omap_getspeed(unsigned int cpu)

static int omap_target(struct cpufreq_policy *policy, unsigned int index)
{
- int r, ret = 0;
- struct cpufreq_freqs freqs;
+ int r, ret;
struct opp *opp;
unsigned long freq, volt = 0, volt_old = 0, tol = 0;
+ unsigned int old_freq, new_freq;

- freqs.old = omap_getspeed(policy->cpu);
- freqs.new = freq_table[index].frequency;
+ old_freq = omap_getspeed(policy->cpu);
+ new_freq = freq_table[index].frequency;

- freq = freqs.new * 1000;
+ freq = new_freq * 1000;
ret = clk_round_rate(mpu_clk, freq);
if (IS_ERR_VALUE(ret)) {
dev_warn(mpu_dev,
@@ -77,7 +77,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)
if (IS_ERR(opp)) {
rcu_read_unlock();
dev_err(mpu_dev, "%s: unable to find MPU OPP for %d\n",
- __func__, freqs.new);
+ __func__, new_freq);
return -EINVAL;
}
volt = opp_get_voltage(opp);
@@ -87,43 +87,32 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)
}

dev_dbg(mpu_dev, "cpufreq-omap: %u MHz, %ld mV --> %u MHz, %ld mV\n",
- freqs.old / 1000, volt_old ? volt_old / 1000 : -1,
- freqs.new / 1000, volt ? volt / 1000 : -1);
-
- /* notifiers */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+ old_freq / 1000, volt_old ? volt_old / 1000 : -1,
+ new_freq / 1000, volt ? volt / 1000 : -1);

/* scaling up? scale voltage before frequency */
- if (mpu_reg && (freqs.new > freqs.old)) {
+ if (mpu_reg && (new_freq > old_freq)) {
r = regulator_set_voltage(mpu_reg, volt - tol, volt + tol);
if (r < 0) {
dev_warn(mpu_dev, "%s: unable to scale voltage up.\n",
__func__);
- freqs.new = freqs.old;
- goto done;
+ return r;
}
}

- ret = clk_set_rate(mpu_clk, freqs.new * 1000);
+ ret = clk_set_rate(mpu_clk, new_freq * 1000);

/* scaling down? scale voltage after frequency */
- if (mpu_reg && (freqs.new < freqs.old)) {
+ if (mpu_reg && (new_freq < old_freq)) {
r = regulator_set_voltage(mpu_reg, volt - tol, volt + tol);
if (r < 0) {
dev_warn(mpu_dev, "%s: unable to scale voltage down.\n",
__func__);
- ret = clk_set_rate(mpu_clk, freqs.old * 1000);
- freqs.new = freqs.old;
- goto done;
+ clk_set_rate(mpu_clk, old_freq * 1000);
+ return r;
}
}

- freqs.new = omap_getspeed(policy->cpu);
-
-done:
- /* notifiers */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return ret;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:26:51

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 199/228] cpufreq: p4-clockmod: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: David S. Miller <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/p4-clockmod.c | 10 ----------
1 file changed, 10 deletions(-)

diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 3c23053..3d1cba9 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -107,15 +107,8 @@ static struct cpufreq_frequency_table p4clockmod_table[] = {

static int cpufreq_p4_target(struct cpufreq_policy *policy, unsigned int index)
{
- struct cpufreq_freqs freqs;
int i;

- freqs.old = cpufreq_p4_get(policy->cpu);
- freqs.new = stock_freq * p4clockmod_table[index].driver_data / 8;
-
- /* notifiers */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
/* run on each logical CPU,
* see section 13.15.3 of IA32 Intel Architecture Software
* Developer's Manual, Volume 3
@@ -123,9 +116,6 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, unsigned int index)
for_each_cpu(i, policy->cpus)
cpufreq_p4_setdc(i, p4clockmod_table[index].driver_data);

- /* notifiers */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:27:02

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 201/228] cpufreq: pmac: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pmac32-cpufreq.c | 20 ++++----------------
drivers/cpufreq/pmac64-cpufreq.c | 18 +-----------------
2 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index 9137fa9..476fc4a 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -331,21 +331,11 @@ static int pmu_set_cpu_speed(int low_speed)
return 0;
}

-static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode,
- int notify)
+static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode)
{
- struct cpufreq_freqs freqs;
unsigned long l3cr;
static unsigned long prev_l3cr;

- freqs.old = cur_freq;
- freqs.new = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq;
-
- if (freqs.old == freqs.new)
- return 0;
-
- if (notify)
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
if (speed_mode == CPUFREQ_LOW &&
cpu_has_feature(CPU_FTR_L3CR)) {
l3cr = _get_L3CR();
@@ -361,8 +351,6 @@ static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode,
if ((prev_l3cr & L3CR_L3E) && l3cr != prev_l3cr)
_set_L3CR(prev_l3cr);
}
- if (notify)
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
cur_freq = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq;

return 0;
@@ -378,7 +366,7 @@ static int pmac_cpufreq_target( struct cpufreq_policy *policy,
{
int rc;

- rc = do_set_cpu_speed(policy, index, 1);
+ rc = do_set_cpu_speed(policy, index);

ppc_proc_freq = cur_freq * 1000ul;
return rc;
@@ -420,7 +408,7 @@ static int pmac_cpufreq_suspend(struct cpufreq_policy *policy)
no_schedule = 1;
sleep_freq = cur_freq;
if (cur_freq == low_freq && !is_pmu_based)
- do_set_cpu_speed(policy, CPUFREQ_HIGH, 0);
+ do_set_cpu_speed(policy, CPUFREQ_HIGH);
return 0;
}

@@ -437,7 +425,7 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)
* probably high speed due to our suspend() routine
*/
do_set_cpu_speed(policy, sleep_freq == low_freq ?
- CPUFREQ_LOW : CPUFREQ_HIGH, 0);
+ CPUFREQ_LOW : CPUFREQ_HIGH);

ppc_proc_freq = cur_freq * 1000ul;

diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index af970b7..07ef0ee 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -79,8 +79,6 @@ static void (*g5_switch_volt)(int speed_mode);
static int (*g5_switch_freq)(int speed_mode);
static int (*g5_query_freq)(void);

-static DEFINE_MUTEX(g5_switch_mutex);
-
static unsigned long transition_latency;

#ifdef CONFIG_PMAC_SMU
@@ -314,21 +312,7 @@ static int g5_pfunc_query_freq(void)

static int g5_cpufreq_target(struct cpufreq_policy *policy, unsigned int index)
{
- struct cpufreq_freqs freqs;
- int rc;
-
- mutex_lock(&g5_switch_mutex);
-
- freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency;
- freqs.new = g5_cpu_freqs[index].frequency;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
- rc = g5_switch_freq(index);
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- mutex_unlock(&g5_switch_mutex);
-
- return rc;
+ return g5_switch_freq(index);
}

static unsigned int g5_cpufreq_get_speed(unsigned int cpu)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:27:08

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 202/228] cpufreq: ppc: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ppc-corenet-cpufreq.c | 19 +------------------
drivers/cpufreq/ppc_cbe_cpufreq.c | 19 +------------------
2 files changed, 2 insertions(+), 36 deletions(-)

diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index 79d8e9c..3f7be46 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -69,8 +69,6 @@ static const struct soc_data sdata[] = {
static u32 min_cpufreq;
static const u32 *fmask;

-/* serialize frequency changes */
-static DEFINE_MUTEX(cpufreq_lock);
static DEFINE_PER_CPU(struct cpu_data *, cpu_data);

/* cpumask in a cluster */
@@ -253,26 +251,11 @@ static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy)
static int corenet_cpufreq_target(struct cpufreq_policy *policy,
unsigned int index)
{
- struct cpufreq_freqs freqs;
struct clk *parent;
- int ret;
struct cpu_data *data = per_cpu(cpu_data, policy->cpu);

- freqs.old = policy->cur;
- 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[index].driver_data);
- ret = clk_set_parent(data->clk, parent);
- if (ret)
- freqs.new = freqs.old;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
- mutex_unlock(&cpufreq_lock);
-
- return ret;
+ return clk_set_parent(data->clk, parent);
}

static struct cpufreq_driver ppc_corenet_cpufreq_driver = {
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
index 52f707d..e42ca9c 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -30,9 +30,6 @@

#include "ppc_cbe_cpufreq.h"

-static DEFINE_MUTEX(cbe_switch_mutex);
-
-
/* the CBE supports an 8 step frequency scaling */
static struct cpufreq_frequency_table cbe_freqs[] = {
{1, 0},
@@ -131,27 +128,13 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
static int cbe_cpufreq_target(struct cpufreq_policy *policy,
unsigned int cbe_pmode_new)
{
- int rc;
- struct cpufreq_freqs freqs;
-
- freqs.old = policy->cur;
- freqs.new = cbe_freqs[cbe_pmode_new].frequency;
-
- mutex_lock(&cbe_switch_mutex);
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
pr_debug("setting frequency for cpu %d to %d kHz, " \
"1/%d of max frequency\n",
policy->cpu,
cbe_freqs[cbe_pmode_new].frequency,
cbe_freqs[cbe_pmode_new].driver_data);

- rc = set_pmode(policy->cpu, cbe_pmode_new);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
- mutex_unlock(&cbe_switch_mutex);
-
- return rc;
+ return set_pmode(policy->cpu, cbe_pmode_new);
}

static struct cpufreq_driver cbe_cpufreq_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:27:18

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 203/228] cpufreq: pxa: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Eric Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pxa2xx-cpufreq.c | 27 ++++++---------------------
drivers/cpufreq/pxa3xx-cpufreq.c | 12 ------------
2 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 183bc13..0a0f436 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -271,7 +271,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
{
struct cpufreq_frequency_table *pxa_freqs_table;
pxa_freqs_t *pxa_freq_settings;
- struct cpufreq_freqs freqs;
unsigned long flags;
unsigned int new_freq_cpu, new_freq_mem;
unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -282,24 +281,17 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)

new_freq_cpu = pxa_freq_settings[idx].khz;
new_freq_mem = pxa_freq_settings[idx].membus;
- freqs.old = policy->cur;
- freqs.new = new_freq_cpu;

if (freq_debug)
pr_debug("Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n",
- freqs.new / 1000, (pxa_freq_settings[idx].div2) ?
+ new_freq_cpu / 1000, (pxa_freq_settings[idx].div2) ?
(new_freq_mem / 2000) : (new_freq_mem / 1000));

- if (vcc_core && freqs.new > freqs.old)
+ if (vcc_core && new_freq_cpu > policy->cur) {
ret = pxa_cpufreq_change_voltage(&pxa_freq_settings[idx]);
- if (ret)
- return ret;
- /*
- * Tell everyone what we're about to do...
- * you should add a notify client with any platform specific
- * Vcc changing capability
- */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+ if (ret)
+ return ret;
+ }

/* Calculate the next MDREFR. If we're slowing down the SDRAM clock
* we need to preset the smaller DRI before the change. If we're
@@ -350,13 +342,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
local_irq_restore(flags);

/*
- * Tell everyone what we've just done...
- * you should add a notify client with any platform specific
- * SDRAM refresh timer adjustments
- */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- /*
* Even if voltage setting fails, we don't report it, as the frequency
* change succeeded. The voltage reduction is not a critical failure,
* only power savings will suffer from this.
@@ -365,7 +350,7 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
* bug is triggered (seems a deadlock). Should anybody find out where,
* the "return 0" should become a "return ret".
*/
- if (vcc_core && freqs.new < freqs.old)
+ if (vcc_core && new_freq_cpu < policy->cur)
ret = pxa_cpufreq_change_voltage(&pxa_freq_settings[idx]);

return 0;
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 132e37d..9384004 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -158,7 +158,6 @@ static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)
static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index)
{
struct pxa3xx_freq_info *next;
- struct cpufreq_freqs freqs;
unsigned long flags;

if (policy->cpu != 0)
@@ -166,22 +165,11 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index)

next = &pxa3xx_freqs[index];

- freqs.old = policy->cur;
- freqs.new = next->cpufreq_mhz * 1000;
-
- pr_debug("CPU frequency from %d MHz to %d MHz%s\n",
- freqs.old / 1000, freqs.new / 1000,
- (freqs.old == freqs.new) ? " (skipped)" : "");
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
local_irq_save(flags);
__update_core_freq(next);
__update_bus_freq(next);
local_irq_restore(flags);

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:27:23

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 204/228] cpufreq: s3c: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s3c2416-cpufreq.c | 21 ++++-------------
drivers/cpufreq/s3c64xx-cpufreq.c | 48 +++++++++++++--------------------------
2 files changed, 20 insertions(+), 49 deletions(-)

diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index 4188acc..8d904a0 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -220,7 +220,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy,
unsigned int index)
{
struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;
- struct cpufreq_freqs freqs;
+ unsigned int new_freq;
int idx, ret, to_dvs = 0;

mutex_lock(&cpufreq_lock);
@@ -237,25 +237,14 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy,
goto out;
}

- freqs.flags = 0;
- freqs.old = s3c_freq->is_dvs ? FREQ_DVS
- : clk_get_rate(s3c_freq->armclk) / 1000;
-
/* When leavin dvs mode, always switch the armdiv to the hclk rate
* The S3C2416 has stability issues when switching directly to
* higher frequencies.
*/
- freqs.new = (s3c_freq->is_dvs && !to_dvs)
+ new_freq = (s3c_freq->is_dvs && !to_dvs)
? clk_get_rate(s3c_freq->hclk) / 1000
: 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) {
pr_debug("cpufreq: enter dvs\n");
ret = s3c2416_cpufreq_enter_dvs(s3c_freq, idx);
@@ -263,12 +252,10 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy,
pr_debug("cpufreq: leave dvs\n");
ret = s3c2416_cpufreq_leave_dvs(s3c_freq, idx);
} else {
- pr_debug("cpufreq: change armdiv to %dkHz\n", freqs.new);
- ret = s3c2416_cpufreq_set_armdiv(s3c_freq, freqs.new);
+ pr_debug("cpufreq: change armdiv to %dkHz\n", new_freq);
+ ret = s3c2416_cpufreq_set_armdiv(s3c_freq, new_freq);
}

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
out:
mutex_unlock(&cpufreq_lock);

diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 34ae66b..8b49a06 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -65,54 +65,46 @@ static unsigned int s3c64xx_cpufreq_get_speed(unsigned int cpu)
static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
unsigned int index)
{
- int ret;
- struct cpufreq_freqs freqs;
struct s3c64xx_dvfs *dvfs;
+ unsigned int old_freq, new_freq;
+ int ret;

- freqs.old = clk_get_rate(armclk) / 1000;
- freqs.new = s3c64xx_freq_table[index].frequency;
- freqs.flags = 0;
+ old_freq = clk_get_rate(armclk) / 1000;
+ new_freq = s3c64xx_freq_table[index].frequency;
dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[index].driver_data];

- pr_debug("Transition %d-%dkHz\n", freqs.old, freqs.new);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
#ifdef CONFIG_REGULATOR
- if (vddarm && freqs.new > freqs.old) {
+ if (vddarm && new_freq > old_freq) {
ret = regulator_set_voltage(vddarm,
dvfs->vddarm_min,
dvfs->vddarm_max);
if (ret != 0) {
pr_err("Failed to set VDDARM for %dkHz: %d\n",
- freqs.new, ret);
- freqs.new = freqs.old;
- goto post_notify;
+ new_freq, ret);
+ return ret;
}
}
#endif

- ret = clk_set_rate(armclk, freqs.new * 1000);
+ ret = clk_set_rate(armclk, new_freq * 1000);
if (ret < 0) {
pr_err("Failed to set rate %dkHz: %d\n",
- freqs.new, ret);
- freqs.new = freqs.old;
+ new_freq, ret);
+ return ret;
}

-post_notify:
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
- if (ret)
- goto err;
-
#ifdef CONFIG_REGULATOR
- if (vddarm && freqs.new < freqs.old) {
+ if (vddarm && new_freq < old_freq) {
ret = regulator_set_voltage(vddarm,
dvfs->vddarm_min,
dvfs->vddarm_max);
if (ret != 0) {
pr_err("Failed to set VDDARM for %dkHz: %d\n",
- freqs.new, ret);
- goto err_clk;
+ new_freq, ret);
+ if (clk_set_rate(armclk, old_freq * 1000) < 0)
+ pr_err("Failed to restore original clock rate\n");
+
+ return ret;
}
}
#endif
@@ -121,14 +113,6 @@ post_notify:
clk_get_rate(armclk) / 1000);

return 0;
-
-err_clk:
- if (clk_set_rate(armclk, freqs.old * 1000) < 0)
- pr_err("Failed to restore original clock rate\n");
-err:
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- return ret;
}

#ifdef CONFIG_REGULATOR
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:27:31

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 205/228] cpufreq: s5pv210: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s5pv210-cpufreq.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 5978b94..e3973da 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -26,7 +26,6 @@
static struct clk *cpu_clk;
static struct clk *dmc0_clk;
static struct clk *dmc1_clk;
-static struct cpufreq_freqs freqs;
static DEFINE_MUTEX(set_freq_lock);

/* APLL M,P,S values for 1G/800Mhz */
@@ -179,6 +178,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
unsigned int priv_index;
unsigned int pll_changing = 0;
unsigned int bus_speed_changing = 0;
+ unsigned int old_freq, new_freq;
int arm_volt, int_volt;
int ret = 0;

@@ -193,12 +193,12 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
goto exit;
}

- freqs.old = s5pv210_getspeed(0);
- freqs.new = s5pv210_freq_table[index].frequency;
+ old_freq = s5pv210_getspeed(0);
+ new_freq = s5pv210_freq_table[index].frequency;

/* Finding current running level index */
if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
- freqs.old, CPUFREQ_RELATION_H,
+ old_freq, CPUFREQ_RELATION_H,
&priv_index)) {
ret = -EINVAL;
goto exit;
@@ -207,7 +207,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
arm_volt = dvs_conf[index].arm_volt;
int_volt = dvs_conf[index].int_volt;

- if (freqs.new > freqs.old) {
+ if (new_freq > old_freq) {
ret = regulator_set_voltage(arm_regulator,
arm_volt, arm_volt_max);
if (ret)
@@ -219,8 +219,6 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
goto exit;
}

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
/* Check if there need to change PLL */
if ((index == L0) || (priv_index == L0))
pll_changing = 1;
@@ -431,9 +429,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
}
}

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- if (freqs.new < freqs.old) {
+ if (new_freq < old_freq) {
regulator_set_voltage(int_regulator,
int_volt, int_volt_max);

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:27:46

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 207/228] cpufreq: sc520: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sc520_freq.c | 11 -----------
1 file changed, 11 deletions(-)

diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c
index 6c86452..6adb354 100644
--- a/drivers/cpufreq/sc520_freq.c
+++ b/drivers/cpufreq/sc520_freq.c
@@ -56,17 +56,8 @@ static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu)
static int sc520_freq_target(struct cpufreq_policy *policy, unsigned int state)
{

- struct cpufreq_freqs freqs;
u8 clockspeed_reg;

- freqs.old = sc520_freq_get_cpu_frequency(0);
- freqs.new = sc520_freq_table[state].frequency;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
- pr_debug("attempting to set frequency to %i kHz\n",
- sc520_freq_table[state].frequency);
-
local_irq_disable();

clockspeed_reg = *cpuctl & ~0x03;
@@ -74,8 +65,6 @@ static int sc520_freq_target(struct cpufreq_policy *policy, unsigned int state)

local_irq_enable();

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:27:38

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Russell King <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sa1100-cpufreq.c | 17 ++++++-----------
drivers/cpufreq/sa1110-cpufreq.c | 12 ++----------
2 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c
index b0da1fe..623da74 100644
--- a/drivers/cpufreq/sa1100-cpufreq.c
+++ b/drivers/cpufreq/sa1100-cpufreq.c
@@ -180,22 +180,17 @@ static void sa1100_update_dram_timings(int current_speed, int new_speed)
static int sa1100_target(struct cpufreq_policy *policy, unsigned int ppcr)
{
unsigned int cur = sa11x0_getspeed(0);
- struct cpufreq_freqs freqs;
+ unsigned int new_freq;

- freqs.old = cur;
- freqs.new = sa11x0_freq_table[ppcr].frequency;
+ new_freq = sa11x0_freq_table[ppcr].frequency;

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
- if (freqs.new > cur)
- sa1100_update_dram_timings(cur, freqs.new);
+ if (new_freq > cur)
+ sa1100_update_dram_timings(cur, new_freq);

PPCR = ppcr;

- if (freqs.new < cur)
- sa1100_update_dram_timings(cur, freqs.new);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
+ if (new_freq < cur)
+ sa1100_update_dram_timings(cur, new_freq);

return 0;
}
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c
index 55b1818c..2c2b2e6 100644
--- a/drivers/cpufreq/sa1110-cpufreq.c
+++ b/drivers/cpufreq/sa1110-cpufreq.c
@@ -232,15 +232,11 @@ sdram_update_refresh(u_int cpu_khz, struct sdram_params *sdram)
static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr)
{
struct sdram_params *sdram = &sdram_params;
- struct cpufreq_freqs freqs;
struct sdram_info sd;
unsigned long flags;
unsigned int unused;

- freqs.old = sa11x0_getspeed(0);
- freqs.new = sa11x0_freq_table[ppcr].frequency;
-
- sdram_calculate_timing(&sd, freqs.new, sdram);
+ sdram_calculate_timing(&sd, sa11x0_freq_table[ppcr].frequency, sdram);

#if 0
/*
@@ -259,8 +255,6 @@ static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr)
sd.mdcas[2] = 0xaaaaaaaa;
#endif

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
/*
* The clock could be going away for some time. Set the SDRAMs
* to refresh rapidly (every 64 memory clock cycles). To get
@@ -305,9 +299,7 @@ static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr)
/*
* Now, return the SDRAM refresh back to normal.
*/
- sdram_update_refresh(freqs.new, sdram);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
+ sdram_update_refresh(sa11x0_freq_table[ppcr].frequency, sdram);

return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:27:56

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 208/228] cpufreq: sparc: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: David S. Miller <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sparc-us2e-cpufreq.c | 7 -------
drivers/cpufreq/sparc-us3-cpufreq.c | 7 -------
2 files changed, 14 deletions(-)

diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index 3bf5b8f..62aa23e 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -251,7 +251,6 @@ static int us2e_freq_target(struct cpufreq_policy *policy, unsigned int index)
unsigned long new_bits, new_freq;
unsigned long clock_tick, divisor, old_divisor, estar;
cpumask_t cpus_allowed;
- struct cpufreq_freqs freqs;

cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current));
set_cpus_allowed_ptr(current, cpumask_of(cpu));
@@ -265,16 +264,10 @@ static int us2e_freq_target(struct cpufreq_policy *policy, unsigned int index)

old_divisor = estar_to_divisor(estar);

- freqs.old = clock_tick / old_divisor;
- freqs.new = new_freq;
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
if (old_divisor != divisor)
us2e_transition(estar, new_bits, clock_tick * 1000,
old_divisor, divisor);

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
set_cpus_allowed_ptr(current, &cpus_allowed);

return 0;
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index 2e54d55..724ffbd 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -98,7 +98,6 @@ static int us3_freq_target(struct cpufreq_policy *policy, unsigned int index)
unsigned int cpu = policy->cpu;
unsigned long new_bits, new_freq, reg;
cpumask_t cpus_allowed;
- struct cpufreq_freqs freqs;

cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current));
set_cpus_allowed_ptr(current, cpumask_of(cpu));
@@ -124,16 +123,10 @@ static int us3_freq_target(struct cpufreq_policy *policy, unsigned int index)

reg = read_safari_cfg();

- freqs.old = get_current_freq(cpu, reg);
- freqs.new = new_freq;
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
reg &= ~SAFARI_CFG_DIV_MASK;
reg |= new_bits;
write_safari_cfg(reg);

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
set_cpus_allowed_ptr(current, &cpus_allowed);

return 0;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:28:15

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Stephen Warren <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/tegra-cpufreq.c | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index bd7d89c..f42df7e 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -102,12 +102,8 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
unsigned long rate)
{
int ret = 0;
- struct cpufreq_freqs freqs;

- freqs.old = tegra_getspeed(0);
- freqs.new = rate;
-
- if (freqs.old == freqs.new)
+ if (tegra_getspeed(0) == rate)
return ret;

/*
@@ -121,21 +117,10 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
else
clk_set_rate(emc_clk, 100000000); /* emc 50Mhz */

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
-#ifdef CONFIG_CPU_FREQ_DEBUG
- printk(KERN_DEBUG "cpufreq-tegra: transition: %u --> %u\n",
- freqs.old, freqs.new);
-#endif
-
- ret = tegra_cpu_clk_set_rate(freqs.new * 1000);
- if (ret) {
- pr_err("cpu-tegra: Failed to set cpu frequency to %d kHz\n",
- freqs.new);
- freqs.new = freqs.old;
- }
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
+ ret = tegra_cpu_clk_set_rate(rate * 1000);
+ if (ret)
+ pr_err("cpu-tegra: Failed to set cpu frequency to %lu kHz\n",
+ rate);

return ret;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:28:23

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 212/228] cpufreq: tegra: remove target_cpu_speed[] array

Tegra's cpufreq driver was maintaining requested target frequencies in an array:
target_cpu_speed. And then finally setting the highest requested freq in the
core. This was probably done because both cores share clock line and logically
we want to set both cores to the max frequency requested..

But this wasn't required to be done in individual CPUFreq drivers, its already
taken care of by CPUFreq governors. They evaluate load for all CPUs and finally
call target only for the frequency corresponding to max load.

So, get rid of this stuff from Tegra's cpufreq driver.

Acked-by: Stephen Warren <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/tegra-cpufreq.c | 36 ++++++------------------------------
1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index f42df7e..7d36b54 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -47,7 +47,6 @@ static struct clk *pll_x_clk;
static struct clk *pll_p_clk;
static struct clk *emc_clk;

-static unsigned long target_cpu_speed[NUM_CPUS];
static DEFINE_MUTEX(tegra_cpu_lock);
static bool is_suspended;

@@ -103,9 +102,6 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
{
int ret = 0;

- if (tegra_getspeed(0) == rate)
- return ret;
-
/*
* Vote on memory bus frequency based on cpu frequency
* This sets the minimum frequency, display or avp may request higher
@@ -125,35 +121,16 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
return ret;
}

-static unsigned long tegra_cpu_highest_speed(void)
-{
- unsigned long rate = 0;
- int i;
-
- for_each_online_cpu(i)
- rate = max(rate, target_cpu_speed[i]);
- return rate;
-}
-
static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
{
- unsigned int freq;
- int ret = 0;
+ int ret = -EBUSY;

mutex_lock(&tegra_cpu_lock);

- if (is_suspended) {
- ret = -EBUSY;
- goto out;
- }
-
- freq = freq_table[index].frequency;
-
- target_cpu_speed[policy->cpu] = freq;
+ if (!is_suspended)
+ ret = tegra_update_cpu_speed(policy,
+ freq_table[index].frequency);

- ret = tegra_update_cpu_speed(policy, tegra_cpu_highest_speed());
-
-out:
mutex_unlock(&tegra_cpu_lock);
return ret;
}
@@ -167,7 +144,8 @@ static int tegra_pm_notify(struct notifier_block *nb, unsigned long event,
is_suspended = true;
pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n",
freq_table[0].frequency);
- tegra_update_cpu_speed(policy, freq_table[0].frequency);
+ if (tegra_getspeed(0) != freq_table[0].frequency)
+ tegra_update_cpu_speed(policy, freq_table[0].frequency);
cpufreq_cpu_put(policy);
} else if (event == PM_POST_SUSPEND) {
is_suspended = false;
@@ -191,8 +169,6 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
clk_prepare_enable(emc_clk);
clk_prepare_enable(cpu_clk);

- target_cpu_speed[policy->cpu] = tegra_getspeed(policy->cpu);
-
/* FIXME: what's the actual transition time? */
ret = cpufreq_generic_init(policy, freq_table, 300 * 1000);
if (ret) {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:28:28

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 213/228] cpufreq: create cpufreq_generic_get() routine

CPUFreq drivers that use clock frameworks interface,i.e. clk_get_rate(), to get
CPUs clk rate, has similar sort of code used for most of them.

This patch adds a generic ->get() which will do the same thing for them. All
those drivers are required to now is to set .get to cpufreq_generic_get() and
set their clk pointer in policy->clk during ->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++++++------
include/linux/cpufreq.h | 3 +++
2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 79f89c3..2c1ae708 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -219,6 +219,20 @@ int cpufreq_generic_init(struct cpufreq_policy *policy,
}
EXPORT_SYMBOL_GPL(cpufreq_generic_init);

+unsigned int cpufreq_generic_get(unsigned int cpu)
+{
+ struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
+
+ if (!policy || IS_ERR(policy->clk)) {
+ pr_err("%s: No %s associated to cpu: %d\n", __func__,
+ policy ? "clk" : "policy", cpu);
+ return 0;
+ }
+
+ return clk_get_rate(policy->clk) / 1000;
+}
+EXPORT_SYMBOL_GPL(cpufreq_generic_get);
+
struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
{
struct cpufreq_policy *policy = NULL;
@@ -1115,6 +1129,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
goto err_set_policy_cpu;
}

+ write_lock_irqsave(&cpufreq_driver_lock, flags);
+ for_each_cpu(j, policy->cpus)
+ per_cpu(cpufreq_cpu_data, j) = policy;
+ write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
if (cpufreq_driver->get) {
policy->cur = cpufreq_driver->get(policy->cpu);
if (!policy->cur) {
@@ -1147,11 +1166,6 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
}
#endif

- write_lock_irqsave(&cpufreq_driver_lock, flags);
- for_each_cpu(j, policy->cpus)
- per_cpu(cpufreq_cpu_data, j) = policy;
- write_unlock_irqrestore(&cpufreq_driver_lock, flags);
-
if (!frozen) {
ret = cpufreq_add_dev_interface(policy, dev);
if (ret)
@@ -1172,12 +1186,12 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
return 0;

err_out_unregister:
+err_get_freq:
write_lock_irqsave(&cpufreq_driver_lock, flags);
for_each_cpu(j, policy->cpus)
per_cpu(cpufreq_cpu_data, j) = NULL;
write_unlock_irqrestore(&cpufreq_driver_lock, flags);

-err_get_freq:
if (cpufreq_driver->exit)
cpufreq_driver->exit(policy);
err_set_policy_cpu:
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index f13beec..d396fba 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -11,6 +11,7 @@
#ifndef _LINUX_CPUFREQ_H
#define _LINUX_CPUFREQ_H

+#include <linux/clk.h>
#include <linux/cpumask.h>
#include <linux/completion.h>
#include <linux/kobject.h>
@@ -66,6 +67,7 @@ struct cpufreq_policy {
unsigned int cpu; /* cpu nr of CPU managing this policy */
unsigned int last_cpu; /* cpu nr of previous CPU that managed
* this policy */
+ struct clk *clk;
struct cpufreq_cpuinfo cpuinfo;/* see above */

unsigned int min; /* in kHz */
@@ -440,6 +442,7 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu);
int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table);

+unsigned int cpufreq_generic_get(unsigned int cpu);
int cpufreq_generic_init(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table,
unsigned int transition_latency);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:28:37

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 214/228] cpufreq: arm_big_little: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/arm_big_little.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 69cae42..5b745f9 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -40,13 +40,6 @@ static struct clk *clk[MAX_CLUSTERS];
static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS];
static atomic_t cluster_usage[MAX_CLUSTERS] = {ATOMIC_INIT(0), ATOMIC_INIT(0)};

-static unsigned int bL_cpufreq_get(unsigned int cpu)
-{
- u32 cur_cluster = cpu_to_cluster(cpu);
-
- return clk_get_rate(clk[cur_cluster]) / 1000;
-}
-
/* Set clock frequency */
static int bL_cpufreq_set_target(struct cpufreq_policy *policy,
unsigned int index)
@@ -145,6 +138,7 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)
else
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

+ policy->clk = clk[cur_cluster];
cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu));

dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu);
@@ -175,7 +169,7 @@ static struct cpufreq_driver bL_cpufreq_driver = {
CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = bL_cpufreq_set_target,
- .get = bL_cpufreq_get,
+ .get = cpufreq_generic_get,
.init = bL_cpufreq_init,
.exit = bL_cpufreq_exit,
.attr = cpufreq_generic_attr,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:28:45

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 215/228] cpufreq: at32ap: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

Acked-by: Hans-Christian Egtvedt <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/at32ap-cpufreq.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
index 856ad80..869c0b5 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -21,17 +21,8 @@
#include <linux/export.h>
#include <linux/slab.h>

-static struct clk *cpuclk;
static struct cpufreq_frequency_table *freq_table;

-static unsigned int at32_get_speed(unsigned int cpu)
-{
- /* No SMP support */
- if (cpu)
- return 0;
- return (unsigned int)((clk_get_rate(cpuclk) + 500) / 1000);
-}
-
static unsigned int ref_freq;
static unsigned long loops_per_jiffy_ref;

@@ -39,7 +30,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned int old_freq, new_freq;

- old_freq = at32_get_speed(0);
+ old_freq = policy->cur;
new_freq = freq_table[index].frequency;

if (!ref_freq) {
@@ -50,7 +41,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)
if (old_freq < new_freq)
boot_cpu_data.loops_per_jiffy = cpufreq_scale(
loops_per_jiffy_ref, ref_freq, new_freq);
- clk_set_rate(cpuclk, new_freq * 1000);
+ clk_set_rate(policy->clk, new_freq * 1000);
if (new_freq < old_freq)
boot_cpu_data.loops_per_jiffy = cpufreq_scale(
loops_per_jiffy_ref, ref_freq, new_freq);
@@ -61,6 +52,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)
static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
{
unsigned int frequency, rate, min_freq;
+ static struct clk *cpuclk;
int retval, steps, i;

if (policy->cpu != 0)
@@ -103,6 +95,7 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
frequency /= 2;
}

+ policy->clk = cpuclk;
freq_table[steps - 1].frequency = CPUFREQ_TABLE_END;

retval = cpufreq_table_validate_and_show(policy, freq_table);
@@ -123,7 +116,7 @@ static struct cpufreq_driver at32_driver = {
.init = at32_cpufreq_driver_init,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = at32_set_target,
- .get = at32_get_speed,
+ .get = cpufreq_generic_get,
.flags = CPUFREQ_STICKY,
};

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:28:53

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 216/228] cpufreq: cpu0: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

Acked-by: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq-cpu0.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 7b5547f..536ac8c 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 unsigned int cpu0_get_speed(unsigned int cpu)
-{
- return clk_get_rate(cpu_clk) / 1000;
-}
-
static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)
{
struct opp *opp;
@@ -99,6 +94,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)

static int cpu0_cpufreq_init(struct cpufreq_policy *policy)
{
+ policy->clk = cpu_clk;
return cpufreq_generic_init(policy, freq_table, transition_latency);
}

@@ -106,7 +102,7 @@ static struct cpufreq_driver cpu0_cpufreq_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = cpu0_set_target,
- .get = cpu0_get_speed,
+ .get = cpufreq_generic_get,
.init = cpu0_cpufreq_init,
.exit = cpufreq_generic_exit,
.name = "generic_cpu0",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:29:08

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 217/228] cpufreq: davinci: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

Cc: Sekhar Nori <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/davinci-cpufreq.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index 5e8a854..cd7fb6e 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -58,14 +58,6 @@ static int davinci_verify_speed(struct cpufreq_policy *policy)
return 0;
}

-static unsigned int davinci_getspeed(unsigned int cpu)
-{
- if (cpu)
- return 0;
-
- return clk_get_rate(cpufreq.armclk) / 1000;
-}
-
static int davinci_target(struct cpufreq_policy *policy, unsigned int idx)
{
struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data;
@@ -73,7 +65,7 @@ static int davinci_target(struct cpufreq_policy *policy, unsigned int idx)
unsigned int old_freq, new_freq;
int ret = 0;

- old_freq = davinci_getspeed(0);
+ old_freq = policy->cur;
new_freq = pdata->freq_table[idx].frequency;

/* if moving to higher frequency, up the voltage beforehand */
@@ -116,6 +108,8 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)
return result;
}

+ policy->clk = cpufreq.armclk;
+
/*
* Time measurement across the target() function yields ~1500-1800us
* time taken with no drivers on notification list.
@@ -129,7 +123,7 @@ static struct cpufreq_driver davinci_driver = {
.flags = CPUFREQ_STICKY,
.verify = davinci_verify_speed,
.target_index = davinci_target,
- .get = davinci_getspeed,
+ .get = cpufreq_generic_get,
.init = davinci_cpu_init,
.exit = cpufreq_generic_exit,
.name = "davinci",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:29:16

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 220/228] cpufreq: imx6q: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

Acked-by: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/imx6q-cpufreq.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index a3829a0..6993f0d 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 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 index)
{
struct opp *opp;
@@ -133,13 +128,14 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)

static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
{
+ policy->clk = arm_clk;
return cpufreq_generic_init(policy, freq_table, transition_latency);
}

static struct cpufreq_driver imx6q_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
.target_index = imx6q_set_target,
- .get = imx6q_get_speed,
+ .get = cpufreq_generic_get,
.init = imx6q_cpufreq_init,
.exit = cpufreq_generic_exit,
.name = "imx6q-cpufreq",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:29:25

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 221/228] cpufreq: loongson2: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

We don't need a global variable to hold clock anymore.

Cc: John Crispin <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/loongson2_cpufreq.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index a436092..b6581ab 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -24,8 +24,6 @@

static uint nowait;

-static struct clk *cpuclk;
-
static void (*saved_cpu_wait) (void);

static int loongson2_cpu_freq_notifier(struct notifier_block *nb,
@@ -44,11 +42,6 @@ static int loongson2_cpu_freq_notifier(struct notifier_block *nb,
return 0;
}

-static unsigned int loongson2_cpufreq_get(unsigned int cpu)
-{
- return clk_get_rate(cpuclk);
-}
-
/*
* Here we notify other drivers of the proposed change and the final change.
*/
@@ -69,13 +62,14 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
set_cpus_allowed_ptr(current, &cpus_allowed);

/* setting the cpu frequency */
- clk_set_rate(cpuclk, freq);
+ clk_set_rate(policy->clk, freq);

return 0;
}

static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
+ static struct clk *cpuclk;
int i;
unsigned long rate;
int ret;
@@ -104,13 +98,14 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
return ret;
}

+ policy->clk = cpuclk;
return cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0);
}

static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
{
cpufreq_frequency_table_put_attr(policy->cpu);
- clk_put(cpuclk);
+ clk_put(policy->clk);
return 0;
}

@@ -119,7 +114,7 @@ static struct cpufreq_driver loongson2_cpufreq_driver = {
.init = loongson2_cpufreq_cpu_init,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = loongson2_cpufreq_target,
- .get = loongson2_cpufreq_get,
+ .get = cpufreq_generic_get,
.exit = loongson2_cpufreq_exit,
.attr = cpufreq_generic_attr,
};
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:29:32

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 222/228] cpufreq: omap: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

We don't need a global variable to hold clock anymore.

Cc: Santosh Shilimkar <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/omap-cpufreq.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index e92d72e..a94c4ef 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -36,21 +36,9 @@

static struct cpufreq_frequency_table *freq_table;
static atomic_t freq_table_users = ATOMIC_INIT(0);
-static struct clk *mpu_clk;
static struct device *mpu_dev;
static struct regulator *mpu_reg;

-static unsigned int omap_getspeed(unsigned int cpu)
-{
- unsigned long rate;
-
- if (cpu >= NR_CPUS)
- return 0;
-
- rate = clk_get_rate(mpu_clk) / 1000;
- return rate;
-}
-
static int omap_target(struct cpufreq_policy *policy, unsigned int index)
{
int r, ret;
@@ -58,11 +46,11 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)
unsigned long freq, volt = 0, volt_old = 0, tol = 0;
unsigned int old_freq, new_freq;

- old_freq = omap_getspeed(policy->cpu);
+ old_freq = policy->cur;
new_freq = freq_table[index].frequency;

freq = new_freq * 1000;
- ret = clk_round_rate(mpu_clk, freq);
+ ret = clk_round_rate(policy->clk, freq);
if (IS_ERR_VALUE(ret)) {
dev_warn(mpu_dev,
"CPUfreq: Cannot find matching frequency for %lu\n",
@@ -100,7 +88,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)
}
}

- ret = clk_set_rate(mpu_clk, new_freq * 1000);
+ ret = clk_set_rate(policy->clk, new_freq * 1000);

/* scaling down? scale voltage after frequency */
if (mpu_reg && (new_freq < old_freq)) {
@@ -108,7 +96,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)
if (r < 0) {
dev_warn(mpu_dev, "%s: unable to scale voltage down.\n",
__func__);
- clk_set_rate(mpu_clk, old_freq * 1000);
+ clk_set_rate(policy->clk, old_freq * 1000);
return r;
}
}
@@ -126,9 +114,9 @@ static int omap_cpu_init(struct cpufreq_policy *policy)
{
int result;

- mpu_clk = clk_get(NULL, "cpufreq_ck");
- if (IS_ERR(mpu_clk))
- return PTR_ERR(mpu_clk);
+ policy->clk = clk_get(NULL, "cpufreq_ck");
+ if (IS_ERR(policy->clk))
+ return PTR_ERR(policy->clk);

if (!freq_table) {
result = opp_init_cpufreq_table(mpu_dev, &freq_table);
@@ -149,7 +137,7 @@ static int omap_cpu_init(struct cpufreq_policy *policy)

freq_table_free();
fail:
- clk_put(mpu_clk);
+ clk_put(policy->clk);
return result;
}

@@ -157,7 +145,7 @@ static int omap_cpu_exit(struct cpufreq_policy *policy)
{
cpufreq_frequency_table_put_attr(policy->cpu);
freq_table_free();
- clk_put(mpu_clk);
+ clk_put(policy->clk);
return 0;
}

@@ -165,7 +153,7 @@ static struct cpufreq_driver omap_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = omap_target,
- .get = omap_getspeed,
+ .get = cpufreq_generic_get,
.init = omap_cpu_init,
.exit = omap_cpu_exit,
.name = "omap",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:29:39

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 223/228] cpufreq: ppc: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

We don't need a variable to hold clock anymore in struct cpu_data.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ppc-corenet-cpufreq.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index 3f7be46..051000f 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -24,12 +24,10 @@

/**
* struct cpu_data - per CPU data struct
- * @clk: the clk of CPU
* @parent: the parent node of cpu clock
* @table: frequency table
*/
struct cpu_data {
- struct clk *clk;
struct device_node *parent;
struct cpufreq_frequency_table *table;
};
@@ -81,13 +79,6 @@ static inline const struct cpumask *cpu_core_mask(int cpu)
}
#endif

-static unsigned int corenet_cpufreq_get_speed(unsigned int cpu)
-{
- struct cpu_data *data = per_cpu(cpu_data, cpu);
-
- return clk_get_rate(data->clk) / 1000;
-}
-
/* reduce the duplicated frequencies in frequency table */
static void freq_table_redup(struct cpufreq_frequency_table *freq_table,
int count)
@@ -158,8 +149,8 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
goto err_np;
}

- data->clk = of_clk_get(np, 0);
- if (IS_ERR(data->clk)) {
+ policy->clk = of_clk_get(np, 0);
+ if (IS_ERR(policy->clk)) {
pr_err("%s: no clock information\n", __func__);
goto err_nomem2;
}
@@ -255,7 +246,7 @@ static int corenet_cpufreq_target(struct cpufreq_policy *policy,
struct cpu_data *data = per_cpu(cpu_data, policy->cpu);

parent = of_clk_get(data->parent, data->table[index].driver_data);
- return clk_set_parent(data->clk, parent);
+ return clk_set_parent(policy->clk, parent);
}

static struct cpufreq_driver ppc_corenet_cpufreq_driver = {
@@ -265,7 +256,7 @@ static struct cpufreq_driver ppc_corenet_cpufreq_driver = {
.exit = __exit_p(corenet_cpufreq_cpu_exit),
.verify = cpufreq_generic_frequency_table_verify,
.target_index = corenet_cpufreq_target,
- .get = corenet_cpufreq_get_speed,
+ .get = cpufreq_generic_get,
.attr = cpufreq_generic_attr,
};

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:29:45

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 224/228] cpufreq: s3c: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

We don't need a global variable to hold clock anymore.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s3c24xx-cpufreq.c | 10 +++-------
drivers/cpufreq/s3c64xx-cpufreq.c | 33 ++++++++++++---------------------
2 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index 4850882..7be6c2d 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -355,11 +355,6 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy,
return -EINVAL;
}

-static unsigned int s3c_cpufreq_get(unsigned int cpu)
-{
- return clk_get_rate(clk_arm) / 1000;
-}
-
struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name)
{
struct clk *clk;
@@ -373,6 +368,7 @@ struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name)

static int s3c_cpufreq_init(struct cpufreq_policy *policy)
{
+ policy->clk = clk_arm;
return cpufreq_generic_init(policy, ftab, cpu_cur.info->latency);
}

@@ -408,7 +404,7 @@ static int s3c_cpufreq_suspend(struct cpufreq_policy *policy)
{
suspend_pll.frequency = clk_get_rate(_clk_mpll);
suspend_pll.driver_data = __raw_readl(S3C2410_MPLLCON);
- suspend_freq = s3c_cpufreq_get(0) * 1000;
+ suspend_freq = clk_get_rate(clk_arm);

return 0;
}
@@ -450,7 +446,7 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy)
static struct cpufreq_driver s3c24xx_driver = {
.flags = CPUFREQ_STICKY,
.target = s3c_cpufreq_target,
- .get = s3c_cpufreq_get,
+ .get = cpufreq_generic_get,
.init = s3c_cpufreq_init,
.suspend = s3c_cpufreq_suspend,
.resume = s3c_cpufreq_resume,
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 8b49a06..5b0089a 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -19,7 +19,6 @@
#include <linux/regulator/consumer.h>
#include <linux/module.h>

-static struct clk *armclk;
static struct regulator *vddarm;
static unsigned long regulator_latency;

@@ -54,14 +53,6 @@ static struct cpufreq_frequency_table s3c64xx_freq_table[] = {
};
#endif

-static unsigned int s3c64xx_cpufreq_get_speed(unsigned int cpu)
-{
- if (cpu != 0)
- return 0;
-
- return clk_get_rate(armclk) / 1000;
-}
-
static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
unsigned int index)
{
@@ -69,7 +60,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
unsigned int old_freq, new_freq;
int ret;

- old_freq = clk_get_rate(armclk) / 1000;
+ old_freq = clk_get_rate(policy->clk) / 1000;
new_freq = s3c64xx_freq_table[index].frequency;
dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[index].driver_data];

@@ -86,7 +77,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
}
#endif

- ret = clk_set_rate(armclk, new_freq * 1000);
+ ret = clk_set_rate(policy->clk, new_freq * 1000);
if (ret < 0) {
pr_err("Failed to set rate %dkHz: %d\n",
new_freq, ret);
@@ -101,7 +92,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
if (ret != 0) {
pr_err("Failed to set VDDARM for %dkHz: %d\n",
new_freq, ret);
- if (clk_set_rate(armclk, old_freq * 1000) < 0)
+ if (clk_set_rate(policy->clk, old_freq * 1000) < 0)
pr_err("Failed to restore original clock rate\n");

return ret;
@@ -110,7 +101,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
#endif

pr_debug("Set actual frequency %lukHz\n",
- clk_get_rate(armclk) / 1000);
+ clk_get_rate(policy->clk) / 1000);

return 0;
}
@@ -169,11 +160,11 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
return -ENODEV;
}

- armclk = clk_get(NULL, "armclk");
- if (IS_ERR(armclk)) {
+ policy->clk = clk_get(NULL, "armclk");
+ if (IS_ERR(policy->clk)) {
pr_err("Unable to obtain ARMCLK: %ld\n",
- PTR_ERR(armclk));
- return PTR_ERR(armclk);
+ PTR_ERR(policy->clk));
+ return PTR_ERR(policy->clk);
}

#ifdef CONFIG_REGULATOR
@@ -193,7 +184,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
unsigned long r;

/* Check for frequencies we can generate */
- r = clk_round_rate(armclk, freq->frequency * 1000);
+ r = clk_round_rate(policy->clk, freq->frequency * 1000);
r /= 1000;
if (r != freq->frequency) {
pr_debug("%dkHz unsupported by clock\n",
@@ -203,7 +194,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)

/* If we have no regulator then assume startup
* frequency is the maximum we can support. */
- if (!vddarm && freq->frequency > s3c64xx_cpufreq_get_speed(0))
+ if (!vddarm && freq->frequency > clk_get_rate(policy->clk) / 1000)
freq->frequency = CPUFREQ_ENTRY_INVALID;

freq++;
@@ -219,7 +210,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
pr_err("Failed to configure frequency table: %d\n",
ret);
regulator_put(vddarm);
- clk_put(armclk);
+ clk_put(policy->clk);
}

return ret;
@@ -229,7 +220,7 @@ static struct cpufreq_driver s3c64xx_cpufreq_driver = {
.flags = 0,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = s3c64xx_cpufreq_set_target,
- .get = s3c64xx_cpufreq_get_speed,
+ .get = cpufreq_generic_get,
.init = s3c64xx_cpufreq_driver_init,
.name = "s3c",
};
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:29:52

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 225/228] cpufreq: s5pv210: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

We don't need a global variable to hold clock anymore.

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s5pv210-cpufreq.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index e3973da..da0e291 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -23,7 +23,6 @@
#include <mach/map.h>
#include <mach/regs-clock.h>

-static struct clk *cpu_clk;
static struct clk *dmc0_clk;
static struct clk *dmc1_clk;
static DEFINE_MUTEX(set_freq_lock);
@@ -164,14 +163,6 @@ static void s5pv210_set_refresh(enum s5pv210_dmc_port ch, unsigned long freq)
__raw_writel(tmp1, reg);
}

-static unsigned int s5pv210_getspeed(unsigned int cpu)
-{
- if (cpu)
- return 0;
-
- return clk_get_rate(cpu_clk) / 1000;
-}
-
static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned long reg;
@@ -193,7 +184,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)
goto exit;
}

- old_freq = s5pv210_getspeed(0);
+ old_freq = policy->cur;
new_freq = s5pv210_freq_table[index].frequency;

/* Finding current running level index */
@@ -471,9 +462,9 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
unsigned long mem_type;
int ret;

- cpu_clk = clk_get(NULL, "armclk");
- if (IS_ERR(cpu_clk))
- return PTR_ERR(cpu_clk);
+ policy->clk = clk_get(NULL, "armclk");
+ if (IS_ERR(policy->clk))
+ return PTR_ERR(policy->clk);

dmc0_clk = clk_get(NULL, "sclk_dmc0");
if (IS_ERR(dmc0_clk)) {
@@ -516,7 +507,7 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
out_dmc1:
clk_put(dmc0_clk);
out_dmc0:
- clk_put(cpu_clk);
+ clk_put(policy->clk);
return ret;
}

@@ -563,7 +554,7 @@ static struct cpufreq_driver s5pv210_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = s5pv210_target,
- .get = s5pv210_getspeed,
+ .get = cpufreq_generic_get,
.init = s5pv210_cpu_init,
.name = "s5pv210",
#ifdef CONFIG_PM
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:30:04

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 226/228] cpufreq: spear: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/spear-cpufreq.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 658cfe7..ea2f26e 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -30,11 +30,6 @@ static struct {
u32 cnt;
} spear_cpufreq;

-static unsigned int spear_cpufreq_get(unsigned int cpu)
-{
- return clk_get_rate(spear_cpufreq.clk) / 1000;
-}
-
static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq)
{
struct clk *sys_pclk;
@@ -156,6 +151,7 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,

static int spear_cpufreq_init(struct cpufreq_policy *policy)
{
+ policy->clk = spear_cpufreq.clk;
return cpufreq_generic_init(policy, spear_cpufreq.freq_tbl,
spear_cpufreq.transition_latency);
}
@@ -165,7 +161,7 @@ static struct cpufreq_driver spear_cpufreq_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = spear_cpufreq_target,
- .get = spear_cpufreq_get,
+ .get = cpufreq_generic_get,
.init = spear_cpufreq_init,
.exit = cpufreq_generic_exit,
.attr = cpufreq_generic_attr,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:30:20

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 227/228] cpufreq: tegra: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

Cc: Stephen Warren <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/tegra-cpufreq.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index 7d36b54..360d1a7 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -50,17 +50,6 @@ static struct clk *emc_clk;
static DEFINE_MUTEX(tegra_cpu_lock);
static bool is_suspended;

-static unsigned int tegra_getspeed(unsigned int cpu)
-{
- unsigned long rate;
-
- if (cpu >= NUM_CPUS)
- return 0;
-
- rate = clk_get_rate(cpu_clk) / 1000;
- return rate;
-}
-
static int tegra_cpu_clk_set_rate(unsigned long rate)
{
int ret;
@@ -144,7 +133,7 @@ static int tegra_pm_notify(struct notifier_block *nb, unsigned long event,
is_suspended = true;
pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n",
freq_table[0].frequency);
- if (tegra_getspeed(0) != freq_table[0].frequency)
+ if (clk_get_rate(cpu_clk) / 1000 != freq_table[0].frequency)
tegra_update_cpu_speed(policy, freq_table[0].frequency);
cpufreq_cpu_put(policy);
} else if (event == PM_POST_SUSPEND) {
@@ -180,6 +169,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
if (policy->cpu == 0)
register_pm_notifier(&tegra_cpu_pm_notifier);

+ policy->clk = cpu_clk;
return 0;
}

@@ -194,7 +184,7 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy)
static struct cpufreq_driver tegra_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
.target_index = tegra_target,
- .get = tegra_getspeed,
+ .get = cpufreq_generic_get,
.init = tegra_cpu_init,
.exit = tegra_cpu_exit,
.name = "tegra",
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:30:16

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 228/228] cpufreq: unicore2: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

We also do clk_get() once instead of doing it again and again in target & init.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/unicore2-cpufreq.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c
index 653ae29..951152f 100644
--- a/drivers/cpufreq/unicore2-cpufreq.c
+++ b/drivers/cpufreq/unicore2-cpufreq.c
@@ -11,6 +11,7 @@
* published by the Free Software Foundation.
*/

+#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/init.h>
@@ -33,26 +34,16 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy)
return 0;
}

-static unsigned int ucv2_getspeed(unsigned int cpu)
-{
- struct clk *mclk = clk_get(NULL, "MAIN_CLK");
-
- if (cpu)
- return 0;
- return clk_get_rate(mclk)/1000;
-}
-
static int ucv2_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation)
{
- unsigned int cur = ucv2_getspeed(0);
+ unsigned int cur = policy->cur;
struct cpufreq_freqs freqs;
- struct clk *mclk = clk_get(NULL, "MAIN_CLK");

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

- if (!clk_set_rate(mclk, target_freq * 1000)) {
+ if (!clk_set_rate(policy->clk, target_freq * 1000)) {
freqs.old = cur;
freqs.new = target_freq;
}
@@ -66,9 +57,13 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
{
if (policy->cpu != 0)
return -EINVAL;
+
policy->min = policy->cpuinfo.min_freq = 250000;
policy->max = policy->cpuinfo.max_freq = 1000000;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
+ policy->clk = clk_get(NULL, "MAIN_CLK");
+ if (IS_ERR(policy->clk))
+ return PTR_ERR(policy->clk);
return 0;
}

@@ -76,7 +71,7 @@ static struct cpufreq_driver ucv2_driver = {
.flags = CPUFREQ_STICKY,
.verify = ucv2_verify_speed,
.target = ucv2_target,
- .get = ucv2_getspeed,
+ .get = cpufreq_generic_get,
.init = ucv2_cpu_init,
.name = "UniCore-II",
};
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:30:56

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 063/228] cpufreq: dbx500: Use generic cpufreq routines

On 13 September 2013 18:48, Linus Walleij <[email protected]> wrote:
> On Fri, Sep 13, 2013 at 3:00 PM, Viresh Kumar <[email protected]> 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: Linus Walleij <[email protected]>
>> Signed-off-by: Viresh Kumar <[email protected]>
>
> Acked-by. It feels like I acked this before...

Nah, I checked it again :)

Btw, for a second I had my heart in my mouth..
I thought its Torvalds and he will blast me off :)

Thank god, its you :)

2013-09-13 13:32:18

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 219/228] cpufreq: exynos: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

Cc: Amit Daniel Kachhap <[email protected]>
Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/exynos-cpufreq.c | 10 +++-------
drivers/cpufreq/exynos5440-cpufreq.c | 33 ++++++++++++++-------------------
2 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index c9ae7e6..0ef13e8 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -30,11 +30,6 @@ static unsigned int locking_frequency;
static bool frequency_locked;
static DEFINE_MUTEX(cpufreq_lock);

-static unsigned int exynos_getspeed(unsigned int cpu)
-{
- return clk_get_rate(exynos_info->cpu_clk) / 1000;
-}
-
static int exynos_cpufreq_get_index(unsigned int freq)
{
struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
@@ -214,6 +209,7 @@ static struct notifier_block exynos_cpufreq_nb = {

static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
+ policy->clk = exynos_info->cpu_clk;
return cpufreq_generic_init(policy, exynos_info->freq_table, 100000);
}

@@ -221,7 +217,7 @@ static struct cpufreq_driver exynos_driver = {
.flags = CPUFREQ_STICKY,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = exynos_target,
- .get = exynos_getspeed,
+ .get = cpufreq_generic_get,
.init = exynos_cpufreq_cpu_init,
.exit = cpufreq_generic_exit,
.name = "exynos_cpufreq",
@@ -263,7 +259,7 @@ static int __init exynos_cpufreq_init(void)
goto err_vdd_arm;
}

- locking_frequency = exynos_getspeed(0);
+ locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;

register_pm_notifier(&exynos_cpufreq_nb);

diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index 340b53e..4b2703d 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -100,7 +100,6 @@ struct exynos_dvfs_data {
struct resource *mem;
int irq;
struct clk *cpu_clk;
- unsigned int cur_frequency;
unsigned int latency;
struct cpufreq_frequency_table *freq_table;
unsigned int freq_count;
@@ -165,7 +164,7 @@ static int init_div_table(void)
return 0;
}

-static void exynos_enable_dvfs(void)
+static void exynos_enable_dvfs(unsigned int cur_frequency)
{
unsigned int tmp, i, cpu;
struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table;
@@ -184,18 +183,18 @@ static void exynos_enable_dvfs(void)

/* Set initial performance index */
for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
- if (freq_table[i].frequency == dvfs_info->cur_frequency)
+ if (freq_table[i].frequency == cur_frequency)
break;

if (freq_table[i].frequency == CPUFREQ_TABLE_END) {
dev_crit(dvfs_info->dev, "Boot up frequency not supported\n");
/* Assign the highest frequency */
i = 0;
- dvfs_info->cur_frequency = freq_table[i].frequency;
+ cur_frequency = freq_table[i].frequency;
}

dev_info(dvfs_info->dev, "Setting dvfs initial frequency = %uKHZ",
- dvfs_info->cur_frequency);
+ cur_frequency);

for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) {
tmp = __raw_readl(dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4);
@@ -209,11 +208,6 @@ static void exynos_enable_dvfs(void)
dvfs_info->base + XMU_DVFS_CTRL);
}

-static unsigned int exynos_getspeed(unsigned int cpu)
-{
- return dvfs_info->cur_frequency;
-}
-
static int exynos_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned int tmp;
@@ -222,7 +216,7 @@ static int exynos_target(struct cpufreq_policy *policy, unsigned int index)

mutex_lock(&cpufreq_lock);

- freqs.old = dvfs_info->cur_frequency;
+ freqs.old = policy->cur;
freqs.new = freq_table[index].frequency;

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
@@ -253,7 +247,7 @@ static void exynos_cpufreq_work(struct work_struct *work)
goto skip_work;

mutex_lock(&cpufreq_lock);
- freqs.old = dvfs_info->cur_frequency;
+ freqs.old = policy->cur;

cur_pstate = __raw_readl(dvfs_info->base + XMU_P_STATUS);
if (cur_pstate >> C0_3_PSTATE_VALID_SHIFT & 0x1)
@@ -263,10 +257,9 @@ static void exynos_cpufreq_work(struct work_struct *work)

if (likely(index < dvfs_info->freq_count)) {
freqs.new = freq_table[index].frequency;
- dvfs_info->cur_frequency = freqs.new;
} else {
dev_crit(dvfs_info->dev, "New frequency out of range\n");
- freqs.new = dvfs_info->cur_frequency;
+ freqs.new = freqs.old;
}
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

@@ -310,6 +303,7 @@ static void exynos_sort_descend_freq_table(void)

static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
+ policy->clk = dvfs_info->cpu_clk;
return cpufreq_generic_init(policy, dvfs_info->freq_table,
dvfs_info->latency);
}
@@ -318,7 +312,7 @@ static struct cpufreq_driver exynos_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_ASYNC_NOTIFICATION,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = exynos_target,
- .get = exynos_getspeed,
+ .get = cpufreq_generic_get,
.init = exynos_cpufreq_cpu_init,
.exit = cpufreq_generic_exit,
.name = CPUFREQ_NAME,
@@ -337,6 +331,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
int ret = -EINVAL;
struct device_node *np;
struct resource res;
+ unsigned int cur_frequency;

np = pdev->dev.of_node;
if (!np)
@@ -392,13 +387,13 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
goto err_free_table;
}

- dvfs_info->cur_frequency = clk_get_rate(dvfs_info->cpu_clk);
- if (!dvfs_info->cur_frequency) {
+ cur_frequency = clk_get_rate(dvfs_info->cpu_clk);
+ if (!cur_frequency) {
dev_err(dvfs_info->dev, "Failed to get clock rate\n");
ret = -EINVAL;
goto err_free_table;
}
- dvfs_info->cur_frequency /= 1000;
+ cur_frequency /= 1000;

INIT_WORK(&dvfs_info->irq_work, exynos_cpufreq_work);
ret = devm_request_irq(dvfs_info->dev, dvfs_info->irq,
@@ -415,7 +410,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
goto err_free_table;
}

- exynos_enable_dvfs();
+ exynos_enable_dvfs(cur_frequency);
ret = cpufreq_register_driver(&exynos_driver);
if (ret) {
dev_err(dvfs_info->dev,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:29:04

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 218/228] cpufreq: dbx500: use cpufreq_generic_get() routine

We have common infrastructure available with us for getting a CPUs clk rate.
Lets use it for this driver.

We don't have to find closest frequency in platform specific ->get() routine
wihch dbx500 driver was doing and hence it can be removed as well.

Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/dbx500-cpufreq.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index 0e67ab9..d83129d 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -26,24 +26,9 @@ static int dbx500_cpufreq_target(struct cpufreq_policy *policy,
return clk_set_rate(armss_clk, freq_table[index].frequency * 1000);
}

-static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu)
-{
- int i = 0;
- unsigned long freq = clk_get_rate(armss_clk) / 1000;
-
- /* The value is rounded to closest frequency in the defined table. */
- while (freq_table[i + 1].frequency != CPUFREQ_TABLE_END) {
- if (freq < freq_table[i].frequency +
- (freq_table[i + 1].frequency - freq_table[i].frequency) / 2)
- return freq_table[i].frequency;
- i++;
- }
-
- return freq_table[i].frequency;
-}
-
static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
{
+ policy->clk = armss_clk;
return cpufreq_generic_init(policy, freq_table, 20 * 1000);
}

@@ -51,7 +36,7 @@ static struct cpufreq_driver dbx500_cpufreq_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = dbx500_cpufreq_target,
- .get = dbx500_cpufreq_getspeed,
+ .get = cpufreq_generic_get,
.init = dbx500_cpufreq_init,
.name = "DBX500",
.attr = cpufreq_generic_attr,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:34:03

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 210/228] cpufreq: speedstep: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: David S. Miller <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/speedstep-centrino.c | 20 +-------------------
drivers/cpufreq/speedstep-ich.c | 9 ---------
drivers/cpufreq/speedstep-smi.c | 7 -------
3 files changed, 1 insertion(+), 35 deletions(-)

diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
index b7a2f8d..90b4581 100644
--- a/drivers/cpufreq/speedstep-centrino.c
+++ b/drivers/cpufreq/speedstep-centrino.c
@@ -424,9 +424,8 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
static int centrino_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned int msr, oldmsr = 0, h = 0, cpu = policy->cpu;
- struct cpufreq_freqs freqs;
int retval = 0;
- unsigned int j, first_cpu, tmp;
+ unsigned int j, first_cpu;
struct cpufreq_frequency_table *op_points;
cpumask_var_t covered_cpus;

@@ -474,15 +473,6 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index)
goto out;
}

- freqs.old = extract_clock(oldmsr, cpu, 0);
- freqs.new = extract_clock(msr, cpu, 0);
-
- pr_debug("target=%dkHz old=%d new=%d msr=%04x\n",
- op_points->frequency, freqs.old, freqs.new, msr);
-
- cpufreq_notify_transition(policy, &freqs,
- CPUFREQ_PRECHANGE);
-
first_cpu = 0;
/* all but 16 LSB are reserved, treat them with care */
oldmsr &= ~0xffff;
@@ -497,8 +487,6 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index)
cpumask_set_cpu(j, covered_cpus);
}

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
if (unlikely(retval)) {
/*
* We have failed halfway through the frequency change.
@@ -509,12 +497,6 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index)

for_each_cpu(j, covered_cpus)
wrmsr_on_cpu(j, MSR_IA32_PERF_CTL, oldmsr, h);
-
- tmp = freqs.new;
- freqs.new = freqs.old;
- freqs.old = tmp;
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
}
retval = 0;

diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c
index 707721e..7639b2b 100644
--- a/drivers/cpufreq/speedstep-ich.c
+++ b/drivers/cpufreq/speedstep-ich.c
@@ -258,21 +258,12 @@ static unsigned int speedstep_get(unsigned int cpu)
static int speedstep_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned int policy_cpu;
- struct cpufreq_freqs freqs;

policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask);
- freqs.old = speedstep_get(policy_cpu);
- freqs.new = speedstep_freqs[index].frequency;
-
- pr_debug("transiting from %u to %u kHz\n", freqs.old, freqs.new);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

smp_call_function_single(policy_cpu, _speedstep_set_state, &index,
true);

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return 0;
}

diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
index 19446e4..0f5326d 100644
--- a/drivers/cpufreq/speedstep-smi.c
+++ b/drivers/cpufreq/speedstep-smi.c
@@ -241,14 +241,7 @@ static void speedstep_set_state(unsigned int state)
*/
static int speedstep_target(struct cpufreq_policy *policy, unsigned int index)
{
- struct cpufreq_freqs freqs;
-
- freqs.old = speedstep_freqs[speedstep_get_state()].frequency;
- freqs.new = speedstep_freqs[index].frequency;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
speedstep_set_state(index);
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

return 0;
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:34:33

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 209/228] cpufreq: SPEAr: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/spear-cpufreq.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 0326040..658cfe7 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -107,12 +107,10 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq)
static int spear_cpufreq_target(struct cpufreq_policy *policy,
unsigned int index)
{
- struct cpufreq_freqs freqs;
unsigned long newfreq;
struct clk *srcclk;
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")) {
@@ -145,23 +143,14 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,
return newfreq;
}

- freqs.new = newfreq / 1000;
- freqs.new /= mult;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
if (mult == 2)
ret = spear1340_set_cpu_rate(srcclk, newfreq);
else
ret = clk_set_rate(spear_cpufreq.clk, newfreq);

- /* Get current rate after clk_set_rate, in case of failure */
- if (ret) {
+ if (ret)
pr_err("CPU Freq: cpu clk_set_rate failed: %d\n", ret);
- freqs.new = clk_get_rate(spear_cpufreq.clk) / 1000;
- }

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
return ret;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:35:59

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 200/228] cpufreq: pasemi: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pasemi-cpufreq.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 17424dd..1c33136 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -51,8 +51,6 @@
static void __iomem *sdcpwr_mapbase;
static void __iomem *sdcasr_mapbase;

-static DEFINE_MUTEX(pas_switch_mutex);
-
/* Current astate, is used when waking up from power savings on
* one core, in case the other core has switched states during
* the idle time.
@@ -242,15 +240,8 @@ static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy)
static int pas_cpufreq_target(struct cpufreq_policy *policy,
unsigned int pas_astate_new)
{
- struct cpufreq_freqs freqs;
int i;

- freqs.old = policy->cur;
- freqs.new = pas_freqs[pas_astate_new].frequency;
-
- mutex_lock(&pas_switch_mutex);
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n",
policy->cpu,
pas_freqs[pas_astate_new].frequency,
@@ -261,10 +252,7 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy,
for_each_online_cpu(i)
set_astate(i, pas_astate_new);

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
- mutex_unlock(&pas_switch_mutex);
-
- ppc_proc_freq = freqs.new * 1000ul;
+ ppc_proc_freq = pas_freqs[pas_astate_new].frequency * 1000ul;
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:36:28

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 197/228] cpufreq: maple: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Dmitry Eremin-Solenikov <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/maple-cpufreq.c | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index 4e2da08..c4dfa42 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -69,8 +69,6 @@ static struct cpufreq_frequency_table maple_cpu_freqs[] = {
*/
static int maple_pmode_cur;

-static DEFINE_MUTEX(maple_switch_mutex);
-
static const u32 *maple_pmode_data;
static int maple_pmode_max;

@@ -133,21 +131,7 @@ static int maple_scom_query_freq(void)
static int maple_cpufreq_target(struct cpufreq_policy *policy,
unsigned int index)
{
- struct cpufreq_freqs freqs;
- int rc;
-
- mutex_lock(&maple_switch_mutex);
-
- freqs.old = maple_cpu_freqs[maple_pmode_cur].frequency;
- freqs.new = maple_cpu_freqs[index].frequency;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
- rc = maple_scom_switch_freq(index);
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- mutex_unlock(&maple_switch_mutex);
-
- return rc;
+ return maple_scom_switch_freq(index);
}

static unsigned int maple_cpufreq_get_speed(unsigned int cpu)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:38:33

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 187/228] cpufreq: cris: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Jesper Nilsson <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cris-artpec3-cpufreq.c | 8 --------
drivers/cpufreq/cris-etraxfs-cpufreq.c | 8 --------
2 files changed, 16 deletions(-)

diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index 841857c..8655904 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -29,15 +29,9 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)

static int cris_freq_target(struct cpufreq_policy *policy, unsigned int state)
{
- struct cpufreq_freqs freqs;
reg_clkgen_rw_clk_ctrl clk_ctrl;
clk_ctrl = REG_RD(clkgen, regi_clkgen, rw_clk_ctrl);

- freqs.old = cris_freq_get_cpu_frequency(policy->cpu);
- freqs.new = cris_freq_table[state].frequency;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
local_irq_disable();

/* Even though we may be SMP they will share the same clock
@@ -50,8 +44,6 @@ static int cris_freq_target(struct cpufreq_policy *policy, unsigned int state)

local_irq_enable();

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return 0;
}

diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index c58811a..26d940d 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -29,15 +29,9 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)

static int cris_freq_target(struct cpufreq_policy *policy, unsigned int state)
{
- struct cpufreq_freqs freqs;
reg_config_rw_clk_ctrl clk_ctrl;
clk_ctrl = REG_RD(config, regi_config, rw_clk_ctrl);

- freqs.old = cris_freq_get_cpu_frequency(policy->cpu);
- freqs.new = cris_freq_table[state].frequency;
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
local_irq_disable();

/* Even though we may be SMP they will share the same clock
@@ -50,8 +44,6 @@ static int cris_freq_target(struct cpufreq_policy *policy, unsigned int state)

local_irq_enable();

- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:38:51

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 185/228] cpufreq: blackfin: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Cc: Steven Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/blackfin-cpufreq.c | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index 12528b2..e9e63fc 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -132,27 +132,23 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index)
#ifndef CONFIG_BF60x
unsigned int plldiv;
#endif
- struct cpufreq_freqs freqs;
static unsigned long lpj_ref;
static unsigned int lpj_ref_freq;
+ unsigned int old_freq, new_freq;
int ret = 0;

#if defined(CONFIG_CYCLES_CLOCKSOURCE)
cycles_t cycles;
#endif

- freqs.old = bfin_getfreq_khz(0);
- freqs.new = bfin_freq_table[index].frequency;
+ old_freq = bfin_getfreq_khz(0);
+ new_freq = bfin_freq_table[index].frequency;

- pr_debug("cpufreq: changing cclk to %lu; target = %u, oldfreq = %u\n",
- freqs.new, freqs.new, freqs.old);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
#ifndef CONFIG_BF60x
plldiv = (bfin_read_PLL_DIV() & SSEL) | dpm_state_table[index].csel;
bfin_write_PLL_DIV(plldiv);
#else
- ret = cpu_set_cclk(policy->cpu, freqs.new * 1000);
+ ret = cpu_set_cclk(policy->cpu, new_freq * 1000);
if (ret != 0) {
WARN_ONCE(ret, "cpufreq set freq failed %d\n", ret);
return ret;
@@ -168,17 +164,13 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index)
#endif
if (!lpj_ref_freq) {
lpj_ref = loops_per_jiffy;
- lpj_ref_freq = freqs.old;
+ lpj_ref_freq = old_freq;
}
- if (freqs.new != freqs.old) {
+ if (new_freq != old_freq) {
loops_per_jiffy = cpufreq_scale(lpj_ref,
- lpj_ref_freq, freqs.new);
+ lpj_ref_freq, new_freq);
}

- /* TODO: just test case for cycles clock source, remove later */
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- pr_debug("cpufreq: done\n");
return ret;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:39:34

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 183/228] cpufreq: arm_big_little: remove calls to cpufreq_notify_transition()

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

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

cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);

/* Change rate here */

cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

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

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

Some related minor cleanups are also done along with it.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/arm_big_little.c | 25 +++----------------------
1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index c3936ef..69cae42 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -51,30 +51,11 @@ static unsigned int bL_cpufreq_get(unsigned int cpu)
static int bL_cpufreq_set_target(struct cpufreq_policy *policy,
unsigned int index)
{
- struct cpufreq_freqs freqs;
- u32 cpu = policy->cpu, cur_cluster;
- int ret = 0;
+ u32 cur_cluster;

cur_cluster = cpu_to_cluster(policy->cpu);
-
- freqs.old = bL_cpufreq_get(policy->cpu);
- 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, freqs.new,
- freqs.new);
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
- ret = clk_set_rate(clk[cur_cluster], freqs.new * 1000);
- if (ret) {
- pr_err("clk_set_rate failed: %d\n", ret);
- freqs.new = freqs.old;
- }
-
- cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
- return ret;
+ return clk_set_rate(clk[cur_cluster],
+ freq_table[cur_cluster][index].frequency * 1000);
}

static void put_cluster_clk_and_freq_table(struct device *cpu_dev)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:24:26

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 179/228] cpufreq: speedstep: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: David S. Miller <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/speedstep-centrino.c | 26 +++++++-------------------
drivers/cpufreq/speedstep-ich.c | 24 ++++++------------------
drivers/cpufreq/speedstep-smi.c | 20 +++++---------------
3 files changed, 18 insertions(+), 52 deletions(-)

diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
index 6b882c7..b7a2f8d 100644
--- a/drivers/cpufreq/speedstep-centrino.c
+++ b/drivers/cpufreq/speedstep-centrino.c
@@ -417,21 +417,17 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
/**
* centrino_setpolicy - set a new CPUFreq policy
* @policy: new policy
- * @target_freq: the target frequency
- * @relation: how that frequency relates to achieved frequency
- * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
+ * @index: index of target frequency
*
* Sets a new CPUFreq policy.
*/
-static int centrino_target (struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int centrino_target(struct cpufreq_policy *policy, unsigned int index)
{
- 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)))
@@ -442,16 +438,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;

@@ -475,7 +463,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);
@@ -490,7 +478,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);
@@ -541,7 +529,7 @@ static struct cpufreq_driver centrino_driver = {
.init = centrino_cpu_init,
.exit = centrino_cpu_exit,
.verify = cpufreq_generic_frequency_table_verify,
- .target = centrino_target,
+ .target_index = centrino_target,
.get = get_cur_freq,
.attr = cpufreq_generic_attr,
};
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c
index 1a8b01b..707721e 100644
--- a/drivers/cpufreq/speedstep-ich.c
+++ b/drivers/cpufreq/speedstep-ich.c
@@ -251,36 +251,24 @@ static unsigned int speedstep_get(unsigned int cpu)
/**
* speedstep_target - set a new CPUFreq policy
* @policy: new policy
- * @target_freq: the target frequency
- * @relation: how that frequency relates to achieved frequency
- * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
+ * @index: index of target frequency
*
* Sets a new CPUFreq policy.
*/
-static int speedstep_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int speedstep_target(struct cpufreq_policy *policy, unsigned int index)
{
- 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);
@@ -330,7 +318,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
static struct cpufreq_driver speedstep_driver = {
.name = "speedstep-ich",
.verify = cpufreq_generic_frequency_table_verify,
- .target = speedstep_target,
+ .target_index = speedstep_target,
.init = speedstep_cpu_init,
.exit = cpufreq_generic_exit,
.get = speedstep_get,
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
index a02b649..19446e4 100644
--- a/drivers/cpufreq/speedstep-smi.c
+++ b/drivers/cpufreq/speedstep-smi.c
@@ -235,29 +235,19 @@ static void speedstep_set_state(unsigned int state)
/**
* speedstep_target - set a new CPUFreq policy
* @policy: new policy
- * @target_freq: new freq
- * @relation:
+ * @index: index of new freq
*
* Sets a new CPUFreq policy/freq.
*/
-static int speedstep_target(struct cpufreq_policy *policy,
- unsigned int target_freq, unsigned int relation)
+static int speedstep_target(struct cpufreq_policy *policy, unsigned int index)
{
- 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;
@@ -327,7 +317,7 @@ static int speedstep_resume(struct cpufreq_policy *policy)
static struct cpufreq_driver speedstep_driver = {
.name = "speedstep-smi",
.verify = cpufreq_generic_frequency_table_verify,
- .target = speedstep_target,
+ .target_index = speedstep_target,
.init = speedstep_cpu_init,
.exit = cpufreq_generic_exit,
.get = speedstep_get,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:41:40

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 171/228] cpufreq: pxa: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Cc: Eric Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pxa2xx-cpufreq.c | 13 ++-----------
drivers/cpufreq/pxa3xx-cpufreq.c | 17 +++--------------
2 files changed, 5 insertions(+), 25 deletions(-)

diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index 29aca57..183bc13 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -267,14 +267,11 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)
return get_clk_frequency_khz(0);
}

-static int pxa_set_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)
{
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 +280,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;
@@ -448,7 +439,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)

static struct cpufreq_driver pxa_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = pxa_set_target,
+ .target_index = pxa_set_target,
.init = pxa_cpufreq_init,
.exit = cpufreq_generic_exit,
.get = pxa_cpufreq_get,
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 47fbee4..132e37d 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -155,24 +155,16 @@ static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)
return pxa3xx_get_clk_frequency_khz(0);
}

-static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index)
{
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 +173,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);
@@ -225,7 +214,7 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)

static struct cpufreq_driver pxa3xx_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
- .target = pxa3xx_cpufreq_set,
+ .target_index = pxa3xx_cpufreq_set,
.init = pxa3xx_cpufreq_init,
.exit = cpufreq_generic_exit,
.get = pxa3xx_cpufreq_get,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:44:51

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 150/228] cpufreq: at32ap: Convert to light weight ->target_index() routine

This patch converts existing .target() to newly defined light weight
.target_index() routine for this driver.

CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and will pass index to it.

Acked-by: Hans-Christian Egtvedt <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/at32ap-cpufreq.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
index 7439ded..81d0752 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -35,25 +35,12 @@ static unsigned int at32_get_speed(unsigned int cpu)
static unsigned int ref_freq;
static unsigned long loops_per_jiffy_ref;

-static int at32_set_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation)
+static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)
{
struct cpufreq_freqs freqs;
- long freq;
-
- /* Convert target_freq from kHz to Hz */
- freq = clk_round_rate(cpuclk, target_freq * 1000);
-
- /* Check if policy->min <= new_freq <= policy->max */
- if(freq < (policy->min * 1000) || freq > (policy->max * 1000))
- return -EINVAL;
-
- pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000);

freqs.old = at32_get_speed(0);
- freqs.new = (freq + 500) / 1000;
- freqs.flags = 0;
+ freqs.new = freq_table[index].frequency;

if (!ref_freq) {
ref_freq = freqs.old;
@@ -64,13 +51,13 @@ static int at32_set_target(struct cpufreq_policy *policy,
if (freqs.old < freqs.new)
boot_cpu_data.loops_per_jiffy = cpufreq_scale(
loops_per_jiffy_ref, ref_freq, freqs.new);
- clk_set_rate(cpuclk, freq);
+ clk_set_rate(cpuclk, freqs.new * 1000);
if (freqs.new < freqs.old)
boot_cpu_data.loops_per_jiffy = cpufreq_scale(
loops_per_jiffy_ref, ref_freq, freqs.new);
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

- pr_debug("cpufreq: set frequency %lu Hz\n", freq);
+ pr_debug("cpufreq: set frequency %u Hz\n", freqs.new * 1000);

return 0;
}
@@ -139,7 +126,7 @@ static struct cpufreq_driver at32_driver = {
.name = "at32ap",
.init = at32_cpufreq_driver_init,
.verify = cpufreq_generic_frequency_table_verify,
- .target = at32_set_target,
+ .target_index = at32_set_target,
.get = at32_get_speed,
.flags = CPUFREQ_STICKY,
};
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:46:38

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 141/228] cpufreq: pmac64: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pmac64-cpufreq.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index 79e40c9..b977b9a 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -347,16 +347,9 @@ static unsigned int g5_cpufreq_get_speed(unsigned int cpu)

static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
- policy->cpuinfo.transition_latency = transition_latency;
- /* secondary CPUs are tied to the primary one by the
- * cpufreq core if in the secondary policy we tell it that
- * it actually must be one policy together with all others. */
- cpumask_copy(policy->cpus, cpu_online_mask);
-
- return cpufreq_table_validate_and_show(policy, g5_cpu_freqs);
+ return cpufreq_generic_init(policy, g5_cpu_freqs, transition_latency);
}

-
static struct cpufreq_driver g5_cpufreq_driver = {
.name = "powermac",
.flags = CPUFREQ_CONST_LOOPS,
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:19:39

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 139/228] cpufreq: pasemi: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pasemi-cpufreq.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 16f2508..1cca332 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -204,20 +204,13 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
pr_debug("%d: %d\n", i, pas_freqs[i].frequency);
}

- policy->cpuinfo.transition_latency = get_gizmo_latency();
-
cur_astate = get_cur_astate(policy->cpu);
pr_debug("current astate is at %d\n",cur_astate);

policy->cur = pas_freqs[cur_astate].frequency;
- cpumask_copy(policy->cpus, cpu_online_mask);
-
ppc_proc_freq = policy->cur * 1000ul;

- /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max
- * are set correctly
- */
- return cpufreq_table_validate_and_show(policy, pas_freqs);
+ return cpufreq_generic_init(policy, pas_freqs, get_gizmo_latency());

out_unmap_sdcpwr:
iounmap(sdcpwr_mapbase);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:19:26

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 099/228] cpufreq: dbx500: don't initialize part of policy that is set by core too

On Fri, Sep 13, 2013 at 3:00 PM, Viresh Kumar <[email protected]> wrote:

> Many common initializations of struct policy are moved to core now and hence
> this driver doesn't need to do it. This patch removes such code.
>
> Most recent of those changes is to call ->get() in the core after calling
> ->init().
>
> Cc: Linus Walleij <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2013-09-13 13:47:58

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 135/228] cpufreq: kirkwood: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/kirkwood-cpufreq.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index dc434c4..fff8653 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -120,10 +120,7 @@ static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
/* Module init and exit code */
static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
- /* cpuinfo and default policy values */
- policy->cpuinfo.transition_latency = 5000; /* 5uS */
-
- return cpufreq_table_validate_and_show(policy, kirkwood_freq_table);
+ return cpufreq_generic_init(policy, kirkwood_freq_table, 5000);
}

static struct cpufreq_driver kirkwood_cpufreq_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:18:49

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 063/228] cpufreq: dbx500: Use generic cpufreq routines

On Fri, Sep 13, 2013 at 3:00 PM, Viresh Kumar <[email protected]> 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: Linus Walleij <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by. It feels like I acked this before...

Yours,
Linus Walleij

2013-09-13 13:49:00

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 130/228] cpufreq: cris: use cpufreq_generic_init() routine

Use generic cpufreq_generic_init() routine instead of replicating the same code
here.

Cc: Jesper Nilsson <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cris-artpec3-cpufreq.c | 6 +-----
drivers/cpufreq/cris-etraxfs-cpufreq.c | 5 +----
2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index 4d88e4f..05fdc7e 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -71,13 +71,9 @@ static int cris_freq_target(struct cpufreq_policy *policy,

static int cris_freq_cpu_init(struct cpufreq_policy *policy)
{
- /* cpuinfo and default policy values */
- policy->cpuinfo.transition_latency = 1000000; /* 1ms */
-
- return cpufreq_table_validate_and_show(policy, cris_freq_table);
+ return cpufreq_generic_init(policy, cris_freq_table, 1000000);
}

-
static struct cpufreq_driver cris_freq_driver = {
.get = cris_freq_get_cpu_frequency,
.verify = cpufreq_generic_frequency_table_verify,
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index f7d2d49..fac2b26 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -70,10 +70,7 @@ static int cris_freq_target(struct cpufreq_policy *policy,

static int cris_freq_cpu_init(struct cpufreq_policy *policy)
{
- /* cpuinfo and default policy values */
- policy->cpuinfo.transition_latency = 1000000; /* 1ms */
-
- return cpufreq_table_validate_and_show(policy, cris_freq_table);
+ return cpufreq_generic_init(policy, cris_freq_table, 1000000);
}

static struct cpufreq_driver cris_freq_driver = {
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:18:03

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 126/228] cpufreq: unicore2: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/unicore2-cpufreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c
index 14e6d31..653ae29 100644
--- a/drivers/cpufreq/unicore2-cpufreq.c
+++ b/drivers/cpufreq/unicore2-cpufreq.c
@@ -66,7 +66,6 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
{
if (policy->cpu != 0)
return -EINVAL;
- policy->cur = ucv2_getspeed(0);
policy->min = policy->cpuinfo.min_freq = 250000;
policy->max = policy->cpuinfo.max_freq = 1000000;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:49:45

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 125/228] cpufreq: tegra: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Stephen Warren <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/tegra-cpufreq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index c36a8e7..9c32b23 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -211,8 +211,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
clk_prepare_enable(cpu_clk);

cpufreq_table_validate_and_show(policy, freq_table);
- policy->cur = tegra_getspeed(policy->cpu);
- target_cpu_speed[policy->cpu] = policy->cur;
+ target_cpu_speed[policy->cpu] = tegra_getspeed(policy->cpu);

/* FIXME: what's the actual transition time? */
policy->cpuinfo.transition_latency = 300 * 1000;
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:51:23

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 115/228] cpufreq: powernow: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/powernow-k6.c | 1 -
drivers/cpufreq/powernow-k7.c | 2 --
drivers/cpufreq/powernow-k8.c | 3 ---
3 files changed, 6 deletions(-)

diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index ff05d28..eda1702 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -151,7 +151,6 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)

/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = 200000;
- policy->cur = busfreq * max_multiplier;

return cpufreq_table_validate_and_show(policy, clock_ratio);
}
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index 14cd98f..44d345b 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -673,8 +673,6 @@ static int powernow_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency =
cpufreq_scale(2000000UL, fsb, latency);

- policy->cur = powernow_get(0);
-
return cpufreq_table_validate_and_show(policy, powernow_table);
}

diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index f054d5b..8721744 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1161,9 +1161,6 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol)
cpumask_copy(pol->cpus, cpu_core_mask(pol->cpu));
data->available_cores = pol->cpus;

- pol->cur = find_khz_freq_from_fid(data->currfid);
- pr_debug("policy current frequency %d kHz\n", pol->cur);
-
/* min/max the cpu is capable of */
if (cpufreq_table_validate_and_show(pol, data->powernow_table)) {
printk(KERN_ERR FW_BUG PFX "invalid powernow_table\n");
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:16:13

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 110/228] cpufreq: maple: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Dmitry Eremin-Solenikov <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/maple-cpufreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index b23d1d8..1c0cec1 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -166,7 +166,6 @@ static unsigned int maple_cpufreq_get_speed(unsigned int cpu)
static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
policy->cpuinfo.transition_latency = 12000;
- policy->cur = maple_cpu_freqs[maple_scom_query_freq()].frequency;
/* secondary CPUs are tied to the primary one by the
* cpufreq core if in the secondary policy we tell it that
* it actually must be one policy together with all others. */
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:52:43

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 107/228] cpufreq: kirkwood: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Andrew Lunn <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/kirkwood-cpufreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index 1a4e4f4..dc434c4 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -122,7 +122,6 @@ static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = 5000; /* 5uS */
- policy->cur = kirkwood_cpufreq_get_cpu_frequency(0);

return cpufreq_table_validate_and_show(policy, kirkwood_freq_table);
}
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:15:37

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 104/228] cpufreq: ia64-acpi: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Tony Luck <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/ia64-acpi-cpufreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
index b958bdb..90c6598 100644
--- a/drivers/cpufreq/ia64-acpi-cpufreq.c
+++ b/drivers/cpufreq/ia64-acpi-cpufreq.c
@@ -305,7 +305,6 @@ acpi_cpufreq_cpu_init (
data->acpi_data.states[i].transition_latency * 1000;
}
}
- policy->cur = processor_get_freq(data, policy->cpu);

/* table init */
for (i = 0; i <= data->acpi_data.state_count; i++)
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:54:56

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 094/228] cpufreq: blackfin: don't initialize part of policy that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init().

Cc: Steven Miao <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/blackfin-cpufreq.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index 48888cf..0bc9e8c 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -204,7 +204,6 @@ static int __bfin_cpu_init(struct cpufreq_policy *policy)

policy->cpuinfo.transition_latency = 50000; /* 50us assumed */

- policy->cur = cclk;
return cpufreq_table_validate_and_show(policy, bfin_freq_table);
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 13:55:44

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 090/228] cpufreq: call cpufreq_driver->get() after calling ->init()

Almost all drivers set policy->cur with current cpu frequency in their ->init()
part. This can be done for all of them at core level and so they wouldn't need
to do it.

This patch adds supporting code in cpufreq core for calling get() after we have
called init() for a policy.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index c7274e6..1e6b602 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1081,6 +1081,14 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
goto err_set_policy_cpu;
}

+ if (cpufreq_driver->get) {
+ policy->cur = cpufreq_driver->get(policy->cpu);
+ if (!policy->cur) {
+ pr_err("%s: ->get() failed\n", __func__);
+ goto err_get_freq;
+ }
+ }
+
/* related cpus should atleast have policy->cpus */
cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);

@@ -1135,6 +1143,9 @@ err_out_unregister:
per_cpu(cpufreq_cpu_data, j) = NULL;
write_unlock_irqrestore(&cpufreq_driver_lock, flags);

+err_get_freq:
+ if (cpufreq_driver->exit)
+ cpufreq_driver->exit(policy);
err_set_policy_cpu:
cpufreq_policy_free(policy);
nomem_out:
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:56:44

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 085/228] cpufreq: sh: Use generic cpufreq routines

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 <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
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 f1fb944..c681b86 100644
--- a/drivers/cpufreq/sh-cpufreq.c
+++ b/drivers/cpufreq/sh-cpufreq.c
@@ -151,11 +151,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,
@@ -163,7 +158,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

2013-09-13 13:11:54

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 074/228] cpufreq: p4-clockmod: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 13:11:19

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 069/228] cpufreq: kirkwood: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 59cbb35..1a4e4f4 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

2013-09-13 13:59:15

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 068/228] cpufreq: imx6q: Use generic cpufreq routines

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.

Acked-by: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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 cd9489f..29767bb 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;
@@ -173,25 +168,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

2013-09-13 14:01:55

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 059/228] cpufreq: blackfin: Use generic cpufreq routines

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 <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
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

2013-09-13 14:02:39

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 056/228] cpufreq: acpi: Use generic cpufreq routines

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 <[email protected]>
---
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 71f8e15..d67023d 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

2013-09-13 14:05:01

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 041/228] cpufreq: sh: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Paul Mundt <[email protected]>
Cc: [email protected]
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sh-cpufreq.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
index f671aa1..f1fb944 100644
--- a/drivers/cpufreq/sh-cpufreq.c
+++ b/drivers/cpufreq/sh-cpufreq.c
@@ -117,9 +117,9 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy)
if (freq_table) {
int result;

- result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
- if (!result)
- cpufreq_frequency_table_get_attr(freq_table, cpu);
+ result = cpufreq_table_validate_and_show(policy, freq_table);
+ if (result)
+ return result;
} else {
dev_notice(dev, "no frequency table found, falling back "
"to rate rounding.\n");
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:07:48

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 039/228] cpufreq: sa11x0: let cpufreq core initialize struct policy fields

Many fields of struct policy are filled by cpufreq core when we call
cpufreq_table_validate_and_show() and so cpufreq driver doesn't need to set them
anymore.

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/sa1100-cpufreq.c | 4 +---
drivers/cpufreq/sa1110-cpufreq.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c
index 1323a69..37fce2f 100644
--- a/drivers/cpufreq/sa1100-cpufreq.c
+++ b/drivers/cpufreq/sa1100-cpufreq.c
@@ -220,9 +220,7 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
{
if (policy->cpu != 0)
return -EINVAL;
- policy->cur = policy->min = policy->max = sa11x0_getspeed(0);
- policy->cpuinfo.min_freq = 59000;
- policy->cpuinfo.max_freq = 287000;
+ policy->cur = sa11x0_getspeed(0);
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

return cpufreq_table_validate_and_show(policy, sa11x0_freq_table);
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c
index adb0524..13760fc 100644
--- a/drivers/cpufreq/sa1110-cpufreq.c
+++ b/drivers/cpufreq/sa1110-cpufreq.c
@@ -334,9 +334,7 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
{
if (policy->cpu != 0)
return -EINVAL;
- policy->cur = policy->min = policy->max = sa11x0_getspeed(0);
- policy->cpuinfo.min_freq = 59000;
- policy->cpuinfo.max_freq = 287000;
+ policy->cur = sa11x0_getspeed(0);
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

return cpufreq_table_validate_and_show(policy, sa11x0_freq_table);
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:07:45

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 038/228] cpufreq: sa11x0: Expose frequency table

This patch exposes sa11x0's frequency table to cpufreq core. It always existed
but not as an array frequencies and not in the format cpufreq core wants it to.
Also it was present in the unit of 100kHz earlier which is made consistent with
cpufreq core now, i.e. kHz.

Signed-off-by: Viresh Kumar <[email protected]>
---
arch/arm/mach-sa1100/generic.c | 45 ++++++++++++++++++++--------------------
arch/arm/mach-sa1100/generic.h | 1 +
drivers/cpufreq/sa1100-cpufreq.c | 3 ++-
drivers/cpufreq/sa1110-cpufreq.c | 3 ++-
4 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index f25b611..5c8167b 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -42,23 +42,24 @@ EXPORT_SYMBOL(reset_status);
/*
* This table is setup for a 3.6864MHz Crystal.
*/
-static const unsigned short cclk_frequency_100khz[NR_FREQS] = {
- 590, /* 59.0 MHz */
- 737, /* 73.7 MHz */
- 885, /* 88.5 MHz */
- 1032, /* 103.2 MHz */
- 1180, /* 118.0 MHz */
- 1327, /* 132.7 MHz */
- 1475, /* 147.5 MHz */
- 1622, /* 162.2 MHz */
- 1769, /* 176.9 MHz */
- 1917, /* 191.7 MHz */
- 2064, /* 206.4 MHz */
- 2212, /* 221.2 MHz */
- 2359, /* 235.9 MHz */
- 2507, /* 250.7 MHz */
- 2654, /* 265.4 MHz */
- 2802 /* 280.2 MHz */
+struct cpufreq_frequency_table sa11x0_freq_table[NR_FREQS+1] = {
+ { .frequency = 59000, /* 59.0 MHz */},
+ { .frequency = 73700, /* 73.7 MHz */},
+ { .frequency = 88500, /* 88.5 MHz */},
+ { .frequency = 103200, /* 103.2 MHz */},
+ { .frequency = 118000, /* 118.0 MHz */},
+ { .frequency = 132700, /* 132.7 MHz */},
+ { .frequency = 147500, /* 147.5 MHz */},
+ { .frequency = 162200, /* 162.2 MHz */},
+ { .frequency = 176900, /* 176.9 MHz */},
+ { .frequency = 191700, /* 191.7 MHz */},
+ { .frequency = 206400, /* 206.4 MHz */},
+ { .frequency = 221200, /* 221.2 MHz */},
+ { .frequency = 235900, /* 235.9 MHz */},
+ { .frequency = 250700, /* 250.7 MHz */},
+ { .frequency = 265400, /* 265.4 MHz */},
+ { .frequency = 280200, /* 280.2 MHz */},
+ { .frequency = CPUFREQ_TABLE_END, },
};

/* rounds up(!) */
@@ -66,10 +67,8 @@ unsigned int sa11x0_freq_to_ppcr(unsigned int khz)
{
int i;

- khz /= 100;
-
for (i = 0; i < NR_FREQS; i++)
- if (cclk_frequency_100khz[i] >= khz)
+ if (sa11x0_freq_table[i].frequency >= khz)
break;

return i;
@@ -79,7 +78,7 @@ unsigned int sa11x0_ppcr_to_freq(unsigned int idx)
{
unsigned int freq = 0;
if (idx < NR_FREQS)
- freq = cclk_frequency_100khz[idx] * 100;
+ freq = sa11x0_freq_table[idx].frequency;
return freq;
}

@@ -96,7 +95,7 @@ int sa11x0_verify_speed(struct cpufreq_policy *policy)
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);

/* make sure that at least one frequency is within the policy */
- tmp = cclk_frequency_100khz[sa11x0_freq_to_ppcr(policy->min)] * 100;
+ tmp = sa11x0_freq_table[sa11x0_freq_to_ppcr(policy->min)].frequency;
if (tmp > policy->max)
policy->max = tmp;

@@ -109,7 +108,7 @@ unsigned int sa11x0_getspeed(unsigned int cpu)
{
if (cpu)
return 0;
- return cclk_frequency_100khz[PPCR & 0xf] * 100;
+ return sa11x0_freq_table[PPCR & 0xf].frequency;
}

/*
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index 9a33695..f5214ce 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -21,6 +21,7 @@ extern void sa1110_mb_disable(void);

struct cpufreq_policy;

+extern struct cpufreq_frequency_table sa11x0_freq_table[];
extern unsigned int sa11x0_freq_to_ppcr(unsigned int khz);
extern int sa11x0_verify_speed(struct cpufreq_policy *policy);
extern unsigned int sa11x0_getspeed(unsigned int cpu);
diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c
index cff18e8..1323a69 100644
--- a/drivers/cpufreq/sa1100-cpufreq.c
+++ b/drivers/cpufreq/sa1100-cpufreq.c
@@ -224,7 +224,8 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.min_freq = 59000;
policy->cpuinfo.max_freq = 287000;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
- return 0;
+
+ return cpufreq_table_validate_and_show(policy, sa11x0_freq_table);
}

static struct cpufreq_driver sa1100_driver __refdata = {
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c
index 39c90b6..adb0524 100644
--- a/drivers/cpufreq/sa1110-cpufreq.c
+++ b/drivers/cpufreq/sa1110-cpufreq.c
@@ -338,7 +338,8 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.min_freq = 59000;
policy->cpuinfo.max_freq = 287000;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
- return 0;
+
+ return cpufreq_table_validate_and_show(policy, sa11x0_freq_table);
}

/* sa1110_driver needs __refdata because it must remain after init registers
--
1.7.12.rc2.18.g61b472e

2013-09-13 13:07:29

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 036/228] cpufreq: s3cx4xx: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Kukjin Kim <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/s3c2416-cpufreq.c | 4 +---
drivers/cpufreq/s3c24xx-cpufreq.c | 6 ++----
drivers/cpufreq/s3c64xx-cpufreq.c | 5 +----
3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index 22dcb81..a7a4c61 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -494,12 +494,10 @@ static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = (500 * 1000) +
s3c_freq->regulator_latency;

- ret = cpufreq_frequency_table_cpuinfo(policy, s3c_freq->freq_table);
+ ret = cpufreq_table_validate_and_show(policy, s3c_freq->freq_table);
if (ret)
goto err_freq_table;

- cpufreq_frequency_table_get_attr(s3c_freq->freq_table, 0);
-
register_reboot_notifier(&s3c2416_cpufreq_reboot_notifier);

return 0;
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index f2c872c..73856d1 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -386,10 +386,8 @@ static int s3c_cpufreq_init(struct cpufreq_policy *policy)
/* feed the latency information from the cpu driver */
policy->cpuinfo.transition_latency = cpu_cur.info->latency;

- if (ftab) {
- cpufreq_frequency_table_cpuinfo(policy, ftab);
- cpufreq_frequency_table_get_attr(ftab, policy->cpu);
- }
+ if (ftab)
+ return cpufreq_table_validate_and_show(policy, ftab);

return 0;
}
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 9024043..872f74d 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -251,15 +251,12 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
*/
policy->cpuinfo.transition_latency = (500 * 1000) + regulator_latency;

- ret = cpufreq_frequency_table_cpuinfo(policy, s3c64xx_freq_table);
+ ret = cpufreq_table_validate_and_show(policy, s3c64xx_freq_table);
if (ret != 0) {
pr_err("Failed to configure frequency table: %d\n",
ret);
regulator_put(vddarm);
clk_put(armclk);
- } else {
- cpufreq_frequency_table_get_attr(s3c64xx_freq_table,
- policy->cpu);
}

return ret;
--
1.7.12.rc2.18.g61b472e

2013-09-13 14:07:07

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 032/228] cpufreq: pmac: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/pmac32-cpufreq.c | 3 +--
drivers/cpufreq/pmac64-cpufreq.c | 4 +---
2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index a096cd3..470b555 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -408,8 +408,7 @@ static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = transition_latency;
policy->cur = cur_freq;

- cpufreq_frequency_table_get_attr(pmac_cpu_freqs, policy->cpu);
- return cpufreq_frequency_table_cpuinfo(policy, pmac_cpu_freqs);
+ return cpufreq_table_validate_and_show(policy, pmac_cpu_freqs);
}

static u32 read_gpio(struct device_node *np)
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index 3a51ad7..41fa89e 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -363,10 +363,8 @@ static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy)
* cpufreq core if in the secondary policy we tell it that
* it actually must be one policy together with all others. */
cpumask_copy(policy->cpus, cpu_online_mask);
- cpufreq_frequency_table_get_attr(g5_cpu_freqs, policy->cpu);

- return cpufreq_frequency_table_cpuinfo(policy,
- g5_cpu_freqs);
+ return cpufreq_table_validate_and_show(policy, g5_cpu_freqs);
}


--
1.7.12.rc2.18.g61b472e

2013-09-13 14:08:45

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 030/228] cpufreq: p4-clockmod: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: David S. Miller <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/p4-clockmod.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 2f0a2a6..03478bf 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -230,7 +230,6 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
else
p4clockmod_table[i].frequency = (stock_freq * i)/8;
}
- cpufreq_frequency_table_get_attr(p4clockmod_table, policy->cpu);

/* cpuinfo and default policy values */

@@ -239,7 +238,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = 10000001;
policy->cur = stock_freq;

- return cpufreq_frequency_table_cpuinfo(policy, &p4clockmod_table[0]);
+ return cpufreq_table_validate_and_show(policy, &p4clockmod_table[0]);
}


--
1.7.12.rc2.18.g61b472e

2013-09-13 14:09:29

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 029/228] cpufreq: omap: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Acked-by: Santosh Shilimkar <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/omap-cpufreq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index f31fcfc..b68ce4e 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -191,12 +191,10 @@ static int omap_cpu_init(struct cpufreq_policy *policy)

atomic_inc_return(&freq_table_users);

- result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
+ result = cpufreq_table_validate_and_show(policy, freq_table);
if (result)
goto fail_table;

- cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
-
policy->cur = omap_getspeed(policy->cpu);

/*
--
1.7.12.rc2.18.g61b472e

2013-09-13 14:10:20

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 028/228] cpufreq: maple: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Cc: Dmitry Eremin-Solenikov <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/maple-cpufreq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index 6168d77..b3fb661 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -181,10 +181,8 @@ static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy)
* cpufreq core if in the secondary policy we tell it that
* it actually must be one policy together with all others. */
cpumask_setall(policy->cpus);
- cpufreq_frequency_table_get_attr(maple_cpu_freqs, policy->cpu);

- return cpufreq_frequency_table_cpuinfo(policy,
- maple_cpu_freqs);
+ return cpufreq_table_validate_and_show(policy, maple_cpu_freqs);
}


--
1.7.12.rc2.18.g61b472e

2013-09-13 14:11:34

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [PATCH 017/228] cpufreq: cris: use cpufreq_table_validate_and_show()

On Fri, Sep 13, 2013 at 02:59:23PM +0200, Viresh Kumar wrote:
> Lets use cpufreq_table_validate_and_show() instead of calling
> cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Acked-by: Jesper Nilsson <[email protected]>

> Cc: Mikael Starvik <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2013-09-13 14:12:43

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH 016/228] cpufreq: cpufreq-cpu0: use cpufreq_table_validate_and_show()

Lets use cpufreq_table_validate_and_show() instead of calling
cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().

Acked-by: Shawn Guo <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/cpufreq-cpu0.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index cbfffa9..ce4fa47 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -128,7 +128,7 @@ static int cpu0_cpufreq_init(struct cpufreq_policy *policy)
{
int ret;

- ret = cpufreq_frequency_table_cpuinfo(policy, freq_table);
+ ret = cpufreq_table_validate_and_show(policy, freq_table);
if (ret) {
pr_err("invalid frequency table: %d\n", ret);
return ret;
@@ -144,8 +144,6 @@ static int cpu0_cpufreq_init(struct cpufreq_policy *policy)
*/
cpumask_setall(policy->cpus);

- cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
-
return 0;
}

--
1.7.12.rc2.18.g61b472e

2013-09-13 14:19:06

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [PATCH 061/228] cpufreq: cris: Use generic cpufreq routines

On Fri, Sep 13, 2013 at 03:00:07PM +0200, 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.

Acked-by: Jesper Nilsson <[email protected]>

> Cc: Mikael Starvik <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2013-09-13 14:27:39

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 120/228] cpufreq: sa11x0: don't initialize part of policy that is set by core too

On Fri, Sep 13, 2013 at 06:31:06PM +0530, Viresh Kumar wrote:
> Many common initializations of struct policy are moved to core now and hence
> this driver doesn't need to do it. This patch removes such code.
>
> Most recent of those changes is to call ->get() in the core after calling
> ->init().
>
> Cc: Russell King <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Russell King <[email protected]>

2013-09-13 14:28:42

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 038/228] cpufreq: sa11x0: Expose frequency table

On Fri, Sep 13, 2013 at 06:29:44PM +0530, Viresh Kumar wrote:
> This patch exposes sa11x0's frequency table to cpufreq core. It always existed
> but not as an array frequencies and not in the format cpufreq core wants it to.
> Also it was present in the unit of 100kHz earlier which is made consistent with
> cpufreq core now, i.e. kHz.
>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Russell King <[email protected]>

2013-09-13 14:29:47

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 039/228] cpufreq: sa11x0: let cpufreq core initialize struct policy fields

On Fri, Sep 13, 2013 at 06:29:45PM +0530, Viresh Kumar wrote:
> Many fields of struct policy are filled by cpufreq core when we call
> cpufreq_table_validate_and_show() and so cpufreq driver doesn't need to set them
> anymore.
>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Russell King <[email protected]>

2013-09-13 14:31:15

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 175/228] cpufreq: sa11x0: Convert to light weight ->target_index() routine

On Fri, Sep 13, 2013 at 06:32:01PM +0530, Viresh Kumar wrote:
> This patch converts existing .target() to newly defined light weight
> .target_index() routine for this driver.
>
> CPUFreq core will call cpufreq_frequency_table_target() before calling this
> routine and will pass index to it.
>
> Some existing routines are no more required and so are removed now.
>
> Cc: Russell King <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Russell King <[email protected]>

2013-09-13 14:32:36

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 144/228] cpufreq: sa11x0: use cpufreq_generic_init() routine

On Fri, Sep 13, 2013 at 06:31:30PM +0530, Viresh Kumar wrote:
> Use generic cpufreq_generic_init() routine instead of replicating the same code
> here.
>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Russell King <[email protected]>

2013-09-13 15:24:47

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [PATCH 153/228] cpufreq: cris: Convert to light weight ->target_index() routine

On Fri, Sep 13, 2013 at 03:01:39PM +0200, Viresh Kumar wrote:
> This patch converts existing .target() to newly defined light weight
> .target_index() routine for this driver.
>
> CPUFreq core will call cpufreq_frequency_table_target() before calling this
> routine and will pass index to it.

Acked-by: Jesper Nilsson <[email protected]>

> Cc: Mikael Starvik <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2013-09-13 15:26:54

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [PATCH 187/228] cpufreq: cris: remove calls to cpufreq_notify_transition()

On Fri, Sep 13, 2013 at 03:02:13PM +0200, Viresh Kumar wrote:
> Most of the drivers do following in their ->target_index() routines:
>
> struct cpufreq_freqs freqs;
> freqs.old = old freq...
> freqs.new = new freq...
>
> cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
>
> /* Change rate here */
>
> cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
>
> This is replicated over all cpufreq drivers today and there doesn't exists a
> good enough reason why this shouldn't be moved to cpufreq core instead.
>
> Earlier patches have added support in cpufreq core to do cpufreq notification on
> frequency change, this one removes it from this driver.
>
> Some related minor cleanups are also done along with it.

Acked-by: Jesper Nilsson <[email protected]>

> Cc: Mikael Starvik <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2013-09-13 15:27:45

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [PATCH 130/228] cpufreq: cris: use cpufreq_generic_init() routine

On Fri, Sep 13, 2013 at 03:01:16PM +0200, Viresh Kumar wrote:
> Use generic cpufreq_generic_init() routine instead of replicating the same code
> here.

Acked-by: Jesper Nilsson <[email protected]>

> Cc: Mikael Starvik <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2013-09-13 15:28:03

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [PATCH 097/228] cpufreq: cris: don't initialize part of policy that is set by core too

On Fri, Sep 13, 2013 at 03:00:43PM +0200, Viresh Kumar wrote:
> Many common initializations of struct policy are moved to core now and hence
> this driver doesn't need to do it. This patch removes such code.
>
> Most recent of those changes is to call ->get() in the core after calling
> ->init().

Acked-by: Jesper Nilsson <[email protected]>

> Cc: Mikael Starvik <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2013-09-13 15:54:30

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 181/228] cpufreq: move freq change notifications to cpufreq core

On Fri, Sep 13, 2013 at 06:32:07PM +0530, Viresh Kumar wrote:
> + read_lock_irqsave(&cpufreq_driver_lock, flags);
> + notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION);
> + read_unlock_irqrestore(&cpufreq_driver_lock, flags);

I don't think this needs to be read under a lock - if this bit changes
dynamically, then there's something very wrong.

2013-09-13 15:55:08

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()

On Fri, Sep 13, 2013 at 06:32:32PM +0530, Viresh Kumar wrote:
> Most of the drivers do following in their ->target_index() routines:
>
> struct cpufreq_freqs freqs;
> freqs.old = old freq...
> freqs.new = new freq...
>
> cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
>
> /* Change rate here */
>
> cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
>
> This is replicated over all cpufreq drivers today and there doesn't exists a
> good enough reason why this shouldn't be moved to cpufreq core instead.
>
> Earlier patches have added support in cpufreq core to do cpufreq notification on
> frequency change, this one removes it from this driver.
>
> Some related minor cleanups are also done along with it.
>
> Cc: Russell King <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>

Shouldn't this patch set CPUFREQ_ASYNC_NOTIFICATION somewhere?

2013-09-13 16:03:28

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 181/228] cpufreq: move freq change notifications to cpufreq core

On 13 September 2013 21:23, Russell King - ARM Linux
<[email protected]> wrote:
> On Fri, Sep 13, 2013 at 06:32:07PM +0530, Viresh Kumar wrote:
>> + read_lock_irqsave(&cpufreq_driver_lock, flags);
>> + notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION);
>> + read_unlock_irqrestore(&cpufreq_driver_lock, flags);
>
> I don't think this needs to be read under a lock - if this bit changes
> dynamically, then there's something very wrong.

No it doesn't change dynamically.. Was a mistake..
Following change folded into the original commit (attached)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 2c1ae708..bb7402d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1802,7 +1802,6 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
else if (cpufreq_driver->target_index) {
struct cpufreq_frequency_table *freq_table;
struct cpufreq_freqs freqs;
- unsigned long flags;
bool notify;
int index;

@@ -1824,9 +1823,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
goto out;
}

- read_lock_irqsave(&cpufreq_driver_lock, flags);
notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION);
- read_unlock_irqrestore(&cpufreq_driver_lock, flags);

if (notify) {
freqs.old = policy->cur;


Attachments:
0181-cpufreq-move-freq-change-notifications-to-cpufreq-co.patch (2.67 kB)

2013-09-13 16:09:25

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 083/228] cpufreq: sa11x0: Use generic cpufreq routines

On Fri, Sep 13, 2013 at 06:30:29PM +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.
>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Russell King <[email protected]>

2013-09-13 16:11:17

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 106/228] cpufreq: integrator: don't initialize part of policy that is set by core too

On Fri, Sep 13, 2013 at 06:30:52PM +0530, Viresh Kumar wrote:
> Many common initializations of struct policy are moved to core now and hence
> this driver doesn't need to do it. This patch removes such code.
>
> Most recent of those changes is to call ->get() in the core after calling
> ->init().
>
> Cc: Russell King <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>
> ---
> drivers/cpufreq/integrator-cpufreq.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c
> index 8152a9b..babf3e4 100644
> --- a/drivers/cpufreq/integrator-cpufreq.c
> +++ b/drivers/cpufreq/integrator-cpufreq.c
> @@ -181,10 +181,9 @@ static int integrator_cpufreq_init(struct cpufreq_policy *policy)
> {
>
> /* set default policy and cpuinfo */
> - policy->cpuinfo.max_freq = 160000;
> - policy->cpuinfo.min_freq = 12000;
> + policy->max = policy->cpuinfo.max_freq = 160000;
> + policy->min = policy->cpuinfo.min_freq = 12000;
> policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */
> - policy->cur = policy->min = policy->max = integrator_get(policy->cpu);

This patch actually changes things - the description is misleading.
Please explain why this change - which results in different values for
policy->min and policy->max doesn't cause any functional difference.

Thanks.

2013-09-13 16:12:25

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()

On 13 September 2013 21:24, Russell King - ARM Linux
<[email protected]> wrote:
> On Fri, Sep 13, 2013 at 06:32:32PM +0530, Viresh Kumar wrote:
>> Most of the drivers do following in their ->target_index() routines:
>>
>> struct cpufreq_freqs freqs;
>> freqs.old = old freq...
>> freqs.new = new freq...
>>
>> cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
>>
>> /* Change rate here */
>>
>> cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
>>
>> This is replicated over all cpufreq drivers today and there doesn't exists a
>> good enough reason why this shouldn't be moved to cpufreq core instead.
>>
>> Earlier patches have added support in cpufreq core to do cpufreq notification on
>> frequency change, this one removes it from this driver.
>>
>> Some related minor cleanups are also done along with it.
>>
>> Cc: Russell King <[email protected]>
>> Signed-off-by: Viresh Kumar <[email protected]>
>
> Shouldn't this patch set CPUFREQ_ASYNC_NOTIFICATION somewhere?

As far as I can see, sa11x0 completes frequency transition from within
target() and so it does it synchronously.. And so it doesn't need to set
CPUFREQ_ASYNC_NOTIFICATION...

Am I missing something?

2013-09-13 16:15:44

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()

On Fri, Sep 13, 2013 at 09:42:23PM +0530, Viresh Kumar wrote:
> On 13 September 2013 21:24, Russell King - ARM Linux
> <[email protected]> wrote:
> > On Fri, Sep 13, 2013 at 06:32:32PM +0530, Viresh Kumar wrote:
> >> Most of the drivers do following in their ->target_index() routines:
> >>
> >> struct cpufreq_freqs freqs;
> >> freqs.old = old freq...
> >> freqs.new = new freq...
> >>
> >> cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
> >>
> >> /* Change rate here */
> >>
> >> cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
> >>
> >> This is replicated over all cpufreq drivers today and there doesn't exists a
> >> good enough reason why this shouldn't be moved to cpufreq core instead.
> >>
> >> Earlier patches have added support in cpufreq core to do cpufreq notification on
> >> frequency change, this one removes it from this driver.
> >>
> >> Some related minor cleanups are also done along with it.
> >>
> >> Cc: Russell King <[email protected]>
> >> Signed-off-by: Viresh Kumar <[email protected]>
> >
> > Shouldn't this patch set CPUFREQ_ASYNC_NOTIFICATION somewhere?
>
> As far as I can see, sa11x0 completes frequency transition from within
> target() and so it does it synchronously.. And so it doesn't need to set
> CPUFREQ_ASYNC_NOTIFICATION...
>
> Am I missing something?

The patch to which I'm replying removes the above calls. These calls are
necessary to shutdown various bits of CPU-clock dependent hardware
before changing the CPU clock, and restore them - reconfiguring them
for the new clock rate after the transition has happened.

So, if you're removing these calls, what replaces them? I don't see
anything which does without the above set.

2013-09-13 16:21:27

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH 195/228] cpufreq: kirkwood: remove calls to cpufreq_notify_transition()

On Fri, Sep 13, 2013 at 06:32:21PM +0530, Viresh Kumar wrote:

> - if (freqs.old != freqs.new) {
> - local_irq_disable();
> -
> - /* Disable interrupts to the CPU */
> - reg = readl_relaxed(priv.base);
> - reg |= CPU_SW_INT_BLK;
> - writel_relaxed(reg, priv.base);
> -
> - switch (state) {
> - case STATE_CPU_FREQ:
> - clk_disable(priv.powersave_clk);
> - break;
> - case STATE_DDR_FREQ:
> - clk_enable(priv.powersave_clk);
> - break;
> - }

Hi Viresh

I see you removed the test that the old and the new frequency are
different. Is this guaranteed by the core? Because if not, you can
lockup the CPU. The call to cpu_do_idle() will never return.

Thanks
Andrew

2013-09-13 16:22:34

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()

On 13 September 2013 21:45, Russell King - ARM Linux
<[email protected]> wrote:
> The patch to which I'm replying removes the above calls. These calls are
> necessary to shutdown various bits of CPU-clock dependent hardware
> before changing the CPU clock, and restore them - reconfiguring them
> for the new clock rate after the transition has happened.
>
> So, if you're removing these calls, what replaces them? I don't see
> anything which does without the above set.

The other patch on which you commented about unnecessary read
locks being taken:

[PATCH 181/228] cpufreq: move freq change notifications to cpufreq

That calls these notifiers, for all platforms except the ones that have
set CPUFREQ_ASYNC_NOTIFICATION, before and after calling
->target_index()..

And so functionally the code is supposed to be the same.. Unless I
have done some stupid mistake..

2013-09-13 16:24:01

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 195/228] cpufreq: kirkwood: remove calls to cpufreq_notify_transition()

On 13 September 2013 21:48, Andrew Lunn <[email protected]> wrote:
> On Fri, Sep 13, 2013 at 06:32:21PM +0530, Viresh Kumar wrote:
>
>> - if (freqs.old != freqs.new) {
>> - local_irq_disable();
>> -
>> - /* Disable interrupts to the CPU */
>> - reg = readl_relaxed(priv.base);
>> - reg |= CPU_SW_INT_BLK;
>> - writel_relaxed(reg, priv.base);
>> -
>> - switch (state) {
>> - case STATE_CPU_FREQ:
>> - clk_disable(priv.powersave_clk);
>> - break;
>> - case STATE_DDR_FREQ:
>> - clk_enable(priv.powersave_clk);
>> - break;
>> - }
>
> Hi Viresh
>
> I see you removed the test that the old and the new frequency are
> different. Is this guaranteed by the core? Because if not, you can
> lockup the CPU. The call to cpu_do_idle() will never return.

Yes, that's guaranteed by core: patch 181..

2013-09-13 16:26:58

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()

On Fri, Sep 13, 2013 at 09:52:31PM +0530, Viresh Kumar wrote:
> On 13 September 2013 21:45, Russell King - ARM Linux
> <[email protected]> wrote:
> > The patch to which I'm replying removes the above calls. These calls are
> > necessary to shutdown various bits of CPU-clock dependent hardware
> > before changing the CPU clock, and restore them - reconfiguring them
> > for the new clock rate after the transition has happened.
> >
> > So, if you're removing these calls, what replaces them? I don't see
> > anything which does without the above set.
>
> The other patch on which you commented about unnecessary read
> locks being taken:
>
> [PATCH 181/228] cpufreq: move freq change notifications to cpufreq
>
> That calls these notifiers, for all platforms except the ones that have
> set CPUFREQ_ASYNC_NOTIFICATION, before and after calling
> ->target_index()..
>
> And so functionally the code is supposed to be the same.. Unless I
> have done some stupid mistake..

Ah, sorry, read that that test the other way around. In that case,
this patch is fine and can have my ack as per the other acks I've
already given.

Thanks.

2013-09-13 16:27:56

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()

On 13 September 2013 21:56, Russell King - ARM Linux
<[email protected]> wrote:
> Ah, sorry, read that that test the other way around. In that case,
> this patch is fine and can have my ack as per the other acks I've
> already given.

Thanks :)

2013-09-13 16:29:15

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 106/228] cpufreq: integrator: don't initialize part of policy that is set by core too

On 13 September 2013 21:40, Russell King - ARM Linux
<[email protected]> wrote:
> This patch actually changes things - the description is misleading.
> Please explain why this change - which results in different values for
> policy->min and policy->max doesn't cause any functional difference.

Yeah, see if below log looks correct (patch attached):

Subject: [PATCH 106/228] cpufreq: integrator: don't initialize part of policy
that is set by core too

Many common initializations of struct policy are moved to core now and hence
this driver doesn't need to do it. This patch removes such code.

Most recent of those changes is to call ->get() in the core after calling
->init(). And so we don't need to set policy->cur from driver anymore.

Over that it sets policy->min and max correctly. They were earlier set to
current frequency of CPU but they should be set to max and min freq of cpu.

Cc: Russell King <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/cpufreq/integrator-cpufreq.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)


Attachments:
0106-cpufreq-integrator-don-t-initialize-part-of-policy-t.patch (1.76 kB)

2013-09-13 21:46:01

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 054/228] cpufreq: sparc: call cpufreq_frequency_table_put_attr()

From: Viresh Kumar <[email protected]>
Date: Fri, 13 Sep 2013 18:30:00 +0530

> 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 <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: David S. Miller <[email protected]>

2013-09-13 21:46:25

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 042/228] cpufreq: sparc: use cpufreq_table_validate_and_show()

From: Viresh Kumar <[email protected]>
Date: Fri, 13 Sep 2013 18:29:48 +0530

> Lets use cpufreq_table_validate_and_show() instead of calling
> cpufreq_frequency_table_cpuinfo() and cpufreq_frequency_table_get_attr().
>
> Cc: David S. Miller <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: David S. Miller <[email protected]>

2013-09-13 21:47:15

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 012/228] cpufreq: sparc: call cpufreq_frequency_table_get_attr()

From: Viresh Kumar <[email protected]>
Date: Fri, 13 Sep 2013 18:29:18 +0530

> This exposes frequency table of driver to cpufreq core and is required for core
> to guess what the index for a target frequency is, when it calls
> cpufreq_frequency_table_target(). And so this driver needs to expose it.
>
> Cc: David S. Miller <[email protected]>
> Cc: [email protected]
> Signed-off-by: Viresh Kumar <[email protected]>

Wait a second, later in this series you add the put_attr() call claiming
it's a fix.

But you're the one adding the "bug" here.

So if you are going to add a get_attr() call you should be adding the
necessary put_attr() call in the same patch. Otherwise this patch
introduces a bug.

2013-09-13 22:52:31

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()

On 09/13/2013 07:02 AM, Viresh Kumar wrote:
> Most of the drivers do following in their ->target_index() routines:
>
> struct cpufreq_freqs freqs;
> freqs.old = old freq...
> freqs.new = new freq...
>
> cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
>
> /* Change rate here */
>
> cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
>
> This is replicated over all cpufreq drivers today and there doesn't exists a
> good enough reason why this shouldn't be moved to cpufreq core instead.
>
> Earlier patches have added support in cpufreq core to do cpufreq notification on
> frequency change, this one removes it from this driver.
>
> Some related minor cleanups are also done along with it.

> diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c

> @@ -121,21 +117,10 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
> else
> clk_set_rate(emc_clk, 100000000); /* emc 50Mhz */
>
> - cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
...
> - cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);

I wonder if this series is bisectable? Perhaps I should just go and read
the rest of the series, but I presume there's a patch somewhere else
that adds those two cpufreq_notify_transition() to the cpufreq core.
Either that happens before this patch (in which case listeners will get
two notifications each time; perhaps that is safe?), or after this patch
(in which case with just this patch applied, no notifications will be
sent until a later patch!

Aside from that, all the Tegra-specific patches in this series,
Acked-by: Stephen Warren <[email protected]>

2013-09-13 23:27:08

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 000/228] CPUFreq: cleanup stuff for 3.13

On Friday, September 13, 2013 06:29:06 PM Viresh Kumar wrote:
> This is my biggest patchset ever and it might not happen again in my entire
> career. I hope I haven't screwed up here :)
>
> CPUFreq cleanup patches are ready to hit linux-next (I hope it doesn't turn out
> into horror stories, where it broke all possible architectures where Linux runs
> :))
>
> Most of these are build tested only, Also done by: Fengguang Wu's build bot.
>
> All of these were sent separately in smaller patchsets earlier and now merged
> together as a single set. Some parts are reviewed by platform maintainers and
> their Acks are included in the patches (Sorry if I missed any)..

I believe I asked you to send this stuff in pieces.

In any case, there's no way I'll apply this all at once and I'm not going to
pull it all at once either.

Thanks,
Rafael

2013-09-14 04:01:45

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 012/228] cpufreq: sparc: call cpufreq_frequency_table_get_attr()

On 14 September 2013 03:17, David Miller <[email protected]> wrote:
> From: Viresh Kumar <[email protected]>
> Date: Fri, 13 Sep 2013 18:29:18 +0530
>
>> This exposes frequency table of driver to cpufreq core and is required for core
>> to guess what the index for a target frequency is, when it calls
>> cpufreq_frequency_table_target(). And so this driver needs to expose it.
>>
>> Cc: David S. Miller <[email protected]>
>> Cc: [email protected]
>> Signed-off-by: Viresh Kumar <[email protected]>
>
> Wait a second, later in this series you add the put_attr() call claiming
> it's a fix.
>
> But you're the one adding the "bug" here.
>
> So if you are going to add a get_attr() call you should be adding the
> necessary put_attr() call in the same patch. Otherwise this patch
> introduces a bug.

Yeah, my mistake.. It was required to be added at both places for
very few drivers and so made this mistake..

I will merge both of those patches together..

2013-09-14 04:09:33

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()

On 14 September 2013 04:22, Stephen Warren <[email protected]> wrote:
> I wonder if this series is bisectable? Perhaps I should just go and read
> the rest of the series, but I presume there's a patch somewhere else
> that adds those two cpufreq_notify_transition() to the cpufreq core.
> Either that happens before this patch (in which case listeners will get
> two notifications each time; perhaps that is safe?), or after this patch
> (in which case with just this patch applied, no notifications will be
> sent until a later patch!

Hmm.. Good Catch..

So, yes git bisect would be compilable but not runnable.. As we are
already serialized notifications and so two PRE notifications will
generate a crash..

But I don't want to get all that in a single patch as that would be:

40 files changed, 192 insertions(+), 623 deletions(-)

And that would be hard to review it..

Any suggestions?

> Aside from that, all the Tegra-specific patches in this series,
> Acked-by: Stephen Warren <[email protected]>

Thanks..

2013-09-14 04:34:56

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 000/228] CPUFreq: cleanup stuff for 3.13

On 14 September 2013 05:08, Rafael J. Wysocki <[email protected]> wrote:
> On Friday, September 13, 2013 06:29:06 PM Viresh Kumar wrote:
>> This is my biggest patchset ever and it might not happen again in my entire
>> career. I hope I haven't screwed up here :)
>>
>> CPUFreq cleanup patches are ready to hit linux-next (I hope it doesn't turn out
>> into horror stories, where it broke all possible architectures where Linux runs
>> :))
>>
>> Most of these are build tested only, Also done by: Fengguang Wu's build bot.
>>
>> All of these were sent separately in smaller patchsets earlier and now merged
>> together as a single set. Some parts are reviewed by platform maintainers and
>> their Acks are included in the patches (Sorry if I missed any)..
>
> I believe I asked you to send this stuff in pieces.
>
> In any case, there's no way I'll apply this all at once and I'm not going to
> pull it all at once either.

Exactly for this reason I had following in my cover-letter:

"As suggested by Rafael earlier, he might not apply all at once and will give
people some chance to test sets one by one.. So, first set now, next one after
few days. So, I am marking different sets with patch numbers to make it easier
for Rafael.

- Patch 1->8: Generic cleanup of cpufreq core (First batch)
- Patch 9->54: Mostly about cpufreq_table_validate_and_show() helper
(First batch)
- Patch 55->89: New generic routines for cpufreq drivers (First/Second batch)
- Patch 90->126: About calling cpufreq_driver->get() from core
(First/Second batch)
- Patch 127->146: Generic init() routine (First/Second batch)
- Patch 147->180: Light weight ->target() routine (Third batch)
- Patch 181->211: Call notifiers from core instead of target()
(Third/Fourth batch)
- Patch 212->228: Generic get() (Fifth batch)
"

I kept them together because it looked like multiple patchsets have confused
people.. I have seen people reviewing first few sets and later on they haven't
bothered to review.. Probably they got confused..

And so it was required to keep them together, so that people get the complete
picture..

Sorry for the noise..

2013-09-14 07:42:35

by Vladimir Murzin

[permalink] [raw]
Subject: Re: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()

On Sat, Sep 14, 2013 at 09:39:31AM +0530, Viresh Kumar wrote:
> On 14 September 2013 04:22, Stephen Warren <[email protected]> wrote:
> > I wonder if this series is bisectable? Perhaps I should just go and read
> > the rest of the series, but I presume there's a patch somewhere else
> > that adds those two cpufreq_notify_transition() to the cpufreq core.
> > Either that happens before this patch (in which case listeners will get
> > two notifications each time; perhaps that is safe?), or after this patch
> > (in which case with just this patch applied, no notifications will be
> > sent until a later patch!
>
> Hmm.. Good Catch..
>
> So, yes git bisect would be compilable but not runnable.. As we are
> already serialized notifications and so two PRE notifications will
> generate a crash..
>
> But I don't want to get all that in a single patch as that would be:
>
> 40 files changed, 192 insertions(+), 623 deletions(-)
>
> And that would be hard to review it..
>
> Any suggestions?
>

It reminds me time of removing CONFIG_HOTPLUG and following __dev* attributes.
At least stats for 48c68c4 "Drivers: video: remove __dev* attributes" is:

135 files changed, 1017 insertions(+), 1129 deletions(-)

Maybe coccinelle script, which maintainers could run it on their trees, would
help?

Vladimir

> > Aside from that, all the Tegra-specific patches in this series,
> > Acked-by: Stephen Warren <[email protected]>
>
> Thanks..
>
> _______________________________________________
> linaro-kernel mailing list
> [email protected]
> http://lists.linaro.org/mailman/listinfo/linaro-kernel

2013-09-14 09:34:48

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH 069/228] cpufreq: kirkwood: Use generic cpufreq routines

On Fri, Sep 13, 2013 at 06:30:15PM +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: Andrew Lunn <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>
> ---
> drivers/cpufreq/kirkwood-cpufreq.c | 22 +++-------------------
> 1 file changed, 3 insertions(+), 19 deletions(-)

Hi Viresh

You can add:

Tested-by: Andrew Lunn <[email protected]>

to

[PATCH 069/228] cpufreq: kirkwood: Use generic cpufreq routines
[PATCH 107/228] cpufreq: kirkwood: don't initialize part of policy that is set by core
[PATCH 161/228] cpufreq: kirkwood: Convert to light weight ->target_index() routine
[PATCH 195/228] cpufreq: kirkwood: remove calls to cpufreq_notify_transition()

It does however require the patch:

http://www.spinics.net/lists/arm-kernel/msg273378.html

but this is not because of this patch series, it was already broken.

Thanks
Andrew

2013-09-14 21:58:20

by Aaro Koskinen

[permalink] [raw]
Subject: Re: [PATCH 136/228] cpufreq: loongson2: use cpufreq_generic_init() routine

On Fri, Sep 13, 2013 at 06:31:22PM +0530, Viresh Kumar wrote:
> Use generic cpufreq_generic_init() routine instead of replicating the same code
> here. This driver wasn't setting transition_latency and so is getting set to 0
> by default. Lets mark it explicitly by calling the generic routine with
> transition_latency as 0.
>
> Cc: Aaro Koskinen <[email protected]>
> Cc: John Crispin <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Aaro Koskinen <[email protected]>

BTW, this is not ARM but MIPS board, so adding linux-mips to CC.

A.

> ---
> drivers/cpufreq/loongson2_cpufreq.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
> index dd4f3e4..2c8ec8e 100644
> --- a/drivers/cpufreq/loongson2_cpufreq.c
> +++ b/drivers/cpufreq/loongson2_cpufreq.c
> @@ -131,8 +131,7 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
> return ret;
> }
>
> - return cpufreq_table_validate_and_show(policy,
> - &loongson2_clockmod_table[0]);
> + return cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0);
> }
>
> static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
> --
> 1.7.12.rc2.18.g61b472e
>

2013-09-15 04:54:47

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()

On Saturday, September 14, 2013 09:39:31 AM Viresh Kumar wrote:
> On 14 September 2013 04:22, Stephen Warren <[email protected]> wrote:
> > I wonder if this series is bisectable? Perhaps I should just go and read
> > the rest of the series, but I presume there's a patch somewhere else
> > that adds those two cpufreq_notify_transition() to the cpufreq core.
> > Either that happens before this patch (in which case listeners will get
> > two notifications each time; perhaps that is safe?), or after this patch
> > (in which case with just this patch applied, no notifications will be
> > sent until a later patch!
>
> Hmm.. Good Catch..
>
> So, yes git bisect would be compilable but not runnable.. As we are
> already serialized notifications and so two PRE notifications will
> generate a crash..
>
> But I don't want to get all that in a single patch as that would be:
>
> 40 files changed, 192 insertions(+), 623 deletions(-)
>
> And that would be hard to review it..
>
> Any suggestions?

Well, I guess you can assume that everyone has a chance to review the series
by now and send it as one patch in the next iteration.

A patch that adds 192 lines of code isn't shockingly large by any measure.

Thanks,
Rafael

2013-09-16 04:27:30

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()

On 15 September 2013 10:35, Rafael J. Wysocki <[email protected]> wrote:
> Well, I guess you can assume that everyone has a chance to review the series
> by now and send it as one patch in the next iteration.

Yeah, that's what I thought..

> A patch that adds 192 lines of code isn't shockingly large by any measure.

It was more about removal of things and the number of files it touches..
But yes, its good for review to send them separately but in the end they can
be merged..

2013-09-20 18:56:37

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 189/228] cpufreq: dbx500: remove calls to cpufreq_notify_transition()

On Fri, Sep 13, 2013 at 3:02 PM, Viresh Kumar <[email protected]> wrote:

> Most of the drivers do following in their ->target_index() routines:
>
> struct cpufreq_freqs freqs;
> freqs.old = old freq...
> freqs.new = new freq...
>
> cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
>
> /* Change rate here */
>
> cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
>
> This is replicated over all cpufreq drivers today and there doesn't exists a
> good enough reason why this shouldn't be moved to cpufreq core instead.
>
> Earlier patches have added support in cpufreq core to do cpufreq notification on
> frequency change, this one removes it from this driver.
>
> Some related minor cleanups are also done along with it.
>
> Cc: Linus Walleij <[email protected]>
> Signed-off-by: Viresh Kumar <[email protected]>

Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2013-10-04 02:53:54

by Olof Johansson

[permalink] [raw]
Subject: Re: [PATCH 038/228] cpufreq: sa11x0: Expose frequency table

On Fri, Sep 13, 2013 at 5:59 AM, Viresh Kumar <[email protected]> wrote:
> This patch exposes sa11x0's frequency table to cpufreq core. It always existed
> but not as an array frequencies and not in the format cpufreq core wants it to.
> Also it was present in the unit of 100kHz earlier which is made consistent with
> cpufreq core now, i.e. kHz.
>
> Signed-off-by: Viresh Kumar <[email protected]>

This causes breakage in linux-next for any SA1100 target:

In file included from ../../arch/arm/mach-sa1100/irq.c:24:0:
../../arch/arm/mach-sa1100/generic.h:24:39: error: array type has
incomplete element type
extern struct cpufreq_frequency_table sa11x0_freq_table[];

-Olof

2013-10-04 05:22:58

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 038/228] cpufreq: sa11x0: Expose frequency table

On 4 October 2013 08:23, Olof Johansson <[email protected]> wrote:
> This causes breakage in linux-next for any SA1100 target:
>
> In file included from ../../arch/arm/mach-sa1100/irq.c:24:0:
> ../../arch/arm/mach-sa1100/generic.h:24:39: error: array type has
> incomplete element type
> extern struct cpufreq_frequency_table sa11x0_freq_table[];

Ahh... sorry!! Below diff fixes it..

@Rafael: Please merge the attached fixup patch with $SUBJECT patch.

------x--------------x-----------

commit d2e1eb969ebdb66e3cc199fbbbe2e2a1a8e2960b
Author: Viresh Kumar <[email protected]>
Date: Fri Oct 4 10:48:16 2013 +0530

fixup! cpufreq: sa11x0: Expose frequency table
---
arch/arm/mach-sa1100/generic.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index f5214ce..2d9bee0 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -3,6 +3,7 @@
*
* Author: Nicolas Pitre
*/
+#include <linux/cpufreq.h>
#include <linux/reboot.h>

extern void sa1100_timer_init(void);
@@ -19,8 +20,6 @@ extern void sa11x0_init_late(void);
extern void sa1110_mb_enable(void);
extern void sa1110_mb_disable(void);

-struct cpufreq_policy;
-
extern struct cpufreq_frequency_table sa11x0_freq_table[];
extern unsigned int sa11x0_freq_to_ppcr(unsigned int khz);
extern int sa11x0_verify_speed(struct cpufreq_policy *policy);


Attachments:
0001-fixup-cpufreq-sa11x0-Expose-frequency-table.patch (1.08 kB)