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

Ben Dooks ben-linux at fluff.org
Sun May 6 16:51:24 CEST 2007


On Sat, May 05, 2007 at 09:58:37PM +0200, Jean Delvare wrote:
> Hi Arnaud,
> 
> 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.

-- 
Ben (ben at fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'



More information about the i2c mailing list