[U-Boot] [PATCH 06/14] net/fm: fix compile warnings for 64-bit platform

Gong Qianyu Qianyu.Gong at freescale.com
Fri Sep 11 13:02:23 CEST 2015


This patch fixes such compile warnings:

drivers/net/fm/eth.c: In function 'fm_eth_recv':
drivers/net/fm/eth.c:549:11: warning: cast to pointer from integer of
different size [-Wint-to-pointer-cast]
	data = (u8 *)in_be32(&rxbd->buf_ptr_lo);
drivers/net/fm/fm.c: In function 'fm_muram_alloc':
drivers/net/fm/fm.c:52:9: warning: cast to pointer from integer of
different size [-Wint-to-pointer-cast]
	memset((void *)ret, 0, size);
drivers/net/fm/fm.c: In function 'fm_init_muram':
drivers/net/fm/fm.c:59:13: warning: cast from pointer to integer of
different size [-Wpointer-to-int-cast]
	u32 base = (u32)reg;

Just make the cast explicit for them.

Signed-off-by: Gong Qianyu <Qianyu.Gong at freescale.com>
---
 drivers/net/fm/eth.c | 31 ++++++++++++++++---------------
 drivers/net/fm/fm.c  |  4 ++--
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index 12eb9b8..6ef0afb 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -120,12 +120,12 @@ static int tgec_is_fibre(struct eth_device *dev)
 
 static u16 muram_readw(u16 *addr)
 {
-	u32 base = (u32)addr & ~0x3;
+	ulong base = (ulong)addr & ~0x3;
 	u32 val32 = in_be32((u32 *)base);
 	int byte_pos;
 	u16 ret;
 
-	byte_pos = (u32)addr & 0x3;
+	byte_pos = (ulong)addr & 0x3;
 	if (byte_pos)
 		ret = (u16)(val32 & 0x0000ffff);
 	else
@@ -136,12 +136,12 @@ static u16 muram_readw(u16 *addr)
 
 static void muram_writew(u16 *addr, u16 val)
 {
-	u32 base = (u32)addr & ~0x3;
+	ulong base = (ulong)addr & ~0x3;
 	u32 org32 = in_be32((u32 *)base);
 	u32 val32;
 	int byte_pos;
 
-	byte_pos = (u32)addr & 0x3;
+	byte_pos = (ulong)addr & 0x3;
 	if (byte_pos)
 		val32 = (org32 & 0xffff0000) | val;
 	else
@@ -217,12 +217,12 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	int i;
 
 	/* alloc global parameter ram at MURAM */
-	pram = (struct fm_port_global_pram *)fm_muram_alloc(fm_eth->fm_index,
-		FM_PRAM_SIZE, FM_PRAM_ALIGN);
+	pram = (struct fm_port_global_pram *)(ulong)fm_muram_alloc(
+			fm_eth->fm_index, FM_PRAM_SIZE, FM_PRAM_ALIGN);
 	fm_eth->rx_pram = pram;
 
 	/* parameter page offset to MURAM */
-	pram_page_offset = (u32)pram - fm_muram_base(fm_eth->fm_index);
+	pram_page_offset = (u32)(ulong)pram - fm_muram_base(fm_eth->fm_index);
 
 	/* enable global mode- snooping data buffers and BDs */
 	out_be32(&pram->mode, PRAM_MODE_GLOBAL);
@@ -258,7 +258,8 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 		muram_writew(&rxbd->status, RxBD_EMPTY);
 		muram_writew(&rxbd->len, 0);
 		muram_writew(&rxbd->buf_ptr_hi, 0);
-		out_be32(&rxbd->buf_ptr_lo, (u32)rx_buf_pool + i * MAX_RXBUF_LEN);
+		out_be32(&rxbd->buf_ptr_lo, (u32)(ulong)rx_buf_pool +
+							i * MAX_RXBUF_LEN);
 		rxbd++;
 	}
 
@@ -266,7 +267,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	rxqd = &pram->rxqd;
 	muram_writew(&rxqd->gen, 0);
 	muram_writew(&rxqd->bd_ring_base_hi, 0);
-	out_be32(&rxqd->bd_ring_base_lo, (u32)rx_bd_ring_base);
+	out_be32(&rxqd->bd_ring_base_lo, (u32)(ulong)rx_bd_ring_base);
 	muram_writew(&rxqd->bd_ring_size, sizeof(struct fm_port_bd)
 			* RX_BD_RING_SIZE);
 	muram_writew(&rxqd->offset_in, 0);
@@ -289,12 +290,12 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 	int i;
 
 	/* alloc global parameter ram at MURAM */
-	pram = (struct fm_port_global_pram *)fm_muram_alloc(fm_eth->fm_index,
-		FM_PRAM_SIZE, FM_PRAM_ALIGN);
+	pram = (struct fm_port_global_pram *)(ulong)fm_muram_alloc(
+			fm_eth->fm_index, FM_PRAM_SIZE, FM_PRAM_ALIGN);
 	fm_eth->tx_pram = pram;
 
 	/* parameter page offset to MURAM */
-	pram_page_offset = (u32)pram - fm_muram_base(fm_eth->fm_index);
+	pram_page_offset = (u32)(ulong)pram - fm_muram_base(fm_eth->fm_index);
 
 	/* enable global mode- snooping data buffers and BDs */
 	out_be32(&pram->mode, PRAM_MODE_GLOBAL);
@@ -326,7 +327,7 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 	/* set the Tx queue decriptor */
 	txqd = &pram->txqd;
 	muram_writew(&txqd->bd_ring_base_hi, 0);
-	out_be32(&txqd->bd_ring_base_lo, (u32)tx_bd_ring_base);
+	out_be32(&txqd->bd_ring_base_lo, (u32)(ulong)tx_bd_ring_base);
 	muram_writew(&txqd->bd_ring_size, sizeof(struct fm_port_bd)
 			* TX_BD_RING_SIZE);
 	muram_writew(&txqd->offset_in, 0);
@@ -494,7 +495,7 @@ static int fm_eth_send(struct eth_device *dev, void *buf, int len)
 	}
 	/* setup TxBD */
 	muram_writew(&txbd->buf_ptr_hi, 0);
-	out_be32(&txbd->buf_ptr_lo, (u32)buf);
+	out_be32(&txbd->buf_ptr_lo, (u32)(ulong)buf);
 	muram_writew(&txbd->len, len);
 	mb();
 	muram_writew(&txbd->status, TxBD_READY | TxBD_LAST);
@@ -546,7 +547,7 @@ static int fm_eth_recv(struct eth_device *dev)
 
 	while (!(status & RxBD_EMPTY)) {
 		if (!(status & RxBD_ERROR)) {
-			data = (u8 *)in_be32(&rxbd->buf_ptr_lo);
+			data = (u8 *)(ulong)in_be32(&rxbd->buf_ptr_lo);
 			len = muram_readw(&rxbd->len);
 			net_process_received_packet(data, len);
 		} else {
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index eb0eb3d..33332d6 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -49,14 +49,14 @@ u32 fm_muram_alloc(int fm_idx, u32 size, u32 align)
 
 	ret = muram[fm_idx].alloc;
 	muram[fm_idx].alloc += size;
-	memset((void *)ret, 0, size);
+	memset((void *)(ulong)ret, 0, size);
 
 	return ret;
 }
 
 static void fm_init_muram(int fm_idx, void *reg)
 {
-	u32 base = (u32)reg;
+	u32 base = (u32)(ulong)reg;
 
 	muram[fm_idx].base = base;
 	muram[fm_idx].size = CONFIG_SYS_FM_MURAM_SIZE;
-- 
2.1.0.27.g96db324



More information about the U-Boot mailing list