diff options
Diffstat (limited to 'drivers/mtd/ubi/misc.c')
-rw-r--r-- | drivers/mtd/ubi/misc.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/mtd/ubi/misc.c b/drivers/mtd/ubi/misc.c index 8bbfb444b895..d089df055484 100644 --- a/drivers/mtd/ubi/misc.c +++ b/drivers/mtd/ubi/misc.c | |||
@@ -121,10 +121,18 @@ void ubi_update_reserved(struct ubi_device *ubi) | |||
121 | */ | 121 | */ |
122 | void ubi_calculate_reserved(struct ubi_device *ubi) | 122 | void ubi_calculate_reserved(struct ubi_device *ubi) |
123 | { | 123 | { |
124 | ubi->beb_rsvd_level = ubi->good_peb_count/100; | 124 | /* |
125 | ubi->beb_rsvd_level *= CONFIG_MTD_UBI_BEB_RESERVE; | 125 | * Calculate the actual number of PEBs currently needed to be reserved |
126 | if (ubi->beb_rsvd_level < MIN_RESEVED_PEBS) | 126 | * for future bad eraseblock handling. |
127 | ubi->beb_rsvd_level = MIN_RESEVED_PEBS; | 127 | */ |
128 | ubi->beb_rsvd_level = ubi->bad_peb_limit - ubi->bad_peb_count; | ||
129 | if (ubi->beb_rsvd_level < 0) { | ||
130 | ubi->beb_rsvd_level = 0; | ||
131 | ubi_warn("number of bad PEBs (%d) is above the expected limit " | ||
132 | "(%d), not reserving any PEBs for bad PEB handling, " | ||
133 | "will use available PEBs (if any)", | ||
134 | ubi->bad_peb_count, ubi->bad_peb_limit); | ||
135 | } | ||
128 | } | 136 | } |
129 | 137 | ||
130 | /** | 138 | /** |