Lines Matching refs:as

192 	struct apm_user *as;  in queue_event()  local
195 list_for_each_entry(as, &apm_user_list, list) { in queue_event()
196 if (as->reader) in queue_event()
197 queue_add_event(&as->queue, event); in queue_event()
205 struct apm_user *as = fp->private_data; in apm_read() local
212 if (queue_empty(&as->queue) && fp->f_flags & O_NONBLOCK) in apm_read()
215 wait_event_interruptible(apm_waitqueue, !queue_empty(&as->queue)); in apm_read()
217 while ((i >= sizeof(event)) && !queue_empty(&as->queue)) { in apm_read()
218 event = queue_get_event(&as->queue); in apm_read()
225 if (as->suspend_state == SUSPEND_PENDING && in apm_read()
227 as->suspend_state = SUSPEND_READ; in apm_read()
242 struct apm_user *as = fp->private_data; in apm_poll() local
245 return queue_empty(&as->queue) ? 0 : EPOLLIN | EPOLLRDNORM; in apm_poll()
261 struct apm_user *as = filp->private_data; in apm_ioctl() local
264 if (!as->suser || !as->writer) in apm_ioctl()
271 as->suspend_result = -EINTR; in apm_ioctl()
273 switch (as->suspend_state) { in apm_ioctl()
280 as->suspend_state = SUSPEND_ACKED; in apm_ioctl()
298 as->suspend_state != SUSPEND_ACKED)) in apm_ioctl()
302 as->suspend_result = -ETIMEDOUT; in apm_ioctl()
306 as->suspend_state = SUSPEND_WAIT; in apm_ioctl()
314 as->suspend_result = pm_suspend(PM_SUSPEND_MEM); in apm_ioctl()
318 err = as->suspend_result; in apm_ioctl()
319 as->suspend_state = SUSPEND_NONE; in apm_ioctl()
329 struct apm_user *as = filp->private_data; in apm_release() local
334 list_del(&as->list); in apm_release()
342 if (as->suspend_state == SUSPEND_PENDING || in apm_release()
343 as->suspend_state == SUSPEND_READ) in apm_release()
349 kfree(as); in apm_release()
355 struct apm_user *as; in apm_open() local
357 as = kzalloc(sizeof(*as), GFP_KERNEL); in apm_open()
358 if (as) { in apm_open()
366 as->suser = capable(CAP_SYS_ADMIN); in apm_open()
367 as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE; in apm_open()
368 as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ; in apm_open()
371 list_add(&as->list, &apm_user_list); in apm_open()
374 filp->private_data = as; in apm_open()
377 return as ? 0 : -ENOMEM; in apm_open()
513 struct apm_user *as; in apm_suspend_notifier() local
533 list_for_each_entry(as, &apm_user_list, list) { in apm_suspend_notifier()
534 if (as->suspend_state != SUSPEND_WAIT && as->reader && in apm_suspend_notifier()
535 as->writer && as->suser) { in apm_suspend_notifier()
536 as->suspend_state = SUSPEND_PENDING; in apm_suspend_notifier()
538 queue_add_event(&as->queue, apm_event); in apm_suspend_notifier()
570 list_for_each_entry(as, &apm_user_list, list) { in apm_suspend_notifier()
571 if (as->suspend_state == SUSPEND_PENDING || in apm_suspend_notifier()
572 as->suspend_state == SUSPEND_READ) { in apm_suspend_notifier()
573 as->suspend_state = SUSPEND_ACKTO; in apm_suspend_notifier()
603 list_for_each_entry(as, &apm_user_list, list) { in apm_suspend_notifier()
604 if (as->suspend_state == SUSPEND_ACKED) { in apm_suspend_notifier()
611 as->suspend_result = 0; in apm_suspend_notifier()
612 as->suspend_state = SUSPEND_DONE; in apm_suspend_notifier()