if (!np)
return -ENODEV;
- dev = alloc_etherdev(sizeof(*ag));
+ dev = devm_alloc_etherdev(&pdev->dev, sizeof(*ag));
if (!dev)
return -ENOMEM;
ag->mac_reset = devm_reset_control_get(&pdev->dev, "mac");
if (IS_ERR(ag->mac_reset)) {
dev_err(&pdev->dev, "missing mac reset\n");
- err = PTR_ERR(ag->mac_reset);
- goto err_free;
+ return PTR_ERR(ag->mac_reset);
}
if (of_property_read_u32_array(np, "fifo-data", ag->fifodata, 3)) {
ag->mac_base = devm_ioremap_nocache(&pdev->dev, res->start,
res->end - res->start + 1);
- if (!ag->mac_base) {
- err = -ENOMEM;
- goto err_free;
- }
+ if (!ag->mac_base)
+ return -ENOMEM;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res) {
ag->mii_base = devm_ioremap_nocache(&pdev->dev, res->start,
res->end - res->start + 1);
- if (!ag->mii_base) {
- err = -ENOMEM;
- goto err_free;
- }
+ if (!ag->mii_base)
+ return -ENOMEM;
}
dev->irq = platform_get_irq(pdev, 0);
0x0, dev_name(&pdev->dev), dev);
if (err) {
dev_err(&pdev->dev, "unable to request IRQ %d\n", dev->irq);
- goto err_free;
+ return err;
}
dev->netdev_ops = &ag71xx_netdev_ops;
sizeof(struct ag71xx_desc),
&ag->stop_desc_dma, GFP_KERNEL);
if (!ag->stop_desc)
- goto err_free;
+ return -ENOMEM;
ag->stop_desc->data = 0;
ag->stop_desc->ctrl = 0;
ag->phy_if_mode = of_get_phy_mode(np);
if (ag->phy_if_mode < 0) {
dev_err(&pdev->dev, "missing phy-mode property in DT\n");
- err = ag->phy_if_mode;
- goto err_free;
+ return ag->phy_if_mode;
}
if (of_property_read_u32(np, "qca,mac-idx", &ag->mac_idx))
err = ag71xx_phy_connect(ag);
if (err)
- goto err_free;
+ return err;
err = ag71xx_debugfs_init(ag);
if (err)
err_phy_disconnect:
ag71xx_phy_disconnect(ag);
-err_free:
- free_netdev(dev);
return err;
}
ag71xx_debugfs_exit(ag);
ag71xx_phy_disconnect(ag);
unregister_netdev(dev);
- free_irq(dev->irq, dev);
- iounmap(ag->mac_base);
- kfree(dev);
platform_set_drvdata(pdev, NULL);
-
return 0;
}