Patchwork [3/4] mtd: nand: gpio: Return real nand_scan() error code on fail and simplify error path

login
register
mail settings
Submitter Alexander Shiyan
Date July 23, 2013, 12:28 p.m.
Message ID <1374582499-31823-3-git-send-email-shc_work@mail.ru>
Download mbox | patch
Permalink /patch/261062/
State New
Headers show

Comments

Alexander Shiyan - July 23, 2013, 12:28 p.m.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/mtd/nand/gpio.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

Patch

diff --git a/drivers/mtd/nand/gpio.c b/drivers/mtd/nand/gpio.c
index 7f16962..7b1dbd3 100644
--- a/drivers/mtd/nand/gpio.c
+++ b/drivers/mtd/nand/gpio.c
@@ -206,7 +206,7 @@  static int gpio_nand_probe(struct platform_device *pdev)
 	struct nand_chip *chip;
 	struct resource *res;
 	struct mtd_part_parser_data ppdata = {};
-	int ret = 0;
+	int ret;
 
 	if (!pdev->dev.of_node && !pdev->dev.platform_data)
 		return -EINVAL;
@@ -282,23 +282,20 @@  static int gpio_nand_probe(struct platform_device *pdev)
 
 	gpio_nand_set_wp(gpiomtd, 1);
 
-	if (nand_scan(&gpiomtd->mtd_info, 1)) {
-		ret = -ENXIO;
-		goto err_wp;
+	ret = nand_scan(&gpiomtd->mtd_info, 1);
+	if (!ret) {
+		if (gpiomtd->plat.adjust_parts)
+			gpiomtd->plat.adjust_parts(&gpiomtd->plat,
+						   gpiomtd->mtd_info.size);
+
+		ppdata.of_node = pdev->dev.of_node;
+		ret = mtd_device_parse_register(&gpiomtd->mtd_info, NULL,
+						&ppdata, gpiomtd->plat.parts,
+						gpiomtd->plat.num_parts);
+		if (!ret)
+			return 0;
 	}
 
-	if (gpiomtd->plat.adjust_parts)
-		gpiomtd->plat.adjust_parts(&gpiomtd->plat,
-					   gpiomtd->mtd_info.size);
-
-	ppdata.of_node = pdev->dev.of_node;
-	ret = mtd_device_parse_register(&gpiomtd->mtd_info, NULL, &ppdata,
-					gpiomtd->plat.parts,
-					gpiomtd->plat.num_parts);
-	if (!ret)
-		return 0;
-
-err_wp:
 	gpio_nand_set_wp(gpiomtd, 0);
 
 	return ret;