summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2026-08-06 08:09:13 +0200
committerGuenter Roeck <linux@roeck-us.net>2026-08-10 08:59:43 -0700
commit87fdc8d7bb64d6f6669fa8daf4c59940387df07e (patch)
tree1e84b169fd5a53839b75ac3e421002ad334acfd9 /drivers
parent52fcdd5639dc0cc2701a7d035e6d05adfd393f73 (diff)
downloadlinux-87fdc8d7bb64d6f6669fa8daf4c59940387df07e.tar.gz
linux-87fdc8d7bb64d6f6669fa8daf4c59940387df07e.zip
hwmon: (sysfs) Allow drivers to register const attributes
Switch to the __DEVICE_ATTR() macro which can handle callbacks taking both const and non-const attribute structure arguments. Allow the step-wise migration of the drivers. Also use container_of_const() over container_of() to avoid casting away the constness accidentally. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20260806-sysfs-const-attr-hwmon-v2-3-22fee8b85509@weissschuh.net [groeck: Squashed 'hwmon: (core) Constify PEC device attribute'] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/hwmon.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index fbceede1182a..41755910a25a 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -341,7 +341,7 @@ static int hwmon_match_device(struct device *dev, const void *data)
return dev->class == &hwmon_class;
}
-static ssize_t pec_show(struct device *dev, struct device_attribute *dummy,
+static ssize_t pec_show(struct device *dev, const struct device_attribute *dummy,
char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
@@ -349,7 +349,7 @@ static ssize_t pec_show(struct device *dev, struct device_attribute *dummy,
return sysfs_emit(buf, "%d\n", !!(client->flags & I2C_CLIENT_PEC));
}
-static ssize_t pec_store(struct device *dev, struct device_attribute *devattr,
+static ssize_t pec_store(struct device *dev, const struct device_attribute *devattr,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
@@ -390,7 +390,7 @@ put:
return err;
}
-static DEVICE_ATTR_RW(pec);
+static const DEVICE_ATTR_RW(pec);
static void hwmon_remove_pec(void *dev)
{