[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230722122534.2279689-1-zhengxingda@iscas.ac.cn>
Date: Sat, 22 Jul 2023 20:25:34 +0800
From: Icenowy Zheng <zhengxingda@...as.ac.cn>
To: Daniel Lezcano <daniel.lezcano@...aro.org>,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Mark Brown <broonie@...nel.org>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
Icenowy Zheng <uwu@...nowy.me>
Subject: [PATCH RESEND RESEND] thermal/of: support thermal zones w/o trips subnode
From: Icenowy Zheng <uwu@...nowy.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@...nowy.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
Powered by blists - more mailing lists