From dafe7f1ec9db8f92a575a22f67d4f0f28bf10657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 6 Aug 2026 08:09:11 +0200 Subject: [PATCH] hwmon: (core) Constify device attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mark the attribute structures as const, as they are never modified. Signed-off-by: Thomas Weißschuh Link: https://lore.kernel.org/r/20260806-sysfs-const-attr-hwmon-v2-1-22fee8b85509@weissschuh.net Signed-off-by: Guenter Roeck --- drivers/hwmon/hwmon.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 29dc90a2c3fe..f1051b89c564 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -71,27 +71,27 @@ struct hwmon_thermal_data { }; static ssize_t -name_show(struct device *dev, struct device_attribute *attr, char *buf) +name_show(struct device *dev, const struct device_attribute *attr, char *buf) { return sysfs_emit(buf, "%s\n", to_hwmon_device(dev)->name); } -static DEVICE_ATTR_RO(name); +static const DEVICE_ATTR_RO(name); static ssize_t -label_show(struct device *dev, struct device_attribute *attr, char *buf) +label_show(struct device *dev, const struct device_attribute *attr, char *buf) { return sysfs_emit(buf, "%s\n", to_hwmon_device(dev)->label); } -static DEVICE_ATTR_RO(label); +static const DEVICE_ATTR_RO(label); -static struct attribute *hwmon_dev_attrs[] = { +static const struct attribute *const hwmon_dev_attrs[] = { &dev_attr_name.attr, &dev_attr_label.attr, NULL }; static umode_t hwmon_dev_attr_is_visible(struct kobject *kobj, - struct attribute *attr, int n) + const struct attribute *attr, int n) { struct device *dev = kobj_to_dev(kobj); struct hwmon_device *hdev = to_hwmon_device(dev); @@ -106,8 +106,8 @@ static umode_t hwmon_dev_attr_is_visible(struct kobject *kobj, } static const struct attribute_group hwmon_dev_attr_group = { - .attrs = hwmon_dev_attrs, - .is_visible = hwmon_dev_attr_is_visible, + .attrs_const = hwmon_dev_attrs, + .is_visible_const = hwmon_dev_attr_is_visible, }; static const struct attribute_group *hwmon_dev_attr_groups[] = {