diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-05 20:57:51 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-05 20:57:51 -0500 |
commit | c47137a99c597330b69057158b26061a360c0e09 (patch) | |
tree | aacd4cb968b8d7bdebdcbcce19f110469a977243 /drivers/ide/ide-iops.c | |
parent | 29dd59755a849cc6475faa6a75f3b804e23a6fc2 (diff) |
ide: add ide_read_[alt]status() inline helpers
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-iops.c')
-rw-r--r-- | drivers/ide/ide-iops.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 7647ac4cdef8..716244c45211 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 | */ |
459 | static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) | 459 | static 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,15 +859,15 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int); | |||
850 | static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) | 859 | static 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 | ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); | 872 | ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); |
864 | /* continue polling */ | 873 | /* continue polling */ |
@@ -897,7 +906,9 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
897 | } | 906 | } |
898 | } | 907 | } |
899 | 908 | ||
900 | 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)) { | ||
901 | if (time_before(jiffies, hwgroup->poll_timeout)) { | 912 | if (time_before(jiffies, hwgroup->poll_timeout)) { |
902 | ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); | 913 | ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); |
903 | /* continue polling */ | 914 | /* continue polling */ |