Patchwork drivers/ide/au1xxx-ide.c: use resource_size()

login
register
mail settings
Submitter hartleys
Date Nov. 23, 2009, 6:15 p.m.
Message ID <BD79186B4FD85F4B8E60E381CAEE190901EE5BFD@mi8nycmail19.Mi8.com>
Download mbox | patch
Permalink /patch/39064/
State Accepted
Delegated to: David Miller
Headers show

Comments

hartleys - Nov. 23, 2009, 6:15 p.m.
Use resource_size() for {request/release}_mem_region and ioremap.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>

---

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Nov. 23, 2009, 6:28 p.m.
From: "H Hartley Sweeten" <hartleys@visionengravers.com>
Date: Mon, 23 Nov 2009 13:15:32 -0500

> Use resource_size() for {request/release}_mem_region and ioremap.
> 
> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>

Applied to ide-next-2.6, thanks.

>  
> -	ahwif->regbase = (u32)ioremap(res->start, res->end - res->start + 1);
> +	ahwif->regbase = (u32)ioremap(res->start, resource_size(res));
>  	if (ahwif->regbase == 0) {
>  		ret = -ENOMEM;
>  		goto out;

That needs some fixing.  ioremap()'s return value is an
"__iomem" pointer, not an integer.  ->regbase's type should be
changed to something like "void __iomem *" etc.
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
hartleys - Nov. 23, 2009, 6:37 p.m.
On Monday, November 23, 2009 11:28 AM, David Miller wrote:
> From: "H Hartley Sweeten" <hartleys@visionengravers.com>
> Date: Mon, 23 Nov 2009 13:15:32 -0500
>
>> Use resource_size() for {request/release}_mem_region and ioremap.
>> 
>> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
>
> Applied to ide-next-2.6, thanks.
>
>>  
>> -	ahwif->regbase = (u32)ioremap(res->start, res->end - res->start + 1);
>> +	ahwif->regbase = (u32)ioremap(res->start, resource_size(res));
>>  	if (ahwif->regbase == 0) {
>>  		ret = -ENOMEM;
>>  		goto out;
>
> That needs some fixing.  ioremap()'s return value is an
> "__iomem" pointer, not an integer.  ->regbase's type should be
> changed to something like "void __iomem *" etc.

Agree.  But that was already in the driver.

I don't have to hardware to test this so I didn't want to dig to deeply
into fixing that.

Thanks,
Hartley
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Nov. 23, 2009, 6:38 p.m.
From: "H Hartley Sweeten" <hartleys@visionengravers.com>
Date: Mon, 23 Nov 2009 13:37:05 -0500

> I don't have to hardware to test this so I didn't want to dig to deeply
> into fixing that.

Fair enough.
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" 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/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 58121bd..87cef0c 100644
--- a/drivers/ide/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
@@ -532,14 +532,13 @@  static int au_ide_probe(struct platform_device *dev)
 		goto out;
 	}
 
-	if (!request_mem_region(res->start, res->end - res->start + 1,
-				dev->name)) {
+	if (!request_mem_region(res->start, resource_size(res), dev->name)) {
 		pr_debug("%s: request_mem_region failed\n", DRV_NAME);
 		ret =  -EBUSY;
 		goto out;
 	}
 
-	ahwif->regbase = (u32)ioremap(res->start, res->end - res->start + 1);
+	ahwif->regbase = (u32)ioremap(res->start, resource_size(res));
 	if (ahwif->regbase == 0) {
 		ret = -ENOMEM;
 		goto out;
@@ -575,7 +574,7 @@  static int au_ide_remove(struct platform_device *dev)
 	iounmap((void *)ahwif->regbase);
 
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	release_mem_region(res->start, res->end - res->start + 1);
+	release_mem_region(res->start, resource_size(res));
 
 	return 0;
 }