@@ -1380,7 +1380,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
plat = dev_get_platdata(dev);
- if (!(ndev = alloc_etherdev(sizeof(struct port))))
+ if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port))))
return -ENOMEM;
SET_NETDEV_DEV(ndev, dev);
@@ -1434,8 +1434,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
regs_phys = IXP4XX_EthC_BASE_PHYS;
break;
default:
- err = -ENODEV;
- goto err_free;
+ return -ENODEV;
}
ndev->netdev_ops = &ixp4xx_netdev_ops;
@@ -1444,10 +1443,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT);
- if (!(port->npe = npe_request(NPE_ID(port->id)))) {
- err = -EIO;
- goto err_free;
- }
+ if (!(port->npe = npe_request(NPE_ID(port->id))))
+ return -EIO;
port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name);
if (!port->mem_res) {
@@ -1481,8 +1478,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
if ((err = register_netdev(ndev)))
goto err_phy_dis;
- printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
- npe_name(port->npe));
+ dev_info(dev, "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
+ npe_name(port->npe));
return 0;
@@ -1493,8 +1490,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
release_resource(port->mem_res);
err_npe_rel:
npe_release(port->npe);
-err_free:
- free_netdev(ndev);
return err;
}
@@ -1510,7 +1505,6 @@ static int ixp4xx_eth_remove(struct platform_device *pdev)
npe_port_tab[NPE_ID(port->id)] = NULL;
npe_release(port->npe);
release_resource(port->mem_res);
- free_netdev(ndev);
return 0;
}
Using the devm_alloc_etherdev() function simplifies the error path. I also patch the message to use dev_info(). Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) -- 2.20.1