From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66F6319CD0B; Mon, 26 May 2025 08:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748247710; cv=none; b=glHF1xHB8Ky0xx3u0umSl0zlCoB1Qx7J/UTqLbfaYM0lwmRu5W/TWYwx2zOMjKJsXUlr3LAENIZTDuHqTE4UiguZ52l91XVofnUqRwFfWw8klug9TBm+PnniO0tlnlxpQT5u9N5QI2XuAE3hgW8gpCGFTj35zjbZxF9jJ5FFYDQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748247710; c=relaxed/simple; bh=kQpQyzSLFXzcV+bV7PWjdFj0k9dCEFAnIJ2CmkjTnDY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=JaBnK6YQ0FJhgPGI79FO+rSWsAtu8oXy/Wm+6M+/gxK5Qa8RF6W8gxE3M4iLaag5pzJZYjYjvKQnY31Z7u94x5Te2stvZN8dkuFH5ZvPOMIHk2Y+nZ9Z336DQM8VkwEGD3xqYkkLuDwRwr6xHUmYXS3leQrT3oBVRIioIfRNhFM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=T8sToZ3s; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="T8sToZ3s" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=kQpQyzSLFXzcV+bV7PWjdFj0k9dCEFAnIJ2CmkjTnDY=; t=1748247708; x=1749457308; b=T8sToZ3sH9mMQV3qqKQz+Mt805KsRLYSnezCuAjf7kvFJHL Y8Aoj7TNnMPQbJrcI7lGDuyNImOPKsCGJIJEe8sjG2QGVnE8UJ+SXzuARyMx52rlHXPfztWfpmHsK /FTanrBgfivQNLOix+t3LwO3whblFlmRuI//zghnr6OV3LPyTxsp1/bnAWARKbZndkJhgg/lzIT7K 6r532pfYN8KHuWL1PoO15+329lQhaiswVCKUvLmc7MVfYBCevLPtUBoCTZw8nW0JKWxTia8umkyIe /pJqFBhgPdkwN+bnyWZ1DBNOqLqHiAAo1OmqV4DqLy4RfFfTJ28JCOY/OFVpJrQQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uJT5X-0000000DQMg-1YY7; Mon, 26 May 2025 10:21:39 +0200 Message-ID: Subject: Re: [PATCH v2 2/6] ASoC: aoa: Use helper function for_each_child_of_node_scoped() From: Johannes Berg To: Ai Chao , perex , tiwai , "kuninori.morimoto.gx" , lgirdwood , broonie , jbrunet , "neil.armstrong" , khilman , "martin.blumenstingl" , "shengjiu.wang" , "Xiubo.Lee" , festevam , nicoleotsuka , shawnguo , "s.hauer" , "srinivas.kandagatla" Cc: linux-sound , linux-kernel , linuxppc-dev , linux-renesas-soc , linux-arm-kernel , linux-amlogic , imx , kernel , linux-arm-msm Date: Mon, 26 May 2025 10:21:37 +0200 In-Reply-To: <9ec008a8-b569-4ad1-9206-fe241fb1712d@kylinos.cn> References: <2aq0nyvyf7t-2aq4hsc7kp6@nsmail7.0.0--kylin--1> <7e708dcc98c6f0f615b1b87d190464cfe78be668.camel@sipsolutions.net> <23aadbd78d3585c900c579c26f360011cf1ca830.camel@sipsolutions.net> <9ec008a8-b569-4ad1-9206-fe241fb1712d@kylinos.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-malware-bazaar: not-scanned On Mon, 2025-05-26 at 16:20 +0800, Ai Chao wrote: > Hi Johannes: > > > Hi Johannes: > > >=20 > > > > > "simplifies the code" is no need to callof_node_put() . > > > > Fair. Except that's not what you _actually_ changed here. Like I sa= id, > > > > either it's buggy before or after. > > > >=20 > > > 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. > >=20 > > johannes >=20 > The for_each_child_of_node() function is used to iterate over all child= =20 > nodes of a device tree node. > During each iteration, it retrieves a pointer to the child node via=20 > of_get_next_child() and automatically increments the node's reference=20 > count (of_node_get()). > Each call to of_get_next_child() increases the reference count=20 > (refcount) of the returned child node, ensuring that the node is not=20 > freed while in use. > for_each_child_of_node() increments the child node's reference count in= =20 > each iteration but does not decrement it automatically. > If of_node_put() is not called manually, the reference count will never= =20 > reach zero, resulting in a memory leak of the node. Yes, good! Now show that you can apply what you've learned to the specific code (and changes) at hand. johannes