diff options
author | Tom Rini <trini@konsulko.com> | 2018-08-09 11:10:41 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-08-09 11:10:41 -0400 |
commit | b243f41f12d63d35234b25949319837e318ff9e0 (patch) | |
tree | f1161e19e75eba5acf78341006609df07a4ac482 /drivers/pci/pci-emul-uclass.c | |
parent | 9d17682a57bcc290a2584d81a47537aa0b6b17c1 (diff) | |
parent | 41d7535cba42cd88f3b04f8fbd4409e5a479076f (diff) |
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'drivers/pci/pci-emul-uclass.c')
-rw-r--r-- | drivers/pci/pci-emul-uclass.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/pci/pci-emul-uclass.c b/drivers/pci/pci-emul-uclass.c index 79e2c1420e..3822758354 100644 --- a/drivers/pci/pci-emul-uclass.c +++ b/drivers/pci/pci-emul-uclass.c @@ -11,33 +11,39 @@ #include <pci.h> #include <dm/lists.h> -struct sandbox_pci_priv { +struct sandbox_pci_emul_priv { int dev_count; }; int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn, - struct udevice **emulp) + struct udevice **containerp, struct udevice **emulp) { struct udevice *dev; int ret; - ret = pci_bus_find_devfn(bus, find_devfn, &dev); + *containerp = NULL; + ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(find_devfn), &dev); if (ret) { debug("%s: Could not find emulator for dev %x\n", __func__, find_devfn); return ret; } + *containerp = dev; - ret = device_find_first_child(dev, emulp); - if (ret) - return ret; + if (device_get_uclass_id(dev) == UCLASS_PCI_GENERIC) { + ret = device_find_first_child(dev, emulp); + if (ret) + return ret; + } else { + *emulp = dev; + } return *emulp ? 0 : -ENODEV; } static int sandbox_pci_emul_post_probe(struct udevice *dev) { - struct sandbox_pci_priv *priv = dev->uclass->priv; + struct sandbox_pci_emul_priv *priv = dev->uclass->priv; priv->dev_count++; sandbox_set_enable_pci_map(true); @@ -47,7 +53,7 @@ static int sandbox_pci_emul_post_probe(struct udevice *dev) static int sandbox_pci_emul_pre_remove(struct udevice *dev) { - struct sandbox_pci_priv *priv = dev->uclass->priv; + struct sandbox_pci_emul_priv *priv = dev->uclass->priv; priv->dev_count--; sandbox_set_enable_pci_map(priv->dev_count > 0); @@ -60,5 +66,5 @@ UCLASS_DRIVER(pci_emul) = { .name = "pci_emul", .post_probe = sandbox_pci_emul_post_probe, .pre_remove = sandbox_pci_emul_pre_remove, - .priv_auto_alloc_size = sizeof(struct sandbox_pci_priv), + .priv_auto_alloc_size = sizeof(struct sandbox_pci_emul_priv), }; |