Lines Matching refs:as
198 struct apm_user *as; in queue_event() local
201 list_for_each_entry(as, &apm_user_list, list) { in queue_event()
202 if (as->reader) in queue_event()
203 queue_add_event(&as->queue, event); in queue_event()
211 struct apm_user *as = fp->private_data; in apm_read() local
218 if (queue_empty(&as->queue) && fp->f_flags & O_NONBLOCK) in apm_read()
221 wait_event_interruptible(apm_waitqueue, !queue_empty(&as->queue)); in apm_read()
223 while ((i >= sizeof(event)) && !queue_empty(&as->queue)) { in apm_read()
224 event = queue_get_event(&as->queue); in apm_read()
231 if (as->suspend_state == SUSPEND_PENDING && in apm_read()
233 as->suspend_state = SUSPEND_READ; in apm_read()
248 struct apm_user *as = fp->private_data; in apm_poll() local
251 return queue_empty(&as->queue) ? 0 : POLLIN | POLLRDNORM; in apm_poll()
267 struct apm_user *as = filp->private_data; in apm_ioctl() local
270 if (!as->suser || !as->writer) in apm_ioctl()
277 as->suspend_result = -EINTR; in apm_ioctl()
279 switch (as->suspend_state) { in apm_ioctl()
286 as->suspend_state = SUSPEND_ACKED; in apm_ioctl()
304 as->suspend_state != SUSPEND_ACKED)) in apm_ioctl()
308 as->suspend_result = -ETIMEDOUT; in apm_ioctl()
312 as->suspend_state = SUSPEND_WAIT; in apm_ioctl()
320 as->suspend_result = pm_suspend(PM_SUSPEND_MEM); in apm_ioctl()
324 err = as->suspend_result; in apm_ioctl()
325 as->suspend_state = SUSPEND_NONE; in apm_ioctl()
335 struct apm_user *as = filp->private_data; in apm_release() local
340 list_del(&as->list); in apm_release()
348 if (as->suspend_state == SUSPEND_PENDING || in apm_release()
349 as->suspend_state == SUSPEND_READ) in apm_release()
355 kfree(as); in apm_release()
361 struct apm_user *as; in apm_open() local
363 as = kzalloc(sizeof(*as), GFP_KERNEL); in apm_open()
364 if (as) { in apm_open()
372 as->suser = capable(CAP_SYS_ADMIN); in apm_open()
373 as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE; in apm_open()
374 as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ; in apm_open()
377 list_add(&as->list, &apm_user_list); in apm_open()
380 filp->private_data = as; in apm_open()
383 return as ? 0 : -ENOMEM; in apm_open()
532 struct apm_user *as; in apm_suspend_notifier() local
552 list_for_each_entry(as, &apm_user_list, list) { in apm_suspend_notifier()
553 if (as->suspend_state != SUSPEND_WAIT && as->reader && in apm_suspend_notifier()
554 as->writer && as->suser) { in apm_suspend_notifier()
555 as->suspend_state = SUSPEND_PENDING; in apm_suspend_notifier()
557 queue_add_event(&as->queue, apm_event); in apm_suspend_notifier()
589 list_for_each_entry(as, &apm_user_list, list) { in apm_suspend_notifier()
590 if (as->suspend_state == SUSPEND_PENDING || in apm_suspend_notifier()
591 as->suspend_state == SUSPEND_READ) { in apm_suspend_notifier()
592 as->suspend_state = SUSPEND_ACKTO; in apm_suspend_notifier()
622 list_for_each_entry(as, &apm_user_list, list) { in apm_suspend_notifier()
623 if (as->suspend_state == SUSPEND_ACKED) { in apm_suspend_notifier()
630 as->suspend_result = 0; in apm_suspend_notifier()
631 as->suspend_state = SUSPEND_DONE; in apm_suspend_notifier()