aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/devfreq/devfreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/devfreq/devfreq.c')
-rw-r--r--drivers/devfreq/devfreq.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index c189b82f5ece..a129a7b6bfd1 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -501,12 +501,82 @@ static ssize_t show_central_polling(struct device *dev,
501 !to_devfreq(dev)->governor->no_central_polling); 501 !to_devfreq(dev)->governor->no_central_polling);
502} 502}
503 503
504static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr,
505 const char *buf, size_t count)
506{
507 struct devfreq *df = to_devfreq(dev);
508 unsigned long value;
509 int ret;
510 unsigned long max;
511
512 ret = sscanf(buf, "%lu", &value);
513 if (ret != 1)
514 goto out;
515
516 mutex_lock(&df->lock);
517 max = df->max_freq;
518 if (value && max && value > max) {
519 ret = -EINVAL;
520 goto unlock;
521 }
522
523 df->min_freq = value;
524 update_devfreq(df);
525 ret = count;
526unlock:
527 mutex_unlock(&df->lock);
528out:
529 return ret;
530}
531
532static ssize_t show_min_freq(struct device *dev, struct device_attribute *attr,
533 char *buf)
534{
535 return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq);
536}
537
538static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr,
539 const char *buf, size_t count)
540{
541 struct devfreq *df = to_devfreq(dev);
542 unsigned long value;
543 int ret;
544 unsigned long min;
545
546 ret = sscanf(buf, "%lu", &value);
547 if (ret != 1)
548 goto out;
549
550 mutex_lock(&df->lock);
551 min = df->min_freq;
552 if (value && min && value < min) {
553 ret = -EINVAL;
554 goto unlock;
555 }
556
557 df->max_freq = value;
558 update_devfreq(df);
559 ret = count;
560unlock:
561 mutex_unlock(&df->lock);
562out:
563 return ret;
564}
565
566static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr,
567 char *buf)
568{
569 return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq);
570}
571
504static struct device_attribute devfreq_attrs[] = { 572static struct device_attribute devfreq_attrs[] = {
505 __ATTR(governor, S_IRUGO, show_governor, NULL), 573 __ATTR(governor, S_IRUGO, show_governor, NULL),
506 __ATTR(cur_freq, S_IRUGO, show_freq, NULL), 574 __ATTR(cur_freq, S_IRUGO, show_freq, NULL),
507 __ATTR(central_polling, S_IRUGO, show_central_polling, NULL), 575 __ATTR(central_polling, S_IRUGO, show_central_polling, NULL),
508 __ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval, 576 __ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval,
509 store_polling_interval), 577 store_polling_interval),
578 __ATTR(min_freq, S_IRUGO | S_IWUSR, show_min_freq, store_min_freq),
579 __ATTR(max_freq, S_IRUGO | S_IWUSR, show_max_freq, store_max_freq),
510 { }, 580 { },
511}; 581};
512 582