Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 1/3] hwmon: (core) Constify device attributes
Date: Thu, 06 Aug 2026 06:20:48 +0000	[thread overview]
Message-ID: <20260806062048.EAABB1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260806-sysfs-const-attr-hwmon-v2-1-22fee8b85509@weissschuh.net>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incomplete constification of device attributes: the `pec` attribute was missed.
--

--- Patch [1]: [PATCH v2 1/3] hwmon: (core) Constify device attributes ---
commit 63bf6c9fac5c27892b6188fad21e12ff51c4b53a
Author: Thomas Weißschuh <linux@weissschuh.net>

hwmon: (core) Constify device attributes

This commit updates the hwmon core to mark device attribute structures as const
since they are never modified. It also updates the show callbacks and visibility
functions to accept const arguments.

> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index 55a9a3ddd4aac..84108a16ef60c 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);

[Severity: Low]
This isn't a bug, but should the pec attribute also be constified?

The pec attribute is defined further down in drivers/hwmon/hwmon.c but seems to
have been missed by this refactoring:

static ssize_t pec_show(struct device *dev, struct device_attribute *dummy,
			char *buf)

static ssize_t pec_store(struct device *dev, struct device_attribute *devattr,
			 const char *buf, size_t count)

static DEVICE_ATTR_RW(pec);

Since device_create_file() accepts a const struct device_attribute, could we
update pec_show(), pec_store(), and the pec device attribute to be const as
well?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806-sysfs-const-attr-hwmon-v2-0-22fee8b85509@weissschuh.net?part=1

  reply	other threads:[~2026-08-06  6:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  6:09 [PATCH v2 0/3] hwmon: Handle const struct attributes Thomas Weißschuh
2026-08-06  6:09 ` [PATCH v2 1/3] hwmon: (core) Constify device attributes Thomas Weißschuh
2026-08-06  6:20   ` sashiko-bot [this message]
2026-08-06 19:19   ` Guenter Roeck
2026-08-06  6:09 ` [PATCH v2 2/3] hwmon: (core) Use const APIs for the dynamically allocated sysfs attributes Thomas Weißschuh
2026-08-06  6:15   ` sashiko-bot
2026-08-06 19:20   ` Guenter Roeck
2026-08-06  6:09 ` [PATCH v2 3/3] hwmon: (sysfs) Allow drivers to register const attributes Thomas Weißschuh
2026-08-06  6:16   ` sashiko-bot
2026-08-06 19:20   ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260806062048.EAABB1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox