From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id 31ABD8EA0 for ; Fri, 22 Jan 2016 16:28:00 +0100 (CET) Received: by mail-wm0-f52.google.com with SMTP id b14so137762500wmb.1 for ; Fri, 22 Jan 2016 07:28:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I/eY/Sq0U9uteqQ2BUwA6WGAplsPimU60HzC5V3vZlY=; b=jIZQfm2aqcysMDi6BSkfIt0wenx5bItehnaZLxJrqV//0BIIollvzznbZlBXJioDV1 gqv10v/RoJ4nBI6jlHb4DjMPOqFyyUVA9UYzY6g+1XXUlu5Lrlpglp23sIXKryN4Pgby esY88CZQ3yS4ShA5dOBHC0VvjwLV3iX3RmMvMd8ZxAfnh6eGKwCFDZWd37OJS/Wo7XYx GKN5/nBfr3E/1NKg5TWb8XtlWAwYQxanLTxYcz0C+z5gGjDCSFyxJpBqPt7lsOiODvh+ cABNhV/JqqwwysTrjOcHmU7bDArUD95wQ/P/m2nAKUQQLBni/IGHUFiJ6dmolU6PeZqf rltw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I/eY/Sq0U9uteqQ2BUwA6WGAplsPimU60HzC5V3vZlY=; b=U3x04OIHN1NQ1t7AEtLVVx2kPfTmwCJV4kFdeJajxHm8SnF8iruKxB3JDdCC86/Tyo 6/EMWA+SIq7HD6xXXWER0b7nu5Fh/G3x7YSboCl60Xots3BpQP8ePbEhCQyKQIqJTPfN dNQ/4xOubA40oL/BVWtkZTc7zAiDugY1KSiJsG+/6rXA8CyOtl2TjS+53kl7hycN6yLi t/5KiHWwS2oh6fEEWNJS7Y84pDlEVVOsotRQw96xcM9ORTZn1NSFwjAmH1EnM284TSkc WlPTQfWz+VbfPoj3vZDLW2KTGHx/8xqCi3VMmhAn6BV1/c3I55MoRSvWPkj7qhZZYvAB sUuw== X-Gm-Message-State: AG10YOSFfd6a7J8Mu50kO8QOwt3AkDtiie4WszNnPAmnrAxjlM3s0Q5/wUMCIwa87x3EQX31 X-Received: by 10.194.209.129 with SMTP id mm1mr4155488wjc.47.1453476480086; Fri, 22 Jan 2016 07:28:00 -0800 (PST) Received: from gloops.dev.6wind.com (144.77.126.78.rev.sfr.net. [78.126.77.144]) by smtp.gmail.com with ESMTPSA id w73sm3359464wmw.21.2016.01.22.07.27.59 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jan 2016 07:27:59 -0800 (PST) From: David Marchand To: dev@dpdk.org Date: Fri, 22 Jan 2016 16:27:43 +0100 Message-Id: <1453476464-31767-9-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453476464-31767-1-git-send-email-david.marchand@6wind.com> References: <1453476464-31767-1-git-send-email-david.marchand@6wind.com> Cc: viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH 8/9] pci: remove driver lookup from detach X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jan 2016 15:28:00 -0000 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 --- 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