Patchwork [MTD] maps/ixp4xx: Use resource_size

login
register
mail settings
Submitter Tobias Klauser
Date Oct. 30, 2009, 4:54 p.m.
Message ID <1256921673-19745-1-git-send-email-tklauser@distanz.ch>
Download mbox | patch
Permalink /patch/37312/
State Accepted
Commit d6587feaf0ed7511b3d0b52bcaae8ecd0949d3af
Headers show

Comments

Tobias Klauser - Oct. 30, 2009, 4:54 p.m.
Use the resource_size inline function instead of manually calculating
the resource size. This reduces the chance of introducing off-by-one
errors.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
 drivers/mtd/maps/ixp4xx.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Artem Bityutskiy - Nov. 9, 2009, 9:36 a.m.
On Fri, 2009-10-30 at 17:54 +0100, Tobias Klauser wrote:
> Use the resource_size inline function instead of manually calculating
> the resource size. This reduces the chance of introducing off-by-one
> errors.
> 
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> ---
>  drivers/mtd/maps/ixp4xx.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)

Taken to l2-mtd-2.6 tree, thanks.

Patch

diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 7214b87..7b05152 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -210,7 +210,7 @@  static int ixp4xx_flash_probe(struct platform_device *dev)
 	 * not attempt to do a direct access on us.
 	 */
 	info->map.phys = NO_XIP;
-	info->map.size = dev->resource->end - dev->resource->start + 1;
+	info->map.size = resource_size(dev->resource);
 
 	/*
 	 * We only support 16-bit accesses for now. If and when
@@ -224,7 +224,7 @@  static int ixp4xx_flash_probe(struct platform_device *dev)
 	info->map.copy_from = ixp4xx_copy_from,
 
 	info->res = request_mem_region(dev->resource->start,
-			dev->resource->end - dev->resource->start + 1,
+			resource_size(dev->resource),
 			"IXP4XXFlash");
 	if (!info->res) {
 		printk(KERN_ERR "IXP4XXFlash: Could not reserve memory region\n");
@@ -233,7 +233,7 @@  static int ixp4xx_flash_probe(struct platform_device *dev)
 	}
 
 	info->map.virt = ioremap(dev->resource->start,
-				 dev->resource->end - dev->resource->start + 1);
+				 resource_size(dev->resource));
 	if (!info->map.virt) {
 		printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n");
 		err = -EIO;