]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: meson: Use helper function for_each_child_of_node_scoped()
authorAi Chao <aichao@kylinos.cn>
Tue, 3 Jun 2025 05:51:08 +0000 (13:51 +0800)
committerMark Brown <broonie@kernel.org>
Sun, 8 Jun 2025 22:30:49 +0000 (23:30 +0100)
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.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202505210557.EpJig9BQ-lkp@intel.com/
Signed-off-by: Ai Chao <aichao@kylinos.cn>
Link: https://patch.msgid.link/20250603055109.3154061-4-aichao@kylinos.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/meson/axg-card.c
sound/soc/meson/meson-card-utils.c

index a2dfccb7990f3a53f508fc6724b21de53b4494d8..b4dca80e15e400dd59ad641dd5f28f23ebe155b7 100644 (file)
@@ -222,7 +222,6 @@ static int axg_card_parse_codecs_masks(struct snd_soc_card *card,
                                       struct axg_dai_link_tdm_data *be)
 {
        struct axg_dai_link_tdm_mask *codec_mask;
-       struct device_node *np;
 
        codec_mask = devm_kcalloc(card->dev, link->num_codecs,
                                  sizeof(*codec_mask), GFP_KERNEL);
@@ -231,7 +230,7 @@ static int axg_card_parse_codecs_masks(struct snd_soc_card *card,
 
        be->codec_masks = codec_mask;
 
-       for_each_child_of_node(node, np) {
+       for_each_child_of_node_scoped(node, np) {
                snd_soc_of_get_slot_mask(np, "dai-tdm-slot-rx-mask",
                                         &codec_mask->rx);
                snd_soc_of_get_slot_mask(np, "dai-tdm-slot-tx-mask",
index 68531183fb60ca720f23508b4f3b6e0e5dc3a028..cdb759b466ad43ccafe5ddd93200eeea0f61c4ba 100644 (file)
@@ -137,7 +137,6 @@ int meson_card_set_be_link(struct snd_soc_card *card,
                           struct device_node *node)
 {
        struct snd_soc_dai_link_component *codec;
-       struct device_node *np;
        int ret, num_codecs;
 
        num_codecs = of_get_child_count(node);
@@ -154,19 +153,17 @@ int meson_card_set_be_link(struct snd_soc_card *card,
        link->codecs = codec;
        link->num_codecs = num_codecs;
 
-       for_each_child_of_node(node, np) {
+       for_each_child_of_node_scoped(node, np) {
                ret = meson_card_parse_dai(card, np, codec);
-               if (ret) {
-                       of_node_put(np);
+               if (ret)
                        return ret;
-               }
 
                codec++;
        }
 
        ret = meson_card_set_link_name(card, link, node, "be");
        if (ret)
-               dev_err(card->dev, "error setting %pOFn link name\n", np);
+               dev_err(card->dev, "error setting %pOFn link name\n", node);
 
        return ret;
 }
@@ -198,7 +195,6 @@ static int meson_card_add_links(struct snd_soc_card *card)
 {
        struct meson_card *priv = snd_soc_card_get_drvdata(card);
        struct device_node *node = card->dev->of_node;
-       struct device_node *np;
        int num, i, ret;
 
        num = of_get_child_count(node);
@@ -212,12 +208,10 @@ static int meson_card_add_links(struct snd_soc_card *card)
                return ret;
 
        i = 0;
-       for_each_child_of_node(node, np) {
+       for_each_child_of_node_scoped(node, np) {
                ret = priv->match_data->add_link(card, np, &i);
-               if (ret) {
-                       of_node_put(np);
+               if (ret)
                        return ret;
-               }
 
                i++;
        }