From: Chris Wright <chr...@sous-sol.org>

The irq handler changes (introduced in 2.6.19, not 2.6.20) dropped
struct pt_regs from the handler prototype, they are found globally now.
This introduces the back compat for older kernels.  The handler is just
a thin layer which calls the real registered handler (all this to work
around a minor little compiler warning ;-)  Needed for device assignment
on older kernels.

Signed-off-by: Chris Wright <chr...@redhat.com>
Signed-off-by: Avi Kivity <a...@redhat.com>

diff --git a/external-module-compat-comm.h b/external-module-compat-comm.h
index c955927..8cb5440 100644
--- a/external-module-compat-comm.h
+++ b/external-module-compat-comm.h
@@ -641,19 +641,41 @@ static inline int pci_reset_function(struct pci_dev *dev)
 #endif
 
 #include <linux/interrupt.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+
+typedef irqreturn_t (*kvm_irq_handler_t)(int, void *);
+static kvm_irq_handler_t kvm_irq_handlers[NR_IRQS];
+
+static irqreturn_t kvm_irq_thunk(int irq, void *dev_id, struct pt_regs *regs)
+{
+       kvm_irq_handler_t handler = kvm_irq_handlers[irq];
+       return handler(irq, dev_id);
+}
 
-typedef irqreturn_t (*kvm_irq_handler_t)(int, void *, struct pt_regs *);
 static inline int kvm_request_irq(unsigned int a, kvm_irq_handler_t handler,
                                  unsigned long c, const char *d, void *e)
 {
-       /* FIXME: allocate thunk, etc. */
-       return -EINVAL;
+       int rc;
+       kvm_irq_handler_t old = kvm_irq_handlers[a];
+       if (old)
+               return -EBUSY;
+       kvm_irq_handlers[a] = handler;
+       rc = request_irq(a, kvm_irq_thunk, c, d, e);
+       if (rc)
+               kvm_irq_handlers[a] = NULL;
+       return rc;
+}
+
+static inline void kvm_free_irq(unsigned int irq, void *dev_id)
+{
+       free_irq(irq, dev_id);
+       kvm_irq_handlers[irq] = NULL;
 }
 
 #else
 
 #define kvm_request_irq request_irq
+#define kvm_free_irq free_irq
 
 #endif
 
diff --git a/ia64/hack-module.awk b/ia64/hack-module.awk
index 2e4e05f..dda3347 100644
--- a/ia64/hack-module.awk
+++ b/ia64/hack-module.awk
@@ -2,7 +2,7 @@ BEGIN { split("INIT_WORK on_each_cpu smp_call_function " \
              "hrtimer_add_expires_ns hrtimer_get_expires " \
              "hrtimer_get_expires_ns hrtimer_start_expires " \
              "hrtimer_expires_remaining " \
-             "request_irq", compat_apis); }
+             "request_irq free_irq", compat_apis); }
 
 /MODULE_AUTHOR/ {
     printf("MODULE_INFO(version, \"%s\");\n", version)
diff --git a/x86/hack-module.awk b/x86/hack-module.awk
index 260eeef..bdb873a 100644
--- a/x86/hack-module.awk
+++ b/x86/hack-module.awk
@@ -2,7 +2,7 @@ BEGIN { split("INIT_WORK desc_struct ldttss_desc64 desc_ptr " \
              "hrtimer_add_expires_ns hrtimer_get_expires " \
              "hrtimer_get_expires_ns hrtimer_start_expires " \
              "hrtimer_expires_remaining " \
-             "on_each_cpu relay_open request_irq" , compat_apis); }
+             "on_each_cpu relay_open request_irq free_irq" , compat_apis); }
 
 /^int kvm_init\(/ { anon_inodes = 1 }
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to