Merge tag 'cxl-for-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
[linux-2.6-microblaze.git] / drivers / cxl / acpi.c
index 8ae8927..54e9d4d 100644 (file)
@@ -243,6 +243,9 @@ static struct acpi_device *to_cxl_host_bridge(struct device *dev)
 {
        struct acpi_device *adev = to_acpi_device(dev);
 
+       if (!acpi_pci_find_root(adev->handle))
+               return NULL;
+
        if (strcmp(acpi_device_hid(adev), "ACPI0016") == 0)
                return adev;
        return NULL;
@@ -266,10 +269,6 @@ static int add_host_bridge_uport(struct device *match, void *arg)
        if (!bridge)
                return 0;
 
-       pci_root = acpi_pci_find_root(bridge->handle);
-       if (!pci_root)
-               return -ENXIO;
-
        dport = find_dport_by_dev(root_port, match);
        if (!dport) {
                dev_dbg(host, "host bridge expected and not found\n");
@@ -282,6 +281,11 @@ static int add_host_bridge_uport(struct device *match, void *arg)
                return PTR_ERR(port);
        dev_dbg(host, "%s: add: %s\n", dev_name(match), dev_name(&port->dev));
 
+       /*
+        * Note that this lookup already succeeded in
+        * to_cxl_host_bridge(), so no need to check for failure here
+        */
+       pci_root = acpi_pci_find_root(bridge->handle);
        ctx = (struct cxl_walk_context){
                .dev = host,
                .root = pci_root->bus,