From 05f11b379c8af946cfc48b8f4823e285fb926df7 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Tue, 12 Aug 2003 20:55:13 -0700 Subject: [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(). --- kernel/power/swsusp.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'kernel') diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index 4ef3892bc04b..441e712155c5 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c @@ -352,15 +352,10 @@ static int count_and_copy_data_pages(struct pbe *pagedir_p) int pfn; struct page *page; -#ifdef CONFIG_DISCONTIGMEM - panic("Discontingmem not supported"); -#else BUG_ON (max_pfn != num_physpages); -#endif + for (pfn = 0; pfn < max_pfn; pfn++) { page = pfn_to_page(pfn); - if (PageHighMem(page)) - panic("Swsusp not supported on highmem boxes. Send 1GB of RAM to and try again ;-)."); if (!PageReserved(page)) { if (PageNosave(page)) @@ -700,7 +695,7 @@ void do_magic_suspend_2(void) mark_swapfiles(((swp_entry_t) {0}), MARK_SWAP_RESUME); } -static void do_software_suspend(void) +static int do_software_suspend(void) { arch_prepare_suspend(); if (pm_prepare_console()) @@ -735,20 +730,30 @@ static void do_software_suspend(void) software_suspend_enabled = 1; MDELAY(1000); pm_restore_console(); + return 0; } -/* - * This is main interface to the outside world. It needs to be - * called from process context. + +/** + * software_suspend - initiate suspend-to-swap transition. + * + * This is main interface to the outside world. It needs to be + * called from process context. */ -void software_suspend(void) + +int software_suspend(void) { 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; might_sleep(); - do_software_suspend(); + return do_software_suspend(); } /* More restore stuff */ -- cgit v1.2.3