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: <20240814175049.00001821@Huawei.com>
Date: Wed, 14 Aug 2024 17:50:49 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
CC: Krzysztof Kozlowski <krzk@...nel.org>, Nicolas Ferre
	<nicolas.ferre@...rochip.com>, Alexandre Belloni
	<alexandre.belloni@...tlin.com>, Claudiu Beznea <claudiu.beznea@...on.dev>,
	Lukasz Luba <lukasz.luba@....com>, Alim Akhtar <alim.akhtar@...sung.com>,
	Maxime Coquelin <mcoquelin.stm32@...il.com>, Alexandre Torgue
	<alexandre.torgue@...s.st.com>, Thierry Reding <thierry.reding@...il.com>,
	Jonathan Hunter <jonathanh@...dia.com>, Santosh Shilimkar
	<ssantosh@...nel.org>, <linux-kernel@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-pm@...r.kernel.org>,
	<linux-samsung-soc@...r.kernel.org>,
	<linux-stm32@...md-mailman.stormreply.com>, <linux-tegra@...r.kernel.org>
Subject: Re: [PATCH 5/9] memory: tegra-mc: simplify with scoped for each OF
 child loop

On Mon, 12 Aug 2024 15:33:59 +0200
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org> wrote:

> Use scoped for_each_child_of_node_scoped() when iterating over device
> nodes to make code a bit simpler.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
The final block is already a weird code structure, but your changes look fine
to me.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>

> ---
>  drivers/memory/tegra/mc.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
> index 224b488794e5..bd5b58f1fd42 100644
> --- a/drivers/memory/tegra/mc.c
> +++ b/drivers/memory/tegra/mc.c
> @@ -450,7 +450,6 @@ static int load_one_timing(struct tegra_mc *mc,
>  
>  static int load_timings(struct tegra_mc *mc, struct device_node *node)
>  {
> -	struct device_node *child;
>  	struct tegra_mc_timing *timing;
>  	int child_count = of_get_child_count(node);
>  	int i = 0, err;
> @@ -462,14 +461,12 @@ static int load_timings(struct tegra_mc *mc, struct device_node *node)
>  
>  	mc->num_timings = child_count;
>  
> -	for_each_child_of_node(node, child) {
> +	for_each_child_of_node_scoped(node, child) {
>  		timing = &mc->timings[i++];
>  
>  		err = load_one_timing(mc, timing, child);
> -		if (err) {
> -			of_node_put(child);
> +		if (err)
>  			return err;
> -		}
>  	}
>  
>  	return 0;
> @@ -477,7 +474,6 @@ static int load_timings(struct tegra_mc *mc, struct device_node *node)
>  
>  static int tegra_mc_setup_timings(struct tegra_mc *mc)
>  {
> -	struct device_node *node;
>  	u32 ram_code, node_ram_code;
>  	int err;
>  
> @@ -485,14 +481,13 @@ static int tegra_mc_setup_timings(struct tegra_mc *mc)
>  
>  	mc->num_timings = 0;
>  
> -	for_each_child_of_node(mc->dev->of_node, node) {
> +	for_each_child_of_node_scoped(mc->dev->of_node, node) {
>  		err = of_property_read_u32(node, "nvidia,ram-code",
>  					   &node_ram_code);
>  		if (err || (node_ram_code != ram_code))
>  			continue;
>  
>  		err = load_timings(mc, node);
> -		of_node_put(node);
>  		if (err)
>  			return err;
>  		break;
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ