arm: Use getenv_ulong() in place of getenv(), strtoul

This changes the board code to use the new getenv_ulong() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2011-10-13 14:43:06 +00:00 committed by Wolfgang Denk
parent 4a9b413108
commit dc8bbea017

View file

@ -118,16 +118,11 @@ void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
#if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE) #if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE)
#define CONFIG_BAUDRATE 115200 #define CONFIG_BAUDRATE 115200
#endif #endif
static int init_baudrate(void) static int init_baudrate(void)
{ {
char tmp[64]; /* long enough for environment variables */ gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
int i = getenv_f("baudrate", tmp, sizeof(tmp)); return 0;
gd->baudrate = (i > 0)
? (int) simple_strtoul(tmp, NULL, 10)
: CONFIG_BAUDRATE;
return (0);
} }
static int display_banner(void) static int display_banner(void)
@ -267,6 +262,9 @@ void board_init_f(ulong bootflag)
init_fnc_t **init_fnc_ptr; init_fnc_t **init_fnc_ptr;
gd_t *id; gd_t *id;
ulong addr, addr_sp; ulong addr, addr_sp;
#ifdef CONFIG_PRAM
ulong reg;
#endif
/* Pointer is writable since we allocated a register for it */ /* Pointer is writable since we allocated a register for it */
gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07); gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
@ -317,9 +315,7 @@ void board_init_f(ulong bootflag)
/* /*
* reserve protected RAM * reserve protected RAM
*/ */
i = getenv_r("pram", (char *)tmp, sizeof(tmp)); reg = getenv_ulong("pram", 10, CONFIG_PRAM);
reg = (i > 0) ? simple_strtoul((const char *)tmp, NULL, 10) :
CONFIG_PRAM;
addr -= (reg << 10); /* size is in kB */ addr -= (reg << 10); /* size is in kB */
debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr); debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
#endif /* CONFIG_PRAM */ #endif /* CONFIG_PRAM */
@ -441,7 +437,6 @@ static char *failed = "*** failed ***\n";
void board_init_r(gd_t *id, ulong dest_addr) void board_init_r(gd_t *id, ulong dest_addr)
{ {
char *s;
ulong malloc_start; ulong malloc_start;
#if !defined(CONFIG_SYS_NO_FLASH) #if !defined(CONFIG_SYS_NO_FLASH)
ulong flash_size; ulong flash_size;
@ -569,9 +564,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */ #endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
/* Initialize from environment */ /* Initialize from environment */
s = getenv("loadaddr"); load_addr = getenv_ulong("loadaddr", 16, load_addr);
if (s != NULL)
load_addr = simple_strtoul(s, NULL, 16);
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
s = getenv("bootfile"); s = getenv("bootfile");
if (s != NULL) if (s != NULL)
@ -604,18 +597,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
* taking into account the protected RAM at top of memory * taking into account the protected RAM at top of memory
*/ */
{ {
ulong pram; ulong pram = 0;
uchar memsz[32]; uchar memsz[32];
#ifdef CONFIG_PRAM
char *s;
s = getenv("pram"); #ifdef CONFIG_PRAM
if (s != NULL) pram = getenv_ulong("pram", 10, CONFIG_PRAM);
pram = simple_strtoul(s, NULL, 10);
else
pram = CONFIG_PRAM;
#else
pram = 0;
#endif #endif
#ifdef CONFIG_LOGBUFFER #ifdef CONFIG_LOGBUFFER
#ifndef CONFIG_ALT_LB_ADDR #ifndef CONFIG_ALT_LB_ADDR