diff options
Diffstat (limited to 'arch/i386/kernel/apm.c')
-rw-r--r-- | arch/i386/kernel/apm.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index d2ef0c2aa93e..003548b8735f 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c | |||
@@ -447,8 +447,7 @@ static char * apm_event_name[] = { | |||
447 | "system standby resume", | 447 | "system standby resume", |
448 | "capabilities change" | 448 | "capabilities change" |
449 | }; | 449 | }; |
450 | #define NR_APM_EVENT_NAME \ | 450 | #define NR_APM_EVENT_NAME ARRAY_SIZE(apm_event_name) |
451 | (sizeof(apm_event_name) / sizeof(apm_event_name[0])) | ||
452 | 451 | ||
453 | typedef struct lookup_t { | 452 | typedef struct lookup_t { |
454 | int key; | 453 | int key; |
@@ -479,7 +478,7 @@ static const lookup_t error_table[] = { | |||
479 | { APM_NO_ERROR, "BIOS did not set a return code" }, | 478 | { APM_NO_ERROR, "BIOS did not set a return code" }, |
480 | { APM_NOT_PRESENT, "No APM present" } | 479 | { APM_NOT_PRESENT, "No APM present" } |
481 | }; | 480 | }; |
482 | #define ERROR_COUNT (sizeof(error_table)/sizeof(lookup_t)) | 481 | #define ERROR_COUNT ARRAY_SIZE(error_table) |
483 | 482 | ||
484 | /** | 483 | /** |
485 | * apm_error - display an APM error | 484 | * apm_error - display an APM error |
@@ -770,8 +769,26 @@ static int set_system_power_state(u_short state) | |||
770 | static int apm_do_idle(void) | 769 | static int apm_do_idle(void) |
771 | { | 770 | { |
772 | u32 eax; | 771 | u32 eax; |
772 | u8 ret = 0; | ||
773 | int idled = 0; | ||
774 | int polling; | ||
775 | |||
776 | polling = test_thread_flag(TIF_POLLING_NRFLAG); | ||
777 | if (polling) { | ||
778 | clear_thread_flag(TIF_POLLING_NRFLAG); | ||
779 | smp_mb__after_clear_bit(); | ||
780 | } | ||
781 | if (!need_resched()) { | ||
782 | idled = 1; | ||
783 | ret = apm_bios_call_simple(APM_FUNC_IDLE, 0, 0, &eax); | ||
784 | } | ||
785 | if (polling) | ||
786 | set_thread_flag(TIF_POLLING_NRFLAG); | ||
787 | |||
788 | if (!idled) | ||
789 | return 0; | ||
773 | 790 | ||
774 | if (apm_bios_call_simple(APM_FUNC_IDLE, 0, 0, &eax)) { | 791 | if (ret) { |
775 | static unsigned long t; | 792 | static unsigned long t; |
776 | 793 | ||
777 | /* This always fails on some SMP boards running UP kernels. | 794 | /* This always fails on some SMP boards running UP kernels. |