bus/pci: reference driver structure before mapping
authorRafal Kozik <rk@semihalf.com>
Fri, 29 Jun 2018 13:54:06 +0000 (15:54 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 29 Jun 2018 22:12:58 +0000 (00:12 +0200)
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 <rk@semihalf.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/bus/pci/pci_common.c

index d8151b0..94b0f41 100644 (file)
@@ -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 needs to be before rte_pci_map_device(), as it enables 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) {