public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] enums to clear suspend-state confusion
@ 2004-08-12 12:02 Pavel Machek
  2004-08-16  0:59 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Pavel Machek @ 2004-08-12 12:02 UTC (permalink / raw)
  To: kernel list, Andrew Morton, Patrick Mochel, benh, david-b

Hi!

This patch should clear up some confusion between driver model and
drivers people, and also prepares way to add runtime power managment
later. Please apply,
							Pavel


--- linux-mm/drivers/base/power/power.h	2004-07-28 21:29:22.000000000 +0200
+++ linux-delme/drivers/base/power/power.h	2004-08-12 13:41:12.000000000 +0200
@@ -1,5 +1,4 @@
-
-
+/* FIXME: This needs explanation... */
 enum {
 	DEVICE_PM_ON,
 	DEVICE_PM1,
@@ -66,14 +65,14 @@
 /*
  * suspend.c
  */
-extern int suspend_device(struct device *, u32);
+extern int suspend_device(struct device *, enum system_state);
 
 
 /*
  * runtime.c
  */
 
-extern int dpm_runtime_suspend(struct device *, u32);
+extern int dpm_runtime_suspend(struct device *, enum system_state);
 extern void dpm_runtime_resume(struct device *);
 
 #else /* CONFIG_PM */
@@ -88,7 +87,7 @@
 
 }
 
-static inline int dpm_runtime_suspend(struct device * dev, u32 state)
+static inline int dpm_runtime_suspend(struct device * dev, enum system_state state)
 {
 	return 0;
 }
--- linux-mm/drivers/base/power/shutdown.c	2004-07-28 21:29:22.000000000 +0200
+++ linux-delme/drivers/base/power/shutdown.c	2004-08-12 13:42:10.000000000 +0200
@@ -29,6 +29,7 @@
 			dev->driver->shutdown(dev);
 		return 0;
 	}
+	/* FIXME: It probably should not be cast like this */
 	return dpm_runtime_suspend(dev, dev->detach_state);
 }
 
--- linux-mm/drivers/base/power/suspend.c	2004-07-28 21:29:22.000000000 +0200
+++ linux-delme/drivers/base/power/suspend.c	2004-08-12 13:43:08.000000000 +0200
@@ -28,6 +28,7 @@
  * lists. This way, the ancestors will be accessed before their descendents.
  */
 
+/* FIXME: Having both suspend_device and device_suspend is evil */
 
 /**
  *	suspend_device - Save state of one device.
@@ -35,7 +36,7 @@
  *	@state:	Power state device is entering.
  */
 
-int suspend_device(struct device * dev, u32 state)
+int suspend_device(struct device * dev, enum system_state state)
 {
 	int error = 0;
 
@@ -70,7 +71,7 @@
  *
  */
 
-int device_suspend(u32 state)
+int device_suspend(enum system_state state)
 {
 	int error = 0;
 
@@ -112,7 +113,7 @@
  *	done, power down system devices.
  */
 
-int device_power_down(u32 state)
+int device_power_down(enum system_state state)
 {
 	int error = 0;
 	struct device * dev;
--- linux-mm/drivers/ide/ide-disk.c	2004-07-28 22:43:29.000000000 +0200
+++ linux-delme/drivers/ide/ide-disk.c	2004-08-12 13:41:12.000000000 +0200
@@ -1406,6 +1406,7 @@
 {
 	switch (rq->pm->pm_step) {
 	case idedisk_pm_flush_cache:	/* Suspend step 1 (flush cache) complete */
+		/* FIXME: This is buggy. */
 		if (rq->pm->pm_state == 4)
 			rq->pm->pm_step = ide_pm_state_completed;
 		else
--- linux-mm/include/linux/pci.h	2004-07-28 22:43:31.000000000 +0200
+++ linux-delme/include/linux/pci.h	2004-08-12 13:41:12.000000000 +0200
@@ -637,7 +637,7 @@
 	const struct pci_device_id *id_table;	/* must be non-NULL for probe to be called */
 	int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);	/* New device inserted */
 	void (*remove) (struct pci_dev *dev);	/* Device removed (NULL if not a hot-plug capable driver) */
-	int  (*suspend) (struct pci_dev *dev, u32 state);	/* Device suspended */
+	int  (*suspend) (struct pci_dev *dev, suspend_state_t reason);	/* Device suspended */
 	int  (*resume) (struct pci_dev *dev);	                /* Device woken up */
 	int  (*enable_wake) (struct pci_dev *dev, u32 state, int enable);   /* Enable wake event */
 
@@ -1021,5 +1021,26 @@
 #define PCIPCI_VSFX		16
 #define PCIPCI_ALIMAGIK		32
 
+enum pci_state {
+	D0 = 0,
+	D1 = 1,
+	D2 = 2,
+	D3hot = 3,
+	D3cold = 4
+};
+
+static inline enum pci_state to_pci_state(suspend_state_t state)
+{
+	if (SUSPEND_EQ(state, PM_SUSPEND_ON))
+		return D0;
+	if (SUSPEND_EQ(state, PM_SUSPEND_STANDBY))
+		return D1;
+	if (SUSPEND_EQ(state, PM_SUSPEND_MEM))
+		return D3hot;
+	if (SUSPEND_EQ(state, PM_SUSPEND_DISK))
+		return D3cold;
+	BUG();
+}
+
 #endif /* __KERNEL__ */
 #endif /* LINUX_PCI_H */
--- linux-mm/include/linux/pm.h	2004-07-28 21:29:32.000000000 +0200
+++ linux-delme/include/linux/pm.h	2004-08-12 13:41:12.000000000 +0200
@@ -193,14 +193,22 @@
 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,
 };
 
+/*
+ * For now, drivers only get system state. Later, this is going to become
+ * structure or something to enable runtime power managment.
+ */
+typedef enum system_state suspend_state_t;
+
+#define SUSPEND_EQ(a, b) (a == b)
+
 enum {
 	PM_DISK_FIRMWARE = 1,
 	PM_DISK_PLATFORM,
@@ -241,8 +249,11 @@
 
 extern void device_pm_set_parent(struct device * dev, struct device * parent);
 
-extern int device_suspend(u32 state);
-extern int device_power_down(u32 state);
+/*
+ * apply system suspend policy to all devices
+ */
+extern int device_suspend(enum system_state reason);
+extern int device_power_down(enum system_state reason);
 extern void device_power_up(void);
 extern void device_resume(void);
 

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

^ permalink raw reply	[flat|nested] 25+ messages in thread
[parent not found: <566B962EB122634D86E6EE29E83DD808182C3774@hdsmsx403.hd.intel.com>]

end of thread, other threads:[~2004-08-19  8:19 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-12 12:02 [patch] enums to clear suspend-state confusion Pavel Machek
2004-08-16  0:59 ` Andrew Morton
2004-08-16  6:25   ` Pavel Machek
2004-08-16 14:09 ` Takashi Iwai
2004-08-16 20:11   ` Pavel Machek
2004-08-17 21:25 ` Pavel Machek
2004-08-17 22:27   ` Andrew Morton
2004-08-17 22:37     ` Pavel Machek
2004-08-17 23:12       ` Andrew Morton
2004-08-18  0:27         ` Pavel Machek
2004-08-18  2:04           ` Benjamin Herrenschmidt
2004-08-18  6:12             ` Pavel Machek
2004-08-18  6:55               ` Benjamin Herrenschmidt
2004-08-18 13:03                 ` Pavel Machek
2004-08-18 14:29                 ` Patrick Mochel
2004-08-18 15:17                 ` David Brownell
2004-08-18 20:47                   ` Pavel Machek
2004-08-18 17:31           ` Alan Cox
2004-08-18 18:28             ` David Brownell
2004-08-18 20:35             ` Pavel Machek
2004-08-18  6:26         ` Pavel Machek
2004-08-18  6:30           ` Andrew Morton
2004-08-18 10:22           ` Takashi Iwai
     [not found] <566B962EB122634D86E6EE29E83DD808182C3774@hdsmsx403.hd.intel.com>
2004-08-19  5:59 ` Len Brown
2004-08-19  8:19   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox