summaryrefslogtreecommitdiff
path: root/common/cmd_jffs2.c
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2009-05-16 12:04:22 +0200
committerWolfgang Denk <wd@denx.de>2009-05-28 21:26:00 +0200
commit76b5883da2cf049cd410901c04ea450e5f5c27c3 (patch)
tree689898ecf9697436de062a5c7bba0590e88654d2 /common/cmd_jffs2.c
parentf40f6db278f602b55820693634a7256b0b4e4b80 (diff)
jffs2/mtdparts: Fix problem with usage from JFFS2 and MTDPARTS together
Currently using JFFS2 with MTDPARTS enabled doesn't work. This is because mtdparts_init() is available in both files, cmd_mtdparts.c and cmd_jffs2.c. Please note that in the original cmd_jffs2.c file (before the jffs2/mtdparts command/file split those 2 different versions already existed. So this is nothing new. The main problem is that the variables "current_dev" and "current_partnum" are declared in both files now. This doesn't work. This patch now changes the names of those variable to more specific names: "current_mtd_dev" and "current_mtd_partnum". This is because this patch also changes the declaration from static to global, so that they can be used from both files. Please note that my first tests were not successful. The MTD devices selected via mtdparts are now accessed but I'm failing to see the directory listed via the "ls" command. Nothing is displayed. Perhaps I didn't generate the JFFS2 image correctly (I never used JFFS2 in U-Boot before). Not sure. Perhaps somebody else could take a look at this as well. I'll continue looking into this on Monday. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Wolfgang Denk <wd@denx.de> Cc: Detlev Zundel <dzu@denx.de> Cc: Ilya Yanok <yanok@emcraft.com> Cc: Renaud barbier <renaud.barbier@ge.com>
Diffstat (limited to 'common/cmd_jffs2.c')
-rw-r--r--common/cmd_jffs2.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index 860d1d97e3..3bb6c3cb15 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -137,8 +137,15 @@
#define MTD_WRITEABLE_CMD 1
/* current active device and partition number */
-static struct mtd_device *current_dev = NULL;
-static u8 current_partnum = 0;
+#ifdef CONFIG_CMD_MTDPARTS
+/* Use the ones declared in cmd_mtdparts.c */
+extern struct mtd_device *current_mtd_dev;
+extern u8 current_mtd_partnum;
+#else
+/* Use local ones */
+struct mtd_device *current_mtd_dev = NULL;
+u8 current_mtd_partnum = 0;
+#endif
#if defined(CONFIG_CMD_CRAMFS)
extern int cramfs_check (struct part_info *info);
@@ -346,6 +353,9 @@ static inline u32 get_part_sector_size(struct mtdids *id, struct part_info *part
* Parse and initialize global mtdids mapping and create global
* device/partition list.
*
+ * 'Static' version of command line mtdparts_init() routine. Single partition on
+ * a single device configuration.
+ *
* @return 0 on success, 1 otherwise
*/
int mtdparts_init(void)
@@ -360,18 +370,18 @@ int mtdparts_init(void)
struct part_info *part;
initialized = 1;
- current_dev = (struct mtd_device *)
+ current_mtd_dev = (struct mtd_device *)
malloc(sizeof(struct mtd_device) +
sizeof(struct part_info) +
sizeof(struct mtdids));
- if (!current_dev) {
+ if (!current_mtd_dev) {
printf("out of memory\n");
return 1;
}
- memset(current_dev, 0, sizeof(struct mtd_device) +
- sizeof(struct part_info) + sizeof(struct mtdids));
+ memset(current_mtd_dev, 0, sizeof(struct mtd_device) +
+ sizeof(struct part_info) + sizeof(struct mtdids));
- id = (struct mtdids *)(current_dev + 1);
+ id = (struct mtdids *)(current_mtd_dev + 1);
part = (struct part_info *)(id + 1);
/* id */
@@ -386,7 +396,7 @@ int mtdparts_init(void)
if ((mtd_id_parse(dev_name, NULL, &id->type, &id->num) != 0) ||
(mtd_device_validate(id->type, id->num, &size) != 0)) {
printf("incorrect device: %s%d\n", MTD_DEV_TYPE(id->type), id->num);
- free(current_dev);
+ free(current_mtd_dev);
return 1;
}
id->size = size;
@@ -413,7 +423,7 @@ int mtdparts_init(void)
part->sector_size = get_part_sector_size(id, part);
- part->dev = current_dev;
+ part->dev = current_mtd_dev;
INIT_LIST_HEAD(&part->link);
/* recalculate size if needed */
@@ -424,11 +434,11 @@ int mtdparts_init(void)
part->name, part->size, part->offset);
/* device */
- current_dev->id = id;
- INIT_LIST_HEAD(&current_dev->link);
- current_dev->num_parts = 1;
- INIT_LIST_HEAD(&current_dev->parts);
- list_add(&part->link, &current_dev->parts);
+ current_mtd_dev->id = id;
+ INIT_LIST_HEAD(&current_mtd_dev->link);
+ current_mtd_dev->num_parts = 1;
+ INIT_LIST_HEAD(&current_mtd_dev->parts);
+ list_add(&part->link, &current_mtd_dev->parts);
}
return 0;
@@ -516,7 +526,7 @@ int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (mtdparts_init() !=0)
return 1;
- if ((part = jffs2_part_info(current_dev, current_partnum))){
+ if ((part = jffs2_part_info(current_mtd_dev, current_mtd_partnum))){
/* check partition type for cramfs */
fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2");
@@ -567,7 +577,7 @@ int do_jffs2_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (mtdparts_init() !=0)
return 1;
- if ((part = jffs2_part_info(current_dev, current_partnum))){
+ if ((part = jffs2_part_info(current_mtd_dev, current_mtd_partnum))){
/* check partition type for cramfs */
if (cramfs_check(part)) {
@@ -602,7 +612,7 @@ int do_jffs2_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (mtdparts_init() !=0)
return 1;
- if ((part = jffs2_part_info(current_dev, current_partnum))){
+ if ((part = jffs2_part_info(current_mtd_dev, current_mtd_partnum))){
/* check partition type for cramfs */
fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2");