diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-05-24 08:52:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-07-01 08:18:53 +0200 |
commit | 5f03074ea98b64b55c133b35ee144fdc909e6d69 (patch) | |
tree | 1a61fd84a5a44d98297014486eca663221ff4cbc /drivers/base/resource.c | |
parent | 20addb80f65076b3a81c7d778f7b93d445a96841 (diff) | |
download | barebox-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/resource.c')
-rw-r--r-- | drivers/base/resource.c | 14 |
1 files changed, 7 insertions, 7 deletions
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); |