[PATCH] powercap: dtpm: constify OF match table

From: Can Peng

Date: Wed Jul 15 2026 - 03:18:26 EST


dtpm_create_hierarchy() only passes the OF match table to
of_machine_get_match_data(), which already takes a const struct
of_device_id pointer. The DTPM code does not modify the table.

Make the DTPM API const-correct and mark the Rockchip match table const as
well. This documents the read-only contract and allows the table to live
in read-only init data.

No functional change.

Signed-off-by: Can Peng <pengcan@xxxxxxxxxx>
---
drivers/powercap/dtpm.c | 2 +-
drivers/soc/rockchip/dtpm.c | 2 +-
include/linux/dtpm.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c
index b7a65e543f19..0a503dc38eb9 100644
--- a/drivers/powercap/dtpm.c
+++ b/drivers/powercap/dtpm.c
@@ -546,7 +546,7 @@ static int dtpm_for_each_child(const struct dtpm_node *hierarchy,
* Return: zero on success, a negative value in case of error. Errors
* are reported back from the underlying functions.
*/
-int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table)
+int dtpm_create_hierarchy(const struct of_device_id *dtpm_match_table)
{
const struct dtpm_node *hierarchy;
int i, ret;
diff --git a/drivers/soc/rockchip/dtpm.c b/drivers/soc/rockchip/dtpm.c
index b36d4f752c30..6f1ad9b24289 100644
--- a/drivers/soc/rockchip/dtpm.c
+++ b/drivers/soc/rockchip/dtpm.c
@@ -41,7 +41,7 @@ static struct dtpm_node __initdata rk3399_hierarchy[] = {
[9] = { /* sentinel */ }
};

-static struct of_device_id __initdata rockchip_dtpm_match_table[] = {
+static const struct of_device_id rockchip_dtpm_match_table[] __initconst = {
{ .compatible = "rockchip,rk3399", .data = rk3399_hierarchy },
{},
};
diff --git a/include/linux/dtpm.h b/include/linux/dtpm.h
index a4a13514b730..05993a55138e 100644
--- a/include/linux/dtpm.h
+++ b/include/linux/dtpm.h
@@ -67,7 +67,7 @@ void dtpm_unregister(struct dtpm *dtpm);

int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent);

-int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table);
+int dtpm_create_hierarchy(const struct of_device_id *dtpm_match_table);

void dtpm_destroy_hierarchy(void);
#endif
--
2.53.0