summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-02-24 17:33:22 +0000
committerSimon Glass <sjg@chromium.org>2013-02-28 19:09:23 -0800
commit41ef372c1a2d344621c74aa4bce5cdb0970ba5f1 (patch)
tree9abdeda0b3b87a70e4f3929e83ddd15f4704377f /common
parentbfc59966431e6335fd5be0589eec073902cc7bb3 (diff)
downloadu-boot-imx-41ef372c1a2d344621c74aa4bce5cdb0970ba5f1.zip
u-boot-imx-41ef372c1a2d344621c74aa4bce5cdb0970ba5f1.tar.gz
u-boot-imx-41ef372c1a2d344621c74aa4bce5cdb0970ba5f1.tar.bz2
common: Use new numeric setenv functions
Use setenv_ulong(), setenv_hex() and setenv_addr() in common/ Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_bootm.c11
-rw-r--r--common/cmd_cbfs.c4
-rw-r--r--common/cmd_cramfs.c4
-rw-r--r--common/cmd_fdos.c4
-rw-r--r--common/cmd_jffs2.c4
-rw-r--r--common/cmd_load.c12
-rw-r--r--common/cmd_mtdparts.c4
-rw-r--r--common/cmd_nand.c12
-rw-r--r--common/cmd_nvedit.c3
-rw-r--r--common/cmd_reiser.c4
-rw-r--r--common/cmd_setexpr.c39
-rw-r--r--common/cmd_unzip.c4
-rw-r--r--common/cmd_ximg.c7
-rw-r--r--common/cmd_zfs.c3
-rw-r--r--common/cmd_zip.c4
15 files changed, 48 insertions, 71 deletions
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 1312a0d..b32991d 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -452,9 +452,7 @@ static int bootm_start_standalone(ulong iflag, int argc, char * const argv[])
/* Don't start if "autostart" is set to "no" */
if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
- char buf[32];
- sprintf(buf, "%lX", images.os.image_len);
- setenv("filesize", buf);
+ setenv_hex("filesize", images.os.image_len);
return 0;
}
appl = (int (*)(int, char * const []))(ulong)ntohl(images.ep);
@@ -529,17 +527,14 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
case BOOTM_STATE_RAMDISK:
{
ulong rd_len = images.rd_end - images.rd_start;
- char str[17];
ret = boot_ramdisk_high(&images.lmb, images.rd_start,
rd_len, &images.initrd_start, &images.initrd_end);
if (ret)
return ret;
- sprintf(str, "%lx", images.initrd_start);
- setenv("initrd_start", str);
- sprintf(str, "%lx", images.initrd_end);
- setenv("initrd_end", str);
+ setenv_hex("initrd_start", images.initrd_start);
+ setenv_hex("initrd_end", images.initrd_end);
}
break;
#endif
diff --git a/common/cmd_cbfs.c b/common/cmd_cbfs.c
index 3b6cfd8..f51534b 100644
--- a/common/cmd_cbfs.c
+++ b/common/cmd_cbfs.c
@@ -65,7 +65,6 @@ int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
const struct cbfs_cachenode *file;
unsigned long offset;
unsigned long count;
- char buf[12];
long size;
if (argc < 3) {
@@ -95,8 +94,7 @@ int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
printf("\n%ld bytes read\n", size);
- sprintf(buf, "%lX", size);
- setenv("filesize", buf);
+ setenv_hex("filesize", size);
return 0;
}
diff --git a/common/cmd_cramfs.c b/common/cmd_cramfs.c
index e7f496e..0e43ab6 100644
--- a/common/cmd_cramfs.c
+++ b/common/cmd_cramfs.c
@@ -146,11 +146,9 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
size = cramfs_load ((char *) offset, &part, filename);
if (size > 0) {
- char buf[10];
printf("### CRAMFS load complete: %d bytes loaded to 0x%lx\n",
size, offset);
- sprintf(buf, "%x", size);
- setenv("filesize", buf);
+ setenv_hex("filesize", size);
} else {
printf("### CRAMFS LOAD ERROR<%x> for %s!\n", size, filename);
}
diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c
index fbee861..8ea1140 100644
--- a/common/cmd_fdos.c
+++ b/common/cmd_fdos.c
@@ -40,7 +40,6 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
char *name;
char *ep;
int size;
- char buf [12];
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER;
/* pre-set load_addr */
@@ -91,8 +90,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
flush_cache (load_addr, size);
- sprintf(buf, "%x", size);
- setenv("filesize", buf);
+ setenv_hex("filesize", size);
printf("Floppy DOS load complete: %d bytes loaded to 0x%lx\n",
size, load_addr);
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index 27296dd..4a4a000 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -525,11 +525,9 @@ int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
if (size > 0) {
- char buf[10];
printf("### %s load complete: %d bytes loaded to 0x%lx\n",
fsname, size, offset);
- sprintf(buf, "%x", size);
- setenv("filesize", buf);
+ setenv_hex("filesize", size);
} else {
printf("### %s LOAD ERROR<%x> for %s!\n", fsname, size, filename);
}
diff --git a/common/cmd_load.c b/common/cmd_load.c
index 46db962..0832e92 100644
--- a/common/cmd_load.c
+++ b/common/cmd_load.c
@@ -149,7 +149,6 @@ static ulong load_serial(long offset)
int type; /* return code for record type */
ulong addr; /* load address from S-Record */
ulong size; /* number of bytes transferred */
- char buf[32];
ulong store_addr;
ulong start_addr = ~0;
ulong end_addr = 0;
@@ -198,8 +197,7 @@ static ulong load_serial(long offset)
start_addr, end_addr, size, size
);
flush_cache(start_addr, size);
- sprintf(buf, "%lX", size);
- setenv("filesize", buf);
+ setenv_hex("filesize", size);
return (addr);
case SREC_START:
break;
@@ -519,7 +517,6 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
static ulong load_serial_bin(ulong offset)
{
int size, i;
- char buf[32];
set_kerm_bin_mode((ulong *) offset);
size = k_recv();
@@ -539,8 +536,7 @@ static ulong load_serial_bin(ulong offset)
flush_cache(offset, size);
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
- sprintf(buf, "%X", size);
- setenv("filesize", buf);
+ setenv_hex("filesize", size);
return offset;
}
@@ -965,7 +961,6 @@ static int getcxmodem(void) {
static ulong load_serial_ymodem(ulong offset)
{
int size;
- char buf[32];
int err;
int res;
connection_info_t info;
@@ -1012,8 +1007,7 @@ static ulong load_serial_ymodem(ulong offset)
flush_cache(offset, size);
printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
- sprintf(buf, "%X", size);
- setenv("filesize", buf);
+ setenv_hex("filesize", size);
return offset;
}
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 06fc171..0cfca0c 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -230,7 +230,6 @@ static void memsize_format(char *buf, u32 size)
*/
static void index_partitions(void)
{
- char buf[16];
u16 mtddevnum;
struct part_info *part;
struct list_head *dentry;
@@ -244,8 +243,7 @@ static void index_partitions(void)
dev = list_entry(dentry, struct mtd_device, link);
if (dev == current_mtd_dev) {
mtddevnum += current_mtd_partnum;
- sprintf(buf, "%d", mtddevnum);
- setenv("mtddevnum", buf);
+ setenv_ulong("mtddevnum", mtddevnum);
break;
}
mtddevnum += dev->num_parts;
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 495610c..32348f3 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -373,7 +373,6 @@ static void nand_print_and_set_info(int idx)
{
nand_info_t *nand = &nand_info[idx];
struct nand_chip *chip = nand->priv;
- char buf[32];
printf("Device %d: ", idx);
if (chip->numchips > 1)
@@ -385,14 +384,9 @@ static void nand_print_and_set_info(int idx)
printf(" Erase size %8d b\n", nand->erasesize);
/* Set geometry info */
- sprintf(buf, "%x", nand->writesize);
- setenv("nand_writesize", buf);
-
- sprintf(buf, "%x", nand->oobsize);
- setenv("nand_oobsize", buf);
-
- sprintf(buf, "%x", nand->erasesize);
- setenv("nand_erasesize", buf);
+ setenv_hex("nand_writesize", nand->writesize);
+ setenv_hex("nand_oobsize", nand->oobsize);
+ setenv_hex("nand_erasesize", nand->erasesize);
}
static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 44e88aa..d646d90 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -891,8 +891,7 @@ NXTARG: ;
envp->flags = ACTIVE_FLAG;
#endif
}
- sprintf(buf, "%zX", (size_t)(len + offsetof(env_t, data)));
- setenv("filesize", buf);
+ setenv_hex("filesize", len + offsetof(env_t, data));
return 0;
diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c
index e658618..717c7f6 100644
--- a/common/cmd_reiser.c
+++ b/common/cmd_reiser.c
@@ -100,7 +100,6 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ulong addr = 0, filelen;
disk_partition_t info;
block_dev_desc_t *dev_desc = NULL;
- char buf [12];
unsigned long count;
char *addr_str;
@@ -175,8 +174,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
load_addr = addr;
printf ("\n%ld bytes read\n", filelen);
- sprintf(buf, "%lX", filelen);
- setenv("filesize", buf);
+ setenv_hex("filesize", filelen);
return filelen;
}
diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c
index 5a04295..7a38e94 100644
--- a/common/cmd_setexpr.c
+++ b/common/cmd_setexpr.c
@@ -53,7 +53,7 @@ static ulong get_arg(char *s, int w)
static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong a, b;
- char buf[16];
+ ulong value;
int w;
/* Validate arguments */
@@ -67,8 +67,7 @@ static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
a = get_arg(argv[2], w);
if (argc == 3) {
- sprintf(buf, "%lx", a);
- setenv(argv[1], buf);
+ setenv_hex(argv[1], a);
return 0;
}
@@ -76,20 +75,36 @@ static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
b = get_arg(argv[4], w);
switch (argv[3][0]) {
- case '|': sprintf(buf, "%lx", (a | b)); break;
- case '&': sprintf(buf, "%lx", (a & b)); break;
- case '+': sprintf(buf, "%lx", (a + b)); break;
- case '^': sprintf(buf, "%lx", (a ^ b)); break;
- case '-': sprintf(buf, "%lx", (a - b)); break;
- case '*': sprintf(buf, "%lx", (a * b)); break;
- case '/': sprintf(buf, "%lx", (a / b)); break;
- case '%': sprintf(buf, "%lx", (a % b)); break;
+ case '|':
+ value = a | b;
+ break;
+ case '&':
+ value = a & b;
+ break;
+ case '+':
+ value = a + b;
+ break;
+ case '^':
+ value = a ^ b;
+ break;
+ case '-':
+ value = a - b;
+ break;
+ case '*':
+ value = a * b;
+ break;
+ case '/':
+ value = a / b;
+ break;
+ case '%':
+ value = a % b;
+ break;
default:
printf("invalid op\n");
return 1;
}
- setenv(argv[1], buf);
+ setenv_hex(argv[1], value);
return 0;
}
diff --git a/common/cmd_unzip.c b/common/cmd_unzip.c
index 43ed791..7470c2b 100644
--- a/common/cmd_unzip.c
+++ b/common/cmd_unzip.c
@@ -28,7 +28,6 @@ static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
unsigned long src, dst;
unsigned long src_len = ~0UL, dst_len = ~0UL;
- char buf[32];
switch (argc) {
case 4:
@@ -46,8 +45,7 @@ static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
- sprintf(buf, "%lX", src_len);
- setenv("filesize", buf);
+ setenv_hex("filesize", src_len);
return 0;
}
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index 42a7eba..ea0a26e 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -50,7 +50,6 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
ulong data, len, count;
int verify;
int part = 0;
- char pbuf[10];
image_header_t *hdr;
#if defined(CONFIG_FIT)
const char *uname = NULL;
@@ -256,10 +255,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
puts("OK\n");
}
- sprintf(pbuf, "%8lx", data);
- setenv("fileaddr", pbuf);
- sprintf(pbuf, "%8lx", len);
- setenv("filesize", pbuf);
+ setenv_hex("fileaddr", data);
+ setenv_hex("filesize", len);
return 0;
}
diff --git a/common/cmd_zfs.c b/common/cmd_zfs.c
index 1df0c4d..900e977 100644
--- a/common/cmd_zfs.c
+++ b/common/cmd_zfs.c
@@ -129,8 +129,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
load_addr = addr;
printf("%llu bytes read\n", zfile.size);
- sprintf(buf, "%llX", zfile.size);
- setenv("filesize", buf);
+ setenv_hex("filesize", zfile.size);
return 0;
}
diff --git a/common/cmd_zip.c b/common/cmd_zip.c
index a73c86d..8607da8 100644
--- a/common/cmd_zip.c
+++ b/common/cmd_zip.c
@@ -28,7 +28,6 @@ static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
unsigned long src, dst;
unsigned long src_len, dst_len = ~0UL;
- char buf[32];
switch (argc) {
case 5:
@@ -47,8 +46,7 @@ static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
printf("Compressed size: %ld = 0x%lX\n", dst_len, dst_len);
- sprintf(buf, "%lX", dst_len);
- setenv("filesize", buf);
+ setenv_hex("filesize", dst_len);
return 0;
}