2021-06-05 20:39:59

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 4/4] x86/platform/uv: Constify static attribute_group struct

The only use of base_attr_group and hubless_base_attr_group is to pass
their addresses to sysfs_create_group() and sysfs_remove_group(), both
which takes pointers to const attribute_group structs. Make them const
to allow the compiler to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <[email protected]>
---
drivers/platform/x86/uv_sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/uv_sysfs.c b/drivers/platform/x86/uv_sysfs.c
index 7badcfa3f384..956a354b57c1 100644
--- a/drivers/platform/x86/uv_sysfs.c
+++ b/drivers/platform/x86/uv_sysfs.c
@@ -778,7 +778,7 @@ static struct attribute *base_attrs[] = {
NULL,
};

-static struct attribute_group base_attr_group = {
+static const struct attribute_group base_attr_group = {
.attrs = base_attrs
};

@@ -823,7 +823,7 @@ static struct attribute *hubless_base_attrs[] = {
NULL,
};

-static struct attribute_group hubless_base_attr_group = {
+static const struct attribute_group hubless_base_attr_group = {
.attrs = hubless_base_attrs
};

--
2.31.1


2021-06-07 14:36:31

by Ernst, Justin

[permalink] [raw]
Subject: RE: [PATCH 4/4] x86/platform/uv: Constify static attribute_group struct

> The only use of base_attr_group and hubless_base_attr_group is to pass
> their addresses to sysfs_create_group() and sysfs_remove_group(), both
> which takes pointers to const attribute_group structs. Make them const
> to allow the compiler to put them in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>

Thank you for the patch.

Reviewed-by: Justin Ernst <[email protected]>

> ---
> drivers/platform/x86/uv_sysfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/uv_sysfs.c b/drivers/platform/x86/uv_sysfs.c
> index 7badcfa3f384..956a354b57c1 100644
> --- a/drivers/platform/x86/uv_sysfs.c
> +++ b/drivers/platform/x86/uv_sysfs.c
> @@ -778,7 +778,7 @@ static struct attribute *base_attrs[] = {
> NULL,
> };
>
> -static struct attribute_group base_attr_group = {
> +static const struct attribute_group base_attr_group = {
> .attrs = base_attrs
> };
>
> @@ -823,7 +823,7 @@ static struct attribute *hubless_base_attrs[] = {
> NULL,
> };
>
> -static struct attribute_group hubless_base_attr_group = {
> +static const struct attribute_group hubless_base_attr_group = {
> .attrs = hubless_base_attrs
> };
>
> --
> 2.31.1