aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/devfreq
diff options
context:
space:
mode:
authorMyungJoo Ham <myungjoo.ham@samsung.com>2011-10-01 18:19:28 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-10-01 18:19:28 -0400
commit9005b65099ee4f14b6be691c4574612fe947531a (patch)
tree5066aa8189dd6614d3418b56a9483db0f8a57aa2 /drivers/devfreq
parenta3c98b8b2ede1f4230f49f9af7135cd902e71e83 (diff)
PM / devfreq: Add common sysfs interfaces
Device specific sysfs interface /sys/devices/.../power/devfreq_* - governor R: name of governor - cur_freq R: current frequency - polling_interval R: polling interval in ms given with devfreq profile W: update polling interval. - central_polling R: 1 if polling is managed by devfreq framework Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Mike Turquette <mturquette@ti.com> Acked-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> -- Documentation/ABI/testing/sysfs-class-devfreq | 44 ++++++++++++++++ drivers/devfreq/devfreq.c | 69 ++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-devfreq
Diffstat (limited to 'drivers/devfreq')
-rw-r--r--drivers/devfreq/devfreq.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index f3100b19f79..5d15b812377 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -437,6 +437,74 @@ int devfreq_remove_device(struct devfreq *devfreq)
437 return 0; 437 return 0;
438} 438}
439 439
440static ssize_t show_governor(struct device *dev,
441 struct device_attribute *attr, char *buf)
442{
443 return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name);
444}
445
446static ssize_t show_freq(struct device *dev,
447 struct device_attribute *attr, char *buf)
448{
449 return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq);
450}
451
452static ssize_t show_polling_interval(struct device *dev,
453 struct device_attribute *attr, char *buf)
454{
455 return sprintf(buf, "%d\n", to_devfreq(dev)->profile->polling_ms);
456}
457
458static ssize_t store_polling_interval(struct device *dev,
459 struct device_attribute *attr,
460 const char *buf, size_t count)
461{
462 struct devfreq *df = to_devfreq(dev);
463 unsigned int value;
464 int ret;
465
466 ret = sscanf(buf, "%u", &value);
467 if (ret != 1)
468 goto out;
469
470 mutex_lock(&df->lock);
471 df->profile->polling_ms = value;
472 df->next_polling = df->polling_jiffies
473 = msecs_to_jiffies(value);
474 mutex_unlock(&df->lock);
475
476 ret = count;
477
478 if (df->governor->no_central_polling)
479 goto out;
480
481 mutex_lock(&devfreq_list_lock);
482 if (df->next_polling > 0 && !polling) {
483 polling = true;
484 queue_delayed_work(devfreq_wq, &devfreq_work,
485 df->next_polling);
486 }
487 mutex_unlock(&devfreq_list_lock);
488out:
489 return ret;
490}
491
492static ssize_t show_central_polling(struct device *dev,
493 struct device_attribute *attr, char *buf)
494{
495 return sprintf(buf, "%d\n",
496 !to_devfreq(dev)->governor->no_central_polling);
497}
498
499static struct device_attribute devfreq_attrs[] = {
500 __ATTR(governor, S_IRUGO, show_governor, NULL),
501 __ATTR(cur_freq, S_IRUGO, show_freq, NULL),
502 __ATTR(central_polling, S_IRUGO, show_central_polling, NULL),
503 __ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval,
504 store_polling_interval),
505 { },
506};
507
440/** 508/**
441 * devfreq_start_polling() - Initialize data structure for devfreq framework and 509 * devfreq_start_polling() - Initialize data structure for devfreq framework and
442 * start polling registered devfreq devices. 510 * start polling registered devfreq devices.
@@ -461,6 +529,7 @@ static int __init devfreq_init(void)
461 pr_err("%s: couldn't create class\n", __FILE__); 529 pr_err("%s: couldn't create class\n", __FILE__);
462 return PTR_ERR(devfreq_class); 530 return PTR_ERR(devfreq_class);
463 } 531 }
532 devfreq_class->dev_attrs = devfreq_attrs;
464 return 0; 533 return 0;
465} 534}
466subsys_initcall(devfreq_init); 535subsys_initcall(devfreq_init);