linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] drivers/perf: Constify static struct attribute_group
@ 2021-01-17 21:28 Rikard Falkeborn
  2021-01-17 21:28 ` [PATCH 1/4] perf: qcom: " Rikard Falkeborn
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Rikard Falkeborn @ 2021-01-17 21:28 UTC (permalink / raw)
  To: Will Deacon, Mark Rutland
  Cc: Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang, Andy Gross,
	Bjorn Andersson, linux-arm-kernel, linux-kernel, linux-arm-msm,
	Rikard Falkeborn

Thie series makes a number of static struct attribute_group const. The
only usage of the structs is to put their address in an array of pointers
to const struct * attribute_group. With this series applied, all but two
static struct attribute_group in drivers/perf are const (and the two
remaining are modified at runtime and can't be const).

Patches are independent and split based on output from get_maintainers.pl.
I can of course split differently if that's desired.

Done with the help of coccinelle.

Rikard Falkeborn (4):
  perf: qcom: Constify static struct attribute_group
  perf/imx_ddr: Constify static struct attribute_group
  perf: hisi: Constify static struct attribute_group
  perf: Constify static struct attribute_group

 drivers/perf/arm-cci.c                        |  2 +-
 drivers/perf/arm-cmn.c                        |  2 +-
 drivers/perf/arm_dmc620_pmu.c                 |  4 ++--
 drivers/perf/arm_pmu.c                        |  2 +-
 drivers/perf/arm_smmuv3_pmu.c                 |  8 ++++----
 drivers/perf/arm_spe_pmu.c                    |  6 +++---
 drivers/perf/fsl_imx8_ddr_perf.c              | 10 +++++-----
 drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c |  2 +-
 drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  |  2 +-
 drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  |  2 +-
 drivers/perf/qcom_l2_pmu.c                    |  6 +++---
 drivers/perf/qcom_l3_pmu.c                    |  6 +++---
 12 files changed, 26 insertions(+), 26 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] perf: qcom: Constify static struct attribute_group
  2021-01-17 21:28 [PATCH 0/4] drivers/perf: Constify static struct attribute_group Rikard Falkeborn
@ 2021-01-17 21:28 ` Rikard Falkeborn
  2021-01-17 21:28 ` [PATCH 2/4] perf/imx_ddr: " Rikard Falkeborn
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Rikard Falkeborn @ 2021-01-17 21:28 UTC (permalink / raw)
  To: Will Deacon, Mark Rutland, Bjorn Andersson, Andy Gross
  Cc: Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang, linux-arm-kernel,
	linux-kernel, linux-arm-msm, Rikard Falkeborn

The only usage is to put their addresses in an array of pointers to
const struct attribute group. Make them const to allow the compiler
to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/perf/qcom_l2_pmu.c | 6 +++---
 drivers/perf/qcom_l3_pmu.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c
index 23a0e008dafa..8883af955a2a 100644
--- a/drivers/perf/qcom_l2_pmu.c
+++ b/drivers/perf/qcom_l2_pmu.c
@@ -649,7 +649,7 @@ static struct attribute *l2_cache_pmu_cpumask_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group l2_cache_pmu_cpumask_group = {
+static const struct attribute_group l2_cache_pmu_cpumask_group = {
 	.attrs = l2_cache_pmu_cpumask_attrs,
 };
 
@@ -665,7 +665,7 @@ static struct attribute *l2_cache_pmu_formats[] = {
 	NULL,
 };
 
-static struct attribute_group l2_cache_pmu_format_group = {
+static const struct attribute_group l2_cache_pmu_format_group = {
 	.name = "format",
 	.attrs = l2_cache_pmu_formats,
 };
@@ -700,7 +700,7 @@ static struct attribute *l2_cache_pmu_events[] = {
 	NULL
 };
 
-static struct attribute_group l2_cache_pmu_events_group = {
+static const struct attribute_group l2_cache_pmu_events_group = {
 	.name = "events",
 	.attrs = l2_cache_pmu_events,
 };
diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c
index 9ddb577c542b..fb34b87b9471 100644
--- a/drivers/perf/qcom_l3_pmu.c
+++ b/drivers/perf/qcom_l3_pmu.c
@@ -630,7 +630,7 @@ static struct attribute *qcom_l3_cache_pmu_formats[] = {
 	NULL,
 };
 
-static struct attribute_group qcom_l3_cache_pmu_format_group = {
+static const struct attribute_group qcom_l3_cache_pmu_format_group = {
 	.name = "format",
 	.attrs = qcom_l3_cache_pmu_formats,
 };
@@ -663,7 +663,7 @@ static struct attribute *qcom_l3_cache_pmu_events[] = {
 	NULL
 };
 
-static struct attribute_group qcom_l3_cache_pmu_events_group = {
+static const struct attribute_group qcom_l3_cache_pmu_events_group = {
 	.name = "events",
 	.attrs = qcom_l3_cache_pmu_events,
 };
@@ -685,7 +685,7 @@ static struct attribute *qcom_l3_cache_pmu_cpumask_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group qcom_l3_cache_pmu_cpumask_attr_group = {
+static const struct attribute_group qcom_l3_cache_pmu_cpumask_attr_group = {
 	.attrs = qcom_l3_cache_pmu_cpumask_attrs,
 };
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] perf/imx_ddr: Constify static struct attribute_group
  2021-01-17 21:28 [PATCH 0/4] drivers/perf: Constify static struct attribute_group Rikard Falkeborn
  2021-01-17 21:28 ` [PATCH 1/4] perf: qcom: " Rikard Falkeborn
@ 2021-01-17 21:28 ` Rikard Falkeborn
  2021-01-17 21:28 ` [PATCH 3/4] perf: hisi: " Rikard Falkeborn
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Rikard Falkeborn @ 2021-01-17 21:28 UTC (permalink / raw)
  To: Will Deacon, Mark Rutland, Frank Li, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team
  Cc: Shaokun Zhang, Andy Gross, Bjorn Andersson, linux-arm-kernel,
	linux-kernel, linux-arm-msm, Rikard Falkeborn

The only usage is to put their addresses in an array of pointers to
const struct attribute group. Make them const to allow the compiler
to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/perf/fsl_imx8_ddr_perf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
index a11bfd8a0823..be1f26b62ddb 100644
--- a/drivers/perf/fsl_imx8_ddr_perf.c
+++ b/drivers/perf/fsl_imx8_ddr_perf.c
@@ -133,7 +133,7 @@ static struct attribute *ddr_perf_identifier_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group ddr_perf_identifier_attr_group = {
+static const struct attribute_group ddr_perf_identifier_attr_group = {
 	.attrs = ddr_perf_identifier_attrs,
 	.is_visible = ddr_perf_identifier_attr_visible,
 };
@@ -188,7 +188,7 @@ static struct attribute *ddr_perf_filter_cap_attr[] = {
 	NULL,
 };
 
-static struct attribute_group ddr_perf_filter_cap_attr_group = {
+static const struct attribute_group ddr_perf_filter_cap_attr_group = {
 	.name = "caps",
 	.attrs = ddr_perf_filter_cap_attr,
 };
@@ -209,7 +209,7 @@ static struct attribute *ddr_perf_cpumask_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group ddr_perf_cpumask_attr_group = {
+static const struct attribute_group ddr_perf_cpumask_attr_group = {
 	.attrs = ddr_perf_cpumask_attrs,
 };
 
@@ -265,7 +265,7 @@ static struct attribute *ddr_perf_events_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group ddr_perf_events_attr_group = {
+static const struct attribute_group ddr_perf_events_attr_group = {
 	.name = "events",
 	.attrs = ddr_perf_events_attrs,
 };
@@ -281,7 +281,7 @@ static struct attribute *ddr_perf_format_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group ddr_perf_format_attr_group = {
+static const struct attribute_group ddr_perf_format_attr_group = {
 	.name = "format",
 	.attrs = ddr_perf_format_attrs,
 };
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] perf: hisi: Constify static struct attribute_group
  2021-01-17 21:28 [PATCH 0/4] drivers/perf: Constify static struct attribute_group Rikard Falkeborn
  2021-01-17 21:28 ` [PATCH 1/4] perf: qcom: " Rikard Falkeborn
  2021-01-17 21:28 ` [PATCH 2/4] perf/imx_ddr: " Rikard Falkeborn
@ 2021-01-17 21:28 ` Rikard Falkeborn
  2021-01-17 21:28 ` [PATCH 4/4] perf: " Rikard Falkeborn
  2021-01-20 18:13 ` [PATCH 0/4] drivers/perf: " Will Deacon
  4 siblings, 0 replies; 6+ messages in thread
From: Rikard Falkeborn @ 2021-01-17 21:28 UTC (permalink / raw)
  To: Will Deacon, Mark Rutland, Shaokun Zhang
  Cc: Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Andy Gross, Bjorn Andersson,
	linux-arm-kernel, linux-kernel, linux-arm-msm, Rikard Falkeborn

The only usage is to put their addresses in an array of pointers to
const struct attribute group. Make them const to allow the compiler
to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 2 +-
 drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  | 2 +-
 drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
index 5ac6c9113767..ac1a8c120a00 100644
--- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
@@ -319,7 +319,7 @@ static struct attribute *hisi_ddrc_pmu_identifier_attrs[] = {
 	NULL
 };
 
-static struct attribute_group hisi_ddrc_pmu_identifier_group = {
+static const struct attribute_group hisi_ddrc_pmu_identifier_group = {
 	.attrs = hisi_ddrc_pmu_identifier_attrs,
 };
 
diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
index 41b2dceb5f26..3402f1a395a8 100644
--- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
@@ -331,7 +331,7 @@ static struct attribute *hisi_hha_pmu_identifier_attrs[] = {
 	NULL
 };
 
-static struct attribute_group hisi_hha_pmu_identifier_group = {
+static const struct attribute_group hisi_hha_pmu_identifier_group = {
 	.attrs = hisi_hha_pmu_identifier_attrs,
 };
 
diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
index 705501d18d03..7d792435c2aa 100644
--- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
@@ -321,7 +321,7 @@ static struct attribute *hisi_l3c_pmu_identifier_attrs[] = {
 	NULL
 };
 
-static struct attribute_group hisi_l3c_pmu_identifier_group = {
+static const struct attribute_group hisi_l3c_pmu_identifier_group = {
 	.attrs = hisi_l3c_pmu_identifier_attrs,
 };
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] perf: Constify static struct attribute_group
  2021-01-17 21:28 [PATCH 0/4] drivers/perf: Constify static struct attribute_group Rikard Falkeborn
                   ` (2 preceding siblings ...)
  2021-01-17 21:28 ` [PATCH 3/4] perf: hisi: " Rikard Falkeborn
@ 2021-01-17 21:28 ` Rikard Falkeborn
  2021-01-20 18:13 ` [PATCH 0/4] drivers/perf: " Will Deacon
  4 siblings, 0 replies; 6+ messages in thread
From: Rikard Falkeborn @ 2021-01-17 21:28 UTC (permalink / raw)
  To: Will Deacon, Mark Rutland
  Cc: Frank Li, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Shaokun Zhang, Andy Gross,
	Bjorn Andersson, linux-arm-kernel, linux-kernel, linux-arm-msm,
	Rikard Falkeborn

The only usage is to put their addresses in an array of pointers to
const struct attribute group. Make them const to allow the compiler
to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/perf/arm-cci.c        | 2 +-
 drivers/perf/arm-cmn.c        | 2 +-
 drivers/perf/arm_dmc620_pmu.c | 4 ++--
 drivers/perf/arm_pmu.c        | 2 +-
 drivers/perf/arm_smmuv3_pmu.c | 8 ++++----
 drivers/perf/arm_spe_pmu.c    | 6 +++---
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c
index 87c4be9dd412..a75cf77c4de4 100644
--- a/drivers/perf/arm-cci.c
+++ b/drivers/perf/arm-cci.c
@@ -1376,7 +1376,7 @@ static struct attribute *pmu_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group pmu_attr_group = {
+static const struct attribute_group pmu_attr_group = {
 	.attrs = pmu_attrs,
 };
 
diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index a76ff594f3ca..f30fcd330899 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -616,7 +616,7 @@ static struct attribute *arm_cmn_cpumask_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group arm_cmn_cpumask_attr_group = {
+static const struct attribute_group arm_cmn_cpumask_attr_group = {
 	.attrs = arm_cmn_cpumask_attrs,
 };
 
diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c
index 004930eb4bbb..27f54c0afc3b 100644
--- a/drivers/perf/arm_dmc620_pmu.c
+++ b/drivers/perf/arm_dmc620_pmu.c
@@ -159,7 +159,7 @@ static struct attribute *dmc620_pmu_events_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group dmc620_pmu_events_attr_group = {
+static const struct attribute_group dmc620_pmu_events_attr_group = {
 	.name = "events",
 	.attrs = dmc620_pmu_events_attrs,
 };
@@ -222,7 +222,7 @@ static struct attribute *dmc620_pmu_formats_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group dmc620_pmu_format_attr_group = {
+static const struct attribute_group dmc620_pmu_format_attr_group = {
 	.name	= "format",
 	.attrs	= dmc620_pmu_formats_attrs,
 };
diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
index cb2f55f450e4..2d10d84fb79c 100644
--- a/drivers/perf/arm_pmu.c
+++ b/drivers/perf/arm_pmu.c
@@ -577,7 +577,7 @@ static struct attribute *armpmu_common_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group armpmu_common_attr_group = {
+static const struct attribute_group armpmu_common_attr_group = {
 	.attrs = armpmu_common_attrs,
 };
 
diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
index 74474bb322c3..8ff7a67f691c 100644
--- a/drivers/perf/arm_smmuv3_pmu.c
+++ b/drivers/perf/arm_smmuv3_pmu.c
@@ -493,7 +493,7 @@ static struct attribute *smmu_pmu_cpumask_attrs[] = {
 	NULL
 };
 
-static struct attribute_group smmu_pmu_cpumask_group = {
+static const struct attribute_group smmu_pmu_cpumask_group = {
 	.attrs = smmu_pmu_cpumask_attrs,
 };
 
@@ -548,7 +548,7 @@ static umode_t smmu_pmu_event_is_visible(struct kobject *kobj,
 	return 0;
 }
 
-static struct attribute_group smmu_pmu_events_group = {
+static const struct attribute_group smmu_pmu_events_group = {
 	.name = "events",
 	.attrs = smmu_pmu_events,
 	.is_visible = smmu_pmu_event_is_visible,
@@ -583,7 +583,7 @@ static struct attribute *smmu_pmu_identifier_attrs[] = {
 	NULL
 };
 
-static struct attribute_group smmu_pmu_identifier_group = {
+static const struct attribute_group smmu_pmu_identifier_group = {
 	.attrs = smmu_pmu_identifier_attrs,
 	.is_visible = smmu_pmu_identifier_attr_visible,
 };
@@ -602,7 +602,7 @@ static struct attribute *smmu_pmu_formats[] = {
 	NULL
 };
 
-static struct attribute_group smmu_pmu_format_group = {
+static const struct attribute_group smmu_pmu_format_group = {
 	.name = "format",
 	.attrs = smmu_pmu_formats,
 };
diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index cc00915ad6d1..7593caf12555 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -146,7 +146,7 @@ static struct attribute *arm_spe_pmu_cap_attr[] = {
 	NULL,
 };
 
-static struct attribute_group arm_spe_pmu_cap_group = {
+static const struct attribute_group arm_spe_pmu_cap_group = {
 	.name	= "caps",
 	.attrs	= arm_spe_pmu_cap_attr,
 };
@@ -227,7 +227,7 @@ static struct attribute *arm_spe_pmu_formats_attr[] = {
 	NULL,
 };
 
-static struct attribute_group arm_spe_pmu_format_group = {
+static const struct attribute_group arm_spe_pmu_format_group = {
 	.name	= "format",
 	.attrs	= arm_spe_pmu_formats_attr,
 };
@@ -247,7 +247,7 @@ static struct attribute *arm_spe_pmu_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group arm_spe_pmu_group = {
+static const struct attribute_group arm_spe_pmu_group = {
 	.attrs	= arm_spe_pmu_attrs,
 };
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] drivers/perf: Constify static struct attribute_group
  2021-01-17 21:28 [PATCH 0/4] drivers/perf: Constify static struct attribute_group Rikard Falkeborn
                   ` (3 preceding siblings ...)
  2021-01-17 21:28 ` [PATCH 4/4] perf: " Rikard Falkeborn
@ 2021-01-20 18:13 ` Will Deacon
  4 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2021-01-20 18:13 UTC (permalink / raw)
  To: Rikard Falkeborn, Mark Rutland
  Cc: catalin.marinas, kernel-team, Will Deacon, Shaokun Zhang,
	Shawn Guo, linux-arm-msm, linux-arm-kernel, Bjorn Andersson,
	Frank Li, Sascha Hauer, linux-kernel, NXP Linux Team,
	Pengutronix Kernel Team, Andy Gross, Fabio Estevam

On Sun, 17 Jan 2021 22:28:43 +0100, Rikard Falkeborn wrote:
> Thie series makes a number of static struct attribute_group const. The
> only usage of the structs is to put their address in an array of pointers
> to const struct * attribute_group. With this series applied, all but two
> static struct attribute_group in drivers/perf are const (and the two
> remaining are modified at runtime and can't be const).
> 
> Patches are independent and split based on output from get_maintainers.pl.
> I can of course split differently if that's desired.
> 
> [...]

Applied to will (for-next/perf), thanks!

[1/4] perf: qcom: Constify static struct attribute_group
      https://git.kernel.org/will/c/30b34c4833ea
[2/4] perf/imx_ddr: Constify static struct attribute_group
      https://git.kernel.org/will/c/3cb7d2da183f
[3/4] perf: hisi: Constify static struct attribute_group
      https://git.kernel.org/will/c/c2c4d5c051b2
[4/4] perf: Constify static struct attribute_group
      https://git.kernel.org/will/c/f0c140481d1b

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-20 18:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-17 21:28 [PATCH 0/4] drivers/perf: Constify static struct attribute_group Rikard Falkeborn
2021-01-17 21:28 ` [PATCH 1/4] perf: qcom: " Rikard Falkeborn
2021-01-17 21:28 ` [PATCH 2/4] perf/imx_ddr: " Rikard Falkeborn
2021-01-17 21:28 ` [PATCH 3/4] perf: hisi: " Rikard Falkeborn
2021-01-17 21:28 ` [PATCH 4/4] perf: " Rikard Falkeborn
2021-01-20 18:13 ` [PATCH 0/4] drivers/perf: " Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).