From 588f7401249be1c906167489b0b0a71faa566809 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 7 Jul 2007 19:19:44 +0000 Subject: [PATCH] Drop the round() function, as it is an exact copy of align_up(). Also, make align_up()/align_down() non-static as they are useful even outside of device/device_util.c. Signed-off-by: Uwe Hermann Acked-by: Stefan Reinauer git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@437 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- device/device.c | 22 +++------------------- device/device_util.c | 4 ++-- include/device/device.h | 3 +++ 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/device/device.c b/device/device.c index 256fee1aab..650b04f550 100644 --- a/device/device.c +++ b/device/device.c @@ -243,22 +243,6 @@ out: return dev; } -/** - * Round a number up to an alignment. - * - * @param val The starting value. - * @param roundup Alignment as a power of two. - * @returns Rounded up number. - */ -static resource_t round(resource_t val, unsigned long pow) -{ - resource_t mask; - mask = (1ULL << pow) - 1ULL; - val += mask; - val &= ~mask; - return val; -} - /** * Read the resources on all devices of a given bus. * @@ -492,9 +476,9 @@ void compute_allocate_resource(struct bus *bus, struct resource *bridge, base = 0x3e0; } } - if (((round(base, align) + size) - 1) <= resource->limit) { + if (((align_up(base, align) + size) - 1) <= resource->limit) { /* Base must be aligned to size. */ - base = round(base, align); + base = align_up(base, align); resource->base = base; resource->flags |= IORESOURCE_ASSIGNED; resource->flags &= ~IORESOURCE_STORED; @@ -517,7 +501,7 @@ void compute_allocate_resource(struct bus *bus, struct resource *bridge, * minimum granularity so we know not to place something else at an * address positively decoded by the bridge. */ - bridge->size = round(base, bridge->gran) - bridge->base; + bridge->size = align_up(base, bridge->gran) - bridge->base; printk(BIOS_SPEW, "%s compute_allocate_%s: base: %08Lx size: %08Lx align: %d gran: %d done\n", dev_path(bus->dev), (bridge->flags & IORESOURCE_IO) ? "io" : (bridge->flags & IORESOURCE_PREFETCH) ? "prefmem" : "mem", base, bridge->size, bridge->align, bridge->gran); } diff --git a/device/device_util.c b/device/device_util.c index c931c30f4a..69b4281fd4 100644 --- a/device/device_util.c +++ b/device/device_util.c @@ -496,7 +496,7 @@ struct resource *find_resource(struct device *dev, unsigned int index) * @param gran Granularity we are aligning the number to. * @returns The aligned value. */ -static resource_t align_up(resource_t val, unsigned long gran) +resource_t align_up(resource_t val, unsigned long gran) { resource_t mask; mask = (1ULL << gran) - 1ULL; @@ -512,7 +512,7 @@ static resource_t align_up(resource_t val, unsigned long gran) * @param gran Granularity we are aligning the number to. * @returns The aligned value. */ -static resource_t align_down(resource_t val, unsigned long gran) +resource_t align_down(resource_t val, unsigned long gran) { resource_t mask; mask = (1ULL << gran) - 1ULL; diff --git a/include/device/device.h b/include/device/device.h index 204b1a6dd4..646839b445 100644 --- a/include/device/device.h +++ b/include/device/device.h @@ -257,6 +257,9 @@ void default_device_constructor(struct device *dev, struct constructor *construc #define DEVICE_IO_ALIGN 16 #define DEVICE_MEM_ALIGN 4096 +resource_t align_up(resource_t val, unsigned long gran); +resource_t align_down(resource_t val, unsigned long gran); + extern struct device_operations default_dev_ops_root; extern int id_eq(struct device_id *id1, struct device_id *id2);