um: virt-pci: implement pcibios_get_phb_of_node()

Implement pcibios_get_phb_of_node() as x86 does in order to allow PCI
busses to be associated with devicetree nodes.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
Vincent Whitchurch 2023-01-20 09:02:32 +01:00 committed by Richard Weinberger
parent 83e913f52a
commit 314a1408b7
1 changed files with 19 additions and 0 deletions

View File

@ -533,6 +533,25 @@ static void um_pci_irq_vq_cb(struct virtqueue *vq)
}
}
/* Copied from arch/x86/kernel/devicetree.c */
struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
{
struct device_node *np;
for_each_node_by_type(np, "pci") {
const void *prop;
unsigned int bus_min;
prop = of_get_property(np, "bus-range", NULL);
if (!prop)
continue;
bus_min = be32_to_cpup(prop);
if (bus->number == bus_min)
return np;
}
return NULL;
}
static int um_pci_init_vqs(struct um_pci_device *dev)
{
struct virtqueue *vqs[2];