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))