]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/power/swsusp.c
Merge git://git.infradead.org/mtd-2.6
[linux-2.6-omap-h63xx.git] / kernel / power / swsusp.c
index c4016cbbd3e05611b7b7dccd9898be340365f31f..17f669c83012e95121d9d8930a32d3bd25c080aa 100644 (file)
@@ -67,9 +67,9 @@ unsigned int count_highmem_pages(void);
 int save_highmem(void);
 int restore_highmem(void);
 #else
-static int save_highmem(void) { return 0; }
-static int restore_highmem(void) { return 0; }
-static unsigned int count_highmem_pages(void) { return 0; }
+static inline int save_highmem(void) { return 0; }
+static inline int restore_highmem(void) { return 0; }
+static inline unsigned int count_highmem_pages(void) { return 0; }
 #endif
 
 /**
@@ -175,6 +175,12 @@ void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
  */
 
 #define SHRINK_BITE    10000
+static inline unsigned long __shrink_memory(long tmp)
+{
+       if (tmp > SHRINK_BITE)
+               tmp = SHRINK_BITE;
+       return shrink_all_memory(tmp);
+}
 
 int swsusp_shrink_memory(void)
 {
@@ -192,15 +198,17 @@ int swsusp_shrink_memory(void)
                        PAGES_FOR_IO;
                tmp = size;
                for_each_zone (zone)
-                       if (!is_highmem(zone))
+                       if (!is_highmem(zone) && populated_zone(zone)) {
                                tmp -= zone->free_pages;
+                               tmp += zone->lowmem_reserve[ZONE_NORMAL];
+                       }
                if (tmp > 0) {
-                       tmp = shrink_all_memory(SHRINK_BITE);
+                       tmp = __shrink_memory(tmp);
                        if (!tmp)
                                return -ENOMEM;
                        pages += tmp;
                } else if (size > image_size / PAGE_SIZE) {
-                       tmp = shrink_all_memory(SHRINK_BITE);
+                       tmp = __shrink_memory(size - (image_size / PAGE_SIZE));
                        pages += tmp;
                }
                printk("\b%c", p[i++%4]);