public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] mtdpart: Allow adding a partition of a partition
@ 2015-02-10 22:58 Dan Ehrenberg
  2015-02-10 22:58 ` [PATCH v2 2/3] mtdpart: Remove partition overlap checks Dan Ehrenberg
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Dan Ehrenberg @ 2015-02-10 22:58 UTC (permalink / raw)
  To: linux-mtd, richard.weinberger, ezequiel.garcia
  Cc: namnguyen, grundler, gwendal, Dan Ehrenberg

MTD allows dynamic partitioning by the BLKPG ioctl.
The current code restricts partition dynamic addition to work only on
the master MTD device. This doesn't make a lot of sense, and is
impossible to meet if the device is already partitioned (since the
master MTD device is not visible). This commit removes the restriction.

Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
---
 drivers/mtd/mtdchar.c | 4 ----
 drivers/mtd/mtdpart.c | 6 ++++++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 5356395..30215c7 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -545,10 +545,6 @@ static int mtdchar_blkpg_ioctl(struct mtd_info *mtd,
 	switch (a.op) {
 	case BLKPG_ADD_PARTITION:
 
-		/* Only master mtd device must be used to add partitions */
-		if (mtd_is_partition(mtd))
-			return -EINVAL;
-
 		/* Sanitize user input */
 		p.devname[BLKPG_DEVNAMELTH - 1] = '\0';
 
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index a3e3a7d..7c6f526 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -566,6 +566,12 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
 	if (length <= 0)
 		return -EINVAL;
 
+	if (mtd_is_partition(master)) {
+		struct mtd_part *master_partition = PART(master);
+		offset += master_partition->offset;
+		master = master_partition->master;
+	}
+
 	part.name = name;
 	part.size = length;
 	part.offset = offset;
-- 
2.2.0.rc0.207.ga3a616c

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-03-05  5:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-10 22:58 [PATCH v2 1/3] mtdpart: Allow adding a partition of a partition Dan Ehrenberg
2015-02-10 22:58 ` [PATCH v2 2/3] mtdpart: Remove partition overlap checks Dan Ehrenberg
2015-02-10 22:58 ` [PATCH v2 3/3] mtdpart: Allow deleting a partition with another partition as master Dan Ehrenberg
2015-03-03  3:51 ` [PATCH v2 1/3] mtdpart: Allow adding a partition of a partition Daniel Ehrenberg
2015-03-04 19:23 ` Brian Norris
2015-03-05  1:50   ` Daniel Ehrenberg
2015-03-05  5:33     ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox