From patchwork Mon Sep 9 07:19:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binbin Zhou X-Patchwork-Id: 13796164 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ABE71AED3E for ; Mon, 9 Sep 2024 07:19:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866394; cv=none; b=jCSVhnoaOPezGqA+ftDghWmWfwySpZfgvwn6p3szXGgzce22yp/M61ZMio52LP0qzFcGbh6CEf5/tQ63SSIH/bGvax761prR63k/OOxdIyKsjDg5HBPO8/cDBR0SH28opb4G02wzB9/99oZlyZs1H69bA6QKseAQriLIJ/pvflg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866394; c=relaxed/simple; bh=tQ9tI8fbsDBpMF4xv2L9qGPzuBFkN6oh6addtpmGrjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VCHnXKurZNleL2D3ZE0zGUpZeCi7ulAJ3VESnLwdrNV9yjhxsNW6ojVVtadaC4OnZC0hzkpC8ujggyfGoBdxat634t+NwxDdMs1ReMXbnFinSGyerQ/AcfCRMxTCh51lX4l73D6FNOA1/y4BebK6EUnSXWbUiRBu0H3f57ogFFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [223.64.68.147]) by gateway (Coremail) with SMTP id _____8BxPOqWod5mbZkCAA--.6120S3; Mon, 09 Sep 2024 15:19:50 +0800 (CST) Received: from localhost.localdomain (unknown [223.64.68.147]) by front1 (Coremail) with SMTP id qMiowMAxQNaQod5msioCAA--.7431S3; Mon, 09 Sep 2024 15:19:47 +0800 (CST) From: Binbin Zhou To: Binbin Zhou , Huacai Chen , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: Huacai Chen , Tang Bin , Kuninori Morimoto , Krzysztof Kozlowski , Pierre-Louis Bossart , linux-sound@vger.kernel.org, Xuerui Wang , loongarch@lists.linux.dev, Binbin Zhou Subject: [PATCH v1 5/8] ASoC: loongson: Simplify of_node_put() reference Date: Mon, 9 Sep 2024 15:19:35 +0800 Message-ID: <56a7aed94441f09ab28bb55a3e3955ce1da8f0f7.1725844530.git.zhoubinbin@loongson.cn> X-Mailer: git-send-email 2.43.5 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: qMiowMAxQNaQod5msioCAA--.7431S3 X-CM-SenderInfo: p2kr3uplqex0o6or00hjvr0hdfq/ X-Coremail-Antispam: 1Uk129KBj93XoWxJrW3Gry3tryrKw43WryfAFc_yoW8Cr48pF sxA39I9rWUJr1xurn5trW8Xa4ak34rWFsrWa17K3Wvkr9IyF1DWr17GF18ZFWakFy8t34D Zry8Kay0ga48GabCm3ZEXasCq-sJn29KB7ZKAUJUUUUD529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBmb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Gr1j6F4UJwAaw2AFwI0_JF0_Jw1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2 xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ ZF0_GryDMcIj6I8E87Iv67AKxVWxJVW8Jr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48Icx kI7VAKI48JMxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCj c4AY6r1j6r4UMxCIbckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxV Cjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY 6xIIjxv20xvE14v26F1j6w1UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcV CF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26F4j6r4UJwCI42IY6I8E87Iv 6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUx2Q6DUUUU 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 --- 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; }