From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Viktorin Subject: Re: [dpdk-dev, 2/2] ethdev: move code to common place in hotplug Date: Thu, 21 Jan 2016 16:38:36 +0100 Message-ID: <20160121163836.0bcd405e@pcviktorin.fit.vutbr.cz> References: <1453377431-25850-3-git-send-email-david.marchand@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: David Marchand Return-path: Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id 113615A62 for ; Thu, 21 Jan 2016 16:36:38 +0100 (CET) In-Reply-To: <1453377431-25850-3-git-send-email-david.marchand@6wind.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 21 Jan 2016 12:57:11 +0100 David Marchand wrote: > Move these error logs and checks on detach capabilities in a common place. > > Signed-off-by: David Marchand > > --- > lib/librte_ether/rte_ethdev.c | 69 +++++++++++++++++++++++++------------------ > 1 file changed, 40 insertions(+), 29 deletions(-) > > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c > index 951fb1c..9083783 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -514,7 +514,6 @@ rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id) > > return 0; > [snip] > > @@ -612,14 +599,25 @@ int > rte_eth_dev_attach(const char *devargs, uint8_t *port_id) > { > struct rte_pci_addr addr; > + int ret = -1; > > if ((devargs == NULL) || (port_id == NULL)) > - return -EINVAL; > + goto err; This change modifies the return value from -EINVAL to -1. I don't know whether is this an issue but it looks suspicious. > > - if (eal_parse_pci_DomBDF(devargs, &addr) == 0) > - return rte_eth_dev_attach_pdev(&addr, port_id); > - else > - return rte_eth_dev_attach_vdev(devargs, port_id); > + if (eal_parse_pci_DomBDF(devargs, &addr) == 0) { > + ret = rte_eth_dev_attach_pdev(&addr, port_id); > + if (ret < 0) > + goto err; > + } else { > + ret = rte_eth_dev_attach_vdev(devargs, port_id); > + if (ret < 0) > + goto err; > + } > + > + return 0; > +err: > + RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n"); > + return ret; > } > > /* detach the device, then store the name of the device */ > @@ -627,26 +625,39 @@ int > rte_eth_dev_detach(uint8_t port_id, char *name) > { > struct rte_pci_addr addr; > - int ret; > + int ret = -1; > > if (name == NULL) > - return -EINVAL; > + goto err; Same here... > + > + /* check whether the driver supports detach feature, or not */ > + if (rte_eth_dev_is_detachable(port_id)) > + goto err; > > [snip] -- Jan Viktorin E-mail: Viktorin@RehiveTech.com System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic