linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: abdoulaye berthe <berthe.ab@gmail.com>
Cc: linus.walleij@linaro.org, gnurou@gmail.com,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio: using devm functions for timberdale gpio memory allocation This eases memory allocation and provides appropriate logging
Date: Tue, 13 May 2014 12:03:35 +0200	[thread overview]
Message-ID: <20140513100334.GA27345@ulmo> (raw)
In-Reply-To: <1399944102-9089-1-git-send-email-berthe.ab@gmail.com>

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

On Tue, May 13, 2014 at 03:21:42AM +0200, abdoulaye berthe wrote:
[...]
> diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
[...]
>  	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!iomem) {
> -		err = -EINVAL;
> -		goto err_mem;
> +		dev_err(dev, "Unable to get resource\n");
> +		return -EINVAL;
>  	}
[...]
> -	if (!request_mem_region(iomem->start, resource_size(iomem),
> -		DRIVER_NAME)) {
> -		err = -EBUSY;
> -		goto err_request;
> +	if (!devm_request_mem_region(dev, iomem->start, resource_size(iomem),
> +				     DRIVER_NAME)) {
> +		dev_err(dev, "Region already claimed\n");
> +		return -EBUSY;
>  	}
>  
> -	tgpio->membase = ioremap(iomem->start, resource_size(iomem));
> +	tgpio->membase = devm_ioremap(dev, iomem->start, resource_size(iomem));
>  	if (!tgpio->membase) {
> -		err = -ENOMEM;
> -		goto err_ioremap;
> +		dev_err(dev, "Cannot ioremap\n");
> +		return -ENOMEM;
>  	}

The above could be further simplified to:

	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	tgpio->membase = devm_ioremap_resource(&pdev->dev, iomem);
	if (IS_ERR(tgpio->membase))
		return PTR_ERR(tgpio->membase);

Where devm_ioremap_resource() already provides error messages as
appropriate.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

      parent reply	other threads:[~2014-05-13 10:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13  1:21 [PATCH] gpio: using devm functions for timberdale gpio memory allocation This eases memory allocation and provides appropriate logging abdoulaye berthe
2014-05-13  7:55 ` Alexandre Courbot
2014-05-13  9:42 ` Linus Walleij
2014-05-13 10:03 ` Thierry Reding [this message]

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=20140513100334.GA27345@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=berthe.ab@gmail.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).