diff mbox series

tpm/ppi: Constify static struct attribute_group

Message ID 20210204215427.49047-1-rikard.falkeborn@gmail.com (mailing list archive)
State New, archived
Headers show
Series tpm/ppi: Constify static struct attribute_group | expand

Commit Message

Rikard Falkeborn Feb. 4, 2021, 9:54 p.m. UTC
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.

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

Comments

Jarkko Sakkinen Feb. 5, 2021, 2:04 a.m. UTC | #1
On Thu, Feb 04, 2021 at 10:54:27PM +0100, Rikard Falkeborn wrote:
> 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.
> 
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

Thanks.

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

/Jarkko

> ---
>  drivers/char/tpm/tpm_ppi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
> index b2dab941cb7f..40018a73b3cb 100644
> --- a/drivers/char/tpm/tpm_ppi.c
> +++ b/drivers/char/tpm/tpm_ppi.c
> @@ -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
>  };
> -- 
> 2.30.0
> 
>
Rikard Falkeborn Feb. 26, 2021, 9:56 p.m. UTC | #2
On Fri, Feb 05, 2021 at 04:04:18AM +0200, Jarkko Sakkinen wrote:
> On Thu, Feb 04, 2021 at 10:54:27PM +0100, Rikard Falkeborn wrote:
> > 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.
> > 
> > Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> 
> Thanks.
> 
> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> 
> /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
Jarkko Sakkinen March 1, 2021, 9:44 a.m. UTC | #3
On Fri, Feb 26, 2021 at 10:56:12PM +0100, Rikard Falkeborn wrote:
> On Fri, Feb 05, 2021 at 04:04:18AM +0200, Jarkko Sakkinen wrote:
> > On Thu, Feb 04, 2021 at 10:54:27PM +0100, Rikard Falkeborn wrote:
> > > 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.
> > > 
> > > Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> > 
> > Thanks.
> > 
> > Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> > 
> > /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
diff mbox series

Patch

diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
index b2dab941cb7f..40018a73b3cb 100644
--- a/drivers/char/tpm/tpm_ppi.c
+++ b/drivers/char/tpm/tpm_ppi.c
@@ -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
 };