diff mbox series

[1/5] mtd: rawnand: diskonchip: Make sure doc2001plus_readbuf() works for single byte reads

Message ID 20200501143917.1388957-2-boris.brezillon@collabora.com
State Accepted
Headers show
Series mtd: rawnand: diskonchip: Convert to exec_op() | expand

Commit Message

Boris Brezillon May 1, 2020, 2:39 p.m. UTC
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>
---
 drivers/mtd/nand/raw/diskonchip.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Miquel Raynal May 11, 2020, 7:49 a.m. UTC | #1
On Fri, 2020-05-01 at 14:39:13 UTC, Boris Brezillon wrote:
> 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>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/diskonchip.c b/drivers/mtd/nand/raw/diskonchip.c
index 03f772a0ec2b..724493624822 100644
--- a/drivers/mtd/nand/raw/diskonchip.c
+++ b/drivers/mtd/nand/raw/diskonchip.c
@@ -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]);