![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0 0002 /* 0003 * PCI IRQ handling code 0004 * 0005 * Copyright (c) 2008 James Bottomley <James.Bottomley@HansenPartnership.com> 0006 * Copyright (C) 2017 Christoph Hellwig. 0007 */ 0008 0009 #include <linux/device.h> 0010 #include <linux/kernel.h> 0011 #include <linux/export.h> 0012 #include <linux/pci.h> 0013 0014 /** 0015 * pci_request_irq - allocate an interrupt line for a PCI device 0016 * @dev: PCI device to operate on 0017 * @nr: device-relative interrupt vector index (0-based). 0018 * @handler: Function to be called when the IRQ occurs. 0019 * Primary handler for threaded interrupts. 0020 * If NULL and thread_fn != NULL the default primary handler is 0021 * installed. 0022 * @thread_fn: Function called from the IRQ handler thread 0023 * If NULL, no IRQ thread is created 0024 * @dev_id: Cookie passed back to the handler function 0025 * @fmt: Printf-like format string naming the handler 0026 * 0027 * This call allocates interrupt resources and enables the interrupt line and 0028 * IRQ handling. From the point this call is made @handler and @thread_fn may 0029 * be invoked. All interrupts requested using this function might be shared. 0030 * 0031 * @dev_id must not be NULL and must be globally unique. 0032 */ 0033 int pci_request_irq(struct pci_dev *dev, unsigned int nr, irq_handler_t handler, 0034 irq_handler_t thread_fn, void *dev_id, const char *fmt, ...) 0035 { 0036 va_list ap; 0037 int ret; 0038 char *devname; 0039 unsigned long irqflags = IRQF_SHARED; 0040 0041 if (!handler) 0042 irqflags |= IRQF_ONESHOT; 0043 0044 va_start(ap, fmt); 0045 devname = kvasprintf(GFP_KERNEL, fmt, ap); 0046 va_end(ap); 0047 0048 ret = request_threaded_irq(pci_irq_vector(dev, nr), handler, thread_fn, 0049 irqflags, devname, dev_id); 0050 if (ret) 0051 kfree(devname); 0052 return ret; 0053 } 0054 EXPORT_SYMBOL(pci_request_irq); 0055 0056 /** 0057 * pci_free_irq - free an interrupt allocated with pci_request_irq 0058 * @dev: PCI device to operate on 0059 * @nr: device-relative interrupt vector index (0-based). 0060 * @dev_id: Device identity to free 0061 * 0062 * Remove an interrupt handler. The handler is removed and if the interrupt 0063 * line is no longer in use by any driver it is disabled. The caller must 0064 * ensure the interrupt is disabled on the device before calling this function. 0065 * The function does not return until any executing interrupts for this IRQ 0066 * have completed. 0067 * 0068 * This function must not be called from interrupt context. 0069 */ 0070 void pci_free_irq(struct pci_dev *dev, unsigned int nr, void *dev_id) 0071 { 0072 kfree(free_irq(pci_irq_vector(dev, nr), dev_id)); 0073 } 0074 EXPORT_SYMBOL(pci_free_irq);
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |