Patchwork [2/8] mtd: spi-nor: handle timeout errors in spi_nor_write()

login
register
mail settings
Submitter Brian Norris
Date Aug. 7, 2014, 1:16 a.m.
Message ID <1407374222-8448-3-git-send-email-computersforpeace@gmail.com>
Download mbox | patch
Permalink /patch/377702/
State Accepted
Commit 1d61dcb3ff5e4713d242a539947d8dd650ab3014
Headers show

Comments

Brian Norris - Aug. 7, 2014, 1:16 a.m.
The error label was unused here. It looks like we're missing at least
one case that should be doing 'goto write_err'.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Marek Vasut - Aug. 7, 2014, 2:23 p.m.
On Thursday, August 07, 2014 at 03:16:56 AM, Brian Norris wrote:
> The error label was unused here. It looks like we're missing at least
> one case that should be doing 'goto write_err'.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Reviewed-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut
Huang Shijie - Aug. 9, 2014, 7:37 a.m.
On Wed, Aug 06, 2014 at 06:16:56PM -0700, Brian Norris wrote:
> The error label was unused here. It looks like we're missing at least
> one case that should be doing 'goto write_err'.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
>  drivers/mtd/spi-nor/spi-nor.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 5825b8a12cee..d77c93232b76 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -809,7 +809,10 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
>  			if (page_size > nor->page_size)
>  				page_size = nor->page_size;
>  
> -			wait_till_ready(nor);
> +			ret = wait_till_ready(nor);
> +			if (ret)
> +				goto write_err;
> +
>  			write_enable(nor);
>  
>  			nor->write(nor, to + i, page_size, retlen, buf + i);
> @@ -818,7 +821,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
>  
>  write_err:
>  	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE);
> -	return 0;
> +	return ret;
>  }
>  
>  static int macronix_quad_enable(struct spi_nor *nor)
> -- 
> 1.9.1
Acked-by: Huang Shijie <shijie8@gmail.com>

Huang Shijie

Patch

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 5825b8a12cee..d77c93232b76 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -809,7 +809,10 @@  static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 			if (page_size > nor->page_size)
 				page_size = nor->page_size;
 
-			wait_till_ready(nor);
+			ret = wait_till_ready(nor);
+			if (ret)
+				goto write_err;
+
 			write_enable(nor);
 
 			nor->write(nor, to + i, page_size, retlen, buf + i);
@@ -818,7 +821,7 @@  static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 write_err:
 	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE);
-	return 0;
+	return ret;
 }
 
 static int macronix_quad_enable(struct spi_nor *nor)