diff mbox series

PM: Constify static struct attribute_group

Message ID 20210201225735.86163-1-rikard.falkeborn@gmail.com
State Accepted
Commit 1556057413a304b3020180240d798ec135d90844
Headers show
Series PM: Constify static struct attribute_group | expand

Commit Message

Rikard Falkeborn Feb. 1, 2021, 10:57 p.m. UTC
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.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 kernel/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rafael J. Wysocki Feb. 12, 2021, 3:48 p.m. UTC | #1
On Mon, Feb 1, 2021 at 11:58 PM Rikard Falkeborn
<rikard.falkeborn@gmail.com> wrote:
>

> 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.

>

> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

> ---

>  kernel/power/main.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/kernel/power/main.c b/kernel/power/main.c

> index 0aefd6f57e0a..12c7e1bb442f 100644

> --- a/kernel/power/main.c

> +++ b/kernel/power/main.c

> @@ -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!
diff mbox series

Patch

diff --git a/kernel/power/main.c b/kernel/power/main.c
index 0aefd6f57e0a..12c7e1bb442f 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -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,
 };