/* The spin_unlock() itself is semi-permeable and only protects one way (it only protects stuff inside the critical region and stops them from bleeding out - it would still allow subsequent loads to move into the critical region).  */
void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
/* The spin_unlock() itself is semi-permeable and only protects one way (it only protects stuff inside the critical region and stops them from bleeding out - it would still allow subsequent loads to move into the critical region).  */
void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
{
	unsigned long flags;
	wait->flags &= ~WQ_FLAG_EXCLUSIVE;
	spin_lock_irqsave(&q->lock, flags);
	if (list_empty(&wait->task_list))
		__add_wait_queue(q, wait);
	set_current_state(state);
	spin_unlock_irqrestore(&q->lock, flags);
}