Yi Yang
53391fa20c
cpufreq: fix obvious condition statement error
...
The function __cpufreq_set_policy in file drivers/cpufreq/cpufreq.c
has a very obvious error:
if (policy->min > data->min && policy->min > policy->max) {
ret = -EINVAL;
goto error_out;
}
This condtion statement is wrong because it returns -EINVAL only if
policy->min is greater than policy->max (in this case,
"policy->min > data->min" is true for ever.). In fact, it should
return -EINVAL as well if policy->max is less than data->min.
The correct condition should be:
if (policy->min > data->max || policy->max < data->min) {
The following test result testifies the above conclusion:
Before applying this patch:
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
2394000 1596000
[root@yangyi-dev /]# echo 1596000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1596000
[root@yangyi-dev /]# echo "2000000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
-bash: echo: write error: Invalid argument
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1596000
[root@yangyi-dev /]# echo "0" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[root@yangyi-dev /]# echo "1595000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[root@yangyi-dev /]#
After applying this patch:
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
2394000 1596000
[root@yangyi-dev /]# echo 1596000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[root@yangyi-dev /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1596000
[root@localhost /]# echo "2000000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
-bash: echo: write error: Invalid argument
[root@localhost /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1596000
[root@localhost /]# echo "0" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
-bash: echo: write error: Invalid argument
[root@localhost /]# echo "1595000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
-bash: echo: write error: Invalid argument
[root@localhost /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[root@localhost /]# echo "1596000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[root@localhost /]# echo "2394000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[root@localhost /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
2394000
[root@localhost /]
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:34 +01:00
..
2008-01-30 13:32:41 +01:00
2008-01-29 08:48:17 +11:00
2008-01-28 15:00:15 -08:00
2008-01-28 23:14:35 +01:00
2008-01-29 21:55:18 +01:00
2008-01-10 22:24:43 -08:00
2008-01-29 08:52:50 +11:00
2008-01-30 13:33:31 +01:00
2008-01-28 15:08:07 -08:00
2008-01-30 13:33:34 +01:00
2008-01-24 20:40:40 -08:00
2008-01-26 14:11:17 +01:00
2008-01-24 20:40:05 -08:00
2008-01-24 20:40:40 -08:00
2008-01-11 18:29:22 -06:00
2008-01-30 13:33:32 +01:00
2008-01-28 14:51:23 +01:00
2008-01-22 07:21:38 -05:00
2008-01-28 13:21:30 +00:00
2008-01-28 10:37:06 +01:00
2008-01-25 17:19:08 -08:00
2008-01-29 22:54:01 +11:00
2008-01-30 13:31:24 +01:00
2008-01-25 08:35:13 -08:00
2008-01-30 13:31:27 +01:00
2007-12-31 23:11:11 +00:00
2008-01-30 13:31:02 +01:00
2008-01-27 18:14:47 +01:00
2008-01-24 20:40:40 -08:00
2008-01-27 18:14:51 +01:00
2008-01-28 10:36:50 +01:00
2008-01-28 10:59:09 +00:00
2008-01-24 20:40:08 -08:00
2008-01-29 08:51:32 +11:00
2008-01-24 20:40:06 -08:00
2008-01-30 09:54:54 +11:00
2008-01-28 14:58:20 -08:00
2007-12-17 19:28:15 -08:00
2008-01-24 20:40:40 -08:00
2008-01-26 15:07:54 +00:00
2008-01-30 13:32:31 +01:00
2008-01-24 20:40:44 -08:00
2007-12-23 12:54:37 -08:00
2008-01-28 23:21:18 +01:00
2008-01-29 08:52:50 +11:00
2008-01-28 15:08:32 -08:00
2008-01-28 15:08:07 -08:00
2008-01-29 08:52:50 +11:00
2008-01-26 15:07:52 +00:00
2008-01-28 15:09:52 -08:00
2008-01-24 20:40:43 -08:00
2008-01-28 13:21:38 +00:00
2008-01-28 13:21:21 +00:00
2008-01-27 18:14:47 +01:00
2008-01-25 20:41:30 +00:00