summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnil Kumar <anil.kumar@stericsson.com>2012-02-14 07:46:53 +0100
committerPhilippe Langlais <philippe.langlais@linaro.org>2012-02-15 09:35:30 +0100
commita9da60fca6b4bb3d57a96a469a5dc2d7d0cb4ac4 (patch)
tree65c72bf739e258aaa739b32b65534338bf6cfad4
parent6321e7cfbff6e6fa46f122402f3f031b2d4f6dd5 (diff)
drivers: hwmon: l3g4200d: Provide gyroscope temperature via sysfs
Add sysfs interface to read gyroscope temperature ST-Ericsson ID: 371726 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I8fe2fa836c92f927cb70742a06a8b87b0beaec2f Signed-off-by: Anil Kumar <anil.kumar@stericsson.com>
-rw-r--r--drivers/hwmon/l3g4200d.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/hwmon/l3g4200d.c b/drivers/hwmon/l3g4200d.c
index fcac3afc044..c07baa09595 100644
--- a/drivers/hwmon/l3g4200d.c
+++ b/drivers/hwmon/l3g4200d.c
@@ -30,6 +30,7 @@
#define CTRL_REG3 0x22 /* CTRL_REG3 */
#define CTRL_REG4 0x23 /* CTRL_REG4 */
#define CTRL_REG5 0x24 /* CTRL_REG5 */
+#define OUT_TEMP 0x26 /* OUT_TEMP */
#define AXISDATA_REG 0x28
@@ -401,6 +402,24 @@ static ssize_t l3g4200d_store_powermode(struct device *dev,
return count;
}
+static ssize_t l3g4200d_show_gyrotemp(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct l3g4200d_data *ddata = platform_get_drvdata(pdev);
+ int ret;
+
+ if (ddata->powermode == PM_OFF ||
+ ddata->device_status == DEVICE_SUSPENDED)
+ return -EINVAL;
+
+ ret = l3g4200d_read(ddata, OUT_TEMP, "OUT_TEMP");
+ if (ret < 0)
+ return ret;
+
+ return sprintf(buf, "%d\n", ret);
+}
+
static DEVICE_ATTR(gyrodata, S_IRUGO, l3g4200d_show_gyrodata, NULL);
static DEVICE_ATTR(range, S_IRUGO | S_IWUGO,
@@ -412,11 +431,14 @@ static DEVICE_ATTR(datarate, S_IRUGO | S_IWUGO,
static DEVICE_ATTR(powermode, S_IRUGO | S_IWUGO,
l3g4200d_show_powermode, l3g4200d_store_powermode);
+static DEVICE_ATTR(gyrotemp, S_IRUGO, l3g4200d_show_gyrotemp, NULL);
+
static struct attribute *l3g4200d_attributes[] = {
&dev_attr_gyrodata.attr,
&dev_attr_range.attr,
&dev_attr_datarate.attr,
&dev_attr_powermode.attr,
+ &dev_attr_gyrotemp.attr,
NULL
};