Skip to contentSkip to conversation

PM: Constify static struct attribute_group

PATCH Applied Rikard Falkeborn 2 participants 2 messages Feb 1, 2021 – Feb 12, 2021

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

PATCH 1/1 PM: Constify static struct attribute_group

The only usage of suspend_attr_group is to put its address in an array of pointers to const attribute_group structs. Make it const to allow the compiler to put it in read-only memory.

---
 kernel/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/main.c +1 -1
index 0aefd6f57e0a..12c7e1bb442f 100644
@@ -387,7 +387,7 @@ static struct attribute *suspend_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group suspend_attr_group = {
+static const struct attribute_group suspend_attr_group = {
 	.name = "suspend_stats",
 	.attrs = suspend_attrs,
 };
Signature · 1 line
2.30.0
maintainer Applied
#1 lore raw
Quoted 15 lines · Rikard Falkeborn

The only usage of suspend_attr_group is to put its address in an array of pointers to const attribute_group structs. Make it const to allow the compiler to put it in read-only memory.

---
 kernel/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/main.c +0 -0
index 0aefd6f57e0a..12c7e1bb442f 100644

kernel/power/main.c static struct attribute *suspend_attrs[] = {

Quoted 9 lines
kernel/power/main.c +1 -2
@@ -387,7 +387,7 @@ static struct attribute *suspend_attrs[] = {
        NULL,
 };
 
-static struct attribute_group suspend_attr_group = {
+static const struct attribute_group suspend_attr_group = {
        .name = "suspend_stats",
        .attrs = suspend_attrs,
 };
--

Applied as 5.12 material, thanks!