]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - mm/memory_hotplug.c
Merge branch 'akpm-current/current'
[karo-tx-linux.git] / mm / memory_hotplug.c
index 4b62bbac55125b07a14706797ad390b14f4a6e8a..67d488ab495e57b9018484932e135078c787903c 100644 (file)
@@ -1232,23 +1232,21 @@ int zone_for_memory(int nid, u64 start, u64 size, int zone_default,
 }
 
 /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
-int __ref add_memory(int nid, u64 start, u64 size)
+int __ref add_memory_resource(int nid, struct resource *res)
 {
+       u64 start, size;
        pg_data_t *pgdat = NULL;
        bool new_pgdat;
        bool new_node;
-       struct resource *res;
        int ret;
 
+       start = res->start;
+       size = resource_size(res);
+
        ret = check_hotplug_memory_range(start, size);
        if (ret)
                return ret;
 
-       res = register_memory_resource(start, size);
-       ret = -EEXIST;
-       if (!res)
-               return ret;
-
        {       /* Stupid hack to suppress address-never-null warning */
                void *p = NODE_DATA(nid);
                new_pgdat = !p;
@@ -1300,13 +1298,28 @@ error:
        /* rollback pgdat allocation and others */
        if (new_pgdat)
                rollback_node_hotadd(nid, pgdat);
-       release_memory_resource(res);
        memblock_remove(start, size);
 
 out:
        mem_hotplug_done();
        return ret;
 }
+EXPORT_SYMBOL_GPL(add_memory_resource);
+
+int __ref add_memory(int nid, u64 start, u64 size)
+{
+       struct resource *res;
+       int ret;
+
+       res = register_memory_resource(start, size);
+       if (!res)
+               return -EEXIST;
+
+       ret = add_memory_resource(nid, res);
+       if (ret < 0)
+               release_memory_resource(res);
+       return ret;
+}
 EXPORT_SYMBOL_GPL(add_memory);
 
 #ifdef CONFIG_MEMORY_HOTREMOVE