From patchwork Fri Aug 30 04:06:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13784203 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 C52B2C83F32 for ; Fri, 30 Aug 2024 04:03:12 +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:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jkEOqyUxcBoPPL5BncIqsc96Qi8FOwtCEEq+nb0MFfA=; b=IPvkmXpcEN1v+PQJrBcSaNHlqH DKzi3+QQ3pSmG9O8rJXoDG/3942Rv5gYtDmuRG+OejbmUAJinoQq4NvbraoMnp7uFQ57AxQ/CELXd y8pzQvMkf+zQAwWL9MWR6nxgTqpAMyFWzdK8Z3cO8Y2Nn4zf7yiaLvmyz2QtYcoLgvSbz/AwD9wmd S8QoAAZhL0U0e0CwWKhaw92OOC3eelc/tAimEtex35LoljSwVmjoBBXAU3FvOlICNnTn4uCrrYAvx 79jvGeXDm5HX40EDMPOXh1iQS2a11WeHW51l0uZRQzzirAUOOELOCwEhUwqfjvYXjWeQyYjixcuQR 99/E1ZHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjsql-00000004bKw-2lbF; Fri, 30 Aug 2024 04:03:03 +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 1sjsmW-00000004Zug-31Y5 for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2024 03:58:43 +0000 Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ww4BJ0Vtvz2DbbD; Fri, 30 Aug 2024 11:58:16 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 950761A0188; Fri, 30 Aug 2024 11:58:29 +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; Fri, 30 Aug 2024 11:58:29 +0800 From: Jinjie Ruan To: , , , , , , , CC: Subject: [PATCH -next v2 1/4] soc: fsl: cpm1: Simplify with scoped for each OF child loop Date: Fri, 30 Aug 2024 12:06:33 +0800 Message-ID: <20240830040636.3508679-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240830040636.3508679-1-ruanjinjie@huawei.com> References: <20240830040636.3508679-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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-20240829_205841_327752_CA64F776 X-CRM114-Status: GOOD ( 10.26 ) 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 Fri Aug 30 04:06:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13784202 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 62DA5CA0EDB for ; Fri, 30 Aug 2024 04:02:23 +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:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IaZ09lYynaRJJ8ecuz1Va8Vbk4D7PbIxaDqDpy2T/Mo=; b=P2J7OUjBwR6xhIzUxbb+YTZj1h 2eHrZH1ns23+vgBeVvg3a5c31GO66h6ZnOxOSJOgakOHNimywHGFkPUO7LnAQzhNMNrRfZMzq0n3x EGxMbPsTuireM5E7CWBEvN1fBM+y/V4xswqjzpVf8JzN0Jf7+c28CHS/DCZU/Yj5Fvel9Ej21Zxyh /oUyfjH/g0fVhUTgADcYMzMAWcTubITDlmIapo1byT8Twa7jy9dJJArN5r9x/0/SIK4NsxfaQbKBh OT4WlIdiafAyME/kh55/9haDKDrScC0et+MgBNep40BX+ilmAt5V4DZjfWuvNAjzp3oGNrU8mHZQ7 G6V9iUGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjspw-00000004b3q-14r9; Fri, 30 Aug 2024 04:02:12 +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 1sjsmW-00000004ZuZ-1xoY for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2024 03:58:43 +0000 Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Ww4BH6df0z1S9QM; Fri, 30 Aug 2024 11:58:15 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 0DF771A0188; Fri, 30 Aug 2024 11:58:30 +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; Fri, 30 Aug 2024 11:58:29 +0800 From: Jinjie Ruan To: , , , , , , , CC: Subject: [PATCH -next v2 2/4] soc: fsl: cpm1: Simplify with dev_err_probe() Date: Fri, 30 Aug 2024 12:06:34 +0800 Message-ID: <20240830040636.3508679-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240830040636.3508679-1-ruanjinjie@huawei.com> References: <20240830040636.3508679-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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-20240829_205841_067696_71C36DA4 X-CRM114-Status: GOOD ( 11.35 ) 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. Signed-off-by: Jinjie Ruan --- v2: - Update the commit message. --- 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 Fri Aug 30 04:06:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13784199 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 3FA73CA0EDB for ; Fri, 30 Aug 2024 03:59: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:CC:To:From:Reply-To: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=XgPrNhB9lUtKx1TnGCUBPmVW4u vJ3bNmPh4ReAQxGEexxg6UBoVZAPJmYhZ7uh0AkTSwjH0FGATTg6gXhPcmDa8ZupJg8REP0pckbzk EpP7puCW9Kew+zUBK5AQpBNfIrtA9+k9hycRWIsp/WynKECm7LTXqk7tRqWIpDsFO0cFn3P+LwMrr aWsNo3cishmXekrpZGfTtq6qFOc0qee6EvuRfPbogsUm2JdTs7bquYSAWX1iP95xKR1loSexBHGR5 Qyp5/MXKjCDp/WwXKlmgQ/5yI4vz1hAJjc1c+GZMnxhpxWU96eFxsIOg3Ucvb8nI/ZuCH3YpExGNv ZuKyf7YQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjsnN-00000004aKj-3ny0; Fri, 30 Aug 2024 03:59:33 +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 1sjsmU-00000004Zuk-22Uz for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2024 03:58:40 +0000 Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Ww49c088gz18Mwr; Fri, 30 Aug 2024 11:57:40 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 70B831401F3; Fri, 30 Aug 2024 11:58:30 +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; Fri, 30 Aug 2024 11:58:29 +0800 From: Jinjie Ruan To: , , , , , , , CC: Subject: [PATCH -next v2 3/4] soc: fsl: cpm1: qmc: Simplify with scoped for each OF child Date: Fri, 30 Aug 2024 12:06:35 +0800 Message-ID: <20240830040636.3508679-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240830040636.3508679-1-ruanjinjie@huawei.com> References: <20240830040636.3508679-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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-20240829_205838_799693_AFC481DE X-CRM114-Status: GOOD ( 10.82 ) 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 Fri Aug 30 04:06:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13784200 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 08F62CA0EDA for ; Fri, 30 Aug 2024 04:00:39 +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:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g9wBhjYLlviDHiMrAUgmwPhGkeBhFmGoHFroxZyIdos=; b=ct3shy1HKLHqnwhKIEb/z35xwc x7Zt0tcUn8C7w8r/B+R8lRAtBA49kzEqYuNRducUbv29zy+jMZ//S1VjgfOJ+i+9G/53uZH8DllUU 1BCaYZW3ECLwaMilEQTiS1AOqvI3AcxF07EGj2nI/dqqsSVW71JW4xaHRg37WfKmsQwyXLre6GGVq Wwfpnr4gBmTFKKbebSPRAcWhIqBx36nW47+a53AnUubUocruY31ZbX8sarqliAeaYj7JDYm3eD0o+ iQxFhUySAonCnT/pcB61Jf215i/PdEyiypaEuo1SRMmeAyb8xBpPvoXtLSh2wk7u48pH5OlbN+WyS ifg7F64Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjsoD-00000004aT1-16cC; Fri, 30 Aug 2024 04:00:25 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjsmU-00000004Zub-1hgm for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2024 03:58:40 +0000 Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Ww48Z2BJJzpV4p; Fri, 30 Aug 2024 11:56:46 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id E41171401F3; Fri, 30 Aug 2024 11:58:30 +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; Fri, 30 Aug 2024 11:58:30 +0800 From: Jinjie Ruan To: , , , , , , , CC: Subject: [PATCH -next v2 4/4] soc: fsl: cpm1: qmc: Simplify with dev_err_probe() Date: Fri, 30 Aug 2024 12:06:36 +0800 Message-ID: <20240830040636.3508679-5-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240830040636.3508679-1-ruanjinjie@huawei.com> References: <20240830040636.3508679-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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-20240829_205839_037781_3508BBA5 X-CRM114-Status: GOOD ( 11.40 ) 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. Signed-off-by: Jinjie Ruan --- v2: - Update the commit message. --- 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);