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 2AC85CDB47F for ; Wed, 24 Jun 2026 19:14:14 +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=8yBQiHhBbaPx10AJMO2mrSTzdi5w57PSOE51pnBcql4=; b=YaL2eNuNJDPR1P4aZK+Su4DjDb wGgvQU7twm+MkU7wJz3HYU/bY5YYdlrTxjjomL2UuzO70Bmb869xQ6SU+vr4KNZmDZH4rwhBm57GZ 9HfJ38xtYmeVydGkec9/SPtGr3/ZMMdfc6bIKEla74CF2ofoCMWVAZhoAA3YVSpjLa7Ddf5Jj/ZGg hCu1WWEMbpbDtEowQgEE8KdhGxKqhoYYMMaHKR8pf6KnV9/56I++ZGsir6+xbjQu94OLuKq5tsUPn qFhZOwahkqNSAmytHXDlEe8n21SsV/cakS7VIgV/CRv7e5la9eWSTx527/Ml6+BQ0KlbNgn9v6ggb 7dmkz4Jw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wcT30-00000008Fbb-1ead; Wed, 24 Jun 2026 19:14:06 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wcT2y-00000008Fan-1E31; Wed, 24 Jun 2026 19:14:05 +0000 Received: from killaraus.ideasonboard.com (2001-14ba-70f3-e800--a06.rev.dnainternet.fi [IPv6:2001:14ba:70f3:e800::a06]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 18912227; Wed, 24 Jun 2026 21:13:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1782328400; bh=TJrYqkEmzBcIuRk4NkFKPbj+WerEbvtlgsXw/+2tDE0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gFRWl17fewRBNx5IZw0ANyYPSgxXydfLNPrihsfkT0KjDgb+4aS3XufW5zBN+i2K7 Me3fSJ/Gp6uZkeqpuAXOP398GX7JFVCUvZDDSxI4OZWAazFuStseVJ+/u0GzXSbB3d 3dx270PDIVjhNVWXDtpBs9Mv5OX6V+dx3r/hN7Vw= Date: Wed, 24 Jun 2026 22:13:58 +0300 From: Laurent Pinchart To: Frank.Li@oss.nxp.com Cc: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Mauro Carvalho Chehab , Dafna Hirschfeld , Heiko Stuebner , Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , driver-core@lists.linux.dev, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, Guoniu Zhou , Frank Li , Guoniu Zhou Subject: Re: [PATCH v2 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped() Message-ID: <20260624191358.GC851255@killaraus.ideasonboard.com> References: <20260624-fw_scoped-v2-0-0a8db472af4a@nxp.com> <20260624-fw_scoped-v2-1-0a8db472af4a@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260624-fw_scoped-v2-1-0a8db472af4a@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260624_121404_482537_B34E263D X-CRM114-Status: GOOD ( 22.27 ) 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 Hi Frank, Thank you for the patch. On Wed, Jun 24, 2026 at 01:00:09PM -0400, Frank.Li@oss.nxp.com wrote: > From: Frank Li > > Similar to recently propose for_each_child_of_node_scoped() this new > version of the loop macro instantiates a new local struct fwnode_handle * > that uses the __free(fwnode_handle) auto cleanup handling so that if a > reference to a node is held on early exit from the loop the reference will > be released. If the loop runs to completion, the child pointer will be NULL > and no action will be taken. > > The reason this is useful is that it removes the need for > fwnode_handle_put() on early loop exits. If there is a need to retain the > reference, then return_ptr(child) or no_free_ptr(child) may be used to > safely disable the auto cleanup. > > Reviewed-by: Andy Shevchenko > Reviewed-by: Guoniu Zhou > Signed-off-by: Frank Li Nice idea. Reviewed-by: Laurent Pinchart > --- > change in v2 > - collect Andy and Guoniu's reviewed-by tags > - fix indention > - remove extra space in commit message > --- > include/linux/property.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/include/linux/property.h b/include/linux/property.h > index 14c304db46648..d51824c13d2cc 100644 > --- a/include/linux/property.h > +++ b/include/linux/property.h > @@ -545,6 +545,11 @@ unsigned int fwnode_graph_get_endpoint_count(const struct fwnode_handle *fwnode, > for (child = fwnode_graph_get_next_endpoint(fwnode, NULL); child; \ > child = fwnode_graph_get_next_endpoint(fwnode, child)) > > +#define fwnode_graph_for_each_endpoint_scoped(fwnode, child) \ > + for (struct fwnode_handle *child __free(fwnode_handle) = \ > + fwnode_graph_get_next_endpoint(fwnode, NULL); \ > + child; child = fwnode_graph_get_next_endpoint(fwnode, child)) > + > int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, > struct fwnode_endpoint *endpoint); > -- Regards, Laurent Pinchart