Skip to contentSkip to conversation

mmc: atmel-mci: Use common error handling code in atmci_of_init()

PATCH In review Markus Elfring 2 participants 2 messages Nov 5, 2023 – Nov 10, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: atmel-mci: Use common error handling code in atmci_of_init()

From: Markus Elfring <[email protected]>
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.

---
 drivers/mmc/host/atmel-mci.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/mmc/host/atmel-mci.c +10 -8
index dba826db739a..1e83119d1dcb 100644
@@ -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

maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Markus Elfring

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

Quoted 46 lines
---
  drivers/mmc/host/atmel-mci.c | 18 ++++++++++--------
  1 file changed, 10 insertions(+), 8 deletions(-)
drivers/mmc/host/atmel-mci.c +10 -9
index dba826db739a..1e83119d1dcb 100644
@@ -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*
--
Quoted 2 lines

2.42.0

Best regards,
Aubin