diff options
author | Jeff Westfahl <jeff.westfahl@ni.com> | 2017-01-10 13:30:17 -0600 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2017-02-08 13:53:52 -0800 |
commit | 6080ef6e7c0a0592cbcca11200d879faf65e27d4 (patch) | |
tree | 509d57287040d86a9fe5459bd501ec0cbe6da66f /include/linux/mtd/mtd.h | |
parent | 7da0fffb3a4cb76a4869bf12acb750a4f9e2f2c1 (diff) | |
download | talos-obmc-linux-6080ef6e7c0a0592cbcca11200d879faf65e27d4.tar.gz talos-obmc-linux-6080ef6e7c0a0592cbcca11200d879faf65e27d4.zip |
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 <jeff.westfahl@ni.com>
Signed-off-by: Zach Brown <zach.brown@ni.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electron.com>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'include/linux/mtd/mtd.h')
-rw-r--r-- | include/linux/mtd/mtd.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 13f8052b9ff9..5bb42c6dacdc 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -322,6 +322,7 @@ struct mtd_info { int (*_block_isreserved) (struct mtd_info *mtd, loff_t ofs); int (*_block_isbad) (struct mtd_info *mtd, loff_t ofs); int (*_block_markbad) (struct mtd_info *mtd, loff_t ofs); + int (*_max_bad_blocks) (struct mtd_info *mtd, loff_t ofs, size_t len); int (*_suspend) (struct mtd_info *mtd); void (*_resume) (struct mtd_info *mtd); void (*_reboot) (struct mtd_info *mtd); @@ -397,6 +398,18 @@ static inline int mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops) return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; } +static inline int mtd_max_bad_blocks(struct mtd_info *mtd, + loff_t ofs, size_t len) +{ + if (!mtd->_max_bad_blocks) + return -ENOTSUPP; + + if (mtd->size < (len + ofs) || ofs < 0) + return -EINVAL; + + return mtd->_max_bad_blocks(mtd, ofs, len); +} + int mtd_wunit_to_pairing_info(struct mtd_info *mtd, int wunit, struct mtd_pairing_info *info); int mtd_pairing_info_to_wunit(struct mtd_info *mtd, |