.../soc/mediatek/common/mtk-soundcard-driver.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
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
Hi Chen-Yu, kernel test robot noticed the following build warnings: [auto build test WARNING on broonie-sound/for-next] [also build test WARNING on broonie-spi/for-next linus/master v6.17-rc2 next-20250822] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Chen-Yu-Tsai/ASoC-mediatek-common-Switch-to-for_each_available_child_of_node_scoped/20250822-142918 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next patch link: https://lore.kernel.org/r/20250822062738.2632746-1-wenst%40chromium.org patch subject: [PATCH] ASoC: mediatek: common: Switch to for_each_available_child_of_node_scoped() config: x86_64-buildonly-randconfig-001-20250823 (https://download.01.org/0day-ci/archive/20250823/202508230528.DeD3hVns-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250823/202508230528.DeD3hVns-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202508230528.DeD3hVns-lkp@intel.com/ All warnings (new ones prefixed by >>): sound/soc/mediatek/common/mtk-soundcard-driver.c: In function 'parse_dai_link_info': >> sound/soc/mediatek/common/mtk-soundcard-driver.c:92:29: warning: unused variable 'sub_node' [-Wunused-variable] 92 | struct device_node *sub_node; | ^~~~~~~~ vim +/sub_node +92 sound/soc/mediatek/common/mtk-soundcard-driver.c c0e7390e6d3f42b Trevor Wu 2023-05-26 88 4302187d955f166 Trevor Wu 2023-01-16 89 int parse_dai_link_info(struct snd_soc_card *card) 4302187d955f166 Trevor Wu 2023-01-16 90 { 4302187d955f166 Trevor Wu 2023-01-16 91 struct device *dev = card->dev; 4302187d955f166 Trevor Wu 2023-01-16 @92 struct device_node *sub_node; 4302187d955f166 Trevor Wu 2023-01-16 93 struct snd_soc_dai_link *dai_link; 4302187d955f166 Trevor Wu 2023-01-16 94 const char *dai_link_name; 4302187d955f166 Trevor Wu 2023-01-16 95 int ret, i; 4302187d955f166 Trevor Wu 2023-01-16 96 4302187d955f166 Trevor Wu 2023-01-16 97 /* Loop over all the dai link sub nodes */ bd1311e421261f6 Chen-Yu Tsai 2025-08-22 98 for_each_available_child_of_node_scoped(dev->of_node, sub_node) { 4302187d955f166 Trevor Wu 2023-01-16 99 if (of_property_read_string(sub_node, "link-name", bd1311e421261f6 Chen-Yu Tsai 2025-08-22 100 &dai_link_name)) 4302187d955f166 Trevor Wu 2023-01-16 101 return -EINVAL; 4302187d955f166 Trevor Wu 2023-01-16 102 4302187d955f166 Trevor Wu 2023-01-16 103 for_each_card_prelinks(card, i, dai_link) { 4302187d955f166 Trevor Wu 2023-01-16 104 if (!strcmp(dai_link_name, dai_link->name)) 4302187d955f166 Trevor Wu 2023-01-16 105 break; 4302187d955f166 Trevor Wu 2023-01-16 106 } 4302187d955f166 Trevor Wu 2023-01-16 107 bd1311e421261f6 Chen-Yu Tsai 2025-08-22 108 if (i >= card->num_links) 4302187d955f166 Trevor Wu 2023-01-16 109 return -EINVAL; 4302187d955f166 Trevor Wu 2023-01-16 110 4302187d955f166 Trevor Wu 2023-01-16 111 ret = set_card_codec_info(card, sub_node, dai_link); bd1311e421261f6 Chen-Yu Tsai 2025-08-22 112 if (ret < 0) 4302187d955f166 Trevor Wu 2023-01-16 113 return ret; c0e7390e6d3f42b Trevor Wu 2023-05-26 114 c0e7390e6d3f42b Trevor Wu 2023-05-26 115 ret = set_dailink_daifmt(card, sub_node, dai_link); bd1311e421261f6 Chen-Yu Tsai 2025-08-22 116 if (ret < 0) c0e7390e6d3f42b Trevor Wu 2023-05-26 117 return ret; c0e7390e6d3f42b Trevor Wu 2023-05-26 118 } 4302187d955f166 Trevor Wu 2023-01-16 119 4302187d955f166 Trevor Wu 2023-01-16 120 return 0; 4302187d955f166 Trevor Wu 2023-01-16 121 } 4302187d955f166 Trevor Wu 2023-01-16 122 EXPORT_SYMBOL_GPL(parse_dai_link_info); 4302187d955f166 Trevor Wu 2023-01-16 123 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.