Re: [PATCH] hwmon: (core) Constify PEC device attribute

From: Guenter Roeck

Date: Fri Aug 07 2026 - 17:07:12 EST


On Fri, Aug 07, 2026 at 10:06:17PM +0200, Thomas Weißschuh wrote:
> Mark the attribute structure as const, as it is never modified.
>
> Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
> ---
> This should have been part of commit 5d27101b6f1c ("hwmon: (core)
> Constify device attributes"). If you do a rebase anyways, maybe you
> could fold them together.

I'll do that.

Applied.

Thanks,
Guenter

> ---
> drivers/hwmon/hwmon.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>
> ---
> base-commit: 611f4cbac429c09a7db4bb2aebf64e3423109639
> change-id: 20260807-sysfs-const-attr-hwmon-2-43bd646c0c67
>
> Best regards,
> --
> Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
>
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index 90ceb815f43e..3297ed6daec1 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 @@ static ssize_t pec_store(struct device *dev, struct device_attribute *devattr,
> return err;
> }
>
> -static DEVICE_ATTR_RW(pec);
> +static const DEVICE_ATTR_RW(pec);
>
> static void hwmon_remove_pec(void *dev)
> {