diff options
| author | Vladimir Kondratyev <wulf@FreeBSD.org> | 2024-04-08 06:47:43 +0000 |
|---|---|---|
| committer | Vladimir Kondratyev <wulf@FreeBSD.org> | 2024-08-01 21:09:38 +0000 |
| commit | acfd6cea1f570baf0ec866b42f9fe56de1ec1ea9 (patch) | |
| tree | b81e79b30ba8026f205dd3e247ca110733ad16d3 | |
| parent | 33b5923a9d5af18924e162d062328d65729b86bb (diff) | |
LinuxKPI: Add pci_dev_id to linux/pci.h
It returns bus/device/function number for given PCI device.
Also add intermediate PCI_DEVID macro used in some drivers.
Sponsored by: Serenity Cyber Security, LLC
Reviewed by: emaste
MFC after: 1 week
(cherry picked from commit f1206503e5a0073f56710bfebb6e503dcf612536)
| -rw-r--r-- | sys/compat/linuxkpi/common/include/linux/pci.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 98ba160150f7..f8ee6c5600da 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -94,6 +94,7 @@ MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \ #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) #define PCI_FUNC(devfn) ((devfn) & 0x07) #define PCI_BUS_NUM(devfn) (((devfn) >> 8) & 0xff) +#define PCI_DEVID(bus, devfn) ((((uint16_t)(bus)) << 8) | (devfn)) #define PCI_VDEVICE(_vendor, _device) \ .vendor = PCI_VENDOR_ID_##_vendor, .device = (_device), \ @@ -386,6 +387,12 @@ dev_is_pci(struct device *dev) return (device_get_devclass(dev->bsddev) == devclass_find("pci")); } +static inline uint16_t +pci_dev_id(struct pci_dev *pdev) +{ + return (PCI_DEVID(pdev->bus->number, pdev->devfn)); +} + static inline int pci_resource_type(struct pci_dev *pdev, int bar) { |
