git: f1206503e5a0 - main - LinuxKPI: Add pci_dev_id to linux/pci.h
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Apr 2024 06:49:18 UTC
The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=f1206503e5a0073f56710bfebb6e503dcf612536 commit f1206503e5a0073f56710bfebb6e503dcf612536 Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2024-04-08 06:47:43 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2024-04-08 06:47:43 +0000 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 --- sys/compat/linuxkpi/common/include/linux/pci.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 9c7e39bf4a42..bf69846f06f0 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), \ @@ -384,6 +385,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) {