diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2019-12-04 13:56:56 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-12-09 10:27:35 +0100 |
commit | e0a8515dd2c21d03c90acc629da9c552760f9ab8 (patch) | |
tree | 9022c325863ca0e5d6449957e196e4c28bcbd5b0 /include/linux | |
parent | 96bd230b078264eaf165b50e6131cd10fb465d25 (diff) | |
download | barebox-e0a8515dd2c21d03c90acc629da9c552760f9ab8.tar.gz barebox-e0a8515dd2c21d03c90acc629da9c552760f9ab8.tar.xz |
PCI: copy over some Linux PCI helpers
Linux PCI drivers, like the incoming 8250_pci, make use of these
helpers. Port them over from Linux v5.4.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/pci.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index d92d70b6bd..c742570e36 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -115,6 +115,17 @@ struct pci_dev { }; #define to_pci_dev(d) container_of(d, struct pci_dev, dev) +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start) +#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end) +#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags) +#define pci_resource_len(dev,bar) \ + ((pci_resource_start((dev), (bar)) == 0 && \ + pci_resource_end((dev), (bar)) == \ + pci_resource_start((dev), (bar))) ? 0 : \ + \ + (pci_resource_end((dev), (bar)) - \ + pci_resource_start((dev), (bar)) + 1)) + enum { PCI_BUS_RESOURCE_IO = 0, PCI_BUS_RESOURCE_MEM = 1, @@ -211,6 +222,20 @@ struct pci_driver { .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID /** + * PCI_DEVICE_SUB - macro used to describe a specific PCI device with subsystem + * @vend: the 16 bit PCI Vendor ID + * @dev: the 16 bit PCI Device ID + * @subvend: the 16 bit PCI Subvendor ID + * @subdev: the 16 bit PCI Subdevice ID + * + * This macro is used to create a struct pci_device_id that matches a + * specific device with subsystem information. + */ +#define PCI_DEVICE_SUB(vend, dev, subvend, subdev) \ + .vendor = (vend), .device = (dev), \ + .subvendor = (subvend), .subdevice = (subdev) + +/** * PCI_DEVICE_CLASS - macro used to describe a specific pci device class * @dev_class: the class, subclass, prog-if triple for this device * @dev_class_mask: the class mask for this device @@ -350,4 +375,13 @@ enum pci_fixup_pass { void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); +#ifdef CONFIG_PCI +const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, + struct pci_dev *dev); +#else +static inline const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, + struct pci_dev *dev) +{ return NULL; } +#endif + #endif /* LINUX_PCI_H */ |