Commit e87fb82d authored by Kunihiko Hayashi's avatar Kunihiko Hayashi Committed by David S. Miller

net: ethernet: ave: Replace alloc_etherdev() with devm_alloc_etherdev()

Use devm_alloc_etherdev() to simplify the code instead of alloc_etherdev().
Signed-off-by: default avatarKunihiko Hayashi <hayashi.kunihiko@socionext.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0675c285
...@@ -1585,7 +1585,7 @@ static int ave_probe(struct platform_device *pdev) ...@@ -1585,7 +1585,7 @@ static int ave_probe(struct platform_device *pdev)
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
ndev = alloc_etherdev(sizeof(struct ave_private)); ndev = devm_alloc_etherdev(dev, sizeof(struct ave_private));
if (!ndev) { if (!ndev) {
dev_err(dev, "can't allocate ethernet device\n"); dev_err(dev, "can't allocate ethernet device\n");
return -ENOMEM; return -ENOMEM;
...@@ -1632,7 +1632,7 @@ static int ave_probe(struct platform_device *pdev) ...@@ -1632,7 +1632,7 @@ static int ave_probe(struct platform_device *pdev)
} }
ret = dma_set_mask(dev, dma_mask); ret = dma_set_mask(dev, dma_mask);
if (ret) if (ret)
goto out_free_netdev; return ret;
priv->tx.ndesc = AVE_NR_TXDESC; priv->tx.ndesc = AVE_NR_TXDESC;
priv->rx.ndesc = AVE_NR_RXDESC; priv->rx.ndesc = AVE_NR_RXDESC;
...@@ -1645,10 +1645,8 @@ static int ave_probe(struct platform_device *pdev) ...@@ -1645,10 +1645,8 @@ static int ave_probe(struct platform_device *pdev)
if (!name) if (!name)
break; break;
priv->clk[i] = devm_clk_get(dev, name); priv->clk[i] = devm_clk_get(dev, name);
if (IS_ERR(priv->clk[i])) { if (IS_ERR(priv->clk[i]))
ret = PTR_ERR(priv->clk[i]); return PTR_ERR(priv->clk[i]);
goto out_free_netdev;
}
priv->nclks++; priv->nclks++;
} }
...@@ -1657,10 +1655,8 @@ static int ave_probe(struct platform_device *pdev) ...@@ -1657,10 +1655,8 @@ static int ave_probe(struct platform_device *pdev)
if (!name) if (!name)
break; break;
priv->rst[i] = devm_reset_control_get_shared(dev, name); priv->rst[i] = devm_reset_control_get_shared(dev, name);
if (IS_ERR(priv->rst[i])) { if (IS_ERR(priv->rst[i]))
ret = PTR_ERR(priv->rst[i]); return PTR_ERR(priv->rst[i]);
goto out_free_netdev;
}
priv->nrsts++; priv->nrsts++;
} }
...@@ -1669,26 +1665,23 @@ static int ave_probe(struct platform_device *pdev) ...@@ -1669,26 +1665,23 @@ static int ave_probe(struct platform_device *pdev)
1, 0, &args); 1, 0, &args);
if (ret) { if (ret) {
dev_err(dev, "can't get syscon-phy-mode property\n"); dev_err(dev, "can't get syscon-phy-mode property\n");
goto out_free_netdev; return ret;
} }
priv->regmap = syscon_node_to_regmap(args.np); priv->regmap = syscon_node_to_regmap(args.np);
of_node_put(args.np); of_node_put(args.np);
if (IS_ERR(priv->regmap)) { if (IS_ERR(priv->regmap)) {
dev_err(dev, "can't map syscon-phy-mode\n"); dev_err(dev, "can't map syscon-phy-mode\n");
ret = PTR_ERR(priv->regmap); return PTR_ERR(priv->regmap);
goto out_free_netdev;
} }
ret = priv->data->get_pinmode(priv, phy_mode, args.args[0]); ret = priv->data->get_pinmode(priv, phy_mode, args.args[0]);
if (ret) { if (ret) {
dev_err(dev, "invalid phy-mode setting\n"); dev_err(dev, "invalid phy-mode setting\n");
goto out_free_netdev; return ret;
} }
priv->mdio = devm_mdiobus_alloc(dev); priv->mdio = devm_mdiobus_alloc(dev);
if (!priv->mdio) { if (!priv->mdio)
ret = -ENOMEM; return -ENOMEM;
goto out_free_netdev;
}
priv->mdio->priv = ndev; priv->mdio->priv = ndev;
priv->mdio->parent = dev; priv->mdio->parent = dev;
priv->mdio->read = ave_mdiobus_read; priv->mdio->read = ave_mdiobus_read;
...@@ -1725,8 +1718,6 @@ static int ave_probe(struct platform_device *pdev) ...@@ -1725,8 +1718,6 @@ static int ave_probe(struct platform_device *pdev)
out_del_napi: out_del_napi:
netif_napi_del(&priv->napi_rx); netif_napi_del(&priv->napi_rx);
netif_napi_del(&priv->napi_tx); netif_napi_del(&priv->napi_tx);
out_free_netdev:
free_netdev(ndev);
return ret; return ret;
} }
...@@ -1739,7 +1730,6 @@ static int ave_remove(struct platform_device *pdev) ...@@ -1739,7 +1730,6 @@ static int ave_remove(struct platform_device *pdev)
unregister_netdev(ndev); unregister_netdev(ndev);
netif_napi_del(&priv->napi_rx); netif_napi_del(&priv->napi_rx);
netif_napi_del(&priv->napi_tx); netif_napi_del(&priv->napi_tx);
free_netdev(ndev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment