Thread (26 messages) flat view 26 messages, 3 authors, 2016-03-22
STALE3787d

Revision v1 of 2 in this series.

Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 8/9] pci: remove driver lookup from detach

From: David Marchand <hidden>
Date: 2016-01-22 15:28:00
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

A device is linked to a driver at probe time.
When detaching, we should call this same driver detach() function and no
need for a driver lookup.

Signed-off-by: David Marchand <redacted>
---
 lib/librte_eal/common/eal_common_pci.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index a1efd57..71222a5 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -256,16 +256,9 @@ pci_probe_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
  * driver.
  */
 static int
-pci_detach_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
+pci_detach_device(struct rte_pci_device *dev)
 {
-	struct rte_pci_addr *loc = &dev->addr;
-
-	RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
-		loc->domain, loc->bus, loc->devid,
-		loc->function, dev->numa_node);
-
-	RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
-		dev->id.device_id, dr->name);
+	struct rte_pci_driver *dr = dev->driver;
 
 	if (dr->devuninit && (dr->devuninit(dev) < 0))
 		return -1;	/* negative value is an error */
@@ -332,20 +325,22 @@ int
 rte_eal_pci_detach(const struct rte_pci_addr *addr)
 {
 	struct rte_pci_device *dev;
-	struct rte_pci_driver *dr;
 
 	if (addr == NULL)
 		return -1;
 
 	dev = pci_find_device(addr);
-	if (!dev)
+	if (!dev || !dev->driver)
 		goto err_return;
 
-	dr = pci_find_driver(dev);
-	if (!dr)
-		goto err_return;
+	RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+		dev->addr.domain, dev->addr.bus, dev->addr.devid,
+		dev->addr.function, dev->numa_node);
+
+	RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
+		dev->id.device_id, dev->driver->name);
 
-	if (pci_detach_device(dr, dev) < 0)
+	if (pci_detach_device(dev) < 0)
 		goto err_return;
 
 	TAILQ_REMOVE(&pci_device_list, dev, next);
-- 
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help