Skip to contentSkip to conversation

mmc: tmio: Use common error handling code in tmio_mmc_host_probe()

PATCH Applied SF Markus Elfring 2 participants 2 messages Oct 27, 2017 – Oct 30, 2017

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

PATCH 1/1 mmc: tmio: Use common error handling code in tmio_mmc_host_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 27 Oct 2017 19:09:17 +0200

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

* Adjust condition checks.

This issue was detected by using the Coccinelle software.

---
 drivers/mmc/host/tmio_mmc_core.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +9 -8
index a7293e186e03..2e85d4048cec 100644
@@ -1286,23 +1286,24 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 	pm_runtime_enable(&pdev->dev);
 
 	ret = mmc_add_host(mmc);
-	if (ret < 0) {
-		tmio_mmc_host_remove(_host);
-		return ret;
-	}
+	if (ret)
+		goto remove_host;
 
 	dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
 
 	if (pdata->flags & TMIO_MMC_USE_GPIO_CD) {
 		ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0);
-		if (ret < 0) {
-			tmio_mmc_host_remove(_host);
-			return ret;
-		}
+		if (ret)
+			goto remove_host;
+
 		mmc_gpiod_request_cd_irq(mmc);
 	}
 
 	return 0;
+
+remove_host:
+	tmio_mmc_host_remove(_host);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_host_probe);
 
Signature · 1 line
2.14.3
Applied
#1 lore raw
Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 27 Oct 2017 19:09:17 +0200

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

* Adjust condition checks.

This issue was detected by using the Coccinelle software.

Thanks, applied for next!

Kind regards
Uffe

Quoted 44 lines
---
 drivers/mmc/host/tmio_mmc_core.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +9 -9
index a7293e186e03..2e85d4048cec 100644
@@ -1286,23 +1286,24 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
        pm_runtime_enable(&pdev->dev);
 
        ret = mmc_add_host(mmc);
-       if (ret < 0) {
-               tmio_mmc_host_remove(_host);
-               return ret;
-       }
+       if (ret)
+               goto remove_host;
 
        dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
 
        if (pdata->flags & TMIO_MMC_USE_GPIO_CD) {
                ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0);
-               if (ret < 0) {
-                       tmio_mmc_host_remove(_host);
-                       return ret;
-               }
+               if (ret)
+                       goto remove_host;
+
                mmc_gpiod_request_cd_irq(mmc);
        }
 
        return 0;
+
+remove_host:
+       tmio_mmc_host_remove(_host);
+       return ret;
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_host_probe);
 
--

2.14.3