Commit 05f11b37 authored by Patrick Mochel's avatar Patrick Mochel

[swsusp] Remove two panic()s.

- Make software_suspend() return an int, so caller can tell what happened.
- Do check for HIGHMEM and DISCONTIGMEM early in software_suspend() and 
  fail gracefully, instead of checking far down the call chain and having
  to call panic().
parent 5e29fc2e
...@@ -50,7 +50,7 @@ extern int shrink_mem(void); ...@@ -50,7 +50,7 @@ extern int shrink_mem(void);
extern void drain_local_pages(void); extern void drain_local_pages(void);
/* kernel/suspend.c */ /* kernel/suspend.c */
extern void software_suspend(void); extern int software_suspend(void);
extern void software_resume(void); extern void software_resume(void);
extern int register_suspend_notifier(struct notifier_block *); extern int register_suspend_notifier(struct notifier_block *);
...@@ -72,8 +72,9 @@ extern void do_suspend_lowlevel(int resume); ...@@ -72,8 +72,9 @@ extern void do_suspend_lowlevel(int resume);
extern void do_suspend_lowlevel_s4bios(int resume); extern void do_suspend_lowlevel_s4bios(int resume);
#else /* CONFIG_SOFTWARE_SUSPEND */ #else /* CONFIG_SOFTWARE_SUSPEND */
static inline void software_suspend(void) static inline int software_suspend(void)
{ {
return -EPERM;
} }
#define software_resume() do { } while(0) #define software_resume() do { } while(0)
#define register_suspend_notifier(a) do { } while(0) #define register_suspend_notifier(a) do { } while(0)
......
...@@ -352,15 +352,10 @@ static int count_and_copy_data_pages(struct pbe *pagedir_p) ...@@ -352,15 +352,10 @@ static int count_and_copy_data_pages(struct pbe *pagedir_p)
int pfn; int pfn;
struct page *page; struct page *page;
#ifdef CONFIG_DISCONTIGMEM
panic("Discontingmem not supported");
#else
BUG_ON (max_pfn != num_physpages); BUG_ON (max_pfn != num_physpages);
#endif
for (pfn = 0; pfn < max_pfn; pfn++) { for (pfn = 0; pfn < max_pfn; pfn++) {
page = pfn_to_page(pfn); page = pfn_to_page(pfn);
if (PageHighMem(page))
panic("Swsusp not supported on highmem boxes. Send 1GB of RAM to <pavel@ucw.cz> and try again ;-).");
if (!PageReserved(page)) { if (!PageReserved(page)) {
if (PageNosave(page)) if (PageNosave(page))
...@@ -700,7 +695,7 @@ void do_magic_suspend_2(void) ...@@ -700,7 +695,7 @@ void do_magic_suspend_2(void)
mark_swapfiles(((swp_entry_t) {0}), MARK_SWAP_RESUME); mark_swapfiles(((swp_entry_t) {0}), MARK_SWAP_RESUME);
} }
static void do_software_suspend(void) static int do_software_suspend(void)
{ {
arch_prepare_suspend(); arch_prepare_suspend();
if (pm_prepare_console()) if (pm_prepare_console())
...@@ -735,20 +730,30 @@ static void do_software_suspend(void) ...@@ -735,20 +730,30 @@ static void do_software_suspend(void)
software_suspend_enabled = 1; software_suspend_enabled = 1;
MDELAY(1000); MDELAY(1000);
pm_restore_console(); pm_restore_console();
return 0;
} }
/*
/**
* software_suspend - initiate suspend-to-swap transition.
*
* This is main interface to the outside world. It needs to be * This is main interface to the outside world. It needs to be
* called from process context. * called from process context.
*/ */
void software_suspend(void)
int software_suspend(void)
{ {
if(!software_suspend_enabled) if(!software_suspend_enabled)
return; return -EINVAL;
#if defined (CONFIG_HIGHMEM) || defined (COFNIG_DISCONTIGMEM)
printk("swsusp is not supported with high- or discontig-mem.\n");
return -EPERM;
#endif
software_suspend_enabled = 0; software_suspend_enabled = 0;
might_sleep(); might_sleep();
do_software_suspend(); return do_software_suspend();
} }
/* More restore stuff */ /* More restore stuff */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment