Thermal: Add passive_delay sysfs attribute in thermal zone
Jinyoung Park [Fri, 30 Nov 2012 10:47:20 +0000 (02:47 -0800)]
Added passive_delay sysfs attribute to show and store passive_delay
in thermal zone.

Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/167876
(cherry picked from commit 782c1fb12325abfaf72b04e338eccd7aafa3a6fe)

Change-Id: I0350f47fe9a8ea29a0f9e85e4cd91633bf635487
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/172169
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

drivers/thermal/thermal_sys.c

index 897b56e..f2d757e 100644 (file)
@@ -673,6 +673,30 @@ passive_show(struct device *dev, struct device_attribute *attr,
 }
 
 static ssize_t
+passive_delay_store(struct device *dev, struct device_attribute *attr,
+                   const char *buf, size_t count)
+{
+       struct thermal_zone_device *tz = to_thermal_zone(dev);
+       int passive_delay;
+
+       if (!sscanf(buf, "%d\n", &passive_delay))
+               return -EINVAL;
+
+       tz->passive_delay = passive_delay;
+       thermal_zone_device_update(tz);
+       return count;
+}
+
+static ssize_t
+passive_delay_show(struct device *dev, struct device_attribute *attr,
+                  char *buf)
+{
+       struct thermal_zone_device *tz = to_thermal_zone(dev);
+
+       return sprintf(buf, "%d\n", tz->passive_delay);
+}
+
+static ssize_t
 policy_store(struct device *dev, struct device_attribute *attr,
                    const char *buf, size_t count)
 {
@@ -727,6 +751,8 @@ static DEVICE_ATTR(type, 0444, type_show, NULL);
 static DEVICE_ATTR(temp, 0444, temp_show, NULL);
 static DEVICE_ATTR(mode, 0644, mode_show, mode_store);
 static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store);
+static DEVICE_ATTR(passive_delay, S_IRUGO | S_IWUSR,
+                  passive_delay_show, passive_delay_store);
 static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store);
 static DEVICE_ATTR(available_policies, S_IRUGO, available_policies_show, NULL);
 
@@ -1638,6 +1664,11 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
        if (result)
                goto unregister;
 
+       /* Create passive_delay attribute */
+       result = device_create_file(&tz->device, &dev_attr_passive_delay);
+       if (result)
+               goto unregister;
+
        /* Create available_policies attribute */
        result = device_create_file(&tz->device, &dev_attr_available_policies);
        if (result)
@@ -1732,6 +1763,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
        device_remove_file(&tz->device, &dev_attr_temp);
        if (tz->ops->get_mode)
                device_remove_file(&tz->device, &dev_attr_mode);
+       device_remove_file(&tz->device, &dev_attr_passive_delay);
        device_remove_file(&tz->device, &dev_attr_policy);
        device_remove_file(&tz->device, &dev_attr_available_policies);
        remove_trip_attrs(tz);