[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240830083851.25241-1-shenlichuan@vivo.com>
Date: Fri, 30 Aug 2024 16:38:51 +0800
From: Shen Lichuan <shenlichuan@...o.com>
To: haver@...ux.ibm.com,
arnd@...db.de,
gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org,
opensource.kernel@...o.com,
Shen Lichuan <shenlichuan@...o.com>
Subject: [PATCH v1] misc: genwqe: Simplify with dev_err_probe()
Use dev_err_probe() to simplify the error path and unify a message
template.
Using this helper is totally fine even if err is known to never
be -EPROBE_DEFER.
The benefit compared to a normal dev_err() is the standardized format
of the error code, it being emitted symbolically and the fact that
the error code is returned which allows more compact error paths.
Signed-off-by: Shen Lichuan <shenlichuan@...o.com>
---
drivers/misc/genwqe/card_base.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/misc/genwqe/card_base.c b/drivers/misc/genwqe/card_base.c
index 224a7e97cbea..4e882bff7ee5 100644
--- a/drivers/misc/genwqe/card_base.c
+++ b/drivers/misc/genwqe/card_base.c
@@ -1185,35 +1185,32 @@ static int genwqe_probe(struct pci_dev *pci_dev,
genwqe_init_crc32();
cd = genwqe_dev_alloc();
- if (IS_ERR(cd)) {
- dev_err(&pci_dev->dev, "err: could not alloc mem (err=%d)!\n",
- (int)PTR_ERR(cd));
- return PTR_ERR(cd);
- }
+ if (IS_ERR(cd))
+ return dev_err_probe(&pci_dev->dev, PTR_ERR(cd),
+ "could not alloc mem\n");
dev_set_drvdata(&pci_dev->dev, cd);
cd->pci_dev = pci_dev;
err = genwqe_pci_setup(cd);
if (err < 0) {
- dev_err(&pci_dev->dev,
- "err: problems with PCI setup (err=%d)\n", err);
+ dev_err_probe(&pci_dev->dev, err,
+ "problems with PCI setup\n");
goto out_free_dev;
}
err = genwqe_start(cd);
if (err < 0) {
- dev_err(&pci_dev->dev,
- "err: cannot start card services! (err=%d)\n", err);
+ dev_err_probe(&pci_dev->dev, err,
+ "cannot start card services!\n");
goto out_pci_remove;
}
if (genwqe_is_privileged(cd)) {
err = genwqe_health_check_start(cd);
if (err < 0) {
- dev_err(&pci_dev->dev,
- "err: cannot start health checking! (err=%d)\n",
- err);
+ dev_err_probe(&pci_dev->dev, err,
+ "cannot start health checking!\n");
goto out_stop_services;
}
}
--
2.17.1
Powered by blists - more mailing lists