* [cocci] [PATCH] mmc: atmel-mci: Use common error handling code in atmci_of_init()
@ 2023-11-05 15:50 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2023-11-05 15:50 UTC (permalink / raw)
To: Julia Lawall, Alexandre Belloni, Aubin Constans, Claudiu Beznea,
Nicolas Ferre, Ulf Hansson, linux-mmc, linux-arm-kernel,
kernel-janitors
Cc: cocci, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 5 Nov 2023 16:36:58 +0100
Add a jump target so that a bit of exception handling can be better
reused at the end of this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/mmc/host/atmel-mci.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index dba826db739a..1e83119d1dcb 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -675,10 +675,9 @@ atmci_of_init(struct platform_device *pdev)
"cd", GPIOD_IN, "cd-gpios");
err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].detect_pin);
if (err) {
- if (err != -ENOENT) {
- of_node_put(cnp);
- return ERR_PTR(err);
- }
+ if (err != -ENOENT)
+ goto put_node;
+
pdata->slot[slot_id].detect_pin = NULL;
}
@@ -690,15 +689,18 @@ atmci_of_init(struct platform_device *pdev)
"wp", GPIOD_IN, "wp-gpios");
err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].wp_pin);
if (err) {
- if (err != -ENOENT) {
- of_node_put(cnp);
- return ERR_PTR(err);
- }
+ if (err != -ENOENT)
+ goto put_node;
+
pdata->slot[slot_id].wp_pin = NULL;
}
}
return pdata;
+
+put_node:
+ of_node_put(cnp);
+ return ERR_PTR(err);
}
#else /* CONFIG_OF */
static inline struct mci_platform_data*
--
2.42.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-05 15:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-05 15:50 [cocci] [PATCH] mmc: atmel-mci: Use common error handling code in atmci_of_init() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).