[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250522050300.519244-6-aichao@kylinos.cn>
Date: Thu, 22 May 2025 13:02:58 +0800
From: Ai Chao <aichao@...inos.cn>
To: perex@...ex.cz,
tiwai@...e.com,
johannes@...solutions.net,
kuninori.morimoto.gx@...esas.com,
lgirdwood@...il.com,
broonie@...nel.org,
jbrunet@...libre.com,
neil.armstrong@...aro.org,
khilman@...libre.com,
martin.blumenstingl@...glemail.com,
shengjiu.wang@...il.com,
Xiubo.Lee@...il.com,
festevam@...il.com,
nicoleotsuka@...il.com,
shawnguo@...nel.org,
s.hauer@...gutronix.de,
srinivas.kandagatla@...aro.org
Cc: linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org,
linux-renesas-soc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-amlogic@...ts.infradead.org,
imx@...ts.linux.dev,
kernel@...gutronix.de,
linux-arm-msm@...r.kernel.org,
Ai Chao <aichao@...inos.cn>
Subject: [PATCH v2 5/6] ASoC: imx-card: Use helper function for_each_child_of_node_scoped()
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.
Thus, use this helper to simplify the code.
Signed-off-by: Ai Chao <aichao@...inos.cn>
---
sound/soc/fsl/imx-card.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index 3686d468506b..bffdba4292b6 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -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");
@@ -722,8 +720,7 @@ static int imx_card_parse_of(struct imx_card_data *data)
of_node_put(cpu);
of_node_put(codec);
of_node_put(platform);
-err_put_np:
- of_node_put(np);
+
return ret;
}
--
2.47.1
Powered by blists - more mailing lists