From 4fa10614c77369ae4edd09a065a70fd20e526d43 Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Sat, 28 Jan 2023 15:02:51 +0000 Subject: [PATCH] LinuxKPI: pci: add more functions Add a dummy pci_assign_resource() and an implementation of pci_irq_vector() returning the irq for MSI-X, MSI, and legacy interrupt. Both are needed by wirless drivers. Sponsored by: The FreeBSD Foundation Reviewed by: jhb Approved by: re (cperciva) Differential Revision: https://reviews.freebsd.org/D38237 (cherry picked from commit fd1a2f3dfc0e8fb20d0d397d586000bb918aab47) (cherry picked from commit 7b65e6f377ca0005a986c59f1e31a0421d92660f) --- .../linuxkpi/common/include/linux/pci.h | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 5e028774f079b0..3d43595df0472c 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -1694,4 +1694,30 @@ pci_is_enabled(struct pci_dev *pdev) PCIM_CMD_BUSMASTEREN) != 0); } +static inline int +pci_assign_resource(struct pci_dev *pdev, int bar) +{ + + return (0); +} + +static inline int +pci_irq_vector(struct pci_dev *pdev, unsigned int vector) +{ + + if (!pdev->msix_enabled && !pdev->msi_enabled) { + if (vector != 0) + return (-EINVAL); + return (pdev->irq); + } + + if (pdev->msix_enabled || pdev->msi_enabled) { + if ((pdev->dev.irq_start + vector) >= pdev->dev.irq_end) + return (-EINVAL); + return (pdev->dev.irq_start + vector); + } + + return (-ENXIO); +} + #endif /* _LINUXKPI_LINUX_PCI_H_ */