From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rafal Kozik Subject: [PATCH v3 2/4] bus/pci: reference driver structure Date: Fri, 29 Jun 2018 12:24:31 +0200 Message-ID: <1530267873-7236-3-git-send-email-rk@semihalf.com> References: <1530191753-18689-2-git-send-email-rk@semihalf.com> <1530267873-7236-1-git-send-email-rk@semihalf.com> Cc: mw@semihalf.com, mk@semihalf.com, gtzalik@amazon.com, evgenys@amazon.com, matua@amazon.com, igorch@amazon.com, thomas@monjalon.net, ferruh.yigit@intel.com, Rafal Kozik To: dev@dpdk.org Return-path: Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by dpdk.org (Postfix) with ESMTP id B14D11B4D1 for ; Fri, 29 Jun 2018 12:24:41 +0200 (CEST) Received: by mail-lj1-f195.google.com with SMTP id v15-v6so6909139ljk.5 for ; Fri, 29 Jun 2018 03:24:41 -0700 (PDT) In-Reply-To: <1530267873-7236-1-git-send-email-rk@semihalf.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add pointer to driver structure before calling rte_pci_map_device. It allows to use driver flags for adjusting configuration. Signed-off-by: Rafal Kozik Acked-by: Bruce Richardson --- drivers/bus/pci/pci_common.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index d8151b0..8f5d77f 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -158,17 +158,24 @@ 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 + * This need to be before rte_pci_map_device(), as it enable to use + * driver flags for adjusting configuration. + */ + dev->driver = dr; + dev->device.driver = &dr->driver; + 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) { -- 2.7.4