mtd: Introduce mtd_block_isreserved()
[firefly-linux-kernel-4.4.55.git] / drivers / mtd / nand / nand_bbt.c
index 7f0c3b4c2a4fdc045f42ca8b5bc54f97815b3484..443fa82cde6a0ecf73f72caae8b808b600799500 100644 (file)
@@ -1310,6 +1310,20 @@ int nand_default_bbt(struct mtd_info *mtd)
        return nand_scan_bbt(mtd, this->badblock_pattern);
 }
 
+/**
+ * nand_isreserved_bbt - [NAND Interface] Check if a block is reserved
+ * @mtd: MTD device structure
+ * @offs: offset in the device
+ */
+int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs)
+{
+       struct nand_chip *this = mtd->priv;
+       int block;
+
+       block = (int)(offs >> this->bbt_erase_shift);
+       return bbt_get_entry(this, block) == BBT_BLOCK_RESERVED;
+}
+
 /**
  * nand_isbad_bbt - [NAND Interface] Check if a block is bad
  * @mtd: MTD device structure