aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-iops.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-iops.c')
-rw-r--r--drivers/ide/ide-iops.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index a95178f5e1bb..c32e759df208 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -430,10 +430,10 @@ int drive_is_ready (ide_drive_t *drive)
430 * about possible isa-pnp and pci-pnp issues yet. 430 * about possible isa-pnp and pci-pnp issues yet.
431 */ 431 */
432 if (IDE_CONTROL_REG) 432 if (IDE_CONTROL_REG)
433 stat = hwif->INB(IDE_ALTSTATUS_REG); 433 stat = ide_read_altstatus(drive);
434 else 434 else
435 /* Note: this may clear a pending IRQ!! */ 435 /* Note: this may clear a pending IRQ!! */
436 stat = hwif->INB(IDE_STATUS_REG); 436 stat = ide_read_status(drive);
437 437
438 if (stat & BUSY_STAT) 438 if (stat & BUSY_STAT)
439 /* drive busy: definitely not interrupting */ 439 /* drive busy: definitely not interrupting */
@@ -458,23 +458,24 @@ EXPORT_SYMBOL(drive_is_ready);
458 */ 458 */
459static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) 459static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat)
460{ 460{
461 ide_hwif_t *hwif = drive->hwif;
462 unsigned long flags; 461 unsigned long flags;
463 int i; 462 int i;
464 u8 stat; 463 u8 stat;
465 464
466 udelay(1); /* spec allows drive 400ns to assert "BUSY" */ 465 udelay(1); /* spec allows drive 400ns to assert "BUSY" */
467 if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) { 466 stat = ide_read_status(drive);
467
468 if (stat & BUSY_STAT) {
468 local_irq_set(flags); 469 local_irq_set(flags);
469 timeout += jiffies; 470 timeout += jiffies;
470 while ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) { 471 while ((stat = ide_read_status(drive)) & BUSY_STAT) {
471 if (time_after(jiffies, timeout)) { 472 if (time_after(jiffies, timeout)) {
472 /* 473 /*
473 * One last read after the timeout in case 474 * One last read after the timeout in case
474 * heavy interrupt load made us not make any 475 * heavy interrupt load made us not make any
475 * progress during the timeout.. 476 * progress during the timeout..
476 */ 477 */
477 stat = hwif->INB(IDE_STATUS_REG); 478 stat = ide_read_status(drive);
478 if (!(stat & BUSY_STAT)) 479 if (!(stat & BUSY_STAT))
479 break; 480 break;
480 481
@@ -494,7 +495,9 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
494 */ 495 */
495 for (i = 0; i < 10; i++) { 496 for (i = 0; i < 10; i++) {
496 udelay(1); 497 udelay(1);
497 if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), good, bad)) { 498 stat = ide_read_status(drive);
499
500 if (OK_STAT(stat, good, bad)) {
498 *rstat = stat; 501 *rstat = stat;
499 return 0; 502 return 0;
500 } 503 }
@@ -617,6 +620,7 @@ int ide_driveid_update(ide_drive_t *drive)
617 ide_hwif_t *hwif = drive->hwif; 620 ide_hwif_t *hwif = drive->hwif;
618 struct hd_driveid *id; 621 struct hd_driveid *id;
619 unsigned long timeout, flags; 622 unsigned long timeout, flags;
623 u8 stat;
620 624
621 /* 625 /*
622 * Re-read drive->id for possible DMA mode 626 * Re-read drive->id for possible DMA mode
@@ -633,10 +637,15 @@ int ide_driveid_update(ide_drive_t *drive)
633 SELECT_MASK(drive, 0); 637 SELECT_MASK(drive, 0);
634 return 0; /* drive timed-out */ 638 return 0; /* drive timed-out */
635 } 639 }
640
636 msleep(50); /* give drive a breather */ 641 msleep(50); /* give drive a breather */
637 } while (hwif->INB(IDE_ALTSTATUS_REG) & BUSY_STAT); 642 stat = ide_read_altstatus(drive);
643 } while (stat & BUSY_STAT);
644
638 msleep(50); /* wait for IRQ and DRQ_STAT */ 645 msleep(50); /* wait for IRQ and DRQ_STAT */
639 if (!OK_STAT(hwif->INB(IDE_STATUS_REG),DRQ_STAT,BAD_R_STAT)) { 646 stat = ide_read_status(drive);
647
648 if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
640 SELECT_MASK(drive, 0); 649 SELECT_MASK(drive, 0);
641 printk("%s: CHECK for good STATUS\n", drive->name); 650 printk("%s: CHECK for good STATUS\n", drive->name);
642 return 0; 651 return 0;
@@ -649,7 +658,7 @@ int ide_driveid_update(ide_drive_t *drive)
649 return 0; 658 return 0;
650 } 659 }
651 ata_input_data(drive, id, SECTOR_WORDS); 660 ata_input_data(drive, id, SECTOR_WORDS);
652 (void) hwif->INB(IDE_STATUS_REG); /* clear drive IRQ */ 661 (void)ide_read_status(drive); /* clear drive IRQ */
653 local_irq_enable(); 662 local_irq_enable();
654 local_irq_restore(flags); 663 local_irq_restore(flags);
655 ide_fix_driveid(id); 664 ide_fix_driveid(id);
@@ -850,17 +859,16 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int);
850static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) 859static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
851{ 860{
852 ide_hwgroup_t *hwgroup = HWGROUP(drive); 861 ide_hwgroup_t *hwgroup = HWGROUP(drive);
853 ide_hwif_t *hwif = HWIF(drive);
854 u8 stat; 862 u8 stat;
855 863
856 SELECT_DRIVE(drive); 864 SELECT_DRIVE(drive);
857 udelay (10); 865 udelay (10);
866 stat = ide_read_status(drive);
858 867
859 if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) { 868 if (OK_STAT(stat, 0, BUSY_STAT))
860 printk("%s: ATAPI reset complete\n", drive->name); 869 printk("%s: ATAPI reset complete\n", drive->name);
861 } else { 870 else {
862 if (time_before(jiffies, hwgroup->poll_timeout)) { 871 if (time_before(jiffies, hwgroup->poll_timeout)) {
863 BUG_ON(HWGROUP(drive)->handler != NULL);
864 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); 872 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
865 /* continue polling */ 873 /* continue polling */
866 return ide_started; 874 return ide_started;
@@ -898,9 +906,10 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
898 } 906 }
899 } 907 }
900 908
901 if (!OK_STAT(tmp = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) { 909 tmp = ide_read_status(drive);
910
911 if (!OK_STAT(tmp, 0, BUSY_STAT)) {
902 if (time_before(jiffies, hwgroup->poll_timeout)) { 912 if (time_before(jiffies, hwgroup->poll_timeout)) {
903 BUG_ON(HWGROUP(drive)->handler != NULL);
904 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); 913 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
905 /* continue polling */ 914 /* continue polling */
906 return ide_started; 915 return ide_started;
@@ -909,7 +918,9 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
909 drive->failures++; 918 drive->failures++;
910 } else { 919 } else {
911 printk("%s: reset: ", hwif->name); 920 printk("%s: reset: ", hwif->name);
912 if ((tmp = hwif->INB(IDE_ERROR_REG)) == 1) { 921 tmp = ide_read_error(drive);
922
923 if (tmp == 1) {
913 printk("success\n"); 924 printk("success\n");
914 drive->failures = 0; 925 drive->failures = 0;
915 } else { 926 } else {