powerpc: permanently include 8xx registers in reg.h
[linux-2.6-block.git] / mm / sparse.c
index 2bfd078301f87bc88d4ef3ece0f1fc2dc60ae87b..bf32de9e666b5697f74cdbe319d4c783237065ab 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/export.h>
 #include <linux/spinlock.h>
 #include <linux/vmalloc.h>
+#include <linux/swap.h>
+#include <linux/swapops.h>
 
 #include "internal.h"
 #include <asm/dma.h>
@@ -501,7 +503,7 @@ void * __meminit sparse_buffer_alloc(unsigned long size)
        void *ptr = NULL;
 
        if (sparsemap_buf) {
-               ptr = PTR_ALIGN(sparsemap_buf, size);
+               ptr = (void *) roundup((unsigned long)sparsemap_buf, size);
                if (ptr + size > sparsemap_buf_end)
                        ptr = NULL;
                else {
@@ -877,7 +879,7 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn,
         */
        page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages);
 
-       ms = __pfn_to_section(start_pfn);
+       ms = __nr_to_section(section_nr);
        set_section_nid(section_nr, nid);
        section_mark_present(ms);
 
@@ -894,9 +896,6 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
 {
        int i;
 
-       if (!memmap)
-               return;
-
        /*
         * A further optimization is to have per section refcounted
         * num_poisoned_pages.  But that would need more space per memmap, so
@@ -908,7 +907,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
 
        for (i = 0; i < nr_pages; i++) {
                if (PageHWPoison(&memmap[i])) {
-                       atomic_long_sub(1, &num_poisoned_pages);
+                       num_poisoned_pages_dec();
                        ClearPageHWPoison(&memmap[i]);
                }
        }