Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp1165895rwo; Sat, 22 Jul 2023 07:46:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlGM4kJNSRrRMDCrVaEUBQJkNGpSpgG9WXkxvA2iOaaZ+MsqtalhITctDsU5z74hAo5S7EcD X-Received: by 2002:a17:90a:2bce:b0:263:7d8:4a with SMTP id n14-20020a17090a2bce00b0026307d8004amr7919597pje.18.1690037196650; Sat, 22 Jul 2023 07:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690037196; cv=none; d=google.com; s=arc-20160816; b=V7AcNgc8PrrILwAZ5Wgz4tTrCF3E+WkUwmQvkoqWJ4W1J5UTk1UxUBf7Cxxyk+CZQy aHokmrPo7gSPEhdyvGxQtz+ERlmmGrXSTi+nWZ41HsUMLIUmyMrfXELlqrxC4JQ3A6+L CTNl3BkAG/EVT+cWT4e1jQ/irJfBnllRYBYdSBQ3ok+29fljKWO0c4LI6zlzEbgOGi6f MofhT63Bnt554VpxQBDz5ud2Tk73zmrBAEEFur6jGmWY5rbC6YYUvERGliCrrCDvZ621 PLTtH/4O5Rr5BEDhppC6W17r0wo6zAuyS0JXNELwSiybtiot47ByMhsSdrz00jC+LCqW 4QoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=v4Mf/dOAr/p3BpqNKcirqA2NYsu6+oxA1qKxBC8zNjo=; fh=0hj141GHdhVN5gNrCdHtcBmsb9j7cqRkqPItIeSX2/k=; b=CWklnf5Dg/tgsAoUYNksemWMCS0Cp1qwgWfQaO1LLa0Ye09Ib//AUs4l3h6zlCItoo 3IQi1lMIoJKW0f5CItmPCzRb0pPSaB38OnhL+VsJv7B4P10HPBUmohyThHc/7j9cln7p srDozFDAq0chEpPJl/ulUgsmWu2o+ztqhE2EmP7SKVMrhwweumDBGljdnLiLc7Ctlip+ dvaarwpPgaqbda9fNjS8bak4PW0O1Es1jP8CZLwF/0sESwZwea+gfBomJvPJSN3otq9b /hTrnaafGGYPQq9PoAsGOtO2X02ZmQgjlt0N/SmPWWxyXXTmBfYdARKHxrHbTORuwbZV FrGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y8-20020a17090a86c800b00263dccf9202si5318055pjv.156.2023.07.22.07.46.24; Sat, 22 Jul 2023 07:46:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbjGVMd1 (ORCPT + 99 others); Sat, 22 Jul 2023 08:33:27 -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 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowADX3sbIyrtkuWM4DQ--.21865S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ArWkCryrGr4fJry3ArykAFb_yoW8tr45pF 43G3s0yrWkJFs7G3Z2yF18XFZ0kr10yFWxZ3yIkas0ya9xJrWaq3yUJryYqryxCFy8XFWa yryqkryY9FWDJaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyab7Iv0xC_tr1lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC2 0s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI 0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE 14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20x vaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8 JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8FfO7UUUUU== X-Originating-IP: [120.85.97.227] X-CM-SenderInfo: x2kh0wp0lqwv3d6l2u1dvotugofq/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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