All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V5 27/31] net: fec: fix build warnings for 64bits support
Date: Wed, 10 Jan 2018 13:20:44 +0800	[thread overview]
Message-ID: <20180110052048.4425-28-peng.fan@nxp.com> (raw)
In-Reply-To: <20180110052048.4425-1-peng.fan@nxp.com>

From: Ye Li <ye.li@nxp.com>

When building for 64bits system, we get some warnings about type
cast between pointer and integer. This patch eliminates the warnings
by using ulong/long type which is 32bits on 32bits system or 64bits on
64bits system.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/net/fec_mxc.c | 74 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 43 insertions(+), 31 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 4cbc8cbbfd..ff7ad91116 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -284,7 +284,7 @@ static int fec_tx_task_disable(struct fec_priv *fec)
 static void fec_rbd_init(struct fec_priv *fec, int count, int dsize)
 {
 	uint32_t size;
-	uint8_t *data;
+	ulong data;
 	int i;
 
 	/*
@@ -293,9 +293,9 @@ static void fec_rbd_init(struct fec_priv *fec, int count, int dsize)
 	 */
 	size = roundup(dsize, ARCH_DMA_MINALIGN);
 	for (i = 0; i < count; i++) {
-		data = (uint8_t *)fec->rbd_base[i].data_pointer;
-		memset(data, 0, dsize);
-		flush_dcache_range((uint32_t)data, (uint32_t)data + size);
+		data = fec->rbd_base[i].data_pointer;
+		memset((void *)data, 0, dsize);
+		flush_dcache_range(data, data + size);
 
 		fec->rbd_base[i].status = FEC_RBD_EMPTY;
 		fec->rbd_base[i].data_length = 0;
@@ -305,8 +305,8 @@ static void fec_rbd_init(struct fec_priv *fec, int count, int dsize)
 	fec->rbd_base[i - 1].status = FEC_RBD_WRAP | FEC_RBD_EMPTY;
 	fec->rbd_index = 0;
 
-	flush_dcache_range((unsigned)fec->rbd_base,
-			   (unsigned)fec->rbd_base + size);
+	flush_dcache_range((ulong)fec->rbd_base,
+			   (ulong)fec->rbd_base + size);
 }
 
 /**
@@ -323,7 +323,7 @@ static void fec_rbd_init(struct fec_priv *fec, int count, int dsize)
  */
 static void fec_tbd_init(struct fec_priv *fec)
 {
-	unsigned addr = (unsigned)fec->tbd_base;
+	ulong addr = (ulong)fec->tbd_base;
 	unsigned size = roundup(2 * sizeof(struct fec_bd),
 				ARCH_DMA_MINALIGN);
 
@@ -423,7 +423,7 @@ static int fec_open(struct eth_device *edev)
 	struct fec_priv *fec = (struct fec_priv *)edev->priv;
 #endif
 	int speed;
-	uint32_t addr, size;
+	ulong addr, size;
 	int i;
 
 	debug("fec_open: fec_open(dev)\n");
@@ -439,7 +439,7 @@ static int fec_open(struct eth_device *edev)
 	/* Flush the descriptors into RAM */
 	size = roundup(FEC_RBD_NUM * sizeof(struct fec_bd),
 			ARCH_DMA_MINALIGN);
-	addr = (uint32_t)fec->rbd_base;
+	addr = (ulong)fec->rbd_base;
 	flush_dcache_range(addr, addr + size);
 
 #ifdef FEC_QUIRK_ENET_MAC
@@ -533,8 +533,9 @@ static int fec_init(struct eth_device *dev, bd_t *bd)
 #else
 	struct fec_priv *fec = (struct fec_priv *)dev->priv;
 #endif
-	uint32_t mib_ptr = (uint32_t)&fec->eth->rmon_t_drop;
-	int i;
+	u8 *mib_ptr = (uint8_t *)&fec->eth->rmon_t_drop;
+	u8 *i;
+	ulong addr;
 
 	/* Initialize MAC address */
 #ifdef CONFIG_DM_ETH
@@ -574,8 +575,12 @@ static int fec_init(struct eth_device *dev, bd_t *bd)
 
 	/* size and address of each buffer */
 	writel(FEC_MAX_PKT_SIZE, &fec->eth->emrbr);
-	writel((uint32_t)fec->tbd_base, &fec->eth->etdsr);
-	writel((uint32_t)fec->rbd_base, &fec->eth->erdsr);
+
+	addr = (ulong)fec->tbd_base;
+	writel((uint32_t)addr, &fec->eth->etdsr);
+
+	addr = (ulong)fec->rbd_base;
+	writel((uint32_t)addr, &fec->eth->erdsr);
 
 #ifndef CONFIG_PHYLIB
 	if (fec->xcv_type != SEVENWIRE)
@@ -640,8 +645,8 @@ static int fec_send(struct eth_device *dev, void *packet, int length)
 #endif
 {
 	unsigned int status;
-	uint32_t size, end;
-	uint32_t addr;
+	u32 size;
+	ulong addr, end;
 	int timeout = FEC_XFER_TIMEOUT;
 	int ret = 0;
 
@@ -672,13 +677,13 @@ static int fec_send(struct eth_device *dev, void *packet, int length)
 	swap_packet((uint32_t *)packet, length);
 #endif
 
-	addr = (uint32_t)packet;
+	addr = (ulong)packet;
 	end = roundup(addr + length, ARCH_DMA_MINALIGN);
 	addr &= ~(ARCH_DMA_MINALIGN - 1);
 	flush_dcache_range(addr, end);
 
 	writew(length, &fec->tbd_base[fec->tbd_index].data_length);
-	writel(addr, &fec->tbd_base[fec->tbd_index].data_pointer);
+	writel((uint32_t)addr, &fec->tbd_base[fec->tbd_index].data_pointer);
 
 	/*
 	 * update BD's status now
@@ -698,7 +703,7 @@ static int fec_send(struct eth_device *dev, void *packet, int length)
 	 * can start DMA.
 	 */
 	size = roundup(2 * sizeof(struct fec_bd), ARCH_DMA_MINALIGN);
-	addr = (uint32_t)fec->tbd_base;
+	addr = (ulong)fec->tbd_base;
 	flush_dcache_range(addr, addr + size);
 
 	/*
@@ -799,7 +804,7 @@ static int fec_recv(struct eth_device *dev)
 	unsigned long ievent;
 	int frame_length, len = 0;
 	uint16_t bd_status;
-	uint32_t addr, size, end;
+	ulong addr, size, end;
 	int i;
 	ALLOC_CACHE_ALIGN_BUFFER(uchar, buff, FEC_MAX_PKT_SIZE);
 
@@ -854,7 +859,7 @@ static int fec_recv(struct eth_device *dev)
 	 * the descriptor. The solution is to mark the whole cache line when all
 	 * descriptors in the cache line are processed.
 	 */
-	addr = (uint32_t)rbd;
+	addr = (ulong)rbd;
 	addr &= ~(ARCH_DMA_MINALIGN - 1);
 	size = roundup(sizeof(struct fec_bd), ARCH_DMA_MINALIGN);
 	invalidate_dcache_range(addr, addr + size);
@@ -882,8 +887,8 @@ static int fec_recv(struct eth_device *dev)
 			len = frame_length;
 		} else {
 			if (bd_status & FEC_RBD_ERR)
-				debug("error frame: 0x%08x 0x%08x\n",
-				       addr, bd_status);
+				debug("error frame: 0x%08lx 0x%08x\n",
+				      addr, bd_status);
 		}
 
 		/*
@@ -895,7 +900,7 @@ static int fec_recv(struct eth_device *dev)
 		size = RXDESC_PER_CACHELINE - 1;
 		if ((fec->rbd_index & size) == size) {
 			i = fec->rbd_index - size;
-			addr = (uint32_t)&fec->rbd_base[i];
+			addr = (ulong)&fec->rbd_base[i];
 			for (; i <= fec->rbd_index ; i++) {
 				fec_rbd_clean(i == (FEC_RBD_NUM - 1),
 					      &fec->rbd_base[i]);
@@ -922,6 +927,7 @@ static int fec_alloc_descs(struct fec_priv *fec)
 	unsigned int size;
 	int i;
 	uint8_t *data;
+	ulong addr;
 
 	/* Allocate TX descriptors. */
 	size = roundup(2 * sizeof(struct fec_bd), ARCH_DMA_MINALIGN);
@@ -950,11 +956,12 @@ static int fec_alloc_descs(struct fec_priv *fec)
 
 		memset(data, 0, size);
 
-		fec->rbd_base[i].data_pointer = (uint32_t)data;
+		addr = (ulong)data;
+		fec->rbd_base[i].data_pointer = (uint32_t)addr;
 		fec->rbd_base[i].status = FEC_RBD_EMPTY;
 		fec->rbd_base[i].data_length = 0;
 		/* Flush the buffer to memory. */
-		flush_dcache_range((uint32_t)data, (uint32_t)data + size);
+		flush_dcache_range(addr, addr + size);
 	}
 
 	/* Mark the last RBD to close the ring. */
@@ -966,8 +973,10 @@ static int fec_alloc_descs(struct fec_priv *fec)
 	return 0;
 
 err_ring:
-	for (; i >= 0; i--)
-		free((void *)fec->rbd_base[i].data_pointer);
+	for (; i >= 0; i--) {
+		addr = fec->rbd_base[i].data_pointer;
+		free((void *)addr);
+	}
 	free(fec->rbd_base);
 err_rx:
 	free(fec->tbd_base);
@@ -978,9 +987,12 @@ err_tx:
 static void fec_free_descs(struct fec_priv *fec)
 {
 	int i;
+	ulong addr;
 
-	for (i = 0; i < FEC_RBD_NUM; i++)
-		free((void *)fec->rbd_base[i].data_pointer);
+	for (i = 0; i < FEC_RBD_NUM; i++) {
+		addr = fec->rbd_base[i].data_pointer;
+		free((void *)addr);
+	}
 	free(fec->rbd_base);
 	free(fec->tbd_base);
 }
@@ -995,7 +1007,7 @@ struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id)
 	struct fec_priv *priv = dev_get_priv(dev);
 	struct ethernet_regs *eth = priv->eth;
 #else
-	struct ethernet_regs *eth = (struct ethernet_regs *)base_addr;
+	struct ethernet_regs *eth = (struct ethernet_regs *)(ulong)base_addr;
 #endif
 	struct mii_dev *bus;
 	int ret;
@@ -1065,7 +1077,7 @@ static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
 	edev->halt = fec_halt;
 	edev->write_hwaddr = fec_set_hwaddr;
 
-	fec->eth = (struct ethernet_regs *)base_addr;
+	fec->eth = (struct ethernet_regs *)(ulong)base_addr;
 	fec->bd = bd;
 
 	fec->xcv_type = CONFIG_FEC_XCV_TYPE;
-- 
2.14.1

  parent reply	other threads:[~2018-01-10  5:20 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10  5:20 [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 01/31] arm: imx: Rework i.MX specific commands to be excluded from SPL Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 02/31] imx: add i.MX8M into Kconfig Peng Fan
2018-01-21 15:53   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 03/31] imx: mx8m: add register definition header file Peng Fan
2018-01-21 15:54   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 04/31] imx: mx8m: add pin " Peng Fan
2018-01-21 15:53   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 05/31] imx: mx8m: add clock driver Peng Fan
2018-01-21 16:28   ` Stefano Babic
2018-01-23  8:58     ` Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 06/31] imx: add sip function Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 07/31] imx: boot_mode: add USB_BOOT entry Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 08/31] imx: cpu: update cpu file to support i.MX8M Peng Fan
2018-01-21 16:28   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 09/31] imx: spl: implement spl_boot_device for i.MX8M Peng Fan
2018-01-21 16:29   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 10/31] imx: add i.MX8MQ SoC Revision and is_mx8m helper Peng Fan
2018-01-21 16:30   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 11/31] imx: add pad settings bit definition for i.MX8M Peng Fan
2018-01-21 16:30   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 12/31] imx: cpu: move speed/temp to common cpu Peng Fan
2018-01-21 16:30   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 13/31] imx: cpu: add cpu speed/grade for i.MX8M Peng Fan
2018-01-21 16:31   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 14/31] imx: refactor imx_get_mac_from_fuse Peng Fan
2018-01-21 16:31   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 15/31] imx: cleanup bootaux Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 16/31] imx: bootaux: support i.MX8M Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 17/31] imx: mx7: move get_boot_device to cpu.c Peng Fan
2018-01-21 16:33   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 18/31] imx: cpu: support get_boot_device for i.MX8M Peng Fan
2018-01-21 16:33   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 19/31] imx: mx7: move mmc env code to mmc_env.c Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 20/31] imx: mx8m: add soc related settings and files Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 21/31] imx: makefile: compile files for i.MX8M Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 22/31] misc: ocotp: add i.MX8M support Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 23/31] mmc: fsl_esdhc: support i.MX8M Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 24/31] imx: lcdif: include i.MX8M Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 25/31] gpio: mxc: add i.MX8M support Peng Fan
2018-01-21 16:33   ` Stefano Babic
2018-01-10  5:20 ` [U-Boot] [PATCH V5 26/31] net: fec: do not access reserved register for i.MX8M Peng Fan
2018-01-21 16:34   ` Stefano Babic
2018-01-10  5:20 ` Peng Fan [this message]
2018-01-10  5:20 ` [U-Boot] [PATCH V5 28/31] imx: imx8mq: add dtsi file Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 29/31] power: pmic/regulator allow dm be omitted by SPL Peng Fan
2018-01-17 12:16   ` Jaehoon Chung
2018-01-10  5:20 ` [U-Boot] [PATCH V5 30/31] imx: mx8m: add ddr controller memory map Peng Fan
2018-01-10  5:20 ` [U-Boot] [PATCH V5 31/31] imx: add i.MX8MQ EVK support Peng Fan
2018-01-22 14:00   ` Stefano Babic
2018-01-22 15:23     ` Fabio Estevam
2018-01-22 16:20       ` Stefano Babic
2018-01-31 10:25         ` Fabio Estevam
2018-01-31 10:30           ` Stefano Babic
2018-02-04  9:42             ` Stefano Babic
2018-02-22 16:40               ` Fabio Estevam
2018-02-23  6:02                 ` Peng Fan
2018-02-23 13:37                   ` Fabio Estevam
2018-03-20 19:46                   ` Fabio Estevam
2018-03-21  9:07                     ` Peng Fan
2018-02-23  9:46                 ` Stefano Babic
2018-02-23 13:21                   ` Fabio Estevam
2018-01-23  2:24     ` Peng Fan
2018-01-23  9:52       ` Stefano Babic
     [not found]   ` <88fee187-cf7f-cd2a-659a-eb67ba814178@denx.de>
2018-01-23  1:54     ` Peng Fan
2018-01-23 10:02       ` Stefano Babic
2018-06-20  8:57   ` Paul Kocialkowski
2018-06-20 11:37     ` Andre Przywara
2018-06-20 11:54       ` Paul Kocialkowski
2018-06-20 12:08         ` Paul Kocialkowski
2018-06-20 11:56     ` Peng Fan
2018-06-20 15:24       ` Paul Kocialkowski
2018-06-20 16:12         ` Andre Przywara
2018-06-20 17:16           ` Paul Kocialkowski
2018-06-21  1:07             ` André Przywara
2018-06-21 18:29               ` Todd Weaver
2018-06-21  7:08           ` Wolfgang Denk
2018-01-10 13:08 ` [U-Boot] [PATCH V5 00/31] imx: add i.MX8M support and i.MX8MQ EVK Diego Dorta
2018-01-11  1:16   ` Peng Fan
2018-01-11 12:36     ` Diego Dorta
2018-01-13 10:55       ` Peng Fan
2018-01-16 12:15         ` Diego Dorta
2018-01-16 12:25           ` Peng Fan
2018-01-17 14:59             ` Diego Dorta
2018-01-18  1:13               ` Peng Fan
2018-01-18 14:58                 ` Diego Dorta
2018-01-18  1:24 ` Peng Fan
2018-01-18  8:50   ` Stefano Babic
2018-01-18  8:58     ` Peng Fan
2018-01-22 13:04 ` Diego Dorta
2018-08-31  6:27   ` Jon Nettleton
2018-09-06 13:37     ` Fabio Estevam
2018-09-07  6:03       ` Jon Nettleton
2018-09-07  6:09         ` Peng Fan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180110052048.4425-28-peng.fan@nxp.com \
    --to=peng.fan@nxp.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.