From patchwork Tue Aug 27 11:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E136C54735 for ; Tue, 27 Aug 2024 11:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jkEOqyUxcBoPPL5BncIqsc96Qi8FOwtCEEq+nb0MFfA=; b=BoGT0vuc9/MG4TUN1rS/P/piGB Hv/MhEDexkbgTcKBiO4fFo/tCghlMKO8n4JP6oDbQ3RSfVXpH8xY+7lWgm30O5//xA19nt/Pju3hO PFjV8VYPMucR5TSgv2jTkDghAKX27KbPFWS8dS63LA2l81Gt6/HV0Nw/68wqFp04usUJwsSf24pnE fa/Y5uZ3yN87YYH/Wg4bCuWj7f1w99ktbAPDxsUEnvmucCg4Uq7xXbHdeza7wU7WYXdL4jAyAsitg 8oz1q7gu8B6uZyaMJdkBYfApVlyIjWIsVGsFt/0L1JrwtBKGjYtnqeEdGoe3ATL5lIYLDjFGEb+kJ ZFCyUYig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuap-0000000B4L2-3DvO; Tue, 27 Aug 2024 11:42:35 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuWk-0000000B2gg-1AAc for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 11:38:26 +0000 Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WtQQr3KRVz20mN6; Tue, 27 Aug 2024 19:33:24 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id B66FB180019; Tue, 27 Aug 2024 19:38:12 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 19:38:11 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 1/8] soc: fsl: cpm1: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:00 +0800 Message-ID: <20240827114607.4019972-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_043822_933720_ED6D069A X-CRM114-Status: GOOD ( 10.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_available_child_of_node_scoped when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/soc/fsl/qe/tsa.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/soc/fsl/qe/tsa.c b/drivers/soc/fsl/qe/tsa.c index 6c5741cf5e9d..7fa399b7a47c 100644 --- a/drivers/soc/fsl/qe/tsa.c +++ b/drivers/soc/fsl/qe/tsa.c @@ -441,7 +441,6 @@ static inline int tsa_of_parse_tdm_tx_route(struct tsa *tsa, static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) { - struct device_node *tdm_np; struct tsa_tdm *tdm; struct clk *clk; u32 tdm_id, val; @@ -452,11 +451,10 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) tsa->tdm[0].is_enable = false; tsa->tdm[1].is_enable = false; - for_each_available_child_of_node(np, tdm_np) { + for_each_available_child_of_node_scoped(np, tdm_np) { ret = of_property_read_u32(tdm_np, "reg", &tdm_id); if (ret) { dev_err(tsa->dev, "%pOF: failed to read reg\n", tdm_np); - of_node_put(tdm_np); return ret; } switch (tdm_id) { @@ -469,16 +467,14 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) default: dev_err(tsa->dev, "%pOF: Invalid tdm_id (%u)\n", tdm_np, tdm_id); - of_node_put(tdm_np); return -EINVAL; } } - for_each_available_child_of_node(np, tdm_np) { + for_each_available_child_of_node_scoped(np, tdm_np) { ret = of_property_read_u32(tdm_np, "reg", &tdm_id); if (ret) { dev_err(tsa->dev, "%pOF: failed to read reg\n", tdm_np); - of_node_put(tdm_np); return ret; } @@ -492,14 +488,12 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) dev_err(tsa->dev, "%pOF: failed to read fsl,rx-frame-sync-delay-bits\n", tdm_np); - of_node_put(tdm_np); return ret; } if (val > 3) { dev_err(tsa->dev, "%pOF: Invalid fsl,rx-frame-sync-delay-bits (%u)\n", tdm_np, val); - of_node_put(tdm_np); return -EINVAL; } tdm->simode_tdm |= TSA_SIMODE_TDM_RFSD(val); @@ -511,14 +505,12 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) dev_err(tsa->dev, "%pOF: failed to read fsl,tx-frame-sync-delay-bits\n", tdm_np); - of_node_put(tdm_np); return ret; } if (val > 3) { dev_err(tsa->dev, "%pOF: Invalid fsl,tx-frame-sync-delay-bits (%u)\n", tdm_np, val); - of_node_put(tdm_np); return -EINVAL; } tdm->simode_tdm |= TSA_SIMODE_TDM_TFSD(val); @@ -538,13 +530,11 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) clk = of_clk_get_by_name(tdm_np, "l1rsync"); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - of_node_put(tdm_np); goto err; } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - of_node_put(tdm_np); goto err; } tdm->l1rsync_clk = clk; @@ -552,13 +542,11 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) clk = of_clk_get_by_name(tdm_np, "l1rclk"); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - of_node_put(tdm_np); goto err; } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - of_node_put(tdm_np); goto err; } tdm->l1rclk_clk = clk; @@ -567,13 +555,11 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) clk = of_clk_get_by_name(tdm_np, "l1tsync"); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - of_node_put(tdm_np); goto err; } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - of_node_put(tdm_np); goto err; } tdm->l1tsync_clk = clk; @@ -581,29 +567,23 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) clk = of_clk_get_by_name(tdm_np, "l1tclk"); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - of_node_put(tdm_np); goto err; } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - of_node_put(tdm_np); goto err; } tdm->l1tclk_clk = clk; } ret = tsa_of_parse_tdm_rx_route(tsa, tdm_np, tsa->tdms, tdm_id); - if (ret) { - of_node_put(tdm_np); + if (ret) goto err; - } ret = tsa_of_parse_tdm_tx_route(tsa, tdm_np, tsa->tdms, tdm_id); - if (ret) { - of_node_put(tdm_np); + if (ret) goto err; - } tdm->is_enable = true; } From patchwork Tue Aug 27 11:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8454C54734 for ; Tue, 27 Aug 2024 11:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kvhSsusYdwfy/ugnFE7LONSgtEPXGqWCQprP7oySnDk=; b=sNxFqKMgRZWcDhoeCbcutnhUWw SP2xJo7S9PM600G5HJl7kGzMBGTUuLLL8hPDnaFflvroHhuF0oipu3VSlUKljFUK4JxgvfkdLXhd4 FXSOqq/iAZFS496KvvPpVAwhMWmiXXPRSW1iWgLp4pcinPlLlHPDTcidlOLcSJsh2OyvyyeBQ13gD 5EYeVDEH8A2kJ4oN+X9fJFvlNAHR2s2+z/apMVlWadbe4as5CxrquYp+CAoiNdRtNNr1iVY808LLx /lDu9FAfDxxQwDRyN2eZ02tMMKR8jhAyi+HAvUvF0QeofF/pTDmrBzds1nX5KJekisfK0n0Cz2zXC prO2qulQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siubc-0000000B4a9-2ART; Tue, 27 Aug 2024 11:43:24 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuWk-0000000B2gl-0EFw for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 11:38:26 +0000 Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4WtQXB5Y2sz1S8sD; Tue, 27 Aug 2024 19:38:02 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 69D4C1A0188; Tue, 27 Aug 2024 19:38:13 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 19:38:12 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 2/8] soc: fsl: cpm1: Simplify with dev_err_probe() Date: Tue, 27 Aug 2024 19:46:01 +0800 Message-ID: <20240827114607.4019972-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_043823_339780_EC2A3245 X-CRM114-Status: GOOD ( 11.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan --- drivers/soc/fsl/qe/tsa.c | 62 +++++++++++++++------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/drivers/soc/fsl/qe/tsa.c b/drivers/soc/fsl/qe/tsa.c index 7fa399b7a47c..fc37d23b746d 100644 --- a/drivers/soc/fsl/qe/tsa.c +++ b/drivers/soc/fsl/qe/tsa.c @@ -453,10 +453,8 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) for_each_available_child_of_node_scoped(np, tdm_np) { ret = of_property_read_u32(tdm_np, "reg", &tdm_id); - if (ret) { - dev_err(tsa->dev, "%pOF: failed to read reg\n", tdm_np); - return ret; - } + if (ret) + return dev_err_probe(tsa->dev, ret, "%pOF: failed to read reg\n", tdm_np); switch (tdm_id) { case 0: tsa->tdms |= BIT(TSA_TDMA); @@ -465,18 +463,15 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) tsa->tdms |= BIT(TSA_TDMB); break; default: - dev_err(tsa->dev, "%pOF: Invalid tdm_id (%u)\n", tdm_np, - tdm_id); - return -EINVAL; + return dev_err_probe(tsa->dev, -EINVAL, "%pOF: Invalid tdm_id (%u)\n", + tdm_np, tdm_id); } } for_each_available_child_of_node_scoped(np, tdm_np) { ret = of_property_read_u32(tdm_np, "reg", &tdm_id); - if (ret) { - dev_err(tsa->dev, "%pOF: failed to read reg\n", tdm_np); - return ret; - } + if (ret) + return dev_err_probe(tsa->dev, ret, "%pOF: failed to read reg\n", tdm_np); tdm = &tsa->tdm[tdm_id]; tdm->simode_tdm = TSA_SIMODE_TDM_SDM_NORM; @@ -484,35 +479,26 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) val = 0; ret = of_property_read_u32(tdm_np, "fsl,rx-frame-sync-delay-bits", &val); - if (ret && ret != -EINVAL) { - dev_err(tsa->dev, - "%pOF: failed to read fsl,rx-frame-sync-delay-bits\n", - tdm_np); - return ret; - } - if (val > 3) { - dev_err(tsa->dev, - "%pOF: Invalid fsl,rx-frame-sync-delay-bits (%u)\n", - tdm_np, val); - return -EINVAL; - } + if (ret && ret != -EINVAL) + return dev_err_probe(tsa->dev, ret, + "%pOF: failed to read fsl,rx-frame-sync-delay-bits\n", + tdm_np); + if (val > 3) + return dev_err_probe(tsa->dev, -EINVAL, + "%pOF: Invalid fsl,rx-frame-sync-delay-bits (%u)\n", + tdm_np, val); tdm->simode_tdm |= TSA_SIMODE_TDM_RFSD(val); val = 0; ret = of_property_read_u32(tdm_np, "fsl,tx-frame-sync-delay-bits", &val); - if (ret && ret != -EINVAL) { - dev_err(tsa->dev, - "%pOF: failed to read fsl,tx-frame-sync-delay-bits\n", - tdm_np); - return ret; - } - if (val > 3) { - dev_err(tsa->dev, - "%pOF: Invalid fsl,tx-frame-sync-delay-bits (%u)\n", - tdm_np, val); - return -EINVAL; - } + if (ret && ret != -EINVAL) + return dev_err_probe(tsa->dev, ret, + "%pOF: failed to read fsl,tx-frame-sync-delay-bits\n", tdm_np); + if (val > 3) + return dev_err_probe(tsa->dev, -EINVAL, + "%pOF: Invalid fsl,tx-frame-sync-delay-bits (%u)\n", + tdm_np, val); tdm->simode_tdm |= TSA_SIMODE_TDM_TFSD(val); if (of_property_read_bool(tdm_np, "fsl,common-rxtx-pins")) @@ -645,10 +631,8 @@ static int tsa_probe(struct platform_device *pdev) return PTR_ERR(tsa->si_regs); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "si_ram"); - if (!res) { - dev_err(tsa->dev, "si_ram resource missing\n"); - return -EINVAL; - } + if (!res) + return dev_err_probe(tsa->dev, -EINVAL, "si_ram resource missing\n"); tsa->si_ram_sz = resource_size(res); tsa->si_ram = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(tsa->si_ram)) From patchwork Tue Aug 27 11:46:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 945F5C54735 for ; Tue, 27 Aug 2024 11:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4X6/RxMpsbE97p+Qhg9yQOSsLMtRv4l/pqbipQn/Ulk=; b=BAkdsbIxfbtJWKYjnL3ZMTsKhw zgEefSZheqg5X/57EZ3IGmBMNzaYSr59EFZHMBGwbR22iP4FICWcan4kRltshHDenU//8qOEriUOf jF3cgc4XCpnNFkaVF3npyoKqbU0RpNSHLjxjCURP/W10Q/xvqo8I0/ZMGDqnywi8GWhecvqG2CILh /ucoWtPsPR2I+ms/sHfaqhN3XG1YxtQ2H3rrmGGIFO++doTo0bwDTs+JHjyeg89xLymRgm2eOxn4E xwYFDsUTvVqpfEaee21InErjDBqWqtM+pPYs4Ua9wa50BYldyFfmKQAfKVx4fGbiGnH+J33PfxQLq MVx574iQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuZy-0000000B40i-423I; Tue, 27 Aug 2024 11:41:42 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuWj-0000000B2gk-3MEG for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 11:38:24 +0000 Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WtQXD0CCYz2Cnkc; Tue, 27 Aug 2024 19:38:04 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 16C9A180019; Tue, 27 Aug 2024 19:38:14 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 19:38:13 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 3/8] soc: fsl: cpm1: qmc: Simplify with scoped for each OF child Date: Tue, 27 Aug 2024 19:46:02 +0800 Message-ID: <20240827114607.4019972-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_043822_642920_5D1FC9E3 X-CRM114-Status: GOOD ( 11.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/soc/fsl/qe/qmc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/soc/fsl/qe/qmc.c b/drivers/soc/fsl/qe/qmc.c index 76bb496305a0..d5937b5b5f15 100644 --- a/drivers/soc/fsl/qe/qmc.c +++ b/drivers/soc/fsl/qe/qmc.c @@ -1174,31 +1174,26 @@ static unsigned int qmc_nb_chans(struct qmc *qmc) static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) { - struct device_node *chan_np; struct qmc_chan *chan; const char *mode; u32 chan_id; u64 ts_mask; int ret; - for_each_available_child_of_node(np, chan_np) { + for_each_available_child_of_node_scoped(np, chan_np) { ret = of_property_read_u32(chan_np, "reg", &chan_id); if (ret) { dev_err(qmc->dev, "%pOF: failed to read reg\n", chan_np); - of_node_put(chan_np); return ret; } if (chan_id > 63) { dev_err(qmc->dev, "%pOF: Invalid chan_id\n", chan_np); - of_node_put(chan_np); return -EINVAL; } chan = devm_kzalloc(qmc->dev, sizeof(*chan), GFP_KERNEL); - if (!chan) { - of_node_put(chan_np); + if (!chan) return -ENOMEM; - } chan->id = chan_id; spin_lock_init(&chan->ts_lock); @@ -1209,7 +1204,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) if (ret) { dev_err(qmc->dev, "%pOF: failed to read fsl,tx-ts-mask\n", chan_np); - of_node_put(chan_np); return ret; } chan->tx_ts_mask_avail = ts_mask; @@ -1219,7 +1213,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) if (ret) { dev_err(qmc->dev, "%pOF: failed to read fsl,rx-ts-mask\n", chan_np); - of_node_put(chan_np); return ret; } chan->rx_ts_mask_avail = ts_mask; @@ -1230,7 +1223,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) if (ret && ret != -EINVAL) { dev_err(qmc->dev, "%pOF: failed to read fsl,operational-mode\n", chan_np); - of_node_put(chan_np); return ret; } if (!strcmp(mode, "transparent")) { @@ -1240,7 +1232,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) } else { dev_err(qmc->dev, "%pOF: Invalid fsl,operational-mode (%s)\n", chan_np, mode); - of_node_put(chan_np); return -EINVAL; } From patchwork Tue Aug 27 11:46:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC5E6C54735 for ; Tue, 27 Aug 2024 11:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=B9a4Nu39qZmPOTpSWwgCGmcdd//9iD0eebXMV4pjG1I=; b=JLznx2K2aaeWmeFy6HhvhADFr6 BXqC5nCYMcMoL4zxldfGAdrsBe1smLZ4PHXCuaz0VKb3GNu62P4MRO6S6biwRmw9NA9Wcx11PLzDa SQqryerraEzCyAAbHVH2JopDYa/AwTW0GoHwjhH2aq3CVdO7gdtuy+HiJbXaZr6TMwQefdzEIb+0s 0SFVYqTMT2akv9bZjsaeYgPoFfEbGPAKVJoIJLuXGUND1wROb+/kkoP4xWX+ibeEWuBF99Bx6VeNL irICqO2VqHK3xPAW5YgwV9wd3k5s9VxGx/WzzoA3YWfiW+r5C5+77xhMt6jP6jtpHoNtriXdqMAxv VEUmqqPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siucO-0000000B4o8-22R0; Tue, 27 Aug 2024 11:44:12 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuWk-0000000B2gj-04NB for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 11:38:27 +0000 Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WtQQt453RzQqgb; Tue, 27 Aug 2024 19:33:26 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 41C0D140202; Tue, 27 Aug 2024 19:38:15 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 19:38:13 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 4/8] soc: fsl: cpm1: qmc: Simplify with dev_err_probe() Date: Tue, 27 Aug 2024 19:46:03 +0800 Message-ID: <20240827114607.4019972-5-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_043822_571947_2DAC6164 X-CRM114-Status: GOOD ( 11.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan --- drivers/soc/fsl/qe/qmc.c | 53 ++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/drivers/soc/fsl/qe/qmc.c b/drivers/soc/fsl/qe/qmc.c index d5937b5b5f15..4315af115b8e 100644 --- a/drivers/soc/fsl/qe/qmc.c +++ b/drivers/soc/fsl/qe/qmc.c @@ -1182,14 +1182,10 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) for_each_available_child_of_node_scoped(np, chan_np) { ret = of_property_read_u32(chan_np, "reg", &chan_id); - if (ret) { - dev_err(qmc->dev, "%pOF: failed to read reg\n", chan_np); - return ret; - } - if (chan_id > 63) { - dev_err(qmc->dev, "%pOF: Invalid chan_id\n", chan_np); - return -EINVAL; - } + if (ret) + return dev_err_probe(qmc->dev, ret, "%pOF: failed to read reg\n", chan_np); + if (chan_id > 63) + return dev_err_probe(qmc->dev, -EINVAL, "%pOF: Invalid chan_id\n", chan_np); chan = devm_kzalloc(qmc->dev, sizeof(*chan), GFP_KERNEL); if (!chan) @@ -1201,39 +1197,34 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) spin_lock_init(&chan->tx_lock); ret = of_property_read_u64(chan_np, "fsl,tx-ts-mask", &ts_mask); - if (ret) { - dev_err(qmc->dev, "%pOF: failed to read fsl,tx-ts-mask\n", - chan_np); - return ret; - } + if (ret) + return dev_err_probe(qmc->dev, ret, + "%pOF: failed to read fsl,tx-ts-mask\n", + chan_np); chan->tx_ts_mask_avail = ts_mask; chan->tx_ts_mask = chan->tx_ts_mask_avail; ret = of_property_read_u64(chan_np, "fsl,rx-ts-mask", &ts_mask); - if (ret) { - dev_err(qmc->dev, "%pOF: failed to read fsl,rx-ts-mask\n", - chan_np); - return ret; - } + if (ret) + dev_err_probe(qmc->dev, ret, "%pOF: failed to read fsl,rx-ts-mask\n", + chan_np); chan->rx_ts_mask_avail = ts_mask; chan->rx_ts_mask = chan->rx_ts_mask_avail; mode = "transparent"; ret = of_property_read_string(chan_np, "fsl,operational-mode", &mode); - if (ret && ret != -EINVAL) { - dev_err(qmc->dev, "%pOF: failed to read fsl,operational-mode\n", - chan_np); - return ret; - } + if (ret && ret != -EINVAL) + return dev_err_probe(qmc->dev, ret, + "%pOF: failed to read fsl,operational-mode\n", + chan_np); if (!strcmp(mode, "transparent")) { chan->mode = QMC_TRANSPARENT; } else if (!strcmp(mode, "hdlc")) { chan->mode = QMC_HDLC; - } else { - dev_err(qmc->dev, "%pOF: Invalid fsl,operational-mode (%s)\n", - chan_np, mode); - return -EINVAL; - } + } else + return dev_err_probe(qmc->dev, -EINVAL, + "%pOF: Invalid fsl,operational-mode (%s)\n", + chan_np, mode); chan->is_reverse_data = of_property_read_bool(chan_np, "fsl,reverse-data"); @@ -1590,10 +1581,8 @@ static int qmc_probe(struct platform_device *pdev) /* Connect the serial (SCC) to TSA */ ret = tsa_serial_connect(qmc->tsa_serial); - if (ret) { - dev_err(qmc->dev, "Failed to connect TSA serial\n"); - return ret; - } + if (ret) + return dev_err_probe(qmc->dev, ret, "Failed to connect TSA serial\n"); /* Parse channels informationss */ ret = qmc_of_parse_chans(qmc, np); From patchwork Tue Aug 27 11:46:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5484C54734 for ; Tue, 27 Aug 2024 11:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Bh5x8cN6b49le4kLR1yloaUU6CqIls1aVKtyGmnM5Q8=; b=AiZFBV1DURI0EJ09hQFtDu7YRs PoC18730COqgleux/GP3uxKQqhrJTx9PRF2BRep6i7gTim9KPZwuvMu/1b7rO3AmVAoxJ4yoGYquG 00HQsbaxyrMapRn/23lgRFRR3a36W8sfvpJszZ4cBfIk0qi2CA6S6jDzbq2hgvwnb8hXi+p4Hxz14 lqJgC1vqqQ663IQwZNBC0dNs8WopXUtbdw49RxI2PPWf4uH2yi/xWJt3sZzPYczxZfL3LyhkIQ9zF wa9NP6alRhwvIk/SYWNvWM1QvLM/lRBilrKn3eEKZF4cJhSCUVOAgTXjIYRbViZrwytVbh5PGY0BD YNLeTMrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuYR-0000000B3Wx-3bpC; Tue, 27 Aug 2024 11:40:08 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuWg-0000000B2fS-0cTB for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 11:38:19 +0000 Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WtQWX139WzyQZW; Tue, 27 Aug 2024 19:37:28 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 51D4B1402DE; Tue, 27 Aug 2024 19:38:15 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 19:38:14 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 5/8] soc/tegra: pmc: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:04 +0800 Message-ID: <20240827114607.4019972-6-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_043818_471118_2B2113EC X-CRM114-Status: GOOD ( 11.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/soc/tegra/pmc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index 6c37d6eb8b49..a08c377933c5 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -1438,7 +1438,7 @@ static int tegra_powergate_init(struct tegra_pmc *pmc, struct device_node *parent) { struct of_phandle_args child_args, parent_args; - struct device_node *np, *child; + struct device_node *np; int err = 0; /* @@ -1457,12 +1457,10 @@ static int tegra_powergate_init(struct tegra_pmc *pmc, if (!np) return 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { err = tegra_powergate_add(pmc, child); - if (err < 0) { - of_node_put(child); + if (err < 0) break; - } if (of_parse_phandle_with_args(child, "power-domains", "#power-domain-cells", @@ -1474,10 +1472,8 @@ static int tegra_powergate_init(struct tegra_pmc *pmc, err = of_genpd_add_subdomain(&parent_args, &child_args); of_node_put(parent_args.np); - if (err) { - of_node_put(child); + if (err) break; - } } of_node_put(np); From patchwork Tue Aug 27 11:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27902C54734 for ; Tue, 27 Aug 2024 11:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1fCgKQIkz/+gi9fV1OrbsnV3X9mQtRzZv7rrrwMCDd8=; b=3FyNZojn27RFeDu1JdWMDVsGOn nXRgrqSg1K0j2ooTg3lZxKfHGY0kdmip7kvnwEObUslng7aKpAar+iwhbWJP+kIZBSvsDwQ3HZ4EI WDIGAWoAETX7hpGDzsiee/8tEfzgXMaJqel3QIxfHRj52ZkrSQZGKdLtwhSVF3HFvle6Zxky4iQpF R5J3laOLi5DRfwKCbESW9iqe01MITGscy7TvF1gRUqHQuTKTFm+V80NAccH6lvvtMxIlcGb7nDs8U osircv7aQETfHwz11/jCw4Tse5yfe8ca7mk4zX1XjeXVflXub3zsmHEUBtTIpanejgszo0q8pJF9e YnokOuig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuZE-0000000B3le-0UzD; Tue, 27 Aug 2024 11:40:56 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuWk-0000000B2gm-04e9 for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 11:38:24 +0000 Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WtQQv39T5zQqgc; Tue, 27 Aug 2024 19:33:27 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 26A9B18010B; Tue, 27 Aug 2024 19:38:16 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 19:38:15 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 6/8] soc: dove: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:05 +0800 Message-ID: <20240827114607.4019972-7-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_043822_519781_C115BF01 X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/soc/dove/pmu.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c index 6202dbcd20a8..75f5fc3cb2c6 100644 --- a/drivers/soc/dove/pmu.c +++ b/drivers/soc/dove/pmu.c @@ -372,7 +372,7 @@ int __init dove_init_pmu_legacy(const struct dove_pmu_initdata *initdata) */ int __init dove_init_pmu(void) { - struct device_node *np_pmu, *domains_node, *np; + struct device_node *np_pmu, *domains_node; struct pmu_data *pmu; int ret, parent_irq; @@ -405,21 +405,18 @@ int __init dove_init_pmu(void) pmu_reset_init(pmu); - for_each_available_child_of_node(domains_node, np) { + for_each_available_child_of_node_scoped(domains_node, np) { struct of_phandle_args args; struct pmu_domain *domain; domain = kzalloc(sizeof(*domain), GFP_KERNEL); - if (!domain) { - of_node_put(np); + if (!domain) break; - } domain->pmu = pmu; domain->base.name = kasprintf(GFP_KERNEL, "%pOFn", np); if (!domain->base.name) { kfree(domain); - of_node_put(np); break; } From patchwork Tue Aug 27 11:46:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0A3CC54735 for ; Tue, 27 Aug 2024 11:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3yiIX9LDkrPDh7GRPqepNE1yKgPXfYii7nzLUNDEKOo=; b=ZIJU9ikIk3LiRilasH6WQE6+OY fLFAnm/0czEz03Fpr0L+DQBOw/r28IWpqn66y8lhebYwYJPpwp6BTsEHAZttm40EJ+EXh/qn2TpOA T9GLtClWLlkHwoiwrxtOMqOuhSbEunfTpfL8UuAEAYznXe3Qp1SQpefxcAn3g6JnoXOjvxxwxL+Ed R/Gk4zoBIvzwnDHMbCwJcwHwhJcGSES6IglIVmA9YsEfHs3VdrrV0XbPAMOYShcNEPtLudY8pxZ8G 7XbQh0QFJoPyhPioDzo1wSHYBXKi6hrNYlzKHeHcQpg95qT0mE6AHx1Frh8CPBTy3Ya5PQRVqEqVn tkc9K4tA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siue1-0000000B5Im-191y; Tue, 27 Aug 2024 11:45:53 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuWl-0000000B2gh-2lzx for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 11:38:28 +0000 Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WtQWY6Vpgz14GKW; Tue, 27 Aug 2024 19:37:29 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id C5510140202; Tue, 27 Aug 2024 19:38:16 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 19:38:15 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 7/8] soc: ti: knav_dma: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:06 +0800 Message-ID: <20240827114607.4019972-8-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_043823_979254_5E55C539 X-CRM114-Status: GOOD ( 12.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. And use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan --- drivers/soc/ti/knav_dma.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c index fb0746d8caad..eeec422a46f0 100644 --- a/drivers/soc/ti/knav_dma.c +++ b/drivers/soc/ti/knav_dma.c @@ -706,20 +706,15 @@ static int knav_dma_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *node = pdev->dev.of_node; - struct device_node *child; int ret = 0; - if (!node) { - dev_err(&pdev->dev, "could not find device info\n"); - return -EINVAL; - } + if (!node) + return dev_err_probe(&pdev->dev, -EINVAL, "could not find device info\n"); kdev = devm_kzalloc(dev, sizeof(struct knav_dma_pool_device), GFP_KERNEL); - if (!kdev) { - dev_err(dev, "could not allocate driver mem\n"); - return -ENOMEM; - } + if (!kdev) + return dev_err_probe(dev, -ENOMEM, "could not allocate driver mem\n"); kdev->dev = dev; INIT_LIST_HEAD(&kdev->list); @@ -732,10 +727,9 @@ static int knav_dma_probe(struct platform_device *pdev) } /* Initialise all packet dmas */ - for_each_child_of_node(node, child) { + for_each_child_of_node_scoped(node, child) { ret = dma_init(node, child); if (ret) { - of_node_put(child); dev_err(&pdev->dev, "init failed with %d\n", ret); break; } From patchwork Tue Aug 27 11:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13779378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 269EBC54734 for ; Tue, 27 Aug 2024 11:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VZGxZGVFQf1lRfodKCfNYUIb199fuQqzsvjfLECwEQE=; b=RzQ7Fs/M+esiNNjhlHuWjbsc/O cW4ctmVgMlx5TM65L0xOCxbqjaBWGbw8IL/Z6Qmu+TJq9kLArWJo0aJhvqq7RV/hRcJqKJkiSZPSj E/QSC8PnO7DPAC6xXv3mP1y0ZLQhP4tKr6D+lQ6aD/nnFC6HUa/NaSNMP/eS3qAUlU2sOumyyDcym 2IfdaVEeA3H1bRUjNUp/aIFdq5CPlB2clYq4gqkt2b2jLkIybP6QDLZ9lRKImaEPZg2tsHSCxXE1k Gmz8zILaN/gO8fHIsi1Q84vSv5rgvRaDRPNhTmRKDb+fythqRxKLthkM8H3ST1Smul3BKtGFUsPwx l+9rhZyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siudA-0000000B523-3GOK; Tue, 27 Aug 2024 11:45:00 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siuWk-0000000B2gi-04s5 for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 11:38:28 +0000 Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WtQQw5RZxzQqtk; Tue, 27 Aug 2024 19:33:28 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 7504F18007C; Tue, 27 Aug 2024 19:38:17 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 19:38:16 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 8/8] soc: ti: knav_qmss_queue: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:07 +0800 Message-ID: <20240827114607.4019972-9-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_043822_767006_B776E48E X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. And use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan --- drivers/soc/ti/knav_qmss_queue.c | 57 ++++++++++---------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index a15eaa1900ab..5126863ed647 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c @@ -1080,17 +1080,13 @@ static int knav_queue_setup_regions(struct knav_device *kdev, { struct device *dev = kdev->dev; struct knav_region *region; - struct device_node *child; u32 temp[2]; int ret; - for_each_child_of_node(regions, child) { + for_each_child_of_node_scoped(regions, child) { region = devm_kzalloc(dev, sizeof(*region), GFP_KERNEL); - if (!region) { - of_node_put(child); - dev_err(dev, "out of memory allocating region\n"); - return -ENOMEM; - } + if (!region) + return dev_err_probe(dev, -ENOMEM, "out of memory allocating region\n"); region->name = knav_queue_find_name(child); of_property_read_u32(child, "id", ®ion->id); @@ -1116,10 +1112,8 @@ static int knav_queue_setup_regions(struct knav_device *kdev, INIT_LIST_HEAD(®ion->pools); list_add_tail(®ion->list, &kdev->regions); } - if (list_empty(&kdev->regions)) { - dev_err(dev, "no valid region information found\n"); - return -ENODEV; - } + if (list_empty(&kdev->regions)) + return dev_err_probe(dev, -ENODEV, "no valid region information found\n"); /* Next, we run through the regions and set things up */ for_each_region(kdev, region) @@ -1313,10 +1307,8 @@ static int knav_setup_queue_pools(struct knav_device *kdev, } /* ... and barf if they all failed! */ - if (list_empty(&kdev->queue_ranges)) { - dev_err(kdev->dev, "no valid queue range found\n"); - return -ENODEV; - } + if (list_empty(&kdev->queue_ranges)) + return dev_err_probe(kdev->dev, -ENODEV, "no valid queue range found\n"); return 0; } @@ -1388,17 +1380,13 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev, { struct device *dev = kdev->dev; struct knav_qmgr_info *qmgr; - struct device_node *child; u32 temp[2]; int ret; - for_each_child_of_node(qmgrs, child) { + for_each_child_of_node_scoped(qmgrs, child) { qmgr = devm_kzalloc(dev, sizeof(*qmgr), GFP_KERNEL); - if (!qmgr) { - of_node_put(child); - dev_err(dev, "out of memory allocating qmgr\n"); - return -ENOMEM; - } + if (!qmgr) + return dev_err_probe(dev, -ENOMEM, "out of memory allocating qmgr\n"); ret = of_property_read_u32_array(child, "managed-queues", temp, 2); @@ -1490,15 +1478,11 @@ static int knav_queue_init_pdsps(struct knav_device *kdev, { struct device *dev = kdev->dev; struct knav_pdsp_info *pdsp; - struct device_node *child; - for_each_child_of_node(pdsps, child) { + for_each_child_of_node_scoped(pdsps, child) { pdsp = devm_kzalloc(dev, sizeof(*pdsp), GFP_KERNEL); - if (!pdsp) { - of_node_put(child); - dev_err(dev, "out of memory allocating pdsp\n"); - return -ENOMEM; - } + if (!pdsp) + return dev_err_probe(dev, -ENOMEM, "out of memory allocating pdsp\n"); pdsp->name = knav_queue_find_name(child); pdsp->iram = knav_queue_map_reg(kdev, child, @@ -1755,16 +1739,12 @@ static int knav_queue_probe(struct platform_device *pdev) u32 temp[2]; int ret; - if (!node) { - dev_err(dev, "device tree info unavailable\n"); - return -ENODEV; - } + if (!node) + return dev_err_probe(dev, -ENODEV, "device tree info unavailable\n"); kdev = devm_kzalloc(dev, sizeof(struct knav_device), GFP_KERNEL); - if (!kdev) { - dev_err(dev, "memory allocation failed\n"); - return -ENOMEM; - } + if (!kdev) + return dev_err_probe(dev, -ENOMEM, "memory allocation failed\n"); if (device_get_match_data(dev)) kdev->version = QMSS_66AK2G; @@ -1781,8 +1761,7 @@ static int knav_queue_probe(struct platform_device *pdev) ret = pm_runtime_resume_and_get(&pdev->dev); if (ret < 0) { pm_runtime_disable(&pdev->dev); - dev_err(dev, "Failed to enable QMSS\n"); - return ret; + return dev_err_probe(dev, ret, "Failed to enable QMSS\n"); } if (of_property_read_u32_array(node, "queue-range", temp, 2)) {