From: Pavel Machek 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. Signed-off-by: Andrew Morton --- 25-akpm/arch/arm/mach-pxa/pm.c | 6 ++--- 25-akpm/arch/arm/mach-sa1100/pm.c | 6 ++--- 25-akpm/drivers/acpi/sleep/main.c | 6 ++--- 25-akpm/include/linux/pm.h | 40 ++++++++++++++++++-------------------- 25-akpm/kernel/power/disk.c | 5 ++-- 25-akpm/kernel/power/main.c | 12 +++++------ 6 files changed, 37 insertions(+), 38 deletions(-) diff -puN arch/arm/mach-pxa/pm.c~add-typechecking-to-suspend-types-and-powerdown-types arch/arm/mach-pxa/pm.c --- 25/arch/arm/mach-pxa/pm.c~add-typechecking-to-suspend-types-and-powerdown-types 2004-10-26 01:09:35.931622432 -0700 +++ 25-akpm/arch/arm/mach-pxa/pm.c 2004-10-26 01:09:35.945620304 -0700 @@ -63,7 +63,7 @@ enum { SLEEP_SAVE_START = 0, }; -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; @@ -163,7 +163,7 @@ unsigned long sleep_phys_sp(void *sp) /* * 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; } @@ -171,7 +171,7 @@ static int pxa_pm_prepare(u32 state) /* * 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; } diff -puN arch/arm/mach-sa1100/pm.c~add-typechecking-to-suspend-types-and-powerdown-types arch/arm/mach-sa1100/pm.c --- 25/arch/arm/mach-sa1100/pm.c~add-typechecking-to-suspend-types-and-powerdown-types 2004-10-26 01:09:35.933622128 -0700 +++ 25-akpm/arch/arm/mach-sa1100/pm.c 2004-10-26 01:09:35.945620304 -0700 @@ -54,7 +54,7 @@ enum { SLEEP_SAVE_SP = 0, }; -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; @@ -135,7 +135,7 @@ unsigned long sleep_phys_sp(void *sp) /* * 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; } @@ -143,7 +143,7 @@ static int sa11x0_pm_prepare(u32 state) /* * 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; } diff -puN drivers/acpi/sleep/main.c~add-typechecking-to-suspend-types-and-powerdown-types drivers/acpi/sleep/main.c --- 25/drivers/acpi/sleep/main.c~add-typechecking-to-suspend-types-and-powerdown-types 2004-10-26 01:09:35.934621976 -0700 +++ 25-akpm/drivers/acpi/sleep/main.c 2004-10-26 01:09:35.944620456 -0700 @@ -44,7 +44,7 @@ static int init_8259A_after_S1; * 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]; @@ -77,7 +77,7 @@ static int acpi_pm_prepare(u32 pm_state) * 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; @@ -139,7 +139,7 @@ static int acpi_pm_enter(u32 pm_state) * 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]; diff -puN include/linux/pm.h~add-typechecking-to-suspend-types-and-powerdown-types include/linux/pm.h --- 25/include/linux/pm.h~add-typechecking-to-suspend-types-and-powerdown-types 2004-10-26 01:09:35.936621672 -0700 +++ 25-akpm/include/linux/pm.h 2004-10-26 01:09:35.944620456 -0700 @@ -167,34 +167,32 @@ static inline void pm_dev_idle(struct pm 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); /* diff -puN kernel/power/disk.c~add-typechecking-to-suspend-types-and-powerdown-types kernel/power/disk.c --- 25/kernel/power/disk.c~add-typechecking-to-suspend-types-and-powerdown-types 2004-10-26 01:09:35.938621368 -0700 +++ 25-akpm/kernel/power/disk.c 2004-10-26 01:09:35.943620608 -0700 @@ -16,10 +16,11 @@ #include #include #include +#include #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); @@ -293,7 +294,7 @@ static ssize_t disk_store(struct subsyst 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; diff -puN kernel/power/main.c~add-typechecking-to-suspend-types-and-powerdown-types kernel/power/main.c --- 25/kernel/power/main.c~add-typechecking-to-suspend-types-and-powerdown-types 2004-10-26 01:09:35.939621216 -0700 +++ 25-akpm/kernel/power/main.c 2004-10-26 01:09:35.943620608 -0700 @@ -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 @@ void pm_set_ops(struct pm_ops * ops) * 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 +102,7 @@ static int suspend_enter(u32 state) * 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 +133,7 @@ char * pm_states[] = { * we've woken up). */ -static int enter_state(u32 state) +static int enter_state(suspend_state_t state) { int error; @@ -183,7 +183,7 @@ int software_suspend(void) * 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 +221,7 @@ static ssize_t state_show(struct subsyst 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; _