/* Sets current thread back to running state and removes the wait descriptor from the given waitqueue if still queued.  */
void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
/* Sets current thread back to running state and removes the wait descriptor from the given waitqueue if still queued.  */
void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
{
	unsigned long flags;
	__set_current_state(TASK_RUNNING);
	if (!list_empty_careful(&wait->task_list)) {
		spin_lock_irqsave(&q->lock, flags);
		list_del_init(&wait->task_list);
		spin_unlock_irqrestore(&q->lock, flags);
	}
}