[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20140513100334.GA27345@ulmo>
Date: Tue, 13 May 2014 12:03:35 +0200
From: Thierry Reding <thierry.reding@...il.com>
To: abdoulaye berthe <berthe.ab@...il.com>
Cc: linus.walleij@...aro.org, gnurou@...il.com,
linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] gpio: using devm functions for timberdale gpio memory
allocation This eases memory allocation and provides appropriate logging
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
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists