All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: (jz4740) Use devm_ioremap_resource()
Date: Tue, 11 Feb 2014 12:12:24 +0000	[thread overview]
Message-ID: <52FA13A8.5080208@metafoo.de> (raw)
In-Reply-To: <000701cf2722$4dba9ac0$e92fd040$%han@samsung.com>

On 02/11/2014 01:10 PM, Jingoo Han wrote:
> Use devm_ioremap_resource() in order to make the code simpler,
> and move 'struct resource *mem' from 'struct jz4740_hwmon' to
> jz4740_hwmon_probe() because the 'mem' variable is used only in
> jz4740_hwmon_probe(). Also the redundant return value check of
> platform_get_resource() is removed, because the value is checked
> by devm_ioremap_resource().
>
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>

Acked-by: Lars-Peter Clausen <lars@metafoo.de>

> ---
>   drivers/hwmon/jz4740-hwmon.c |   25 +++++--------------------
>   1 file changed, 5 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/hwmon/jz4740-hwmon.c b/drivers/hwmon/jz4740-hwmon.c
> index a183e48..7488e36 100644
> --- a/drivers/hwmon/jz4740-hwmon.c
> +++ b/drivers/hwmon/jz4740-hwmon.c
> @@ -28,7 +28,6 @@
>   #include <linux/hwmon.h>
>
>   struct jz4740_hwmon {
> -	struct resource *mem;
>   	void __iomem *base;
>
>   	int irq;
> @@ -106,6 +105,7 @@ static int jz4740_hwmon_probe(struct platform_device *pdev)
>   {
>   	int ret;
>   	struct jz4740_hwmon *hwmon;
> +	struct resource *mem;
>
>   	hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL);
>   	if (!hwmon)
> @@ -120,25 +120,10 @@ static int jz4740_hwmon_probe(struct platform_device *pdev)
>   		return hwmon->irq;
>   	}
>
> -	hwmon->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!hwmon->mem) {
> -		dev_err(&pdev->dev, "Failed to get platform mmio resource\n");
> -		return -ENOENT;
> -	}
> -
> -	hwmon->mem = devm_request_mem_region(&pdev->dev, hwmon->mem->start,
> -			resource_size(hwmon->mem), pdev->name);
> -	if (!hwmon->mem) {
> -		dev_err(&pdev->dev, "Failed to request mmio memory region\n");
> -		return -EBUSY;
> -	}
> -
> -	hwmon->base = devm_ioremap_nocache(&pdev->dev, hwmon->mem->start,
> -					   resource_size(hwmon->mem));
> -	if (!hwmon->base) {
> -		dev_err(&pdev->dev, "Failed to ioremap mmio memory\n");
> -		return -EBUSY;
> -	}
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	hwmon->base = devm_ioremap_resource(&pdev->dev, mem);
> +	if (IS_ERR(hwmon->base))
> +		return PTR_ERR(hwmon->base);
>
>   	init_completion(&hwmon->read_completion);
>   	mutex_init(&hwmon->lock);
>


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  reply	other threads:[~2014-02-11 12:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11 12:10 [lm-sensors] [PATCH] hwmon: (jz4740) Use devm_ioremap_resource() Jingoo Han
2014-02-11 12:12 ` Lars-Peter Clausen [this message]
2014-02-11 20:23 ` Guenter Roeck

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=52FA13A8.5080208@metafoo.de \
    --to=lars@metafoo.de \
    --cc=lm-sensors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.