Skip to content

Commit 138b57f

Browse files
tititiou36davem330
authored andcommitted
net: ibm: emac: Fix some error handling path in 'emac_probe()'
If 'irq_of_parse_and_map()' or 'of_address_to_resource()' fail, 'err' is known to be 0 at this point. So return -ENODEV instead in the first case and use 'of_iomap()' instead of the equivalent 'of_address_to_resource()/ioremap()' combinaison in the 2nd case. Doing so, the 'rsrc_regs' field of the 'emac_instance struct' becomes redundant and is removed. While at it, turn a 'err != 0' test into an equivalent 'err' to be more consistent. Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c3168ca commit 138b57f

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,26 +3032,22 @@ static int emac_probe(struct platform_device *ofdev)
30323032

30333033
/* Init various config data based on device-tree */
30343034
err = emac_init_config(dev);
3035-
if (err != 0)
3035+
if (err)
30363036
goto err_free;
30373037

30383038
/* Get interrupts. EMAC irq is mandatory, WOL irq is optional */
30393039
dev->emac_irq = irq_of_parse_and_map(np, 0);
30403040
dev->wol_irq = irq_of_parse_and_map(np, 1);
30413041
if (!dev->emac_irq) {
30423042
printk(KERN_ERR "%pOF: Can't map main interrupt\n", np);
3043+
err = -ENODEV;
30433044
goto err_free;
30443045
}
30453046
ndev->irq = dev->emac_irq;
30463047

30473048
/* Map EMAC regs */
3048-
if (of_address_to_resource(np, 0, &dev->rsrc_regs)) {
3049-
printk(KERN_ERR "%pOF: Can't get registers address\n", np);
3050-
goto err_irq_unmap;
3051-
}
3052-
// TODO : request_mem_region
3053-
dev->emacp = ioremap(dev->rsrc_regs.start,
3054-
resource_size(&dev->rsrc_regs));
3049+
// TODO : platform_get_resource() and devm_ioremap_resource()
3050+
dev->emacp = of_iomap(np, 0);
30553051
if (dev->emacp == NULL) {
30563052
printk(KERN_ERR "%pOF: Can't map device registers!\n", np);
30573053
err = -ENOMEM;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ struct emac_error_stats {
167167

168168
struct emac_instance {
169169
struct net_device *ndev;
170-
struct resource rsrc_regs;
171170
struct emac_regs __iomem *emacp;
172171
struct platform_device *ofdev;
173172
struct device_node **blist; /* bootlist entry */

0 commit comments

Comments
 (0)