diff options
-rw-r--r-- | drivers/mtd/mtdpart.c | 13 | ||||
-rw-r--r-- | include/linux/mtd/partitions.h | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 3477e16be1c8..b73720502433 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -479,6 +479,19 @@ static struct mtd_part *allocate_partition(struct mtd_info *master, | |||
479 | (unsigned long long)cur_offset, (unsigned long long)slave->offset); | 479 | (unsigned long long)cur_offset, (unsigned long long)slave->offset); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | if (slave->offset == MTDPART_OFS_RETAIN) { | ||
483 | slave->offset = cur_offset; | ||
484 | if (master->size - slave->offset >= slave->mtd.size) { | ||
485 | slave->mtd.size = master->size - slave->offset | ||
486 | - slave->mtd.size; | ||
487 | } else { | ||
488 | printk(KERN_ERR "mtd partition \"%s\" doesn't have enough space: %#llx < %#llx, disabled\n", | ||
489 | part->name, master->size - slave->offset, | ||
490 | slave->mtd.size); | ||
491 | /* register to preserve ordering */ | ||
492 | goto out_register; | ||
493 | } | ||
494 | } | ||
482 | if (slave->mtd.size == MTDPART_SIZ_FULL) | 495 | if (slave->mtd.size == MTDPART_SIZ_FULL) |
483 | slave->mtd.size = master->size - slave->offset; | 496 | slave->mtd.size = master->size - slave->offset; |
484 | 497 | ||
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index 08c9c7b8b8e2..1431cf2609ed 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h | |||
@@ -24,7 +24,9 @@ | |||
24 | * will extend to the end of the master MTD device. | 24 | * will extend to the end of the master MTD device. |
25 | * offset: absolute starting position within the master MTD device; if | 25 | * offset: absolute starting position within the master MTD device; if |
26 | * defined as MTDPART_OFS_APPEND, the partition will start where the | 26 | * defined as MTDPART_OFS_APPEND, the partition will start where the |
27 | * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block. | 27 | * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block; |
28 | * if MTDPART_OFS_RETAIN, consume as much as possible, leaving size | ||
29 | * after the end of partition. | ||
28 | * mask_flags: contains flags that have to be masked (removed) from the | 30 | * mask_flags: contains flags that have to be masked (removed) from the |
29 | * master MTD flag set for the corresponding MTD partition. | 31 | * master MTD flag set for the corresponding MTD partition. |
30 | * For example, to force a read-only partition, simply adding | 32 | * For example, to force a read-only partition, simply adding |
@@ -42,6 +44,7 @@ struct mtd_partition { | |||
42 | struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */ | 44 | struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */ |
43 | }; | 45 | }; |
44 | 46 | ||
47 | #define MTDPART_OFS_RETAIN (-3) | ||
45 | #define MTDPART_OFS_NXTBLK (-2) | 48 | #define MTDPART_OFS_NXTBLK (-2) |
46 | #define MTDPART_OFS_APPEND (-1) | 49 | #define MTDPART_OFS_APPEND (-1) |
47 | #define MTDPART_SIZ_FULL (0) | 50 | #define MTDPART_SIZ_FULL (0) |