drivers: thermal: enable reading sensors_active
Neil Patel [Thu, 16 Apr 2015 17:03:06 +0000 (13:03 -0400)]
Enable reading of the sensors_active attribute from user space to
help diagnose cases where the modem temperature readings are
returning an error.

Bug 1619534

Change-Id: I8672feb31a08f0c9d9c4ff6583abc2cbb9d270dc
Signed-off-by: Neil Patel <neilp@nvidia.com>
Reviewed-on: http://git-master/r/733234
(cherry picked from commit d8f8f464c405db08df05fe9cb5dd773759798e03)
Reviewed-on: http://git-master/r/732342
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Rajkumar Jayaraman <rjayaraman@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Steve Lin <stlin@nvidia.com>

drivers/thermal/modem_thermal.c

index 5b99390..b55a721 100644 (file)
@@ -75,6 +75,14 @@ err:
 }
 static DEVICE_ATTR(temp, S_IWUSR, NULL, temp_store);
 
+static ssize_t sensors_active_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+       struct modem_thermal_data *mtd = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%lu\n", mtd->sensors_active);
+}
+
 static ssize_t sensors_active_store(struct device *dev,
                        struct device_attribute *attr, const char *buf,
                        size_t count)
@@ -89,7 +97,8 @@ static ssize_t sensors_active_store(struct device *dev,
 
        return count;
 }
-static DEVICE_ATTR(sensors_active, S_IWUSR, NULL, sensors_active_store);
+static DEVICE_ATTR(sensors_active, S_IRUGO | S_IWUSR, sensors_active_show,
+               sensors_active_store);
 
 static int modem_thermal_get_temp(struct thermal_zone_device *tzd, long *t)
 {