mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 10:33:41 +02:00
ASoC: mediatek: common: Switch to for_each_available_child_of_node_scoped()
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> Reviewed-by: Fei Shao <fshao@chromium.org> Message-ID: <20250825151111.3696404-1-wenst@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
a12b74d2bd
commit
b088b6189a
|
|
@ -89,40 +89,31 @@ static int set_dailink_daifmt(struct snd_soc_card *card,
|
|||
int parse_dai_link_info(struct snd_soc_card *card)
|
||||
{
|
||||
struct device *dev = card->dev;
|
||||
struct device_node *sub_node;
|
||||
struct snd_soc_dai_link *dai_link;
|
||||
const char *dai_link_name;
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user