]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
EDAC/device: Constify info sysfs attributes
authorThomas Weißschuh <linux@weissschuh.net>
Mon, 23 Feb 2026 21:16:31 +0000 (22:16 +0100)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 11 Mar 2026 21:20:20 +0000 (22:20 +0100)
These structures are never modified, mark them read-only.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20260223-sysfs-const-edac-v1-4-3ff0b87249e7@weissschuh.net
drivers/edac/edac_device_sysfs.c

index 1e79f36a91fafd7c57feee947d100359c51cc752..754d448279427b7820c4f0bb667f3ccab8631595 100644 (file)
@@ -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,