aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-03-26 14:13:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-03-26 14:13:06 -0400
commitbc2fd381d8f9dbeb181f82286cdca1567e3d0def (patch)
treee03b088a8bc1052d8f851764d201a13366cb97ce /drivers/ide/ide-probe.c
parent928a726b0e12184729900c076e13dbf1c511c96c (diff)
parent2ebe1d9efed5f232afc8d00901d0959c9814bce3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (53 commits) ide: use try_to_identify() in ide_driveid_update() ide: clear drive IRQ after re-enabling local IRQs in ide_driveid_update() ide: sanitize SELECT_MASK() usage in ide_driveid_update() ide: classify device type in do_probe() ide: remove broken EXABYTENEST support ide: shorten timeout value in ide_driveid_update() ide: propagate AltStatus workarounds to ide_driveid_update() ide: fix kmalloc() failure handling in ide_driveid_update() mn10300: remove <asm/ide.h> frv: remove <asm/ide.h> ide: remove pciirq argument from ide_pci_setup_ports() ide: fix ->init_chipset method to return 'int' value ide: remove try_to_identify() wrapper ide: remove no longer needed IRQ auto-probing from try_to_identify() (v2) ide: remove no longer needed IRQ fallback code from hwif_init() amd74xx: remove no longer needed ->init_hwif method ide: remove no longer needed IDE_HFLAG[_FORCE]_LEGACY_IRQS ide: use ide_pci_is_in_compatibility_mode() in ide_pci_init_{one,two}() ide: use pci_get_legacy_ide_irq() in ide_pci_init_{one,two}() ide: handle IDE_HFLAG[_FORCE]_LEGACY_IRQS in ide_pci_init_{one,two}() ...
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c257
1 files changed, 58 insertions, 199 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index ee8e3e7cad51..974067043fba 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -181,16 +181,16 @@ static void ide_classify_atapi_dev(ide_drive_t *drive)
181 * do_identify - identify a drive 181 * do_identify - identify a drive
182 * @drive: drive to identify 182 * @drive: drive to identify
183 * @cmd: command used 183 * @cmd: command used
184 * @id: buffer for IDENTIFY data
184 * 185 *
185 * Called when we have issued a drive identify command to 186 * Called when we have issued a drive identify command to
186 * read and parse the results. This function is run with 187 * read and parse the results. This function is run with
187 * interrupts disabled. 188 * interrupts disabled.
188 */ 189 */
189 190
190static void do_identify(ide_drive_t *drive, u8 cmd) 191static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id)
191{ 192{
192 ide_hwif_t *hwif = drive->hwif; 193 ide_hwif_t *hwif = drive->hwif;
193 u16 *id = drive->id;
194 char *m = (char *)&id[ATA_ID_PROD]; 194 char *m = (char *)&id[ATA_ID_PROD];
195 unsigned long flags; 195 unsigned long flags;
196 int bswap = 1; 196 int bswap = 1;
@@ -233,16 +233,6 @@ static void do_identify(ide_drive_t *drive, u8 cmd)
233 drive->dev_flags |= IDE_DFLAG_PRESENT; 233 drive->dev_flags |= IDE_DFLAG_PRESENT;
234 drive->dev_flags &= ~IDE_DFLAG_DEAD; 234 drive->dev_flags &= ~IDE_DFLAG_DEAD;
235 235
236 /*
237 * Check for an ATAPI device
238 */
239 if (cmd == ATA_CMD_ID_ATAPI)
240 ide_classify_atapi_dev(drive);
241 else
242 /*
243 * Not an ATAPI device: looks like a "regular" hard disk
244 */
245 ide_classify_ata_dev(drive);
246 return; 236 return;
247err_misc: 237err_misc:
248 kfree(id); 238 kfree(id);
@@ -250,21 +240,19 @@ err_misc:
250} 240}
251 241
252/** 242/**
253 * actual_try_to_identify - send ata/atapi identify 243 * ide_dev_read_id - send ATA/ATAPI IDENTIFY command
254 * @drive: drive to identify 244 * @drive: drive to identify
255 * @cmd: command to use 245 * @cmd: command to use
246 * @id: buffer for IDENTIFY data
256 * 247 *
257 * try_to_identify() sends an ATA(PI) IDENTIFY request to a drive 248 * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response.
258 * and waits for a response. It also monitors irqs while this is
259 * happening, in hope of automatically determining which one is
260 * being used by the interface.
261 * 249 *
262 * Returns: 0 device was identified 250 * Returns: 0 device was identified
263 * 1 device timed-out (no response to identify request) 251 * 1 device timed-out (no response to identify request)
264 * 2 device aborted the command (refused to identify itself) 252 * 2 device aborted the command (refused to identify itself)
265 */ 253 */
266 254
267static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) 255int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
268{ 256{
269 ide_hwif_t *hwif = drive->hwif; 257 ide_hwif_t *hwif = drive->hwif;
270 struct ide_io_ports *io_ports = &hwif->io_ports; 258 struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -273,6 +261,13 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
273 unsigned long timeout; 261 unsigned long timeout;
274 u8 s = 0, a = 0; 262 u8 s = 0, a = 0;
275 263
264 /*
265 * Disable device IRQ. Otherwise we'll get spurious interrupts
266 * during the identify phase that the IRQ handler isn't expecting.
267 */
268 if (io_ports->ctl_addr)
269 tp_ops->set_irq(hwif, 0);
270
276 /* take a deep breath */ 271 /* take a deep breath */
277 msleep(50); 272 msleep(50);
278 273
@@ -317,7 +312,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
317 312
318 if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { 313 if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
319 /* drive returned ID */ 314 /* drive returned ID */
320 do_identify(drive, cmd); 315 do_identify(drive, cmd, id);
321 /* drive responded with ID */ 316 /* drive responded with ID */
322 rc = 0; 317 rc = 0;
323 /* clear drive IRQ */ 318 /* clear drive IRQ */
@@ -329,63 +324,6 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
329 return rc; 324 return rc;
330} 325}
331 326
332/**
333 * try_to_identify - try to identify a drive
334 * @drive: drive to probe
335 * @cmd: command to use
336 *
337 * Issue the identify command and then do IRQ probing to
338 * complete the identification when needed by finding the
339 * IRQ the drive is attached to
340 */
341
342static int try_to_identify (ide_drive_t *drive, u8 cmd)
343{
344 ide_hwif_t *hwif = drive->hwif;
345 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
346 int retval;
347 int autoprobe = 0;
348 unsigned long cookie = 0;
349
350 /*
351 * Disable device irq unless we need to
352 * probe for it. Otherwise we'll get spurious
353 * interrupts during the identify-phase that
354 * the irq handler isn't expecting.
355 */
356 if (hwif->io_ports.ctl_addr) {
357 if (!hwif->irq) {
358 autoprobe = 1;
359 cookie = probe_irq_on();
360 }
361 tp_ops->set_irq(hwif, autoprobe);
362 }
363
364 retval = actual_try_to_identify(drive, cmd);
365
366 if (autoprobe) {
367 int irq;
368
369 tp_ops->set_irq(hwif, 0);
370 /* clear drive IRQ */
371 (void)tp_ops->read_status(hwif);
372 udelay(5);
373 irq = probe_irq_off(cookie);
374 if (!hwif->irq) {
375 if (irq > 0) {
376 hwif->irq = irq;
377 } else {
378 /* Mmmm.. multiple IRQs..
379 * don't know which was ours
380 */
381 printk(KERN_ERR "%s: IRQ probe failed (0x%lx)\n",
382 drive->name, cookie);
383 }
384 }
385 }
386 return retval;
387}
388
389int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus) 327int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
390{ 328{
391 u8 stat; 329 u8 stat;
@@ -440,6 +378,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
440{ 378{
441 ide_hwif_t *hwif = drive->hwif; 379 ide_hwif_t *hwif = drive->hwif;
442 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 380 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
381 u16 *id = drive->id;
443 int rc; 382 int rc;
444 u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; 383 u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat;
445 384
@@ -475,11 +414,10 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
475 414
476 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || 415 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) ||
477 present || cmd == ATA_CMD_ID_ATAPI) { 416 present || cmd == ATA_CMD_ID_ATAPI) {
478 /* send cmd and wait */ 417 rc = ide_dev_read_id(drive, cmd, id);
479 if ((rc = try_to_identify(drive, cmd))) { 418 if (rc)
480 /* failed: try again */ 419 /* failed: try again */
481 rc = try_to_identify(drive,cmd); 420 rc = ide_dev_read_id(drive, cmd, id);
482 }
483 421
484 stat = tp_ops->read_status(hwif); 422 stat = tp_ops->read_status(hwif);
485 423
@@ -494,7 +432,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
494 msleep(50); 432 msleep(50);
495 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); 433 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
496 (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); 434 (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0);
497 rc = try_to_identify(drive, cmd); 435 rc = ide_dev_read_id(drive, cmd, id);
498 } 436 }
499 437
500 /* ensure drive IRQ is clear */ 438 /* ensure drive IRQ is clear */
@@ -517,37 +455,6 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
517 return rc; 455 return rc;
518} 456}
519 457
520/*
521 *
522 */
523static void enable_nest (ide_drive_t *drive)
524{
525 ide_hwif_t *hwif = drive->hwif;
526 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
527 u8 stat;
528
529 printk(KERN_INFO "%s: enabling %s -- ",
530 hwif->name, (char *)&drive->id[ATA_ID_PROD]);
531
532 SELECT_DRIVE(drive);
533 msleep(50);
534 tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST);
535
536 if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 0)) {
537 printk(KERN_CONT "failed (timeout)\n");
538 return;
539 }
540
541 msleep(50);
542
543 stat = tp_ops->read_status(hwif);
544
545 if (!OK_STAT(stat, 0, BAD_STAT))
546 printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
547 else
548 printk(KERN_CONT "success\n");
549}
550
551/** 458/**
552 * probe_for_drives - upper level drive probe 459 * probe_for_drives - upper level drive probe
553 * @drive: drive to probe for 460 * @drive: drive to probe for
@@ -563,6 +470,8 @@ static void enable_nest (ide_drive_t *drive)
563static u8 probe_for_drive(ide_drive_t *drive) 470static u8 probe_for_drive(ide_drive_t *drive)
564{ 471{
565 char *m; 472 char *m;
473 int rc;
474 u8 cmd;
566 475
567 /* 476 /*
568 * In order to keep things simple we have an id 477 * In order to keep things simple we have an id
@@ -586,21 +495,19 @@ static u8 probe_for_drive(ide_drive_t *drive)
586 495
587 /* skip probing? */ 496 /* skip probing? */
588 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) { 497 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) {
589retry:
590 /* if !(success||timed-out) */ 498 /* if !(success||timed-out) */
591 if (do_probe(drive, ATA_CMD_ID_ATA) >= 2) 499 cmd = ATA_CMD_ID_ATA;
500 rc = do_probe(drive, cmd);
501 if (rc >= 2) {
592 /* look for ATAPI device */ 502 /* look for ATAPI device */
593 (void)do_probe(drive, ATA_CMD_ID_ATAPI); 503 cmd = ATA_CMD_ID_ATAPI;
504 rc = do_probe(drive, cmd);
505 }
594 506
595 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 507 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
596 /* drive not found */ 508 /* drive not found */
597 return 0; 509 return 0;
598 510
599 if (strstr(m, "E X A B Y T E N E S T")) {
600 enable_nest(drive);
601 goto retry;
602 }
603
604 /* identification failed? */ 511 /* identification failed? */
605 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 512 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
606 if (drive->media == ide_disk) { 513 if (drive->media == ide_disk) {
@@ -614,8 +521,12 @@ retry:
614 printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); 521 printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name);
615 drive->dev_flags &= ~IDE_DFLAG_PRESENT; 522 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
616 } 523 }
524 } else {
525 if (cmd == ATA_CMD_ID_ATAPI)
526 ide_classify_atapi_dev(drive);
527 else
528 ide_classify_ata_dev(drive);
617 } 529 }
618 /* drive was found */
619 } 530 }
620 531
621 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 532 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
@@ -779,7 +690,6 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
779static int ide_probe_port(ide_hwif_t *hwif) 690static int ide_probe_port(ide_hwif_t *hwif)
780{ 691{
781 ide_drive_t *drive; 692 ide_drive_t *drive;
782 unsigned long flags;
783 unsigned int irqd; 693 unsigned int irqd;
784 int i, rc = -ENODEV; 694 int i, rc = -ENODEV;
785 695
@@ -797,9 +707,6 @@ static int ide_probe_port(ide_hwif_t *hwif)
797 if (irqd) 707 if (irqd)
798 disable_irq(hwif->irq); 708 disable_irq(hwif->irq);
799 709
800 local_save_flags(flags);
801 local_irq_enable_in_hardirq();
802
803 if (ide_port_wait_ready(hwif) == -EBUSY) 710 if (ide_port_wait_ready(hwif) == -EBUSY)
804 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); 711 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name);
805 712
@@ -813,8 +720,6 @@ static int ide_probe_port(ide_hwif_t *hwif)
813 rc = 0; 720 rc = 0;
814 } 721 }
815 722
816 local_irq_restore(flags);
817
818 /* 723 /*
819 * Use cached IRQ number. It might be (and is...) changed by probe 724 * Use cached IRQ number. It might be (and is...) changed by probe
820 * code above 725 * code above
@@ -831,29 +736,18 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
831 ide_drive_t *drive; 736 ide_drive_t *drive;
832 int i; 737 int i;
833 738
834 ide_port_for_each_dev(i, drive, hwif) { 739 ide_port_for_each_present_dev(i, drive, hwif) {
835 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 740 if (port_ops && port_ops->quirkproc)
836 if (port_ops && port_ops->quirkproc) 741 port_ops->quirkproc(drive);
837 port_ops->quirkproc(drive);
838 }
839 } 742 }
840 743
841 ide_port_for_each_dev(i, drive, hwif) { 744 ide_port_for_each_present_dev(i, drive, hwif) {
842 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 745 ide_set_max_pio(drive);
843 ide_set_max_pio(drive);
844 746
845 drive->dev_flags |= IDE_DFLAG_NICE1; 747 drive->dev_flags |= IDE_DFLAG_NICE1;
846
847 if (hwif->dma_ops)
848 ide_set_dma(drive);
849 }
850 }
851 748
852 ide_port_for_each_dev(i, drive, hwif) { 749 if (hwif->dma_ops)
853 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) 750 ide_set_dma(drive);
854 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
855 else
856 drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT;
857 } 751 }
858} 752}
859 753
@@ -924,10 +818,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
924 int i, j = 0; 818 int i, j = 0;
925 819
926 mutex_lock(&ide_cfg_mtx); 820 mutex_lock(&ide_cfg_mtx);
927 ide_port_for_each_dev(i, drive, hwif) { 821 ide_port_for_each_present_dev(i, drive, hwif) {
928 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
929 continue;
930
931 if (ide_init_queue(drive)) { 822 if (ide_init_queue(drive)) {
932 printk(KERN_ERR "ide: failed to init %s\n", 823 printk(KERN_ERR "ide: failed to init %s\n",
933 drive->name); 824 drive->name);
@@ -953,13 +844,6 @@ static int init_irq (ide_hwif_t *hwif)
953 irq_handler_t irq_handler; 844 irq_handler_t irq_handler;
954 int sa = 0; 845 int sa = 0;
955 846
956 mutex_lock(&ide_cfg_mtx);
957 spin_lock_init(&hwif->lock);
958
959 init_timer(&hwif->timer);
960 hwif->timer.function = &ide_timer_expiry;
961 hwif->timer.data = (unsigned long)hwif;
962
963 irq_handler = hwif->host->irq_handler; 847 irq_handler = hwif->host->irq_handler;
964 if (irq_handler == NULL) 848 if (irq_handler == NULL)
965 irq_handler = ide_intr; 849 irq_handler = ide_intr;
@@ -997,10 +881,8 @@ static int init_irq (ide_hwif_t *hwif)
997 printk(KERN_CONT " (serialized)"); 881 printk(KERN_CONT " (serialized)");
998 printk(KERN_CONT "\n"); 882 printk(KERN_CONT "\n");
999 883
1000 mutex_unlock(&ide_cfg_mtx);
1001 return 0; 884 return 0;
1002out_up: 885out_up:
1003 mutex_unlock(&ide_cfg_mtx);
1004 return 1; 886 return 1;
1005} 887}
1006 888
@@ -1099,14 +981,9 @@ static void drive_release_dev (struct device *dev)
1099 981
1100static int hwif_init(ide_hwif_t *hwif) 982static int hwif_init(ide_hwif_t *hwif)
1101{ 983{
1102 int old_irq;
1103
1104 if (!hwif->irq) { 984 if (!hwif->irq) {
1105 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); 985 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name);
1106 if (!hwif->irq) { 986 return 0;
1107 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name);
1108 return 0;
1109 }
1110 } 987 }
1111 988
1112 if (register_blkdev(hwif->major, hwif->name)) 989 if (register_blkdev(hwif->major, hwif->name))
@@ -1124,29 +1001,12 @@ static int hwif_init(ide_hwif_t *hwif)
1124 1001
1125 sg_init_table(hwif->sg_table, hwif->sg_max_nents); 1002 sg_init_table(hwif->sg_table, hwif->sg_max_nents);
1126 1003
1127 if (init_irq(hwif) == 0)
1128 goto done;
1129
1130 old_irq = hwif->irq;
1131 /*
1132 * It failed to initialise. Find the default IRQ for
1133 * this port and try that.
1134 */
1135 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr);
1136 if (!hwif->irq) {
1137 printk(KERN_ERR "%s: disabled, unable to get IRQ %d\n",
1138 hwif->name, old_irq);
1139 goto out;
1140 }
1141 if (init_irq(hwif)) { 1004 if (init_irq(hwif)) {
1142 printk(KERN_ERR "%s: probed IRQ %d and default IRQ %d failed\n", 1005 printk(KERN_ERR "%s: disabled, unable to get IRQ %d\n",
1143 hwif->name, old_irq, hwif->irq); 1006 hwif->name, hwif->irq);
1144 goto out; 1007 goto out;
1145 } 1008 }
1146 printk(KERN_WARNING "%s: probed IRQ %d failed, using default\n",
1147 hwif->name, hwif->irq);
1148 1009
1149done:
1150 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, 1010 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS,
1151 THIS_MODULE, ata_probe, ata_lock, hwif); 1011 THIS_MODULE, ata_probe, ata_lock, hwif);
1152 return 1; 1012 return 1;
@@ -1161,13 +1021,10 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1161 ide_drive_t *drive; 1021 ide_drive_t *drive;
1162 unsigned int i; 1022 unsigned int i;
1163 1023
1164 ide_port_for_each_dev(i, drive, hwif) { 1024 ide_port_for_each_present_dev(i, drive, hwif) {
1165 struct device *dev = &drive->gendev; 1025 struct device *dev = &drive->gendev;
1166 int ret; 1026 int ret;
1167 1027
1168 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
1169 continue;
1170
1171 dev_set_name(dev, "%u.%u", hwif->index, i); 1028 dev_set_name(dev, "%u.%u", hwif->index, i);
1172 dev->parent = &hwif->gendev; 1029 dev->parent = &hwif->gendev;
1173 dev->bus = &ide_bus_type; 1030 dev->bus = &ide_bus_type;
@@ -1192,6 +1049,8 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
1192 1049
1193 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) 1050 if (hwif->host_flags & IDE_HFLAG_IO_32BIT)
1194 drive->io_32bit = 1; 1051 drive->io_32bit = 1;
1052 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT)
1053 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
1195 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) 1054 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS)
1196 drive->dev_flags |= IDE_DFLAG_UNMASK; 1055 drive->dev_flags |= IDE_DFLAG_UNMASK;
1197 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) 1056 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS)
@@ -1213,10 +1072,6 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
1213 if (d->init_iops) 1072 if (d->init_iops)
1214 d->init_iops(hwif); 1073 d->init_iops(hwif);
1215 1074
1216 if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) ||
1217 (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
1218 hwif->irq = port ? 15 : 14;
1219
1220 /* ->host_flags may be set by ->init_iops (or even earlier...) */ 1075 /* ->host_flags may be set by ->init_iops (or even earlier...) */
1221 hwif->host_flags |= d->host_flags; 1076 hwif->host_flags |= d->host_flags;
1222 hwif->pio_mask = d->pio_mask; 1077 hwif->pio_mask = d->pio_mask;
@@ -1317,6 +1172,12 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
1317 hwif->name[2] = 'e'; 1172 hwif->name[2] = 'e';
1318 hwif->name[3] = '0' + index; 1173 hwif->name[3] = '0' + index;
1319 1174
1175 spin_lock_init(&hwif->lock);
1176
1177 init_timer(&hwif->timer);
1178 hwif->timer.function = &ide_timer_expiry;
1179 hwif->timer.data = (unsigned long)hwif;
1180
1320 init_completion(&hwif->gendev_rel_comp); 1181 init_completion(&hwif->gendev_rel_comp);
1321 1182
1322 hwif->tp_ops = &default_tp_ops; 1183 hwif->tp_ops = &default_tp_ops;
@@ -1567,7 +1428,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1567 1428
1568 j++; 1429 j++;
1569 1430
1570 ide_acpi_init(hwif); 1431 ide_acpi_init_port(hwif);
1571 1432
1572 if (hwif->present) 1433 if (hwif->present)
1573 ide_acpi_port_init_devices(hwif); 1434 ide_acpi_port_init_devices(hwif);
@@ -1624,11 +1485,9 @@ static void __ide_port_unregister_devices(ide_hwif_t *hwif)
1624 ide_drive_t *drive; 1485 ide_drive_t *drive;
1625 int i; 1486 int i;
1626 1487
1627 ide_port_for_each_dev(i, drive, hwif) { 1488 ide_port_for_each_present_dev(i, drive, hwif) {
1628 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 1489 device_unregister(&drive->gendev);
1629 device_unregister(&drive->gendev); 1490 wait_for_completion(&drive->gendev_rel_comp);
1630 wait_for_completion(&drive->gendev_rel_comp);
1631 }
1632 } 1491 }
1633} 1492}
1634 1493