[i2c] [PATCH] i2c-s3c2410.c: Fix build warning

Jean Delvare khali at linux-fr.org
Thu May 10 10:37:50 CEST 2007


Hi Arnaud,

On Wed, 09 May 2007 09:31:46 +0200, Arnaud Patard (Rtp) wrote:
> Jean Delvare <khali at linux-fr.org> writes:
> 
> Hi Jean and Ben !
> 
> > Hi Ben,
> >
> > On Sun, 6 May 2007 14:51:24 +0000, Ben Dooks wrote:
> >> On Sat, May 05, 2007 at 09:58:37PM +0200, Jean Delvare wrote:
> >> > On Sat, 05 May 2007 16:02:20 +0200, Arnaud Patard (Rtp) wrote:
> >> > > 
> >> > > Fix for the following build warning :
> >> > >   CC      drivers/i2c/busses/i2c-s3c2410.o drivers/i2c/busses/i2c-s3c2410.c: In function 's3c24xx_i2c_probe':
> >> > >   drivers/i2c/busses/i2c-s3c2410.c:839: warning: format '%ld' expects type 'long int', but argument 4 has type 'resource_size_t'
> >> > > 
> >> > > Signed-off-by: Arnaud Patard <arnaud.patard at rtp-net.org>
> >> > 
> >> > > ---
> >> > > diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> >> > > index 556f244..674ca30 100644
> >> > > --- a/drivers/i2c/busses/i2c-s3c2410.c
> >> > > +++ b/drivers/i2c/busses/i2c-s3c2410.c
> >> > > @@ -836,7 +836,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
> >> > >  
> >> > >  	i2c->irq = res;
> >> > >  		
> >> > > -	dev_dbg(&pdev->dev, "irq resource %p (%ld)\n", res, res->start);
> >> > > +	dev_dbg(&pdev->dev, "irq resource %p (%zd)\n", res, res->start);
> >> > >  
> >> > >  	ret = i2c_add_adapter(&i2c->adap);
> >> > >  	if (ret < 0) {
> >> > 
> >> > I'm not sure this is the right fix. resource_size_t might be either u32
> >> > or u64 depending on CONFIG_RESOURCES_64BIT, so I suspect that you are
> >> > clearing the warning in one case but adding it in the other. As a
> >> > matter of fact, I couldn't find any other example in the kernel tree of
> >> > %zd, %zu or %zx being used to print a resource boundary.
> >> > 
> >> > So I think that it would be better to keep %ld and cast res->start to
> >> > an unsigned long. Ben, what do you think?
> >> 
> >> I think the best fix is to cast to (unsigned long long) and use %llu
> >> as this means you are not truncating 64bit resources... although why
> >> anyone would want to use 64bit resources on an ARM chip that is 32bit
> >> only is a little strange.
> >
> > long longs are costly to handle so I'd rather avoid that. This is an
> > IRQ we're talking about, so I'd be very surprised if it didn't fit in
> > 32 bits.
> >
> > I can't tell you why anyone would want to use 64-bit resources on ARM.
> > In fact I simply don't get why CONFIG_RESOURCES_64BIT exists for 32-bit
> > architectures.
> 
> Did you find an agreement on this ? I should use a cast on res->start ?

Please cast res->start to an unsigned long.

Thanks,
-- 
Jean Delvare



More information about the i2c mailing list