summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2013-03-20 15:52:00 +0000
committerJonathan Cameron <jic23@kernel.org>2013-03-20 21:37:59 +0000
commit3465a22488a47d5f4791876a22fde2bb1720f4cf (patch)
tree0670bfd4df972c122215420a9cc213d62862f39d
parentbb916ebbeabd18f7dc3c661275d2c9d343f4fa85 (diff)
staging/iio: iio_hwmon: Use device tree node name for hwmon name attribute
So far, all instances of iio_hwmon set their hwmon name attribute to "iio_hwmon", which is not very descriptive. Set it to the device tree node name if available, and only revert to iio_hwmon otherwise. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/staging/iio/iio_hwmon.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
index 93af756ba48c..aafa4531b961 100644
--- a/drivers/staging/iio/iio_hwmon.c
+++ b/drivers/staging/iio/iio_hwmon.c
@@ -13,6 +13,7 @@
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/hwmon.h>
+#include <linux/of.h>
#include <linux/hwmon-sysfs.h>
#include <linux/iio/consumer.h>
#include <linux/iio/types.h>
@@ -58,7 +59,12 @@ static ssize_t iio_hwmon_read_val(struct device *dev,
static ssize_t show_name(struct device *dev, struct device_attribute *attr,
char *buf)
{
- return sprintf(buf, "iio_hwmon\n");
+ const char *name = "iio_hwmon";
+
+ if (dev->of_node && dev->of_node->name)
+ name = dev->of_node->name;
+
+ return sprintf(buf, "%s\n", name);
}
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);