lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260105223644.GA3633916-robh@kernel.org>
Date: Mon, 5 Jan 2026 16:36:44 -0600
From: Rob Herring <robh@...nel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Saravana Kannan <saravanak@...gle.com>,
	Nathan Chancellor <nathan@...nel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
	Bill Wendling <morbo@...gle.com>,
	Justin Stitt <justinstitt@...gle.com>,
	Russell King <linux@...linux.org.uk>,
	Nicolas Ferre <nicolas.ferre@...rochip.com>,
	Alexandre Belloni <alexandre.belloni@...tlin.com>,
	Claudiu Beznea <claudiu.beznea@...on.dev>,
	Krzysztof Kozlowski <krzk@...nel.org>,
	Alim Akhtar <alim.akhtar@...sung.com>,
	Madhavan Srinivasan <maddy@...ux.ibm.com>,
	Michael Ellerman <mpe@...erman.id.au>,
	Nicholas Piggin <npiggin@...il.com>,
	"Christophe Leroy (CS GROUP)" <chleroy@...nel.org>,
	Nipun Gupta <nipun.gupta@....com>,
	Nikhil Agarwal <nikhil.agarwal@....com>,
	Abel Vesa <abelvesa@...nel.org>, Peng Fan <peng.fan@....com>,
	Michael Turquette <mturquette@...libre.com>,
	Stephen Boyd <sboyd@...nel.org>, Shawn Guo <shawnguo@...nel.org>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,
	Fabio Estevam <festevam@...il.com>, Vinod Koul <vkoul@...nel.org>,
	Sylwester Nawrocki <s.nawrocki@...sung.com>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Viresh Kumar <viresh.kumar@...aro.org>,
	linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
	llvm@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
	linux-samsung-soc@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
	linux-clk@...r.kernel.org, imx@...ts.linux.dev,
	dmaengine@...r.kernel.org, linux-media@...r.kernel.org,
	linux-pm@...r.kernel.org,
	Jonathan Cameron <jonathan.cameron@...wei.com>
Subject: Re: [PATCH 01/11] of: Add for_each_compatible_node_scoped() helper

On Mon, Jan 05, 2026 at 02:33:39PM +0100, Krzysztof Kozlowski wrote:
> Just like looping through children and available children, add a scoped
> helper for for_each_compatible_node() so error paths can drop
> of_node_put() leading to simpler code.
> 
> Suggested-by: Jonathan Cameron <jonathan.cameron@...wei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com>
> 
> ---
> 
> Prerequisite for all further patches.
> ---
>  .clang-format      | 1 +
>  include/linux/of.h | 7 +++++++
>  2 files changed, 8 insertions(+)

You need to update scripts/dtc/dt-extract-compatibles

> 
> diff --git a/.clang-format b/.clang-format
> index c7060124a47a..1cc151e2adcc 100644
> --- a/.clang-format
> +++ b/.clang-format
> @@ -259,6 +259,7 @@ ForEachMacros:
>    - 'for_each_collection'
>    - 'for_each_comp_order'
>    - 'for_each_compatible_node'
> +  - 'for_each_compatible_node_scoped'
>    - 'for_each_component_dais'
>    - 'for_each_component_dais_safe'
>    - 'for_each_conduit'
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 9bbdcf25a2b4..be6ec4916adf 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -1485,6 +1485,13 @@ static inline int of_property_read_s32(const struct device_node *np,
>  #define for_each_compatible_node(dn, type, compatible) \
>  	for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
>  	     dn = of_find_compatible_node(dn, type, compatible))
> +
> +#define for_each_compatible_node_scoped(dn, type, compatible) \
> +	for (struct device_node *dn __free(device_node) =		\
> +	     of_find_compatible_node(NULL, type, compatible);		\
> +	     dn;							\
> +	     dn = of_find_compatible_node(dn, type, compatible))
> +
>  #define for_each_matching_node(dn, matches) \
>  	for (dn = of_find_matching_node(NULL, matches); dn; \
>  	     dn = of_find_matching_node(dn, matches))
> 
> -- 
> 2.51.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ