@@ -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;
}
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@loongson.cn> --- sound/soc/loongson/loongson_card.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)