aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/build.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/build.c')
-rw-r--r--drivers/mtd/ubi/build.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 3174dd40095d..ce311aa75a75 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -607,8 +607,18 @@ static int io_init(struct ubi_device *ubi)
607 ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd); 607 ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd);
608 ubi->flash_size = ubi->mtd->size; 608 ubi->flash_size = ubi->mtd->size;
609 609
610 if (mtd_can_have_bb(ubi->mtd)) 610 if (mtd_can_have_bb(ubi->mtd)) {
611 ubi->bad_allowed = 1; 611 ubi->bad_allowed = 1;
612 if (CONFIG_MTD_UBI_BEB_LIMIT > 0) {
613 int percent = CONFIG_MTD_UBI_BEB_LIMIT;
614 int limit = mult_frac(ubi->peb_count, percent, 100);
615
616 /* Round it up */
617 if (mult_frac(limit, 100, percent) < ubi->peb_count)
618 limit += 1;
619 ubi->bad_peb_limit = limit;
620 }
621 }
612 622
613 if (ubi->mtd->type == MTD_NORFLASH) { 623 if (ubi->mtd->type == MTD_NORFLASH) {
614 ubi_assert(ubi->mtd->writesize == 1); 624 ubi_assert(ubi->mtd->writesize == 1);