All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: mediatek: common: Switch to for_each_available_child_of_node_scoped()
@ 2025-08-22  6:27 Chen-Yu Tsai
  2025-08-22 21:31 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Chen-Yu Tsai @ 2025-08-22  6:27 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: Chen-Yu Tsai, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-mediatek, linux-kernel

Using for_each_available_child_of_node_scoped() allows us to get rid of
of_node_put() calls from early returns or breaks in the loop. It also
fixes issues with missing of_node_put() calls.

Switch to for_each_available_child_of_node_scoped() in parse_dai_link_info().
Also drop the braces around if blocks now that the inner block is just
one statement.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
 .../soc/mediatek/common/mtk-soundcard-driver.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/mediatek/common/mtk-soundcard-driver.c
index 95a083939f3e..1e3b43fbb16f 100644
--- a/sound/soc/mediatek/common/mtk-soundcard-driver.c
+++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c
@@ -95,34 +95,26 @@ int parse_dai_link_info(struct snd_soc_card *card)
 	int ret, i;
 
 	/* Loop over all the dai link sub nodes */
-	for_each_available_child_of_node(dev->of_node, sub_node) {
+	for_each_available_child_of_node_scoped(dev->of_node, sub_node) {
 		if (of_property_read_string(sub_node, "link-name",
-					    &dai_link_name)) {
-			of_node_put(sub_node);
+					    &dai_link_name))
 			return -EINVAL;
-		}
 
 		for_each_card_prelinks(card, i, dai_link) {
 			if (!strcmp(dai_link_name, dai_link->name))
 				break;
 		}
 
-		if (i >= card->num_links) {
-			of_node_put(sub_node);
+		if (i >= card->num_links)
 			return -EINVAL;
-		}
 
 		ret = set_card_codec_info(card, sub_node, dai_link);
-		if (ret < 0) {
-			of_node_put(sub_node);
+		if (ret < 0)
 			return ret;
-		}
 
 		ret = set_dailink_daifmt(card, sub_node, dai_link);
-		if (ret < 0) {
-			of_node_put(sub_node);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	return 0;
-- 
2.51.0.261.g7ce5a0a67e-goog



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-23  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22  6:27 [PATCH] ASoC: mediatek: common: Switch to for_each_available_child_of_node_scoped() Chen-Yu Tsai
2025-08-22 21:31 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.