[linux-pm] Re: Add typechecking to suspend types and powerdown types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

> > This adds typechecking to suspend types and powerdown types... This
> >  should solve at least part of suspend type confusion. There should be
> >  no code changes generated by this one. I'd like to see it applied...
> 
> drivers/acpi/sleep/main.c:171: warning: initialization from incompatible pointer type
> drivers/acpi/sleep/main.c:172: warning: initialization from incompatible pointer type
> drivers/acpi/sleep/main.c:173: warning: initialization from incompatible pointer type
> 
> static struct pm_ops acpi_pm_ops = {
> 	.prepare	= acpi_pm_prepare,
> 	.enter		= acpi_pm_enter,
> 	.finish		= acpi_pm_finish,
> };
> 
> I'll drop this one.  Please try again when things have calmed down a
> > bit.

I do not know if things are calm enough now... I forgot about acpi
pieces. Hmm, and about some arm pieces. This should fix it.

---

This adds typechecking to suspend types and powerdown types... This
should solve at least part of suspend type confusion. There should be
no code changes generated by this one. I'd like to see it applied...

--- clean/kernel/power/disk.c	2004-10-01 00:30:32.000000000 +0200
+++ linux/kernel/power/disk.c	2004-10-24 23:05:10.000000000 +0200
@@ -15,10 +16,11 @@
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/fs.h>
+#include <linux/device.h>
 #include "power.h"
 
 
-extern u32 pm_disk_mode;
+extern suspend_disk_method_t pm_disk_mode;
 extern struct pm_ops * pm_ops;
 
 extern int swsusp_suspend(void);
@@ -292,7 +297,7 @@
 	int i;
 	int len;
 	char *p;
-	u32 mode = 0;
+	suspend_disk_method_t mode = 0;
 
 	p = memchr(buf, '\n', n);
 	len = p ? p - buf : n;
--- clean/kernel/power/main.c	2004-10-01 00:30:32.000000000 +0200
+++ linux/kernel/power/main.c	2004-10-24 22:49:23.000000000 +0200
@@ -22,7 +22,7 @@
 DECLARE_MUTEX(pm_sem);
 
 struct pm_ops * pm_ops = NULL;
-u32 pm_disk_mode = PM_DISK_SHUTDOWN;
+suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
 
 /**
  *	pm_set_ops - Set the global power method table. 
@@ -46,7 +46,7 @@
  *	the platform can enter the requested state.
  */
 
-static int suspend_prepare(u32 state)
+static int suspend_prepare(suspend_state_t state)
 {
 	int error = 0;
 
@@ -102,7 +107,7 @@
  *	console that we've allocated.
  */
 
-static void suspend_finish(u32 state)
+static void suspend_finish(suspend_state_t state)
 {
 	device_resume();
 	if (pm_ops && pm_ops->finish)
@@ -133,7 +138,7 @@
  *	we've woken up).
  */
 
-static int enter_state(u32 state)
+static int enter_state(suspend_state_t state)
 {
 	int error;
 
@@ -183,7 +188,7 @@
  *	structure, and enter (above).
  */
 
-int pm_suspend(u32 state)
+int pm_suspend(suspend_state_t state)
 {
 	if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX)
 		return enter_state(state);
@@ -221,7 +226,7 @@
 
 static ssize_t state_store(struct subsystem * subsys, const char * buf, size_t n)
 {
-	u32 state = PM_SUSPEND_STANDBY;
+	suspend_state_t state = PM_SUSPEND_STANDBY;
 	char ** s;
 	char *p;
 	int error;
--- clean/include/linux/pm.h	2004-10-01 00:30:30.000000000 +0200
+++ linux/include/linux/pm.h	2004-10-22 10:33:53.000000000 +0200
@@ -193,34 +167,32 @@
 extern void (*pm_idle)(void);
 extern void (*pm_power_off)(void);
 
-enum {
-	PM_SUSPEND_ON = 0,
-	PM_SUSPEND_STANDBY = 1,
-	/* NOTE: PM_SUSPEND_MEM == PCI_D3hot */
-	PM_SUSPEND_MEM = 3,
-	PM_SUSPEND_DISK = 4,
-	PM_SUSPEND_MAX = 5,
-};
-
-enum {
-	PM_DISK_FIRMWARE = 1,
-	PM_DISK_PLATFORM,
-	PM_DISK_SHUTDOWN,
-	PM_DISK_REBOOT,
-	PM_DISK_MAX,
-};
+typedef int __bitwise suspend_state_t;
 
+#define PM_SUSPEND_ON		((__force suspend_state_t) 0)
+#define PM_SUSPEND_STANDBY	((__force suspend_state_t) 1)
+#define PM_SUSPEND_MEM		((__force suspend_state_t) 3)
+#define PM_SUSPEND_DISK		((__force suspend_state_t) 4)
+#define PM_SUSPEND_MAX		((__force suspend_state_t) 5)
+
+typedef int __bitwise suspend_disk_method_t;
+
+#define	PM_DISK_FIRMWARE	((__force suspend_disk_method_t) 1)
+#define	PM_DISK_PLATFORM	((__force suspend_disk_method_t) 2)
+#define	PM_DISK_SHUTDOWN	((__force suspend_disk_method_t) 3)
+#define	PM_DISK_REBOOT		((__force suspend_disk_method_t) 4)
+#define	PM_DISK_MAX		((__force suspend_disk_method_t) 5)
 
 struct pm_ops {
-	u32	pm_disk_mode;
-	int (*prepare)(u32 state);
-	int (*enter)(u32 state);
-	int (*finish)(u32 state);
+	suspend_disk_method_t pm_disk_mode;
+	int (*prepare)(suspend_state_t state);
+	int (*enter)(suspend_state_t state);
+	int (*finish)(suspend_state_t state);
 };
 
 extern void pm_set_ops(struct pm_ops *);
 
-extern int pm_suspend(u32 state);
+extern int pm_suspend(suspend_state_t state);
 
 
 /*

--- clean/drivers/acpi/sleep/main.c	2004-10-01 00:30:09.000000000 +0200
+++ linux/drivers/acpi/sleep/main.c	2004-10-25 23:03:40.000000000 +0200
@@ -42,7 +42,7 @@
  *	wakeup code to the waking vector. 
  */
 
-static int acpi_pm_prepare(u32 pm_state)
+static int acpi_pm_prepare(suspend_state_t pm_state)
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
 
@@ -74,7 +74,7 @@
  *	It's unfortunate, but it works. Please fix if you're feeling frisky.
  */
 
-static int acpi_pm_enter(u32 pm_state)
+static int acpi_pm_enter(suspend_state_t pm_state)
 {
 	acpi_status status = AE_OK;
 	unsigned long flags = 0;
@@ -136,7 +136,7 @@
  *	failed). 
  */
 
-static int acpi_pm_finish(u32 pm_state)
+static int acpi_pm_finish(suspend_state_t pm_state)
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
 
--- clean/arch/arm/mach-pxa/pm.c	2004-10-19 14:16:27.000000000 +0200
+++ linux/arch/arm/mach-pxa/pm.c	2004-10-26 00:26:44.000000000 +0200
@@ -66,7 +66,7 @@
 };
 
 
-static int pxa_pm_enter(u32 state)
+static int pxa_pm_enter(suspend_state_t state)
 {
 	unsigned long sleep_save[SLEEP_SAVE_SIZE];
 	unsigned long checksum = 0;
@@ -182,7 +182,7 @@
 /*
  * Called after processes are frozen, but before we shut down devices.
  */
-static int pxa_pm_prepare(u32 state)
+static int pxa_pm_prepare(suspend_state_t state)
 {
 	return 0;
 }
@@ -190,7 +190,7 @@
 /*
  * Called after devices are re-setup, but before processes are thawed.
  */
-static int pxa_pm_finish(u32 state)
+static int pxa_pm_finish(suspend_state_t state)
 {
 	return 0;
 }
--- clean/arch/arm/mach-sa1100/pm.c	2004-10-19 14:16:27.000000000 +0200
+++ linux/arch/arm/mach-sa1100/pm.c	2004-10-26 00:27:12.000000000 +0200
@@ -57,7 +57,7 @@
 };
 
 
-static int sa11x0_pm_enter(u32 state)
+static int sa11x0_pm_enter(suspend_state_t state)
 {
 	unsigned long gpio, sleep_save[SLEEP_SAVE_SIZE];
 	struct timespec delta, rtc;
@@ -153,7 +153,7 @@
 /*
  * Called after processes are frozen, but before we shut down devices.
  */
-static int sa11x0_pm_prepare(u32 state)
+static int sa11x0_pm_prepare(suspend_state_t state)
 {
 	return 0;
 }
@@ -161,7 +161,7 @@
 /*
  * Called after devices are re-setup, but before processes are thawed.
  */
-static int sa11x0_pm_finish(u32 state)
+static int sa11x0_pm_finish(suspend_state_t state)
 {
 	return 0;
 }


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


[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux