Skip to content

Commit b9758c4

Browse files
nehebkuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent beb2baa commit b9758c4

File tree

1 file changed

+3
-6
lines changed
  • drivers/net/ethernet/ibm/emac

1 file changed

+3
-6
lines changed

drivers/net/ethernet/ibm/emac/core.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,7 @@ static int emac_probe(struct platform_device *ofdev)
30533053

30543054
/* Allocate our net_device structure */
30553055
err = -ENOMEM;
3056-
ndev = alloc_etherdev(sizeof(struct emac_instance));
3056+
ndev = devm_alloc_etherdev(&ofdev->dev, sizeof(struct emac_instance));
30573057
if (!ndev)
30583058
goto err_gone;
30593059

@@ -3072,15 +3072,15 @@ static int emac_probe(struct platform_device *ofdev)
30723072
/* Init various config data based on device-tree */
30733073
err = emac_init_config(dev);
30743074
if (err)
3075-
goto err_free;
3075+
goto err_gone;
30763076

30773077
/* Get interrupts. EMAC irq is mandatory, WOL irq is optional */
30783078
dev->emac_irq = irq_of_parse_and_map(np, 0);
30793079
dev->wol_irq = irq_of_parse_and_map(np, 1);
30803080
if (!dev->emac_irq) {
30813081
printk(KERN_ERR "%pOF: Can't map main interrupt\n", np);
30823082
err = -ENODEV;
3083-
goto err_free;
3083+
goto err_gone;
30843084
}
30853085
ndev->irq = dev->emac_irq;
30863086

@@ -3239,8 +3239,6 @@ static int emac_probe(struct platform_device *ofdev)
32393239
irq_dispose_mapping(dev->wol_irq);
32403240
if (dev->emac_irq)
32413241
irq_dispose_mapping(dev->emac_irq);
3242-
err_free:
3243-
free_netdev(ndev);
32443242
err_gone:
32453243
/* if we were on the bootlist, remove us as we won't show up and
32463244
* wake up all waiters to notify them in case they were waiting
@@ -3289,7 +3287,6 @@ static void emac_remove(struct platform_device *ofdev)
32893287
if (dev->emac_irq)
32903288
irq_dispose_mapping(dev->emac_irq);
32913289

3292-
free_netdev(dev->ndev);
32933290
}
32943291

32953292
/* XXX Features in here should be replaced by properties... */

0 commit comments

Comments
 (0)