]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
sysfs: Do not warn on incomplete slot addresses
authorMartin Mares <mj@ucw.cz>
Sun, 10 Nov 2013 11:39:19 +0000 (12:39 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 10 Nov 2013 11:39:19 +0000 (12:39 +0100)
Based on a patch by Zheng Huai Cheng <zhenghch@linux.vnet.ibm.com>.

lib/sysfs.c

index fb1b5214332861d078a1d10e69fa1ece761e38f6..5a48c0db86285ea226a836a6fd185514c227d77d 100644 (file)
@@ -226,6 +226,7 @@ sysfs_fill_slots(struct pci_access *a)
       char namebuf[OBJNAMELEN], buf[16];
       FILE *file;
       unsigned int dom, bus, dev;
+      int res = 0;
       struct pci_dev *d;
 
       /* ".", ".." or a special non-device perhaps */
@@ -244,8 +245,16 @@ sysfs_fill_slots(struct pci_access *a)
       if (!file)
        continue;
 
-      if (!fgets(buf, sizeof(buf), file) || sscanf(buf, "%x:%x:%x", &dom, &bus, &dev) < 3)
-       a->warning("sysfs_fill_slots: Couldn't parse entry address %s", buf);
+      if (!fgets(buf, sizeof(buf), file) || (res = sscanf(buf, "%x:%x:%x", &dom, &bus, &dev)) < 3)
+       {
+         /*
+          * In some cases, the slot is not tied to a specific device before
+          * a card gets inserted. This happens for example on IBM pSeries
+          * and we need not warn about it.
+          */
+         if (res != 2)
+           a->warning("sysfs_fill_slots: Couldn't parse entry address %s", buf);
+       }
       else
        {
          for (d = a->devices; d; d = d->next)