/* klist_remove - Decrement the refcount of node and wait for it to go away.  */
void klist_remove(struct klist_node *n)
/* klist_remove - Decrement the refcount of node and wait for it to go away.  */
void klist_remove(struct klist_node *n)
{
	struct klist_waiter waiter;
	waiter.node = n;
	waiter.process = current;
	waiter.woken = 0;
	spin_lock(&klist_remove_lock);
	list_add(&waiter.list, &klist_remove_waiters);
	spin_unlock(&klist_remove_lock);
	klist_del(n);
	for (;;) {
		set_current_state(TASK_UNINTERRUPTIBLE);
		if (waiter.woken)
			break;
		schedule();
	}
	__set_current_state(TASK_RUNNING);
}