Skip to content

Commit 3465a22

Browse files
groeckjic23
authored andcommitted
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>
1 parent bb916eb commit 3465a22

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/staging/iio/iio_hwmon.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/err.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/hwmon.h>
16+
#include <linux/of.h>
1617
#include <linux/hwmon-sysfs.h>
1718
#include <linux/iio/consumer.h>
1819
#include <linux/iio/types.h>
@@ -58,7 +59,12 @@ static ssize_t iio_hwmon_read_val(struct device *dev,
5859
static ssize_t show_name(struct device *dev, struct device_attribute *attr,
5960
char *buf)
6061
{
61-
return sprintf(buf, "iio_hwmon\n");
62+
const char *name = "iio_hwmon";
63+
64+
if (dev->of_node && dev->of_node->name)
65+
name = dev->of_node->name;
66+
67+
return sprintf(buf, "%s\n", name);
6268
}
6369

6470
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);

0 commit comments

Comments
 (0)