summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/hwmon.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2022-01-10 14:56:25 -0800
committerGuenter Roeck <linux@roeck-us.net>2022-02-27 17:03:16 -0800
commit7f3cc8f897634b7e2d79bc2b7105e9ae6eaf4ac2 (patch)
treeaf8268c8c6f4f8f713a1220bbc3fa9a7a23b9328 /drivers/hwmon/hwmon.c
parent686d303ee6301261b422ea51e64833d7909a2c36 (diff)
downloadlinux-7f3cc8f897634b7e2d79bc2b7105e9ae6eaf4ac2.tar.bz2
hwmon: Report attribute name with udev events
Up to now udev events only report the affected hwmon device if an alert is reported. This requires userspace to read all attributes if it wants to know what triggered the event. Provide the attribute name with the NAME property to help userspace find the attribute causing the event. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/hwmon.c')
-rw-r--r--drivers/hwmon/hwmon.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 3ae961986fc3..0b79c4e1bf99 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -625,7 +625,9 @@ static const int __templates_size[] = {
int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel)
{
+ char event[MAX_SYSFS_ATTR_NAME_LENGTH + 5];
char sattr[MAX_SYSFS_ATTR_NAME_LENGTH];
+ char *envp[] = { event, NULL };
const char * const *templates;
const char *template;
int base;
@@ -641,8 +643,9 @@ int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type,
base = hwmon_attr_base(type);
scnprintf(sattr, MAX_SYSFS_ATTR_NAME_LENGTH, template, base + channel);
+ scnprintf(event, sizeof(event), "NAME=%s", sattr);
sysfs_notify(&dev->kobj, NULL, sattr);
- kobject_uevent(&dev->kobj, KOBJ_CHANGE);
+ kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
if (type == hwmon_temp)
hwmon_thermal_notify(dev, channel);