# # Patch managed by http://www.holgerschurig.de/patcher.html # --- linux/arch/arm/mach-pxa/sharpsl_apm.c~fix_tosa_apm.patch +++ linux/arch/arm/mach-pxa/sharpsl_apm.c @@ -254,6 +254,8 @@ int magic; struct apm_user * next; int suser: 1; + int reader: 1; + int writer: 1; int suspend_wait: 1; int suspend_result; int suspends_pending; @@ -1596,12 +1598,12 @@ { struct apm_user * as; - DPRINTK("event=%d\n",event); + DPRINTK("event=%d, sender=%p\n",event,sender); if (user_list == NULL) return; for (as = user_list; as != NULL; as = as->next) { - if (as == sender) + if ((as == sender) || (!as->reader)) continue; as->event_head = (as->event_head + 1) % APM_MAX_EVENTS; if (as->event_head == as->event_tail) { @@ -1611,8 +1613,8 @@ as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS; } as->events[as->event_head] = event; - if (!as->suser) - continue; + if ((!as->suser) || (!as->writer)) + continue; switch (event) { case APM_SYS_SUSPEND: case APM_USER_SUSPEND: @@ -1630,9 +1632,8 @@ #ifdef SHARPSL_NEW_IDLE current->nice = save_nice; current->counter = save_counter; -#else - wake_up_interruptible(&apm_waitqueue); #endif + wake_up_interruptible(&apm_waitqueue); } static unsigned long get_cmos_time(void) @@ -2532,6 +2533,8 @@ * privileged operation -- cevans */ as->suser = capable(CAP_SYS_ADMIN); + as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE; + as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ; as->next = user_list; user_list = as; filp->private_data = as; @@ -3000,6 +3003,9 @@ #endif #endif + suspends_pending = 0; + standbys_pending = 0; + apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info); if (apm_proc) SET_MODULE_OWNER(apm_proc);