Skip to contentSkip to conversation

ata: libahci_platform: Use common error handling code in ahci_platform_get_resources()

PATCH In review Markus Elfring 2 participants 2 messages Sep 22, 2019 – Sep 23, 2019

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

PATCH 1/1 ata: libahci_platform: Use common error handling code in ahci_platform_get_resources()

From: Markus Elfring <[email protected]>
Date: Sun, 22 Sep 2019 15:42:46 +0200

Convert the call of the function “of_node_put” to another jump target so that it can be better reused at three places in this function.

---
 drivers/ata/libahci_platform.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/ata/libahci_platform.c +7 -10
index e742780950de..7b2e364f3bd5 100644
@@ -497,8 +497,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
 
 			if (of_property_read_u32(child, "reg", &port)) {
 				rc = -EINVAL;
-				of_node_put(child);
-				goto err_out;
+				goto err_put_node;
 			}
 
 			if (port >= hpriv->nports) {
@@ -515,18 +514,14 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
 			if (port_dev) {
 				rc = ahci_platform_get_regulator(hpriv, port,
 								&port_dev->dev);
-				if (rc == -EPROBE_DEFER) {
-					of_node_put(child);
-					goto err_out;
-				}
+				if (rc == -EPROBE_DEFER)
+					goto err_put_node;
 			}
 #endif
 
 			rc = ahci_platform_get_phy(hpriv, port, dev, child);
-			if (rc) {
-				of_node_put(child);
-				goto err_out;
-			}
+			if (rc)
+				goto err_put_node;
 
 			enabled_ports++;
 		}
@@ -558,6 +553,8 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
 	devres_remove_group(dev, NULL);
 	return hpriv;
 
+err_put_node:
+	of_node_put(child);
 err_out:
 	devres_release_group(dev, NULL);
 	return ERR_PTR(rc);

--
2.23.0

Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 7 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 22 Sep 2019 15:42:46 +0200

Convert the call of the function “of_node_put” to another jump target so that it can be better reused at three places in this function.

Patch looks good to me:

Regards,

Hans

Quoted 53 lines
---
  drivers/ata/libahci_platform.c | 17 +++++++----------
  1 file changed, 7 insertions(+), 10 deletions(-)
drivers/ata/libahci_platform.c +7 -11
index e742780950de..7b2e364f3bd5 100644
@@ -497,8 +497,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
 
  			if (of_property_read_u32(child, "reg", &port)) {
  				rc = -EINVAL;
-				of_node_put(child);
-				goto err_out;
+				goto err_put_node;
  			}
 
  			if (port >= hpriv->nports) {
@@ -515,18 +514,14 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
  			if (port_dev) {
  				rc = ahci_platform_get_regulator(hpriv, port,
  								&port_dev->dev);
-				if (rc == -EPROBE_DEFER) {
-					of_node_put(child);
-					goto err_out;
-				}
+				if (rc == -EPROBE_DEFER)
+					goto err_put_node;
  			}
  #endif
 
  			rc = ahci_platform_get_phy(hpriv, port, dev, child);
-			if (rc) {
-				of_node_put(child);
-				goto err_out;
-			}
+			if (rc)
+				goto err_put_node;
 
  			enabled_ports++;
  		}
@@ -558,6 +553,8 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
  	devres_remove_group(dev, NULL);
  	return hpriv;
 
+err_put_node:
+	of_node_put(child);
  err_out:
  	devres_release_group(dev, NULL);
  	return ERR_PTR(rc);
--

2.23.0