Skip to contentSkip to conversation

mtd: nand: docg4: simplify error case

PATCH Applied Brian Norris 2 participants 3 messages Dec 18, 2015

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

PATCH 1/1 mtd: nand: docg4: simplify error case

Other refactorings have left the 'fail' label much simpler, so it shouldn't have to handle the failed allocation case.

This also fixes a -Wshadow warning.

---
 drivers/mtd/nand/docg4.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/mtd/nand/docg4.c +4 -8
index cb6efadd712e..24d478d90dcc 100644
@@ -1353,14 +1353,10 @@ static int __init probe_docg4(struct platform_device *pdev)
 	doc->mtd = mtd;
 	return 0;
 
- fail:
-	if (nand) {
-		/* re-declarations avoid compiler warning */
-		struct docg4_priv *doc = nand->priv;
-		nand_release(mtd); /* deletes partitions and mtd devices */
-		free_bch(doc->bch);
-		kfree(nand);
-	}
+fail:
+	nand_release(mtd); /* deletes partitions and mtd devices */
+	free_bch(doc->bch);
+	kfree(nand);
 
 fail_unmap:
 	iounmap(virtadr);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Fri, 18 Dec 2015 11:39:53 -0800 Brian Norris <[email protected]>…

Other refactorings have left the 'fail' label much simpler, so it shouldn't have to handle the failed allocation case.

This also fixes a -Wshadow warning.

Quoted 27 lines
---
 drivers/mtd/nand/docg4.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/mtd/nand/docg4.c +4 -8
index cb6efadd712e..24d478d90dcc 100644
@@ -1353,14 +1353,10 @@ static int __init probe_docg4(struct platform_device *pdev)
 	doc->mtd = mtd;
 	return 0;
 
- fail:
-	if (nand) {
-		/* re-declarations avoid compiler warning */
-		struct docg4_priv *doc = nand->priv;
-		nand_release(mtd); /* deletes partitions and mtd devices */
-		free_bch(doc->bch);
-		kfree(nand);
-	}
+fail:
+	nand_release(mtd); /* deletes partitions and mtd devices */
+	free_bch(doc->bch);
+	kfree(nand);
 
 fail_unmap:
 	iounmap(virtadr);
Signature · 3 lines
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com