[1/5] ubi: introduce ubi->bad_peb_limit

Submitted by Artem Bityutskiy on July 18, 2012, 7:09 a.m.

Details

Message ID 1342595359.31927.11.camel@brekeke
State New, archived
Headers show

Commit Message

Artem Bityutskiy July 18, 2012, 7:09 a.m.
On Wed, 2012-07-04 at 11:06 +0300, Shmulik Ladkani wrote:
> Introduce 'ubi->bad_peb_limit', which specifies an upper limit of PEBs
> ubi expects to go bad.
> Currently, it is initialized to a fixed percentage of total PEBs in the
> ubi device (configurable via CONFIG_MTD_UBI_BEB_LIMIT).
> 
> The 'bad_peb_limit' is intended to be used for calculating the amount of
> PEBs ubi needs to reserve for bad eraseblock handling.
> 
> Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>

Created branch "beb" and pushed this patch there with minor amendments
(see diff below). Let's use this branch in UBI tree for this work and
merge it as soon as it is ready.

Patch hide | download patch | download mbox

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index c33e25b..dee90b7 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -668,13 +668,12 @@  static int io_init(struct ubi_device *ubi)
                ubi->bad_allowed = 1;
                if (CONFIG_MTD_UBI_BEB_LIMIT > 0) {
                        int percent = CONFIG_MTD_UBI_BEB_LIMIT;
-                       int beb_limit;
+                       int limit = mult_frac(ubi->peb_count, percent, 100);
 
-                       beb_limit = mult_frac(ubi->peb_count, percent, 100);
-                       /* round it up */
-                       if (mult_frac(beb_limit, 100, percent) < ubi->peb_count)
-                               beb_limit++;
-                       ubi->bad_peb_limit = beb_limit;
+                       /* Round it up */
+                       if (mult_frac(limit, 100, percent) < ubi->peb_count)
+                               limit += 1;
+                       ubi->bad_peb_limit = limit;
                }
        }