From patchwork Sat Jul 22 12:25:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Icenowy Zheng X-Patchwork-Id: 705556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D629EB64DC for ; Sat, 22 Jul 2023 12:33:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229551AbjGVMd0 (ORCPT ); Sat, 22 Jul 2023 08:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjGVMd0 (ORCPT ); Sat, 22 Jul 2023 08:33:26 -0400 X-Greylist: delayed 439 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 22 Jul 2023 05:33:22 PDT Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC29E74; Sat, 22 Jul 2023 05:33:22 -0700 (PDT) Received: from edelgard.fodlan.icenowy.me (unknown [120.85.97.227]) by APP-03 (Coremail) with SMTP id rQCowADX3sbIyrtkuWM4DQ--.21865S2; Sat, 22 Jul 2023 20:25:44 +0800 (CST) From: Icenowy Zheng To: Daniel Lezcano , Amit Kucheria , Zhang Rui , Mark Brown Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Icenowy Zheng Subject: [PATCH RESEND RESEND] thermal/of: support thermal zones w/o trips subnode Date: Sat, 22 Jul 2023 20:25:34 +0800 Message-Id: <20230722122534.2279689-1-zhengxingda@iscas.ac.cn> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-CM-TRANSID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enderInfo: x2kh0wp0lqwv3d6l2u1dvotugofq/ Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Icenowy Zheng 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 Reviewed-by: Mark Brown --- 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,