--- sharpsl_apm.c-original 2005-09-07 02:38:21.000000000 -0600 +++ sharpsl_apm.c 2005-09-08 01:11:56.000000000 -0600 @@ -89,6 +89,7 @@ #include #include #include +#include /* blc */ #include #include #include @@ -155,6 +156,7 @@ /// ioctl #if defined(CONFIG_ARCH_PXA_POODLE) || defined(CONFIG_ARCH_PXA_CORGI) || defined(CONFIG_ARCH_PXA_TOSA) static u32 apm_event_mask = (APM_EVT_POWER_BUTTON); +extern kbd_keyinfo sharppda_kbdstate[(NR_KEYCODES+1)]; #else static u32 apm_event_mask = (APM_EVT_POWER_BUTTON | APM_EVT_BATTERY_STATUS); #endif @@ -472,7 +474,7 @@ if (irq == IRQ_GPIO_ON_KEY) { /* suspend */ DPRINTK("irq=%d count=%d sharpsl_suspend_request%d\n",irq, count, sharpsl_suspend_request); - if ( GPLR(GPIO_ON_KEY) & GPIO_bit(GPIO_ON_KEY) ) { + if ( GPLR(GPIO_ON_KEY) & GPIO_bit(GPIO_ON_KEY) || (!sharppda_kbdstate[1].in) ) { /* second half, if something other than cancel is pushed blc */ /* release */ count = 0; } else { @@ -1876,10 +1878,11 @@ switch (event) { case APM_SYS_STANDBY: case APM_USER_STANDBY: - if (send_event(event)) { - queue_event(event, NULL); - if (standbys_pending <= 0) + queue_event(event, NULL); + if (standbys_pending <= 0) { + if (send_event(event)) { standby(); + } } break; @@ -1907,12 +1910,11 @@ */ if (waiting_for_resume) return; - if (send_event(event)) { - queue_event(event, NULL); - waiting_for_resume = 1; - if (suspends_pending <= 0){ + queue_event(event, NULL); + waiting_for_resume = 1; + if (suspends_pending <= 0) + if (send_event(event)) { (void) suspend(); - } } break; @@ -2225,26 +2227,32 @@ as->standbys_read--; as->standbys_pending--; standbys_pending--; - } else if (!send_event(APM_USER_STANDBY)) - return -EAGAIN; - else + } else { queue_event(APM_USER_STANDBY, as); - if (standbys_pending <= 0) - standby(); + } + if (standbys_pending <= 0) { + if (send_event(APM_USER_STANDBY)) { + standby(); + } else { + return -EAGAIN; + } + } break; case APM_IOC_SUSPEND: if (as->suspends_read > 0) { as->suspends_read--; as->suspends_pending--; suspends_pending--; - } else if (!send_event(APM_USER_SUSPEND)) - return -EAGAIN; - else + } else { queue_event(APM_USER_SUSPEND, as); + } if (suspends_pending <= 0) { - - if (suspend() != APM_SUCCESS) - return -EIO; + if (send_event(APM_USER_SUSPEND)) { + if (suspend() != APM_SUCCESS) + return -EIO; + } else { + return -EAGAIN; + } } else { as->suspend_wait = 1; add_wait_queue(&apm_suspend_waitqueue, &wait); @@ -2483,13 +2491,18 @@ lock_kernel(); if (as->standbys_pending > 0) { standbys_pending -= as->standbys_pending; - if (standbys_pending <= 0) - standby(); + if (standbys_pending <= 0) { + if (send_event(APM_USER_STANDBY)) { + standby(); + } + } } if (as->suspends_pending > 0) { suspends_pending -= as->suspends_pending; - if (suspends_pending <= 0){ - (void) suspend(); + if (suspends_pending <= 0) { + if (send_event(APM_USER_SUSPEND)) { + (void) suspend(); + } } } if (user_list == as)