Skip to contentSkip to conversation

drivers/base: Constify static attribute_group structs

PATCH New Rikard Falkeborn 1 participant 1 message May 28, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/base: Constify static attribute_group structs

These are only used by putting their address in an array of pointers to const struct attribute_group (either directly or via the __ATTRIBUTE_GROUP macro). Make them const to allow the compiler to place them in read-only memory.

---
 drivers/base/cpu.c      | 4 ++--
 drivers/base/memory.c   | 4 ++--
 drivers/base/node.c     | 2 +-
 drivers/base/platform.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/base/cpu.c +2 -2
index 2b9e41377a07..5ef14db97904 100644
@@ -175,7 +175,7 @@ static struct attribute *crash_note_cpu_attrs[] = {
 	NULL
 };
 
-static struct attribute_group crash_note_cpu_attr_group = {
+static const struct attribute_group crash_note_cpu_attr_group = {
 	.attrs = crash_note_cpu_attrs,
 };
 #endif
@@ -475,7 +475,7 @@ static struct attribute *cpu_root_attrs[] = {
 	NULL
 };
 
-static struct attribute_group cpu_root_attr_group = {
+static const struct attribute_group cpu_root_attr_group = {
 	.attrs = cpu_root_attrs,
 };
 
drivers/base/memory.c +2 -2
index b31b3af5c490..600ae518c02a 100644
@@ -596,7 +596,7 @@ static struct attribute *memory_memblk_attrs[] = {
 	NULL
 };
 
-static struct attribute_group memory_memblk_attr_group = {
+static const struct attribute_group memory_memblk_attr_group = {
 	.attrs = memory_memblk_attrs,
 };
 
@@ -772,7 +772,7 @@ static struct attribute *memory_root_attrs[] = {
 	NULL
 };
 
-static struct attribute_group memory_root_attr_group = {
+static const struct attribute_group memory_root_attr_group = {
 	.attrs = memory_root_attrs,
 };
 
drivers/base/node.c +1 -1
index 4cef82c1b079..4a4ae868ad9f 100644
@@ -1038,7 +1038,7 @@ static struct attribute *node_state_attrs[] = {
 	NULL
 };
 
-static struct attribute_group memory_root_attr_group = {
+static const struct attribute_group memory_root_attr_group = {
 	.attrs = node_state_attrs,
 };
 
drivers/base/platform.c +1 -1
index 9cd34def2237..d093ba4371b8 100644
@@ -1355,7 +1355,7 @@ static umode_t platform_dev_attrs_visible(struct kobject *kobj, struct attribute
 	return a->mode;
 }
 
-static struct attribute_group platform_dev_group = {
+static const struct attribute_group platform_dev_group = {
 	.attrs = platform_dev_attrs,
 	.is_visible = platform_dev_attrs_visible,
 };
Signature · 1 line
2.31.1