diff options
author | Durgadoss R <durgadoss.r@intel.com> | 2012-09-18 01:34:58 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2012-11-05 01:00:05 -0500 |
commit | 5a2c090b3327353a78232182f2c7fcd69a46eff0 (patch) | |
tree | 691a783d55a7c945097954c0252ffdb117567060 /drivers | |
parent | a4a15485fbba44d162d626141b9a7404e790f570 (diff) |
Thermal: Add a policy sysfs attribute
This patch adds a policy sysfs attribute to a thermal zone.
This attribute denotes the throttling governor used for the
zone. This is a RW attribute.
Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/thermal/thermal_sys.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 0afd84cb127d..a6933dad3bab 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c | |||
@@ -454,10 +454,41 @@ passive_show(struct device *dev, struct device_attribute *attr, | |||
454 | return sprintf(buf, "%d\n", tz->forced_passive); | 454 | return sprintf(buf, "%d\n", tz->forced_passive); |
455 | } | 455 | } |
456 | 456 | ||
457 | static ssize_t | ||
458 | policy_store(struct device *dev, struct device_attribute *attr, | ||
459 | const char *buf, size_t count) | ||
460 | { | ||
461 | int ret = -EINVAL; | ||
462 | struct thermal_zone_device *tz = to_thermal_zone(dev); | ||
463 | struct thermal_governor *gov; | ||
464 | |||
465 | mutex_lock(&thermal_governor_lock); | ||
466 | |||
467 | gov = __find_governor(buf); | ||
468 | if (!gov) | ||
469 | goto exit; | ||
470 | |||
471 | tz->governor = gov; | ||
472 | ret = count; | ||
473 | |||
474 | exit: | ||
475 | mutex_unlock(&thermal_governor_lock); | ||
476 | return ret; | ||
477 | } | ||
478 | |||
479 | static ssize_t | ||
480 | policy_show(struct device *dev, struct device_attribute *devattr, char *buf) | ||
481 | { | ||
482 | struct thermal_zone_device *tz = to_thermal_zone(dev); | ||
483 | |||
484 | return sprintf(buf, "%s\n", tz->governor->name); | ||
485 | } | ||
486 | |||
457 | static DEVICE_ATTR(type, 0444, type_show, NULL); | 487 | static DEVICE_ATTR(type, 0444, type_show, NULL); |
458 | static DEVICE_ATTR(temp, 0444, temp_show, NULL); | 488 | static DEVICE_ATTR(temp, 0444, temp_show, NULL); |
459 | static DEVICE_ATTR(mode, 0644, mode_show, mode_store); | 489 | static DEVICE_ATTR(mode, 0644, mode_show, mode_store); |
460 | static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); | 490 | static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); |
491 | static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); | ||
461 | 492 | ||
462 | /* sys I/F for cooling device */ | 493 | /* sys I/F for cooling device */ |
463 | #define to_cooling_device(_dev) \ | 494 | #define to_cooling_device(_dev) \ |
@@ -1509,10 +1540,14 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, | |||
1509 | passive = 1; | 1540 | passive = 1; |
1510 | } | 1541 | } |
1511 | 1542 | ||
1512 | if (!passive) | 1543 | if (!passive) { |
1513 | result = device_create_file(&tz->device, | 1544 | result = device_create_file(&tz->device, &dev_attr_passive); |
1514 | &dev_attr_passive); | 1545 | if (result) |
1546 | goto unregister; | ||
1547 | } | ||
1515 | 1548 | ||
1549 | /* Create policy attribute */ | ||
1550 | result = device_create_file(&tz->device, &dev_attr_policy); | ||
1516 | if (result) | 1551 | if (result) |
1517 | goto unregister; | 1552 | goto unregister; |
1518 | 1553 | ||
@@ -1588,6 +1623,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) | |||
1588 | device_remove_file(&tz->device, &dev_attr_temp); | 1623 | device_remove_file(&tz->device, &dev_attr_temp); |
1589 | if (tz->ops->get_mode) | 1624 | if (tz->ops->get_mode) |
1590 | device_remove_file(&tz->device, &dev_attr_mode); | 1625 | device_remove_file(&tz->device, &dev_attr_mode); |
1626 | device_remove_file(&tz->device, &dev_attr_policy); | ||
1591 | remove_trip_attrs(tz); | 1627 | remove_trip_attrs(tz); |
1592 | tz->governor = NULL; | 1628 | tz->governor = NULL; |
1593 | 1629 | ||