um: virt-pci: implement pcibios_get_phb_of_node()
authorVincent Whitchurch <vincent.whitchurch@axis.com>
Fri, 20 Jan 2023 08:02:32 +0000 (09:02 +0100)
committerRichard Weinberger <richard@nod.at>
Mon, 13 Feb 2023 09:14:31 +0000 (10:14 +0100)
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>
arch/um/drivers/virt-pci.c

index 3ac220d..6884e1b 100644 (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];