Skip to content

Commit

Permalink
LinuxKPI: pci: add more functions
Browse files Browse the repository at this point in the history
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 fd1a2f3)
(cherry picked from commit 7b65e6f)
  • Loading branch information
Bjoern A. Zeeb authored and Bjoern A. Zeeb committed Feb 23, 2023
1 parent 0de7dba commit 4fa1061
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions sys/compat/linuxkpi/common/include/linux/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */

0 comments on commit 4fa1061

Please sign in to comment.