diff mbox series

[3/8] net: ehernet: ixp4xx: Use devm_alloc_etherdev()

Message ID 20190524162023.9115-4-linus.walleij@linaro.org
State Superseded
Headers show
Series Xscale IXP4xx ethernet refurbishing | expand

Commit Message

Linus Walleij May 24, 2019, 4:20 p.m. UTC
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

Comments

Andrew Lunn May 24, 2019, 7:52 p.m. UTC | #1
> @@ -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));


Hi Linus

If you get here, the interface has been registered. So you could use
netdev_info(ndev, ...). You can also call it before register_netdev,
but since the name as not yet been determined, it is not so
informative as dev_err() which will give you the bus address or
something.

	Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index a0c02458f456..064ff0886cc3 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -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;
 }