aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-01-30 11:37:33 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-03-08 03:12:48 -0500
commit30b542ef453e6832ff682170b2db95d7bca2fe70 (patch)
treea74ccffb6a4eebb6ec8f9d3aa2d152700f995830 /drivers/mtd
parent10ac27970274e9094aee84a6452a25bf1b7e59e1 (diff)
UBI: incorporate maximum write size
Incorporate MTD write buffer size into UBI device information because UBIFS needs this field. UBI does not use it ATM, just provides to upper layers in 'struct ubi_device_info'. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/build.c14
-rw-r--r--drivers/mtd/ubi/kapi.c1
-rw-r--r--drivers/mtd/ubi/ubi.h3
3 files changed, 18 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 5ebe280225d6..f38e8de81811 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -690,11 +690,25 @@ static int io_init(struct ubi_device *ubi)
690 ubi_assert(ubi->hdrs_min_io_size <= ubi->min_io_size); 690 ubi_assert(ubi->hdrs_min_io_size <= ubi->min_io_size);
691 ubi_assert(ubi->min_io_size % ubi->hdrs_min_io_size == 0); 691 ubi_assert(ubi->min_io_size % ubi->hdrs_min_io_size == 0);
692 692
693 ubi->max_write_size = ubi->mtd->writebufsize;
694 /*
695 * Maximum write size has to be greater or equivalent to min. I/O
696 * size, and be multiple of min. I/O size.
697 */
698 if (ubi->max_write_size < ubi->min_io_size ||
699 ubi->max_write_size % ubi->min_io_size ||
700 !is_power_of_2(ubi->max_write_size)) {
701 ubi_err("bad write buffer size %d for %d min. I/O unit",
702 ubi->max_write_size, ubi->min_io_size);
703 return -EINVAL;
704 }
705
693 /* Calculate default aligned sizes of EC and VID headers */ 706 /* Calculate default aligned sizes of EC and VID headers */
694 ubi->ec_hdr_alsize = ALIGN(UBI_EC_HDR_SIZE, ubi->hdrs_min_io_size); 707 ubi->ec_hdr_alsize = ALIGN(UBI_EC_HDR_SIZE, ubi->hdrs_min_io_size);
695 ubi->vid_hdr_alsize = ALIGN(UBI_VID_HDR_SIZE, ubi->hdrs_min_io_size); 708 ubi->vid_hdr_alsize = ALIGN(UBI_VID_HDR_SIZE, ubi->hdrs_min_io_size);
696 709
697 dbg_msg("min_io_size %d", ubi->min_io_size); 710 dbg_msg("min_io_size %d", ubi->min_io_size);
711 dbg_msg("max_write_size %d", ubi->max_write_size);
698 dbg_msg("hdrs_min_io_size %d", ubi->hdrs_min_io_size); 712 dbg_msg("hdrs_min_io_size %d", ubi->hdrs_min_io_size);
699 dbg_msg("ec_hdr_alsize %d", ubi->ec_hdr_alsize); 713 dbg_msg("ec_hdr_alsize %d", ubi->ec_hdr_alsize);
700 dbg_msg("vid_hdr_alsize %d", ubi->vid_hdr_alsize); 714 dbg_msg("vid_hdr_alsize %d", ubi->vid_hdr_alsize);
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 69fa4ef03c53..701df4f848f6 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -41,6 +41,7 @@ void ubi_do_get_device_info(struct ubi_device *ubi, struct ubi_device_info *di)
41 di->ubi_num = ubi->ubi_num; 41 di->ubi_num = ubi->ubi_num;
42 di->leb_size = ubi->leb_size; 42 di->leb_size = ubi->leb_size;
43 di->min_io_size = ubi->min_io_size; 43 di->min_io_size = ubi->min_io_size;
44 di->max_write_size = ubi->max_write_size;
44 di->ro_mode = ubi->ro_mode; 45 di->ro_mode = ubi->ro_mode;
45 di->cdev = ubi->cdev.dev; 46 di->cdev = ubi->cdev.dev;
46} 47}
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 0b0149c41fe3..b78994330ebc 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -381,6 +381,8 @@ struct ubi_wl_entry;
381 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or 381 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or
382 * not 382 * not
383 * @nor_flash: non-zero if working on top of NOR flash 383 * @nor_flash: non-zero if working on top of NOR flash
384 * @max_write_size: maximum amount of bytes the underlying flash can write at a
385 * time (MTD write buffer size)
384 * @mtd: MTD device descriptor 386 * @mtd: MTD device descriptor
385 * 387 *
386 * @peb_buf1: a buffer of PEB size used for different purposes 388 * @peb_buf1: a buffer of PEB size used for different purposes
@@ -464,6 +466,7 @@ struct ubi_device {
464 int vid_hdr_shift; 466 int vid_hdr_shift;
465 unsigned int bad_allowed:1; 467 unsigned int bad_allowed:1;
466 unsigned int nor_flash:1; 468 unsigned int nor_flash:1;
469 int max_write_size;
467 struct mtd_info *mtd; 470 struct mtd_info *mtd;
468 471
469 void *peb_buf1; 472 void *peb_buf1;