mtd: introduce function max_bad_blocks

If implemented, 'max_bad_blocks' returns the maximum number of bad
blocks to reserve for a MTD. An implementation for NAND is coming soon.

Signed-off-by: Jeff Westfahl <[email protected]>
Signed-off-by: Zach Brown <[email protected]>
Acked-by: Boris Brezillon <[email protected]>
Acked-by: Brian Norris <[email protected]>
Signed-off-by: Brian Norris <[email protected]>
This commit is contained in:
Jeff Westfahl 2017-01-10 13:30:17 -06:00 • committed by Brian Norris
commit 6080ef6e7c
2 changed files with 23 additions and 0 deletions

View file

@ -349,6 +349,14 @@ static const struct mtd_ooblayout_ops part_ooblayout_ops = {
.free = part_ooblayout_free,
};
static int part_max_bad_blocks(struct mtd_info *mtd, loff_t ofs, size_t len)
{
struct mtd_part *part = mtd_to_part(mtd);
return part->master->_max_bad_blocks(part->master,
ofs + part->offset, len);
}
static inline void free_partition(struct mtd_part *p)
{
kfree(p->mtd.name);
@ -475,6 +483,8 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
slave->mtd._block_isbad = part_block_isbad;
if (master->_block_markbad)
slave->mtd._block_markbad = part_block_markbad;
if (master->_max_bad_blocks)
slave->mtd._max_bad_blocks = part_max_bad_blocks;
if (master->_get_device)
slave->mtd._get_device = part_get_device;