[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <758b0ad2-e337-4be6-a7da-4d5af8b193d1@kylinos.cn>
Date: Wed, 21 May 2025 09:58:54 +0800
From: Ai Chao <aichao@...inos.cn>
To: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
srinivas.kandagatla@...aro.org, lgirdwood@...il.com, broonie@...nel.org,
perex@...ex.cz, tiwai@...e.com, aichao@...inos.cn
Cc: linux-sound@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 6/6] ASoC: qcom: Use helper function
for_each_child_of_node_scoped()
Hi Krzysztof :
Thanks for your help.
The for_each_child_of_node() function is used to iterate over all
child nodes of a device tree node. During each iteration, it retrieves a
pointer to the child node via of_get_next_child() and automatically
increments the node's reference count (of_node_get()). Each call to
of_get_next_child() increases the reference count (refcount) of the
returned child node, ensuring that the node is not freed while in use.
The of_node_put() function is used to decrement the node's
reference count. When the reference count drops to zero, the kernel
releases the memory occupied by the node.for_each_child_of_node()
increments the child node's reference count in each iteration but does
not decrement it automatically. If of_node_put() is not called manually,
the reference count will never reach zero, resulting in a memory leak of
the node.
On 2025/5/20 17:19, Krzysztof Kozlowski wrote:
> On 20/05/2025 11:11, Ai Chao wrote:
>> The for_each_child_of_node_scoped() helper provides a scope-based
>> clean-up functionality to put the device_node automatically, and
>> as such, there is no need to call of_node_put() directly.
>
> I do not see any of_node_put() there, so I don't understand what is the
> benefit of this and how this commit msg explains reason behind the change.
>
> Best regards,
> Krzysztof
Powered by blists - more mailing lists