Patchwork [U-Boot,3/4] ELPPC: Don't write magic numbers via short.

login
register
mail settings
Submitter Tom Rini
Date May 13, 2013, 8:31 p.m.
Message ID <1368477117-32669-3-git-send-email-trini@ti.com>
Download mbox | patch
Permalink /patch/243532/
State Superseded
Delegated to: Wolfgang Denk
Headers show

Comments

Tom Rini - May 13, 2013, 8:31 p.m.
We need to write each segment of the buffer directly rather than using
shorts.

Cc: Frank Gottschling <fgottschling@eltec.de>
Signed-off-by: Tom Rini <trini@ti.com>
---
 board/eltec/elppc/misc.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
Wolfgang Denk - May 13, 2013, 10:40 p.m.
Dear Tom Rini,

In message <1368477117-32669-3-git-send-email-trini@ti.com> you wrote:
> We need to write each segment of the buffer directly rather than using
> shorts.
> 
> Cc: Frank Gottschling <fgottschling@eltec.de>
> Signed-off-by: Tom Rini <trini@ti.com>
> ---
>  board/eltec/elppc/misc.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/board/eltec/elppc/misc.c b/board/eltec/elppc/misc.c
> index 89f1b1d..a7d8486 100644
> --- a/board/eltec/elppc/misc.c
> +++ b/board/eltec/elppc/misc.c
> @@ -207,9 +207,12 @@ int misc_init_r (void)
>  		buf[4] = eerev.etheraddr[5];
>  		buf[5] = eerev.etheraddr[4];
>  
> -		*(unsigned short *) &buf[20] = 0x48B2;
> -		*(unsigned short *) &buf[22] = 0x0004;
> -		*(unsigned short *) &buf[24] = 0x1433;
> +		buf[20] = 0x48;
> +		buf[21] = 0xB2;
> +		buf[22] = 0x00;
> +		buf[23] = 0x04;
> +		buf[24] = 0x14;
> +		buf[25] = 0x33;

I guess the 16 bit numbers originally written had some meaning, so
there should be at least a comment explaining the code.

Best regards,

Wolfgang Denk

Patch

diff --git a/board/eltec/elppc/misc.c b/board/eltec/elppc/misc.c
index 89f1b1d..a7d8486 100644
--- a/board/eltec/elppc/misc.c
+++ b/board/eltec/elppc/misc.c
@@ -207,9 +207,12 @@  int misc_init_r (void)
 		buf[4] = eerev.etheraddr[5];
 		buf[5] = eerev.etheraddr[4];
 
-		*(unsigned short *) &buf[20] = 0x48B2;
-		*(unsigned short *) &buf[22] = 0x0004;
-		*(unsigned short *) &buf[24] = 0x1433;
+		buf[20] = 0x48;
+		buf[21] = 0xB2;
+		buf[22] = 0x00;
+		buf[23] = 0x04;
+		buf[24] = 0x14;
+		buf[25] = 0x33;
 
 		printf ("\nSRom:  Writing i82559 info ........ ");
 		if (eepro100_srom_store ((unsigned short *) buf) == -1)