public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
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, 24 Sep 2015 21:33:57 -0500	[thread overview]
Message-ID: <1443148437.32298.101.camel@freescale.com> (raw)
In-Reply-To: <CY1PR0301MB07806E5378A59E98B459CB188B420@CY1PR0301MB0780.namprd03.prod.outlook.com>

On Thu, 2015-09-24 at 21:22 -0500, Hou Zhiqiang-B48286 wrote:
> 
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: 2015?9?18? 2:14
> > To: Gong Qianyu-B52263
> > Cc: u-boot at lists.denx.de; Hu Mingkai-B21284; Sun York-R58495; Hou
> > Zhiqiang-B48286; Song Wenbin-B53747; Xie Shaohui-B21989; Wood Scott-
> > B07421
> > Subject: Re: [Patch v2 08/16] net/fm: fix compile warnings for 64-bit
> > platform
> > 
> > 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.
> > 
>  
> The muram is a region included in CCSR.
> So does we take muram >= 4GiB into account make sense?

The fact that currently, we run U-Boot as 32-bit on platforms where CCSR is 
>= 4GiB is not a good excuse to be sloppy with types.

-Scott

  reply	other threads:[~2015-09-25  2:33 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
2015-09-25  2:22     ` Hou Zhiqiang
2015-09-25  2:33       ` Scott Wood [this message]
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=1443148437.32298.101.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox