public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: kernel list <linux-kernel@vger.kernel.org>,
	Patrick Mochel <mochel@digitalimplant.org>,
	Andrew Morton <akpm@zip.com.au>,
	benh@kernel.crashing.org, david-b@pacbell.net
Subject: Use global system_state to avoid system-state confusion
Date: Thu, 19 Aug 2004 13:36:00 +0200	[thread overview]
Message-ID: <20040819113600.GA1317@elf.ucw.cz> (raw)

Hi!

I started using system_state (already defined in kernel.h) to allow
drivers to do something different in response to swsusp. This at least
kills ide-disk.c hack.

Please apply,
								Pavel

--- linux-mm.middle/drivers/ide/ide-disk.c	2004-08-17 12:21:43.000000000 +0200
+++ linux-mm/drivers/ide/ide-disk.c	2004-08-19 13:12:28.000000000 +0200
@@ -1406,7 +1406,7 @@
 {
 	switch (rq->pm->pm_step) {
 	case idedisk_pm_flush_cache:	/* Suspend step 1 (flush cache) complete */
-		if (rq->pm->pm_state == 4)
+		if (system_state == SYSTEM_SWSUSP_SNAPSHOT)
 			rq->pm->pm_step = ide_pm_state_completed;
 		else
 			rq->pm->pm_step = idedisk_pm_standby;
@@ -1678,7 +1678,6 @@
 		return;
 	}
 
-	printk("Shutdown: %s\n", drive->name);
 	dev->bus->suspend(dev, PM_SUSPEND_STANDBY);
 }
 
--- linux-mm.middle/include/linux/kernel.h	2004-08-17 12:21:44.000000000 +0200
+++ linux-mm/include/linux/kernel.h	2004-08-19 13:12:08.000000000 +0200
@@ -136,6 +136,9 @@
 extern enum system_states {
 	SYSTEM_BOOTING,
 	SYSTEM_RUNNING,
+	SYSTEM_SWSUSP_SNAPSHOT,
+	SYSTEM_DISK_SUSPEND,
+	SYSTEM_RAM_SUSPEND,
 	SYSTEM_HALT,
 	SYSTEM_POWER_OFF,
 	SYSTEM_RESTART,
--- linux-mm.middle/include/linux/pm.h	2004-08-15 19:15:05.000000000 +0200
+++ linux-mm/include/linux/pm.h	2004-08-19 13:12:08.000000000 +0200
@@ -193,11 +193,11 @@
 extern void (*pm_idle)(void);
 extern void (*pm_power_off)(void);
 
-enum {
-	PM_SUSPEND_ON,
-	PM_SUSPEND_STANDBY,
-	PM_SUSPEND_MEM,
-	PM_SUSPEND_DISK,
+enum system_state {
+	PM_SUSPEND_ON = 0,
+	PM_SUSPEND_STANDBY = 1,
+	PM_SUSPEND_MEM = 2,
+	PM_SUSPEND_DISK = 3,
 	PM_SUSPEND_MAX,
 };
 
--- linux-mm.middle/kernel/power/disk.c	2004-08-17 12:21:44.000000000 +0200
+++ linux-mm/kernel/power/disk.c	2004-08-19 13:13:35.000000000 +0200
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/fs.h>
+#include <linux/device.h>
 #include "power.h"
 
 
@@ -49,15 +50,18 @@
 	local_irq_save(flags);
 	switch(mode) {
 	case PM_DISK_PLATFORM:
+		system_state = SYSTEM_DISK_SUSPEND;
 		device_power_down(PM_SUSPEND_DISK);
 		error = pm_ops->enter(PM_SUSPEND_DISK);
 		break;
 	case PM_DISK_SHUTDOWN:
+		system_state = SYSTEM_POWER_OFF;
 		printk("Powering off system\n");
 		device_shutdown();
 		machine_power_off();
 		break;
 	case PM_DISK_REBOOT:
+		system_state = SYSTEM_RESTART;
 		device_shutdown();
 		machine_restart(NULL);
 		break;
@@ -114,6 +118,7 @@
 {
 	int error;
 
+	system_state = SYSTEM_SWSUSP_SNAPSHOT;
 	pm_prepare_console();
 
 	sys_sync();
@@ -226,6 +231,7 @@
 
 	pr_debug("PM: Preparing system for restore.\n");
 
+	system_state = SYSTEM_SWSUSP_SNAPSHOT;
 	if ((error = prepare()))
 		goto Free;
 
--- linux-mm.middle/kernel/power/main.c	2004-08-17 12:22:47.000000000 +0200
+++ linux-mm/kernel/power/main.c	2004-08-19 13:12:08.000000000 +0200
@@ -151,6 +151,7 @@
 		goto Unlock;
 	}
 
+	system_state = SYSTEM_RAM_SUSPEND;
 	pr_debug("PM: Preparing system for suspend\n");
 	if ((error = suspend_prepare(state)))
 		goto Unlock;
@@ -162,6 +163,7 @@
 	suspend_finish(state);
  Unlock:
 	up(&pm_sem);
+	system_state = SYSTEM_RUNNING;
 	return error;
 }
 

-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

             reply	other threads:[~2004-08-19 11:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-19 11:36 Pavel Machek [this message]
2004-08-19 11:11 ` Use global system_state to avoid system-state confusion Alan Cox
2004-08-20 10:01   ` Pavel Machek
2004-08-19 11:42 ` Nigel Cunningham
2004-08-20  8:26   ` Pavel Machek

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=20040819113600.GA1317@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=akpm@zip.com.au \
    --cc=benh@kernel.crashing.org \
    --cc=david-b@pacbell.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@digitalimplant.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