Skip to contentSkip to conversation

tpm/ppi: Constify static struct attribute_group

PATCH In review Rikard Falkeborn 2 participants 4 messages Feb 4, 2021 – Mar 1, 2021

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

PATCH 1/1 tpm/ppi: Constify static struct attribute_group

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

---
 drivers/char/tpm/tpm_ppi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_ppi.c +1 -1
index b2dab941cb7f..40018a73b3cb 100644
@@ -358,7 +358,7 @@ static struct attribute *ppi_attrs[] = {
 	&dev_attr_tcg_operations.attr,
 	&dev_attr_vs_operations.attr, NULL,
 };
-static struct attribute_group ppi_attr_grp = {
+static const struct attribute_group ppi_attr_grp = {
 	.name = "ppi",
 	.attrs = ppi_attrs
 };
Signature · 1 line
2.30.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Rikard Falkeborn

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

Thanks.

/Jarkko

Quoted 21 lines
---
 drivers/char/tpm/tpm_ppi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_ppi.c +1 -1
index b2dab941cb7f..40018a73b3cb 100644
@@ -358,7 +358,7 @@ static struct attribute *ppi_attrs[] = {
 	&dev_attr_tcg_operations.attr,
 	&dev_attr_vs_operations.attr, NULL,
 };
-static struct attribute_group ppi_attr_grp = {
+static const struct attribute_group ppi_attr_grp = {
 	.name = "ppi",
 	.attrs = ppi_attrs
 };
Signature · 1 line
2.30.0
#2 lore raw
Quoted 5 lines · Jarkko Sakkinen
Quoted 4 lines · Rikard Falkeborn

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

Quoted 8 lines
Quoted 1 line

Thanks.

/Jarkko

Hi Jarkko,
I saw this was merged as commit 90cba8d20f8b09d62a25f9864cb8e67722d76c3a, but in the commit, there was an additional change where a call to dump_stack() was added in drivers/char/tpm/tpm-chip.c, was this intentional?

/Rikard

maintainer
#3 lore raw
Quoted 12 lines · Rikard Falkeborn
Quoted 11 lines · Jarkko Sakkinen
Quoted 5 lines · Rikard Falkeborn

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

Thanks.

Quoted 8 lines
Quoted 2 lines

/Jarkko

Hi Jarkko,
I saw this was merged as commit 90cba8d20f8b09d62a25f9864cb8e67722d76c3a, but in the commit, there was an additional change where a call to dump_stack() was added in drivers/char/tpm/tpm-chip.c, was this intentional?

No, thanks for reporting. I sent a fixup. Can you ack it?

/Jarkko