Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Guenter Roeck and committed by
Jonathan Cameron
3465a224 bb916ebb

+7 -1
+7 -1
drivers/staging/iio/iio_hwmon.c
··· 13 13 #include <linux/err.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/hwmon.h> 16 + #include <linux/of.h> 16 17 #include <linux/hwmon-sysfs.h> 17 18 #include <linux/iio/consumer.h> 18 19 #include <linux/iio/types.h> ··· 59 58 static ssize_t show_name(struct device *dev, struct device_attribute *attr, 60 59 char *buf) 61 60 { 62 - return sprintf(buf, "iio_hwmon\n"); 61 + const char *name = "iio_hwmon"; 62 + 63 + if (dev->of_node && dev->of_node->name) 64 + name = dev->of_node->name; 65 + 66 + return sprintf(buf, "%s\n", name); 63 67 } 64 68 65 69 static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);