@@ -174,6 +174,16 @@ static ssize_t mtd_name_show(struct device *dev,
}
static DEVICE_ATTR(name, S_IRUGO, mtd_name_show, NULL);
+static ssize_t mtd_bb_allowed_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct mtd_info *mtd = dev_to_mtd(dev);
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", !!mtd->block_markbad);
+
+}
+static DEVICE_ATTR(bb_allowed, S_IRUGO, mtd_bb_allowed_show, NULL);
+
static struct attribute *mtd_attrs[] = {
&dev_attr_type.attr,
&dev_attr_flags.attr,
@@ -184,6 +194,7 @@ static struct attribute *mtd_attrs[] = {
&dev_attr_oobsize.attr,
&dev_attr_numeraseregions.attr,
&dev_attr_name.attr,
+ &dev_attr_bb_allowed.attr,
NULL,
};
Add a per-mtd device 'bb_allowed' sysfs file which contains 0 if bad blocks are not allowed, and 1 if they are allowed. This is useful for userspace. Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> --- drivers/mtd/mtdcore.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)