diff options
Diffstat (limited to 'drivers/ide/ide-generic.c')
-rw-r--r-- | drivers/ide/ide-generic.c | 51 |
1 files changed, 12 insertions, 39 deletions
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 0a3cb0c33ae5..81a5282ce1eb 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -137,15 +137,10 @@ 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 | ||
146 | if (!ide_probe_legacy()) | ||
147 | return -ENODEV; | ||
148 | #endif | ||
149 | ide_generic_check_pci_legacy_iobases(&primary, &secondary); | 144 | ide_generic_check_pci_legacy_iobases(&primary, &secondary); |
150 | 145 | ||
151 | if (!probe_mask) { | 146 | if (!probe_mask) { |
@@ -161,13 +156,9 @@ static int __init ide_generic_init(void) | |||
161 | printk(KERN_INFO DRV_NAME ": enforcing probing of I/O ports " | 156 | printk(KERN_INFO DRV_NAME ": enforcing probing of I/O ports " |
162 | "upon user request\n"); | 157 | "upon user request\n"); |
163 | 158 | ||
164 | memset(hws, 0, sizeof(hw_regs_t *) * MAX_HWIFS); | ||
165 | |||
166 | for (i = 0; i < ARRAY_SIZE(legacy_bases); i++) { | 159 | for (i = 0; i < ARRAY_SIZE(legacy_bases); i++) { |
167 | io_addr = legacy_bases[i]; | 160 | io_addr = legacy_bases[i]; |
168 | 161 | ||
169 | hws[i] = NULL; | ||
170 | |||
171 | if ((probe_mask & (1 << i)) && io_addr) { | 162 | if ((probe_mask & (1 << i)) && io_addr) { |
172 | if (!request_region(io_addr, 8, DRV_NAME)) { | 163 | if (!request_region(io_addr, 8, DRV_NAME)) { |
173 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " | 164 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " |
@@ -184,45 +175,27 @@ static int __init ide_generic_init(void) | |||
184 | continue; | 175 | continue; |
185 | } | 176 | } |
186 | 177 | ||
187 | memset(&hw[i], 0, sizeof(hw[i])); | 178 | memset(&hw, 0, sizeof(hw)); |
188 | ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206); | 179 | ide_std_init_ports(&hw, io_addr, io_addr + 0x206); |
189 | #ifdef CONFIG_IA64 | 180 | #ifdef CONFIG_IA64 |
190 | hw[i].irq = isa_irq_to_vector(legacy_irqs[i]); | 181 | hw.irq = isa_irq_to_vector(legacy_irqs[i]); |
191 | #else | 182 | #else |
192 | hw[i].irq = legacy_irqs[i]; | 183 | hw.irq = legacy_irqs[i]; |
193 | #endif | 184 | #endif |
194 | hw[i].chipset = ide_generic; | 185 | hw.chipset = ide_generic; |
195 | 186 | ||
196 | hws[i] = &hw[i]; | 187 | rc = ide_host_add(NULL, hws, NULL); |
188 | if (rc) { | ||
189 | release_region(io_addr + 0x206, 1); | ||
190 | release_region(io_addr, 8); | ||
191 | } | ||
197 | } | 192 | } |
198 | } | 193 | } |
199 | 194 | ||
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()) | 195 | if (ide_generic_sysfs_init()) |
211 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " | 196 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " |
212 | "class\n"); | 197 | "class\n"); |
213 | 198 | ||
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; | 199 | return rc; |
227 | } | 200 | } |
228 | 201 | ||