From 04d969ce4d548d3ae4fb2dbce68caa3923153bf8 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Thu, 12 Feb 2009 21:04:18 +0100 Subject: [PATCH] hdt: Improving detection speed by skipping uncessary lines --- com32/lib/pci/scan.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c index 7d11399..0630285 100644 --- a/com32/lib/pci/scan.c +++ b/com32/lib/pci/scan.c @@ -256,6 +256,7 @@ int get_name_from_pci_ids(struct pci_domain *domain) char sub_vendor_id[5]; FILE *f; struct pci_device *dev; + bool skip_to_next_vendor=false; /* Intializing the vendor/product name for each pci device to "unknown" */ /* adding a dev_info member if needed */ @@ -306,9 +307,19 @@ int get_name_from_pci_ids(struct pci_domain *domain) /* ffff is an invalid vendor id */ if (strstr(vendor_id,"ffff")) break; + skip_to_next_vendor=true; + int int_vendor_id=hex_to_int(vendor_id); + for_each_pci_func(dev, domain) { + if (int_vendor_id == dev->vendor) { + skip_to_next_vendor=false; + continue; + } + } /* if we have a tab + a char, it means this is a product id */ } else if ((line[0] == '\t') && (line[1] != '\t')) { + if (skip_to_next_vendor == true) continue; + /* the product name the second field */ strlcpy(product,skipspace(strstr(line," ")),255); remove_eol(product); @@ -335,6 +346,8 @@ int get_name_from_pci_ids(struct pci_domain *domain) /* if we have two tabs, it means this is a sub product */ } else if ((line[0] == '\t') && (line[1] == '\t')) { + if (skip_to_next_vendor == true) continue; + /* the product name is last field */ strlcpy(product,skipspace(strstr(line," ")),255); strlcpy(product,skipspace(strstr(product," ")),255); -- 2.7.4