summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-12-04 13:56:56 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-12-09 10:27:35 +0100
commite0a8515dd2c21d03c90acc629da9c552760f9ab8 (patch)
tree9022c325863ca0e5d6449957e196e4c28bcbd5b0 /drivers
parent96bd230b078264eaf165b50e6131cd10fb465d25 (diff)
downloadbarebox-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 'drivers')
-rw-r--r--drivers/pci/bus.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index ac15623307..251be4fffa 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -23,6 +23,32 @@ pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev)
return NULL;
}
+/**
+ * pci_match_id - See if a pci device matches a given pci_id table
+ * @ids: array of PCI device id structures to search in
+ * @dev: the PCI device structure to match against.
+ *
+ * Used by a driver to check whether a PCI device present in the
+ * system is in its list of supported devices. Returns the matching
+ * pci_device_id structure or %NULL if there is no match.
+ *
+ * Deprecated, don't use this as it will not catch any dynamic ids
+ * that a driver might want to check for.
+ */
+const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
+ struct pci_dev *dev)
+{
+ if (ids) {
+ while (ids->vendor || ids->subvendor || ids->class_mask) {
+ if (pci_match_one_device(ids, dev))
+ return ids;
+ ids++;
+ }
+ }
+ return NULL;
+}
+EXPORT_SYMBOL(pci_match_id);
+
static int pci_match(struct device_d *dev, struct driver_d *drv)
{
struct pci_dev *pdev = to_pci_dev(dev);