[U-Boot] [PATCH v3 4/4] mtdparts: new add.e: add part skipping bad blocks
Ben Gardiner
bengardiner at nanometrics.ca
Mon Jul 5 23:43:32 CEST 2010
This patch adds a new 'mtdparts add' variant: add.e (with a synomym add.i). This
command variant adds a new partition to the mtdparts variable but also increases
the partitions size by skipping bad blocks and aggregating any additional bad
blocks found at the end of the partition.
Signed-off-by: Ben Gardiner <bengardiner at nanometrics.ca>
---
V2:
* formatting: spaces after 'if' and 'for'
* trailing whitespace removed
V3:
* rebased to 54841ab50c20d6fa6c9cc3eb826989da3a22d934 of
git://git.denx.de/u-boot.git
* fix more checkpatch errors
* updating copyright to include addition of add.e command
---
common/cmd_mtdparts.c | 38 +++++++++++++++++++++++++++++++++++++-
1 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index c1adbd4..d57f9ad 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -26,6 +26,8 @@
* Added net partition size output to mtdparts list command.
* Ported 'dynamic partitions' support to current u-boot 'mtdparts spread'
* command. Current mtdparts variable is now used as input.
+ * Add the 'add.e' mtdparts command. Dynamic partitions can be added one at
+ * a time -- specified by size only.
*
* $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $
* Copyright 2002 SYSGO Real-Time Solutions GmbH
@@ -1951,9 +1953,14 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
/* mtdparts add <mtd-dev> <size>[@<offset>] <name> [ro] */
- if (((argc == 5) || (argc == 6)) && (strcmp(argv[1], "add") == 0)) {
+ if (((argc == 5) || (argc == 6)) && (strncmp(argv[1], "add", 3) == 0)) {
#define PART_ADD_DESC_MAXLEN 64
char tmpbuf[PART_ADD_DESC_MAXLEN];
+#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
+ char *s;
+ struct mtd_info *mtd;
+ u32 next_offset;
+#endif
u8 type, num, len;
struct mtd_device *dev;
struct mtd_device *dev_tmp;
@@ -1988,11 +1995,36 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
debug("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
dev->id->num, dev->id->mtd_id);
+#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
+ s = strchr(argv[1], '.');
+
+ if (get_mtd_info(dev->id->type, dev->id->num, &mtd))
+ return 1;
+#endif
+
if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) {
+#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
+ if (!strcmp(s, ".e") || !strcmp(s, ".i")) {
+ p = list_entry(dev->parts.next,
+ struct part_info, link);
+ spread_partition(mtd, p, &next_offset);
+
+ debug("increased %s to %d bytes\n", p->name,
+ p->size);
+ }
+#endif
device_add(dev);
} else {
/* merge new partition with existing ones*/
p = list_entry(dev->parts.next, struct part_info, link);
+#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
+ if (!strcmp(s, ".e") || !strcmp(s, ".i")) {
+ spread_partition(mtd, p, &next_offset);
+
+ debug("increased %s to %d bytes\n", p->name,
+ p->size);
+ }
+#endif
if (part_add(dev_tmp, p) != 0) {
device_del(dev);
return 1;
@@ -2042,6 +2074,10 @@ U_BOOT_CMD(
" - delete partition (e.g. part-id = nand0,1)\n"
"mtdparts add <mtd-dev> <size>[@<offset>] [<name>] [ro]\n"
" - add partition\n"
+#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
+ "mtdparts add.e <mtd-dev> <size>[@<offset>] [<name>] [ro]\n"
+ " - add partition, padding size by skipping bad blocks\n"
+#endif
"mtdparts default\n"
" - reset partition table to defaults\n"
#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
--
1.7.0.4
More information about the U-Boot
mailing list