mtd: nand: fix off-by-one read retry mode counting

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Feb 14 15:59:01 EST 2014


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=28fa65e643ed7cf753e89db20745e264c41f3682
Commit:     28fa65e643ed7cf753e89db20745e264c41f3682
Parent:     b28a960c42fcd9cfc987441fa6d1c1a471f0f9ed
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Wed Feb 12 16:08:28 2014 -0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Fri Feb 14 12:08:20 2014 -0800

    mtd: nand: fix off-by-one read retry mode counting
    
    A flash may support N read retry voltage threshold modes, numbered 0
    through N-1 (where mode 0 represents the initial state). However,
    nand_do_read_ops() tries to use mode 0 through N.
    
    This off-by-one error shows up, for instance, when using nanddump, and
    we have cycled through available modes:
    
        nand: setting READ RETRY mode 0
        nand: setting READ RETRY mode 1
        nand: setting READ RETRY mode 2
        nand: setting READ RETRY mode 3
        nand: setting READ RETRY mode 4
        nand: setting READ RETRY mode 5
        nand: setting READ RETRY mode 6
        nand: setting READ RETRY mode 7
        nand: setting READ RETRY mode 8
        libmtd: error!: cannot read 8192 bytes from mtd0 (eraseblock 20, offset 0)
                error 22 (Invalid argument)
        nanddump: error!: mtd_read
    
    Tested on Micron MT29F64G08CBCBBH1, with 8 retry modes.
    
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
    Acked-by: Huang Shijie <b32955 at freescale.com>
---
 drivers/mtd/nand/nand_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 59eba5d..9715a7b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1584,7 +1584,7 @@ read_retry:
 			}
 
 			if (mtd->ecc_stats.failed - ecc_failures) {
-				if (retry_mode + 1 <= chip->read_retries) {
+				if (retry_mode + 1 < chip->read_retries) {
 					retry_mode++;
 					ret = nand_setup_read_retry(mtd,
 							retry_mode);



More information about the linux-mtd-cvs mailing list