* [PATCH] staging: iio: Introduce the use of devm_ioremap_resource
@ 2014-07-01 18:44 Himangi Saraogi
2014-07-07 12:36 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Himangi Saraogi @ 2014-07-01 18:44 UTC (permalink / raw)
To: Jonathan Cameron, Greg Kroah-Hartman, linux-iio, devel,
linux-kernel
Cc: julia.lawall
This patch introduces the use of devm_ioremap_resource. It does away
with call to request_mem_region and the error checking on
platform_get_resource. Also, the calls to free the allocated resources
like release_mem_region and iounmap are done away with. The ret variable
in the probe function is also eliminated. Also, a bug is fixed as the
goto in the error handling of request_mem_region should not have
called release_mem_region which releases a resource that has not been
allocated.
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
drivers/staging/iio/adc/ad7606_par.c | 37 ++++++------------------------------
1 file changed, 6 insertions(+), 31 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c
index 8a48d18..7511839 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -53,7 +53,7 @@ static int ad7606_par_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
void __iomem *addr;
resource_size_t remap_size;
- int ret, irq;
+ int irq;
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
@@ -62,56 +62,31 @@ static int ad7606_par_probe(struct platform_device *pdev)
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
+ addr = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(addr))
+ return PTR_ERR(addr);
remap_size = resource_size(res);
- /* Request the regions */
- if (!request_mem_region(res->start, remap_size, "iio-ad7606")) {
- ret = -EBUSY;
- goto out1;
- }
- addr = ioremap(res->start, remap_size);
- if (!addr) {
- ret = -ENOMEM;
- goto out1;
- }
-
indio_dev = ad7606_probe(&pdev->dev, irq, addr,
platform_get_device_id(pdev)->driver_data,
remap_size > 1 ? &ad7606_par16_bops :
&ad7606_par8_bops);
- if (IS_ERR(indio_dev)) {
- ret = PTR_ERR(indio_dev);
- goto out2;
- }
+ if (IS_ERR(indio_dev))
+ return PTR_ERR(indio_dev);
platform_set_drvdata(pdev, indio_dev);
return 0;
-
-out2:
- iounmap(addr);
-out1:
- release_mem_region(res->start, remap_size);
-
- return ret;
}
static int ad7606_par_remove(struct platform_device *pdev)
{
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
- struct resource *res;
- struct ad7606_state *st = iio_priv(indio_dev);
ad7606_remove(indio_dev, platform_get_irq(pdev, 0));
- iounmap(st->base_address);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
-
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: iio: Introduce the use of devm_ioremap_resource
2014-07-01 18:44 [PATCH] staging: iio: Introduce the use of devm_ioremap_resource Himangi Saraogi
@ 2014-07-07 12:36 ` Jonathan Cameron
2014-07-07 12:36 ` Lars-Peter Clausen
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2014-07-07 12:36 UTC (permalink / raw)
To: Himangi Saraogi, Greg Kroah-Hartman, linux-iio, devel,
linux-kernel
Cc: julia.lawall, Lars-Peter Clausen
On 01/07/14 19:44, Himangi Saraogi wrote:
> This patch introduces the use of devm_ioremap_resource. It does away
> with call to request_mem_region and the error checking on
> platform_get_resource. Also, the calls to free the allocated resources
> like release_mem_region and iounmap are done away with. The ret variable
> in the probe function is also eliminated. Also, a bug is fixed as the
> goto in the error handling of request_mem_region should not have
> called release_mem_region which releases a resource that has not been
> allocated.
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Again, looks superficially fine, but I'd like an ack from someone
at Analog ideally.
Cc'd Lars
> ---
> drivers/staging/iio/adc/ad7606_par.c | 37 ++++++------------------------------
> 1 file changed, 6 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c
> index 8a48d18..7511839 100644
> --- a/drivers/staging/iio/adc/ad7606_par.c
> +++ b/drivers/staging/iio/adc/ad7606_par.c
> @@ -53,7 +53,7 @@ static int ad7606_par_probe(struct platform_device *pdev)
> struct iio_dev *indio_dev;
> void __iomem *addr;
> resource_size_t remap_size;
> - int ret, irq;
> + int irq;
>
> irq = platform_get_irq(pdev, 0);
> if (irq < 0) {
> @@ -62,56 +62,31 @@ static int ad7606_par_probe(struct platform_device *pdev)
> }
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res)
> - return -ENODEV;
> + addr = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(addr))
> + return PTR_ERR(addr);
>
> remap_size = resource_size(res);
>
> - /* Request the regions */
> - if (!request_mem_region(res->start, remap_size, "iio-ad7606")) {
> - ret = -EBUSY;
> - goto out1;
> - }
> - addr = ioremap(res->start, remap_size);
> - if (!addr) {
> - ret = -ENOMEM;
> - goto out1;
> - }
> -
> indio_dev = ad7606_probe(&pdev->dev, irq, addr,
> platform_get_device_id(pdev)->driver_data,
> remap_size > 1 ? &ad7606_par16_bops :
> &ad7606_par8_bops);
>
> - if (IS_ERR(indio_dev)) {
> - ret = PTR_ERR(indio_dev);
> - goto out2;
> - }
> + if (IS_ERR(indio_dev))
> + return PTR_ERR(indio_dev);
>
> platform_set_drvdata(pdev, indio_dev);
>
> return 0;
> -
> -out2:
> - iounmap(addr);
> -out1:
> - release_mem_region(res->start, remap_size);
> -
> - return ret;
> }
>
> static int ad7606_par_remove(struct platform_device *pdev)
> {
> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> - struct resource *res;
> - struct ad7606_state *st = iio_priv(indio_dev);
>
> ad7606_remove(indio_dev, platform_get_irq(pdev, 0));
>
> - iounmap(st->base_address);
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - release_mem_region(res->start, resource_size(res));
> -
> return 0;
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: iio: Introduce the use of devm_ioremap_resource
2014-07-07 12:36 ` Jonathan Cameron
@ 2014-07-07 12:36 ` Lars-Peter Clausen
2014-07-07 16:21 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2014-07-07 12:36 UTC (permalink / raw)
To: Jonathan Cameron, Himangi Saraogi, Greg Kroah-Hartman, linux-iio,
devel, linux-kernel
Cc: julia.lawall
On 07/07/2014 02:36 PM, Jonathan Cameron wrote:
> On 01/07/14 19:44, Himangi Saraogi wrote:
>> This patch introduces the use of devm_ioremap_resource. It does away
>> with call to request_mem_region and the error checking on
>> platform_get_resource. Also, the calls to free the allocated resources
>> like release_mem_region and iounmap are done away with. The ret variable
>> in the probe function is also eliminated. Also, a bug is fixed as the
>> goto in the error handling of request_mem_region should not have
>> called release_mem_region which releases a resource that has not been
>> allocated.
>>
>> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
>> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> Again, looks superficially fine, but I'd like an ack from someone
> at Analog ideally.
> Cc'd Lars
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: iio: Introduce the use of devm_ioremap_resource
2014-07-07 12:36 ` Lars-Peter Clausen
@ 2014-07-07 16:21 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2014-07-07 16:21 UTC (permalink / raw)
To: Lars-Peter Clausen, Himangi Saraogi, Greg Kroah-Hartman,
linux-iio, devel, linux-kernel
Cc: julia.lawall
On 07/07/14 13:36, Lars-Peter Clausen wrote:
> On 07/07/2014 02:36 PM, Jonathan Cameron wrote:
>> On 01/07/14 19:44, Himangi Saraogi wrote:
>>> This patch introduces the use of devm_ioremap_resource. It does away
>>> with call to request_mem_region and the error checking on
>>> platform_get_resource. Also, the calls to free the allocated resources
>>> like release_mem_region and iounmap are done away with. The ret variable
>>> in the probe function is also eliminated. Also, a bug is fixed as the
>>> goto in the error handling of request_mem_region should not have
>>> called release_mem_region which releases a resource that has not been
>>> allocated.
>>>
>>> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
>>> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
>> Again, looks superficially fine, but I'd like an ack from someone
>> at Analog ideally.
>> Cc'd Lars
>
> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git. This will be initially
pushed out as testing for the autobuilders to play.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-07 16:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-01 18:44 [PATCH] staging: iio: Introduce the use of devm_ioremap_resource Himangi Saraogi
2014-07-07 12:36 ` Jonathan Cameron
2014-07-07 12:36 ` Lars-Peter Clausen
2014-07-07 16:21 ` Jonathan Cameron
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).