From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 015732C6A for ; Tue, 27 Jun 2017 15:49:18 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2017 06:49:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,399,1493708400"; d="scan'208";a="119334552" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.28]) by fmsmga005.fm.intel.com with SMTP; 27 Jun 2017 06:49:16 -0700 Received: by (sSMTP sendmail emulation); Tue, 27 Jun 2017 14:49:15 +0100 Date: Tue, 27 Jun 2017 14:49:15 +0100 From: Bruce Richardson To: Gaetan Rivet Cc: dev@dpdk.org Message-ID: <20170627134915.GG104744@bricha3-MOBL3.ger.corp.intel.com> References: <98e3e67ce4b581325398aa6167e4a9a3ab20a6e8.1498436062.git.gaetan.rivet@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98e3e67ce4b581325398aa6167e4a9a3ab20a6e8.1498436062.git.gaetan.rivet@6wind.com> Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.8.1 (2017-04-11) Subject: Re: [dpdk-dev] [PATCH v5 11/12] pci: implement hotplug bus operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jun 2017 13:49:19 -0000 On Mon, Jun 26, 2017 at 02:22:09AM +0200, Gaetan Rivet wrote: > Signed-off-by: Gaetan Rivet > --- > lib/librte_eal/common/eal_common_pci.c | 44 ++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c > index 00d48d9..286357d 100644 > --- a/lib/librte_eal/common/eal_common_pci.c > +++ b/lib/librte_eal/common/eal_common_pci.c > @@ -47,6 +47,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -500,11 +501,54 @@ pci_find_device(rte_dev_cmp_t cmp, const void *data) > return NULL; > } > > +static struct rte_device * > +pci_plug(struct rte_devargs *da) > +{ > + struct rte_pci_device *pdev; > + struct rte_pci_addr *addr; > + > + addr = &da->pci.addr; > + /* > + * Update eventual pci device in global list. > + * Insert it if none was found. > + */ > + if (pci_update_device(addr) < 0) { > + rte_errno = EIO; > + return NULL; > + } > + /* Find the current device holding this address in the bus. */ > + FOREACH_DEVICE_ON_PCIBUS(pdev) { > + if (rte_eal_compare_pci_addr(&pdev->addr, addr) == 0) { > + if (rte_pci_probe_one(addr)) { Please put the != 0, or == -1 in the condition, to make it clear it's an error leg. > + rte_errno = ENODEV; > + return NULL; > + } > + break; > + } > + } > + return pdev ? &pdev->device : NULL; > +} Please put in explicit != NULL, as per coding standards here. > + > +static int > +pci_unplug(struct rte_device *dev) > +{ > + struct rte_pci_device *pdev; > + > + pdev = RTE_DEV_TO_PCI(dev); > + if (rte_pci_detach(&pdev->addr)) { As above, please check for == or != some value. > + rte_errno = ENODEV; > + return -1; > + } > + return 0; > +} > + > struct rte_pci_bus rte_pci_bus = { > .bus = { > .scan = rte_pci_scan, > .probe = rte_pci_probe, > .find_device = pci_find_device, > + .plug = pci_plug, > + .unplug = pci_unplug, > }, > .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), > .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), > -- > 2.1.4 > With above fixes, Acked-by: Bruce Richardson