diff options
author | Zhang Rui <rui.zhang@intel.com> | 2013-04-27 09:28:56 +0800 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-04-27 09:28:56 +0800 |
commit | 8f578bfefdd13d28d5baf3345405c46b101fe2f5 (patch) | |
tree | bc5288ac0f07ba92943b48b8d490c7c5825a3fcd /drivers/thermal | |
parent | 09681dfa554743041a3dbd9ca87a320c908c37f4 (diff) | |
parent | d44ada516277f5d58b9bda2ea0a2c9503b316bbf (diff) |
Merge branch 'cpu_cooling-doc-comments-update' of .git into next
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/cpu_cooling.c | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index a294921be650..c94bf2e5de62 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); } @@ -134,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; @@ -142,14 +150,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) @@ -174,8 +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 */ @@ -201,6 +207,7 @@ static int get_property(unsigned int cpu, unsigned long input, } j++; } + return -EINVAL; } @@ -221,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); @@ -245,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; } @@ -261,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; @@ -303,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; @@ -314,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; @@ -324,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. @@ -373,6 +380,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; } @@ -417,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; @@ -427,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) { @@ -437,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); @@ -458,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); @@ -471,10 +479,11 @@ 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); + return cool_dev; } EXPORT_SYMBOL_GPL(cpufreq_cooling_register); @@ -495,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); |