ia64/xen-unstable

changeset 11992:0886fc73e787

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>
author Ian Campbell <ian.campbell@xensource.com>
date Wed Oct 25 13:58:30 2006 +0100 (2006-10-25)
parents ac6e4405ab6c
children d30a4d4ccd94
files unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h unmodified_drivers/linux-2.6/platform-pci/platform-compat.c
line diff
     1.1 --- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h	Wed Oct 25 13:58:30 2006 +0100
     1.2 +++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h	Wed Oct 25 13:58:30 2006 +0100
     1.3 @@ -33,4 +33,8 @@
     1.4  unsigned long vmalloc_to_pfn(void *addr);
     1.5  #endif
     1.6  
     1.7 +#if defined(__LINUX_COMPLETION_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
     1.8 +unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout);
     1.9  #endif
    1.10 +
    1.11 +#endif
     2.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c	Wed Oct 25 13:58:30 2006 +0100
     2.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c	Wed Oct 25 13:58:30 2006 +0100
     2.3 @@ -3,6 +3,7 @@
     2.4  
     2.5  #include <linux/mm.h>
     2.6  #include <linux/module.h>
     2.7 +#include <linux/sched.h>
     2.8  
     2.9  #include <xen/platform-compat.h>
    2.10  
    2.11 @@ -41,3 +42,34 @@ unsigned long vmalloc_to_pfn(void * vmal
    2.12  }
    2.13  EXPORT_SYMBOL(vmalloc_to_pfn);
    2.14  #endif
    2.15 +
    2.16 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
    2.17 +unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout)
    2.18 +{
    2.19 +        might_sleep();
    2.20 +
    2.21 +        spin_lock_irq(&x->wait.lock);
    2.22 +        if (!x->done) {
    2.23 +                DECLARE_WAITQUEUE(wait, current);
    2.24 +
    2.25 +                wait.flags |= WQ_FLAG_EXCLUSIVE;
    2.26 +                __add_wait_queue_tail(&x->wait, &wait);
    2.27 +                do {
    2.28 +                        __set_current_state(TASK_UNINTERRUPTIBLE);
    2.29 +                        spin_unlock_irq(&x->wait.lock);
    2.30 +                        timeout = schedule_timeout(timeout);
    2.31 +                        spin_lock_irq(&x->wait.lock);
    2.32 +                        if (!timeout) {
    2.33 +                                __remove_wait_queue(&x->wait, &wait);
    2.34 +                                goto out;
    2.35 +                        }
    2.36 +                } while (!x->done);
    2.37 +                __remove_wait_queue(&x->wait, &wait);
    2.38 +        }
    2.39 +        x->done--;
    2.40 +out:
    2.41 +        spin_unlock_irq(&x->wait.lock);
    2.42 +        return timeout;
    2.43 +}
    2.44 +EXPORT_SYMBOL(wait_for_completion_timeout);
    2.45 +#endif