X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=kernel%2Fresource.c;h=2eb553d9b517153d8d938b34d60718b948b6bac0;hb=e4cc0a9c876d4d4eadaef97a2bff4a199946d202;hp=bdb55a33f9691e2f79765eeba502d075f71d067c;hpb=c0cd79d11412969b6b8fa1624cdc1277db82e2fe;p=powerpc.git diff --git a/kernel/resource.c b/kernel/resource.c index bdb55a33f9..2eb553d9b5 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -212,27 +212,6 @@ int request_resource(struct resource *root, struct resource *new) EXPORT_SYMBOL(request_resource); -/** - * ____request_resource - reserve a resource, with resource conflict returned - * @root: root resource descriptor - * @new: resource descriptor desired by caller - * - * Returns: - * On success, NULL is returned. - * On error, a pointer to the conflicting resource is returned. - */ -struct resource *____request_resource(struct resource *root, struct resource *new) -{ - struct resource *conflict; - - write_lock(&resource_lock); - conflict = __request_resource(root, new); - write_unlock(&resource_lock); - return conflict; -} - -EXPORT_SYMBOL(____request_resource); - /** * release_resource - release a previously reserved resource * @old: resource pointer @@ -255,7 +234,7 @@ EXPORT_SYMBOL(release_resource); * the caller must specify res->start, res->end, res->flags. * If found, returns 0, res is overwritten, if not found, returns -1. */ -int find_next_system_ram(struct resource *res) +static int find_next_system_ram(struct resource *res) { resource_size_t start, end; struct resource *p; @@ -288,6 +267,30 @@ int find_next_system_ram(struct resource *res) res->end = p->end; return 0; } +int +walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg, + int (*func)(unsigned long, unsigned long, void *)) +{ + struct resource res; + unsigned long pfn, len; + u64 orig_end; + int ret = -1; + res.start = (u64) start_pfn << PAGE_SHIFT; + res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; + res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; + orig_end = res.end; + while ((res.start < res.end) && (find_next_system_ram(&res) >= 0)) { + pfn = (unsigned long)(res.start >> PAGE_SHIFT); + len = (unsigned long)((res.end + 1 - res.start) >> PAGE_SHIFT); + ret = (*func)(pfn, len, arg); + if (ret) + break; + res.start = res.end + 1; + res.end = orig_end; + } + return ret; +} + #endif /*