platform/x86: Constify static attribute_group structs
Subsystems (3)
cover 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(-)
Signature · 1 line
2.31.1
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.
--- drivers/platform/x86/hdaps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/hdaps.c +1 -1
@@ -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, };
Signature · 1 line
2.31.1
Re: [PATCH 1/4] platform/x86: hdaps: Constify static attribute_group struct
Quoted 6 lines
The only use of
hdaps_attribute_groupis to pass its address tosysfs_create_group()andsysfs_remove_group(), both which takes pointers to constattribute_groupstructs. 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.
Quoted 18 lines
--- drivers/platform/x86/hdaps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/x86/hdaps.c +1
-1@@ -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, };
PATCH 2/4 platform/x86: intel_pmt_crashlog: Constify static attribute_group struct
In reply to Rikard FalkebornThe 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.
--- drivers/platform/x86/intel_pmt_crashlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_pmt_crashlog.c +1 -1
@@ -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, };
Signature · 1 line
2.31.1
PATCH 3/4 platform/x86: tc1100-wmi: Constify static attribute_group struct
In reply to Rikard FalkebornThe 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.
--- drivers/platform/x86/tc1100-wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/tc1100-wmi.c +1 -1
@@ -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, };
Signature · 1 line
2.31.1
PATCH 4/4 x86/platform/uv: Constify static attribute_group struct
In reply to Rikard FalkebornThe 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.
--- drivers/platform/x86/uv_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/uv_sysfs.c +2 -2
@@ -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 };
Signature · 1 line
2.31.1
RE: [PATCH 4/4] x86/platform/uv: Constify static attribute_group struct
Quoted 6 lines
The only use of
base_attr_groupandhubless_base_attr_groupis to pass their addresses tosysfs_create_group()andsysfs_remove_group(), both which takes pointers to constattribute_groupstructs. 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.
Quoted 28 lines
--- drivers/platform/x86/uv_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/platform/x86/uv_sysfs.c +2
-3@@ -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
Hi,
Quoted 9 lines · Rikard Falkeborn
Constify a couple of static
attribute_groupstructs which are never modified to allow the compiler to put them in read-only memory.Rikard Falkeborn (4):
platform/x86: hdaps: Constify staticattribute_groupstruct platform/x86:intel_pmt_crashlog: Constify staticattribute_group
struct
platform/x86: tc1100-wmi: Constify staticattribute_groupstruct x86/platform/uv: Constify staticattribute_groupstruct
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