[PATCH v1 5/8] ASoC: loongson: Simplify of_node_put() reference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



There are multiple references to of_node_put() in
loongson_card_parse_of(). We can merge them into one place to improve
code readability.

Signed-off-by: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>
---
 sound/soc/loongson/loongson_card.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/sound/soc/loongson/loongson_card.c b/sound/soc/loongson/loongson_card.c
index 3dd82caaae3b..4033cd7f09f6 100644
--- a/sound/soc/loongson/loongson_card.c
+++ b/sound/soc/loongson/loongson_card.c
@@ -114,45 +114,42 @@ static int loongson_card_parse_acpi(struct loongson_card_data *data)
 
 static int loongson_card_parse_of(struct loongson_card_data *data)
 {
-	struct device_node *cpu, *codec;
 	struct snd_soc_card *card = &data->snd_card;
+	struct device_node *cpu, *codec;
 	struct device *dev = card->dev;
-	int ret, i;
+	int ret = 0, i;
 
 	cpu = of_get_child_by_name(dev->of_node, "cpu");
 	if (!cpu) {
 		dev_err(dev, "platform property missing or invalid\n");
 		return -EINVAL;
 	}
+
 	codec = of_get_child_by_name(dev->of_node, "codec");
 	if (!codec) {
 		dev_err(dev, "audio-codec property missing or invalid\n");
-		of_node_put(cpu);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto cpu_put;
 	}
 
 	for (i = 0; i < card->num_links; i++) {
 		ret = snd_soc_of_get_dlc(cpu, NULL, loongson_dai_links[i].cpus, 0);
 		if (ret < 0) {
 			dev_err(dev, "getting cpu dlc error (%d)\n", ret);
-			goto err;
+			goto codec_put;
 		}
 
 		ret = snd_soc_of_get_dlc(codec, NULL, loongson_dai_links[i].codecs, 0);
 		if (ret < 0) {
 			dev_err(dev, "getting codec dlc error (%d)\n", ret);
-			goto err;
+			goto codec_put;
 		}
 	}
 
-	of_node_put(cpu);
+codec_put:
 	of_node_put(codec);
-
-	return 0;
-
-err:
+cpu_put:
 	of_node_put(cpu);
-	of_node_put(codec);
 	return ret;
 }
 
-- 
2.43.5





[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux