[PATCH 4/7] EDAC/device: Constify info sysfs attributes
From: Thomas Weißschuh
Date: Mon Feb 23 2026 - 16:21:17 EST
These structures are never modified, mark them read-only.
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
drivers/edac/edac_device_sysfs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 1e79f36a91fa..754d44827942 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -109,14 +109,14 @@ struct ctl_info_attribute {
};
#define to_ctl_info(k) container_of(k, struct edac_device_ctl_info, kobj)
-#define to_ctl_info_attr(a) container_of(a,struct ctl_info_attribute,attr)
+#define to_ctl_info_attr(a) container_of_const(a, struct ctl_info_attribute, attr)
/* Function to 'show' fields from the edac_dev 'ctl_info' structure */
static ssize_t edac_dev_ctl_info_show(struct kobject *kobj,
struct attribute *attr, char *buffer)
{
struct edac_device_ctl_info *edac_dev = to_ctl_info(kobj);
- struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr);
+ const struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr);
if (ctl_info_attr->show)
return ctl_info_attr->show(edac_dev, buffer);
@@ -129,7 +129,7 @@ static ssize_t edac_dev_ctl_info_store(struct kobject *kobj,
const char *buffer, size_t count)
{
struct edac_device_ctl_info *edac_dev = to_ctl_info(kobj);
- struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr);
+ const struct ctl_info_attribute *ctl_info_attr = to_ctl_info_attr(attr);
if (ctl_info_attr->store)
return ctl_info_attr->store(edac_dev, buffer, count);
@@ -143,7 +143,7 @@ static const struct sysfs_ops device_ctl_info_ops = {
};
#define CTL_INFO_ATTR(_name,_mode,_show,_store) \
-static struct ctl_info_attribute attr_ctl_info_##_name = { \
+static const struct ctl_info_attribute attr_ctl_info_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.store = _store, \
@@ -161,7 +161,7 @@ CTL_INFO_ATTR(poll_msec, S_IRUGO | S_IWUSR,
edac_device_ctl_poll_msec_show, edac_device_ctl_poll_msec_store);
/* Base Attributes of the EDAC_DEVICE ECC object */
-static struct attribute *device_ctrl_attrs[] = {
+static const struct attribute *const device_ctrl_attrs[] = {
&attr_ctl_info_panic_on_ue.attr,
&attr_ctl_info_log_ue.attr,
&attr_ctl_info_log_ce.attr,
--
2.53.0