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 <uwe@hermann-uwe.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@437 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
fc12d1d148
commit
588f740124
3 changed files with 8 additions and 21 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue