Skip to content

Commit a5ff4f1

Browse files
Jeff WestfahlDavid Woodhouse
authored andcommitted
mtd: nand: Added a device flag for subpage read support
Added a NAND device flag for subpage read support. Previously this was hard coded based on large page and soft ECC. Updated base NAND driver to use the new subpage read flag if the NAND is large page and soft ECC. Signed-off-by: Jeff Westfahl <[email protected]> Reviewed-by: Brian Norris <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
1 parent 32098f6 commit a5ff4f1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

drivers/mtd/nand/nand_base.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
14841484
ret = chip->ecc.read_page_raw(mtd, chip, bufpoi,
14851485
oob_required,
14861486
page);
1487-
else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
1487+
else if (!aligned && NAND_HAS_SUBPAGE_READ(chip) &&
1488+
!oob)
14881489
ret = chip->ecc.read_subpage(mtd, chip,
14891490
col, bytes, bufpoi);
14901491
else
@@ -1501,7 +1502,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
15011502

15021503
/* Transfer not aligned data */
15031504
if (!aligned) {
1504-
if (!NAND_SUBPAGE_READ(chip) && !oob &&
1505+
if (!NAND_HAS_SUBPAGE_READ(chip) && !oob &&
15051506
!(mtd->ecc_stats.failed - stats.failed) &&
15061507
(ops->mode != MTD_OPS_RAW)) {
15071508
chip->pagebuf = realpage;
@@ -3415,6 +3416,10 @@ int nand_scan_tail(struct mtd_info *mtd)
34153416
/* Invalidate the pagebuffer reference */
34163417
chip->pagebuf = -1;
34173418

3419+
/* Large page NAND with SOFT_ECC should support subpage reads */
3420+
if ((chip->ecc.mode == NAND_ECC_SOFT) && (chip->page_shift > 9))
3421+
chip->options |= NAND_SUBPAGE_READ;
3422+
34183423
/* Fill in remaining MTD driver data */
34193424
mtd->type = MTD_NANDFLASH;
34203425
mtd->flags = (chip->options & NAND_ROM) ? MTD_CAP_ROM :

include/linux/mtd/nand.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ typedef enum {
194194
/* Device behaves just like nand, but is readonly */
195195
#define NAND_ROM 0x00000800
196196

197+
/* Device supports subpage reads */
198+
#define NAND_SUBPAGE_READ 0x00001000
199+
197200
/* Options valid for Samsung large page devices */
198201
#define NAND_SAMSUNG_LP_OPTIONS \
199202
(NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK)
@@ -202,9 +205,7 @@ typedef enum {
202205
#define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
203206
#define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
204207
#define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
205-
/* Large page NAND with SOFT_ECC should support subpage reads */
206-
#define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
207-
&& (chip->page_shift > 9))
208+
#define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ))
208209

209210
/* Non chip related options */
210211
/* This option skips the bbt scan during initialization. */

0 commit comments

Comments
 (0)