aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2012-10-25 19:50:43 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-14 18:35:05 -0500
commit12e26265e6225bf93b2fdc70399774b31e2dd980 (patch)
tree623fba6c1690ab23f8aeed388be9dfb3506ef07e /drivers
parentc5b4a1c15da3e6f472c6ff1a085a1134d18a1464 (diff)
PM / devfreq: fix sscanf handling for writable sysfs entries
sscanf returns 0 when an invalid parameter like: echo -n "a">min_freq is attempted. Returning back the return result(0) will cause the command not to return back to command prompt. Instead, just return -EINVAL when sscanf does not return 1. This is done for min_freq, max_freq and polling_interval Signed-off-by: Nishanth Menon <nm@ti.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/devfreq/devfreq.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index a42f69b34eb2..79a7343c28a6 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -496,12 +496,11 @@ static ssize_t store_polling_interval(struct device *dev,
496 496
497 ret = sscanf(buf, "%u", &value); 497 ret = sscanf(buf, "%u", &value);
498 if (ret != 1) 498 if (ret != 1)
499 goto out; 499 return -EINVAL;
500 500
501 df->governor->event_handler(df, DEVFREQ_GOV_INTERVAL, &value); 501 df->governor->event_handler(df, DEVFREQ_GOV_INTERVAL, &value);
502 ret = count; 502 ret = count;
503 503
504out:
505 return ret; 504 return ret;
506} 505}
507 506
@@ -515,7 +514,7 @@ static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr,
515 514
516 ret = sscanf(buf, "%lu", &value); 515 ret = sscanf(buf, "%lu", &value);
517 if (ret != 1) 516 if (ret != 1)
518 goto out; 517 return -EINVAL;
519 518
520 mutex_lock(&df->lock); 519 mutex_lock(&df->lock);
521 max = df->max_freq; 520 max = df->max_freq;
@@ -529,7 +528,6 @@ static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr,
529 ret = count; 528 ret = count;
530unlock: 529unlock:
531 mutex_unlock(&df->lock); 530 mutex_unlock(&df->lock);
532out:
533 return ret; 531 return ret;
534} 532}
535 533
@@ -549,7 +547,7 @@ static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr,
549 547
550 ret = sscanf(buf, "%lu", &value); 548 ret = sscanf(buf, "%lu", &value);
551 if (ret != 1) 549 if (ret != 1)
552 goto out; 550 return -EINVAL;
553 551
554 mutex_lock(&df->lock); 552 mutex_lock(&df->lock);
555 min = df->min_freq; 553 min = df->min_freq;
@@ -563,7 +561,6 @@ static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr,
563 ret = count; 561 ret = count;
564unlock: 562unlock:
565 mutex_unlock(&df->lock); 563 mutex_unlock(&df->lock);
566out:
567 return ret; 564 return ret;
568} 565}
569 566