Messages in this thread Patch in this message | | | From | Dejin Zheng <> | Subject | [PATCH v1 1/4] PCI: Introduce pcim_alloc_irq_vectors() | Date | Tue, 16 Feb 2021 02:15:47 +0800 |
| |
Introduce pcim_alloc_irq_vectors(), a explicit device-managed version of pci_alloc_irq_vectors().
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com> --- drivers/pci/pci.c | 19 +++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 22 insertions(+)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b67c4327d307..33244b512057 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2054,6 +2054,25 @@ void pcim_pin_device(struct pci_dev *pdev) } EXPORT_SYMBOL(pcim_pin_device); +/** + * pcim_alloc_irq_vectors - a device-managed pci_alloc_irq_vectors() + * + * It depends on calling pcim_enable_device() to make irq resources manageable. + */ +int pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags) +{ + struct pci_devres *dr; + + /*Ensure that the pcim_enable_device() function has been called*/ + dr = find_pci_dr(dev); + if (!dr || !dr->enabled) + return -EINVAL; + + return pci_alloc_irq_vectors(dev, min_vecs, max_vecs, flags); +} +EXPORT_SYMBOL(pcim_alloc_irq_vectors); + /* * pcibios_add_device - provide arch specific hooks when adding device dev * @dev: the PCI device being added diff --git a/include/linux/pci.h b/include/linux/pci.h index 86c799c97b77..d75ba85ddfc5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1818,6 +1818,9 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, NULL); } +int pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags); + /* Include architecture-dependent settings and functions */ #include <asm/pci.h> -- 2.25.0
| |