From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF27D16D9A2 for ; Fri, 9 Aug 2024 07:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723187335; cv=none; b=GPL8wLDjKwLw6VMtf8pcMYmvoF+jyrlug/7KbpAuSq7VCVYiIZBq4VpMmMxzfrft6NL1Jjh4HbhlwImUqM4vWWAqgzpNnl1OwkDT9+/Ckd7mnZepII+0ztQQHwhdfAMq+TMo9GDpDxAb6+IJFtaI7Rhw+hW0SrBzkW8DIfB0ldk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723187335; c=relaxed/simple; bh=1N26HGLw//R3d32px3tfcAXifr5s/f7rI6nJGtHpe08=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KzRKcqg41Og0SyZOmKOzwsJaIG4BxqiJAn28wZir8CzvJr3xKDGrz7t6nn4qjFPBEwt2e0hHB1cYSfrSQLp1UBAwbQmNsfg2yREUq19NmSri+tRm+wL82T2C4firD3YAAuC/UlCBgYdho8ozTkIBUTP8lvdAaBlY66vzqw+RdX8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Vqje6S5B; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Vqje6S5B" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1fd640a6454so16534855ad.3 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.linux.dev; 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=Vqje6S5BpYPPXWuSlDlqI9QjzJpgcF8NFAt4p9YtG0x8JdBw4BeJfYtWqFyrBZ02BM JbRvZ5StnBqsOc4LfwOs+PQhGtDHucPF952o3KMw8uYpNSaI4ueiX/nAO3vUX3KL1AjL dZ7NguThiVweviUhWDViBFTtw5cRSqTPZQOLE= 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=rQ96Jk2OHEQUHfwzNJE6k/j5MuOTCdvx4yE6JmHjlPyvQv9M0aupUcKTDeqtkuTZR2 2NWwWbOYG6OxZaJiqzLS1ERy0L/7V+F6qfTHdxP4NkhJ4f+JeOhO1wFEiZfWf33uWQCL xK/RQ8R5olex364Z40/EERTKPfEy3Yrh3IwWs9tgZUqL+7o8VPPOVRezf7rI2rZDkGD3 AGhYsRYvZ6rl10+cTxZvUh75vNIPhmMJPtxeMiLxbVTBUWjpiyI1ssdHC4Y2JeXZffRJ emaKg8vecAiW3WlyDftj9rhy7szNF4ux++s4nvmptfVFLTZe8RFU1ni1v5nC7p/ojyNj L8dQ== X-Forwarded-Encrypted: i=1; AJvYcCVd5yjpT7XdSyqoEd8xBm4BCavpPthebOWn86Qc7yxNH66pO4gdqu7I/byxRxNPfN15blqNBEOYBOKzTX9l4cI3ab/7eIylnghlkfo= X-Gm-Message-State: AOJu0YyOnLD2ElxctIiwVIt9+SQ06RKrKh7FawSqwgGBEKGfrbANCXvJ wSUkB9RbdqfTkcCoHIVYWne5zkrfA1CFKZpiOtgTWm18yhn416aMCZuuQFRvug== 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?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , 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 Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.46.0.76.ge559c4bf1a-goog