From: Thomas Weißschuh Date: Mon, 23 Feb 2026 21:16:31 +0000 (+0100) Subject: EDAC/device: Constify info sysfs attributes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e72e70870a0b4955ca74e2a715f9bda4c08b252c;p=thirdparty%2Fkernel%2Flinux.git EDAC/device: Constify info sysfs attributes These structures are never modified, mark them read-only. Signed-off-by: Thomas Weißschuh Signed-off-by: Borislav Petkov (AMD) Link: https://patch.msgid.link/20260223-sysfs-const-edac-v1-4-3ff0b87249e7@weissschuh.net --- diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 1e79f36a91faf..754d448279427 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,