diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-23 13:55:59 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-23 13:55:59 -0400 |
commit | 8a69580e1ea9516caada5eed202afd39546e9809 (patch) | |
tree | fb300fb7d67e09470a2654811baaa7832fec2fae /drivers/ide/ide-generic.c | |
parent | 18de10170df31d34b342612f1c896a16a52f0a5c (diff) |
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.c | 27 |
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) | |||
84 | { | 84 | { |
85 | hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; | 85 | hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; |
86 | struct ide_host *host; | 86 | struct ide_host *host; |
87 | int i; | 87 | unsigned long io_addr; |
88 | int i, rc; | ||
88 | 89 | ||
89 | printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " | 90 | printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " |
90 | "parameter for probing all legacy ISA IDE ports\n"); | 91 | "parameter for probing all legacy ISA IDE ports\n"); |
91 | 92 | ||
92 | for (i = 0; i < MAX_HWIFS; i++) { | 93 | for (i = 0; i < MAX_HWIFS; i++) { |
93 | unsigned long io_addr = ide_default_io_base(i); | 94 | io_addr = ide_default_io_base(i); |
94 | 95 | ||
95 | hws[i] = NULL; | 96 | hws[i] = NULL; |
96 | 97 | ||
@@ -120,14 +121,32 @@ static int __init ide_generic_init(void) | |||
120 | } | 121 | } |
121 | 122 | ||
122 | host = ide_host_alloc_all(NULL, hws); | 123 | host = ide_host_alloc_all(NULL, hws); |
123 | if (host) | 124 | if (host == NULL) { |
124 | ide_host_register(host, NULL, hws); | 125 | rc = -ENOMEM; |
126 | goto err; | ||
127 | } | ||
128 | |||
129 | rc = ide_host_register(host, NULL, hws); | ||
130 | if (rc) | ||
131 | goto err_free; | ||
125 | 132 | ||
126 | if (ide_generic_sysfs_init()) | 133 | if (ide_generic_sysfs_init()) |
127 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " | 134 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " |
128 | "class\n"); | 135 | "class\n"); |
129 | 136 | ||
130 | return 0; | 137 | return 0; |
138 | err_free: | ||
139 | ide_host_free(host); | ||
140 | err: | ||
141 | for (i = 0; i < MAX_HWIFS; i++) { | ||
142 | if (hws[i] == NULL) | ||
143 | continue; | ||
144 | |||
145 | io_addr = hws[i]->io_ports.data_addr; | ||
146 | release_region(io_addr + 0x206, 1); | ||
147 | release_region(io_addr, 8); | ||
148 | } | ||
149 | return rc; | ||
131 | } | 150 | } |
132 | 151 | ||
133 | module_init(ide_generic_init); | 152 | module_init(ide_generic_init); |