Patchwork arch: sparc: kernel: use devm_ioremap_resource()

login
register
mail settings
Submitter Laurent Navet
Date May 12, 2013, 2:10 p.m.
Message ID <1368367807-1263-1-git-send-email-laurent.navet@gmail.com>
Download mbox | patch
Permalink /patch/243183/
State Superseded
Delegated to: David Miller
Headers show

Comments

Laurent Navet - May 12, 2013, 2:10 p.m.
Replace a call to deprecated devm_request_and_ioremap by devm_ioremap_resource.

Found with coccicheck and this semantic patch:
 scripts/coccinelle/api/devm_request_and_ioremap.cocci.

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
---
 arch/sparc/kernel/leon_pci_grpci1.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
Sam Ravnborg - May 12, 2013, 3:28 p.m.
On Sun, May 12, 2013 at 04:10:07PM +0200, Laurent Navet wrote:
> Replace a call to deprecated devm_request_and_ioremap by devm_ioremap_resource.
> 
> Found with coccicheck and this semantic patch:
>  scripts/coccinelle/api/devm_request_and_ioremap.cocci.
> 
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
> ---
>  arch/sparc/kernel/leon_pci_grpci1.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/sparc/kernel/leon_pci_grpci1.c b/arch/sparc/kernel/leon_pci_grpci1.c
> index 7739a54..6df26e3 100644
> --- a/arch/sparc/kernel/leon_pci_grpci1.c
> +++ b/arch/sparc/kernel/leon_pci_grpci1.c
> @@ -536,11 +536,9 @@ static int grpci1_of_probe(struct platform_device *ofdev)
>  
>  	/* find device register base address */
>  	res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
> -	regs = devm_request_and_ioremap(&ofdev->dev, res);
> -	if (!regs) {
> -		dev_err(&ofdev->dev, "io-regs mapping failed\n");
> -		return -EADDRNOTAVAIL;
> -	}
> +	regs = devm_ioremap_resource(&ofdev->dev, res);
> +	if (IS_ERR(regs))
> +		return PTR_ERR(regs);

This looks bogus. The function return an int - not a pointer.

	Sam
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Navet - May 13, 2013, 11:43 a.m.
The same is done almost everywhere in kernel tree :

e.g :
http://lxr.free-electrons.com/source/drivers/staging/iio/adc/mxs-lradc.c#L928
http://lxr.free-electrons.com/source/drivers/gpio/gpio-mxs.c#L292
http://lxr.free-electrons.com/source/drivers/iommu/tegra-smmu.c#L1181
http://lxr.free-electrons.com/source/drivers/rtc/rtc-spear.c#L388
http://lxr.free-electrons.com/source/drivers/i2c/busses/i2c-imx.c#L514
http://lxr.free-electrons.com/source/sound/soc/kirkwood/kirkwood-i2s.c#L475

and so on...  all theses functions return an int.

Regards,
Laurent.

2013/5/12, Sam Ravnborg <sam@ravnborg.org>:
> On Sun, May 12, 2013 at 04:10:07PM +0200, Laurent Navet wrote:
>> Replace a call to deprecated devm_request_and_ioremap by
>> devm_ioremap_resource.
>>
>> Found with coccicheck and this semantic patch:
>>  scripts/coccinelle/api/devm_request_and_ioremap.cocci.
>>
>> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
>> ---
>>  arch/sparc/kernel/leon_pci_grpci1.c |    8 +++-----
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/sparc/kernel/leon_pci_grpci1.c
>> b/arch/sparc/kernel/leon_pci_grpci1.c
>> index 7739a54..6df26e3 100644
>> --- a/arch/sparc/kernel/leon_pci_grpci1.c
>> +++ b/arch/sparc/kernel/leon_pci_grpci1.c
>> @@ -536,11 +536,9 @@ static int grpci1_of_probe(struct platform_device
>> *ofdev)
>>
>>  	/* find device register base address */
>>  	res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
>> -	regs = devm_request_and_ioremap(&ofdev->dev, res);
>> -	if (!regs) {
>> -		dev_err(&ofdev->dev, "io-regs mapping failed\n");
>> -		return -EADDRNOTAVAIL;
>> -	}
>> +	regs = devm_ioremap_resource(&ofdev->dev, res);
>> +	if (IS_ERR(regs))
>> +		return PTR_ERR(regs);
>
> This looks bogus. The function return an int - not a pointer.
>
> 	Sam
>
Sam Ravnborg - May 13, 2013, 3:37 p.m.
On Mon, May 13, 2013 at 01:43:17PM +0200, Laurent Navet wrote:
> The same is done almost everywhere in kernel tree :
> 
> e.g :
> http://lxr.free-electrons.com/source/drivers/staging/iio/adc/mxs-lradc.c#L928
> http://lxr.free-electrons.com/source/drivers/gpio/gpio-mxs.c#L292
> http://lxr.free-electrons.com/source/drivers/iommu/tegra-smmu.c#L1181
> http://lxr.free-electrons.com/source/drivers/rtc/rtc-spear.c#L388
> http://lxr.free-electrons.com/source/drivers/i2c/busses/i2c-imx.c#L514
> http://lxr.free-electrons.com/source/sound/soc/kirkwood/kirkwood-i2s.c#L475
> 
> and so on...  all theses functions return an int.

I was confusing PTR_ERR() and ERR_PTR(),
so path looks ok.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/sparc/kernel/leon_pci_grpci1.c b/arch/sparc/kernel/leon_pci_grpci1.c
index 7739a54..6df26e3 100644
--- a/arch/sparc/kernel/leon_pci_grpci1.c
+++ b/arch/sparc/kernel/leon_pci_grpci1.c
@@ -536,11 +536,9 @@  static int grpci1_of_probe(struct platform_device *ofdev)
 
 	/* find device register base address */
 	res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
-	regs = devm_request_and_ioremap(&ofdev->dev, res);
-	if (!regs) {
-		dev_err(&ofdev->dev, "io-regs mapping failed\n");
-		return -EADDRNOTAVAIL;
-	}
+	regs = devm_ioremap_resource(&ofdev->dev, res);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
 	/*
 	 * check that we're in Host Slot and that we can act as a Host Bridge