Commit 138b57f0 authored by Christophe Jaillet's avatar Christophe Jaillet Committed by David S. Miller

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c3168cab
...@@ -3032,7 +3032,7 @@ static int emac_probe(struct platform_device *ofdev) ...@@ -3032,7 +3032,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 != 0) if (err)
goto err_free; goto err_free;
/* Get interrupts. EMAC irq is mandatory, WOL irq is optional */ /* Get interrupts. EMAC irq is mandatory, WOL irq is optional */
...@@ -3040,18 +3040,14 @@ static int emac_probe(struct platform_device *ofdev) ...@@ -3040,18 +3040,14 @@ static int emac_probe(struct platform_device *ofdev)
dev->wol_irq = irq_of_parse_and_map(np, 1); dev->wol_irq = irq_of_parse_and_map(np, 1);
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;
goto err_free; goto err_free;
} }
ndev->irq = dev->emac_irq; ndev->irq = dev->emac_irq;
/* Map EMAC regs */ /* Map EMAC regs */
if (of_address_to_resource(np, 0, &dev->rsrc_regs)) { // TODO : platform_get_resource() and devm_ioremap_resource()
printk(KERN_ERR "%pOF: Can't get registers address\n", np); dev->emacp = of_iomap(np, 0);
goto err_irq_unmap;
}
// TODO : request_mem_region
dev->emacp = ioremap(dev->rsrc_regs.start,
resource_size(&dev->rsrc_regs));
if (dev->emacp == NULL) { if (dev->emacp == NULL) {
printk(KERN_ERR "%pOF: Can't map device registers!\n", np); printk(KERN_ERR "%pOF: Can't map device registers!\n", np);
err = -ENOMEM; err = -ENOMEM;
......
...@@ -167,7 +167,6 @@ struct emac_error_stats { ...@@ -167,7 +167,6 @@ struct emac_error_stats {
struct emac_instance { struct emac_instance {
struct net_device *ndev; struct net_device *ndev;
struct resource rsrc_regs;
struct emac_regs __iomem *emacp; struct emac_regs __iomem *emacp;
struct platform_device *ofdev; struct platform_device *ofdev;
struct device_node **blist; /* bootlist entry */ struct device_node **blist; /* bootlist entry */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment