Re: [PATCH v2] powerpc: declare unmodified attribute_group usages const

2022-03-05 Thread Michael Ellerman
Christophe Leroy  writes:
> Le 04/03/2022 à 01:21, Rohan McLure a écrit :
>> Inspired by (bd75b4ef4977: Constify static attribute_group structs),
>> accepted by linux-next, reported:
>> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220210202805.7750-4-rikard.falkeb...@gmail.com/
>> 
>> Nearly all singletons of type struct attribute_group are never
>> modified, and so
>> are candidates for being const. Declare them as const.
>> 
>> Signed-off-by: Rohan McLure 
>> ---
>>   arch/powerpc/perf/generic-compat-pmu.c  | 4 ++--
>>   arch/powerpc/perf/hv-24x7.c | 6 +++---
>>   arch/powerpc/perf/hv-gpci.c | 8 
>>   arch/powerpc/perf/imc-pmu.c | 6 +++---
>>   arch/powerpc/perf/isa207-common.c   | 2 +-
>>   arch/powerpc/perf/power10-pmu.c | 6 +++---
>>   arch/powerpc/perf/power7-pmu.c  | 4 ++--
>>   arch/powerpc/perf/power8-pmu.c  | 4 ++--
>>   arch/powerpc/perf/power9-pmu.c  | 6 +++---
>>   arch/powerpc/platforms/cell/cbe_thermal.c   | 4 ++--
>>   arch/powerpc/platforms/powernv/opal-core.c  | 2 +-
>>   arch/powerpc/platforms/powernv/opal-dump.c  | 2 +-
>>   arch/powerpc/platforms/powernv/opal-flash.c | 2 +-
>>   arch/powerpc/platforms/pseries/papr_scm.c   | 2 +-
>>   arch/powerpc/platforms/pseries/power.c  | 2 +-
>>   15 files changed, 30 insertions(+), 30 deletions(-)
>> 
>
> /linux/arch/powerpc/platforms/cell/cbe_thermal.c: In function 
> 'thermal_init':
> /linux/arch/powerpc/platforms/cell/cbe_thermal.c:370:26: error: passing 
> argument 1 of 'spu_add_dev_attr_group' discards 'const' qualifier from 
> pointer target type [-Werror=discarded-qualifiers]
> spu_add_dev_attr_group(&spu_attribute_group);

Hi Rohan,

If you follow the instructions here:

  https://github.com/linuxppc/wiki/wiki/Testing-with-GitHub-Actions

You can get some automatic build tests done before you post, which would
have caught this.

cheers


Re: [PATCH v2] powerpc: declare unmodified attribute_group usages const

2022-03-04 Thread Christophe Leroy


Le 04/03/2022 à 01:21, Rohan McLure a écrit :
> Inspired by (bd75b4ef4977: Constify static attribute_group structs),
> accepted by linux-next, reported:
> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220210202805.7750-4-rikard.falkeb...@gmail.com/
> 
> Nearly all singletons of type struct attribute_group are never
> modified, and so
> are candidates for being const. Declare them as const.
> 
> Signed-off-by: Rohan McLure 
> ---
>   arch/powerpc/perf/generic-compat-pmu.c  | 4 ++--
>   arch/powerpc/perf/hv-24x7.c | 6 +++---
>   arch/powerpc/perf/hv-gpci.c | 8 
>   arch/powerpc/perf/imc-pmu.c | 6 +++---
>   arch/powerpc/perf/isa207-common.c   | 2 +-
>   arch/powerpc/perf/power10-pmu.c | 6 +++---
>   arch/powerpc/perf/power7-pmu.c  | 4 ++--
>   arch/powerpc/perf/power8-pmu.c  | 4 ++--
>   arch/powerpc/perf/power9-pmu.c  | 6 +++---
>   arch/powerpc/platforms/cell/cbe_thermal.c   | 4 ++--
>   arch/powerpc/platforms/powernv/opal-core.c  | 2 +-
>   arch/powerpc/platforms/powernv/opal-dump.c  | 2 +-
>   arch/powerpc/platforms/powernv/opal-flash.c | 2 +-
>   arch/powerpc/platforms/pseries/papr_scm.c   | 2 +-
>   arch/powerpc/platforms/pseries/power.c  | 2 +-
>   15 files changed, 30 insertions(+), 30 deletions(-)
> 

/linux/arch/powerpc/platforms/cell/cbe_thermal.c: In function 
'thermal_init':
/linux/arch/powerpc/platforms/cell/cbe_thermal.c:370:26: error: passing 
argument 1 of 'spu_add_dev_attr_group' discards 'const' qualifier from 
pointer target type [-Werror=discarded-qualifiers]
spu_add_dev_attr_group(&spu_attribute_group);
   ^
In file included from /linux/arch/powerpc/platforms/cell/cbe_thermal.c:40:0:
/linux/arch/powerpc/include/asm/spu.h:252:5: note: expected 'struct 
attribute_group *' but argument is of type 'const struct attribute_group *'
  int spu_add_dev_attr_group(struct attribute_group *attrs);
  ^
/linux/arch/powerpc/platforms/cell/cbe_thermal.c:371:26: error: passing 
argument 1 of 'cpu_add_dev_attr_group' discards 'const' qualifier from 
pointer target type [-Werror=discarded-qualifiers]
cpu_add_dev_attr_group(&ppe_attribute_group);
   ^
In file included from /linux/arch/powerpc/platforms/cell/cbe_thermal.c:38:0:
/linux/include/linux/cpu.h:47:12: note: expected 'struct attribute_group 
*' but argument is of type 'const struct attribute_group *'
  extern int cpu_add_dev_attr_group(struct attribute_group *attrs);
 ^
/linux/arch/powerpc/platforms/cell/cbe_thermal.c: In function 
'thermal_exit':
/linux/arch/powerpc/platforms/cell/cbe_thermal.c:380:28: error: passing 
argument 1 of 'spu_remove_dev_attr_group' discards 'const' qualifier 
from pointer target type [-Werror=discarded-qualifiers]
   spu_remove_dev_attr_group(&spu_attribute_group);
 ^
In file included from /linux/arch/powerpc/platforms/cell/cbe_thermal.c:40:0:
/linux/arch/powerpc/include/asm/spu.h:253:6: note: expected 'struct 
attribute_group *' but argument is of type 'const struct attribute_group *'
  void spu_remove_dev_attr_group(struct attribute_group *attrs);
   ^
/linux/arch/powerpc/platforms/cell/cbe_thermal.c:381:28: error: passing 
argument 1 of 'cpu_remove_dev_attr_group' discards 'const' qualifier 
from pointer target type [-Werror=discarded-qualifiers]
   cpu_remove_dev_attr_group(&ppe_attribute_group);
 ^
In file included from /linux/arch/powerpc/platforms/cell/cbe_thermal.c:38:0:
/linux/include/linux/cpu.h:48:13: note: expected 'struct attribute_group 
*' but argument is of type 'const struct attribute_group *'
  extern void cpu_remove_dev_attr_group(struct attribute_group *attrs);
  ^
cc1: all warnings being treated as errors
make[4]: *** [arch/powerpc/platforms/cell/cbe_thermal.o] Error 1
/linux/scripts/Makefile.build:288: recipe for target 
'arch/powerpc/platforms/cell/cbe_thermal.o' failed

[PATCH v2] powerpc: declare unmodified attribute_group usages const

2022-03-03 Thread Rohan McLure
Inspired by (bd75b4ef4977: Constify static attribute_group structs),
accepted by linux-next, reported:
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220210202805.7750-4-rikard.falkeb...@gmail.com/

Nearly all singletons of type struct attribute_group are never
modified, and so
are candidates for being const. Declare them as const.

Signed-off-by: Rohan McLure 
---
 arch/powerpc/perf/generic-compat-pmu.c  | 4 ++--
 arch/powerpc/perf/hv-24x7.c | 6 +++---
 arch/powerpc/perf/hv-gpci.c | 8 
 arch/powerpc/perf/imc-pmu.c | 6 +++---
 arch/powerpc/perf/isa207-common.c   | 2 +-
 arch/powerpc/perf/power10-pmu.c | 6 +++---
 arch/powerpc/perf/power7-pmu.c  | 4 ++--
 arch/powerpc/perf/power8-pmu.c  | 4 ++--
 arch/powerpc/perf/power9-pmu.c  | 6 +++---
 arch/powerpc/platforms/cell/cbe_thermal.c   | 4 ++--
 arch/powerpc/platforms/powernv/opal-core.c  | 2 +-
 arch/powerpc/platforms/powernv/opal-dump.c  | 2 +-
 arch/powerpc/platforms/powernv/opal-flash.c | 2 +-
 arch/powerpc/platforms/pseries/papr_scm.c   | 2 +-
 arch/powerpc/platforms/pseries/power.c  | 2 +-
 15 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/arch/powerpc/perf/generic-compat-pmu.c 
b/arch/powerpc/perf/generic-compat-pmu.c
index b6e25f75109d..f3db88aee4dd 100644
--- a/arch/powerpc/perf/generic-compat-pmu.c
+++ b/arch/powerpc/perf/generic-compat-pmu.c
@@ -130,7 +130,7 @@ static struct attribute *generic_compat_events_attr[] = {
NULL
 };
 
-static struct attribute_group generic_compat_pmu_events_group = {
+static const struct attribute_group generic_compat_pmu_events_group = {
.name = "events",
.attrs = generic_compat_events_attr,
 };
@@ -146,7 +146,7 @@ static struct attribute *generic_compat_pmu_format_attr[] = 
{
NULL,
 };
 
-static struct attribute_group generic_compat_pmu_format_group = {
+static const struct attribute_group generic_compat_pmu_format_group = {
.name = "format",
.attrs = generic_compat_pmu_format_attr,
 };
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 1e8aa934e37e..12c1777187fc 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -204,7 +204,7 @@ static struct attribute *format_attrs[] = {
NULL,
 };
 
-static struct attribute_group format_group = {
+static const struct attribute_group format_group = {
.name = "format",
.attrs = format_attrs,
 };
@@ -1148,7 +1148,7 @@ static struct attribute *cpumask_attrs[] = {
NULL,
 };
 
-static struct attribute_group cpumask_attr_group = {
+static const struct attribute_group cpumask_attr_group = {
.attrs = cpumask_attrs,
 };
 
@@ -1162,7 +1162,7 @@ static struct attribute *if_attrs[] = {
NULL,
 };
 
-static struct attribute_group if_group = {
+static const struct attribute_group if_group = {
.name = "interface",
.bin_attrs = if_bin_attrs,
.attrs = if_attrs,
diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index c756228a081f..5eb60ed5b5e8 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -65,12 +65,12 @@ static struct attribute *format_attrs[] = {
NULL,
 };
 
-static struct attribute_group format_group = {
+static const struct attribute_group format_group = {
.name = "format",
.attrs = format_attrs,
 };
 
-static struct attribute_group event_group = {
+static const struct attribute_group event_group = {
.name  = "events",
.attrs = hv_gpci_event_attrs,
 };
@@ -126,11 +126,11 @@ static struct attribute *cpumask_attrs[] = {
NULL,
 };
 
-static struct attribute_group cpumask_attr_group = {
+static const struct attribute_group cpumask_attr_group = {
.attrs = cpumask_attrs,
 };
 
-static struct attribute_group interface_group = {
+static const struct attribute_group interface_group = {
.name = "interface",
.attrs = interface_attrs,
 };
diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index e106909ff9c3..70981a321036 100644
--- a/arch/powerpc/perf/imc-pmu.c
+++ b/arch/powerpc/perf/imc-pmu.c
@@ -71,7 +71,7 @@ static struct attribute *imc_format_attrs[] = {
NULL,
 };
 
-static struct attribute_group imc_format_group = {
+static const struct attribute_group imc_format_group = {
.name = "format",
.attrs = imc_format_attrs,
 };
@@ -90,7 +90,7 @@ static struct attribute *trace_imc_format_attrs[] = {
NULL,
 };
 
-static struct attribute_group trace_imc_format_group = {
+static const struct attribute_group trace_imc_format_group = {
 .name = "format",
 .attrs = trace_imc_format_attrs,
 };
@@ -125,7 +125,7 @@ static struct attribute *imc_pmu_cpumask_attrs[] = {
NULL,
 };
 
-static struct attribute_group imc_pmu_cpumask_attr_group = {
+static const struct attribute_group imc_pmu_cpumask_attr_group = {
.attrs = imc_