diff mbox

mtd: nand: docg4: simplify error case

Message ID 1450467593-90957-1-git-send-email-computersforpeace@gmail.com
State Accepted
Commit 2d3743944a6b425f3a3795a967499c13e0d8856c
Headers show

Commit Message

Brian Norris Dec. 18, 2015, 7:39 p.m. UTC
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.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/docg4.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Boris Brezillon Dec. 18, 2015, 8:24 p.m. UTC | #1
On Fri, 18 Dec 2015 11:39:53 -0800
Brian Norris <computersforpeace@gmail.com> wrote:

> 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.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
>  drivers/mtd/nand/docg4.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
> index cb6efadd712e..24d478d90dcc 100644
> --- a/drivers/mtd/nand/docg4.c
> +++ b/drivers/mtd/nand/docg4.c
> @@ -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);
Brian Norris Dec. 18, 2015, 8:43 p.m. UTC | #2
On Fri, Dec 18, 2015 at 11:39:53AM -0800, Brian Norris wrote:
> 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.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Applied
diff mbox

Patch

diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
index cb6efadd712e..24d478d90dcc 100644
--- a/drivers/mtd/nand/docg4.c
+++ b/drivers/mtd/nand/docg4.c
@@ -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);