Re: [PATCH] i2c: i2c-ocores: Use devm_request_and_ioremap()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 15, 2012 at 09:10:15AM +0200, Jean Delvare wrote:
> Hi Thierry,
> 
> On Wed,  8 Aug 2012 08:54:32 +0200, Thierry Reding wrote:
> > Replacing the devm_request_mem_region() and devm_ioremap_nocache() calls
> > by a single call to devm_request_and_ioremap() simplifies the code.
> > 
> > Signed-off-by: Thierry Reding <thierry.reding@xxxxxxxxxxxxxxxxx>
> > ---
> >  drivers/i2c/busses/i2c-ocores.c | 15 +++------------
> >  1 file changed, 3 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
> > index bffd550..1fad4ae 100644
> > --- a/drivers/i2c/busses/i2c-ocores.c
> > +++ b/drivers/i2c/busses/i2c-ocores.c
> > @@ -283,18 +283,9 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
> >  	if (!i2c)
> >  		return -ENOMEM;
> >  
> > -	if (!devm_request_mem_region(&pdev->dev, res->start,
> > -				     resource_size(res), pdev->name)) {
> > -		dev_err(&pdev->dev, "Memory region busy\n");
> > -		return -EBUSY;
> > -	}
> > -
> > -	i2c->base = devm_ioremap_nocache(&pdev->dev, res->start,
> > -					 resource_size(res));
> > -	if (!i2c->base) {
> > -		dev_err(&pdev->dev, "Unable to map registers\n");
> > -		return -EIO;
> > -	}
> > +	i2c->base = devm_request_and_ioremap(&pdev->dev, res);
> > +	if (!i2c->base)
> > +		return -EADDRNOTAVAIL;
> 
> I would suggest sticking to -EBUSY, AFAIK EADDRNOTAVAIL is for network
> address errors.

Actually the kerneldoc comment for devm_request_and_ioremap()
(lib/devres.c) explicitly lists this as the error code to return on
failure. EBUSY could be misleading since the error could just as well
come from a failed ioremap().

Thierry

Attachment: pgp4JEK8oCG6W.pgp
Description: PGP signature


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux