[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9ec008a8-b569-4ad1-9206-fe241fb1712d@kylinos.cn>
Date: Mon, 26 May 2025 16:20:37 +0800
From: Ai Chao <aichao@...inos.cn>
To: Johannes Berg <johannes@...solutions.net>, perex <perex@...ex.cz>,
tiwai <tiwai@...e.com>,
"kuninori.morimoto.gx" <kuninori.morimoto.gx@...esas.com>,
lgirdwood <lgirdwood@...il.com>, broonie <broonie@...nel.org>,
jbrunet <jbrunet@...libre.com>, "neil.armstrong"
<neil.armstrong@...aro.org>, khilman <khilman@...libre.com>,
"martin.blumenstingl" <martin.blumenstingl@...glemail.com>,
"shengjiu.wang" <shengjiu.wang@...il.com>, "Xiubo.Lee"
<Xiubo.Lee@...il.com>, festevam <festevam@...il.com>,
nicoleotsuka <nicoleotsuka@...il.com>, shawnguo <shawnguo@...nel.org>,
"s.hauer" <s.hauer@...gutronix.de>,
"srinivas.kandagatla" <srinivas.kandagatla@...aro.org>
Cc: linux-sound <linux-sound@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>,
linux-renesas-soc <linux-renesas-soc@...r.kernel.org>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
linux-amlogic <linux-amlogic@...ts.infradead.org>, imx
<imx@...ts.linux.dev>, kernel <kernel@...gutronix.de>,
linux-arm-msm <linux-arm-msm@...r.kernel.org>
Subject: Re: [PATCH v2 2/6] ASoC: aoa: Use helper function
for_each_child_of_node_scoped()
Hi Johannes:
>> Hi Johannes:
>>
>>>> "simplifies the code" is no need to callof_node_put() .
>>> Fair. Except that's not what you _actually_ changed here. Like I said,
>>> either it's buggy before or after.
>>>
>> In the function i2sbus_probe, it not return a struct device_node, so , I
>> think function for_each_child_of_node_scoped is better than
>> for_each_child_of_node.
> You still haven't explained why it's even correct.
>
> johannes
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.
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.
Best regards,
Ai Chao
Powered by blists - more mailing lists