aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-17 14:15:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-17 14:15:30 -0500
commitab2020f2f11fc7fb81e6c71298b0830d85412011 (patch)
treec9a6342063461dcf31278d65585bca73bdda4a84 /drivers/mtd/ubi
parent235646a486d10891bd86af28d8eac75d9f22bd2d (diff)
parent154bf89f5e3e3dc59666926f27ca4a0866f39157 (diff)
Merge git://git.infradead.org/mtd-2.6
* git://git.infradead.org/mtd-2.6: (59 commits) mtd: mtdpart: disallow reading OOB past the end of the partition mtd: pxa3xx_nand: NULL dereference in pxa3xx_nand_probe UBI: use mtd->writebufsize to set minimal I/O unit size mtd: initialize writebufsize in the MTD object of a partition mtd: onenand: add mtd->writebufsize initialization mtd: nand: add mtd->writebufsize initialization mtd: cfi: add writebufsize initialization mtd: add writebufsize field to mtd_info struct mtd: OneNAND: OMAP2/3: prevent regulator sleeping while OneNAND is in use mtd: OneNAND: add enable / disable methods to onenand_chip mtd: m25p80: Fix JEDEC ID for AT26DF321 mtd: txx9ndfmc: limit transfer bytes to 512 (ECC provides 6 bytes max) mtd: cfi_cmdset_0002: add support for Samsung K8D3x16UxC NOR chips mtd: cfi_cmdset_0002: add support for Samsung K8D6x16UxM NOR chips mtd: nand: ams-delta: drop omap_read/write, use ioremap mtd: m25p80: add debugging trace in sst_write mtd: nand: ams-delta: select for built-in by default mtd: OneNAND: lighten scary initial bad block messages mtd: OneNAND: OMAP2/3: add support for command line partitioning mtd: nand: rearrange ONFI revision checking, add ONFI 2.3 ... Fix up trivial conflict in drivers/mtd/Kconfig as per DavidW.
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/build.c28
-rw-r--r--drivers/mtd/ubi/vtbl.c6
2 files changed, 29 insertions, 5 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 5ebe280225d6..f49e49dc5928 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -672,7 +672,33 @@ static int io_init(struct ubi_device *ubi)
672 ubi->nor_flash = 1; 672 ubi->nor_flash = 1;
673 } 673 }
674 674
675 ubi->min_io_size = ubi->mtd->writesize; 675 /*
676 * Set UBI min. I/O size (@ubi->min_io_size). We use @mtd->writebufsize
677 * for these purposes, not @mtd->writesize. At the moment this does not
678 * matter for NAND, because currently @mtd->writebufsize is equivalent to
679 * @mtd->writesize for all NANDs. However, some CFI NOR flashes may
680 * have @mtd->writebufsize which is multiple of @mtd->writesize.
681 *
682 * The reason we use @mtd->writebufsize for @ubi->min_io_size is that
683 * UBI and UBIFS recovery algorithms rely on the fact that if there was
684 * an unclean power cut, then we can find offset of the last corrupted
685 * node, align the offset to @ubi->min_io_size, read the rest of the
686 * eraseblock starting from this offset, and check whether there are
687 * only 0xFF bytes. If yes, then we are probably dealing with a
688 * corruption caused by a power cut, if not, then this is probably some
689 * severe corruption.
690 *
691 * Thus, we have to use the maximum write unit size of the flash, which
692 * is @mtd->writebufsize, because @mtd->writesize is the minimum write
693 * size, not the maximum.
694 */
695 if (ubi->mtd->type == MTD_NANDFLASH)
696 ubi_assert(ubi->mtd->writebufsize == ubi->mtd->writesize);
697 else if (ubi->mtd->type == MTD_NORFLASH)
698 ubi_assert(ubi->mtd->writebufsize % ubi->mtd->writesize == 0);
699
700 ubi->min_io_size = ubi->mtd->writebufsize;
701
676 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; 702 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
677 703
678 /* 704 /*
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index fcdb7f65fe0b..0b8141fc5c26 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -425,12 +425,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
425 425
426 /* Read both LEB 0 and LEB 1 into memory */ 426 /* Read both LEB 0 and LEB 1 into memory */
427 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { 427 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) {
428 leb[seb->lnum] = vmalloc(ubi->vtbl_size); 428 leb[seb->lnum] = vzalloc(ubi->vtbl_size);
429 if (!leb[seb->lnum]) { 429 if (!leb[seb->lnum]) {
430 err = -ENOMEM; 430 err = -ENOMEM;
431 goto out_free; 431 goto out_free;
432 } 432 }
433 memset(leb[seb->lnum], 0, ubi->vtbl_size);
434 433
435 err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, 434 err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0,
436 ubi->vtbl_size); 435 ubi->vtbl_size);
@@ -516,10 +515,9 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
516 int i; 515 int i;
517 struct ubi_vtbl_record *vtbl; 516 struct ubi_vtbl_record *vtbl;
518 517
519 vtbl = vmalloc(ubi->vtbl_size); 518 vtbl = vzalloc(ubi->vtbl_size);
520 if (!vtbl) 519 if (!vtbl)
521 return ERR_PTR(-ENOMEM); 520 return ERR_PTR(-ENOMEM);
522 memset(vtbl, 0, ubi->vtbl_size);
523 521
524 for (i = 0; i < ubi->vtbl_slots; i++) 522 for (i = 0; i < ubi->vtbl_slots; i++)
525 memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE); 523 memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE);