mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: kernel list <linux-kernel@vger.kernel.org>,
	Patrick Mochel <mochel@osdl.org>
Subject: [PM] Gracefully handle errors from device_suspend()
Date: Fri, 8 Aug 2003 01:28:21 +0200	[thread overview]
Message-ID: <20030807232820.GA149@elf.ucw.cz> (raw)

Hi!

This makes drivers_suspend() correctly fail when some driver vetoes
the suspend. Device disable is moved after pm_send_all; that looks
more correct to me as pm_send_all may expect some mainboard devices to
still work. Few small whitespace/codingstyle fixes.

[Sorry, filename is wrong, but it should be easy to fix.]

Please apply,
								Pavel

--- /usr/src/tmp/linux/kernel/suspend.c	2003-08-08 01:19:01.000000000 +0200
+++ /usr/src/linux/kernel/suspend.c	2003-08-08 01:14:26.000000000 +0200
@@ -636,19 +637,23 @@
 /* Called from process context */
 static int drivers_suspend(void)
 {
-	device_suspend(4, SUSPEND_NOTIFY);
-	device_suspend(4, SUSPEND_SAVE_STATE);
-	device_suspend(4, SUSPEND_DISABLE);
-	if(!pm_suspend_state) {
+	if (device_suspend(4, SUSPEND_NOTIFY))
+		return -EIO;
+	if (device_suspend(4, SUSPEND_SAVE_STATE)) {
+		device_resume(RESUME_RESTORE_STATE);
+		return -EIO;
+	}
+	if (!pm_suspend_state) {
 		if(pm_send_all(PM_SUSPEND,(void *)3)) {
 			printk(KERN_WARNING "Problem while sending suspend event\n");
-			return(1);
+			return -EIO;
 		}
 		pm_suspend_state=1;
 	} else
 		printk(KERN_WARNING "PM suspend state already raised\n");
+	device_suspend(4, SUSPEND_DISABLE);
 	  
-	return(0);
+	return 0;
 }
 
 #define RESUME_PHASE1 1 /* Called from interrupts disabled */
@@ -661,7 +666,7 @@
 		device_resume(RESUME_ENABLE);
 	}
   	if (flags & RESUME_PHASE2) {
-		if(pm_suspend_state) {
+		if (pm_suspend_state) {
 			if(pm_send_all(PM_RESUME,(void *)0))
 				printk(KERN_WARNING "Problem while sending resume event\n");
 			pm_suspend_state=0;
@@ -868,7 +873,7 @@
 		blk_run_queues();
 
 		/* Save state of all device drivers, and stop them. */		   
-		if(drivers_suspend()==0)
+		if (drivers_suspend()==0)
 			/* If stopping device drivers worked, we proceed basically into
 			 * suspend_save_image.
 			 *

-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

                 reply	other threads:[~2003-08-07 23:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030807232820.GA149@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®