diff options
Diffstat (limited to 'drivers/mtd/ubi/misc.c')
-rw-r--r-- | drivers/mtd/ubi/misc.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/mtd/ubi/misc.c b/drivers/mtd/ubi/misc.c index 8bbfb444b895..f913d701a5b3 100644 --- a/drivers/mtd/ubi/misc.c +++ b/drivers/mtd/ubi/misc.c | |||
@@ -121,10 +121,16 @@ 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 (%d), not reserving any PEBs for bad PEB handling, will use available PEBs (if any)", | ||
132 | ubi->bad_peb_count, ubi->bad_peb_limit); | ||
133 | } | ||
128 | } | 134 | } |
129 | 135 | ||
130 | /** | 136 | /** |