[U-Boot] [Patch V2 1/4] spi: fsl_qspi: fix compile warning for 64-bit platform

Gong Q.Y. Qianyu.Gong at freescale.com
Wed Dec 16 12:44:38 CET 2015


> -----Original Message-----
> From: Jagan Teki [mailto:jteki at openedev.com]
> Sent: Wednesday, December 16, 2015 12:55 AM
> To: Gong Qianyu-B52263
> Cc: u-boot at lists.denx.de
> Subject: Re: [U-Boot] [Patch V2 1/4] spi: fsl_qspi: fix compile warning
> for 64-bit platform
> 
> On 15 December 2015 at 15:59, Gong Qianyu <Qianyu.Gong at freescale.com>
> wrote:
> > This patch fixes the following compile warning:
> > drivers/spi/fsl_qspi.c: In function 'fsl_qspi_probe':
> > drivers/spi/fsl_qspi.c:937:15:
> >   warning: cast to pointer from integer of different size
> >                                          [-Wint-to-pointer-cast]
> >   priv->regs = (struct fsl_qspi_regs *)plat->reg_base;
> >                ^
> >
> > Signed-off-by: Gong Qianyu <Qianyu.Gong at freescale.com>
> > ---
> > V2:
> >  - No change.
> >
> >  drivers/spi/fsl_qspi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index
> > ed39114..9f296c1 100644
> > --- a/drivers/spi/fsl_qspi.c
> > +++ b/drivers/spi/fsl_qspi.c
> > @@ -931,7 +931,7 @@ static int fsl_qspi_probe(struct udevice *bus)
> >
> >         dm_spi_bus->max_hz = plat->speed_hz;
> >
> > -       priv->regs = (struct fsl_qspi_regs *)plat->reg_base;
> > +       priv->regs = (struct fsl_qspi_regs *)(unsigned
> > + long)plat->reg_base;
> 
> What about using fdtdec_get_addr instead of typecasting long?
> 
> thanks!
> --
> Jagan.

But the reg_base could be a 32-bit type on 64-bit platform. Then the 
fdtdec_get_addr would return a wrong value which actually gets 64 bits
from the node. Or else we still have to convert it.

So I think just making the cast explicit is easier to look at.

Regards,
Qianyu


More information about the U-Boot mailing list