lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20211202143734.101760-3-rikard.falkeborn@gmail.com>
Date:   Thu,  2 Dec 2021 15:37:34 +0100
From:   Rikard Falkeborn <rikard.falkeborn@...il.com>
To:     Daniel Lezcano <daniel.lezcano@...nel.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Rikard Falkeborn <rikard.falkeborn@...il.com>
Subject: [PATCH 2/2] powercap/drivers/dtpm: Constify dtpm_ops

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@...il.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 --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);
 
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ