diff mbox

nand: fix .correct callback return value check

Message ID ca767a0d6cafbea862c307e944c2b800dafb6660.1281327492.git.baruch@tkos.co.il
State Accepted
Commit 12c8eb98de747ebc08404e3719c40abb405994e2
Headers show

Commit Message

Baruch Siach Aug. 9, 2010, 4:20 a.m. UTC
Drivers may (and do) return negative errno values other than -1 from the
.correct callback.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/mtd/nand/nand_base.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Baruch Siach Aug. 12, 2010, 5:42 a.m. UTC | #1
Hi linux-mtd list,

Ping?

At least the atmel_nand and the bf5xx_nand drivers may return -EIO for 
uncorrectable errors, so this patch fixes a real bug.

baruch

On Mon, Aug 09, 2010 at 07:20:23AM +0300, Baruch Siach wrote:
> Drivers may (and do) return negative errno values other than -1 from the
> .correct callback.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  drivers/mtd/nand/nand_base.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 4a7b864..080f551 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -1210,7 +1210,7 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, uint3
>  		int stat;
>  
>  		stat = chip->ecc.correct(mtd, p, &chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]);
> -		if (stat == -1)
> +		if (stat < 0)
>  			mtd->ecc_stats.failed++;
>  		else
>  			mtd->ecc_stats.corrected += stat;
> -- 
> 1.7.1
Artem Bityutskiy Aug. 29, 2010, 11:01 a.m. UTC | #2
On Mon, 2010-08-09 at 07:20 +0300, Baruch Siach wrote:
> Drivers may (and do) return negative errno values other than -1 from the
> .correct callback.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>

Pushed to l2-mtd-2.6.git / master, thank you!

Artem.
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 4a7b864..080f551 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1210,7 +1210,7 @@  static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, uint3
 		int stat;
 
 		stat = chip->ecc.correct(mtd, p, &chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]);
-		if (stat == -1)
+		if (stat < 0)
 			mtd->ecc_stats.failed++;
 		else
 			mtd->ecc_stats.corrected += stat;