summaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-generic.c')
-rw-r--r--drivers/ide/ide-generic.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
index a7082c28d06..31d98fec775 100644
--- a/drivers/ide/ide-generic.c
+++ b/drivers/ide/ide-generic.c
@@ -84,13 +84,14 @@ static int __init ide_generic_init(void)
{
hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS];
struct ide_host *host;
- int i;
+ unsigned long io_addr;
+ int i, rc;
printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module "
"parameter for probing all legacy ISA IDE ports\n");
for (i = 0; i < MAX_HWIFS; i++) {
- unsigned long io_addr = ide_default_io_base(i);
+ io_addr = ide_default_io_base(i);
hws[i] = NULL;
@@ -120,14 +121,32 @@ static int __init ide_generic_init(void)
}
host = ide_host_alloc_all(NULL, hws);
- if (host)
- ide_host_register(host, NULL, hws);
+ if (host == NULL) {
+ rc = -ENOMEM;
+ goto err;
+ }
+
+ rc = ide_host_register(host, NULL, hws);
+ if (rc)
+ goto err_free;
if (ide_generic_sysfs_init())
printk(KERN_ERR DRV_NAME ": failed to create ide_generic "
"class\n");
return 0;
+err_free:
+ ide_host_free(host);
+err:
+ for (i = 0; i < MAX_HWIFS; i++) {
+ if (hws[i] == NULL)
+ continue;
+
+ io_addr = hws[i]->io_ports.data_addr;
+ release_region(io_addr + 0x206, 1);
+ release_region(io_addr, 8);
+ }
+ return rc;
}
module_init(ide_generic_init);