From: Sascha Hauer Date: Fri, 28 May 2010 08:02:17 +0000 (+0200) Subject: mtd: mxc_nand: fix OOB accesses on i.MX27 X-Git-Tag: v2.6.36-rc1~301^2~75 X-Git-Url: https://bbs.cooldavid.org/git/?a=commitdiff_plain;h=6c49939869c20550512386610ece45aceb65e7f4;p=net-next-2.6.git mtd: mxc_nand: fix OOB accesses on i.MX27 The OOB handling in the mxc_nand driver is broken for v1 type controllers (i.MX27/31) with 512 byte page size. This perhaps did not show up because ubi does not use OOB. Update the driver to always read/write a whole page even if only OOB is requested. With this patch the driver passes the mtd_oobtest on i.MX27 with 512 byte page size. Also tested with 2048 byte page size and on i.MX35 (v2 type controller) Signed-off-by: Sascha Hauer Signed-off-by: David Woodhouse --- diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 82e94389824..6e8aa34e4df 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -623,8 +623,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, else host->buf_start = column + mtd->writesize; - if (mtd->writesize > 512) - command = NAND_CMD_READ0; /* only READ0 is valid */ + command = NAND_CMD_READ0; /* only READ0 is valid */ send_cmd(host, command, false); mxc_do_addr_cycle(mtd, column, page_addr); @@ -639,31 +638,11 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, break; case NAND_CMD_SEQIN: - if (column >= mtd->writesize) { - /* - * FIXME: before send SEQIN command for write OOB, - * We must read one page out. - * For K9F1GXX has no READ1 command to set current HW - * pointer to spare area, we must write the whole page - * including OOB together. - */ - if (mtd->writesize > 512) - /* call ourself to read a page */ - mxc_nand_command(mtd, NAND_CMD_READ0, 0, - page_addr); - - host->buf_start = column; - - /* Set program pointer to spare region */ - if (mtd->writesize == 512) - send_cmd(host, NAND_CMD_READOOB, false); - } else { - host->buf_start = column; + if (column >= mtd->writesize) + /* call ourself to read a page */ + mxc_nand_command(mtd, NAND_CMD_READ0, 0, page_addr); - /* Set program pointer to page start */ - if (mtd->writesize == 512) - send_cmd(host, NAND_CMD_READ0, false); - } + host->buf_start = column; send_cmd(host, command, false); mxc_do_addr_cycle(mtd, column, page_addr);