diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-02-04 07:40:19 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-02-04 07:40:19 +0000 |
commit | 33263fc5f9ac8e8cb2b22d06af3ce5ac1dd815e4 (patch) | |
tree | 2d1b86a40bef0958a68cf1a2eafbeb0667a70543 /kernel/resource.c | |
parent | 216f5f51aa02f8b113aa620ebc14a9631a217a00 (diff) |
Merge with Linux 2.3.32.
Diffstat (limited to 'kernel/resource.c')
-rw-r--r-- | kernel/resource.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index e3dd3a16d..bdf9fef31 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -13,9 +13,10 @@ #include <linux/init.h> #include <linux/malloc.h> #include <linux/spinlock.h> +#include <asm/io.h> -struct resource ioport_resource = { "PCI IO", 0x0000, 0xFFFF, IORESOURCE_IO }; -struct resource iomem_resource = { "PCI mem", 0x00000000, 0xFFFFFFFF, IORESOURCE_MEM }; +struct resource ioport_resource = { "PCI IO", 0x0000, IO_SPACE_LIMIT, IORESOURCE_IO }; +struct resource iomem_resource = { "PCI mem", 0x00000000, 0xffffffff, IORESOURCE_MEM }; static rwlock_t resource_lock = RW_LOCK_UNLOCKED; @@ -126,30 +127,32 @@ int release_resource(struct resource *old) static int find_resource(struct resource *root, struct resource *new, unsigned long size, unsigned long min, unsigned long max, - unsigned long align) + unsigned long align, + void (*alignf)(void *, struct resource *, unsigned long), + void *alignf_data) { struct resource *this = root->child; - unsigned long start, end; - start = root->start; + new->start = root->start; for(;;) { if (this) - end = this->start; + new->end = this->start; else - end = root->end; - if (start < min) - start = min; - if (end > max) - end = max; - start = (start + align - 1) & ~(align - 1); - if (start < end && end - start + 1 >= size) { - new->start = start; - new->end = start + size - 1; + new->end = root->end; + if (new->start < min) + new->start = min; + if (new->end > max) + new->end = max; + new->start = (new->start + align - 1) & ~(align - 1); + if (alignf) + alignf(alignf_data, new, size); + if (new->start < new->end && new->end - new->start + 1 >= size) { + new->end = new->start + size - 1; return 0; } if (!this) break; - start = this->end + 1; + new->start = this->end + 1; this = this->sibling; } return -EBUSY; @@ -161,12 +164,14 @@ static int find_resource(struct resource *root, struct resource *new, int allocate_resource(struct resource *root, struct resource *new, unsigned long size, unsigned long min, unsigned long max, - unsigned long align) + unsigned long align, + void (*alignf)(void *, struct resource *, unsigned long), + void *alignf_data) { int err; write_lock(&resource_lock); - err = find_resource(root, new, size, min, max, align); + err = find_resource(root, new, size, min, max, align, alignf, alignf_data); if (err >= 0 && __request_resource(root, new)) err = -EBUSY; write_unlock(&resource_lock); |