cpufreq: exynos5440: Fix to skip when new frequency same as current

This patch fixes the issue of un-necessary setting the clock controller
when the new target frequency is same as the current one. This case usually
occurs with governors like ondemand which passes the target frequency as the
percentage of average frequency. This check is present in most of the cpufreq
drivers.

Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
cpufreq: fix EXYNOS drivers selection

* remove superfluous pr_debug() call from exynos_cpufreq_init()
  (init errors are always logged anyway)
* add dummy per-SoC type init functions to exynos-cpufreq.h
* make per-SoC type cpufreq config options selectable
* make CONFIG_ARM_EXYNOS_CPUFREQ config option invisible to user and
  automatically enable it when needed

This patch fixes following issues:
* EXYNOS per-SoC type cpufreq support (i.e. exynos4210-cpufreq.c) being
  always built if given SoC support was enabled (i.e. CPU_EXYNOS4210),
  even if common EXYNOS cpufreq support was disabled
* inability to select cpufreq for each SoC type separately (it could
  be only enabled/disabled for all SoCs for which support was enabled)
* EXYNOS5440 cpufreq support was always enabled when EXYNOS5440
  support was enabled and couldn't be disabled

Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
SH: cpuidle: Add missing parameter for cpuidle_register()

arch/sh/kernel/cpu/shmobile/cpuidle.c: In function 'sh_mobile_setup_cpuidle':
arch/sh/kernel/cpu/shmobile/cpuidle.c:102:2: error: too few arguments to function 'cpuidle_register'
include/linux/cpuidle.h:129:12: note: declared here
arch/sh/kernel/cpu/shmobile/cpuidle.c:94:6: warning: unused variable 'ret' [-Wunused-variable]

Add the missing parameter, and remove the unused variable.

Both introduced by commit b181a3b03f866776211f22390c185c4da1dc45ff ("SH:
cpuidle: use init/exit common routine").

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
cpuidle: calxeda: Add missing __iomem annotation

Added missing __iomem annotation in order to fix the following
sparse warnings:

drivers/cpuidle/cpuidle-calxeda.c:44:24: warning: incorrect type in argument 1 (different address spaces)
drivers/cpuidle/cpuidle-calxeda.c:44:24:    expected void [noderef] <asn:2>*<noident>
drivers/cpuidle/cpuidle-calxeda.c:44:24:    got void *extern [addressable] [toplevel] scu_base_addr
drivers/cpuidle/cpuidle-calxeda.c:56:24: warning: incorrect type in argument 1 (different address spaces)
drivers/cpuidle/cpuidle-calxeda.c:56:24:    expected void [noderef] <asn:2>*<noident>
drivers/cpuidle/cpuidle-calxeda.c:56:24:    got void *extern [addressable] [toplevel] scu_base_addr

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
cpuidle: kirkwood: Make kirkwood_cpuidle_remove function static

This local symbol is used only in this file.
Fix the following sparse warnings:

drivers/cpuidle/cpuidle-kirkwood.c:73:5: warning: symbol 'kirkwood_cpuidle_remove' was not declared. Should it be static ?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
ACPI / processor: Remove acpi_processor_get_limit_info()

acpi_processor_get_limit_info() is only called in the __acpi_processor_start()
and what it does actually is just to check pr->flags.throttling and set limit.
The pr pointer has been checked in the __acpi_processor_start() before
acpi_processor_get_limit_info() being called. It doesn't make sense still to
keep it as a function. So move code to __acpi_processor_start() and remove
acpi_processor_get_limit_info().

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / processor: Acquire writer lock to update CPU maps

CPU system maps are protected with reader/writer locks.  The reader
lock, get_online_cpus(), assures that the maps are not updated while
holding the lock.  The writer lock, cpu_hotplug_begin(), is used to
udpate the cpu maps along with cpu_maps_update_begin().

However, the ACPI processor handler updates the cpu maps without
holding the the writer lock.

acpi_map_lsapic() is called from acpi_processor_hotadd_init() to
update cpu_possible_mask and cpu_present_mask.  acpi_unmap_lsapic()
is called from acpi_processor_remove() to update cpu_possible_mask.
Currently, they are either unprotected or protected with the reader
lock, which is not correct.

For example, the get_online_cpus() below is supposed to assure that
cpu_possible_mask is not changed while the code is iterating with
for_each_possible_cpu().

        get_online_cpus();
        for_each_possible_cpu(cpu) {
		:
        }
        put_online_cpus();

However, this lock has no protection with CPU hotplug since the ACPI
processor handler does not use the writer lock when it updates
cpu_possible_mask.  The reader lock does not serialize within the
readers.

This patch protects them with the writer lock with cpu_hotplug_begin()
along with cpu_maps_update_begin(), which must be held before calling
cpu_hotplug_begin().  It also protects arch_register_cpu() /
arch_unregister_cpu(), which creates / deletes a sysfs cpu device
interface.  For this purpose it changes cpu_hotplug_begin() and
cpu_hotplug_done() to global and exports them in cpu.h.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / dock: Fix __init attribute location in find_dock_and_bay()

__init belongs after the return type on functions, not before it.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / numa: Fix __init attribute location in slit_valid()

__init belongs after the return type on functions, not before it.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / osl: Fix osi_setup_entries[] __initdata attribute location

__initdata should come after the variable name being declared and
nowhere else, in this way the variable will be placed in the
intended section.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'pm-cpufreq-general' into pm-cpufreq
Merge branch 'cpufreq-fixes' of git://git.linaro.org/people/vireshk/linux into pm-cpufreq

Pull ARM cpufreq fixes from Viresh Kumar.

* 'cpufreq-fixes' of git://git.linaro.org/people/vireshk/linux:
  cpufreq: fix EXYNOS drivers selection
  cpufreq: exynos5440: Fix to skip when new frequency same as current
acpi-cpufreq: Use cpufreq_freq_attr_rw to define the cpb attribute

Standardise the defintion of the cpb (Core Performance Boost)
attribute in the acpi-cpufreq driver via the cpufreq_freq_attr_rw
macro.

[rjw: Subject and changelog]
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'pm-cpuidle-general' into pm-cpuidle
Merge branch 'cpuidle/arm-next' of git://git.linaro.org/people/dlezcano/linux into pm-cpuidle

Pull cpuidle updates from Daniel Lezcano.

* 'cpuidle/arm-next' of git://git.linaro.org/people/dlezcano/linux:
  cpuidle: kirkwood: Make kirkwood_cpuidle_remove function static
  cpuidle: calxeda: Add missing __iomem annotation
  SH: cpuidle: Add missing parameter for cpuidle_register()
cpufreq: cpufreq-cpu0: NULL is a valid regulator

Since NULL could in theory be a valid regulator we ought to check for
IS_ERR() rather than for NULL. In practice this is unlikely to be an
issue but it's better for neatness.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
pxa3xx-cpufreq.c: Avoid using ARRAY_AND_SIZE(e) as a function argument

Replace ARRAY_AND_SIZE(e) in function argument position to avoid
hiding the arity of the called function.

The semantic match that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,f;
@@

f(...,
- ARRAY_AND_SIZE(e)
+ e,ARRAY_SIZE(e)
  ,...)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq / gx: Fix gx_detect_chipset() __init attribute location

__init belongs after the return type on functions, not before it.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq / pxa2xx: Fix pxa_cpufreq_init_voltages() __init attribute location

__init belongs after the return type on functions, not before it.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq / s3c24xx: Fix s3c_cpufreq_initclks() __init attribute location

__init belongs after the return type on functions, not before it.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>