mtd: introduce mtd_can_have_bb helper

This patch introduces new 'mtd_can_have_bb()' helper function which checks
whether the flash can have bad eraseblocks. Then it changes all the
direct 'mtd->block_isbad' use cases with 'mtd_can_have_bb()'.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 0893707..7e35755 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -440,6 +440,8 @@
 
 static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
 {
+	if (!mtd->block_isbad)
+		return -EOPNOTSUPP;
 	return mtd->block_isbad(mtd, ofs);
 }
 
@@ -483,6 +485,11 @@
 	return mtd->read_oob && mtd->write_oob;
 }
 
+static inline int mtd_can_have_bb(const struct mtd_info *mtd)
+{
+	return !!mtd->block_isbad;
+}
+
 	/* Kernel-side ioctl definitions */
 
 struct mtd_partition;