[PATCH v3 10/11] thermal/of: Process cooling device index in cooling-spec
From: Daniel Lezcano
Date: Wed Apr 29 2026 - 12:22:18 EST
The new DT bindings format describes a cooling device spec with the
cooling device node, the id and the mitigation limits.
Depending on the version of the DT bindings, in order to bind, check
with the device node pointer only or, in addition, the cooling device
id.
Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxxxxxxxx>
---
drivers/thermal/thermal_of.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index c9190a03993f..1c944daebec3 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -259,16 +259,34 @@ static bool thermal_of_get_cooling_spec(struct device_node *map_np, int index,
of_node_put(cooling_spec.np);
- if (cooling_spec.args_count < 2) {
- pr_err("wrong reference to cooling device, missing limits\n");
+ /*
+ * There are two formats:
+ * - Legacy format : <&cdev lower upper>
+ * - New format : <&cdev of_index lower upper>
+ *
+ * With the new format, along with the device node pointer,
+ * the of_index must match with the cooling device of_index in
+ * order to bind
+ */
+ if (cooling_spec.args_count < 2 || cooling_spec.args_count > 3) {
+ pr_err("Invalid number of cooling device parameters\n");
return false;
}
+ if (cooling_spec.args_count == 3 &&
+ cooling_spec.args[0] != cdev->of_index)
+ return false;
+
if (cooling_spec.np != cdev->np)
return false;
- c->lower = cooling_spec.args[0];
- c->upper = cooling_spec.args[1];
+ if (cooling_spec.args_count != 3) {
+ c->lower = cooling_spec.args[0];
+ c->upper = cooling_spec.args[1];
+ } else {
+ c->lower = cooling_spec.args[1];
+ c->upper = cooling_spec.args[2];
+ }
c->weight = weight;
return true;
--
2.43.0