@@ -600,6 +600,15 @@ int mtd_del_partition(struct mtd_info *master, int partno)
struct mtd_part *slave, *next;
int ret = -EINVAL;
+ /* If del_partition was called as a partition, just treat
+ * this as if it were called on its master. This is a harmless
+ * generalization and lets partitions be deleted in a system
+ * where they are sometimes already present on boot */
+ if (mtd_is_partition(master)) {
+ struct mtd_part *master_partition = PART(master);
+ master = master_partition->master;
+ }
+
mutex_lock(&mtd_partitions_mutex);
list_for_each_entry_safe(slave, next, &mtd_partitions, list)
if ((slave->master == master) &&
This patch makes MTD dynamic partitioning more flexible by allowing partitions to be deleted by referencing any partition with the same master. For example, if you have /dev/mtd0 and /dev/mtd1 both partitions on the same underlying device, then you can call BLKPG_DEL_PARTITION with an fd of /dev/mtd0 and pno of 1, and /dev/mtd1 will be deleted (as opposed to returning EINVAL to signal a missing partition, which it did previously). Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> --- drivers/mtd/mtdpart.c | 9 +++++++++ 1 file changed, 9 insertions(+)