diff mbox series

[2/2] powercap/drivers/dtpm: Constify dtpm_ops

Message ID 20211202143734.101760-3-rikard.falkeborn@gmail.com (mailing list archive)
State New, archived
Delegated to: Daniel Lezcano
Headers show
Series powercap/drivers/dtpm: Constify static ops structs | expand

Commit Message

Rikard Falkeborn Dec. 2, 2021, 2:37 p.m. UTC
dtpm_ops is never modified, so update functions and structs to reflect
that, and constify the one static instance to allow the compiler to put
it in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/powercap/dtpm.c     | 2 +-
 drivers/powercap/dtpm_cpu.c | 2 +-
 include/linux/dtpm.h        | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c
index d7ac5e79fee1..07e4dec604de 100644
--- a/drivers/powercap/dtpm.c
+++ b/drivers/powercap/dtpm.c
@@ -361,7 +361,7 @@  static const struct powercap_zone_ops zone_ops = {
  * @dtpm: The dtpm struct pointer to be initialized
  * @ops: The dtpm device specific ops, NULL for a virtual node
  */
-void dtpm_init(struct dtpm *dtpm, struct dtpm_ops *ops)
+void dtpm_init(struct dtpm *dtpm, const struct dtpm_ops *ops)
 {
 	if (dtpm) {
 		INIT_LIST_HEAD(&dtpm->children);
diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c
index b740866b228d..2eeff292ffbe 100644
--- a/drivers/powercap/dtpm_cpu.c
+++ b/drivers/powercap/dtpm_cpu.c
@@ -157,7 +157,7 @@  static void pd_release(struct dtpm *dtpm)
 	kfree(dtpm_cpu);
 }
 
-static struct dtpm_ops dtpm_ops = {
+static const struct dtpm_ops dtpm_ops = {
 	.set_power_uw	 = set_pd_power_limit,
 	.get_power_uw	 = get_pd_power_uw,
 	.update_power_uw = update_pd_power_uw,
diff --git a/include/linux/dtpm.h b/include/linux/dtpm.h
index 2890f6370eb9..883f5ab213f3 100644
--- a/include/linux/dtpm.h
+++ b/include/linux/dtpm.h
@@ -17,7 +17,7 @@  struct dtpm {
 	struct dtpm *parent;
 	struct list_head sibling;
 	struct list_head children;
-	struct dtpm_ops *ops;
+	const struct dtpm_ops *ops;
 	unsigned long flags;
 	u64 power_limit;
 	u64 power_max;
@@ -64,7 +64,7 @@  int dtpm_update_power(struct dtpm *dtpm);
 
 int dtpm_release_zone(struct powercap_zone *pcz);
 
-void dtpm_init(struct dtpm *dtpm, struct dtpm_ops *ops);
+void dtpm_init(struct dtpm *dtpm, const struct dtpm_ops *ops);
 
 void dtpm_unregister(struct dtpm *dtpm);