Skip to content

Commit dcc34ef

Browse files
nehebkuba-moo
authored andcommitted
net: ibm: emac: manage emac_irq with devm
It's the last to go in remove. Safe to let devm handle it. Also move request_irq to probe for clarity. It's removed in _remove not close. Use dev_err_probe instead of printk. Handles EPROBE_DEFER automatically. 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 b9758c4 commit dcc34ef

File tree

1 file changed

+11
-18
lines changed
  • drivers/net/ethernet/ibm/emac

1 file changed

+11
-18
lines changed

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,18 +1228,10 @@ static void emac_print_link_status(struct emac_instance *dev)
12281228
static int emac_open(struct net_device *ndev)
12291229
{
12301230
struct emac_instance *dev = netdev_priv(ndev);
1231-
int err, i;
1231+
int i;
12321232

12331233
DBG(dev, "open" NL);
12341234

1235-
/* Setup error IRQ handler */
1236-
err = request_irq(dev->emac_irq, emac_irq, 0, "EMAC", dev);
1237-
if (err) {
1238-
printk(KERN_ERR "%s: failed to request IRQ %d\n",
1239-
ndev->name, dev->emac_irq);
1240-
return err;
1241-
}
1242-
12431235
/* Allocate RX ring */
12441236
for (i = 0; i < NUM_RX_BUFF; ++i)
12451237
if (emac_alloc_rx_skb(dev, i)) {
@@ -1293,8 +1285,6 @@ static int emac_open(struct net_device *ndev)
12931285
return 0;
12941286
oom:
12951287
emac_clean_rx_ring(dev);
1296-
free_irq(dev->emac_irq, dev);
1297-
12981288
return -ENOMEM;
12991289
}
13001290

@@ -1408,8 +1398,6 @@ static int emac_close(struct net_device *ndev)
14081398
emac_clean_tx_ring(dev);
14091399
emac_clean_rx_ring(dev);
14101400

1411-
free_irq(dev->emac_irq, dev);
1412-
14131401
netif_carrier_off(ndev);
14141402

14151403
return 0;
@@ -3082,6 +3070,16 @@ static int emac_probe(struct platform_device *ofdev)
30823070
err = -ENODEV;
30833071
goto err_gone;
30843072
}
3073+
3074+
/* Setup error IRQ handler */
3075+
err = devm_request_irq(&ofdev->dev, dev->emac_irq, emac_irq, 0, "EMAC",
3076+
dev);
3077+
if (err) {
3078+
dev_err_probe(&ofdev->dev, err, "failed to request IRQ %d",
3079+
dev->emac_irq);
3080+
goto err_gone;
3081+
}
3082+
30853083
ndev->irq = dev->emac_irq;
30863084

30873085
/* Map EMAC regs */
@@ -3237,8 +3235,6 @@ static int emac_probe(struct platform_device *ofdev)
32373235
err_irq_unmap:
32383236
if (dev->wol_irq)
32393237
irq_dispose_mapping(dev->wol_irq);
3240-
if (dev->emac_irq)
3241-
irq_dispose_mapping(dev->emac_irq);
32423238
err_gone:
32433239
/* if we were on the bootlist, remove us as we won't show up and
32443240
* wake up all waiters to notify them in case they were waiting
@@ -3284,9 +3280,6 @@ static void emac_remove(struct platform_device *ofdev)
32843280

32853281
if (dev->wol_irq)
32863282
irq_dispose_mapping(dev->wol_irq);
3287-
if (dev->emac_irq)
3288-
irq_dispose_mapping(dev->emac_irq);
3289-
32903283
}
32913284

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

0 commit comments

Comments
 (0)