public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: Jean Delvare <khali@linux-fr.org>
Cc: Peter Korsgaard <jacmet@sunsite.dk>,
	"Ben Dooks (embedded platforms)" <ben-linux@fluff.org>,
	"Wolfram Sang (embedded platforms)" <w.sang@pengutronix.de>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: i2c-ocores: Use devm_request_and_ioremap()
Date: Mon, 15 Oct 2012 09:21:41 +0200	[thread overview]
Message-ID: <20121015072141.GA18741@avionic-0098.mockup.avionic-design.de> (raw)
In-Reply-To: <20121015091015.2887fcb9@endymion.delvare>

[-- Attachment #1: Type: text/plain, Size: 1718 bytes --]

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@avionic-design.de>
> > ---
> >  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 #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2012-10-15  7:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-08  6:54 [PATCH] i2c: i2c-ocores: Use devm_request_and_ioremap() Thierry Reding
2012-10-15  7:10 ` Jean Delvare
2012-10-15  7:21   ` Thierry Reding [this message]
2012-10-15  7:34     ` Jean Delvare
2012-11-13 11:19 ` Wolfram Sang

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=20121015072141.GA18741@avionic-0098.mockup.avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --cc=ben-linux@fluff.org \
    --cc=jacmet@sunsite.dk \
    --cc=khali@linux-fr.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=w.sang@pengutronix.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