OSDN Git Service

Fix another buggy fake acpi pci root driver
authorPeter Jones <pjones@redhat.com>
Mon, 10 Sep 2018 19:00:03 +0000 (15:00 -0400)
committerPeter Jones <pjones@redhat.com>
Mon, 10 Sep 2018 19:02:23 +0000 (15:02 -0400)
In this case, the platform driver that creates the PCI(e) root device
doesn't fill in its driver link, so we can't look up what driver is in
use - but since it's the root, it *really* doesn't matter.  And in
general, we only really care if it's the last node in our path, because
that'll be the controller for the boot device anyway.

Signed-off-by: Peter Jones <pjones@redhat.com>
src/linux-pci.c

index e7c864b..f63f591 100644 (file)
@@ -67,7 +67,9 @@ parse_pci(struct device *dev, const char *current, const char *root)
                 uint8_t bus, device, function;
                 struct pci_dev_info *pci_dev;
                 unsigned int i = dev->n_pci_devs;
+                struct stat statbuf;
 
+                debug("devpart is \"%s\"", devpart);
                 pos = 0;
                 debug("searching for 0000:00:00.0/");
                 rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n",
@@ -100,15 +102,23 @@ parse_pci(struct device *dev, const char *current, const char *root)
                         return -1;
                 }
                 tmp[devpart - root] = '\0';
-                rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp);
-                if (rc < 0 || !linkbuf) {
-                        efi_error("Could not find driver for pci device %s", tmp);
-                        free(tmp);
-                        return -1;
+                rc = sysfs_stat(&statbuf, "class/block/%s/driver", tmp);
+                if (rc < 0 && errno == ENOENT) {
+                        debug("No driver link for /sys/class/block/%s", tmp);
+                        debug("Assuming this is just a buggy platform core driver");
+                        dev->pci_dev[i].driverlink = NULL;
+                } else {
+                        rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp);
+                        if (rc < 0 || !linkbuf) {
+                                efi_error("Could not find driver for pci device %s", tmp);
+                                free(tmp);
+                                return -1;
+                        } else {
+                                dev->pci_dev[i].driverlink = strdup(linkbuf);
+                                debug("driver:%s\n", linkbuf);
+                        }
                 }
                 free(tmp);
-                dev->pci_dev[i].driverlink = strdup(linkbuf);
-                debug("driver:%s\n", linkbuf);
                 dev->n_pci_devs += 1;
         }