summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-05-24 08:52:22 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-07-01 08:18:53 +0200
commit5f03074ea98b64b55c133b35ee144fdc909e6d69 (patch)
tree1a61fd84a5a44d98297014486eca663221ff4cbc /drivers/base
parent20addb80f65076b3a81c7d778f7b93d445a96841 (diff)
downloadbarebox-5f03074ea98b64b55c133b35ee144fdc909e6d69.tar.gz
barebox-5f03074ea98b64b55c133b35ee144fdc909e6d69.tar.xz
resource: store 'end' instead of 'size' in struct resource
Storing the size instead of the resource end in struct resource was a mistake. 'size' ranges from 0 to UINT[32|64]_MAX + 1 which obviously leads to problems. 'end' on the other hand will never exceed UINT[32|64]_MAX. Also this way we can express a iomem region covering the whole address space. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/driver.c4
-rw-r--r--drivers/base/resource.c14
2 files changed, 9 insertions, 9 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 81cedca1db..31d6f2a406 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -261,7 +261,7 @@ void __iomem *dev_request_mem_region(struct device_d *dev, int num)
if (!res)
return NULL;
- res = request_iomem_region(dev_name(dev), res->start, res->size);
+ res = request_iomem_region(dev_name(dev), res->start, res->end);
if (!res)
return NULL;
@@ -392,7 +392,7 @@ static int do_devinfo(int argc, char *argv[])
printf("name : %s\n", res->name);
printf("start : " PRINTF_CONVERSION_RESOURCE "\nsize : "
PRINTF_CONVERSION_RESOURCE "\n",
- res->start, res->size);
+ res->start, resource_size(res));
}
printf("driver: %s\n\n", dev->driver ?
diff --git a/drivers/base/resource.c b/drivers/base/resource.c
index 347b2f01f0..6790af36d8 100644
--- a/drivers/base/resource.c
+++ b/drivers/base/resource.c
@@ -47,7 +47,7 @@ struct device_d *add_generic_device(const char* devname, int id, const char *res
if (resname)
res[0].name = xstrdup(resname);
res[0].start = start;
- res[0].size = size;
+ res[0].end = start + size - 1;
res[0].flags = flags;
return add_generic_device_res(devname, id, res, 1, pdata);
@@ -94,10 +94,10 @@ struct device_d *add_dm9000_device(int id, resource_size_t base,
}
res[0].start = base;
- res[0].size = size;
+ res[0].end = base + size - 1;
res[0].flags = IORESOURCE_MEM | flags;
res[1].start = data;
- res[1].size = size;
+ res[1].end = data + size - 1;
res[1].flags = IORESOURCE_MEM | flags;
return add_generic_device_res("dm9000", id, res, 2, pdata);
@@ -113,10 +113,10 @@ struct device_d *add_usb_ehci_device(int id, resource_size_t hccr,
res = xzalloc(sizeof(struct resource) * 2);
res[0].start = hccr;
- res[0].size = 0x40;
+ res[0].end = hccr + 0x40 - 1;
res[0].flags = IORESOURCE_MEM;
res[1].start = hcor;
- res[1].size = 0xc0;
+ res[1].end = hcor + 0xc0 - 1;
res[1].flags = IORESOURCE_MEM;
return add_generic_device_res("ehci", id, res, 2, pdata);
@@ -146,10 +146,10 @@ struct device_d *add_ks8851_device(int id, resource_size_t addr,
res = xzalloc(sizeof(struct resource) * 2);
res[0].start = addr;
- res[0].size = size;
+ res[0].end = addr + size - 1;
res[0].flags = IORESOURCE_MEM | flags;
res[1].start = addr_cmd;
- res[1].size = size;
+ res[1].end = addr_cmd + size - 1;
res[1].flags = IORESOURCE_MEM | flags;
return add_generic_device_res("ks8851_mll", id, res, 2, pdata);