[PATCH RESEND RESEND] thermal/of: support thermal zones w/o trips subnode
Icenowy Zheng
zhengxingda at iscas.ac.cn
Sat Jul 22 05:25:34 PDT 2023
From: Icenowy Zheng <uwu at icenowy.me>
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: d0c75fa2c17f ("thermal/of: Initialize trip points separately")
Signed-off-by: Icenowy Zheng <uwu at icenowy.me>
---
Unfortunately the code gets dropped by mailing lists again and again...
Sorry for the disturbance.
drivers/thermal/thermal_of.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 6fb14e521197..2c76df847e84 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -127,15 +127,17 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
trips = of_get_child_by_name(np, "trips");
if (!trips) {
- pr_err("Failed to find 'trips' node\n");
- return ERR_PTR(-EINVAL);
+ pr_debug("Failed to find 'trips' node\n");
+ *ntrips = 0;
+ return NULL;
}
count = of_get_child_count(trips);
if (!count) {
- pr_err("No trip point defined\n");
- ret = -EINVAL;
- goto out_of_node_put;
+ pr_debug("No trip point defined\n");
+ of_node_put(trips);
+ *ntrips = 0;
+ return NULL;
}
tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL);
@@ -519,7 +521,10 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
of_ops->bind = thermal_of_bind;
of_ops->unbind = thermal_of_unbind;
- mask = GENMASK_ULL((ntrips) - 1, 0);
+ if (ntrips)
+ mask = GENMASK_ULL((ntrips) - 1, 0);
+ else
+ mask = 0;
tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
mask, data, of_ops, tzp,
--
2.39.1
More information about the linux-arm-kernel
mailing list