diff options
Diffstat (limited to 'drivers/pci/irq.c')
-rw-r--r-- | drivers/pci/irq.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c index f9f2a0324ecc..83d30953ce19 100644 --- a/drivers/pci/irq.c +++ b/drivers/pci/irq.c | |||
@@ -1,7 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * PCI IRQ failure handing code | 2 | * PCI IRQ handling code |
3 | * | 3 | * |
4 | * Copyright (c) 2008 James Bottomley <James.Bottomley@HansenPartnership.com> | 4 | * Copyright (c) 2008 James Bottomley <James.Bottomley@HansenPartnership.com> |
5 | * Copyright (C) 2017 Christoph Hellwig. | ||
5 | */ | 6 | */ |
6 | 7 | ||
7 | #include <linux/acpi.h> | 8 | #include <linux/acpi.h> |
@@ -59,3 +60,61 @@ enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *pdev) | |||
59 | return PCI_LOST_IRQ_NO_INFORMATION; | 60 | return PCI_LOST_IRQ_NO_INFORMATION; |
60 | } | 61 | } |
61 | EXPORT_SYMBOL(pci_lost_interrupt); | 62 | EXPORT_SYMBOL(pci_lost_interrupt); |
63 | |||
64 | /** | ||
65 | * pci_request_irq - allocate an interrupt line for a PCI device | ||
66 | * @dev: PCI device to operate on | ||
67 | * @nr: device-relative interrupt vector index (0-based). | ||
68 | * @handler: Function to be called when the IRQ occurs. | ||
69 | * Primary handler for threaded interrupts. | ||
70 | * If NULL and thread_fn != NULL the default primary handler is | ||
71 | * installed. | ||
72 | * @thread_fn: Function called from the IRQ handler thread | ||
73 | * If NULL, no IRQ thread is created | ||
74 | * @dev_id: Cookie passed back to the handler function | ||
75 | * @fmt: Printf-like format string naming the handler | ||
76 | * | ||
77 | * This call allocates interrupt resources and enables the interrupt line and | ||
78 | * IRQ handling. From the point this call is made @handler and @thread_fn may | ||
79 | * be invoked. All interrupts requested using this function might be shared. | ||
80 | * | ||
81 | * @dev_id must not be NULL and must be globally unique. | ||
82 | */ | ||
83 | int pci_request_irq(struct pci_dev *dev, unsigned int nr, irq_handler_t handler, | ||
84 | irq_handler_t thread_fn, void *dev_id, const char *fmt, ...) | ||
85 | { | ||
86 | va_list ap; | ||
87 | int ret; | ||
88 | char *devname; | ||
89 | |||
90 | va_start(ap, fmt); | ||
91 | devname = kvasprintf(GFP_KERNEL, fmt, ap); | ||
92 | va_end(ap); | ||
93 | |||
94 | ret = request_threaded_irq(pci_irq_vector(dev, nr), handler, thread_fn, | ||
95 | IRQF_SHARED, devname, dev_id); | ||
96 | if (ret) | ||
97 | kfree(devname); | ||
98 | return ret; | ||
99 | } | ||
100 | EXPORT_SYMBOL(pci_request_irq); | ||
101 | |||
102 | /** | ||
103 | * pci_free_irq - free an interrupt allocated with pci_request_irq | ||
104 | * @dev: PCI device to operate on | ||
105 | * @nr: device-relative interrupt vector index (0-based). | ||
106 | * @dev_id: Device identity to free | ||
107 | * | ||
108 | * Remove an interrupt handler. The handler is removed and if the interrupt | ||
109 | * line is no longer in use by any driver it is disabled. The caller must | ||
110 | * ensure the interrupt is disabled on the device before calling this function. | ||
111 | * The function does not return until any executing interrupts for this IRQ | ||
112 | * have completed. | ||
113 | * | ||
114 | * This function must not be called from interrupt context. | ||
115 | */ | ||
116 | void pci_free_irq(struct pci_dev *dev, unsigned int nr, void *dev_id) | ||
117 | { | ||
118 | kfree(free_irq(pci_irq_vector(dev, nr), dev_id)); | ||
119 | } | ||
120 | EXPORT_SYMBOL(pci_free_irq); | ||