diff options
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/Kconfig | 26 | ||||
-rw-r--r-- | drivers/mtd/ubi/build.c | 12 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 2 |
3 files changed, 32 insertions, 8 deletions
diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index ea4b95b5451c..76195ac90e51 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig | |||
@@ -34,13 +34,25 @@ config MTD_UBI_BEB_RESERVE | |||
34 | help | 34 | help |
35 | If the MTD device admits of bad eraseblocks (e.g. NAND flash), UBI | 35 | If the MTD device admits of bad eraseblocks (e.g. NAND flash), UBI |
36 | reserves some amount of physical eraseblocks to handle new bad | 36 | reserves some amount of physical eraseblocks to handle new bad |
37 | eraseblocks. For example, if a flash physical eraseblock becomes bad, | 37 | eraseblocks. When a physical eraseblock becomes bad, UBI uses these |
38 | UBI uses these reserved physical eraseblocks to relocate the bad one. | 38 | reserved physical eraseblocks to relocate the bad one. This |
39 | This option specifies how many physical eraseblocks will be reserved | 39 | configuration option specifies how many physical eraseblocks will be |
40 | for bad eraseblock handling (percents of total number of good flash | 40 | reserved for bad eraseblock handling (percents of total number of |
41 | eraseblocks). If the underlying flash does not admit of bad | 41 | good physical eraseblocks on this MTD partition). If the underlying |
42 | eraseblocks (e.g. NOR flash), this value is ignored and nothing is | 42 | flash does not admit of bad eraseblocks (e.g. NOR flash), this value |
43 | reserved. Leave the default value if unsure. | 43 | is ignored and nothing is reserved. Leave the default value if |
44 | unsure. | ||
45 | |||
46 | config MTD_UBI_BEB_LIMIT | ||
47 | int "Percentage of maximum expected bad eraseblocks" | ||
48 | default 2 | ||
49 | range 0 25 | ||
50 | help | ||
51 | This option specifies the maximum bad physical eraseblocks UBI | ||
52 | expects on the UBI device (percents of total number of physical | ||
53 | eraseblocks on this MTD partition). If the underlying flash does not | ||
54 | admit of bad eraseblocks (e.g. NOR flash), this value is ignored. | ||
55 | Leave the default value if unsure. | ||
44 | 56 | ||
45 | config MTD_UBI_GLUEBI | 57 | config MTD_UBI_GLUEBI |
46 | tristate "MTD devices emulation driver (gluebi)" | 58 | tristate "MTD devices emulation driver (gluebi)" |
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); |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 84f66e3fa05d..aeb459eb7e42 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -363,6 +363,7 @@ struct ubi_wl_entry; | |||
363 | * @flash_size: underlying MTD device size (in bytes) | 363 | * @flash_size: underlying MTD device size (in bytes) |
364 | * @peb_count: count of physical eraseblocks on the MTD device | 364 | * @peb_count: count of physical eraseblocks on the MTD device |
365 | * @peb_size: physical eraseblock size | 365 | * @peb_size: physical eraseblock size |
366 | * @bad_peb_limit: top limit of expected bad physical eraseblocks | ||
366 | * @bad_peb_count: count of bad physical eraseblocks | 367 | * @bad_peb_count: count of bad physical eraseblocks |
367 | * @good_peb_count: count of good physical eraseblocks | 368 | * @good_peb_count: count of good physical eraseblocks |
368 | * @corr_peb_count: count of corrupted physical eraseblocks (preserved and not | 369 | * @corr_peb_count: count of corrupted physical eraseblocks (preserved and not |
@@ -410,6 +411,7 @@ struct ubi_device { | |||
410 | int avail_pebs; | 411 | int avail_pebs; |
411 | int beb_rsvd_pebs; | 412 | int beb_rsvd_pebs; |
412 | int beb_rsvd_level; | 413 | int beb_rsvd_level; |
414 | int bad_peb_limit; | ||
413 | 415 | ||
414 | int autoresize_vol_id; | 416 | int autoresize_vol_id; |
415 | int vtbl_slots; | 417 | int vtbl_slots; |