From fc35b35cbe24ef021ea9acfba21e54da958df747 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Fri, 8 Feb 2013 13:09:32 +0800 Subject: Thermal: cpufreq cooling: fix parsing per_cpu cpufreq_frequency_table 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 Tested-by: Amit Daniel kachhap --- drivers/thermal/cpu_cooling.c | 143 +++++++++++++++++++++++++++--------------- 1 file changed, 93 insertions(+), 50 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 8dc44cbb3e09..9e208d300647 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -108,54 +108,109 @@ static int is_cpufreq_valid(int cpu) return !cpufreq_get_policy(&policy, cpu); } -/** - * get_cpu_frequency - get the absolute value of frequency from level. - * @cpu: cpu for which frequency is fetched. - * @level: level of frequency, equals cooling state of cpu cooling device - * e.g level=0 --> 1st MAX FREQ, level=1 ---> 2nd MAX FREQ, .... etc - */ -static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) +enum cpufreq_cooling_property { + GET_LEVEL, + GET_FREQ, + GET_MAXL, +}; + +/* + * this is the common function to + * 1. get maximum cpu cooling states + * 2. translate frequency to cooling state + * 3. translate cooling state to frequency + * Note that the code may be not in good shape + * but it is written in this way in order to: + * a) reduce duplicate code as most of the code can be shared. + * b) make sure the logic is consistent when translating between + * cooling states and frequencies. +*/ +static int get_property(unsigned int cpu, unsigned long input, + unsigned int* output, enum cpufreq_cooling_property property) { - int ret = 0, i = 0; - unsigned long level_index; - bool descend = false; + int i, j; + unsigned long max_level = 0, level; + unsigned int freq = CPUFREQ_ENTRY_INVALID; + int descend = -1; struct cpufreq_frequency_table *table = cpufreq_frequency_get_table(cpu); + + if (!output) + return -EINVAL; + if (!table) - return ret; + return -EINVAL; - while (table[i].frequency != CPUFREQ_TABLE_END) { + + for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { + /* ignore invalid entries */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) continue; - /*check if table in ascending or descending order*/ - if ((table[i + 1].frequency != CPUFREQ_TABLE_END) && - (table[i + 1].frequency < table[i].frequency) - && !descend) { - descend = true; - } + /* ignore duplicate entry */ + if (freq == table[i].frequency) + continue; + + /* get the frequency order */ + if (freq != CPUFREQ_ENTRY_INVALID && descend != -1) + descend = !!(freq > table[i].frequency); - /*return if level matched and table in descending order*/ - if (descend && i == level) - return table[i].frequency; - i++; + freq = table[i].frequency; + max_level++; } - i--; - if (level > i || descend) - return ret; - level_index = i - level; + /* get max level */ + if (property == GET_MAXL) { + *output = (unsigned int)max_level; + return 0; + } - /*Scan the table in reverse order and match the level*/ - while (i >= 0) { + if (property == GET_FREQ) + level = descend ? input : (max_level - input -1); + + + for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { + /* ignore invalid entry */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) continue; - /*return if level matched*/ - if (i == level_index) - return table[i].frequency; - i--; + + /* ignore duplicate entry */ + if (freq == table[i].frequency) + continue; + + /* now we have a valid frequency entry */ + freq = table[i].frequency; + + if (property == GET_LEVEL && (unsigned int)input == freq) { + /* get level by frequency */ + *output = descend ? j : (max_level - j - 1); + return 0; + } + if (property == GET_FREQ && level == j) { + /* get frequency by level */ + *output = freq; + return 0; + } + j++; } - return ret; + return -EINVAL; +} + +/** + * get_cpu_frequency - get the absolute value of frequency from level. + * @cpu: cpu for which frequency is fetched. + * @level: level of frequency, equals cooling state of cpu cooling device + * e.g level=0 --> 1st MAX FREQ, level=1 ---> 2nd MAX FREQ, .... etc + */ +static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) +{ + int ret = 0; + unsigned int freq; + + ret = get_property(cpu, level, &freq, GET_FREQ); + if (ret) + return 0; + return freq; } /** @@ -237,29 +292,17 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; struct cpumask *maskPtr = &cpufreq_device->allowed_cpus; unsigned int cpu; - struct cpufreq_frequency_table *table; unsigned long count = 0; - int i = 0; + int ret; cpu = cpumask_any(maskPtr); - table = cpufreq_frequency_get_table(cpu); - if (!table) { - *state = 0; - return 0; - } - for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { - if (table[i].frequency == CPUFREQ_ENTRY_INVALID) - continue; - count++; - } + ret = get_property(cpu, 0, (unsigned int *)&count, GET_MAXL); - if (count > 0) { - *state = --count; - return 0; - } + if (count > 0) + *state = count; - return -EINVAL; + return ret; } /** -- cgit v1.2.3 From 57df8106932b57427df1eaaa13871857f75b1194 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Fri, 8 Feb 2013 14:52:06 +0800 Subject: Thermal: exynos: fix cooling state translation Signed-off-by: Zhang Rui Tested-by: Amit Daniel kachhap --- drivers/thermal/cpu_cooling.c | 11 +++++++++++ drivers/thermal/exynos_thermal.c | 24 ++---------------------- include/linux/cpu_cooling.h | 7 +++++++ include/linux/thermal.h | 5 ++++- 4 files changed, 24 insertions(+), 23 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 9e208d300647..e03891b03c9b 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -196,6 +196,17 @@ static int get_property(unsigned int cpu, unsigned long input, return -EINVAL; } +unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) +{ + unsigned int val; + + if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) + return THERMAL_CSTATE_INVALID; + return (unsigned long)val; +} + +EXPORT_SYMBOL(cpufreq_cooling_get_level); + /** * get_cpu_frequency - get the absolute value of frequency from level. * @cpu: cpu for which frequency is fetched. diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 46568c078dee..541257888c3e 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -242,26 +242,6 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal, return ret; } -static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq) -{ - int i = 0, ret = -EINVAL; - struct cpufreq_frequency_table *table = NULL; -#ifdef CONFIG_CPU_FREQ - table = cpufreq_frequency_get_table(cpu); -#endif - if (!table) - return ret; - - while (table[i].frequency != CPUFREQ_TABLE_END) { - if (table[i].frequency == CPUFREQ_ENTRY_INVALID) - continue; - if (table[i].frequency == freq) - return i; - i++; - } - return ret; -} - /* Bind callback functions for thermal zone */ static int exynos_bind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) @@ -288,8 +268,8 @@ static int exynos_bind(struct thermal_zone_device *thermal, /* Bind the thermal zone to the cpufreq cooling device */ for (i = 0; i < tab_size; i++) { clip_data = (struct freq_clip_table *)&(tab_ptr[i]); - level = exynos_get_frequency_level(0, clip_data->freq_clip_max); - if (level < 0) + level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max); + if (level == THERMAL_CSTATE_INVALID) return 0; switch (GET_ZONE(i)) { case MONITOR_ZONE: diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index 40b4ef54cc7d..bc479b1e0fd9 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -42,6 +42,8 @@ struct thermal_cooling_device *cpufreq_cooling_register( * @cdev: thermal cooling device pointer. */ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); + +unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int); #else /* !CONFIG_CPU_THERMAL */ static inline struct thermal_cooling_device *cpufreq_cooling_register( const struct cpumask *clip_cpus) @@ -53,6 +55,11 @@ static inline void cpufreq_cooling_unregister( { return; } +static inline unsigned long cpufreq_cooling_get_level(unsigned int, + unsigned int) +{ + return THERMAL_CSTATE_INVALID; +} #endif /* CONFIG_CPU_THERMAL */ #endif /* __CPU_COOLING_H__ */ diff --git a/include/linux/thermal.h b/include/linux/thermal.h index f0bd7f90a90d..5a3b428daaab 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -33,8 +33,11 @@ #define THERMAL_MAX_TRIPS 12 #define THERMAL_NAME_LENGTH 20 +/* invalid cooling state */ +#define THERMAL_CSTATE_INVALID -1UL + /* No upper/lower limit requirement */ -#define THERMAL_NO_LIMIT -1UL +#define THERMAL_NO_LIMIT THERMAL_CSTATE_INVALID /* Unit conversion macros */ #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \ -- cgit v1.2.3 From bde00663098db4d6a25681351ffa4a87eff3d0b4 Mon Sep 17 00:00:00 2001 From: "Laurent Navet [Mali]" Date: Tue, 12 Mar 2013 10:47:50 +0000 Subject: drivers: thermal: cpu_cooling: fix checkpatch warning - WARNING: Avoid CamelCase: Signed-off-by: Laurent Navet Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 8dc44cbb3e09..be2e6b0e5349 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -168,8 +168,8 @@ static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, unsigned long cooling_state) { unsigned int cpuid, clip_freq; - struct cpumask *maskPtr = &cpufreq_device->allowed_cpus; - unsigned int cpu = cpumask_any(maskPtr); + struct cpumask *mask = &cpufreq_device->allowed_cpus; + unsigned int cpu = cpumask_any(mask); /* Check if the old cooling action is same as new cooling action */ @@ -184,7 +184,7 @@ static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, cpufreq_device->cpufreq_val = clip_freq; notify_device = cpufreq_device; - for_each_cpu(cpuid, maskPtr) { + for_each_cpu(cpuid, mask) { if (is_cpufreq_valid(cpuid)) cpufreq_update_policy(cpuid); } @@ -235,13 +235,13 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, unsigned long *state) { struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; - struct cpumask *maskPtr = &cpufreq_device->allowed_cpus; + struct cpumask *mask = &cpufreq_device->allowed_cpus; unsigned int cpu; struct cpufreq_frequency_table *table; unsigned long count = 0; int i = 0; - cpu = cpumask_any(maskPtr); + cpu = cpumask_any(mask); table = cpufreq_frequency_get_table(cpu); if (!table) { *state = 0; -- cgit v1.2.3 From 4f89038f177462dbd2fd911297fd004226176db7 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 17 Apr 2013 07:18:28 +0000 Subject: Thermal: cpufreq cooling: endian bug in cpufreq_get_max_state() 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 Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 5f5c780bcd90..768b508f0d69 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -303,12 +303,12 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; struct cpumask *mask = &cpufreq_device->allowed_cpus; unsigned int cpu; - unsigned long count = 0; + unsigned int count = 0; int ret; cpu = cpumask_any(mask); - ret = get_property(cpu, 0, (unsigned int *)&count, GET_MAXL); + ret = get_property(cpu, 0, &count, GET_MAXL); if (count > 0) *state = count; -- cgit v1.2.3 From 25c52afe1c8a50390d822d89c38cd28d4c19bd8a Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:11:54 +0000 Subject: thermal: cpu_cooling: remove unused headers Remove some unused header files. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 768b508f0d69..7950a41ab934 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -20,10 +20,8 @@ * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include #include #include -#include #include #include #include -- cgit v1.2.3 From 3b3c07485579b9a4ecaee718667c87f59c603686 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:11:56 +0000 Subject: thermal: cpu_cooling: fix kernel_doc for cpufreq_cooling_device Simple fixes for making kernel_doc happy about struct cpufreq_cooling_device. Includes also a minor spelling fix. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 7950a41ab934..82829d674720 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -29,11 +29,11 @@ #include /** - * struct cpufreq_cooling_device + * struct cpufreq_cooling_device - data for cooling device with cpufreq * @id: unique integer value corresponding to each cpufreq_cooling_device * registered. - * @cool_dev: thermal_cooling_device pointer to keep track of the the - * egistered cooling device. + * @cool_dev: thermal_cooling_device pointer to keep track of the + * registered cooling device. * @cpufreq_state: integer value representing the current state of cpufreq * cooling devices. * @cpufreq_val: integer value representing the absolute value of the clipped -- cgit v1.2.3 From 243dbd9c606ff4f925496022762c8cf5b6e4a85e Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:11:57 +0000 Subject: thermal: cpu_cooling: use EXPORT_SYMBOL_GPL Restrict the usage to GPL modules. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 82829d674720..fe0a8f593283 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -202,8 +202,7 @@ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) return THERMAL_CSTATE_INVALID; return (unsigned long)val; } - -EXPORT_SYMBOL(cpufreq_cooling_get_level); +EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); /** * get_cpu_frequency - get the absolute value of frequency from level. @@ -416,7 +415,7 @@ struct thermal_cooling_device *cpufreq_cooling_register( mutex_unlock(&cooling_cpufreq_lock); return cool_dev; } -EXPORT_SYMBOL(cpufreq_cooling_register); +EXPORT_SYMBOL_GPL(cpufreq_cooling_register); /** * cpufreq_cooling_unregister - function to remove cpufreq cooling device. @@ -440,4 +439,4 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) release_idr(&cpufreq_idr, cpufreq_dev->id); kfree(cpufreq_dev); } -EXPORT_SYMBOL(cpufreq_cooling_unregister); +EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister); -- cgit v1.2.3 From 4469b99743d296e24aefc5f8ed7df1bc9cfbbac8 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:11:58 +0000 Subject: thermal: cpu_cooling: remove compiler warning 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 Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index fe0a8f593283..14c64b2a1466 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -127,7 +127,7 @@ static int get_property(unsigned int cpu, unsigned long input, unsigned int* output, enum cpufreq_cooling_property property) { int i, j; - unsigned long max_level = 0, level; + unsigned long max_level = 0, level = 0; unsigned int freq = CPUFREQ_ENTRY_INVALID; int descend = -1; struct cpufreq_frequency_table *table = -- cgit v1.2.3 From 82b9ee402fa9867edde8dbf17a55f615f80bc3ba Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:00 +0000 Subject: thermal: cpu_cooling: fix kernel doc for is_cpufreq_valid Update documentation for is_cpufreq_valid function so that kernel-doc does not complain about return value. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 14c64b2a1466..b8b8a1ef85ed 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -97,8 +97,14 @@ static void release_idr(struct idr *idr, int id) /* Below code defines functions to be used for cpufreq as cooling device */ /** - * is_cpufreq_valid - function to check if a cpu has frequency transition policy. + * is_cpufreq_valid - function to check frequency transitioning capability. * @cpu: cpu for which check is needed. + * + * This function will check the current state of the system if + * it is capable of changing the frequency for a given @cpu. + * + * Return: 0 if the system is not currently capable of changing + * the frequency of given cpu. !0 in case the frequency is changeable. */ static int is_cpufreq_valid(int cpu) { -- cgit v1.2.3 From 2d6f28fedcd2842635a02b29e3823ba9881d5086 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:01 +0000 Subject: thermal: cpu_cooling: add documentation for get_property 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 Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index b8b8a1ef85ed..084ef0096cc9 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -118,8 +118,14 @@ enum cpufreq_cooling_property { GET_MAXL, }; -/* - * this is the common function to +/** + * get_property - fetch a property of interest for a give cpu. + * @cpu: cpu for which the property is required + * @input: query parameter + * @output: query return + * @property: type of query (frequency, level, max level) + * + * This is the common function to * 1. get maximum cpu cooling states * 2. translate frequency to cooling state * 3. translate cooling state to frequency @@ -128,7 +134,9 @@ enum cpufreq_cooling_property { * a) reduce duplicate code as most of the code can be shared. * b) make sure the logic is consistent when translating between * cooling states and frequencies. -*/ + * + * Return: 0 on success, -EINVAL when invalid parameters are passed. + */ static int get_property(unsigned int cpu, unsigned long input, unsigned int* output, enum cpufreq_cooling_property property) { -- cgit v1.2.3 From 44952d338ad73439b993c7a09a93a3a688e49768 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:05 +0000 Subject: thermal: cpu_cooling: document cpufreq_get_cooling_level Add documentation for cpufreq_get_cooling_level. As this is an exported function, it has to be documented. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 084ef0096cc9..f1a041205a0e 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -208,6 +208,17 @@ static int get_property(unsigned int cpu, unsigned long input, return -EINVAL; } +/** + * cpufreq_cooling_get_level - for a give cpu, return the cooling level. + * @cpu: cpu for which the level is required + * @freq: the frequency of interest + * + * This function will match the cooling level corresponding to the + * requested @freq and return it. + * + * Return: The matched cooling level on success or THERMAL_CSTATE_INVALID + * otherwise. + */ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) { unsigned int val; -- cgit v1.2.3 From 41518c41dd6f36a0a951d1850e286a44773f75ca Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:07 +0000 Subject: thermal: cpu_cooling: improve documentation for get_cpu_frequency Fix kernel-doc warning on get_cpu_frequency and improve documentation comments. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index f1a041205a0e..73944a34fdb9 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -232,8 +232,14 @@ EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); /** * get_cpu_frequency - get the absolute value of frequency from level. * @cpu: cpu for which frequency is fetched. - * @level: level of frequency, equals cooling state of cpu cooling device + * @level: cooling level + * + * This function matches cooling level with frequency. Based on a cooling level + * of frequency, equals cooling state of cpu cooling device, it will return + * the corresponding frequency. * e.g level=0 --> 1st MAX FREQ, level=1 ---> 2nd MAX FREQ, .... etc + * + * Return: 0 on error, the corresponding frequency otherwise. */ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) { -- cgit v1.2.3 From 4b33deb5470cda8268d684da6d448c081b6bf641 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:08 +0000 Subject: thermal: cpu_cooling: update documentation for cpufreq_apply_cooling Update kernel-doc comments for cpufreq_apply_cooling function. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 73944a34fdb9..1ec1591e3fd3 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -257,6 +257,12 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) * @cpufreq_device: cpufreq_cooling_device pointer containing frequency * clipping data. * @cooling_state: value of the cooling state. + * + * Function used to make sure the cpufreq layer is aware of current thermal + * limits. The limits are applied by updating the cpufreq policy. + * + * Return: 0 on success, an error code otherwise (-EINVAL in case wrong + * cooling state). */ static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, unsigned long cooling_state) -- cgit v1.2.3 From bab3055472b44f0897fff88f9c8d3fc55e5d7685 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:09 +0000 Subject: thermal: cpu_cooling: update documentation for cpufreq_thermal_notifier Update kernel-doc comment and documentation for cpufreq_thermal_notifier. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 1ec1591e3fd3..eb62ffaad6a2 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -299,6 +299,12 @@ static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, * @nb: struct notifier_block * with callback info. * @event: value showing cpufreq event for which this function invoked. * @data: callback-specific data + * + * Callback to highjack the notification on cpufreq policy transition. + * Every time there is a change in policy, we will intercept and + * update the cpufreq policy with thermal constraints. + * + * Return: 0 (success) */ static int cpufreq_thermal_notifier(struct notifier_block *nb, unsigned long event, void *data) -- cgit v1.2.3 From 62c00421b31424489435619545a53802eab07f3e Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:12 +0000 Subject: thermal: cpu_cooling: update documentation for cpufreq_get_max_state Update documentation for cpufreq_get_max_state callback. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index eb62ffaad6a2..329653caba21 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -336,6 +336,11 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, * cpufreq_get_max_state - callback function to get the max cooling state. * @cdev: thermal cooling device pointer. * @state: fill this variable with the max cooling state. + * + * Callback for the thermal cooling device to return the cpufreq + * max cooling state. + * + * Return: 0 on success, an error code otherwise. */ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, unsigned long *state) -- cgit v1.2.3 From 3672552dc0c5f6ffacb611a7ddb4ddbd8b3adb68 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:13 +0000 Subject: thermal: cpu_cooling: update documentation for cpufreq_get_cur_state Update documentation for cpufreq_get_cur_state callback. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 329653caba21..4318a7d84df4 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -365,6 +365,11 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, * cpufreq_get_cur_state - callback function to get the current cooling state. * @cdev: thermal cooling device pointer. * @state: fill this variable with the current cooling state. + * + * Callback for the thermal cooling device to return the cpufreq + * current cooling state. + * + * Return: 0 on success, an error code otherwise. */ static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, unsigned long *state) -- cgit v1.2.3 From 56e05fdb6d1fe02b7d28391332cf65a77bffd691 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:14 +0000 Subject: thermal: cpu_cooling: update documentation for cpufreq_set_cur_state Update documentation for cpufreq_set_cur_state callback. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 4318a7d84df4..aa9c38b1c3ac 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -384,6 +384,11 @@ static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, * cpufreq_set_cur_state - callback function to set the current cooling state. * @cdev: thermal cooling device pointer. * @state: set this variable to the current cooling state. + * + * Callback for the thermal cooling device to change the cpufreq + * current cooling state. + * + * Return: 0 on success, an error code otherwise. */ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) -- cgit v1.2.3 From 12cb08ba50b73be97e555bcdf84e8f21a196794b Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:15 +0000 Subject: thermal: cpu_cooling: update kernel-doc for cpufreq_cooling_register Add proper documentation for exported function cpufreq_cooling_register. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index aa9c38b1c3ac..9a1d82ef491e 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -413,6 +413,13 @@ static struct notifier_block thermal_cpufreq_notifier_block = { /** * cpufreq_cooling_register - function to create cpufreq cooling device. * @clip_cpus: cpumask of cpus where the frequency constraints will happen. + * + * This interface function registers the cpufreq cooling device with the name + * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq + * cooling devices. + * + * Return: a valid struct thermal_cooling_device pointer on success, + * on failure, it returns a corresponding ERR_PTR(). */ struct thermal_cooling_device *cpufreq_cooling_register( const struct cpumask *clip_cpus) -- cgit v1.2.3 From 135266b4ea4567419c475354437b7aaa96023d9e Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:16 +0000 Subject: thermal: cpu_cooling: update kernel-doc comment for cpufreq_cooling_unregister Update comments for this exported function. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 9a1d82ef491e..b4161cfce4a8 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -485,6 +485,8 @@ EXPORT_SYMBOL_GPL(cpufreq_cooling_register); /** * cpufreq_cooling_unregister - function to remove cpufreq cooling device. * @cdev: thermal cooling device pointer. + * + * This interface function unregisters the "thermal-cpufreq-%x" cooling device. */ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) { -- cgit v1.2.3 From 99871a714b0a9429e960629fbc2c6c20c57ea484 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:17 +0000 Subject: thermal: cpu_cooling: use snprintf instead of sprintf Limit the amount of bytes written to dev_name by secure writing with snprintf. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index b4161cfce4a8..a04269de1570 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -458,7 +458,8 @@ struct thermal_cooling_device *cpufreq_cooling_register( return ERR_PTR(-EINVAL); } - sprintf(dev_name, "thermal-cpufreq-%d", cpufreq_dev->id); + snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", + cpufreq_dev->id); cool_dev = thermal_cooling_device_register(dev_name, cpufreq_dev, &cpufreq_cooling_ops); -- cgit v1.2.3 From 2d9bf71c12be9caadd9a8276a78f3a3df8e9e852 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:18 +0000 Subject: thermal: cpu_cooling: remove not needed curl brackets Just for style purposes, remove extra curl brackets. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index a04269de1570..aa6875b272cb 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -497,10 +497,10 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) cpufreq_dev_count--; /* Unregister the notifier for the last cpufreq cooling device */ - if (cpufreq_dev_count == 0) { + if (cpufreq_dev_count == 0) cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); - } + mutex_unlock(&cooling_cpufreq_lock); thermal_cooling_device_unregister(cpufreq_dev->cool_dev); -- cgit v1.2.3 From 67d0b2a8267caa4e653714bec79013fa6b7dd508 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:19 +0000 Subject: thermal: cpu_cooling: remove unused symbols The list is not needed so far. Thus removing it. Signed-off-by: Eduardo Valentin Acked-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index aa6875b272cb..a294921be650 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -39,11 +39,9 @@ * @cpufreq_val: integer value representing the absolute value of the clipped * frequency. * @allowed_cpus: all the cpus involved for this cpufreq_cooling_device. - * @node: list_head to link all cpufreq_cooling_device together. * * This structure is required for keeping information of each - * cpufreq_cooling_device registered as a list whose head is represented by - * cooling_cpufreq_list. In order to prevent corruption of this list a + * cpufreq_cooling_device registered. In order to prevent corruption of this a * mutex lock cooling_cpufreq_lock is used. */ struct cpufreq_cooling_device { @@ -52,9 +50,7 @@ struct cpufreq_cooling_device { unsigned int cpufreq_state; unsigned int cpufreq_val; struct cpumask allowed_cpus; - struct list_head node; }; -static LIST_HEAD(cooling_cpufreq_list); static DEFINE_IDR(cpufreq_idr); static DEFINE_MUTEX(cooling_cpufreq_lock); -- cgit v1.2.3 From 79d264016ac011b74497b553022d2fc45bf9d9f2 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:11:55 +0000 Subject: thermal: cpu_cooling: remove trailing white spaces Remove unnecessary white spaces. Signed-off-by: Eduardo Valentin Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index a294921be650..4b9be532cb14 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -142,14 +142,13 @@ static int get_property(unsigned int cpu, unsigned long input, int descend = -1; struct cpufreq_frequency_table *table = cpufreq_frequency_get_table(cpu); - + if (!output) return -EINVAL; if (!table) return -EINVAL; - for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { /* ignore invalid entries */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) -- cgit v1.2.3 From 79491e53dcd73175473e3293a574f5e006b468be Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:11:59 +0000 Subject: thermal: cpu_cooling: standardize end of function 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 Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 4b9be532cb14..bb32ca0056c4 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -64,6 +64,11 @@ static struct cpufreq_cooling_device *notify_device; * get_idr - function to get a unique id. * @idr: struct idr * handle used to create a id. * @id: int * value generated by this function. + * + * This function will populate @id with an unique + * id, using the idr API. + * + * Return: 0 on success, an error code on failure. */ static int get_idr(struct idr *idr, int *id) { @@ -75,6 +80,7 @@ static int get_idr(struct idr *idr, int *id) if (unlikely(ret < 0)) return ret; *id = ret; + return 0; } @@ -105,6 +111,7 @@ static void release_idr(struct idr *idr, int id) static int is_cpufreq_valid(int cpu) { struct cpufreq_policy policy; + return !cpufreq_get_policy(&policy, cpu); } @@ -200,6 +207,7 @@ static int get_property(unsigned int cpu, unsigned long input, } j++; } + return -EINVAL; } @@ -220,6 +228,7 @@ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) return THERMAL_CSTATE_INVALID; + return (unsigned long)val; } EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); @@ -244,6 +253,7 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) ret = get_property(cpu, level, &freq, GET_FREQ); if (ret) return 0; + return freq; } @@ -372,6 +382,7 @@ static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; *state = cpufreq_device->cpufreq_state; + return 0; } @@ -474,6 +485,7 @@ struct thermal_cooling_device *cpufreq_cooling_register( cpufreq_dev_count++; mutex_unlock(&cooling_cpufreq_lock); + return cool_dev; } EXPORT_SYMBOL_GPL(cpufreq_cooling_register); -- cgit v1.2.3 From 1b9e35265903c2e0e484dc224e8f7de506e3353f Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:02 +0000 Subject: thermal: cpu_cooling: standardize comment style 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 Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index bb32ca0056c4..2d94ffa3230d 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -323,7 +323,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, if (cpumask_test_cpu(policy->cpu, ¬ify_device->allowed_cpus)) max_freq = notify_device->cpufreq_val; - /* Never exceed user_policy.max*/ + /* Never exceed user_policy.max */ if (max_freq > policy->user_policy.max) max_freq = policy->user_policy.max; @@ -333,9 +333,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, return 0; } -/* - * cpufreq cooling device callback functions are defined below - */ +/* cpufreq cooling device callback functions are defined below */ /** * cpufreq_get_max_state - callback function to get the max cooling state. @@ -437,9 +435,9 @@ struct thermal_cooling_device *cpufreq_cooling_register( int ret = 0, i; struct cpufreq_policy policy; - /*Verify that all the clip cpus have same freq_min, freq_max limit*/ + /* Verify that all the clip cpus have same freq_min, freq_max limit */ for_each_cpu(i, clip_cpus) { - /*continue if cpufreq policy not found and not return error*/ + /* continue if cpufreq policy not found and not return error */ if (!cpufreq_get_policy(&policy, i)) continue; if (min == 0 && max == 0) { -- cgit v1.2.3 From d8892a01b13c8ea3ad74fb0c56beb96e92a2c65e Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:03 +0000 Subject: thermal: cpu_cooling: align on open parenthesis Improve code readiness by remove checkpatch.pl warnings on get_property function. Signed-off-by: Eduardo Valentin Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 2d94ffa3230d..34d807bc5c3f 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -141,7 +141,8 @@ enum cpufreq_cooling_property { * Return: 0 on success, -EINVAL when invalid parameters are passed. */ static int get_property(unsigned int cpu, unsigned long input, - unsigned int* output, enum cpufreq_cooling_property property) + unsigned int *output, + enum cpufreq_cooling_property property) { int i, j; unsigned long max_level = 0, level = 0; -- cgit v1.2.3 From e45a6430025811c9ffc8932389adf5912f8ba4fd Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:04 +0000 Subject: thermal: cpu_cooling: remove trailing blank line Remove unnecessary blank line. Signed-off-by: Eduardo Valentin Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 34d807bc5c3f..be04bb419fd7 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -183,7 +183,6 @@ static int get_property(unsigned int cpu, unsigned long input, if (property == GET_FREQ) level = descend ? input : (max_level - input -1); - for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { /* ignore invalid entry */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) -- cgit v1.2.3 From ef5e2124ec3d54182bd826411d864e0e28fc00d4 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:06 +0000 Subject: thermal: cpu_cooling: remove checkpatch.pl warning Simple code style fix. Signed-off-by: Eduardo Valentin Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index be04bb419fd7..04a952079eca 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -181,7 +181,7 @@ static int get_property(unsigned int cpu, unsigned long input, } if (property == GET_FREQ) - level = descend ? input : (max_level - input -1); + level = descend ? input : (max_level - input - 1); for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { /* ignore invalid entry */ -- cgit v1.2.3 From 5fda7f680a44c65ce44fbe37f254b8a82f49d241 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Wed, 17 Apr 2013 17:12:11 +0000 Subject: thermal: cpu_cooling: alignment improvements Improve code readiness by changing alignments so that they match open parenthesis, like checkpatch.pl --strict suggests. Signed-off-by: Eduardo Valentin Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers/thermal/cpu_cooling.c') diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 04a952079eca..c94bf2e5de62 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -270,7 +270,7 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) * cooling state). */ static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, - unsigned long cooling_state) + unsigned long cooling_state) { unsigned int cpuid, clip_freq; struct cpumask *mask = &cpufreq_device->allowed_cpus; @@ -312,7 +312,7 @@ static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, * Return: 0 (success) */ static int cpufreq_thermal_notifier(struct notifier_block *nb, - unsigned long event, void *data) + unsigned long event, void *data) { struct cpufreq_policy *policy = data; unsigned long max_freq = 0; @@ -425,8 +425,8 @@ static struct notifier_block thermal_cpufreq_notifier_block = { * Return: a valid struct thermal_cooling_device pointer on success, * on failure, it returns a corresponding ERR_PTR(). */ -struct thermal_cooling_device *cpufreq_cooling_register( - const struct cpumask *clip_cpus) +struct thermal_cooling_device * +cpufreq_cooling_register(const struct cpumask *clip_cpus) { struct thermal_cooling_device *cool_dev; struct cpufreq_cooling_device *cpufreq_dev = NULL; @@ -445,12 +445,12 @@ struct thermal_cooling_device *cpufreq_cooling_register( max = policy.cpuinfo.max_freq; } else { if (min != policy.cpuinfo.min_freq || - max != policy.cpuinfo.max_freq) + max != policy.cpuinfo.max_freq) return ERR_PTR(-EINVAL); } } cpufreq_dev = kzalloc(sizeof(struct cpufreq_cooling_device), - GFP_KERNEL); + GFP_KERNEL); if (!cpufreq_dev) return ERR_PTR(-ENOMEM); @@ -466,7 +466,7 @@ struct thermal_cooling_device *cpufreq_cooling_register( cpufreq_dev->id); cool_dev = thermal_cooling_device_register(dev_name, cpufreq_dev, - &cpufreq_cooling_ops); + &cpufreq_cooling_ops); if (!cool_dev) { release_idr(&cpufreq_idr, cpufreq_dev->id); kfree(cpufreq_dev); @@ -479,7 +479,7 @@ struct thermal_cooling_device *cpufreq_cooling_register( /* Register the notifier for first cpufreq cooling device */ if (cpufreq_dev_count == 0) cpufreq_register_notifier(&thermal_cpufreq_notifier_block, - CPUFREQ_POLICY_NOTIFIER); + CPUFREQ_POLICY_NOTIFIER); cpufreq_dev_count++; mutex_unlock(&cooling_cpufreq_lock); @@ -504,8 +504,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) /* Unregister the notifier for the last cpufreq cooling device */ if (cpufreq_dev_count == 0) cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, - CPUFREQ_POLICY_NOTIFIER); - + CPUFREQ_POLICY_NOTIFIER); mutex_unlock(&cooling_cpufreq_lock); thermal_cooling_device_unregister(cpufreq_dev->cool_dev); -- cgit v1.2.3