lkml.org 
[lkml]   [2016]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RESEND PATCH v2 3/3] mtd: ubi: use 'max_bad_blocks' to compute bad_peb_limit if available
Date
From: Jeff Westfahl <jeff.westfahl@ni.com>

Use the MTD function 'max_bad_blocks' to compute the UBI bad_peb_limit,
if the function is implemented for an MTD and doesn't return an error.

Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
Signed-off-by: Zach Brown <zach.brown@ni.com>
---
drivers/mtd/ubi/build.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 85d54f3..0648863 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -584,6 +584,15 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)
int limit, device_pebs;
uint64_t device_size;

+ /* If the MTD provides a max_bad_blocks function, use that value. Fall
+ * back to max_beb_per1024 if that function returns an error.
+ */
+ if (ubi->mtd->_max_bad_blocks) {
+ limit = ubi->mtd->_max_bad_blocks(ubi->mtd, 0, ubi->mtd->size);
+ if (limit > 0)
+ return limit;
+ }
+
if (!max_beb_per1024)
return 0;

--
2.7.4
\
 
 \ /
  Last update: 2016-10-27 21:15    [W:0.369 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site