aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_base.c
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2011-08-30 21:45:37 -0400
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-09-11 08:02:18 -0400
commit9ce244b3fb416ce6600e05612ac46b9692dcc638 (patch)
tree34b9b77f38ce65f8efe9f9f40e71efd22bc43507 /drivers/mtd/nand/nand_base.c
parent10a2bcae99267b28e058b089fda30de7397b69f5 (diff)
mtd: support writing OOB without ECC
This fixes issues with `nandwrite -n -o' and the MEMWRITEOOB[64] ioctls on hardware that writes ECC when writing OOB. The problem arises as follows: `nandwrite -n' can write page data to flash without applying ECC, but when used with the `-o' option, ECC is applied (incorrectly), contrary to the `--noecc' option. I found that this is the case because my hardware computes and writes ECC data to flash upon either OOB write or page write. Thus, to support a proper "no ECC" write, my driver must know when we're performing a raw OOB write vs. a normal ECC OOB write. However, MTD does not pass any raw mode information to the write_oob functions. This patch addresses the problems by: 1) Passing MTD_OOB_RAW down to lower layers, instead of just defaulting to MTD_OOB_PLACE 2) Handling MTD_OOB_RAW within the NAND layer's `nand_do_write_oob' 3) Adding a new (replaceable) function pointer in struct ecc_ctrl; this function should support writing OOB without ECC data. Current hardware often can use the same OOB write function when writing either with or without ECC This was tested with nandsim as well as on actual SLC NAND. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Jim Quinlan <jim2101024@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r--drivers/mtd/nand/nand_base.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 7f2691f94322..b61a7c7bd097 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2404,7 +2404,11 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
2404 chip->pagebuf = -1; 2404 chip->pagebuf = -1;
2405 2405
2406 nand_fill_oob(mtd, ops->oobbuf, ops->ooblen, ops); 2406 nand_fill_oob(mtd, ops->oobbuf, ops->ooblen, ops);
2407 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask); 2407
2408 if (ops->mode == MTD_OOB_RAW)
2409 status = chip->ecc.write_oob_raw(mtd, chip, page & chip->pagemask);
2410 else
2411 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask);
2408 2412
2409 if (status) 2413 if (status)
2410 return status; 2414 return status;
@@ -3380,6 +3384,10 @@ int nand_scan_tail(struct mtd_info *mtd)
3380 BUG(); 3384 BUG();
3381 } 3385 }
3382 3386
3387 /* For many systems, the standard OOB write also works for raw */
3388 if (!chip->ecc.write_oob_raw)
3389 chip->ecc.write_oob_raw = chip->ecc.write_oob;
3390
3383 /* 3391 /*
3384 * The number of bytes available for a client to place data into 3392 * The number of bytes available for a client to place data into
3385 * the out of band area. 3393 * the out of band area.