Skip to content

Commit 725f31f

Browse files
Icenowydlezcano
authored andcommitted
thermal/of: support thermal zones w/o trips subnode
Although the current device tree binding of thermal zones require the trips subnode, the binding in kernel v5.15 does not require it, and many device trees shipped with the kernel, for example, allwinner/sun50i-a64.dtsi and mediatek/mt8183-kukui.dtsi in ARM64, still comply to the old binding and contain no trips subnode. Allow the code to successfully register thermal zones w/o trips subnode for DT binding compatibility now. Furtherly, the inconsistency between DTs and bindings should be resolved by either adding empty trips subnode or dropping the trips subnode requirement. Fixes: d0c75fa ("thermal/of: Initialize trip points separately") Signed-off-by: Icenowy Zheng <[email protected]> [[email protected]: Reworked logic and kernel log messages] Signed-off-by: Chen-Yu Tsai <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent c5426dc commit 725f31f

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

drivers/thermal/thermal_of.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,15 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
9999
struct device_node *trips;
100100
int ret, count;
101101

102+
*ntrips = 0;
103+
102104
trips = of_get_child_by_name(np, "trips");
103-
if (!trips) {
104-
pr_err("Failed to find 'trips' node\n");
105-
return ERR_PTR(-EINVAL);
106-
}
105+
if (!trips)
106+
return NULL;
107107

108108
count = of_get_child_count(trips);
109-
if (!count) {
110-
pr_err("No trip point defined\n");
111-
ret = -EINVAL;
112-
goto out_of_node_put;
113-
}
109+
if (!count)
110+
return NULL;
114111

115112
tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL);
116113
if (!tt) {
@@ -133,7 +130,6 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
133130

134131
out_kfree:
135132
kfree(tt);
136-
*ntrips = 0;
137133
out_of_node_put:
138134
of_node_put(trips);
139135

@@ -401,11 +397,14 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
401397

402398
trips = thermal_of_trips_init(np, &ntrips);
403399
if (IS_ERR(trips)) {
404-
pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
400+
pr_err("Failed to parse trip points for %pOFn id=%d\n", sensor, id);
405401
ret = PTR_ERR(trips);
406402
goto out_of_node_put;
407403
}
408404

405+
if (!trips)
406+
pr_info("No trip points found for %pOFn id=%d\n", sensor, id);
407+
409408
ret = thermal_of_monitor_init(np, &delay, &pdelay);
410409
if (ret) {
411410
pr_err("Failed to initialize monitoring delays from %pOFn\n", np);

0 commit comments

Comments
 (0)