From e8f50fb7b31893a7ee3ff49dcadcb064f499f8fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Tue, 5 Nov 2013 22:54:05 +0100 Subject: [PATCH] fs: jffs2: make jffs2 work zero oobavail --- drivers/mtd/nand/nand_base.c | 6 ++++++ fs/jffs2/scan.c | 4 ++-- fs/jffs2/wbuf.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index ec1db1e19c05..2d9fe18e58c6 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1741,6 +1741,9 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, else len = mtd->oobsize; + if (len == 0) + return 0; + if (unlikely(ops->ooboffs >= len)) { pr_debug("%s: attempt to start read outside oob\n", __func__); @@ -2409,6 +2412,9 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, else len = mtd->oobsize; + if (len == 0) + return 0; + /* Do not allow write past end of page */ if ((ops->ooboffs + ops->ooblen) > len) { pr_debug("%s: attempt to write past end of page\n", diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index 7654e87b0428..96ef21eff62b 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c @@ -113,7 +113,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) if (!flashbuf) { /* For NAND it's quicker to read a whole eraseblock at a time, apparently */ - if (jffs2_cleanmarker_oob(c)) + if (c->mtd->type == MTD_NANDFLASH) try_size = c->sector_size; else try_size = PAGE_SIZE; @@ -459,7 +459,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo jffs2_dbg(1, "%s(): Scanning block at 0x%x\n", __func__, ofs); #ifdef CONFIG_JFFS2_FS_WRITEBUFFER - if (jffs2_cleanmarker_oob(c)) { + if (c->mtd->type == MTD_NANDFLASH) { int ret; if (mtd_block_isbad(c->mtd, jeb->offset)) diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index a6597d60d76d..b5f218903d7b 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c @@ -1200,7 +1200,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) /* Cleanmarker is out-of-band, so inline size zero */ c->cleanmarker_size = 0; - if (!oinfo || oinfo->oobavail == 0) { + if (!oinfo /* || oinfo->oobavail == 0 */) { pr_err("inconsistent device description\n"); return -EINVAL; } -- 2.39.2