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

Signed-off-by: Ai Chao <aichao@kylinos.cn>
Link: https://patch.msgid.link/20250603055109.3154061-5-aichao@kylinos.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/imx-card.c

index 9e668ae68039f51e9cadb11506ef00b11fec4f0b..ea5dbb54b5842a4379ffc2614a8effec686b6a14 100644 (file)
@@ -513,7 +513,6 @@ static int imx_card_parse_of(struct imx_card_data *data)
        struct device_node *platform = NULL;
        struct device_node *codec = NULL;
        struct device_node *cpu = NULL;
-       struct device_node *np;
        struct device *dev = card->dev;
        struct snd_soc_dai_link *link;
        struct dai_link_data *link_data;
@@ -552,11 +551,10 @@ static int imx_card_parse_of(struct imx_card_data *data)
        link = card->dai_link;
        link_data = data->link_data;
 
-       for_each_child_of_node(dev->of_node, np) {
+       for_each_child_of_node_scoped(dev->of_node, np) {
                dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL);
                if (!dlc) {
-                       ret = -ENOMEM;
-                       goto err_put_np;
+                       return -ENOMEM;
                }
 
                link->cpus      = &dlc[0];
@@ -567,8 +565,8 @@ static int imx_card_parse_of(struct imx_card_data *data)
 
                ret = of_property_read_string(np, "link-name", &link->name);
                if (ret) {
-                       dev_err(card->dev, "error getting codec dai_link name\n");
-                       goto err_put_np;
+                       return dev_err_probe(card->dev, ret,
+                                            "error getting codec dai_link name\n");
                }
 
                cpu = of_get_child_by_name(np, "cpu");
@@ -725,8 +723,7 @@ err:
        of_node_put(cpu);
        of_node_put(codec);
        of_node_put(platform);
-err_put_np:
-       of_node_put(np);
+
        return ret;
 }