powerpc: Correct im_dprambase cast
PATCH 1/4 powerpc: Correct im_dprambase cast
When casting im_dprambase we must cast to unsigned char not unsigned short.
--- arch/powerpc/cpu/mpc8260/commproc.c | 2 +- arch/powerpc/cpu/mpc8260/cpu.c | 2 +- arch/powerpc/cpu/mpc8260/i2c.c | 8 ++++---- arch/powerpc/cpu/mpc8260/serial_smc.c | 4 ++-- arch/powerpc/cpu/mpc8260/spi.c | 2 +- common/cmd_immap.c | 2 +- examples/standalone/mem_to_mem_idma2intr.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-)
arch/powerpc/cpu/mpc8260/commproc.c +1 -1
@@ -43,7 +43,7 @@ m8260_cpm_reset(void) }while ((immr->im_cpm.cp_cpcr &CPM_CR_FLG ) && ++count <1000000 );#ifdef CONFIG_HARD_I2C - *((unsigned short *)(&immr->im_dprambase[PROFF_I2C_BASE ])) =0 ; + *((unsigned char *)(&immr->im_dprambase[PROFF_I2C_BASE ])) =0 ;#endif }
arch/powerpc/cpu/mpc8260/cpu.c +1 -1
@@ -106,7 +106,7 @@ int checkcpu (void)* in the mask. */ m = immr & (IMMR_PARTNUM_MSK |IMMR_MASKNUM_MSK ); - k = *((ushort *) & immap->im_dprambase[PROFF_REVNUM ]); + k = *((uchar *) & immap->im_dprambase[PROFF_REVNUM ]);switch (m) {case 0x0000 :
arch/powerpc/cpu/mpc8260/i2c.c +4 -4
@@ -221,14 +221,14 @@ void i2c_init(int speed, int slaveadd)i2c_init_board ();#endif - dpaddr = *((unsigned short *) (&immap->im_dprambase[PROFF_I2C_BASE ])); + dpaddr = *((unsigned char *) (&immap->im_dprambase[PROFF_I2C_BASE ]));if (dpaddr ==0 ) {/* need to allocate dual port ram */ dpaddr =m8260_cpm_dpalloc (64 + (NUM_RX_BDS *sizeof (I2C_BD )) + (NUM_TX_BDS *sizeof (I2C_BD )) +MAX_TX_SPACE ,64 ); - *((unsigned short *)(&immap->im_dprambase[PROFF_I2C_BASE ])) = + *((unsigned char *)(&immap->im_dprambase[PROFF_I2C_BASE ])) = dpaddr; }
@@ -305,7 +305,7 @@ void i2c_newio(i2c_state_t *state)debug ("[I2C] i2c_newio\n" ); - dpaddr = *((unsigned short *)(&immap->im_dprambase[PROFF_I2C_BASE ])); + dpaddr = *((unsigned char *)(&immap->im_dprambase[PROFF_I2C_BASE ])); iip = (iic_t *)&immap->im_dprambase[dpaddr]; state->rx_idx =0 ; state->tx_idx =0 ;
@@ -480,7 +480,7 @@ int i2c_doio(i2c_state_t *state)return I2CERR_QUEUE_EMPTY ; } - dpaddr = *((unsigned short *)(&immap->im_dprambase[PROFF_I2C_BASE ])); + dpaddr = *((unsigned char *)(&immap->im_dprambase[PROFF_I2C_BASE ])); iip = (iic_t *)&immap->im_dprambase[dpaddr]; iip->iic_rbptr = iip->iic_rbase; iip->iic_tbptr = iip->iic_tbase;
arch/powerpc/cpu/mpc8260/serial_smc.c +2 -2
@@ -105,7 +105,7 @@ static int mpc8260_smc_serial_init(void)/* initialize pointers to SMC */ sp = (smc_t *) &(im->im_smc[SMC_INDEX ]); - *(ushort *)(&im->im_dprambase[PROFF_SMC_BASE ]) =PROFF_SMC ; + *(uchar *)(&im->im_dprambase[PROFF_SMC_BASE ]) =PROFF_SMC ; up = (smc_uart_t *)&im->im_dprambase[PROFF_SMC ];/* Disable transmitter/receiver. */
@@ -331,7 +331,7 @@ kgdb_serial_init (void)/* initialize pointers to SMC */ sp = (smc_t *) &(im->im_smc[KGDB_SMC_INDEX ]); - *(ushort *)(&im->im_dprambase[KGDB_PROFF_SMC_BASE ]) =KGDB_PROFF_SMC ; + *(uchar *)(&im->im_dprambase[KGDB_PROFF_SMC_BASE ]) =KGDB_PROFF_SMC ; up = (smc_uart_t *)&im->im_dprambase[KGDB_PROFF_SMC ];/* Disable transmitter/receiver. */
arch/powerpc/cpu/mpc8260/spi.c +1 -1
@@ -146,7 +146,7 @@ void spi_init_f (void) immr = (immap_t *)CONFIG_SYS_IMMR ; cp = (cpm8260_t *) &immr->im_cpm; - *(ushort *)(&immr->im_dprambase[PROFF_SPI_BASE ]) =PROFF_SPI ; + *(uchar *)(&immr->im_dprambase[PROFF_SPI_BASE ]) =PROFF_SPI ; spi = (spi_t *)&immr->im_dprambase[PROFF_SPI ];/* 1 */
common/cmd_immap.c +1 -1
@@ -535,7 +535,7 @@ do_i2cinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])volatile iic_t *iip;uint dpaddr; - dpaddr = *((unsigned short *) (&immap->im_dprambase[PROFF_I2C_BASE ])); + dpaddr = *((unsigned char *) (&immap->im_dprambase[PROFF_I2C_BASE ]));if (dpaddr ==0 ) iip =NULL ;else
examples/standalone/mem_to_mem_idma2intr.c +1 -1
@@ -309,7 +309,7 @@ int idma_init (void) memaddr =dpalloc (sizeof (pram_idma_t),64 ); - *(volatile ushort *) &immap->im_dprambase[PROFF_IDMA2_BASE ] = memaddr; + *(volatile uchar *) &immap->im_dprambase[PROFF_IDMA2_BASE ] = memaddr; piptr = (volatile pram_idma_t *) ((uint) (immap) + memaddr); piptr->pi_resv1 =0 ;/* manual says: clear it */
Signature · 1 line
1.7.9.5
PATCH 2/4 mpc8xx: Correct cast of im_cpm.cp_dparam
We must cast this to unsigned char not unsigned short to avoid warnings.
--- arch/powerpc/cpu/mpc8xx/cpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/cpu/mpc8xx/cpu.c +4 -4
@@ -78,7 +78,7 @@ static int check_CPU (long clock, uint pvr, uint immr)if ((pvr >>16 ) !=0x0050 )return -1 ; - k = (immr <<16 ) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0 ]); + k = (immr <<16 ) | *((uchar *) & immap->im_cpm.cp_dparam[0xB0 ]); m =0 ; suf ="" ;
@@ -194,7 +194,7 @@ static int check_CPU (long clock, uint pvr, uint immr)if ((pvr >>16 ) !=0x0050 )return -1 ; - k = (immr <<16 ) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0 ]); + k = (immr <<16 ) | *((uchar *) & immap->im_cpm.cp_dparam[0xB0 ]); m =0 ;switch (k) {
@@ -253,7 +253,7 @@ static int check_CPU (long clock, uint pvr, uint immr)if ((pvr >>16 ) !=0x0050 )return -1 ; - k = (immr <<16 ) |in_be16 ((ushort *)&immap->im_cpm.cp_dparam[0xB0 ]); + k = (immr <<16 ) |in_be16 ((uchar *)&immap->im_cpm.cp_dparam[0xB0 ]); m =0 ;switch (k) {
@@ -312,7 +312,7 @@ static int check_CPU (long clock, uint pvr, uint immr)if ((pvr >>16 ) !=0x0050 )return -1 ; - k = (immr <<16 ) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0 ]); + k = (immr <<16 ) | *((uchar *) & immap->im_cpm.cp_dparam[0xB0 ]); m =0 ;switch (k) {
Signature · 1 line
1.7.9.5
PATCH 2/4 mpc8xx: Correct cast of im_cpm.cp_dparam
Dear Tom Rini,
Quoted 1 line · In message <[email protected]> you wrote:
We must cast this to unsigned char not unsigned short to avoid warnings.
But this is wrong. We're actually reading a 16 bit value here.
I think there was previous discussion, and Scott Wodd has a patch out there, which just needed some minor fixing...
Best regards,
Wolfgang Denk
Signature · 6 lines
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 at denx.de
It is impractical for the standard to attempt to constrain the
behavior of code that does not obey the constraints of the standard.
- Doug GwynPATCH 2/4 mpc8xx: Correct cast of im_cpm.cp_dparam
Dear Tom,
Quoted 8 lines · In message <[email protected]> I wrote:
Quoted 1 line · In message <[email protected]> you wrote:
We must cast this to unsigned char not unsigned short to avoid warnings.
But this is wrong. We're actually reading a 16 bit value here.
I think there was previous discussion, and Scott Wodd has a patch out there, which just needed some minor fixing...
Scott's patch is here:
http://patchwork.ozlabs.org/patch/210599/
Scott, do you have any plans to submit an updated version?
Best regards,
Wolfgang Denk
Signature · 5 lines
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 at denx.de All men should freely use those seven words which have the power to make any marriage run smoothly: You know dear, you may be right.
PATCH 2/4 mpc8xx: Correct cast of im_cpm.cp_dparam
Quoted 12 lines · Wolfgang Denk
Dear Tom,
Quoted 2 lines · In message <[email protected]> I wrote:
In message <[email protected]> you
Quoted 1 line · wrote:
Quoted 1 line
We must cast this to unsigned char not unsigned short to avoid
warnings.
Quoted 4 lines
But this is wrong. We're actually reading a 16 bit value here.
I think there was previous discussion, and Scott Wodd has a patch
Quoted 8 lines
out
Quoted 1 line
there, which just needed some minor fixing...
Scott's patch is here:
http://patchwork.ozlabs.org/patch/210599/
Scott, do you have any plans to submit an updated version?
I'll try to get to it soon.
-Scott
PATCH 2/4 mpc8xx: Correct cast of im_cpm.cp_dparam
In reply to Wolfgang Denk-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 8 lines · Wolfgang Denk
Dear Tom Rini,
In message <[email protected]> you
Quoted 2 lines · wrote:
We must cast this to unsigned char not unsigned short to avoid warnings.
But this is wrong. We're actually reading a 16 bit value here.
Oh derp, I was mis-recalling the type rules here.
- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBAgAGBQJRkji2AAoJENk4IS6UOR1WoPUP/jaVGG2jSUGwsSWqCeWDuPu3 dWzu7CjqA01/pzhKYcJ/EBHTGuWaE0kQR7EHP0jhWFU+S20jIHaLqrRyznBnaHFJ wsqsmyRhzgBEDq6oj6sKJa2OW+iVy6jkPlK3zRQJy9n9PpqdCW2u6b57dtCFq2tf 0f+GQDqwV2v3l5IOCWJfX5VeIJG1udBfKXGm1zNdEgcM8smJMdJsPuUBfUvUkO6d GSPp+G6DQLIwJpCX6LE5LZGCTbZIm5hPgBqds1PhSgy5AupOPwLIBeAjlxjOJ4JD Pp1pAfE9KSGnKJhJ000/24/74WAPOhvHVIn/9q8DPSFJaL/sze3vtnmrWX2WpXmL kujYQVo89iL7KbJmN/OdEsxVImnp6pSahc+od1sZTZQa+6vuBfu8uoRluEmcJLnf 5lMrqg5b+IUdB/pC7UA+w6RG+RZj930U/G+duBvKuUQSqTpNG9GSXA8FXjRToope MlUNpREU9w+pbUpJUMtbA97INzshGOSHyZvZDz1yFP6gJNBK+V+Tkz2P0zv9JC6V UWdrRcuKBZ+6uteKTc1NCukhx2XH90VdVe1y+OhVT9G+mcbTkQo3KQv4FSi7B8Nu jaxutfTve+FWbDTeHSCw5GqrB/GyB5mB4rdOVN1Q8I8GmuBkK4azKnsbccjkWGTJ oHSCaEruXuTw8CqRvRM/
=XAN7
-----END PGP SIGNATURE-----
PATCH 3/4 ELPPC: Don't write magic numbers via short.
In reply to Tom RiniWe need to write each segment of the buffer directly rather than using shorts.
--- board/eltec/elppc/misc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
board/eltec/elppc/misc.c +6 -3
@@ -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 )
Signature · 1 line
1.7.9.5
PATCH 3/4 ELPPC: Don't write magic numbers via short.
Dear Tom Rini,
Quoted 16 lines · In message <[email protected]> you wrote:
We need to write each segment of the buffer directly rather than using shorts.
Cc Frank Gottschling <[email protected]>Signed-off-by Tom Rini <[email protected]>--- board/eltec/elppc/misc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)board/eltec/elppc/misc.c +0
-0@@ -207,9 +207,12 @@ int misc_init_r (void) buf[4 ] = eerev.etheraddr[5 ]; buf[5 ] = eerev.etheraddr[4 ];
board/eltec/elppc/misc.c int misc_init_r (void) · line 215
Quoted 10 lines
board/eltec/elppc/misc.c +6
-3- *(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
Signature · 6 lines
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 at denx.de My challenge to the goto-less programmer is to recode tcp_input() without any gotos ... without any loss of efficiency (there has to be a catch). - W. R. Stevens
PATCH 4/4 mpc8323erdb: Update crc32 check of MAC
In reply to Tom RiniWe need to cast to unsigned char, not unsigned short here to avoid a warning.
--- board/freescale/mpc8323erdb/mpc8323erdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/freescale/mpc8323erdb/mpc8323erdb.c +1 -1
@@ -195,7 +195,7 @@ int mac_read_from_eeprom(void)printf ("\nEEPROM @ 0x%02x read FAILED!!!\n" ,CONFIG_SYS_I2C_EEPROM_ADDR ); }else { -if (crc32 (crc, buf,24 ) == *(unsigned int *)&buf[24 ]) { +if (crc32 (crc, buf,24 ) == *(unsigned char *)&buf[24 ]) {printf ("Reading MAC from EEPROM\n" );for (i =0 ; i <4 ; i++) {if (memcmp (&buf[i *6 ],"\0\0\0\0\0\0" ,6 )) {
Signature · 1 line
1.7.9.5
PATCH 4/4 mpc8323erdb: Update crc32 check of MAC
Dear Tom Rini,
Quoted 2 lines · In message <[email protected]> you wrote:
We need to cast to unsigned char, not unsigned short here to avoid a warning.
You fix the warning, but break the code.
Quoted 11 lines
Cc Michael Barkowski <[email protected]>Signed-off-by Tom Rini <[email protected]>--- board/freescale/mpc8323erdb/mpc8323erdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/freescale/mpc8323erdb/mpc8323erdb.c +0
-0
board/freescale/mpc8323erdb/mpc8323erdb.c int mac_read_from_eeprom(void) · line 198
Quoted 5 lines
board/freescale/mpc8323erdb/mpc8323erdb.c +1
-1@@ -195,7 +195,7 @@ int mac_read_from_eeprom(void)printf ("\nEEPROM @ 0x%02x read FAILED!!!\n" ,CONFIG_SYS_I2C_EEPROM_ADDR ); }else { -if (crc32 (crc, buf,24 ) == *(unsigned int *)&buf[24 ]) { +if (crc32 (crc, buf,24 ) == *(unsigned char *)&buf[24 ]) {
We need to read a 32 bit number here.
Best regards,
Wolfgang Denk
Signature · 8 lines
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 at denx.de Politician: An eel in the fundamental mud upon which the superstructure of organized society is reared. When he wriggles he mistakes the agitation of his tail for the trembling of the edifice. As compared with the statesman, he suffers the disadvantage of being alive. - Ambrose Bierce
PATCH 1/4 powerpc: Correct im_dprambase cast
In reply to Tom RiniDear Tom Rini,
Quoted 2 lines · In message <[email protected]> you wrote:
When casting
im_dprambasewe must cast to unsigned char not unsigned short.
No, this is wrong. Now you write only 8 bit where 16 bit needs to be written.
Best regards,
Wolfgang Denk
Signature · 5 lines
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 at denx.de "Never face facts; if you do, you'll never get up in the morning." - Marlo Thomas