]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/proc.c
Corrected masking of hdr_type
[pciutils.git] / lib / proc.c
index d18a0dbf655319311e856e0d46bb7cfb37e0e42e..d46e5cba4aba1e4dd0bd3c43c85b3b29a3a86862 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     The PCI Library -- Configuration Access via /proc/bus/pci
  *
- *     Copyright (c) 1997--1999 Martin Mares <mj@ucw.cz>
+ *     Copyright (c) 1997--2003 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -128,12 +128,8 @@ proc_scan(struct pci_access *a)
       struct pci_dev *d = pci_alloc_dev(a);
       unsigned int dfn, vend, cnt, known;
 
-      cnt = sscanf(buf,
-#ifdef HAVE_LONG_ADDRESS
-            "%x %x %x %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx %llx",
-#else
-            "%x %x %x %lx %lx %lx %lx %lx %lx %lx %lx %lx %lx %lx %lx %lx %lx",
-#endif
+#define F " " PCIADDR_T_FMT
+      cnt = sscanf(buf, "%x %x %x" F F F F F F F F F F F F F F,
             &dfn,
             &vend,
             &d->irq,
@@ -151,6 +147,7 @@ proc_scan(struct pci_access *a)
             &d->size[4],
             &d->size[5],
             &d->rom_size);
+#undef F
       if (cnt != 9 && cnt != 10 && cnt != 17)
        a->error("proc: parse error (read only %d items)", cnt);
       d->bus = dfn >> 8U;
@@ -158,7 +155,7 @@ proc_scan(struct pci_access *a)
       d->func = PCI_FUNC(dfn & 0xff);
       d->vendor_id = vend >> 16U;
       d->device_id = vend & 0xffff;
-      d->hdrtype = pci_read_byte(d, PCI_HEADER_TYPE);
+      d->hdrtype = pci_read_byte(d, PCI_HEADER_TYPE) & 0x7f;
       known = PCI_FILL_IDENT;
       if (!a->buscentric)
        {