diff options
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 45 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_bbt.c | 10 |
2 files changed, 51 insertions, 4 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index e190db7308..5db0b5625e 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3415,6 +3415,9 @@ int nand_write_oob_std(struct nand_chip *chip, int page) { struct mtd_info *mtd = nand_to_mtd(chip); + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + return nand_prog_page_op(chip, page, mtd->writesize, chip->oob_poi, mtd->oobsize); } @@ -3434,6 +3437,9 @@ static int nand_write_oob_syndrome(struct nand_chip *chip, int page) int ret, i, len, pos, sndcmd = 0, steps = chip->ecc.steps; const uint8_t *bufpoi = chip->oob_poi; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + /* * data-ecc-data-ecc ... ecc-oob * or @@ -3635,6 +3641,9 @@ int nand_write_page_raw(struct nand_chip *chip, const uint8_t *buf, struct mtd_info *mtd = nand_to_mtd(chip); int ret; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + ret = nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize); if (ret) return ret; @@ -3673,6 +3682,9 @@ int nand_monolithic_write_page_raw(struct nand_chip *chip, const u8 *buf, unsigned int size = mtd->writesize; u8 *write_buf = (u8 *)buf; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + if (oob_required) { size += mtd->oobsize; @@ -3705,6 +3717,9 @@ static int nand_write_page_raw_syndrome(struct nand_chip *chip, uint8_t *oob = chip->oob_poi; int steps, size, ret; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + ret = nand_prog_page_begin_op(chip, page, 0, NULL, 0); if (ret) return ret; @@ -3767,6 +3782,9 @@ static int nand_write_page_swecc(struct nand_chip *chip, const uint8_t *buf, uint8_t *ecc_calc = chip->ecc.calc_buf; const uint8_t *p = buf; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + /* Software ECC calculation */ for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) chip->ecc.calculate(chip, p, &ecc_calc[i]); @@ -3796,6 +3814,9 @@ static int nand_write_page_hwecc(struct nand_chip *chip, const uint8_t *buf, uint8_t *ecc_calc = chip->ecc.calc_buf; const uint8_t *p = buf; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + ret = nand_prog_page_begin_op(chip, page, 0, NULL, 0); if (ret) return ret; @@ -3847,6 +3868,9 @@ static int nand_write_subpage_hwecc(struct nand_chip *chip, uint32_t offset, int oob_bytes = mtd->oobsize / ecc_steps; int step, ret; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + ret = nand_prog_page_begin_op(chip, page, 0, NULL, 0); if (ret) return ret; @@ -3914,6 +3938,9 @@ static int nand_write_page_syndrome(struct nand_chip *chip, const uint8_t *buf, uint8_t *oob = chip->oob_poi; int ret; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + ret = nand_prog_page_begin_op(chip, page, 0, NULL, 0); if (ret) return ret; @@ -3980,6 +4007,9 @@ static int nand_write_page(struct nand_chip *chip, uint32_t offset, struct mtd_info *mtd = nand_to_mtd(chip); int status, subpage; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + if (!(chip->options & NAND_NO_SUBPAGE_WRITE) && chip->ecc.write_subpage) subpage = offset || (data_len < mtd->writesize); @@ -4026,6 +4056,9 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to, int ret; int oob_required = oob ? 1 : 0; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + ops->retlen = 0; if (!writelen) return 0; @@ -4143,6 +4176,9 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, struct nand_chip *chip = mtd_to_nand(mtd); int ret; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + ops->retlen = 0; ret = nand_get_device(chip); @@ -4178,6 +4214,9 @@ out: */ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr) { + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + return nand_erase_nand(mtd_to_nand(mtd), instr, 0); } @@ -4197,6 +4236,9 @@ int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr, int page, pages_per_block, ret, chipnr; loff_t len; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + pr_debug("%s: start = 0x%012llx, len = %llu\n", __func__, (unsigned long long)instr->addr, (unsigned long long)instr->len); @@ -4335,6 +4377,9 @@ static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs) { int ret; + if (!IS_ENABLED(CONFIG_MTD_WRITE)) + return -ENOTSUPP; + ret = nand_block_isbad(mtd, ofs); if (ret) { /* If it was bad already, return success and do nothing */ diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index f582799636..a86b5b2da3 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c @@ -1018,14 +1018,16 @@ static int check_create(struct nand_chip *this, uint8_t *buf, } /* Write the bad block table to the device? */ - if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { + if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE) && + IS_ENABLED(CONFIG_MTD_WRITE)) { res = write_bbt(this, buf, td, md, chipsel); if (res < 0) return res; } /* Write the mirror bad block table to the device? */ - if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { + if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE) && + IS_ENABLED(CONFIG_MTD_WRITE)) { res = write_bbt(this, buf, md, td, chipsel); if (res < 0) return res; @@ -1074,13 +1076,13 @@ int nand_update_bbt(struct nand_chip *this, loff_t offs) md->version[chip]++; /* Write the bad block table to the device? */ - if (td->options & NAND_BBT_WRITE) { + if ((td->options & NAND_BBT_WRITE) && IS_ENABLED(CONFIG_MTD_WRITE)) { res = write_bbt(this, buf, td, md, chipsel); if (res < 0) goto out; } /* Write the mirror bad block table to the device? */ - if (md && (md->options & NAND_BBT_WRITE)) { + if (md && (md->options & NAND_BBT_WRITE) && IS_ENABLED(CONFIG_MTD_WRITE)) { res = write_bbt(this, buf, md, td, chipsel); } |