]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mtd: ubi: Use 'max_bad_blocks' to compute bad_peb_limit if available
authorJeff Westfahl <jeff.westfahl@ni.com>
Tue, 10 Jan 2017 19:30:18 +0000 (13:30 -0600)
committerRichard Weinberger <richard@nod.at>
Wed, 17 Jan 2018 18:28:54 +0000 (19:28 +0100)
If the user has not set max_beb_per1024 using either the cmdline or
Kconfig options for doing so, use the MTD function 'max_bad_blocks' to
compute the UBI bad_peb_limit.

Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
Signed-off-by: Zach Brown <zach.brown@ni.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electron.com>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/build.c

index 136ce05d23283217563d6a9287cd8651c590050e..e941395de3aedc0d4fc6d641e214ec9848c72e27 100644 (file)
@@ -535,8 +535,17 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)
        int limit, device_pebs;
        uint64_t device_size;
 
-       if (!max_beb_per1024)
-               return 0;
+       if (!max_beb_per1024) {
+               /*
+                * Since max_beb_per1024 has not been set by the user in either
+                * the cmdline or Kconfig, use mtd_max_bad_blocks to set the
+                * limit if it is supported by the device.
+                */
+               limit = mtd_max_bad_blocks(ubi->mtd, 0, ubi->mtd->size);
+               if (limit < 0)
+                       return 0;
+               return limit;
+       }
 
        /*
         * Here we are using size of the entire flash chip and