aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r--drivers/ide/ide.c69
1 files changed, 14 insertions, 55 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 917c72dcd33d..d868ca44d033 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -100,13 +100,8 @@ int ide_noacpitfs = 1;
100int ide_noacpionboot = 1; 100int ide_noacpionboot = 1;
101#endif 101#endif
102 102
103/*
104 * This is declared extern in ide.h, for access by other IDE modules:
105 */
106ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ 103ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */
107 104
108EXPORT_SYMBOL(ide_hwifs);
109
110static void ide_port_init_devices_data(ide_hwif_t *); 105static void ide_port_init_devices_data(ide_hwif_t *);
111 106
112/* 107/*
@@ -232,30 +227,6 @@ static int ide_system_bus_speed(void)
232 return pci_dev_present(pci_default) ? 33 : 50; 227 return pci_dev_present(pci_default) ? 33 : 50;
233} 228}
234 229
235ide_hwif_t * ide_find_port(unsigned long base)
236{
237 ide_hwif_t *hwif;
238 int i;
239
240 for (i = 0; i < MAX_HWIFS; i++) {
241 hwif = &ide_hwifs[i];
242 if (hwif->io_ports[IDE_DATA_OFFSET] == base)
243 goto found;
244 }
245
246 for (i = 0; i < MAX_HWIFS; i++) {
247 hwif = &ide_hwifs[i];
248 if (hwif->chipset == ide_unknown)
249 goto found;
250 }
251
252 hwif = NULL;
253found:
254 return hwif;
255}
256
257EXPORT_SYMBOL_GPL(ide_find_port);
258
259static struct resource* hwif_request_region(ide_hwif_t *hwif, 230static struct resource* hwif_request_region(ide_hwif_t *hwif,
260 unsigned long addr, int num) 231 unsigned long addr, int num)
261{ 232{
@@ -280,29 +251,21 @@ static struct resource* hwif_request_region(ide_hwif_t *hwif,
280int ide_hwif_request_regions(ide_hwif_t *hwif) 251int ide_hwif_request_regions(ide_hwif_t *hwif)
281{ 252{
282 unsigned long addr; 253 unsigned long addr;
283 unsigned int i;
284 254
285 if (hwif->mmio) 255 if (hwif->mmio)
286 return 0; 256 return 0;
257
287 addr = hwif->io_ports[IDE_CONTROL_OFFSET]; 258 addr = hwif->io_ports[IDE_CONTROL_OFFSET];
259
288 if (addr && !hwif_request_region(hwif, addr, 1)) 260 if (addr && !hwif_request_region(hwif, addr, 1))
289 goto control_region_busy; 261 goto control_region_busy;
290 hwif->straight8 = 0; 262
291 addr = hwif->io_ports[IDE_DATA_OFFSET]; 263 addr = hwif->io_ports[IDE_DATA_OFFSET];
292 if ((addr | 7) == hwif->io_ports[IDE_STATUS_OFFSET]) { 264 BUG_ON((addr | 7) != hwif->io_ports[IDE_STATUS_OFFSET]);
293 if (!hwif_request_region(hwif, addr, 8)) 265
294 goto data_region_busy; 266 if (!hwif_request_region(hwif, addr, 8))
295 hwif->straight8 = 1; 267 goto data_region_busy;
296 return 0; 268
297 }
298 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
299 addr = hwif->io_ports[i];
300 if (!hwif_request_region(hwif, addr, 1)) {
301 while (--i)
302 release_region(addr, 1);
303 goto data_region_busy;
304 }
305 }
306 return 0; 269 return 0;
307 270
308data_region_busy: 271data_region_busy:
@@ -328,19 +291,13 @@ control_region_busy:
328 291
329void ide_hwif_release_regions(ide_hwif_t *hwif) 292void ide_hwif_release_regions(ide_hwif_t *hwif)
330{ 293{
331 u32 i = 0;
332
333 if (hwif->mmio) 294 if (hwif->mmio)
334 return; 295 return;
296
335 if (hwif->io_ports[IDE_CONTROL_OFFSET]) 297 if (hwif->io_ports[IDE_CONTROL_OFFSET])
336 release_region(hwif->io_ports[IDE_CONTROL_OFFSET], 1); 298 release_region(hwif->io_ports[IDE_CONTROL_OFFSET], 1);
337 if (hwif->straight8) { 299
338 release_region(hwif->io_ports[IDE_DATA_OFFSET], 8); 300 release_region(hwif->io_ports[IDE_DATA_OFFSET], 8);
339 return;
340 }
341 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
342 if (hwif->io_ports[i])
343 release_region(hwif->io_ports[i], 1);
344} 301}
345 302
346void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) 303void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
@@ -627,11 +584,13 @@ out:
627int set_pio_mode(ide_drive_t *drive, int arg) 584int set_pio_mode(ide_drive_t *drive, int arg)
628{ 585{
629 struct request rq; 586 struct request rq;
587 ide_hwif_t *hwif = drive->hwif;
630 588
631 if (arg < 0 || arg > 255) 589 if (arg < 0 || arg > 255)
632 return -EINVAL; 590 return -EINVAL;
633 591
634 if (drive->hwif->set_pio_mode == NULL) 592 if (hwif->set_pio_mode == NULL ||
593 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
635 return -ENOSYS; 594 return -ENOSYS;
636 595
637 if (drive->special.b.set_tune) 596 if (drive->special.b.set_tune)