Skip to contentSkip to conversation

powercap: dtpm: constify OF match table

PATCH New Can Peng 1 participant 1 message Jul 15

Subsystems (3)
lore
Share & tools
lore

Can Peng

author
#0 lore raw

PATCH 1/1 powercap: dtpm: constify OF match table

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.

---
 drivers/powercap/dtpm.c     | 2 +-
 drivers/soc/rockchip/dtpm.c | 2 +-
 include/linux/dtpm.h        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/powercap/dtpm.c +1 -1
index b7a65e543f19..0a503dc38eb9 100644
@@ -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;
drivers/soc/rockchip/dtpm.c +1 -1
index b36d4f752c30..6f1ad9b24289 100644
@@ -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 },
         {},
 };
include/linux/dtpm.h +1 -1
index a4a13514b730..05993a55138e 100644
@@ -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
Signature · 1 line
2.53.0