diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:42 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:42 -0400 |
commit | 6ccc6d7ecbb427580d045699e434bc5c6f45e227 (patch) | |
tree | 885b73f2ecd57944333280965e77101c9d97c9bf /drivers/ide | |
parent | bfa7d8e55f0c5ae22ef57eb22942c74fdde7b9bd (diff) |
ide-generic: no need to probe all ports at once
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-generic.c | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 0a3cb0c33ae5..3104dc8d5b61 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -137,10 +137,9 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary) | |||
137 | 137 | ||
138 | static int __init ide_generic_init(void) | 138 | static int __init ide_generic_init(void) |
139 | { | 139 | { |
140 | hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; | 140 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
141 | struct ide_host *host; | ||
142 | unsigned long io_addr; | 141 | unsigned long io_addr; |
143 | int i, rc, primary = 0, secondary = 0; | 142 | int i, rc = 0, primary = 0, secondary = 0; |
144 | 143 | ||
145 | #ifdef CONFIG_MIPS | 144 | #ifdef CONFIG_MIPS |
146 | if (!ide_probe_legacy()) | 145 | if (!ide_probe_legacy()) |
@@ -161,13 +160,9 @@ static int __init ide_generic_init(void) | |||
161 | printk(KERN_INFO DRV_NAME ": enforcing probing of I/O ports " | 160 | printk(KERN_INFO DRV_NAME ": enforcing probing of I/O ports " |
162 | "upon user request\n"); | 161 | "upon user request\n"); |
163 | 162 | ||
164 | memset(hws, 0, sizeof(hw_regs_t *) * MAX_HWIFS); | ||
165 | |||
166 | for (i = 0; i < ARRAY_SIZE(legacy_bases); i++) { | 163 | for (i = 0; i < ARRAY_SIZE(legacy_bases); i++) { |
167 | io_addr = legacy_bases[i]; | 164 | io_addr = legacy_bases[i]; |
168 | 165 | ||
169 | hws[i] = NULL; | ||
170 | |||
171 | if ((probe_mask & (1 << i)) && io_addr) { | 166 | if ((probe_mask & (1 << i)) && io_addr) { |
172 | if (!request_region(io_addr, 8, DRV_NAME)) { | 167 | if (!request_region(io_addr, 8, DRV_NAME)) { |
173 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " | 168 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " |
@@ -184,45 +179,27 @@ static int __init ide_generic_init(void) | |||
184 | continue; | 179 | continue; |
185 | } | 180 | } |
186 | 181 | ||
187 | memset(&hw[i], 0, sizeof(hw[i])); | 182 | memset(&hw, 0, sizeof(hw)); |
188 | ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206); | 183 | ide_std_init_ports(&hw, io_addr, io_addr + 0x206); |
189 | #ifdef CONFIG_IA64 | 184 | #ifdef CONFIG_IA64 |
190 | hw[i].irq = isa_irq_to_vector(legacy_irqs[i]); | 185 | hw.irq = isa_irq_to_vector(legacy_irqs[i]); |
191 | #else | 186 | #else |
192 | hw[i].irq = legacy_irqs[i]; | 187 | hw.irq = legacy_irqs[i]; |
193 | #endif | 188 | #endif |
194 | hw[i].chipset = ide_generic; | 189 | hw.chipset = ide_generic; |
195 | 190 | ||
196 | hws[i] = &hw[i]; | 191 | rc = ide_host_add(NULL, hws, NULL); |
192 | if (rc) { | ||
193 | release_region(io_addr + 0x206, 1); | ||
194 | release_region(io_addr, 8); | ||
195 | } | ||
197 | } | 196 | } |
198 | } | 197 | } |
199 | 198 | ||
200 | host = ide_host_alloc_all(NULL, hws); | ||
201 | if (host == NULL) { | ||
202 | rc = -ENOMEM; | ||
203 | goto err; | ||
204 | } | ||
205 | |||
206 | rc = ide_host_register(host, NULL, hws); | ||
207 | if (rc) | ||
208 | goto err_free; | ||
209 | |||
210 | if (ide_generic_sysfs_init()) | 199 | if (ide_generic_sysfs_init()) |
211 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " | 200 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " |
212 | "class\n"); | 201 | "class\n"); |
213 | 202 | ||
214 | return 0; | ||
215 | err_free: | ||
216 | ide_host_free(host); | ||
217 | err: | ||
218 | for (i = 0; i < MAX_HWIFS; i++) { | ||
219 | if (hws[i] == NULL) | ||
220 | continue; | ||
221 | |||
222 | io_addr = hws[i]->io_ports.data_addr; | ||
223 | release_region(io_addr + 0x206, 1); | ||
224 | release_region(io_addr, 8); | ||
225 | } | ||
226 | return rc; | 203 | return rc; |
227 | } | 204 | } |
228 | 205 | ||