[dpdk-dev,RFC,v2,18/28] eal/pci: Prevent double registrations for pci_device_list
Commit Message
The patch fixes pci_scan_one() not to register same pci devices twice.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_eal/linuxapp/eal/eal_pci.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
@@ -292,14 +292,17 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
}
else {
struct rte_pci_device *dev2 = NULL;
+ int ret;
TAILQ_FOREACH(dev2, &pci_device_list, next) {
- if (eal_compare_pci_addr(&dev->addr, &dev2->addr) != 0)
+ ret = eal_compare_pci_addr(&dev->addr, &dev2->addr);
+ if (ret > 0)
continue;
- else {
+ else if (ret < 0) {
TAILQ_INSERT_BEFORE(dev2, dev, next);
return 0;
- }
+ } else /* already registered */
+ return 0;
}
TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
}