X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fcaps.c;h=039c86f7e206a6bf5ec7a7bb0b85491a65eaacfa;hb=4c2b4b1bfa348ea22a22f4ca271bc13096ab3e78;hp=4267adbf0134ee512b82c988ad1bf64c65876257;hpb=d7d9e30534eb55145e7033018ee945b09de6928a;p=pciutils.git diff --git a/lib/caps.c b/lib/caps.c index 4267adb..039c86f 100644 --- a/lib/caps.c +++ b/lib/caps.c @@ -15,8 +15,12 @@ pci_add_cap(struct pci_dev *d, unsigned int addr, unsigned int id, unsigned int { struct pci_cap *cap = pci_malloc(d->access, sizeof(*cap)); - cap->next = d->first_cap; - d->first_cap = cap; + if (d->last_cap) + d->last_cap->next = cap; + else + d->first_cap = cap; + d->last_cap = cap; + cap->next = NULL; cap->addr = addr; cap->id = id; cap->type = type; @@ -76,17 +80,16 @@ pci_scan_ext_caps(struct pci_dev *d) while (where); } -unsigned int +void pci_scan_caps(struct pci_dev *d, unsigned int want_fields) { - if ((want_fields & PCI_FILL_EXT_CAPS) && !(d->known_fields & PCI_FILL_CAPS)) + if (want_fields & PCI_FILL_EXT_CAPS) want_fields |= PCI_FILL_CAPS; - if (want_fields & PCI_FILL_CAPS) + if (want_fill(d, want_fields, PCI_FILL_CAPS)) pci_scan_trad_caps(d); - if (want_fields & PCI_FILL_EXT_CAPS) + if (want_fill(d, want_fields, PCI_FILL_EXT_CAPS)) pci_scan_ext_caps(d); - return want_fields; } void @@ -113,8 +116,8 @@ pci_find_cap(struct pci_dev *d, unsigned int id, unsigned int type) * To select one capability if there are more than one with the same id, you * can provide a pointer to an unsigned int that contains the index which you * want as cap_number. If you don't care and are fine with the first one you - * can supply NULL. The cap_number will be replaced by the acutal number - * of capablities with that id. + * can supply NULL. The cap_number will be replaced by the actual number + * of capabilities with that id. */ struct pci_cap * pci_find_cap_nr(struct pci_dev *d, unsigned int id, unsigned int type, @@ -125,7 +128,7 @@ pci_find_cap_nr(struct pci_dev *d, unsigned int id, unsigned int type, unsigned int target = (cap_number ? *cap_number : 0); unsigned int index = 0; - pci_fill_info_v35(d, ((type == PCI_CAP_NORMAL) ? PCI_FILL_CAPS : PCI_FILL_EXT_CAPS)); + pci_fill_info_v38(d, ((type == PCI_CAP_NORMAL) ? PCI_FILL_CAPS : PCI_FILL_EXT_CAPS)); for (c=d->first_cap; c; c=c->next) { @@ -133,8 +136,8 @@ pci_find_cap_nr(struct pci_dev *d, unsigned int id, unsigned int type, { if (target == index) found = c; + index++; } - index++; } if (cap_number)