diff options
Diffstat (limited to 'drivers/pci/bus.c')
-rw-r--r-- | drivers/pci/bus.c | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index ac15623307..37bdc9a22f 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -1,7 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-only #include <common.h> #include <init.h> #include <driver.h> #include <linux/pci.h> +#include <linux/resource_ext.h> + +void pci_add_resource_offset(struct list_head *resources, struct resource *res, + resource_size_t offset) +{ + struct resource_entry *entry; + + entry = resource_list_create_entry(res, 0); + if (!entry) { + pr_err("PCI: can't add host bridge window %pR\n", res); + return; + } + entry->offset = offset; + + resource_list_add_tail(entry, resources); +} +EXPORT_SYMBOL(pci_add_resource_offset); + +void pci_add_resource(struct list_head *resources, struct resource *res) +{ + pci_add_resource_offset(resources, res, 0); +} +EXPORT_SYMBOL(pci_add_resource); /** * pci_match_one_device - Tell if a PCI device structure has a matching @@ -23,7 +47,33 @@ pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev) return NULL; } -static int pci_match(struct device_d *dev, struct driver_d *drv) +/** + * 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 *dev, struct driver *drv) { struct pci_dev *pdev = to_pci_dev(dev); struct pci_driver *pdrv = to_pci_driver(drv); @@ -38,7 +88,7 @@ static int pci_match(struct device_d *dev, struct driver_d *drv) return -1; } -static int pci_probe(struct device_d *dev) +static int pci_probe(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct pci_driver *pdrv = to_pci_driver(dev->driver); @@ -46,7 +96,7 @@ static int pci_probe(struct device_d *dev) return pdrv->probe(pdev, pdev->id); } -static void pci_remove(struct device_d *dev) +static void pci_remove(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct pci_driver *pdrv = to_pci_driver(dev->driver); @@ -70,7 +120,7 @@ pure_initcall(pci_bus_init); int pci_register_driver(struct pci_driver *pdrv) { - struct driver_d *drv = &pdrv->driver; + struct driver *drv = &pdrv->driver; if (!pdrv->id_table) return -EIO; @@ -84,9 +134,12 @@ int pci_register_driver(struct pci_driver *pdrv) int pci_register_device(struct pci_dev *pdev) { char str[6]; - struct device_d *dev = &pdev->dev; + struct device *dev = &pdev->dev; int ret; + if (!of_device_is_available(pdev->dev.of_node)) + return 0; + dev_set_name(dev, "pci-%04x:%04x.", pdev->vendor, pdev->device); dev->bus = &pci_bus; dev->id = DEVICE_ID_DYNAMIC; |