diff mbox series

fpga: dfl: fme: Constify static attribute_group structs

Message ID 20210108235414.48017-1-rikard.falkeborn@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series fpga: dfl: fme: Constify static attribute_group structs | expand

Commit Message

Rikard Falkeborn Jan. 8, 2021, 11:54 p.m. UTC
The only usage of these is to put their addresses in arrays of pointers
to const attribute_groups. Make them const to allow the compiler to put
them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/fpga/dfl-fme-perf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Tom Rix Jan. 9, 2021, 9:55 p.m. UTC | #1
On 1/8/21 3:54 PM, Rikard Falkeborn wrote:
> The only usage of these is to put their addresses in arrays of pointers
> to const attribute_groups. Make them const to allow the compiler to put
> them in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> ---
>  drivers/fpga/dfl-fme-perf.c | 6 +++---

This looks ok.

There are other 'static struct's in drivers/fpga.

Why is the change limited to this file ?

Tom

>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c
> index 531266287eee..4299145ef347 100644
> --- a/drivers/fpga/dfl-fme-perf.c
> +++ b/drivers/fpga/dfl-fme-perf.c
> @@ -192,7 +192,7 @@ static struct attribute *fme_perf_cpumask_attrs[] = {
>  	NULL,
>  };
>  
> -static struct attribute_group fme_perf_cpumask_group = {
> +static const struct attribute_group fme_perf_cpumask_group = {
>  	.attrs = fme_perf_cpumask_attrs,
>  };
>  
> @@ -225,7 +225,7 @@ static struct attribute *fme_perf_format_attrs[] = {
>  	NULL,
>  };
>  
> -static struct attribute_group fme_perf_format_group = {
> +static const struct attribute_group fme_perf_format_group = {
>  	.name = "format",
>  	.attrs = fme_perf_format_attrs,
>  };
> @@ -239,7 +239,7 @@ static struct attribute *fme_perf_events_attrs_empty[] = {
>  	NULL,
>  };
>  
> -static struct attribute_group fme_perf_events_group = {
> +static const struct attribute_group fme_perf_events_group = {
>  	.name = "events",
>  	.attrs = fme_perf_events_attrs_empty,
>  };
Rikard Falkeborn Jan. 9, 2021, 10:52 p.m. UTC | #2
On Sat, Jan 09, 2021 at 01:55:13PM -0800, Tom Rix wrote:
> 
> On 1/8/21 3:54 PM, Rikard Falkeborn wrote:
> > The only usage of these is to put their addresses in arrays of pointers
> > to const attribute_groups. Make them const to allow the compiler to put
> > them in read-only memory.
> >
> > Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> > ---
> >  drivers/fpga/dfl-fme-perf.c | 6 +++---
> 
> This looks ok.
> 
> There are other 'static struct's in drivers/fpga.
> 
> Why is the change limited to this file ?
> 
> Tom
> 

I have a WIP coccinelle script to constify static struct attribute_group
and this is the only file in drivers/fpga which has non-const struct
attribute_group, that's why it's limited to this file. I could have
mentioned that in the commit message.

Rikard


> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c
> > index 531266287eee..4299145ef347 100644
> > --- a/drivers/fpga/dfl-fme-perf.c
> > +++ b/drivers/fpga/dfl-fme-perf.c
> > @@ -192,7 +192,7 @@ static struct attribute *fme_perf_cpumask_attrs[] = {
> >  	NULL,
> >  };
> >  
> > -static struct attribute_group fme_perf_cpumask_group = {
> > +static const struct attribute_group fme_perf_cpumask_group = {
> >  	.attrs = fme_perf_cpumask_attrs,
> >  };
> >  
> > @@ -225,7 +225,7 @@ static struct attribute *fme_perf_format_attrs[] = {
> >  	NULL,
> >  };
> >  
> > -static struct attribute_group fme_perf_format_group = {
> > +static const struct attribute_group fme_perf_format_group = {
> >  	.name = "format",
> >  	.attrs = fme_perf_format_attrs,
> >  };
> > @@ -239,7 +239,7 @@ static struct attribute *fme_perf_events_attrs_empty[] = {
> >  	NULL,
> >  };
> >  
> > -static struct attribute_group fme_perf_events_group = {
> > +static const struct attribute_group fme_perf_events_group = {
> >  	.name = "events",
> >  	.attrs = fme_perf_events_attrs_empty,
> >  };
>
Tom Rix Jan. 10, 2021, 1:40 a.m. UTC | #3
On 1/9/21 2:52 PM, Rikard Falkeborn wrote:
> On Sat, Jan 09, 2021 at 01:55:13PM -0800, Tom Rix wrote:
>> On 1/8/21 3:54 PM, Rikard Falkeborn wrote:
>>> The only usage of these is to put their addresses in arrays of pointers
>>> to const attribute_groups. Make them const to allow the compiler to put
>>> them in read-only memory.
>>>
>>> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
>>> ---
>>>  drivers/fpga/dfl-fme-perf.c | 6 +++---
>> This looks ok.
>>
>> There are other 'static struct's in drivers/fpga.
>>
>> Why is the change limited to this file ?
>>
>> Tom
>>
> I have a WIP coccinelle script to constify static struct attribute_group
> and this is the only file in drivers/fpga which has non-const struct
> attribute_group, that's why it's limited to this file. I could have
> mentioned that in the commit message.

No worries, thanks for the change!

Reviewed-by: Tom Rix <trix@redhat.com>

> Rikard
>
>
>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c
>>> index 531266287eee..4299145ef347 100644
>>> --- a/drivers/fpga/dfl-fme-perf.c
>>> +++ b/drivers/fpga/dfl-fme-perf.c
>>> @@ -192,7 +192,7 @@ static struct attribute *fme_perf_cpumask_attrs[] = {
>>>  	NULL,
>>>  };
>>>  
>>> -static struct attribute_group fme_perf_cpumask_group = {
>>> +static const struct attribute_group fme_perf_cpumask_group = {
>>>  	.attrs = fme_perf_cpumask_attrs,
>>>  };
>>>  
>>> @@ -225,7 +225,7 @@ static struct attribute *fme_perf_format_attrs[] = {
>>>  	NULL,
>>>  };
>>>  
>>> -static struct attribute_group fme_perf_format_group = {
>>> +static const struct attribute_group fme_perf_format_group = {
>>>  	.name = "format",
>>>  	.attrs = fme_perf_format_attrs,
>>>  };
>>> @@ -239,7 +239,7 @@ static struct attribute *fme_perf_events_attrs_empty[] = {
>>>  	NULL,
>>>  };
>>>  
>>> -static struct attribute_group fme_perf_events_group = {
>>> +static const struct attribute_group fme_perf_events_group = {
>>>  	.name = "events",
>>>  	.attrs = fme_perf_events_attrs_empty,
>>>  };
Moritz Fischer Jan. 10, 2021, 7:06 p.m. UTC | #4
On Sat, Jan 09, 2021 at 05:40:38PM -0800, Tom Rix wrote:
> 
> On 1/9/21 2:52 PM, Rikard Falkeborn wrote:
> > On Sat, Jan 09, 2021 at 01:55:13PM -0800, Tom Rix wrote:
> >> On 1/8/21 3:54 PM, Rikard Falkeborn wrote:
> >>> The only usage of these is to put their addresses in arrays of pointers
> >>> to const attribute_groups. Make them const to allow the compiler to put
> >>> them in read-only memory.
> >>>
> >>> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> >>> ---
> >>>  drivers/fpga/dfl-fme-perf.c | 6 +++---
> >> This looks ok.
> >>
> >> There are other 'static struct's in drivers/fpga.
> >>
> >> Why is the change limited to this file ?
> >>
> >> Tom
> >>
> > I have a WIP coccinelle script to constify static struct attribute_group
> > and this is the only file in drivers/fpga which has non-const struct
> > attribute_group, that's why it's limited to this file. I could have
> > mentioned that in the commit message.
> 
> No worries, thanks for the change!
> 
> Reviewed-by: Tom Rix <trix@redhat.com>
> 
> > Rikard
> >
> >
> >>>  1 file changed, 3 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c
> >>> index 531266287eee..4299145ef347 100644
> >>> --- a/drivers/fpga/dfl-fme-perf.c
> >>> +++ b/drivers/fpga/dfl-fme-perf.c
> >>> @@ -192,7 +192,7 @@ static struct attribute *fme_perf_cpumask_attrs[] = {
> >>>  	NULL,
> >>>  };
> >>>  
> >>> -static struct attribute_group fme_perf_cpumask_group = {
> >>> +static const struct attribute_group fme_perf_cpumask_group = {
> >>>  	.attrs = fme_perf_cpumask_attrs,
> >>>  };
> >>>  
> >>> @@ -225,7 +225,7 @@ static struct attribute *fme_perf_format_attrs[] = {
> >>>  	NULL,
> >>>  };
> >>>  
> >>> -static struct attribute_group fme_perf_format_group = {
> >>> +static const struct attribute_group fme_perf_format_group = {
> >>>  	.name = "format",
> >>>  	.attrs = fme_perf_format_attrs,
> >>>  };
> >>> @@ -239,7 +239,7 @@ static struct attribute *fme_perf_events_attrs_empty[] = {
> >>>  	NULL,
> >>>  };
> >>>  
> >>> -static struct attribute_group fme_perf_events_group = {
> >>> +static const struct attribute_group fme_perf_events_group = {
> >>>  	.name = "events",
> >>>  	.attrs = fme_perf_events_attrs_empty,
> >>>  };
> 
Applied,

Thanks
diff mbox series

Patch

diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c
index 531266287eee..4299145ef347 100644
--- a/drivers/fpga/dfl-fme-perf.c
+++ b/drivers/fpga/dfl-fme-perf.c
@@ -192,7 +192,7 @@  static struct attribute *fme_perf_cpumask_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group fme_perf_cpumask_group = {
+static const struct attribute_group fme_perf_cpumask_group = {
 	.attrs = fme_perf_cpumask_attrs,
 };
 
@@ -225,7 +225,7 @@  static struct attribute *fme_perf_format_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group fme_perf_format_group = {
+static const struct attribute_group fme_perf_format_group = {
 	.name = "format",
 	.attrs = fme_perf_format_attrs,
 };
@@ -239,7 +239,7 @@  static struct attribute *fme_perf_events_attrs_empty[] = {
 	NULL,
 };
 
-static struct attribute_group fme_perf_events_group = {
+static const struct attribute_group fme_perf_events_group = {
 	.name = "events",
 	.attrs = fme_perf_events_attrs_empty,
 };