2021-06-05 20:40:16

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 0/4] platform/x86: Constify static attribute_group structs

Constify a couple of static attribute_group structs which are never
modified to allow the compiler to put them in read-only memory.

Rikard Falkeborn (4):
platform/x86: hdaps: Constify static attribute_group struct
platform/x86: intel_pmt_crashlog: Constify static attribute_group
struct
platform/x86: tc1100-wmi: Constify static attribute_group struct
x86/platform/uv: Constify static attribute_group struct

drivers/platform/x86/hdaps.c | 2 +-
drivers/platform/x86/intel_pmt_crashlog.c | 2 +-
drivers/platform/x86/tc1100-wmi.c | 2 +-
drivers/platform/x86/uv_sysfs.c | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)

--
2.31.1


2021-06-05 20:41:10

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 3/4] platform/x86: tc1100-wmi: Constify static attribute_group struct

The only use of tc1100_attribute_group is to pass its address to
sysfs_create_group() and sysfs_remove_group(), both which takes pointer
to const attribute_group structs. Make it const to allow the compiler to
put it in read-only memory.

Signed-off-by: Rikard Falkeborn <[email protected]>
---
drivers/platform/x86/tc1100-wmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/tc1100-wmi.c b/drivers/platform/x86/tc1100-wmi.c
index 803920b6f01d..9072eb302618 100644
--- a/drivers/platform/x86/tc1100-wmi.c
+++ b/drivers/platform/x86/tc1100-wmi.c
@@ -156,7 +156,7 @@ static struct attribute *tc1100_attributes[] = {
NULL
};

-static struct attribute_group tc1100_attribute_group = {
+static const struct attribute_group tc1100_attribute_group = {
.attrs = tc1100_attributes,
};

--
2.31.1

2021-06-05 20:41:23

by Rikard Falkeborn

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

The only use of hdaps_attribute_group is to pass its address to
sysfs_create_group() and sysfs_remove_group(), both which takes 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 <[email protected]>
---
drivers/platform/x86/hdaps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/hdaps.c b/drivers/platform/x86/hdaps.c
index a72270932ec3..9996485f5295 100644
--- a/drivers/platform/x86/hdaps.c
+++ b/drivers/platform/x86/hdaps.c
@@ -462,7 +462,7 @@ static struct attribute *hdaps_attributes[] = {
NULL,
};

-static struct attribute_group hdaps_attribute_group = {
+static const struct attribute_group hdaps_attribute_group = {
.attrs = hdaps_attributes,
};

--
2.31.1

2021-06-05 20:42:22

by Rikard Falkeborn

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

The only use of pmt_crashlog_group is to assign its address to the
attr_grp field in the intel_pmt_namespace struct, which is a pointer to
const attribute_group. Make it const to allow the compiler to put it in
read-only memory.

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

diff --git a/drivers/platform/x86/intel_pmt_crashlog.c b/drivers/platform/x86/intel_pmt_crashlog.c
index 92d315a16cfd..56963ceb6345 100644
--- a/drivers/platform/x86/intel_pmt_crashlog.c
+++ b/drivers/platform/x86/intel_pmt_crashlog.c
@@ -218,7 +218,7 @@ static struct attribute *pmt_crashlog_attrs[] = {
NULL
};

-static struct attribute_group pmt_crashlog_group = {
+static const struct attribute_group pmt_crashlog_group = {
.attrs = pmt_crashlog_attrs,
};

--
2.31.1

2021-06-07 16:31:58

by Frank Seidel

[permalink] [raw]
Subject: Re: [PATCH 1/4] platform/x86: hdaps: Constify static attribute_group struct

> The only use of hdaps_attribute_group is to pass its address to
> sysfs_create_group() and sysfs_remove_group(), both which takes 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 <[email protected]>

Thanks for the patch and keeping me informed.

Reviewed-by: Frank Seidel <[email protected]>

> ---
> drivers/platform/x86/hdaps.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/hdaps.c b/drivers/platform/x86/hdaps.c
> index a72270932ec3..9996485f5295 100644
> --- a/drivers/platform/x86/hdaps.c
> +++ b/drivers/platform/x86/hdaps.c
> @@ -462,7 +462,7 @@ static struct attribute *hdaps_attributes[] = {
> NULL,
> };
>
> -static struct attribute_group hdaps_attribute_group = {
> +static const struct attribute_group hdaps_attribute_group = {
> .attrs = hdaps_attributes,
> };
>
>

2021-06-09 17:50:21

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH 0/4] platform/x86: Constify static attribute_group structs

Hi,

On 6/5/21 10:38 PM, Rikard Falkeborn wrote:
> Constify a couple of static attribute_group structs which are never
> modified to allow the compiler to put them in read-only memory.
>
> Rikard Falkeborn (4):
> platform/x86: hdaps: Constify static attribute_group struct
> platform/x86: intel_pmt_crashlog: Constify static attribute_group
> struct
> platform/x86: tc1100-wmi: Constify static attribute_group struct
> x86/platform/uv: Constify static attribute_group struct

Thank you for your patch-series, I've applied the series to my
review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans