Patchwork [U-Boot,1/4] powerpc: Correct im_dprambase cast

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

Comments

Tom Rini - May 13, 2013, 8:31 p.m.
When casting im_dprambase we must cast to unsigned char not unsigned
short.

Signed-off-by: Tom Rini <trini@ti.com>
---
 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(-)
Wolfgang Denk - May 13, 2013, 10:37 p.m.
Dear Tom Rini,

In message <1368477117-32669-1-git-send-email-trini@ti.com> you wrote:
> When casting im_dprambase we 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

Patch

diff --git a/arch/powerpc/cpu/mpc8260/commproc.c b/arch/powerpc/cpu/mpc8260/commproc.c
index 22cef3e..9d6c8e2 100644
--- a/arch/powerpc/cpu/mpc8260/commproc.c
+++ b/arch/powerpc/cpu/mpc8260/commproc.c
@@ -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
 }
 
diff --git a/arch/powerpc/cpu/mpc8260/cpu.c b/arch/powerpc/cpu/mpc8260/cpu.c
index f8bc5a9..26b3e8d 100644
--- a/arch/powerpc/cpu/mpc8260/cpu.c
+++ b/arch/powerpc/cpu/mpc8260/cpu.c
@@ -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:
diff --git a/arch/powerpc/cpu/mpc8260/i2c.c b/arch/powerpc/cpu/mpc8260/i2c.c
index b720b1f..48917ea 100644
--- a/arch/powerpc/cpu/mpc8260/i2c.c
+++ b/arch/powerpc/cpu/mpc8260/i2c.c
@@ -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;
diff --git a/arch/powerpc/cpu/mpc8260/serial_smc.c b/arch/powerpc/cpu/mpc8260/serial_smc.c
index feba1f6..d57c44e 100644
--- a/arch/powerpc/cpu/mpc8260/serial_smc.c
+++ b/arch/powerpc/cpu/mpc8260/serial_smc.c
@@ -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. */
diff --git a/arch/powerpc/cpu/mpc8260/spi.c b/arch/powerpc/cpu/mpc8260/spi.c
index dc98ea7..b5ead9f 100644
--- a/arch/powerpc/cpu/mpc8260/spi.c
+++ b/arch/powerpc/cpu/mpc8260/spi.c
@@ -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 */
diff --git a/common/cmd_immap.c b/common/cmd_immap.c
index fdf9489..2cee082 100644
--- a/common/cmd_immap.c
+++ b/common/cmd_immap.c
@@ -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
diff --git a/examples/standalone/mem_to_mem_idma2intr.c b/examples/standalone/mem_to_mem_idma2intr.c
index e466c90..ee9ca76 100644
--- a/examples/standalone/mem_to_mem_idma2intr.c
+++ b/examples/standalone/mem_to_mem_idma2intr.c
@@ -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 */