From 4134538ae5df2adfa9a9befd49d1de4418b04780 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 10 Nov 2013 12:39:19 +0100 Subject: [PATCH] sysfs: Do not warn on incomplete slot addresses Based on a patch by Zheng Huai Cheng . --- lib/sysfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/sysfs.c b/lib/sysfs.c index fb1b521..5a48c0d 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -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) -- 2.39.2