From patchwork Thu May 22 05:02:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ai Chao X-Patchwork-Id: 891987 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9018A1A5BBD; Thu, 22 May 2025 05:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747890224; cv=none; b=SGOqTsg3ElYyHL0rb2OXH0QaJFXLX39Oa7b9R8Umn2A4mYJJmpWK+uAwg8bsOe/cGsCH5Ry3IeJkBuCk/Lcqed5ghEbh/WWVKqplDDi8Y12bu9d72aS/VpU30UbiPvDv1mJSSfzU/YDUZIrlUZXW9ZOqng3S+UusVqq1NzqXnaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747890224; c=relaxed/simple; bh=QkIwbA+4b/t4KG3wul4jsM2v+1uGv7WMaXB/U42Cuxc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uxpI2MnLjk2BxJrzyhPGU2couy7ZmVEfK/c42kFAHBVsPX8aELg8drrUuNCI8A0+b+fbDutLgI7pRwdwawh/8qG1YbOGwRPyGuSKwVCBmFeeCnHyt8OdP2hHEVgzqvPq+r/MHfnPnv85Fk+vWmqMTQHoAsB/WVt/H28vJ+jhAO8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 1cbb10ca36ca11f0b29709d653e92f7d-20250522 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45, REQID:fadaa0c0-1669-4e2d-8fbf-1547de942e0f, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067, CLOUDID:82d79eed96e3b3d732c5fad996b78929, BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:-3,IP: nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,L ES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 1cbb10ca36ca11f0b29709d653e92f7d-20250522 Received: from node4.com.cn [(10.44.16.170)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 621894384; Thu, 22 May 2025 13:03:34 +0800 Received: from node4.com.cn (localhost [127.0.0.1]) by node4.com.cn (NSMail) with SMTP id D373216003840; Thu, 22 May 2025 13:03:33 +0800 (CST) X-ns-mid: postfix-682EB024-50849734 Received: from kylin-pc.. (unknown [172.25.130.133]) by node4.com.cn (NSMail) with ESMTPA id 7732A16001CC7; Thu, 22 May 2025 05:03:30 +0000 (UTC) From: Ai Chao To: perex@perex.cz, tiwai@suse.com, johannes@sipsolutions.net, kuninori.morimoto.gx@renesas.com, lgirdwood@gmail.com, broonie@kernel.org, jbrunet@baylibre.com, neil.armstrong@linaro.org, khilman@baylibre.com, martin.blumenstingl@googlemail.com, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, shawnguo@kernel.org, s.hauer@pengutronix.de, srinivas.kandagatla@linaro.org Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, imx@lists.linux.dev, kernel@pengutronix.de, linux-arm-msm@vger.kernel.org, Ai Chao Subject: [PATCH v2 5/6] ASoC: imx-card: Use helper function for_each_child_of_node_scoped() Date: Thu, 22 May 2025 13:02:58 +0800 Message-ID: <20250522050300.519244-6-aichao@kylinos.cn> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250522050300.519244-1-aichao@kylinos.cn> References: <20250522050300.519244-1-aichao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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; }