diff options
author | Wolfgang Denk <wd@denx.de> | 2010-12-16 23:00:53 +0100 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2010-12-16 23:00:53 +0100 |
commit | 006915fbb0e3c1c9927fe32c4e92cb011f8499e7 (patch) | |
tree | b477df920f7d638a0472aa1d6bfa5ff71243448c /common | |
parent | 98e69567022eb2138dd99554b3a2e80522a1b153 (diff) | |
parent | b5d58d8500bfb918c7fec56f241e6ee1078c2be0 (diff) |
Merge branch 'master' of ../master into next
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_onenand.c | 4 | ||||
-rw-r--r-- | common/cmd_ubi.c | 15 | ||||
-rw-r--r-- | common/cmd_ubifs.c | 47 | ||||
-rw-r--r-- | common/env_nand.c | 2 | ||||
-rw-r--r-- | common/hwconfig.c | 27 |
5 files changed, 79 insertions, 16 deletions
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c index 33108f1b34a..cb2ba70517d 100644 --- a/common/cmd_onenand.c +++ b/common/cmd_onenand.c @@ -293,7 +293,7 @@ static int onenand_dump(struct mtd_info *mtd, ulong off, int only_oob) addr = (loff_t) off; memset(&ops, 0, sizeof(ops)); ops.datbuf = datbuf; - ops.oobbuf = oobbuf; /* must exist, but oob data will be appended to ops.datbuf */ + ops.oobbuf = oobbuf; ops.len = mtd->writesize; ops.ooblen = mtd->oobsize; ops.retlen = 0; @@ -319,6 +319,8 @@ static int onenand_dump(struct mtd_info *mtd, ulong off, int only_oob) } puts("OOB:\n"); i = mtd->oobsize >> 3; + p = oobbuf; + while (i--) { printf("\t%02x %02x %02x %02x %02x %02x %02x %02x\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 7692ac7716d..b486ca8fefa 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -42,6 +42,11 @@ struct selected_dev { static struct selected_dev ubi_dev; +#ifdef CONFIG_CMD_UBIFS +int ubifs_is_mounted(void); +void cmd_ubifs_umount(void); +#endif + static void ubi_dump_vol_info(const struct ubi_volume *vol) { ubi_msg("volume information dump:"); @@ -472,6 +477,16 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) if (argc < 3) return cmd_usage(cmdtp); +#ifdef CONFIG_CMD_UBIFS + /* + * Automatically unmount UBIFS partition when user + * changes the UBI device. Otherwise the following + * UBIFS commands will crash. + */ + if (ubifs_is_mounted()) + cmd_ubifs_umount(); +#endif + /* todo: get dev number for NAND... */ ubi_dev.nr = 0; diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c index a0ec184486d..3cd2d8fa824 100644 --- a/common/cmd_ubifs.c +++ b/common/cmd_ubifs.c @@ -33,12 +33,17 @@ #include <config.h> #include <command.h> +#include "../fs/ubifs/ubifs.h" + static int ubifs_initialized; static int ubifs_mounted; +extern struct super_block *ubifs_sb; + /* Prototypes */ int ubifs_init(void); int ubifs_mount(char *vol_name); +void ubifs_umount(struct ubifs_info *c); int ubifs_ls(char *dir_name); int ubifs_load(char *filename, u32 addr, u32 size); @@ -67,13 +72,47 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } +int ubifs_is_mounted(void) +{ + return ubifs_mounted; +} + +void cmd_ubifs_umount(void) +{ + + if (ubifs_sb) { + printf("Unmounting UBIFS volume %s!\n", + ((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name); + ubifs_umount(ubifs_sb->s_fs_info); + } + + ubifs_sb = NULL; + ubifs_mounted = 0; + ubifs_initialized = 0; +} + +int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + if (argc != 1) + return cmd_usage(cmdtp); + + if (ubifs_initialized == 0) { + printf("No UBIFS volume mounted!\n"); + return -1; + } + + cmd_ubifs_umount(); + + return 0; +} + int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *filename = "/"; int ret; if (!ubifs_mounted) { - printf("UBIFS not mounted, use ubifs mount to mount volume first!\n"); + printf("UBIFS not mounted, use ubifsmount to mount volume first!\n"); return -1; } @@ -132,6 +171,12 @@ U_BOOT_CMD( ); U_BOOT_CMD( + ubifsumount, 1, 0, do_ubifs_umount, + "unmount UBIFS volume", + " - unmount current volume" +); + +U_BOOT_CMD( ubifsls, 2, 0, do_ubifs_ls, "list files in a directory", "[directory]\n" diff --git a/common/env_nand.c b/common/env_nand.c index 4e8307aa333..7f6c9175189 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -297,7 +297,7 @@ int readenv(size_t offset, u_char * buf) offset += blocksize; } else { char_ptr = &buf[amount_loaded]; - if (nand_read(&nand_info[0], offset, &len, char_ptr)) + if (nand_read_skip_bad(&nand_info[0], offset, &len, char_ptr)) return 1; offset += blocksize; amount_loaded += len; diff --git a/common/hwconfig.c b/common/hwconfig.c index 3c9759fc557..193863a9701 100644 --- a/common/hwconfig.c +++ b/common/hwconfig.c @@ -68,14 +68,14 @@ next: return NULL; } -const char *cpu_hwconfig __attribute__((weak)); -const char *board_hwconfig __attribute__((weak)); +const char cpu_hwconfig[] __attribute__((weak)) = ""; +const char board_hwconfig[] __attribute__((weak)) = ""; #define HWCONFIG_PRE_RELOC_BUF_SIZE 128 static const char *__hwconfig(const char *opt, size_t *arglen) { - const char *env_hwconfig = NULL; + const char *env_hwconfig = NULL, *ret; char buf[HWCONFIG_PRE_RELOC_BUF_SIZE]; if (gd->flags & GD_FLG_ENV_READY) { @@ -92,19 +92,20 @@ static const char *__hwconfig(const char *opt, size_t *arglen) env_hwconfig = buf; } - if (env_hwconfig) - return hwconfig_parse(env_hwconfig, strlen(env_hwconfig), + if (env_hwconfig) { + ret = hwconfig_parse(env_hwconfig, strlen(env_hwconfig), opt, ";", ':', arglen); + if (ret) + return ret; + } - if (board_hwconfig) - return hwconfig_parse(board_hwconfig, strlen(board_hwconfig), - opt, ";", ':', arglen); + ret = hwconfig_parse(board_hwconfig, strlen(board_hwconfig), + opt, ";", ':', arglen); + if (ret) + return ret; - if (cpu_hwconfig) - return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), - opt, ";", ':', arglen); - - return NULL; + return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), + opt, ";", ':', arglen); } /* |