[v5,4/4] mtd: add option to enable scanning for partitions
Commit Message
Add Kconfig boolean CONFIG_MTD_BLOCK_PARTITIONS and enable block
partition parsers on non-NAND mtdblock as well as ubiblock devices
in case it is selected.
Never scan partitions on NAND-backed mtdblock devices, ubiblock
should be used instead.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/Kconfig | 11 +++++++++++
drivers/mtd/mtd_blkdevs.c | 4 +++-
drivers/mtd/ubi/block.c | 5 ++++-
3 files changed, 18 insertions(+), 2 deletions(-)
@@ -69,6 +69,17 @@ config MTD_BLOCK_RO
You do not need this option for use with the DiskOnChip devices. For
those, enable NFTL support (CONFIG_NFTL) instead.
+config MTD_BLOCK_PARTITIONS
+ bool "Scan for partitions on MTD block devices"
+ depends on MTD_BLOCK || MTD_BLOCK_RO
+ default y if FIT_PARTITION
+ help
+ Scan MTD block devices for partitions (ie. MBR, GPT, uImage.FIT, ...).
+ (NAND devices are omitted, ubiblock should be used instead when)
+
+ Unless your MTD partitions contain sub-partitions mapped using a
+ partition table, say no.
+
comment "Note that in some cases UBI block is preferred. See MTD_UBI_BLOCK."
depends on MTD_BLOCK || MTD_BLOCK_RO
@@ -359,7 +359,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
} else {
snprintf(gd->disk_name, sizeof(gd->disk_name),
"%s%d", tr->name, new->devnum);
- gd->flags |= GENHD_FL_NO_PART;
+
+ if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd))
+ gd->flags |= GENHD_FL_NO_PART;
}
set_capacity(gd, ((u64)new->size * tr->blksize) >> 9);
@@ -430,7 +430,10 @@ int ubiblock_create(struct ubi_volume_info *vi)
ret = -ENODEV;
goto out_cleanup_disk;
}
- gd->flags |= GENHD_FL_NO_PART;
+
+ if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS))
+ gd->flags |= GENHD_FL_NO_PART;
+
gd->private_data = dev;
sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
set_capacity(gd, disk_capacity);