[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240827114607.4019972-5-ruanjinjie@huawei.com>
Date: Tue, 27 Aug 2024 19:46:03 +0800
From: Jinjie Ruan <ruanjinjie@...wei.com>
To: <andrew@...n.ch>, <sebastian.hesselbarth@...il.com>,
<gregory.clement@...tlin.com>, <herve.codina@...tlin.com>,
<qiang.zhao@....com>, <christophe.leroy@...roup.eu>,
<thierry.reding@...il.com>, <jonathanh@...dia.com>, <nm@...com>,
<ssantosh@...nel.org>, <petlozup@...dia.com>, <pshete@...dia.com>,
<ruanjinjie@...wei.com>, <christophe.jaillet@...adoo.fr>,
<ulf.hansson@...aro.org>, <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linuxppc-dev@...ts.ozlabs.org>,
<linux-tegra@...r.kernel.org>, <krzk@...nel.org>, <jic23@...nel.org>
Subject: [PATCH -next 4/8] soc: fsl: cpm1: qmc: Simplify with dev_err_probe()
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 <ruanjinjie@...wei.com>
---
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);
--
2.34.1
Powered by blists - more mailing lists