mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 14:26:03 -04:00
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 f1206503e5)
This commit is contained in:
parent
33b5923a9d
commit
acfd6cea1f
1 changed files with 7 additions and 0 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue