Skip to content

Commit

Permalink
stmmac: change the stmmac_dvr_probe return type to int
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joachim Eastwood authored and David S. Miller committed May 21, 2015
1 parent e56788c commit 15ffac7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 31 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/stmicro/stmmac/stmmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
15 changes: 7 additions & 8 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2801,20 +2801,19 @@ 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;
struct stmmac_priv *priv;

ndev = alloc_etherdev(sizeof(struct stmmac_priv));
if (!ndev)
return ERR_PTR(-ENOMEM);
return -ENOMEM;

SET_NETDEV_DEV(ndev, device);

Expand Down Expand Up @@ -2950,7 +2949,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
}
}

return priv;
return 0;

error_mdio_register:
unregister_netdev(ndev);
Expand All @@ -2963,7 +2962,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
error_clk_get:
free_netdev(ndev);

return ERR_PTR(ret);
return ret;
}
EXPORT_SYMBOL_GPL(stmmac_dvr_probe);

Expand Down
11 changes: 1 addition & 10 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

/**
Expand Down
11 changes: 1 addition & 10 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 15ffac7

Please sign in to comment.