From patchwork Fri Aug 9 07:08:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13758453 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4AB2C3DA4A for ; Fri, 9 Aug 2024 07:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=TSZy4qeB9prpZkXZFFSCy09Nr7J/x1zL/3+bFofkJV8=; b=h8nz85sdbvwVME0xZYkrA5KxbF hSpgj0887HYQrfmll6q0ebY6w5NhdzOBdyVnj4i3jP1aqkD0UGLrL4qrcODaO7dsJosALIoZhwQJ7 Y5wnvmFjnBHkolqbGGLaxdyu36aJPaMqPO1iF7Ub/4mDqECLlQ39a/YeR3q9xj5mZ0YSbDEaceCfi ZzuEoZj21Kmx6C8l1WX3p7BK7Itq/BQlwiC/+8qE3zc4724HHNi2XddD2YsY6t0Rtzr0dajIV+qJW wNzGWUX2WxH/KuyaZKMKhyeIVJraoID5hjW6uRYKjr6KeIF/C6fwFRUNcDpaO6u5u+Caw+HdVm8yH 3lmx5wjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scJkg-0000000AV4e-003u; Fri, 09 Aug 2024 07:09:30 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1scJk6-0000000AUxN-0GCQ for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 07:08:56 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1fc60c3ead4so14702175ad.0 for ; Fri, 09 Aug 2024 00:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723187333; x=1723792133; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TSZy4qeB9prpZkXZFFSCy09Nr7J/x1zL/3+bFofkJV8=; b=IGlhj1qbYVlzz9+DN4HjBFno8X9BJ/TOJoNdS7k/lcIDQhn1C9A92n/c8H1HZH158D cPPJjc1lt+VNBLeFgLh2ks+ll99RGq0IkcrQG10VTwFhUVSRrkuxNGPk/WxqKjDn6HbW rS0gzhJeEcwLzkHf/9nDn7/Pe23s0u0cl6w4A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723187333; x=1723792133; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TSZy4qeB9prpZkXZFFSCy09Nr7J/x1zL/3+bFofkJV8=; b=dHnjGEK58+9QTCJRQrzHp/11+cClLYJxn/0QL9OQyMWOW/8bJr8g7jMxRyzka6JMZ3 zoj+dhgp0U6lJ7HECCY/zHe2zjkHsaRCH3MxZ2+WXfQ5jqLCu2SBnjTkNRMGMsXKvFFk wRBQDhaJK7s5SB0VqVYJQPTWsxbafgZZV8RU5Van1QAh8qDvlGWbsY8rPdg9xgvMnVCL PQn/p7p1RawTbDSp4VzTlTXPQaj86GEnsJGcliCaJEpkta7UWpzSWIR/FMhsJxyizKP8 7JATNINopZakJPA7hU48/ieG612fej6rdjyJvHm1DAo9mJDYHLIX3QF/GPeWCUStNq2i ttxA== X-Forwarded-Encrypted: i=1; AJvYcCVJPy6p86d9becPoyO/Bo2PYmJuqQvrC9rRLlbGkxr0CAEjlKUQSV3w7HkvYR7SJVQJkUIdbJEXqBTOoI7HJVrVOnx8LJ07WnGp6eSrn5sQoTftHoM= X-Gm-Message-State: AOJu0YxDQtfagmDma7eE3Hcyk0J7iXJgj71uy7y8GhBf0MTcttDhF1xO T8MtiwpuDsCYT2bvKtL5PvsxhUgFfYcM4h0Zq6TFOkVSbENxgBHl61x3pAdP0s+Q5r5FylttIuw = X-Google-Smtp-Source: AGHT+IEojA8/Dm/IiJ94OPxhJiSpOpo4eMo23qz6LSsMPk8j238AnhJYY+ravisXXY3kEbh0Zu1A8A== X-Received: by 2002:a17:903:41ca:b0:1fb:7435:c2cc with SMTP id d9443c01a7336-200ae5e6889mr6909505ad.45.1723187333055; Fri, 09 Aug 2024 00:08:53 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:e48b:2b26:14f9:21cb]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff59294515sm136254215ad.244.2024.08.09.00.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 00:08:52 -0700 (PDT) From: Chen-Yu Tsai To: Daniel Lezcano , Amit Kucheria , Zhang Rui Cc: Icenowy Zheng , Mark Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , AngeloGioacchino Del Regno , Matthias Brugger , linux-mediatek@lists.infradead.org, Hsin-Te Yuan , Chen-Yu Tsai Subject: [PATCH v2] thermal/of: support thermal zones w/o trips subnode Date: Fri, 9 Aug 2024 15:08:19 +0800 Message-ID: <20240809070822.2835371-1-wenst@chromium.org> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_000854_153923_AE48FDC0 X-CRM114-Status: GOOD ( 16.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Signed-off-by: Chen-Yu Tsai --- Resurrecting this patch specifically for MediaTek MT8183 Kukui devices. Changes since v1: - set *ntrips at beginning of thermal_of_trips_init() - Keep goto out_of_node_put in of_get_child_count(trips) == 0 branch - Check return value of thermal_of_trips_init(), if it is -ENXIO, print warning and clear |trips| pointer - Drop |mask| change, as the variable was removed I kept Mark's reviewed-by since the changes are more stylish than functional. --- drivers/thermal/thermal_of.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index aa34b6e82e26..f237e74c92fc 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -128,16 +128,17 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n struct device_node *trips, *trip; 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); + pr_debug("Failed to find 'trips' node\n"); + return ERR_PTR(-ENXIO); } count = of_get_child_count(trips); if (!count) { - pr_err("No trip point defined\n"); - ret = -EINVAL; + pr_debug("No trip point defined\n"); + ret = -ENXIO; goto out_of_node_put; } @@ -162,7 +163,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); @@ -490,8 +490,13 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node * 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); - return ERR_CAST(trips); + if (PTR_ERR(trips) != -ENXIO) { + pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id); + return ERR_CAST(trips); + } + + pr_warn("Failed to find trip points for %pOFn id=%d\n", sensor, id); + trips = NULL; } ret = thermal_of_monitor_init(np, &delay, &pdelay);