Skip to contentSkip to conversation

Use sampling_rate_min/max if value beyond limit is written to ondemand/sampling_rate

PATCH New Holger Macht 1 participant 1 message May 30, 2006 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use sampling_rate_min/max if value beyond limit is written to ondemand/sampling_rate

If a value lower then sampling_rate_min or greater than sampling_rate_max is written to ondemand/sampling_rate, the request ist ignored and a write error is thrown. Patch takes sampling_rate_min/max into account if a value beyond the limit is written.

This leads to consistent behaviour between ondemand/sampling_rate and the userspace governor scaling_setspeed interface, where one can write a frequency lower than scaling_min_freq and scaling_min_freq is actually used instead of the setting being ignored.

---
 cpufreq_ondemand.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq_ondemand.c +6 -1
@@ -155,11 +155,16 @@ static ssize_t store_sampling_rate(struc
 	ret = sscanf (buf, "%u", &input);
 
 	mutex_lock(&dbs_mutex);
-	if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) {
+	if (ret != 1) {
 		mutex_unlock(&dbs_mutex);
 		return -EINVAL;
 	}
 
+	if (input > MAX_SAMPLING_RATE)
+		input = MAX_SAMPLING_RATE;
+	else if (input < MIN_SAMPLING_RATE)
+		input = MIN_SAMPLING_RATE;
+
 	dbs_tuners_ins.sampling_rate = input;
 	mutex_unlock(&dbs_mutex);