From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [Patch v2 08/16] net/fm: fix compile warnings for 64-bit platform
Date: Thu, 17 Sep 2015 13:13:44 -0500 [thread overview]
Message-ID: <1442513624.19102.55.camel@freescale.com> (raw)
In-Reply-To: <1442473613-17374-5-git-send-email-Qianyu.Gong@freescale.com>
On Thu, 2015-09-17 at 15:06 +0800, Gong Qianyu wrote:
> 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@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;
This will still truncate the address at 32 bits. It needs to be ~0x3UL.
> 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);
Make fm_muram_alloc() return a pointer instead. If muram were >= 4 GiB the
above would fail.
> 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);
Get rid of the u32 cast -- again, if the muram base were above >= 4 GiB this
would fail because you're dropping the high bits before the subtraction
rather than after.
>
> /* 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++;
Use virt_to_phys() and lower_32_bits(). Is there a "hi" register to handle
the upper 32 bits?
Likewise elsewhere. Don't just apply the minimum bandage to get rid of the
warning. Make the code actually be 64-bit clean.
-Scott
next prev parent reply other threads:[~2015-09-17 18:13 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 7:06 [U-Boot] [Patch v2 04/16] net/fm: bug fix when CONFIG_PHYLIB not defined Gong Qianyu
2015-09-17 7:06 ` [U-Boot] [Patch v2 05/16] net: Move some header files to include/ Gong Qianyu
2015-09-17 18:06 ` Scott Wood
2015-09-17 7:06 ` [U-Boot] [Patch v2 06/16] net/fm: Add QSGMII PCS init Gong Qianyu
2015-09-17 7:06 ` [U-Boot] [Patch v2 07/16] net/fm: fix MDIO controller base on FMAN2 Gong Qianyu
2015-09-17 18:04 ` Scott Wood
2015-09-18 3:49 ` Shaohui Xie
2015-09-18 5:13 ` Scott Wood
2015-09-25 10:51 ` Hu Vincent
2015-09-17 7:06 ` [U-Boot] [Patch v2 08/16] net/fm: fix compile warnings for 64-bit platform Gong Qianyu
2015-09-17 18:13 ` Scott Wood [this message]
2015-09-25 2:22 ` Hou Zhiqiang
2015-09-25 2:33 ` Scott Wood
2015-09-25 3:49 ` Hou Zhiqiang
2015-09-17 7:06 ` [U-Boot] [Patch v2 09/16] ARMv8/FSL_LSCH2: Add FSL_LSCH2 SoC Gong Qianyu
2015-09-21 17:27 ` York Sun
2015-09-25 12:28 ` Hu Vincent
2015-09-25 14:53 ` York Sun
2015-09-27 4:10 ` Kushwaha Prabhakar
2015-09-28 7:23 ` Hu Vincent
2015-09-17 7:06 ` [U-Boot] [Patch v2 10/16] ARMv8/ls1043ardb: Add LS1043ARDB board support Gong Qianyu
2015-09-21 17:27 ` York Sun
2015-09-17 7:06 ` [U-Boot] [Patch v2 11/16] armv8/ls1043ardb: Add nand boot support Gong Qianyu
2015-09-17 20:16 ` Scott Wood
2015-09-18 3:36 ` Gong Q.Y.
2015-09-18 5:14 ` Scott Wood
2015-09-17 7:06 ` [U-Boot] [Patch v2 12/16] armv8/ls1043ardb: Add cpld command to boot from nand Gong Qianyu
2015-09-21 17:27 ` York Sun
2015-09-17 7:06 ` [U-Boot] [Patch v2 13/16] armv8/ls1043a: Add Fman support Gong Qianyu
2015-09-17 7:06 ` [U-Boot] [Patch v2 14/16] armv8/ls1043ardb: esdhc: Add esdhc support for ls1043ardb Gong Qianyu
2015-09-17 7:06 ` [U-Boot] [Patch v2 15/16] armv8/ls1043ardb: Add sd boot support Gong Qianyu
2015-09-17 7:06 ` [U-Boot] [Patch v2 16/16] armv8/ls1043ardb: Add cpld command to boot from sd Gong Qianyu
2015-09-21 17:27 ` York Sun
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=1442513624.19102.55.camel@freescale.com \
--to=scottwood@freescale.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.