Merge remote branch 'linus/master'
[powerpc.git] / kernel / resource.c
index 2a3f886..82aea81 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -213,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
@@ -250,13 +228,13 @@ int release_resource(struct resource *old)
 
 EXPORT_SYMBOL(release_resource);
 
-#ifdef CONFIG_MEMORY_HOTPLUG
+#if defined(CONFIG_MEMORY_HOTPLUG) && !defined(CONFIG_ARCH_HAS_WALK_MEMORY)
 /*
  * Finds the lowest memory reosurce exists within [res->start.res->end)
  * 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;
@@ -289,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
 
 /*