diff mbox

[U-Boot,02/10] arm: Use getenv_ulong() in place of getenv(), strtoul

Message ID 1318552994-6653-3-git-send-email-sjg@chromium.org
State Accepted, archived
Commit dc8bbea0170eb2aca428ea221c91fc2e5e11f199
Headers show

Commit Message

Simon Glass Oct. 14, 2011, 12:43 a.m. UTC
This changes the board code to use the new getenv_ulong() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/lib/board.c |   36 +++++++++++-------------------------
 1 files changed, 11 insertions(+), 25 deletions(-)

Comments

Wolfgang Denk Oct. 23, 2011, 8:50 p.m. UTC | #1
Dear Simon Glass,

In message <1318552994-6653-3-git-send-email-sjg@chromium.org> you wrote:
> This changes the board code to use the new getenv_ulong() function.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>  arch/arm/lib/board.c |   36 +++++++++++-------------------------
>  1 files changed, 11 insertions(+), 25 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
Wolfgang Denk Oct. 23, 2011, 9:49 p.m. UTC | #2
Dear Simon Glass,

In message <1318552994-6653-3-git-send-email-sjg@chromium.org> you wrote:
> This changes the board code to use the new getenv_ulong() function.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>  arch/arm/lib/board.c |   36 +++++++++++-------------------------
>  1 files changed, 11 insertions(+), 25 deletions(-)

Urgh...

This breaks almost all ARM boards like this:

Configuring for a320evb board...
board.c: In function 'board_init_r':
board.c:569: error: 's' undeclared (first use in this function)
board.c:569: error: (Each undeclared identifier is reported only once
board.c:569: error: for each function it appears in.)
make[1]: *** [/work/wd/tmp-arm/arch/arm/lib/board.o] Error 1
make: *** [/work/wd/tmp-arm/arch/arm/lib/libarm.o] Error 2


Didn't you run MAKELL?

Best regards,

Wolfgang Denk
Simon Glass Oct. 24, 2011, 12:19 a.m. UTC | #3
Hi Wolfgang,

On Sun, Oct 23, 2011 at 2:49 PM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Simon Glass,
>
> In message <1318552994-6653-3-git-send-email-sjg@chromium.org> you wrote:
>> This changes the board code to use the new getenv_ulong() function.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>  arch/arm/lib/board.c |   36 +++++++++++-------------------------
>>  1 files changed, 11 insertions(+), 25 deletions(-)
>
> Urgh...
>
> This breaks almost all ARM boards like this:
>
> Configuring for a320evb board...
> board.c: In function 'board_init_r':
> board.c:569: error: 's' undeclared (first use in this function)
> board.c:569: error: (Each undeclared identifier is reported only once
> board.c:569: error: for each function it appears in.)
> make[1]: *** [/work/wd/tmp-arm/arch/arm/lib/board.o] Error 1
> make: *** [/work/wd/tmp-arm/arch/arm/lib/libarm.o] Error 2

Sorry, I have sent a patch for this.

>
>
> Didn't you run MAKELL?

No these pre-date my getting that running (with Mike's help) and I
didn't think to go back to this series.

Regards,
Simon

>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
> ADVISORY:  There is  an  Extremely Small  but  Nonzero  Chance  That,
> Through a Process Know as "Tunneling," This Product May Spontaneously
> Disappear  from Its Present Location and Reappear at Any Random Place
> in the Universe, Including Your Neighbor's Domicile. The Manufacturer
> Will Not Be Responsible for Any Damages  or  Inconvenience  That  May
> Result.
>
diff mbox

Patch

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