From 94a13a99f3a472e9903f49589740fec8d4c2c30b Mon Sep 17 00:00:00 2001 From: hselasky Date: Fri, 16 Feb 2018 15:37:33 +0000 Subject: [PATCH] Implement enable_irq() and disable_irq() in the LinuxKPI. MFC after: 1 week Submitted by: Johannes Lundberg Sponsored by: Mellanox Technologies --- .../linuxkpi/common/include/linux/interrupt.h | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/interrupt.h b/sys/compat/linuxkpi/common/include/linux/interrupt.h index 6f7b96dbaa6d..e9bae5139738 100644 --- a/sys/compat/linuxkpi/common/include/linux/interrupt.h +++ b/sys/compat/linuxkpi/common/include/linux/interrupt.h @@ -111,6 +111,38 @@ request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, return 0; } +static inline int +enable_irq(unsigned int irq) +{ + struct irq_ent *irqe; + struct device *dev; + + dev = linux_pci_find_irq_dev(irq); + if (dev == NULL) + return -EINVAL; + irqe = linux_irq_ent(dev, irq); + if (irqe == NULL) + return -EINVAL; + return -bus_setup_intr(dev->bsddev, irqe->res, INTR_TYPE_NET | INTR_MPSAFE, + NULL, linux_irq_handler, irqe, &irqe->tag); +} + +static inline void +disable_irq(unsigned int irq) +{ + struct irq_ent *irqe; + struct device *dev; + + dev = linux_pci_find_irq_dev(irq); + if (dev == NULL) + return; + irqe = linux_irq_ent(dev, irq); + if (irqe == NULL) + return; + bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); + irqe->tag = NULL; +} + static inline int bind_irq_to_cpu(unsigned int irq, int cpu_id) {