diff options
| author | Thomas Weißschuh <linux@weissschuh.net> | 2025-10-29 09:12:11 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-11-26 15:16:35 +0100 |
| commit | 964c93b1eef37e3bbe0edb37346c076217d71fe7 (patch) | |
| tree | 93b833cc3b3e5ac6c90d44164b4481400d8f6d4e | |
| parent | f85d90dd8d0efbc75e79698e147c6e682df22e1a (diff) | |
sysfs: transparently handle const pointers in ATTRIBUTE_GROUPS()
To ease the constification process of 'struct attribute', transparently
handle the const pointers in ATTRIBUTE_GROUPS(). A cast is used instead
of assigning to .attrs_new as it keeps the macro smaller. As both
members are aliased to each other the result is identical.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://patch.msgid.link/20251029-sysfs-const-attr-prep-v5-2-ea7d745acff4@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | include/linux/sysfs.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index e34d6af96abb..92f82cee5f11 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -287,7 +287,12 @@ static const struct attribute_group *_name##_groups[] = { \ #define ATTRIBUTE_GROUPS(_name) \ static const struct attribute_group _name##_group = { \ - .attrs = _name##_attrs, \ + .attrs = _Generic(_name##_attrs, \ + struct attribute **: \ + _name##_attrs, \ + const struct attribute *const *: \ + (void *)_name##_attrs \ + ), \ }; \ __ATTRIBUTE_GROUPS(_name) |
