drivers/net: use higher level of probing helper for PCI
authorThomas Monjalon <thomas@monjalon.net>
Thu, 10 May 2018 23:58:29 +0000 (01:58 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 May 2018 21:31:53 +0000 (22:31 +0100)
The drivers avp, bnx2x and liquidio were using the helper function
rte_eth_dev_pci_allocate() and can be replaced by
rte_eth_dev_pci_generic_probe() which calls the former.

Fixes: dcd5c8112bc3 ("ethdev: add PCI driver helpers")
Cc: stable@dpdk.org
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
drivers/net/avp/avp_ethdev.c
drivers/net/bnx2x/bnx2x_ethdev.c
drivers/net/liquidio/lio_ethdev.c

index 5b3c4ce..dc97e60 100644 (file)
@@ -1048,19 +1048,8 @@ static int
 eth_avp_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
                  struct rte_pci_device *pci_dev)
 {
-       struct rte_eth_dev *eth_dev;
-       int ret;
-
-       eth_dev = rte_eth_dev_pci_allocate(pci_dev,
-                                          sizeof(struct avp_adapter));
-       if (eth_dev == NULL)
-               return -ENOMEM;
-
-       ret = eth_avp_dev_init(eth_dev);
-       if (ret)
-               rte_eth_dev_pci_release(eth_dev);
-
-       return ret;
+       return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct avp_adapter),
+                       eth_avp_dev_init);
 }
 
 static int
index 6ccbb99..7a1e9f5 100644 (file)
@@ -644,24 +644,14 @@ static struct rte_pci_driver rte_bnx2xvf_pmd;
 static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv,
        struct rte_pci_device *pci_dev)
 {
-       struct rte_eth_dev *eth_dev;
-       int ret;
-
-       eth_dev = rte_eth_dev_pci_allocate(pci_dev, sizeof(struct bnx2x_softc));
-       if (!eth_dev)
-               return -ENOMEM;
-
        if (pci_drv == &rte_bnx2x_pmd)
-               ret = eth_bnx2x_dev_init(eth_dev);
+               return rte_eth_dev_pci_generic_probe(pci_dev,
+                               sizeof(struct bnx2x_softc), eth_bnx2x_dev_init);
        else if (pci_drv == &rte_bnx2xvf_pmd)
-               ret = eth_bnx2xvf_dev_init(eth_dev);
+               return rte_eth_dev_pci_generic_probe(pci_dev,
+                               sizeof(struct bnx2x_softc), eth_bnx2xvf_dev_init);
        else
-               ret = -EINVAL;
-
-       if (ret)
-               rte_eth_dev_pci_release(eth_dev);
-
-       return ret;
+               return -EINVAL;
 }
 
 static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev)
index a13a566..0e0b5d8 100644 (file)
@@ -2110,19 +2110,8 @@ static int
 lio_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
                      struct rte_pci_device *pci_dev)
 {
-       struct rte_eth_dev *eth_dev;
-       int ret;
-
-       eth_dev = rte_eth_dev_pci_allocate(pci_dev,
-                                          sizeof(struct lio_device));
-       if (eth_dev == NULL)
-               return -ENOMEM;
-
-       ret = lio_eth_dev_init(eth_dev);
-       if (ret)
-               rte_eth_dev_pci_release(eth_dev);
-
-       return ret;
+       return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct lio_device),
+                       lio_eth_dev_init);
 }
 
 static int