Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: declare unmodified attribute_group usages const

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.falkeborn@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 <rmclure@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220307231414.86560-1-rmclure@linux.ibm.com

authored by

Rohan McLure and committed by
Michael Ellerman
6b3a3e12 5986f6b6

+33 -33
+2 -2
arch/powerpc/include/asm/spu.h
··· 249 249 int spu_add_dev_attr(struct device_attribute *attr); 250 250 void spu_remove_dev_attr(struct device_attribute *attr); 251 251 252 - int spu_add_dev_attr_group(struct attribute_group *attrs); 253 - void spu_remove_dev_attr_group(struct attribute_group *attrs); 252 + int spu_add_dev_attr_group(const struct attribute_group *attrs); 253 + void spu_remove_dev_attr_group(const struct attribute_group *attrs); 254 254 255 255 extern void notify_spus_active(void); 256 256 extern void do_notify_spus_active(void);
+2 -2
arch/powerpc/perf/generic-compat-pmu.c
··· 130 130 NULL 131 131 }; 132 132 133 - static struct attribute_group generic_compat_pmu_events_group = { 133 + static const struct attribute_group generic_compat_pmu_events_group = { 134 134 .name = "events", 135 135 .attrs = generic_compat_events_attr, 136 136 }; ··· 146 146 NULL, 147 147 }; 148 148 149 - static struct attribute_group generic_compat_pmu_format_group = { 149 + static const struct attribute_group generic_compat_pmu_format_group = { 150 150 .name = "format", 151 151 .attrs = generic_compat_pmu_format_attr, 152 152 };
+3 -3
arch/powerpc/perf/hv-24x7.c
··· 204 204 NULL, 205 205 }; 206 206 207 - static struct attribute_group format_group = { 207 + static const struct attribute_group format_group = { 208 208 .name = "format", 209 209 .attrs = format_attrs, 210 210 }; ··· 1148 1148 NULL, 1149 1149 }; 1150 1150 1151 - static struct attribute_group cpumask_attr_group = { 1151 + static const struct attribute_group cpumask_attr_group = { 1152 1152 .attrs = cpumask_attrs, 1153 1153 }; 1154 1154 ··· 1162 1162 NULL, 1163 1163 }; 1164 1164 1165 - static struct attribute_group if_group = { 1165 + static const struct attribute_group if_group = { 1166 1166 .name = "interface", 1167 1167 .bin_attrs = if_bin_attrs, 1168 1168 .attrs = if_attrs,
+4 -4
arch/powerpc/perf/hv-gpci.c
··· 65 65 NULL, 66 66 }; 67 67 68 - static struct attribute_group format_group = { 68 + static const struct attribute_group format_group = { 69 69 .name = "format", 70 70 .attrs = format_attrs, 71 71 }; 72 72 73 - static struct attribute_group event_group = { 73 + static const struct attribute_group event_group = { 74 74 .name = "events", 75 75 .attrs = hv_gpci_event_attrs, 76 76 }; ··· 126 126 NULL, 127 127 }; 128 128 129 - static struct attribute_group cpumask_attr_group = { 129 + static const struct attribute_group cpumask_attr_group = { 130 130 .attrs = cpumask_attrs, 131 131 }; 132 132 133 - static struct attribute_group interface_group = { 133 + static const struct attribute_group interface_group = { 134 134 .name = "interface", 135 135 .attrs = interface_attrs, 136 136 };
+3 -3
arch/powerpc/perf/imc-pmu.c
··· 71 71 NULL, 72 72 }; 73 73 74 - static struct attribute_group imc_format_group = { 74 + static const struct attribute_group imc_format_group = { 75 75 .name = "format", 76 76 .attrs = imc_format_attrs, 77 77 }; ··· 90 90 NULL, 91 91 }; 92 92 93 - static struct attribute_group trace_imc_format_group = { 93 + static const struct attribute_group trace_imc_format_group = { 94 94 .name = "format", 95 95 .attrs = trace_imc_format_attrs, 96 96 }; ··· 125 125 NULL, 126 126 }; 127 127 128 - static struct attribute_group imc_pmu_cpumask_attr_group = { 128 + static const struct attribute_group imc_pmu_cpumask_attr_group = { 129 129 .attrs = imc_pmu_cpumask_attrs, 130 130 }; 131 131
+1 -1
arch/powerpc/perf/isa207-common.c
··· 37 37 NULL, 38 38 }; 39 39 40 - struct attribute_group isa207_pmu_format_group = { 40 + const struct attribute_group isa207_pmu_format_group = { 41 41 .name = "format", 42 42 .attrs = isa207_pmu_format_attr, 43 43 };
+3 -3
arch/powerpc/perf/power10-pmu.c
··· 200 200 NULL 201 201 }; 202 202 203 - static struct attribute_group power10_pmu_events_group_dd1 = { 203 + static const struct attribute_group power10_pmu_events_group_dd1 = { 204 204 .name = "events", 205 205 .attrs = power10_events_attr_dd1, 206 206 }; 207 207 208 - static struct attribute_group power10_pmu_events_group = { 208 + static const struct attribute_group power10_pmu_events_group = { 209 209 .name = "events", 210 210 .attrs = power10_events_attr, 211 211 }; ··· 253 253 NULL, 254 254 }; 255 255 256 - static struct attribute_group power10_pmu_format_group = { 256 + static const struct attribute_group power10_pmu_format_group = { 257 257 .name = "format", 258 258 .attrs = power10_pmu_format_attr, 259 259 };
+2 -2
arch/powerpc/perf/power7-pmu.c
··· 405 405 NULL 406 406 }; 407 407 408 - static struct attribute_group power7_pmu_events_group = { 408 + static const struct attribute_group power7_pmu_events_group = { 409 409 .name = "events", 410 410 .attrs = power7_events_attr, 411 411 }; ··· 417 417 NULL, 418 418 }; 419 419 420 - static struct attribute_group power7_pmu_format_group = { 420 + static const struct attribute_group power7_pmu_format_group = { 421 421 .name = "format", 422 422 .attrs = power7_pmu_format_attr, 423 423 };
+2 -2
arch/powerpc/perf/power8-pmu.c
··· 92 92 */ 93 93 94 94 /* PowerISA v2.07 format attribute structure*/ 95 - extern struct attribute_group isa207_pmu_format_group; 95 + extern const struct attribute_group isa207_pmu_format_group; 96 96 97 97 /* Table of alternatives, sorted by column 0 */ 98 98 static const unsigned int event_alternatives[][MAX_ALT] = { ··· 182 182 NULL 183 183 }; 184 184 185 - static struct attribute_group power8_pmu_events_group = { 185 + static const struct attribute_group power8_pmu_events_group = { 186 186 .name = "events", 187 187 .attrs = power8_events_attr, 188 188 };
+3 -3
arch/powerpc/perf/power9-pmu.c
··· 96 96 #define PVR_POWER9_CUMULUS 0x00002000 97 97 98 98 /* PowerISA v2.07 format attribute structure*/ 99 - extern struct attribute_group isa207_pmu_format_group; 99 + extern const struct attribute_group isa207_pmu_format_group; 100 100 101 101 int p9_dd21_bl_ev[] = { 102 102 PM_MRK_ST_DONE_L2, ··· 217 217 NULL 218 218 }; 219 219 220 - static struct attribute_group power9_pmu_events_group = { 220 + static const struct attribute_group power9_pmu_events_group = { 221 221 .name = "events", 222 222 .attrs = power9_events_attr, 223 223 }; ··· 253 253 NULL, 254 254 }; 255 255 256 - static struct attribute_group power9_pmu_format_group = { 256 + static const struct attribute_group power9_pmu_format_group = { 257 257 .name = "format", 258 258 .attrs = power9_pmu_format_attr, 259 259 };
+1 -1
arch/powerpc/platforms/cell/cbe_thermal.c
··· 255 255 NULL, 256 256 }; 257 257 258 - static struct attribute_group spu_attribute_group = { 258 + static const struct attribute_group spu_attribute_group = { 259 259 .name = "thermal", 260 260 .attrs = spu_attributes, 261 261 };
+2 -2
arch/powerpc/platforms/cell/spu_base.c
··· 490 490 } 491 491 EXPORT_SYMBOL_GPL(spu_add_dev_attr); 492 492 493 - int spu_add_dev_attr_group(struct attribute_group *attrs) 493 + int spu_add_dev_attr_group(const struct attribute_group *attrs) 494 494 { 495 495 struct spu *spu; 496 496 int rc = 0; ··· 529 529 } 530 530 EXPORT_SYMBOL_GPL(spu_remove_dev_attr); 531 531 532 - void spu_remove_dev_attr_group(struct attribute_group *attrs) 532 + void spu_remove_dev_attr_group(const struct attribute_group *attrs) 533 533 { 534 534 struct spu *spu; 535 535
+1 -1
arch/powerpc/platforms/powernv/opal-core.c
··· 603 603 604 604 }; 605 605 606 - static struct attribute_group mpipl_group = { 606 + static const struct attribute_group mpipl_group = { 607 607 .attrs = mpipl_attr, 608 608 .bin_attrs = mpipl_bin_attr, 609 609 };
+1 -1
arch/powerpc/platforms/powernv/opal-dump.c
··· 150 150 NULL, 151 151 }; 152 152 153 - static struct attribute_group initiate_attr_group = { 153 + static const struct attribute_group initiate_attr_group = { 154 154 .attrs = initiate_attrs, 155 155 }; 156 156
+1 -1
arch/powerpc/platforms/powernv/opal-flash.c
··· 512 512 NULL /* need to NULL terminate the list of attributes */ 513 513 }; 514 514 515 - static struct attribute_group image_op_attr_group = { 515 + static const struct attribute_group image_op_attr_group = { 516 516 .attrs = image_op_attrs, 517 517 }; 518 518
+1 -1
arch/powerpc/platforms/pseries/papr_scm.c
··· 1039 1039 NULL, 1040 1040 }; 1041 1041 1042 - static struct attribute_group papr_nd_attribute_group = { 1042 + static const struct attribute_group papr_nd_attribute_group = { 1043 1043 .name = "papr", 1044 1044 .is_visible = papr_nd_attribute_visible, 1045 1045 .attrs = papr_nd_attributes,
+1 -1
arch/powerpc/platforms/pseries/power.c
··· 51 51 NULL, 52 52 }; 53 53 54 - static struct attribute_group attr_group = { 54 + static const struct attribute_group attr_group = { 55 55 .attrs = g, 56 56 }; 57 57