aboutsummaryrefslogtreecommitdiff
path: root/drivers/thermal/cpu_cooling.c
AgeCommit message (Collapse)Author
2013-11-06thermal: cpu_cooling: fix return value check in cpufreq_cooling_register()Wei Yongjun
In case of error, the function thermal_cooling_device_register() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-09-03drivers: thermal: add check when unregistering cpu coolingEduardo Valentin
This patch avoids NULL pointer accesses while unregistering cpu cooling devices, in case a NULL pointer is received. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
2013-08-15Thermal/cpu_cooling: Return directly for the cpu out of allowed_cpus in the ↵Lan Tianyu
cpufreq_thermal_notifier() cpufreq_thermal_notifier() is to change the cpu's cpufreq in the allowed_cpus mask when associated thermal-cpufreq cdev's cooling state is changed. It's a cpufreq policy notifier handler and it will be triggered even if those cpus out of allowed_cpus has changed freq policy. cpufreq_thermal_notifier() checks the policy->cpu. If it belongs to allowed_cpus, change max_freq(default to 0) to the desire cpufreq value and pass 0 and max_freq to cpufreq_verify_within_limits() as cpufreq scope. But if not, do nothing and max_freq will remain 0. This will cause the cpufreq scope to become 0~0. This is not right. This patch is to return directly after finding cpu not belonging to allowed_cpus. Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-05-28thermal: cpu_cooling: fix 'descend' check in get_property()Shawn Guo
The variable 'descend' is initialized as -1 in function get_property(), and will never get any chance to be updated by the following code. if (freq != CPUFREQ_ENTRY_INVALID && descend != -1) descend = !!(freq > table[i].frequency); This makes function get_property() return the wrong frequency for given cooling level if the frequency table is sorted in ascending. Fix it by correcting the 'descend' check in if-condition to 'descend == -1'. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-27thermal: cpu_cooling: alignment improvementsEduardo Valentin
Improve code readiness by changing alignments so that they match open parenthesis, like checkpatch.pl --strict suggests. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-27thermal: cpu_cooling: remove checkpatch.pl warningEduardo Valentin
Simple code style fix. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-27thermal: cpu_cooling: remove trailing blank lineEduardo Valentin
Remove unnecessary blank line. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-27thermal: cpu_cooling: align on open parenthesisEduardo Valentin
Improve code readiness by remove checkpatch.pl warnings on get_property function. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-27thermal: cpu_cooling: standardize comment styleEduardo Valentin
There are at least three patterns for oneline comments in this file. This patch changes them to one single pattern Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-27thermal: cpu_cooling: standardize end of functionEduardo Valentin
Just for code readiness, this patch makes all functions on this file to have a blank line before their returns. Now, some functions follow this pattern, and others will not have a blank line. So, this patch makes it a single pattern. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-27thermal: cpu_cooling: remove trailing white spacesEduardo Valentin
Remove unnecessary white spaces. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: remove unused symbolsEduardo Valentin
The list is not needed so far. Thus removing it. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: remove not needed curl bracketsEduardo Valentin
Just for style purposes, remove extra curl brackets. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: use snprintf instead of sprintfEduardo Valentin
Limit the amount of bytes written to dev_name by secure writing with snprintf. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: update kernel-doc comment for cpufreq_cooling_unregisterEduardo Valentin
Update comments for this exported function. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: update kernel-doc for cpufreq_cooling_registerEduardo Valentin
Add proper documentation for exported function cpufreq_cooling_register. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: update documentation for cpufreq_set_cur_stateEduardo Valentin
Update documentation for cpufreq_set_cur_state callback. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: update documentation for cpufreq_get_cur_stateEduardo Valentin
Update documentation for cpufreq_get_cur_state callback. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: update documentation for cpufreq_get_max_stateEduardo Valentin
Update documentation for cpufreq_get_max_state callback. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: update documentation for cpufreq_thermal_notifierEduardo Valentin
Update kernel-doc comment and documentation for cpufreq_thermal_notifier. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: update documentation for cpufreq_apply_coolingEduardo Valentin
Update kernel-doc comments for cpufreq_apply_cooling function. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: improve documentation for get_cpu_frequencyEduardo Valentin
Fix kernel-doc warning on get_cpu_frequency and improve documentation comments. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: document cpufreq_get_cooling_levelEduardo Valentin
Add documentation for cpufreq_get_cooling_level. As this is an exported function, it has to be documented. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: add documentation for get_propertyEduardo Valentin
As this is one of the central functions of this file, it deserves a proper documentation. This patch improves the existing comment to format it as a kernel-doc style. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: fix kernel doc for is_cpufreq_validEduardo Valentin
Update documentation for is_cpufreq_valid function so that kernel-doc does not complain about return value. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: remove compiler warningEduardo Valentin
level will be used only if GET_FREQ mode is requested. There is no potential harm with current code. But for cleaning the compilation log, this patch initializes level to zero. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: use EXPORT_SYMBOL_GPLEduardo Valentin
Restrict the usage to GPL modules. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: fix kernel_doc for cpufreq_cooling_deviceEduardo Valentin
Simple fixes for making kernel_doc happy about struct cpufreq_cooling_device. Includes also a minor spelling fix. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-25thermal: cpu_cooling: remove unused headersEduardo Valentin
Remove some unused header files. Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-17Thermal: cpufreq cooling: endian bug in cpufreq_get_max_state()Dan Carpenter
This code doesn't work on big endian systems because we're storing low values in the high bits of the unsigned long. It makes it a very high value instead. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-04-15Merge branch 'thermal' of ↵Zhang Rui
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux into next Conflicts: drivers/thermal/cpu_cooling.c
2013-03-26drivers: thermal: cpu_cooling: fix checkpatch warningLaurent Navet [Mali]
- WARNING: Avoid CamelCase: <maskPtr> Signed-off-by: Laurent Navet <laurent.navet@gmail.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2013-03-26Thermal: exynos: fix cooling state translationZhang Rui
Signed-off-by: Zhang Rui <rui.zhang@intel.com> Tested-by: Amit Daniel kachhap <amit.daniel@samsung.com>
2013-03-26Thermal: cpufreq cooling: fix parsing per_cpu cpufreq_frequency_tableZhang Rui
cpufreq cooling uses different frequencies as different cooling states. But the per_cpu cpufreq_frequency_table may contain duplicate, invalid entries, and it may be in either ascending or descending order. And currently, code for parsing the per_cpu cpufreq_frequency_table is used in several places and inconsistent. Now introduce new code to 1. get the maximum cooling states 2. translate cooling state to cpu frequency 3. translate cpu frequency to cooling state in one place, with the correct logic of handling per_cpu cpufreq_frequency_table. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Tested-by: Amit Daniel kachhap <amit.daniel@samsung.com>
2013-02-28Merge branch 'release' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux Pull thermal management updates from Zhang Rui: "Highlights: - introduction of Dove thermal sensor driver. - introduction of Kirkwood thermal sensor driver. - introduction of intel_powerclamp thermal cooling device driver. - add interrupt and DT support for rcar thermal driver. - add thermal emulation support which allows platform thermal driver to do software/hardware emulation for thermal issues." * 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: (36 commits) thermal: rcar: remove __devinitconst thermal: return an error on failure to register thermal class Thermal: rename thermal governor Kconfig option to avoid generic naming thermal: exynos: Use the new thermal trend type for quick cooling action. Thermal: exynos: Add support for temperature falling interrupt. Thermal: Dove: Add Themal sensor support for Dove. thermal: Add support for the thermal sensor on Kirkwood SoCs thermal: rcar: add Device Tree support thermal: rcar: remove machine_power_off() from rcar_thermal_notify() thermal: rcar: add interrupt support thermal: rcar: add read/write functions for common/priv data thermal: rcar: multi channel support thermal: rcar: use mutex lock instead of spin lock thermal: rcar: enable CPCTL to use hardware TSC deciding thermal: rcar: use parenthesis on macro Thermal: fix a build warning when CONFIG_THERMAL_EMULATION cleared Thermal: fix a wrong comment thermal: sysfs: Add a new sysfs node emul_temp for thermal emulation PM: intel_powerclamp: off by one in start_power_clamp() thermal: exynos: Miscellaneous fixes to support falling threshold interrupt ...
2013-02-27thermal: convert to idr_alloc()Tejun Heo
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-06Thermal: fix a wrong commentZhang Rui
"level" parameter of get_cpu_frequency equals cooling state of cpu cooling device, and it starts from 0. Fix the misleading comment. Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2012-11-22thermal: cpu cooling: use const parameter while registeringEduardo Valentin
There are predefined cpu_masks that are const data structures. This patch changes the cpu cooling register function so that those const cpu_masks can be used, without compilation warnings. include/linux/cpumask.h * The following particular system cpumasks and operations manage * possible, present, active and online cpus. * * cpu_possible_mask- has bit 'cpu' set iff cpu is populatable * cpu_present_mask - has bit 'cpu' set iff cpu is populated * cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler * cpu_active_mask - has bit 'cpu' set iff cpu available to migration * Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2012-11-15thermal: cpu_cooling: Make 'notify_device' staticSachin Kamat
Silences the following sparse warning: drivers/thermal/cpu_cooling.c:67:31: warning: symbol 'notify_device' was not declared. Should it be static? Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2012-11-07Thermal: Remove the cooling_cpufreq_list.hongbo.zhang
Problem of using this list is that the cpufreq_get_max_state callback will be called when register cooling device by thermal_cooling_device_register, but this list isn't ready at this moment. What's more, there is no need to maintain such a list, we can get cpufreq_cooling_device instance by the private thermal_cooling_device.devdata. Signed-off-by: hongbo.zhang <hongbo.zhang@linaro.com> Reviewed-by: Francesco Lavra <francescolavra.fl@gmail.com> Reviewed-by: Amit Daniel Kachhap <amit.kachhap@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2012-11-07Thermal: fix bug of counting cpu frequencies.hongbo.zhang
In the while loop for counting cpu frequencies, if table[i].frequency equals CPUFREQ_ENTRY_INVALID, index i won't be increased, so this leads to an endless loop, what's more the index i cannot be referred as cpu frequencies number if there is CPUFREQ_ENTRY_INVALID case. Signed-off-by: hongbo.zhang <hongbo.zhang@linaro.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Amit Daniel Kachhap <amit.kachhap@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2012-11-07Thermal: add indent for code alignment.hongbo.zhang
The curly bracket should be aligned with corresponding if else statements. Signed-off-by: hongbo.zhang <hongbo.zhang@linaro.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2012-10-09Merge branch 'release' of ↵Len Brown
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux into thermal Conflicts: drivers/staging/omap-thermal/omap-thermal-common. OMAP supplied dummy TC1 and TC2, at the same time that the thermal tree removed them from thermal_zone_device_register() drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c propogate the upstream MAX_IDR_LEVEL re-name to prevent a build failure Previously-fixed-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Len Brown <len.brown@intel.com>
2012-09-27Thermal: Fix bug on cpu_cooling, cooling device's id conflict problem.Jonghwa Lee
This patch fixes small bug on cpu_cooling. CPU cooling device has own id generated with idr mathod. However in the previous version, it swapped to all same id at last stage of probing as 0. This makes id's collision and also occures error when it releases that id. Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
2012-09-24thermal: add generic cpufreq cooling implementationAmit Daniel Kachhap
This patchset introduces a new generic cooling device based on cpufreq that can be used on non-ACPI platforms. As a proof of concept, we have drivers for the following platforms using this mechanism now: * Samsung Exynos (Exynos4 and Exynos5) in the current patchset. * Freescale i.MX (git://git.linaro.org/people/amitdanielk/linux.git imx6q_thermal) There is a small change in cpufreq cooling registration APIs, so a minor change is needed for Freescale platforms. Brief Description: 1) The generic cooling devices code is placed inside driver/thermal/* as placing inside acpi folder will need un-necessary enabling of acpi code. This code is architecture independent. 2) This patchset adds generic cpu cooling low level implementation through frequency clipping. In future, other cpu related cooling devices may be added here. An ACPI version of this already exists (drivers/acpi/processor_thermal.c) .But this will be useful for platforms like ARM using the generic thermal interface along with the generic cpu cooling devices. The cooling device registration API's return cooling device pointers which can be easily binded with the thermal zone trip points. The important APIs exposed are, a) struct thermal_cooling_device *cpufreq_cooling_register( struct cpumask *clip_cpus) b) void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) 3) Samsung exynos platform thermal implementation is done using the generic cpu cooling APIs and the new trip type. The temperature sensor driver present in the hwmon folder(registered as hwmon driver) is moved to thermal folder and registered as a thermal driver. A simple data/control flow diagrams is shown below, Core Linux thermal <-----> Exynos thermal interface <----- Temperature Sensor | | \|/ | Cpufreq cooling device <--------------- TODO: *Will send the DT enablement patches later after the driver is merged. This patch: Add support for generic cpu thermal cooling low level implementations using frequency scaling up/down based on the registration parameters. Different cpu related cooling devices can be registered by the user and the binding of these cooling devices to the corresponding trip points can be easily done as the registration APIs return the cooling device pointer. The user of these APIs are responsible for passing clipping frequency . The drivers can also register to recieve notification about any cooling action called. [akpm@linux-foundation.org: fix comment layout] Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org> Cc: Guenter Roeck <guenter.roeck@ericsson.com> Cc: SangWook Ju <sw.ju@samsung.com> Cc: Durgadoss <durgadoss.r@intel.com> Cc: Len Brown <lenb@kernel.org> Cc: Jean Delvare <khali@linux-fr.org> Cc: Kyungmin Park <kmpark@infradead.org> Cc: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>