X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fcmd_jffs2.c;h=b4698bee47888a3e352551e32a1b41164aa209ce;hb=98824ce3f95e6c4d08d439b779c0acb0048045a6;hp=b5fd41724f6a4eb3c831e37d69765ebb1e3d02c7;hpb=5d5269f87fc00a3fe1960cacd92e3d04864dff7d;p=u-boot diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index b5fd41724f..b4698bee47 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -93,19 +93,16 @@ #include #include #include - -#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) - #include -#if (CONFIG_COMMANDS & CFG_CMD_NAND) +#if defined(CONFIG_CMD_NAND) #ifdef CFG_NAND_LEGACY #include #else /* !CFG_NAND_LEGACY */ #include #include #endif /* !CFG_NAND_LEGACY */ -#endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */ +#endif /* enable/disable debugging messages */ #define DEBUG_JFFS #undef DEBUG_JFFS @@ -170,10 +167,19 @@ struct list_head devices; static struct mtd_device *current_dev = NULL; static u8 current_partnum = 0; +#if defined(CONFIG_CMD_CRAMFS) extern int cramfs_check (struct part_info *info); extern int cramfs_load (char *loadoffset, struct part_info *info, char *filename); extern int cramfs_ls (struct part_info *info, char *filename); extern int cramfs_info (struct part_info *info); +#else +/* defining empty macros for function names is ugly but avoids ifdef clutter + * all over the code */ +#define cramfs_check(x) (0) +#define cramfs_load(x,y,z) (-1) +#define cramfs_ls(x,y) (0) +#define cramfs_info(x) (0) +#endif static struct part_info* jffs2_part_info(struct mtd_device *dev, unsigned int part_num); @@ -235,13 +241,13 @@ static void memsize_format(char *buf, u32 size) #define SIZE_KB ((u32)1024) if ((size % SIZE_GB) == 0) - sprintf(buf, "%lug", size/SIZE_GB); + sprintf(buf, "%ug", size/SIZE_GB); else if ((size % SIZE_MB) == 0) - sprintf(buf, "%lum", size/SIZE_MB); + sprintf(buf, "%um", size/SIZE_MB); else if (size % SIZE_KB == 0) - sprintf(buf, "%luk", size/SIZE_KB); + sprintf(buf, "%uk", size/SIZE_KB); else - sprintf(buf, "%lu", size); + sprintf(buf, "%u", size); } /** @@ -321,7 +327,7 @@ static void current_save(void) */ static int part_validate_nor(struct mtdids *id, struct part_info *part) { -#if (CONFIG_COMMANDS & CFG_CMD_FLASH) +#if defined(CONFIG_CMD_FLASH) /* info for FLASH chips */ extern flash_info_t flash_info[]; flash_info_t *flash; @@ -370,7 +376,7 @@ static int part_validate_nor(struct mtdids *id, struct part_info *part) */ static int part_validate_nand(struct mtdids *id, struct part_info *part) { -#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND) +#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND) /* info for NAND chips */ nand_info_t *nand; @@ -410,7 +416,7 @@ static int part_validate(struct mtdids *id, struct part_info *part) part->size = id->size - part->offset; if (part->offset > id->size) { - printf("%s: offset %08lx beyond flash size %08lx\n", + printf("%s: offset %08x beyond flash size %08x\n", id->mtd_id, part->offset, id->size); return 1; } @@ -719,7 +725,7 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i static int device_validate(u8 type, u8 num, u32 *size) { if (type == MTD_DEV_TYPE_NOR) { -#if (CONFIG_COMMANDS & CFG_CMD_FLASH) +#if defined(CONFIG_CMD_FLASH) if (num < CFG_MAX_FLASH_BANKS) { extern flash_info_t flash_info[]; *size = flash_info[num].size; @@ -733,7 +739,7 @@ static int device_validate(u8 type, u8 num, u32 *size) printf("support for FLASH devices not present\n"); #endif } else if (type == MTD_DEV_TYPE_NAND) { -#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND) +#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND) if (num < CFG_MAX_NAND_DEVICE) { #ifndef CFG_NAND_LEGACY *size = nand_info[num].size; @@ -1282,7 +1288,7 @@ static void list_partitions(void) if (current_dev) { part = jffs2_part_info(current_dev, current_partnum); if (part) { - printf("\nactive partition: %s%d,%d - (%s) 0x%08lx @ 0x%08lx\n", + printf("\nactive partition: %s%d,%d - (%s) 0x%08x @ 0x%08x\n", MTD_DEV_TYPE(current_dev->id->type), current_dev->id->num, current_partnum, part->name, part->size, part->offset); @@ -1300,7 +1306,7 @@ static void list_partitions(void) * Given partition identifier in form of , find * corresponding device and verify partition number. * - * @param id string describing device and partition + * @param id string describing device and partition or partition name * @param dev pointer to the requested device (output) * @param part_num verified partition number (output) * @param part pointer to requested partition (output) @@ -1309,11 +1315,23 @@ static void list_partitions(void) int find_dev_and_part(const char *id, struct mtd_device **dev, u8 *part_num, struct part_info **part) { + struct list_head *dentry, *pentry; u8 type, dnum, pnum; const char *p; DEBUGF("--- find_dev_and_part ---\nid = %s\n", id); + list_for_each(dentry, &devices) { + *part_num = 0; + *dev = list_entry(dentry, struct mtd_device, link); + list_for_each(pentry, &(*dev)->parts) { + *part = list_entry(pentry, struct part_info, link); + if (strcmp((*part)->name, id) == 0) + return 0; + (*part_num)++; + } + } + p = id; *dev = NULL; *part = NULL; @@ -2179,5 +2197,3 @@ U_BOOT_CMD( #endif /* #ifdef CONFIG_JFFS2_CMDLINE */ /***************************************************/ - -#endif /* CFG_CMD_JFFS2 */