summaryrefslogtreecommitdiff
path: root/drivers/ide/ide-generic.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 21:55:59 +0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 21:55:59 +0400
commit8a69580e1ea9516caada5eed202afd39546e9809 (patch)
treefb300fb7d67e09470a2654811baaa7832fec2fae /drivers/ide/ide-generic.c
parent18de10170df31d34b342612f1c896a16a52f0a5c (diff)
downloadlinux-8a69580e1ea9516caada5eed202afd39546e9809.tar.xz
ide: add ide_host_free() helper (take 2)
* Add ide_host_free() helper and convert ide_host_remove() to use it. * Fix handling of ide_host_register() failure in ide_host_add(), icside.c, ide-generic.c, falconide.c and sgiioc4.c. While at it: * Fix handling of ide_host_alloc_all() failure in ide-generic.c. * Fix handling of ide_host_alloc() failure in falconide.c (also return the correct error value if no device is found). v2: * falconide build fix. (From Stephen Rothwell) Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
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 a7082c28d06f..31d98fec775f 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);