PV-on-HVM: Implement compatibilty version of wait_for_completion_timeout

for kernels before 2.6.11

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
This commit is contained in:
Ian Campbell committed 2006-10-25 13:58:30 +01:00
1 parent 5a246a6332
commit e46b787ee3
2 files changed
+36

No files matched your search

@@ -33,4 +33,8 @@
unsigned long vmalloc_to_pfn(void *addr);
#endif
#if defined(__LINUX_COMPLETION_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout);
#endif
#endif
@@ -3,6 +3,7 @@
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <xen/platform-compat.h>
@@ -41,3 +42,34 @@ unsigned long vmalloc_to_pfn(void * vmalloc_addr)
}
EXPORT_SYMBOL(vmalloc_to_pfn);
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout)
{
might_sleep();
spin_lock_irq(&x->wait.lock);
if (!x->done) {
DECLARE_WAITQUEUE(wait, current);
wait.flags |= WQ_FLAG_EXCLUSIVE;
__add_wait_queue_tail(&x->wait, &wait);
do {
__set_current_state(TASK_UNINTERRUPTIBLE);
spin_unlock_irq(&x->wait.lock);
timeout = schedule_timeout(timeout);
spin_lock_irq(&x->wait.lock);
if (!timeout) {
__remove_wait_queue(&x->wait, &wait);
goto out;
}
} while (!x->done);
__remove_wait_queue(&x->wait, &wait);
}
x->done--;
out:
spin_unlock_irq(&x->wait.lock);
return timeout;
}
EXPORT_SYMBOL(wait_for_completion_timeout);
#endif
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.