From: Jinjie Ruan <ruanjinjie@huawei.com>
To: <andrew@lunn.ch>, <sebastian.hesselbarth@gmail.com>,
<gregory.clement@bootlin.com>, <herve.codina@bootlin.com>,
<qiang.zhao@nxp.com>, <christophe.leroy@csgroup.eu>,
<thierry.reding@gmail.com>, <jonathanh@nvidia.com>, <nm@ti.com>,
<ssantosh@kernel.org>, <petlozup@nvidia.com>, <pshete@nvidia.com>,
<ruanjinjie@huawei.com>, <christophe.jaillet@wanadoo.fr>,
<ulf.hansson@linaro.org>, <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linuxppc-dev@lists.ozlabs.org>,
<linux-tegra@vger.kernel.org>, <krzk@kernel.org>,
<jic23@kernel.org>
Subject: [PATCH -next 4/8] soc: fsl: cpm1: qmc: Simplify with dev_err_probe()
Date: Tue, 27 Aug 2024 19:46:03 +0800 [thread overview]
Message-ID: <20240827114607.4019972-5-ruanjinjie@huawei.com> (raw)
In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com>
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@huawei.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
next prev parent reply other threads:[~2024-08-27 11:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 11:45 [PATCH -next 0/8] soc: Simplify with scoped for each OF child loop and dev_err_probe() Jinjie Ruan
2024-08-27 11:46 ` [PATCH -next 1/8] soc: fsl: cpm1: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-27 11:46 ` [PATCH -next 2/8] soc: fsl: cpm1: Simplify with dev_err_probe() Jinjie Ruan
2024-08-27 13:50 ` Krzysztof Kozlowski
2024-08-28 1:58 ` Jinjie Ruan
2024-08-28 13:08 ` Krzysztof Kozlowski
2024-08-29 2:25 ` Jinjie Ruan
2024-08-27 11:46 ` [PATCH -next 3/8] soc: fsl: cpm1: qmc: Simplify with scoped for each OF child Jinjie Ruan
2024-08-27 11:46 ` Jinjie Ruan [this message]
2024-08-27 11:46 ` [PATCH -next 5/8] soc/tegra: pmc: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-27 11:46 ` [PATCH -next 6/8] soc: dove: " Jinjie Ruan
2024-08-27 11:46 ` [PATCH -next 7/8] soc: ti: knav_dma: " Jinjie Ruan
2024-08-27 11:46 ` [PATCH -next 8/8] soc: ti: knav_qmss_queue: " Jinjie Ruan
2024-08-29 15:58 ` Kousik Sanagavarapu
2024-08-29 18:06 ` Nishanth Menon
2024-08-30 3:24 ` Jinjie Ruan
2024-08-31 10:30 ` Jonathan Cameron
2024-08-29 15:43 ` (subset) [PATCH -next 0/8] soc: Simplify with scoped for each OF child loop and dev_err_probe() Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240827114607.4019972-5-ruanjinjie@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=andrew@lunn.ch \
--cc=christophe.jaillet@wanadoo.fr \
--cc=christophe.leroy@csgroup.eu \
--cc=gregory.clement@bootlin.com \
--cc=herve.codina@bootlin.com \
--cc=jic23@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nm@ti.com \
--cc=petlozup@nvidia.com \
--cc=pshete@nvidia.com \
--cc=qiang.zhao@nxp.com \
--cc=sebastian.hesselbarth@gmail.com \
--cc=ssantosh@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox