Lines Matching defs:state
261 static int __adb_suspend(struct platform_device *dev, pm_message_t state)
616 struct adbdev_state *state = (struct adbdev_state *) req->arg;
623 spin_lock_irqsave(&state->lock, flags);
624 atomic_dec(&state->n_pending);
625 if (!state->inuse) {
627 if (atomic_read(&state->n_pending) == 0) {
628 spin_unlock_irqrestore(&state->lock, flags);
629 kfree(state);
633 struct adb_request **ap = &state->completed;
638 wake_up_interruptible(&state->wait_queue);
640 spin_unlock_irqrestore(&state->lock, flags);
667 struct adbdev_state *state;
675 state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
676 if (state == 0) {
680 file->private_data = state;
681 spin_lock_init(&state->lock);
682 atomic_set(&state->n_pending, 0);
683 state->completed = NULL;
684 init_waitqueue_head(&state->wait_queue);
685 state->inuse = 1;
694 struct adbdev_state *state = file->private_data;
698 if (state) {
700 spin_lock_irqsave(&state->lock, flags);
701 if (atomic_read(&state->n_pending) == 0
702 && state->completed == NULL) {
703 spin_unlock_irqrestore(&state->lock, flags);
704 kfree(state);
706 state->inuse = 0;
707 spin_unlock_irqrestore(&state->lock, flags);
718 struct adbdev_state *state = file->private_data;
729 spin_lock_irqsave(&state->lock, flags);
730 add_wait_queue(&state->wait_queue, &wait);
734 req = state->completed;
736 state->completed = req->next;
737 else if (atomic_read(&state->n_pending) == 0)
750 spin_unlock_irqrestore(&state->lock, flags);
752 spin_lock_irqsave(&state->lock, flags);
756 remove_wait_queue(&state->wait_queue, &wait);
757 spin_unlock_irqrestore(&state->lock, flags);
776 struct adbdev_state *state = file->private_data;
791 req->arg = (void *) state;
798 atomic_inc(&state->n_pending);
817 atomic_dec(&state->n_pending);
831 atomic_dec(&state->n_pending);