mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] misc: genwqe: Simplify with dev_err_probe()
@ 2024-08-30  8:38 Shen Lichuan
  2024-08-30 18:15 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Shen Lichuan @ 2024-08-30  8:38 UTC (permalink / raw)
  To: haver, arnd, gregkh; +Cc: linux-kernel, opensource.kernel, Shen Lichuan

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@vivo.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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-30 18:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-30  8:38 [PATCH v1] misc: genwqe: Simplify with dev_err_probe() Shen Lichuan
2024-08-30 18:15 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®