Skip to contentSkip to conversation

blackfin: Fix using gd->baudrate before setting its value

PATCH New Axel Lin 3 participants 6 messages Jun 29, 2013 – Jul 1, 2013

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 blackfin: Fix using gd->baudrate before setting its value

Current code uses gd->baudrate before setting its value. Besides, I got below build warning which is introduced by commit ddb5c5be "blackfin: add baudrate to bdinfo".

board.c:235:3: warning: passing argument 1 of 'simple_strtoul' makes pointer from integer without a cast [enabled by default] include/vsprintf.h:27:7: note: expected 'const char *' but argument is of type 'unsigned int'

This patch moves the code using gd->baudrate to be after init_baudrate() call, this ensures we get the baudrate setting before using it.

---
I forgot to CC u-boot mail list. here is a resend.

Hi,
I don't have this hardware to test.
I'd appreciate if someone can test it.

Thanks,
Axel

 arch/blackfin/lib/board.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/blackfin/lib/board.c +1 -2
index f1d5547..9e2e9de 100644
@@ -231,8 +231,6 @@ static int global_board_data_init(void)
 	bd->bi_sclk = get_sclk();
 	bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
 	bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-	bd->bi_baudrate = (gd->baudrate > 0)
-		? simple_strtoul(gd->baudrate, NULL, 10) : CONFIG_BAUDRATE;
 
 	return 0;
 }
@@ -299,6 +297,7 @@ void board_init_f(ulong bootflag)
 	env_init();
 	serial_early_puts("Baudrate init\n");
 	init_baudrate();
+	gd->bd->bi_baudrate = gd->baudrate;
 	serial_early_puts("Serial init\n");
 	serial_init();
 	serial_initialize();
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 blackfin: Fix using gd->baudrate before setting its value

Dear Axel Lin,

Quoted 30 lines

Current code uses gd->baudrate before setting its value. Besides, I got below build warning which is introduced by commit ddb5c5be "blackfin: add baudrate to bdinfo".

board.c:235:3: warning: passing argument 1 of 'simple_strtoul' makes pointer from integer without a cast [enabled by default] include/vsprintf.h:27:7: note: expected 'const char *' but argument is of type 'unsigned int'

This patch moves the code using gd->baudrate to be after init_baudrate() call, this ensures we get the baudrate setting before using it.

---
I forgot to CC u-boot mail list. here is a resend.

Hi,
I don't have this hardware to test.
I'd appreciate if someone can test it.

Thanks,
Axel

 arch/blackfin/lib/board.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/blackfin/lib/board.c +0 -0
index f1d5547..9e2e9de 100644

arch/blackfin/lib/board.c static int global_board_data_init(void) · line 235

Quoted 5 lines
arch/blackfin/lib/board.c +0 -2
@@ -231,8 +231,6 @@ static int global_board_data_init(void)
 	bd->bi_sclk = get_sclk();
 	bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
 	bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-	bd->bi_baudrate = (gd->baudrate > 0)
-		? simple_strtoul(gd->baudrate, NULL, 10) : CONFIG_BAUDRATE;

I'd rather say the fix here is to use (gd->baudrate > 0) ? gd->baudrate ? CONFIG_BAUDRATE ;

Otherwise you're changing the logic of the code and for that, you'd need Mikes' ack.

arch/blackfin/lib/board.c void board_init_f(ulong bootflag) · line 303

Quoted 10 lines
arch/blackfin/lib/board.c +1 -0
 	return 0;
 }
@@ -299,6 +297,7 @@ void board_init_f(ulong bootflag)
 	env_init();
 	serial_early_puts("Baudrate init\n");
 	init_baudrate();
+	gd->bd->bi_baudrate = gd->baudrate;
 	serial_early_puts("Serial init\n");
 	serial_init();
 	serial_initialize();

Best regards,
Marek Vasut

author
#2 lore raw

PATCH 1/1 blackfin: Fix using gd->baudrate before setting its value

2013/6/29 Marek Vasut <[email protected]>:

Quoted 42 lines

Dear Axel Lin,

Quoted 30 lines

Current code uses gd->baudrate before setting its value. Besides, I got below build warning which is introduced by commit ddb5c5be "blackfin: add baudrate to bdinfo".

board.c:235:3: warning: passing argument 1 of 'simple_strtoul' makes pointer from integer without a cast [enabled by default] include/vsprintf.h:27:7: note: expected 'const char *' but argument is of type 'unsigned int'

This patch moves the code using gd->baudrate to be after init_baudrate() call, this ensures we get the baudrate setting before using it.

---
I forgot to CC u-boot mail list. here is a resend.

Hi,
I don't have this hardware to test.
I'd appreciate if someone can test it.

Thanks,
Axel

 arch/blackfin/lib/board.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/blackfin/lib/board.c +0 -0
index f1d5547..9e2e9de 100644

arch/blackfin/lib/board.c static int global_board_data_init(void) · line 235

Quoted 5 lines
arch/blackfin/lib/board.c +0 -2
@@ -231,8 +231,6 @@ static int global_board_data_init(void)
      bd->bi_sclk = get_sclk();
      bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
      bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-     bd->bi_baudrate = (gd->baudrate > 0)
-             ? simple_strtoul(gd->baudrate, NULL, 10) : CONFIG_BAUDRATE;

I'd rather say the fix here is to use (gd->baudrate > 0) ? gd->baudrate ? CONFIG_BAUDRATE ;

Quoted 2 lines

Otherwise you're changing the logic of the code and for that, you'd need Mikes' ack.

Hi Marek,

It's because gd->baudrate is set in init_baudrate(). And if it is not found in an environment variable, the default is CONFIG_BAUDRATE.
It's unlikely gd->baudrate is 0.

So if we have below code:
init_baudrate();
gd->bd->bi_baudrate = (gd->baudrate > 0) ? gd->baudrate : CONFIG_BAUDRATE;

In an unlikely case where baudrate environment variable is set to 0, then we have inconsistency setting:

gd->baudrate = 0;
gd->bd->bi_baudrate = CONFIG_BAUDRATE;

Comments?

Regards,
Axel

#3 lore raw

PATCH 1/1 blackfin: Fix using gd->baudrate before setting its value

In reply to Axel Lin

Hi Axel,

Quoted 37 lines · Axel Lin

Current code uses gd->baudrate before setting its value. Besides, I got below build warning which is introduced by commit ddb5c5be "blackfin: add baudrate to bdinfo".

board.c:235:3: warning: passing argument 1 of 'simple_strtoul' makes pointer from integer without a cast [enabled by default] include/vsprintf.h:27:7: note: expected 'const char *' but argument is of type 'unsigned int'

This patch moves the code using gd->baudrate to be after init_baudrate() call, this ensures we get the baudrate setting before using it.

---
I forgot to CC u-boot mail list. here is a resend.

Hi,
I don't have this hardware to test.
I'd appreciate if someone can test it.

Thanks,
Axel

 arch/blackfin/lib/board.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/blackfin/lib/board.c +0 -2
index f1d5547..9e2e9de 100644
@@ -231,8 +231,6 @@ static int global_board_data_init(void)
        bd->bi_sclk = get_sclk();
        bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
        bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-       bd->bi_baudrate = (gd->baudrate > 0)
-               ? simple_strtoul(gd->baudrate, NULL, 10) : CONFIG_BAUDRATE;
 
        return 0;
 }

arch/blackfin/lib/board.c void board_init_f(ulong bootflag) · line 300

Quoted 4 lines
arch/blackfin/lib/board.c +1 -0
@@ -299,6 +297,7 @@ void board_init_f(ulong bootflag)
        env_init();
        serial_early_puts("Baudrate init\n");
        init_baudrate();
+       gd->bd->bi_baudrate = gd->baudrate;

I prefer to move this line into init_baudrate().

Regards,

Sonic

author
#4 lore raw

PATCH 1/1 blackfin: Fix using gd->baudrate before setting its value

2013/7/1 Sonic Zhang <[email protected]>:

Quoted 37 lines

Hi Axel,

Quoted 34 lines · Axel Lin

Current code uses gd->baudrate before setting its value. Besides, I got below build warning which is introduced by commit ddb5c5be "blackfin: add baudrate to bdinfo".

board.c:235:3: warning: passing argument 1 of 'simple_strtoul' makes pointer from integer without a cast [enabled by default] include/vsprintf.h:27:7: note: expected 'const char *' but argument is of type 'unsigned int'

This patch moves the code using gd->baudrate to be after init_baudrate() call, this ensures we get the baudrate setting before using it.

---
I forgot to CC u-boot mail list. here is a resend.

Hi,
I don't have this hardware to test.
I'd appreciate if someone can test it.

Thanks,
Axel

 arch/blackfin/lib/board.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/blackfin/lib/board.c +0 -2
index f1d5547..9e2e9de 100644
@@ -231,8 +231,6 @@ static int global_board_data_init(void)
        bd->bi_sclk = get_sclk();
        bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
        bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-       bd->bi_baudrate = (gd->baudrate > 0)
-               ? simple_strtoul(gd->baudrate, NULL, 10) : CONFIG_BAUDRATE;
 
Quoted 9 lines

arch/blackfin/lib/board.c void board_init_f(ulong bootflag) · line 300

Quoted 7 lines
arch/blackfin/lib/board.c +1 -0
        return 0;
 }
@@ -299,6 +297,7 @@ void board_init_f(ulong bootflag)
        env_init();
        serial_early_puts("Baudrate init\n");
        init_baudrate();
+       gd->bd->bi_baudrate = gd->baudrate;

I prefer to move this line into init_baudrate().

hi Sonic,

$ grep -r "int init_baudrate" -A 4 arch
It shows we have the same implementation for all supported architectures.

So I think init_baudrate() may be moved to a common place in the future. I pernsonal prefer keep the code as is in this patch.
But if you insist on moving this line into init_baudrate(), I have no problem to send a v2. Just let me know how do you think.

Thanks for the review,
Axel

#5 lore raw

PATCH 1/1 blackfin: Fix using gd->baudrate before setting its value

Hi Axel,

Quoted 49 lines · Axel Lin

2013/7/1 Sonic Zhang <[email protected]>:

Quoted 37 lines

Hi Axel,

Quoted 34 lines · Axel Lin

Current code uses gd->baudrate before setting its value. Besides, I got below build warning which is introduced by commit ddb5c5be "blackfin: add baudrate to bdinfo".

board.c:235:3: warning: passing argument 1 of 'simple_strtoul' makes pointer from integer without a cast [enabled by default] include/vsprintf.h:27:7: note: expected 'const char *' but argument is of type 'unsigned int'

This patch moves the code using gd->baudrate to be after init_baudrate() call, this ensures we get the baudrate setting before using it.

---
I forgot to CC u-boot mail list. here is a resend.

Hi,
I don't have this hardware to test.
I'd appreciate if someone can test it.

Thanks,
Axel

 arch/blackfin/lib/board.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/blackfin/lib/board.c +0 -2
index f1d5547..9e2e9de 100644
@@ -231,8 +231,6 @@ static int global_board_data_init(void)
        bd->bi_sclk = get_sclk();
        bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
        bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
-       bd->bi_baudrate = (gd->baudrate > 0)
-               ? simple_strtoul(gd->baudrate, NULL, 10) : CONFIG_BAUDRATE;
 
Quoted 9 lines

arch/blackfin/lib/board.c void board_init_f(ulong bootflag) · line 300

Quoted 7 lines
arch/blackfin/lib/board.c +1 -0
        return 0;
 }
@@ -299,6 +297,7 @@ void board_init_f(ulong bootflag)
        env_init();
        serial_early_puts("Baudrate init\n");
        init_baudrate();
+       gd->bd->bi_baudrate = gd->baudrate;

I prefer to move this line into init_baudrate().

hi Sonic,

Quoted 7 lines
$ grep -r "int init_baudrate" -A 4 arch
It shows we have the same implementation for all supported architectures.

So I think init_baudrate() may be moved to a common place in the future. I pernsonal prefer keep the code as is in this patch.
But if you insist on moving this line into init_baudrate(), I have no problem to send a v2. Just let me know how do you think.

Yes, please.

Regards,

Sonic