mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
net: ibm: emac: use devm for alloc_etherdev
Allows to simplify the code slightly. This is safe to do as free_netdev gets called last. Signed-off-by: Rosen Penev <rosenp@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/20240912024903.6201-2-rosenp@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
beb2baa9e5
commit
b9758c4342
@ -3053,7 +3053,7 @@ static int emac_probe(struct platform_device *ofdev)
|
|||||||
|
|
||||||
/* Allocate our net_device structure */
|
/* Allocate our net_device structure */
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
ndev = alloc_etherdev(sizeof(struct emac_instance));
|
ndev = devm_alloc_etherdev(&ofdev->dev, sizeof(struct emac_instance));
|
||||||
if (!ndev)
|
if (!ndev)
|
||||||
goto err_gone;
|
goto err_gone;
|
||||||
|
|
||||||
@ -3072,7 +3072,7 @@ static int emac_probe(struct platform_device *ofdev)
|
|||||||
/* Init various config data based on device-tree */
|
/* Init various config data based on device-tree */
|
||||||
err = emac_init_config(dev);
|
err = emac_init_config(dev);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_free;
|
goto err_gone;
|
||||||
|
|
||||||
/* Get interrupts. EMAC irq is mandatory, WOL irq is optional */
|
/* Get interrupts. EMAC irq is mandatory, WOL irq is optional */
|
||||||
dev->emac_irq = irq_of_parse_and_map(np, 0);
|
dev->emac_irq = irq_of_parse_and_map(np, 0);
|
||||||
@ -3080,7 +3080,7 @@ static int emac_probe(struct platform_device *ofdev)
|
|||||||
if (!dev->emac_irq) {
|
if (!dev->emac_irq) {
|
||||||
printk(KERN_ERR "%pOF: Can't map main interrupt\n", np);
|
printk(KERN_ERR "%pOF: Can't map main interrupt\n", np);
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
goto err_free;
|
goto err_gone;
|
||||||
}
|
}
|
||||||
ndev->irq = dev->emac_irq;
|
ndev->irq = dev->emac_irq;
|
||||||
|
|
||||||
@ -3239,8 +3239,6 @@ static int emac_probe(struct platform_device *ofdev)
|
|||||||
irq_dispose_mapping(dev->wol_irq);
|
irq_dispose_mapping(dev->wol_irq);
|
||||||
if (dev->emac_irq)
|
if (dev->emac_irq)
|
||||||
irq_dispose_mapping(dev->emac_irq);
|
irq_dispose_mapping(dev->emac_irq);
|
||||||
err_free:
|
|
||||||
free_netdev(ndev);
|
|
||||||
err_gone:
|
err_gone:
|
||||||
/* if we were on the bootlist, remove us as we won't show up and
|
/* if we were on the bootlist, remove us as we won't show up and
|
||||||
* wake up all waiters to notify them in case they were waiting
|
* wake up all waiters to notify them in case they were waiting
|
||||||
@ -3289,7 +3287,6 @@ static void emac_remove(struct platform_device *ofdev)
|
|||||||
if (dev->emac_irq)
|
if (dev->emac_irq)
|
||||||
irq_dispose_mapping(dev->emac_irq);
|
irq_dispose_mapping(dev->emac_irq);
|
||||||
|
|
||||||
free_netdev(dev->ndev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX Features in here should be replaced by properties... */
|
/* XXX Features in here should be replaced by properties... */
|
||||||
|
Loading…
Reference in New Issue
Block a user