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