ide: add ide_read_[alt]status() inline helpers

Acked-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 29dd5975
...@@ -365,7 +365,7 @@ static void icside_dma_timeout(ide_drive_t *drive) ...@@ -365,7 +365,7 @@ static void icside_dma_timeout(ide_drive_t *drive)
if (icside_dma_test_irq(drive)) if (icside_dma_test_irq(drive))
return; return;
ide_dump_status(drive, "DMA timeout", HWIF(drive)->INB(IDE_STATUS_REG)); ide_dump_status(drive, "DMA timeout", ide_read_status(drive));
icside_dma_end(drive); icside_dma_end(drive);
} }
......
...@@ -295,7 +295,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) ...@@ -295,7 +295,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
int stat, err, sense_key; int stat, err, sense_key;
/* Check for errors. */ /* Check for errors. */
stat = HWIF(drive)->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (stat_ret) if (stat_ret)
*stat_ret = stat; *stat_ret = stat;
...@@ -692,7 +693,7 @@ int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw) ...@@ -692,7 +693,7 @@ int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw)
/* Some drives (ASUS) seem to tell us that status /* Some drives (ASUS) seem to tell us that status
* info is available. just get it and ignore. * info is available. just get it and ignore.
*/ */
(void) HWIF(drive)->INB(IDE_STATUS_REG); (void)ide_read_status(drive);
return 0; return 0;
} else { } else {
/* Drive wants a command packet, or invalid ireason... */ /* Drive wants a command packet, or invalid ireason... */
...@@ -1326,7 +1327,7 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) ...@@ -1326,7 +1327,7 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
if (blk_fs_request(rq)) { if (blk_fs_request(rq)) {
if (info->cd_flags & IDE_CD_FLAG_SEEKING) { if (info->cd_flags & IDE_CD_FLAG_SEEKING) {
unsigned long elapsed = jiffies - info->start_seek; unsigned long elapsed = jiffies - info->start_seek;
int stat = HWIF(drive)->INB(IDE_STATUS_REG); int stat = ide_read_status(drive);
if ((stat & SEEK_STAT) != SEEK_STAT) { if ((stat & SEEK_STAT) != SEEK_STAT) {
if (elapsed < IDECD_SEEK_TIMEOUT) { if (elapsed < IDECD_SEEK_TIMEOUT) {
......
...@@ -147,7 +147,8 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive) ...@@ -147,7 +147,8 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
u8 stat = 0, dma_stat = 0; u8 stat = 0, dma_stat = 0;
dma_stat = HWIF(drive)->ide_dma_end(drive); dma_stat = HWIF(drive)->ide_dma_end(drive);
stat = HWIF(drive)->INB(IDE_STATUS_REG); /* get drive status */ stat = ide_read_status(drive);
if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
if (!dma_stat) { if (!dma_stat) {
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
......
...@@ -501,7 +501,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -501,7 +501,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
} }
/* Clear the interrupt */ /* Clear the interrupt */
stat = drive->hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
/* No more interrupts */ /* No more interrupts */
if ((stat & DRQ_STAT) == 0) { if ((stat & DRQ_STAT) == 0) {
...@@ -1246,7 +1246,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) ...@@ -1246,7 +1246,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
u8 stat; u8 stat;
local_irq_save(flags); local_irq_save(flags);
stat = drive->hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
local_irq_restore(flags); local_irq_restore(flags);
progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000; progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000;
......
...@@ -466,7 +466,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 ...@@ -466,7 +466,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
return ide_stopped; return ide_stopped;
} }
if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
rq->errors |= ERROR_RESET; rq->errors |= ERROR_RESET;
if ((rq->errors & ERROR_RESET) == ERROR_RESET) { if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
...@@ -493,7 +493,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u ...@@ -493,7 +493,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
/* add decoding error stuff */ /* add decoding error stuff */
} }
if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
/* force an abort */ /* force an abort */
hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG); hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG);
...@@ -821,8 +821,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, ...@@ -821,8 +821,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
#ifdef DEBUG #ifdef DEBUG
printk("%s: DRIVE_CMD (null)\n", drive->name); printk("%s: DRIVE_CMD (null)\n", drive->name);
#endif #endif
ide_end_drive_cmd(drive, ide_end_drive_cmd(drive, ide_read_status(drive),
hwif->INB(IDE_STATUS_REG),
hwif->INB(IDE_ERROR_REG)); hwif->INB(IDE_ERROR_REG));
return ide_stopped; return ide_stopped;
} }
...@@ -1231,7 +1230,7 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) ...@@ -1231,7 +1230,7 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
(void)HWIF(drive)->ide_dma_end(drive); (void)HWIF(drive)->ide_dma_end(drive);
ret = ide_error(drive, "dma timeout error", ret = ide_error(drive, "dma timeout error",
hwif->INB(IDE_STATUS_REG)); ide_read_status(drive));
} else { } else {
printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
hwif->dma_timeout(drive); hwif->dma_timeout(drive);
...@@ -1355,7 +1354,8 @@ void ide_timer_expiry (unsigned long data) ...@@ -1355,7 +1354,8 @@ void ide_timer_expiry (unsigned long data)
startstop = ide_dma_timeout_retry(drive, wait); startstop = ide_dma_timeout_retry(drive, wait);
} else } else
startstop = startstop =
ide_error(drive, "irq timeout", hwif->INB(IDE_STATUS_REG)); ide_error(drive, "irq timeout",
ide_read_status(drive));
} }
drive->service_time = jiffies - drive->service_start; drive->service_time = jiffies - drive->service_start;
spin_lock_irq(&ide_lock); spin_lock_irq(&ide_lock);
......
...@@ -430,10 +430,10 @@ int drive_is_ready (ide_drive_t *drive) ...@@ -430,10 +430,10 @@ int drive_is_ready (ide_drive_t *drive)
* about possible isa-pnp and pci-pnp issues yet. * about possible isa-pnp and pci-pnp issues yet.
*/ */
if (IDE_CONTROL_REG) if (IDE_CONTROL_REG)
stat = hwif->INB(IDE_ALTSTATUS_REG); stat = ide_read_altstatus(drive);
else else
/* Note: this may clear a pending IRQ!! */ /* Note: this may clear a pending IRQ!! */
stat = hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (stat & BUSY_STAT) if (stat & BUSY_STAT)
/* drive busy: definitely not interrupting */ /* drive busy: definitely not interrupting */
...@@ -458,23 +458,24 @@ EXPORT_SYMBOL(drive_is_ready); ...@@ -458,23 +458,24 @@ EXPORT_SYMBOL(drive_is_ready);
*/ */
static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat)
{ {
ide_hwif_t *hwif = drive->hwif;
unsigned long flags; unsigned long flags;
int i; int i;
u8 stat; u8 stat;
udelay(1); /* spec allows drive 400ns to assert "BUSY" */ udelay(1); /* spec allows drive 400ns to assert "BUSY" */
if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) { stat = ide_read_status(drive);
if (stat & BUSY_STAT) {
local_irq_set(flags); local_irq_set(flags);
timeout += jiffies; timeout += jiffies;
while ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) { while ((stat = ide_read_status(drive)) & BUSY_STAT) {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
/* /*
* One last read after the timeout in case * One last read after the timeout in case
* heavy interrupt load made us not make any * heavy interrupt load made us not make any
* progress during the timeout.. * progress during the timeout..
*/ */
stat = hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (!(stat & BUSY_STAT)) if (!(stat & BUSY_STAT))
break; break;
...@@ -494,7 +495,9 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti ...@@ -494,7 +495,9 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
*/ */
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
udelay(1); udelay(1);
if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), good, bad)) { stat = ide_read_status(drive);
if (OK_STAT(stat, good, bad)) {
*rstat = stat; *rstat = stat;
return 0; return 0;
} }
...@@ -617,6 +620,7 @@ int ide_driveid_update(ide_drive_t *drive) ...@@ -617,6 +620,7 @@ int ide_driveid_update(ide_drive_t *drive)
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct hd_driveid *id; struct hd_driveid *id;
unsigned long timeout, flags; unsigned long timeout, flags;
u8 stat;
/* /*
* Re-read drive->id for possible DMA mode * Re-read drive->id for possible DMA mode
...@@ -633,10 +637,15 @@ int ide_driveid_update(ide_drive_t *drive) ...@@ -633,10 +637,15 @@ int ide_driveid_update(ide_drive_t *drive)
SELECT_MASK(drive, 0); SELECT_MASK(drive, 0);
return 0; /* drive timed-out */ return 0; /* drive timed-out */
} }
msleep(50); /* give drive a breather */ msleep(50); /* give drive a breather */
} while (hwif->INB(IDE_ALTSTATUS_REG) & BUSY_STAT); stat = ide_read_altstatus(drive);
} while (stat & BUSY_STAT);
msleep(50); /* wait for IRQ and DRQ_STAT */ msleep(50); /* wait for IRQ and DRQ_STAT */
if (!OK_STAT(hwif->INB(IDE_STATUS_REG),DRQ_STAT,BAD_R_STAT)) { stat = ide_read_status(drive);
if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
SELECT_MASK(drive, 0); SELECT_MASK(drive, 0);
printk("%s: CHECK for good STATUS\n", drive->name); printk("%s: CHECK for good STATUS\n", drive->name);
return 0; return 0;
...@@ -649,7 +658,7 @@ int ide_driveid_update(ide_drive_t *drive) ...@@ -649,7 +658,7 @@ int ide_driveid_update(ide_drive_t *drive)
return 0; return 0;
} }
ata_input_data(drive, id, SECTOR_WORDS); ata_input_data(drive, id, SECTOR_WORDS);
(void) hwif->INB(IDE_STATUS_REG); /* clear drive IRQ */ (void)ide_read_status(drive); /* clear drive IRQ */
local_irq_enable(); local_irq_enable();
local_irq_restore(flags); local_irq_restore(flags);
ide_fix_driveid(id); ide_fix_driveid(id);
...@@ -850,15 +859,15 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int); ...@@ -850,15 +859,15 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int);
static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
{ {
ide_hwgroup_t *hwgroup = HWGROUP(drive); ide_hwgroup_t *hwgroup = HWGROUP(drive);
ide_hwif_t *hwif = HWIF(drive);
u8 stat; u8 stat;
SELECT_DRIVE(drive); SELECT_DRIVE(drive);
udelay (10); udelay (10);
stat = ide_read_status(drive);
if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) { if (OK_STAT(stat, 0, BUSY_STAT))
printk("%s: ATAPI reset complete\n", drive->name); printk("%s: ATAPI reset complete\n", drive->name);
} else { else {
if (time_before(jiffies, hwgroup->poll_timeout)) { if (time_before(jiffies, hwgroup->poll_timeout)) {
ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
/* continue polling */ /* continue polling */
...@@ -897,7 +906,9 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) ...@@ -897,7 +906,9 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
} }
} }
if (!OK_STAT(tmp = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) { tmp = ide_read_status(drive);
if (!OK_STAT(tmp, 0, BUSY_STAT)) {
if (time_before(jiffies, hwgroup->poll_timeout)) { if (time_before(jiffies, hwgroup->poll_timeout)) {
ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
/* continue polling */ /* continue polling */
......
...@@ -264,8 +264,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) ...@@ -264,8 +264,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
{ {
ide_hwif_t *hwif = HWIF(drive); ide_hwif_t *hwif = HWIF(drive);
int rc; int use_altstatus = 0, rc;
unsigned long hd_status;
unsigned long timeout; unsigned long timeout;
u8 s = 0, a = 0; u8 s = 0, a = 0;
...@@ -273,19 +272,17 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) ...@@ -273,19 +272,17 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
msleep(50); msleep(50);
if (IDE_CONTROL_REG) { if (IDE_CONTROL_REG) {
a = hwif->INB(IDE_ALTSTATUS_REG); a = ide_read_altstatus(drive);
s = hwif->INB(IDE_STATUS_REG); s = ide_read_status(drive);
if ((a ^ s) & ~INDEX_STAT) { if ((a ^ s) & ~INDEX_STAT)
printk(KERN_INFO "%s: probing with STATUS(0x%02x) instead of "
"ALTSTATUS(0x%02x)\n", drive->name, s, a);
/* ancient Seagate drives, broken interfaces */ /* ancient Seagate drives, broken interfaces */
hd_status = IDE_STATUS_REG; printk(KERN_INFO "%s: probing with STATUS(0x%02x) "
} else { "instead of ALTSTATUS(0x%02x)\n",
drive->name, s, a);
else
/* use non-intrusive polling */ /* use non-intrusive polling */
hd_status = IDE_ALTSTATUS_REG; use_altstatus = 1;
} }
} else
hd_status = IDE_STATUS_REG;
/* set features register for atapi /* set features register for atapi
* identify command to be sure of reply * identify command to be sure of reply
...@@ -306,11 +303,15 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) ...@@ -306,11 +303,15 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
} }
/* give drive a breather */ /* give drive a breather */
msleep(50); msleep(50);
} while ((hwif->INB(hd_status)) & BUSY_STAT); s = use_altstatus ? ide_read_altstatus(drive)
: ide_read_status(drive);
} while (s & BUSY_STAT);
/* wait for IRQ and DRQ_STAT */ /* wait for IRQ and DRQ_STAT */
msleep(50); msleep(50);
if (OK_STAT((hwif->INB(IDE_STATUS_REG)), DRQ_STAT, BAD_R_STAT)) { s = ide_read_status(drive);
if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) {
unsigned long flags; unsigned long flags;
/* local CPU only; some systems need this */ /* local CPU only; some systems need this */
...@@ -320,7 +321,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) ...@@ -320,7 +321,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
/* drive responded with ID */ /* drive responded with ID */
rc = 0; rc = 0;
/* clear drive IRQ */ /* clear drive IRQ */
(void) hwif->INB(IDE_STATUS_REG); (void)ide_read_status(drive);
local_irq_restore(flags); local_irq_restore(flags);
} else { } else {
/* drive refused ID */ /* drive refused ID */
...@@ -367,7 +368,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) ...@@ -367,7 +368,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
ide_set_irq(drive, 0); ide_set_irq(drive, 0);
/* clear drive IRQ */ /* clear drive IRQ */
(void) hwif->INB(IDE_STATUS_REG); (void)ide_read_status(drive);
udelay(5); udelay(5);
irq = probe_irq_off(cookie); irq = probe_irq_off(cookie);
if (!hwif->irq) { if (!hwif->irq) {
...@@ -455,7 +456,9 @@ static int do_probe (ide_drive_t *drive, u8 cmd) ...@@ -455,7 +456,9 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
return 3; return 3;
} }
if (OK_STAT((hwif->INB(IDE_STATUS_REG)), READY_STAT, BUSY_STAT) || stat = ide_read_status(drive);
if (OK_STAT(stat, READY_STAT, BUSY_STAT) ||
drive->present || cmd == WIN_PIDENTIFY) { drive->present || cmd == WIN_PIDENTIFY) {
/* send cmd and wait */ /* send cmd and wait */
if ((rc = try_to_identify(drive, cmd))) { if ((rc = try_to_identify(drive, cmd))) {
...@@ -463,7 +466,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) ...@@ -463,7 +466,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
rc = try_to_identify(drive,cmd); rc = try_to_identify(drive,cmd);
} }
stat = hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (stat == (BUSY_STAT | READY_STAT)) if (stat == (BUSY_STAT | READY_STAT))
return 4; return 4;
...@@ -482,7 +485,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) ...@@ -482,7 +485,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
} }
/* ensure drive IRQ is clear */ /* ensure drive IRQ is clear */
stat = hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (rc == 1) if (rc == 1)
printk(KERN_ERR "%s: no response (status = 0x%02x)\n", printk(KERN_ERR "%s: no response (status = 0x%02x)\n",
...@@ -496,7 +499,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) ...@@ -496,7 +499,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
SELECT_DRIVE(&hwif->drives[0]); SELECT_DRIVE(&hwif->drives[0]);
msleep(50); msleep(50);
/* ensure drive irq is clear */ /* ensure drive irq is clear */
(void) hwif->INB(IDE_STATUS_REG); (void)ide_read_status(drive);
} }
return rc; return rc;
} }
...@@ -521,7 +524,7 @@ static void enable_nest (ide_drive_t *drive) ...@@ -521,7 +524,7 @@ static void enable_nest (ide_drive_t *drive)
msleep(50); msleep(50);
stat = hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (!OK_STAT(stat, 0, BAD_STAT)) if (!OK_STAT(stat, 0, BAD_STAT))
printk(KERN_CONT "failed (status = 0x%02x)\n", stat); printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
......
...@@ -1178,7 +1178,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) ...@@ -1178,7 +1178,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
#endif /* IDETAPE_DEBUG_LOG */ #endif /* IDETAPE_DEBUG_LOG */
/* Clear the interrupt */ /* Clear the interrupt */
stat = hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) {
if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) {
...@@ -1598,7 +1598,8 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive) ...@@ -1598,7 +1598,8 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive)
idetape_pc_t *pc = tape->pc; idetape_pc_t *pc = tape->pc;
u8 stat; u8 stat;
stat = drive->hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (stat & SEEK_STAT) { if (stat & SEEK_STAT) {
if (stat & ERR_STAT) { if (stat & ERR_STAT) {
/* Error detected */ /* Error detected */
...@@ -1758,7 +1759,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -1758,7 +1759,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
* If the tape is still busy, postpone our request and service * If the tape is still busy, postpone our request and service
* the other device meanwhile. * the other device meanwhile.
*/ */
stat = drive->hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2)) if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2))
set_bit(IDETAPE_IGNORE_DSC, &tape->flags); set_bit(IDETAPE_IGNORE_DSC, &tape->flags);
......
...@@ -189,12 +189,11 @@ EXPORT_SYMBOL_GPL(do_rw_taskfile); ...@@ -189,12 +189,11 @@ EXPORT_SYMBOL_GPL(do_rw_taskfile);
*/ */
static ide_startstop_t set_multmode_intr(ide_drive_t *drive) static ide_startstop_t set_multmode_intr(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = HWIF(drive); u8 stat = ide_read_status(drive);
u8 stat;
if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) { if (OK_STAT(stat, READY_STAT, BAD_STAT))
drive->mult_count = drive->mult_req; drive->mult_count = drive->mult_req;
} else { else {
drive->mult_req = drive->mult_count = 0; drive->mult_req = drive->mult_count = 0;
drive->special.b.recalibrate = 1; drive->special.b.recalibrate = 1;
(void) ide_dump_status(drive, "set_multmode", stat); (void) ide_dump_status(drive, "set_multmode", stat);
...@@ -207,11 +206,10 @@ static ide_startstop_t set_multmode_intr(ide_drive_t *drive) ...@@ -207,11 +206,10 @@ static ide_startstop_t set_multmode_intr(ide_drive_t *drive)
*/ */
static ide_startstop_t set_geometry_intr(ide_drive_t *drive) static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = HWIF(drive);
int retries = 5; int retries = 5;
u8 stat; u8 stat;
while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--) while (((stat = ide_read_status(drive)) & BUSY_STAT) && retries--)
udelay(10); udelay(10);
if (OK_STAT(stat, READY_STAT, BAD_STAT)) if (OK_STAT(stat, READY_STAT, BAD_STAT))
...@@ -230,10 +228,9 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive) ...@@ -230,10 +228,9 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
*/ */
static ide_startstop_t recal_intr(ide_drive_t *drive) static ide_startstop_t recal_intr(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = HWIF(drive); u8 stat = ide_read_status(drive);
u8 stat;
if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), READY_STAT, BAD_STAT)) if (!OK_STAT(stat, READY_STAT, BAD_STAT))
return ide_error(drive, "recal_intr", stat); return ide_error(drive, "recal_intr", stat);
return ide_stopped; return ide_stopped;
} }
...@@ -248,10 +245,12 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive) ...@@ -248,10 +245,12 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
u8 stat; u8 stat;
local_irq_enable_in_hardirq(); local_irq_enable_in_hardirq();
if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) { stat = ide_read_status(drive);
if (!OK_STAT(stat, READY_STAT, BAD_STAT))
return ide_error(drive, "task_no_data_intr", stat); return ide_error(drive, "task_no_data_intr", stat);
/* calls ide_end_drive_cmd */ /* calls ide_end_drive_cmd */
}
if (args) if (args)
ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG)); ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG));
...@@ -260,7 +259,6 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive) ...@@ -260,7 +259,6 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
static u8 wait_drive_not_busy(ide_drive_t *drive) static u8 wait_drive_not_busy(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = HWIF(drive);
int retries; int retries;
u8 stat; u8 stat;
...@@ -269,7 +267,9 @@ static u8 wait_drive_not_busy(ide_drive_t *drive) ...@@ -269,7 +267,9 @@ static u8 wait_drive_not_busy(ide_drive_t *drive)
* This can take up to 10 usec, but we will wait max 1 ms. * This can take up to 10 usec, but we will wait max 1 ms.
*/ */
for (retries = 0; retries < 100; retries++) { for (retries = 0; retries < 100; retries++) {
if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) stat = ide_read_status(drive);
if (stat & BUSY_STAT)
udelay(10); udelay(10);
else else
break; break;
...@@ -430,7 +430,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive) ...@@ -430,7 +430,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
u8 stat = hwif->INB(IDE_STATUS_REG); u8 stat = ide_read_status(drive);
/* new way for dealing with premature shared PCI interrupts */ /* new way for dealing with premature shared PCI interrupts */
if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
...@@ -465,7 +465,7 @@ static ide_startstop_t task_out_intr (ide_drive_t *drive) ...@@ -465,7 +465,7 @@ static ide_startstop_t task_out_intr (ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
u8 stat = hwif->INB(IDE_STATUS_REG); u8 stat = ide_read_status(drive);
if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
return task_error(drive, rq, __FUNCTION__, stat); return task_error(drive, rq, __FUNCTION__, stat);
......
...@@ -287,7 +287,7 @@ static int idescsi_end_request(ide_drive_t *, int, int); ...@@ -287,7 +287,7 @@ static int idescsi_end_request(ide_drive_t *, int, int);
static ide_startstop_t static ide_startstop_t
idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
{ {
if (HWIF(drive)->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
/* force an abort */ /* force an abort */
HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG); HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG);
...@@ -423,7 +423,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -423,7 +423,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
} }
/* Clear the interrupt */ /* Clear the interrupt */
stat = drive->hwif->INB(IDE_STATUS_REG); stat = ide_read_status(drive);
if ((stat & DRQ_STAT) == 0) { if ((stat & DRQ_STAT) == 0) {
/* No more interrupts */ /* No more interrupts */
......
...@@ -1309,4 +1309,18 @@ static inline void ide_set_irq(ide_drive_t *drive, int on) ...@@ -1309,4 +1309,18 @@ static inline void ide_set_irq(ide_drive_t *drive, int on)
drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG); drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG);
} }
static inline u8 ide_read_status(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
return hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]);
}
static inline u8 ide_read_altstatus(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
return hwif->INB(hwif->io_ports[IDE_CONTROL_OFFSET]);
}
#endif /* _IDE_H */ #endif /* _IDE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment