From: Daniel Golle <daniel@makrotopia.org> To: Jens Axboe <axboe@kernel.dk>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Matthew Wilcox <willy@infradead.org>, Daniel Golle <daniel@makrotopia.org>, "Martin K. Petersen" <martin.petersen@oracle.com>, Chaitanya Kulkarni <kch@nvidia.com>, Michal Orzel <michalorzel.eng@gmail.com>, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v5 4/4] mtd: add option to enable scanning for partitions Date: Tue, 15 Nov 2022 21:47:25 +0000 [thread overview] Message-ID: <88d7c15691af5d956275b5326303d5aeb3ea1d2f.1668548123.git.daniel@makrotopia.org> (raw) In-Reply-To: <cover.1668548123.git.daniel@makrotopia.org> 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(-) diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index 796a2eccbef0..12874dec1569 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig @@ -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 diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 60b222799871..e6f2e0888246 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -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); diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 75eaecc8639f..e617635ff6e6 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -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); -- 2.38.1
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Golle <daniel@makrotopia.org> To: Jens Axboe <axboe@kernel.dk>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Matthew Wilcox <willy@infradead.org>, Daniel Golle <daniel@makrotopia.org>, "Martin K. Petersen" <martin.petersen@oracle.com>, Chaitanya Kulkarni <kch@nvidia.com>, Michal Orzel <michalorzel.eng@gmail.com>, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v5 4/4] mtd: add option to enable scanning for partitions Date: Tue, 15 Nov 2022 21:47:25 +0000 [thread overview] Message-ID: <88d7c15691af5d956275b5326303d5aeb3ea1d2f.1668548123.git.daniel@makrotopia.org> (raw) In-Reply-To: <cover.1668548123.git.daniel@makrotopia.org> 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(-) diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index 796a2eccbef0..12874dec1569 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig @@ -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 diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 60b222799871..e6f2e0888246 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -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); diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 75eaecc8639f..e617635ff6e6 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -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); -- 2.38.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2022-11-15 21:49 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-15 21:45 [PATCH v5 0/4] partition parser for U-Boot's uImage.FIT Daniel Golle 2022-11-15 21:45 ` Daniel Golle 2022-11-15 21:45 ` [PATCH v5 1/4] block: add new flag to add partitions read-only Daniel Golle 2022-11-15 21:45 ` Daniel Golle 2022-11-15 21:46 ` [PATCH v5 2/4] block: add partition parser for U-Boot uImage.FIT Daniel Golle 2022-11-15 21:46 ` Daniel Golle 2022-11-15 21:47 ` [PATCH v5 3/4] partitions/efi: add support for uImage.FIT sub-partitions Daniel Golle 2022-11-15 21:47 ` Daniel Golle 2022-11-16 6:01 ` Christoph Hellwig 2022-11-16 6:01 ` Christoph Hellwig 2022-11-17 0:19 ` Daniel Golle 2022-11-17 0:19 ` Daniel Golle 2022-11-17 6:00 ` Christoph Hellwig 2022-11-17 6:00 ` Christoph Hellwig 2022-11-17 6:50 ` Richard Weinberger 2022-11-17 6:50 ` Richard Weinberger 2022-11-17 6:59 ` Christoph Hellwig 2022-11-17 6:59 ` Christoph Hellwig 2022-11-17 13:59 ` Daniel Golle 2022-11-17 13:59 ` Daniel Golle 2022-11-15 21:47 ` Daniel Golle [this message] 2022-11-15 21:47 ` [PATCH v5 4/4] mtd: add option to enable scanning for partitions Daniel Golle
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=88d7c15691af5d956275b5326303d5aeb3ea1d2f.1668548123.git.daniel@makrotopia.org \ --to=daniel@makrotopia.org \ --cc=axboe@kernel.dk \ --cc=kch@nvidia.com \ --cc=linux-block@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mtd@lists.infradead.org \ --cc=martin.petersen@oracle.com \ --cc=michalorzel.eng@gmail.com \ --cc=miquel.raynal@bootlin.com \ --cc=richard@nod.at \ --cc=vigneshr@ti.com \ --cc=willy@infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.