mtd: rawnand: diskonchip: Make sure doc2001plus_readbuf() works for single byte reads
authorBoris Brezillon <boris.brezillon@collabora.com>
Fri, 1 May 2020 14:39:13 +0000 (16:39 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 11 May 2020 07:51:43 +0000 (09:51 +0200)
Single byte accesses normally go through read_byte() but we are about
to use this function in the exec_op() implementation and thus needs to
prepare for single byte reads.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200501143917.1388957-2-boris.brezillon@collabora.com
drivers/mtd/nand/raw/diskonchip.c

index 4c3d04d..ab5a366 100644 (file)
@@ -550,9 +550,12 @@ static void doc2001plus_readbuf(struct nand_chip *this, u_char *buf, int len)
        }
 
        /* Terminate read pipeline */
-       buf[len - 2] = ReadDOC(docptr, Mplus_LastDataRead);
-       if (debug && i < 16)
-               printk("%02x ", buf[len - 2]);
+       if (len >= 2) {
+               buf[len - 2] = ReadDOC(docptr, Mplus_LastDataRead);
+               if (debug && i < 16)
+                       printk("%02x ", buf[len - 2]);
+       }
+
        buf[len - 1] = ReadDOC(docptr, Mplus_LastDataRead);
        if (debug && i < 16)
                printk("%02x ", buf[len - 1]);