Commit fe12455c authored by Russell King's avatar Russell King

[ARM] Use ecard_{request,release}_resources() for resource management

Signed-off-by: default avatarRussell King <rmk@arm.linux.org.uk>
parent 7af60616
...@@ -997,15 +997,18 @@ static int __devinit ...@@ -997,15 +997,18 @@ static int __devinit
ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
{ {
struct net_device *dev; struct net_device *dev;
struct ether1_priv *priv;
int i, ret = 0; int i, ret = 0;
ether1_banner(); ether1_banner();
ret = ecard_request_resources(ec);
if (ret)
goto out;
dev = alloc_etherdev(sizeof(struct ether1_priv)); dev = alloc_etherdev(sizeof(struct ether1_priv));
if (!dev) { if (!dev) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto release;
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
...@@ -1013,15 +1016,9 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1013,15 +1016,9 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
dev->base_addr = ecard_address(ec, ECARD_IOC, ECARD_FAST); dev->base_addr = ecard_address(ec, ECARD_IOC, ECARD_FAST);
dev->irq = ec->irq; dev->irq = ec->irq;
/*
* these will not fail - the nature of the bus ensures this
*/
request_region(dev->base_addr, 16, dev->name);
request_region(dev->base_addr + 0x800, 4096, dev->name);
if ((priv(dev)->bus_type = ether1_reset(dev)) == 0) { if ((priv(dev)->bus_type = ether1_reset(dev)) == 0) {
ret = -ENODEV; ret = -ENODEV;
goto release; goto free;
} }
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
...@@ -1029,7 +1026,7 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1029,7 +1026,7 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
if (ether1_init_2(dev)) { if (ether1_init_2(dev)) {
ret = -ENODEV; ret = -ENODEV;
goto release; goto free;
} }
dev->open = ether1_open; dev->open = ether1_open;
...@@ -1042,7 +1039,7 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1042,7 +1039,7 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
ret = register_netdev(dev); ret = register_netdev(dev);
if (ret) if (ret)
goto release; goto free;
printk(KERN_INFO "%s: ether1 in slot %d, ", printk(KERN_INFO "%s: ether1 in slot %d, ",
dev->name, ec->slot_no); dev->name, ec->slot_no);
...@@ -1053,11 +1050,11 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1053,11 +1050,11 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
ecard_set_drvdata(ec, dev); ecard_set_drvdata(ec, dev);
return 0; return 0;
release: free:
release_region(dev->base_addr, 16);
release_region(dev->base_addr + 0x800, 4096);
free_netdev(dev); free_netdev(dev);
out: release:
ecard_release_resources(ec);
out:
return ret; return ret;
} }
...@@ -1068,10 +1065,8 @@ static void __devexit ether1_remove(struct expansion_card *ec) ...@@ -1068,10 +1065,8 @@ static void __devexit ether1_remove(struct expansion_card *ec)
ecard_set_drvdata(ec, NULL); ecard_set_drvdata(ec, NULL);
unregister_netdev(dev); unregister_netdev(dev);
release_region(dev->base_addr, 16);
release_region(dev->base_addr + 0x800, 4096);
free_netdev(dev); free_netdev(dev);
ecard_release_resources(ec);
} }
static const struct ecard_id ether1_ids[] = { static const struct ecard_id ether1_ids[] = {
......
...@@ -804,10 +804,14 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -804,10 +804,14 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
ether3_banner(); ether3_banner();
ret = ecard_request_resources(ec);
if (ret)
goto out;
dev = alloc_etherdev(sizeof(struct dev_priv)); dev = alloc_etherdev(sizeof(struct dev_priv));
if (!dev) { if (!dev) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto release;
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
...@@ -818,14 +822,6 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -818,14 +822,6 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
goto free; goto free;
} }
/*
* this will not fail - the nature of the bus ensures this
*/
if (!request_region(dev->base_addr, 128, dev->name)) {
ret = -EBUSY;
goto free;
}
init_timer(&priv(dev)->timer); init_timer(&priv(dev)->timer);
/* Reset card... /* Reset card...
...@@ -850,13 +846,13 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -850,13 +846,13 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
case BUS_UNKNOWN: case BUS_UNKNOWN:
printk(KERN_ERR "%s: unable to identify bus width\n", dev->name); printk(KERN_ERR "%s: unable to identify bus width\n", dev->name);
ret = -ENODEV; ret = -ENODEV;
goto failed; goto free;
case BUS_8: case BUS_8:
printk(KERN_ERR "%s: %s found, but is an unsupported " printk(KERN_ERR "%s: %s found, but is an unsupported "
"8-bit card\n", dev->name, name); "8-bit card\n", dev->name, name);
ret = -ENODEV; ret = -ENODEV;
goto failed; goto free;
default: default:
break; break;
...@@ -864,7 +860,7 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -864,7 +860,7 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
if (ether3_init_2(dev)) { if (ether3_init_2(dev)) {
ret = -ENODEV; ret = -ENODEV;
goto failed; goto free;
} }
dev->open = ether3_open; dev->open = ether3_open;
...@@ -877,7 +873,7 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -877,7 +873,7 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
ret = register_netdev(dev); ret = register_netdev(dev);
if (ret) if (ret)
goto failed; goto free;
printk("%s: %s in slot %d, ", dev->name, name, ec->slot_no); printk("%s: %s in slot %d, ", dev->name, name, ec->slot_no);
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
...@@ -886,11 +882,11 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -886,11 +882,11 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
ecard_set_drvdata(ec, dev); ecard_set_drvdata(ec, dev);
return 0; return 0;
failed: free:
release_region(dev->base_addr, 128);
free:
free_netdev(dev); free_netdev(dev);
out: release:
ecard_release_resources(ec);
out:
return ret; return ret;
} }
...@@ -901,8 +897,8 @@ static void __devexit ether3_remove(struct expansion_card *ec) ...@@ -901,8 +897,8 @@ static void __devexit ether3_remove(struct expansion_card *ec)
ecard_set_drvdata(ec, NULL); ecard_set_drvdata(ec, NULL);
unregister_netdev(dev); unregister_netdev(dev);
release_region(dev->base_addr, 128);
free_netdev(dev); free_netdev(dev);
ecard_release_resources(ec);
} }
static const struct ecard_id ether3_ids[] = { static const struct ecard_id ether3_ids[] = {
......
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