summaryrefslogtreecommitdiff
path: root/drivers/pci/msi/api.c
diff options
context:
space:
mode:
authorAhmed S. Darwish <darwi@linutronix.de>2022-11-11 16:54:53 +0300
committerThomas Gleixner <tglx@linutronix.de>2022-11-17 17:15:21 +0300
commit017239c8db209307d2acfc0f9a3b104c39f911b3 (patch)
treeb60ca123d467970c35592102705a5eb810e062bf /drivers/pci/msi/api.c
parentbeddb5efb43ee5b1c048e49225f75b03f8d36aac (diff)
downloadlinux-017239c8db209307d2acfc0f9a3b104c39f911b3.tar.xz
PCI/MSI: Move pci_irq_vector() to api.c
To disentangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_irq_vector() and let its kernel-doc match the rest of the file. Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/r/20221111122014.984490384@linutronix.de
Diffstat (limited to 'drivers/pci/msi/api.c')
-rw-r--r--drivers/pci/msi/api.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c
index 8546749afa6e..0f1ec87e3f9f 100644
--- a/drivers/pci/msi/api.c
+++ b/drivers/pci/msi/api.c
@@ -182,3 +182,26 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
return nvecs;
}
EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity);
+
+/**
+ * pci_irq_vector() - Get Linux IRQ number of a device interrupt vector
+ * @dev: the PCI device to operate on
+ * @nr: device-relative interrupt vector index (0-based); has different
+ * meanings, depending on interrupt mode
+ * MSI-X the index in the MSI-X vector table
+ * MSI the index of the enabled MSI vectors
+ * INTx must be 0
+ *
+ * Return: the Linux IRQ number, or -EINVAL if @nr is out of range
+ */
+int pci_irq_vector(struct pci_dev *dev, unsigned int nr)
+{
+ unsigned int irq;
+
+ if (!dev->msi_enabled && !dev->msix_enabled)
+ return !nr ? dev->irq : -EINVAL;
+
+ irq = msi_get_virq(&dev->dev, nr);
+ return irq ? irq : -EINVAL;
+}
+EXPORT_SYMBOL(pci_irq_vector);