From mboxrd@z Thu Jan 1 00:00:00 1970 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 736C9C52D7D for ; Thu, 15 Aug 2024 07:11:17 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=J08p29teShFomh8KvO2Ddu4MMDaSeQCVywSAkToMLKQ=; b=FdPCEd5J0wsg3RrZFg59kl5d0Q 1r70BX0ak+0yjxaO/5LFUgT9ts3nNxPekJ1qoxaarO5a37mx8Y7EYYKtj8Vf5EX4x+BphVzt2mG4R WoJJC2yO3PT8M2gIgOdaWF8w7MsVu19dzG266FK+qs2aCs7wd0IRA7Af9CnslFQxmRU2AOZTYbh/F OudVoWeVmK1QNu/3UGbvf6xL1Y8C0rvPZ6DA9OaAHKoIflfOKHekUIelxFNsxMYucufVFRitnT0IG T6WFvev0FPVTJLnBfFVp/SDMs8QTm2DL4hdqxIbYTHCueXsoLwWLyfbZEmyHWpzQ1urKdkf1su56L pIYE+IgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seUdW-00000009EZd-1GuW; Thu, 15 Aug 2024 07:11:06 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seUcs-00000009EVK-17Qe for linux-arm-kernel@lists.infradead.org; Thu, 15 Aug 2024 07:10:27 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70d1a74a43bso427826b3a.1 for ; Thu, 15 Aug 2024 00:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723705825; x=1724310625; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=J08p29teShFomh8KvO2Ddu4MMDaSeQCVywSAkToMLKQ=; b=QUhYpJnyWmxj2OQ82ZJwgbg3xb4dMK3Wvj1QNQsisXc/UJMiWGyj0Qp8W3ZlwwGFuM 0LdFcjIhU00G1kAOOu11cvSNZ7Snrx/R0X0LYT7gnOgqb+pJFy97GvvLzRUUGUEE28W4 Ggre56dF1C8E4XqRoa8PCK7uwAIIs4EuVHjCo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723705825; x=1724310625; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=J08p29teShFomh8KvO2Ddu4MMDaSeQCVywSAkToMLKQ=; b=A0uFDQRg/hluSdtEQPegKnvdU2Hfw90A7PpGfmSyVALqcpLhdT8xxF5aXNEQXcH9x8 fUyENNRCaJ09GB8BFmGc6CoWK/2r2jvWgujwbOY3G9T4je8LMp0CJsNGXkY2JWE8CUQa PEzxgnAbThYT32o07uaYOevvVHVCSL/iGtwJUP+lbdYIx6iUrys4ROmu56ik6kmuK+b6 YyIsOwd9fUkrUJiQxUhv+eeR7BHXjr8j/TLgDxUJ9+IZFSACSY3prqWUNxQdZXjNeYG8 KbxdMyyeoGHpEkVS9W8GjouOJRemGVUgGF6vjPk5ofyvGUQUyFGE/WDzIhn0x3OdrEgZ UF3w== X-Forwarded-Encrypted: i=1; AJvYcCXOj7rj6ztsDEG7fZKa4/Z+C1MSwJ6FUenuw0W5U0WZvxMblA+pvGO1Bc+6W8A8EvHV0IR6BXMLpOfibz2WRLglR6rClJ/sCJiB7ps1hiQ42x5Fa5A= X-Gm-Message-State: AOJu0YxDUF6BEKbz3EkZZX20TcHFQs7fTGFjJdu0Oz2ie2YQ1RmWdWkN Zg2eNYCFJhwHtXgqGVEpFXKtVIp373zElTlI+ogDFwvXI9oHtwyi/2h+q8qgcQ== X-Google-Smtp-Source: AGHT+IHiXJsW+fRg102OhEnKAhvxwqG0Aaky2UVkllFzxbNrNdYCyuMBqkLJT5RdAPJhpDiPBU7AYw== X-Received: by 2002:a05:6a00:4b49:b0:70e:8070:f9d0 with SMTP id d2e1a72fcca58-7126710d3a1mr6179895b3a.9.1723705824996; Thu, 15 Aug 2024 00:10:24 -0700 (PDT) Received: from google.com ([2401:fa00:1:10:745d:58f7:b3cd:901f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af19683sm536163b3a.163.2024.08.15.00.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 00:10:24 -0700 (PDT) Date: Thu, 15 Aug 2024 15:10:19 +0800 From: Chen-Yu Tsai To: Krzysztof Kozlowski Cc: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH 1/7] thermal: of: Use scoped device node handling to simplify of_find_trip_id() Message-ID: <20240815071019.GA350960@google.com> References: <20240814-b4-cleanup-h-of-node-put-thermal-v1-0-7a1381e1627e@linaro.org> <20240814-b4-cleanup-h-of-node-put-thermal-v1-1-7a1381e1627e@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240814-b4-cleanup-h-of-node-put-thermal-v1-1-7a1381e1627e@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240815_001026_331203_53C80AE1 X-CRM114-Status: GOOD ( 22.49 ) 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 On Wed, Aug 14, 2024 at 10:17:47PM +0200, Krzysztof Kozlowski wrote: > Obtain the device node reference with scoped/cleanup.h and use scoped > for_each_child_of_node_scoped() to reduce error handling in > of_find_trip_id() and make the code a bit simpler. > > Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai > --- > drivers/thermal/thermal_of.c | 20 ++++++-------------- > 1 file changed, 6 insertions(+), 14 deletions(-) > > diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c > index 1f252692815a..a2278d4ad886 100644 > --- a/drivers/thermal/thermal_of.c > +++ b/drivers/thermal/thermal_of.c > @@ -8,6 +8,7 @@ > > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > +#include > #include > #include > #include > @@ -22,11 +23,9 @@ > > static int of_find_trip_id(struct device_node *np, struct device_node *trip) > { > - struct device_node *trips; > - struct device_node *t; > int i = 0; > > - trips = of_get_child_by_name(np, "trips"); > + struct device_node *trips __free(device_node) = of_get_child_by_name(np, "trips"); > if (!trips) { > pr_err("Failed to find 'trips' node\n"); > return -EINVAL; > @@ -35,20 +34,13 @@ static int of_find_trip_id(struct device_node *np, struct device_node *trip) > /* > * Find the trip id point associated with the cooling device map > */ > - for_each_child_of_node(trips, t) { > - > - if (t == trip) { > - of_node_put(t); > - goto out; > - } > + for_each_child_of_node_scoped(trips, t) { > + if (t == trip) > + return i; > i++; > } > > - i = -ENXIO; > -out: > - of_node_put(trips); > - > - return i; > + return -ENXIO; > } > > /* > > -- > 2.43.0 >