stmmac: change the stmmac_dvr_probe return type to int
authorJoachim Eastwood <manabian@gmail.com>
Wed, 20 May 2015 18:03:08 +0000 (20:03 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 May 2015 22:57:26 +0000 (18:57 -0400)
Since stmmac_dvr_probe takes care of setting driver data and
assign resources to the priv structure there is no need to
access the priv structure from the other probe functions.
This mean that this function can be changed into just return
an int and thus simplifying the callers.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

index b1687ad..9cbcae2 100644 (file)
@@ -137,9 +137,9 @@ void stmmac_ptp_unregister(struct stmmac_priv *priv);
 int stmmac_resume(struct net_device *ndev);
 int stmmac_suspend(struct net_device *ndev);
 int stmmac_dvr_remove(struct net_device *ndev);
-struct stmmac_priv *stmmac_dvr_probe(struct device *device,
-                                    struct plat_stmmacenet_data *plat_dat,
-                                    struct stmmac_resources *res);
+int stmmac_dvr_probe(struct device *device,
+                    struct plat_stmmacenet_data *plat_dat,
+                    struct stmmac_resources *res);
 void stmmac_disable_eee_mode(struct stmmac_priv *priv);
 bool stmmac_eee_init(struct stmmac_priv *priv);
 
index c73570f..e4f2739 100644 (file)
@@ -2801,12 +2801,11 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
  * Description: this is the main probe function used to
  * call the alloc_etherdev, allocate the priv structure.
  * Return:
- * on success the new private structure is returned, otherwise the error
- * pointer.
+ * returns 0 on success, otherwise errno.
  */
-struct stmmac_priv *stmmac_dvr_probe(struct device *device,
-                                    struct plat_stmmacenet_data *plat_dat,
-                                    struct stmmac_resources *res)
+int stmmac_dvr_probe(struct device *device,
+                    struct plat_stmmacenet_data *plat_dat,
+                    struct stmmac_resources *res)
 {
        int ret = 0;
        struct net_device *ndev = NULL;
@@ -2814,7 +2813,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
 
        ndev = alloc_etherdev(sizeof(struct stmmac_priv));
        if (!ndev)
-               return ERR_PTR(-ENOMEM);
+               return -ENOMEM;
 
        SET_NETDEV_DEV(ndev, device);
 
@@ -2950,7 +2949,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
                }
        }
 
-       return priv;
+       return 0;
 
 error_mdio_register:
        unregister_netdev(ndev);
@@ -2963,7 +2962,7 @@ error_pclk_get:
 error_clk_get:
        free_netdev(ndev);
 
-       return ERR_PTR(ret);
+       return ret;
 }
 EXPORT_SYMBOL_GPL(stmmac_dvr_probe);
 
index 2c663ec..d71a721 100644 (file)
@@ -164,7 +164,6 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
        struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;
        struct plat_stmmacenet_data *plat;
        struct stmmac_resources res;
-       struct stmmac_priv *priv;
        int i;
        int ret;
 
@@ -220,15 +219,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
        res.wol_irq = pdev->irq;
        res.irq = pdev->irq;
 
-       priv = stmmac_dvr_probe(&pdev->dev, plat, &res);
-       if (IS_ERR(priv)) {
-               dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__);
-               return PTR_ERR(priv);
-       }
-
-       dev_dbg(&pdev->dev, "STMMAC PCI driver registration completed\n");
-
-       return 0;
+       return stmmac_dvr_probe(&pdev->dev, plat, &res);
 }
 
 /**
index af4f035..e8d4c96 100644 (file)
@@ -256,7 +256,6 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
        int ret = 0;
        struct resource *res;
        struct device *dev = &pdev->dev;
-       struct stmmac_priv *priv = NULL;
        struct plat_stmmacenet_data *plat_dat = NULL;
 
        memset(&stmmac_res, 0, sizeof(stmmac_res));
@@ -335,15 +334,7 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
                        return ret;
        }
 
-       priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, &stmmac_res);
-       if (IS_ERR(priv)) {
-               pr_err("%s: main driver probe failed", __func__);
-               return PTR_ERR(priv);
-       }
-
-       pr_debug("STMMAC platform driver registration completed");
-
-       return 0;
+       return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
 }
 EXPORT_SYMBOL_GPL(stmmac_pltfr_probe);