[PATCH] swsusp: avoid problems if there are too many pages to save
[linux-2.6.git] / kernel / power / power.h
1 #include <linux/suspend.h>
2 #include <linux/utsname.h>
3
4 /* With SUSPEND_CONSOLE defined suspend looks *really* cool, but
5    we probably do not take enough locks for switching consoles, etc,
6    so bad things might happen.
7 */
8 #if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
9 #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
10 #endif
11
12 #define MAX_PBES        ((PAGE_SIZE - sizeof(struct new_utsname) \
13                         - 4 - 3*sizeof(unsigned long) - sizeof(int) \
14                         - sizeof(void *)) / sizeof(swp_entry_t))
15
16 struct swsusp_info {
17         struct new_utsname      uts;
18         u32                     version_code;
19         unsigned long           num_physpages;
20         int                     cpus;
21         unsigned long           image_pages;
22         unsigned long           pagedir_pages;
23         suspend_pagedir_t       * suspend_pagedir;
24         swp_entry_t             pagedir[MAX_PBES];
25 } __attribute__((aligned(PAGE_SIZE)));
26
27
28
29 #ifdef CONFIG_SOFTWARE_SUSPEND
30 extern int pm_suspend_disk(void);
31
32 #else
33 static inline int pm_suspend_disk(void)
34 {
35         return -EPERM;
36 }
37 #endif
38 extern struct semaphore pm_sem;
39 #define power_attr(_name) \
40 static struct subsys_attribute _name##_attr = { \
41         .attr   = {                             \
42                 .name = __stringify(_name),     \
43                 .mode = 0644,                   \
44         },                                      \
45         .show   = _name##_show,                 \
46         .store  = _name##_store,                \
47 }
48
49 extern struct subsystem power_subsys;
50
51 extern int freeze_processes(void);
52 extern void thaw_processes(void);
53
54 extern int pm_prepare_console(void);
55 extern void pm_restore_console(void);