aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@xensource.com>2006-10-25 13:58:30 +0100
committerIan Campbell <ian.campbell@xensource.com>2006-10-25 13:58:30 +0100
commite46b787ee33cfbec5438c60ada2014184bf0abf0 (patch)
tree9ca7578f2ffc392434d28d294544f7dfa28f0e2d
parent5a246a63328b8768b0270490281c9945bb124fd5 (diff)
downloadxen-e46b787ee33cfbec5438c60ada2014184bf0abf0.tar.gz
xen-e46b787ee33cfbec5438c60ada2014184bf0abf0.tar.bz2
xen-e46b787ee33cfbec5438c60ada2014184bf0abf0.zip
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>
-rw-r--r--unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h4
-rw-r--r--unmodified_drivers/linux-2.6/platform-pci/platform-compat.c32
2 files changed, 36 insertions, 0 deletions
diff --git a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h
index 185a97449c..1026f97653 100644
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h
@@ -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
diff --git a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c
index b79006bc21..f13d54b15c 100644
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c
@@ -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