From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ferruh Yigit Subject: Re: [PATCH 2/4] bus/pci: reference driver structure Date: Wed, 27 Jun 2018 17:36:11 +0100 Message-ID: <3c81fa25-5508-5111-0c24-b022665b507a@intel.com> References: <1523455637-31719-1-git-send-email-rk@semihalf.com> <1523455637-31719-3-git-send-email-rk@semihalf.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: mw@semihalf.com, mk@semihalf.com, gtzalik@amazon.com, evgenys@amazon.com, matua@amazon.com, igorch@amazon.com To: Rafal Kozik , dev@dpdk.org Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 3208B1C2AC for ; Wed, 27 Jun 2018 18:36:15 +0200 (CEST) In-Reply-To: <1523455637-31719-3-git-send-email-rk@semihalf.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 4/11/2018 3:07 PM, Rafal Kozik wrote: > Reference driver structure before calling rte_pci_map_device. > It allow to use driver flags for adjusting configuration. > > Signed-off-by: Rafal Kozik > --- > drivers/bus/pci/pci_common.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c > index 2a00f36..15e9a47 100644 > --- a/drivers/bus/pci/pci_common.c > +++ b/drivers/bus/pci/pci_common.c > @@ -159,17 +159,20 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, > RTE_LOG(INFO, EAL, " probe driver: %x:%x %s\n", dev->id.vendor_id, > dev->id.device_id, dr->driver.name); > > + /* reference driver structure */ > + dev->driver = dr; > + dev->device.driver = &dr->driver; It can be good to comment that this needs to be before rte_pci_map_device() incase someone wants to refactor code later. > + > if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { > /* map resources for devices that use igb_uio */ > ret = rte_pci_map_device(dev); > - if (ret != 0) > + if (ret != 0) { > + dev->driver = NULL; > + dev->device.driver = NULL; > return ret; > + } > } > > - /* reference driver structure */ > - dev->driver = dr; > - dev->device.driver = &dr->driver; > - > /* call the driver probe() function */ > ret = dr->probe(dr, dev); > if (ret) { >