]> git.hungrycats.org Git - linux/commitdiff
thermal/of: support thermal zones w/o trips subnode
authorIcenowy Zheng <uwu@icenowy.me>
Fri, 18 Oct 2024 07:31:36 +0000 (15:31 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Nov 2024 12:15:13 +0000 (13:15 +0100)
[ Upstream commit 725f31f300e300a9d94976bd8f1db6e746f95f63 ]

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@icenowy.me>
[wenst@chromium.org: Reworked logic and kernel log messages]
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20241018073139.1268995-1-wenst@chromium.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/thermal/thermal_of.c

index 323c8cd1714851796dc54d4f39d5dc5f8f92e9d3..07476147559a51ac0db6b1fc628ef998f3f56b80 100644 (file)
@@ -238,18 +238,15 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
        struct device_node *trips;
        int ret, count;
 
+       *ntrips = 0;
+       
        trips = of_get_child_by_name(np, "trips");
-       if (!trips) {
-               pr_err("Failed to find 'trips' node\n");
-               return ERR_PTR(-EINVAL);
-       }
+       if (!trips)
+               return NULL;
 
        count = of_get_child_count(trips);
-       if (!count) {
-               pr_err("No trip point defined\n");
-               ret = -EINVAL;
-               goto out_of_node_put;
-       }
+       if (!count)
+               return NULL;
 
        tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL);
        if (!tt) {
@@ -272,7 +269,6 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
 
 out_kfree:
        kfree(tt);
-       *ntrips = 0;
 out_of_node_put:
        of_node_put(trips);
 
@@ -619,11 +615,14 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor,
 
        trips = thermal_of_trips_init(np, &ntrips);
        if (IS_ERR(trips)) {
-               pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
+               pr_err("Failed to parse trip points for %pOFn id=%d\n", sensor, id);
                ret = PTR_ERR(trips);
                goto out_kfree_of_ops;
        }
 
+       if (!trips)
+               pr_info("No trip points found for %pOFn id=%d\n", sensor, id);
+
        ret = thermal_of_monitor_init(np, &delay, &pdelay);
        if (ret) {
                pr_err("Failed to initialize monitoring delays from %pOFn\n", np);