aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-05 20:57:51 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-05 20:57:51 -0500
commitc47137a99c597330b69057158b26061a360c0e09 (patch)
treeaacd4cb968b8d7bdebdcbcce19f110469a977243
parent29dd59755a849cc6475faa6a75f3b804e23a6fc2 (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>
-rw-r--r--drivers/ide/arm/icside.c2
-rw-r--r--drivers/ide/ide-cd.c7
-rw-r--r--drivers/ide/ide-dma.c3
-rw-r--r--drivers/ide/ide-floppy.c4
-rw-r--r--drivers/ide/ide-io.c12
-rw-r--r--drivers/ide/ide-iops.c39
-rw-r--r--drivers/ide/ide-probe.c47
-rw-r--r--drivers/ide/ide-tape.c7
-rw-r--r--drivers/ide/ide-taskfile.c30
-rw-r--r--drivers/scsi/ide-scsi.c4
-rw-r--r--include/linux/ide.h14
11 files changed, 100 insertions, 69 deletions
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index fb00f3827ecd..e816b0ffcfe6 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -365,7 +365,7 @@ static void icside_dma_timeout(ide_drive_t *drive)
365 if (icside_dma_test_irq(drive)) 365 if (icside_dma_test_irq(drive))
366 return; 366 return;
367 367
368 ide_dump_status(drive, "DMA timeout", HWIF(drive)->INB(IDE_STATUS_REG)); 368 ide_dump_status(drive, "DMA timeout", ide_read_status(drive));
369 369
370 icside_dma_end(drive); 370 icside_dma_end(drive);
371} 371}
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index ee4d458e2bbf..892e42e80a32 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -295,7 +295,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
295 int stat, err, sense_key; 295 int stat, err, sense_key;
296 296
297 /* Check for errors. */ 297 /* Check for errors. */
298 stat = HWIF(drive)->INB(IDE_STATUS_REG); 298 stat = ide_read_status(drive);
299
299 if (stat_ret) 300 if (stat_ret)
300 *stat_ret = stat; 301 *stat_ret = stat;
301 302
@@ -692,7 +693,7 @@ int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw)
692 /* Some drives (ASUS) seem to tell us that status 693 /* Some drives (ASUS) seem to tell us that status
693 * info is available. just get it and ignore. 694 * info is available. just get it and ignore.
694 */ 695 */
695 (void) HWIF(drive)->INB(IDE_STATUS_REG); 696 (void)ide_read_status(drive);
696 return 0; 697 return 0;
697 } else { 698 } else {
698 /* Drive wants a command packet, or invalid ireason... */ 699 /* 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 if (blk_fs_request(rq)) { 1327 if (blk_fs_request(rq)) {
1327 if (info->cd_flags & IDE_CD_FLAG_SEEKING) { 1328 if (info->cd_flags & IDE_CD_FLAG_SEEKING) {
1328 unsigned long elapsed = jiffies - info->start_seek; 1329 unsigned long elapsed = jiffies - info->start_seek;
1329 int stat = HWIF(drive)->INB(IDE_STATUS_REG); 1330 int stat = ide_read_status(drive);
1330 1331
1331 if ((stat & SEEK_STAT) != SEEK_STAT) { 1332 if ((stat & SEEK_STAT) != SEEK_STAT) {
1332 if (elapsed < IDECD_SEEK_TIMEOUT) { 1333 if (elapsed < IDECD_SEEK_TIMEOUT) {
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 3cf59f2c3928..a4bb32883c6b 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -147,7 +147,8 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
147 u8 stat = 0, dma_stat = 0; 147 u8 stat = 0, dma_stat = 0;
148 148
149 dma_stat = HWIF(drive)->ide_dma_end(drive); 149 dma_stat = HWIF(drive)->ide_dma_end(drive);
150 stat = HWIF(drive)->INB(IDE_STATUS_REG); /* get drive status */ 150 stat = ide_read_status(drive);
151
151 if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { 152 if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
152 if (!dma_stat) { 153 if (!dma_stat) {
153 struct request *rq = HWGROUP(drive)->rq; 154 struct request *rq = HWGROUP(drive)->rq;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index f8fe6ee128f3..3ac79ed2bc63 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -501,7 +501,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
501 } 501 }
502 502
503 /* Clear the interrupt */ 503 /* Clear the interrupt */
504 stat = drive->hwif->INB(IDE_STATUS_REG); 504 stat = ide_read_status(drive);
505 505
506 /* No more interrupts */ 506 /* No more interrupts */
507 if ((stat & DRQ_STAT) == 0) { 507 if ((stat & DRQ_STAT) == 0) {
@@ -1246,7 +1246,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
1246 u8 stat; 1246 u8 stat;
1247 1247
1248 local_irq_save(flags); 1248 local_irq_save(flags);
1249 stat = drive->hwif->INB(IDE_STATUS_REG); 1249 stat = ide_read_status(drive);
1250 local_irq_restore(flags); 1250 local_irq_restore(flags);
1251 1251
1252 progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000; 1252 progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 4bddef0c0b96..29cb043a2d3a 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -466,7 +466,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
466 return ide_stopped; 466 return ide_stopped;
467 } 467 }
468 468
469 if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 469 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
470 rq->errors |= ERROR_RESET; 470 rq->errors |= ERROR_RESET;
471 471
472 if ((rq->errors & ERROR_RESET) == ERROR_RESET) { 472 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 /* add decoding error stuff */ 493 /* add decoding error stuff */
494 } 494 }
495 495
496 if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 496 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
497 /* force an abort */ 497 /* force an abort */
498 hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG); 498 hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG);
499 499
@@ -821,8 +821,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
821#ifdef DEBUG 821#ifdef DEBUG
822 printk("%s: DRIVE_CMD (null)\n", drive->name); 822 printk("%s: DRIVE_CMD (null)\n", drive->name);
823#endif 823#endif
824 ide_end_drive_cmd(drive, 824 ide_end_drive_cmd(drive, ide_read_status(drive),
825 hwif->INB(IDE_STATUS_REG),
826 hwif->INB(IDE_ERROR_REG)); 825 hwif->INB(IDE_ERROR_REG));
827 return ide_stopped; 826 return ide_stopped;
828} 827}
@@ -1231,7 +1230,7 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
1231 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); 1230 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
1232 (void)HWIF(drive)->ide_dma_end(drive); 1231 (void)HWIF(drive)->ide_dma_end(drive);
1233 ret = ide_error(drive, "dma timeout error", 1232 ret = ide_error(drive, "dma timeout error",
1234 hwif->INB(IDE_STATUS_REG)); 1233 ide_read_status(drive));
1235 } else { 1234 } else {
1236 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); 1235 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
1237 hwif->dma_timeout(drive); 1236 hwif->dma_timeout(drive);
@@ -1355,7 +1354,8 @@ void ide_timer_expiry (unsigned long data)
1355 startstop = ide_dma_timeout_retry(drive, wait); 1354 startstop = ide_dma_timeout_retry(drive, wait);
1356 } else 1355 } else
1357 startstop = 1356 startstop =
1358 ide_error(drive, "irq timeout", hwif->INB(IDE_STATUS_REG)); 1357 ide_error(drive, "irq timeout",
1358 ide_read_status(drive));
1359 } 1359 }
1360 drive->service_time = jiffies - drive->service_start; 1360 drive->service_time = jiffies - drive->service_start;
1361 spin_lock_irq(&ide_lock); 1361 spin_lock_irq(&ide_lock);
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 */
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,15 +859,15 @@ 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 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 */
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 9c07bdb68d1a..fd0ef8268950 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -264,8 +264,7 @@ err_misc:
264static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) 264static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
265{ 265{
266 ide_hwif_t *hwif = HWIF(drive); 266 ide_hwif_t *hwif = HWIF(drive);
267 int rc; 267 int use_altstatus = 0, rc;
268 unsigned long hd_status;
269 unsigned long timeout; 268 unsigned long timeout;
270 u8 s = 0, a = 0; 269 u8 s = 0, a = 0;
271 270
@@ -273,19 +272,17 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
273 msleep(50); 272 msleep(50);
274 273
275 if (IDE_CONTROL_REG) { 274 if (IDE_CONTROL_REG) {
276 a = hwif->INB(IDE_ALTSTATUS_REG); 275 a = ide_read_altstatus(drive);
277 s = hwif->INB(IDE_STATUS_REG); 276 s = ide_read_status(drive);
278 if ((a ^ s) & ~INDEX_STAT) { 277 if ((a ^ s) & ~INDEX_STAT)
279 printk(KERN_INFO "%s: probing with STATUS(0x%02x) instead of "
280 "ALTSTATUS(0x%02x)\n", drive->name, s, a);
281 /* ancient Seagate drives, broken interfaces */ 278 /* ancient Seagate drives, broken interfaces */
282 hd_status = IDE_STATUS_REG; 279 printk(KERN_INFO "%s: probing with STATUS(0x%02x) "
283 } else { 280 "instead of ALTSTATUS(0x%02x)\n",
281 drive->name, s, a);
282 else
284 /* use non-intrusive polling */ 283 /* use non-intrusive polling */
285 hd_status = IDE_ALTSTATUS_REG; 284 use_altstatus = 1;
286 } 285 }
287 } else
288 hd_status = IDE_STATUS_REG;
289 286
290 /* set features register for atapi 287 /* set features register for atapi
291 * identify command to be sure of reply 288 * identify command to be sure of reply
@@ -306,11 +303,15 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
306 } 303 }
307 /* give drive a breather */ 304 /* give drive a breather */
308 msleep(50); 305 msleep(50);
309 } while ((hwif->INB(hd_status)) & BUSY_STAT); 306 s = use_altstatus ? ide_read_altstatus(drive)
307 : ide_read_status(drive);
308 } while (s & BUSY_STAT);
310 309
311 /* wait for IRQ and DRQ_STAT */ 310 /* wait for IRQ and DRQ_STAT */
312 msleep(50); 311 msleep(50);
313 if (OK_STAT((hwif->INB(IDE_STATUS_REG)), DRQ_STAT, BAD_R_STAT)) { 312 s = ide_read_status(drive);
313
314 if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) {
314 unsigned long flags; 315 unsigned long flags;
315 316
316 /* local CPU only; some systems need this */ 317 /* local CPU only; some systems need this */
@@ -320,7 +321,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
320 /* drive responded with ID */ 321 /* drive responded with ID */
321 rc = 0; 322 rc = 0;
322 /* clear drive IRQ */ 323 /* clear drive IRQ */
323 (void) hwif->INB(IDE_STATUS_REG); 324 (void)ide_read_status(drive);
324 local_irq_restore(flags); 325 local_irq_restore(flags);
325 } else { 326 } else {
326 /* drive refused ID */ 327 /* drive refused ID */
@@ -367,7 +368,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
367 368
368 ide_set_irq(drive, 0); 369 ide_set_irq(drive, 0);
369 /* clear drive IRQ */ 370 /* clear drive IRQ */
370 (void) hwif->INB(IDE_STATUS_REG); 371 (void)ide_read_status(drive);
371 udelay(5); 372 udelay(5);
372 irq = probe_irq_off(cookie); 373 irq = probe_irq_off(cookie);
373 if (!hwif->irq) { 374 if (!hwif->irq) {
@@ -455,7 +456,9 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
455 return 3; 456 return 3;
456 } 457 }
457 458
458 if (OK_STAT((hwif->INB(IDE_STATUS_REG)), READY_STAT, BUSY_STAT) || 459 stat = ide_read_status(drive);
460
461 if (OK_STAT(stat, READY_STAT, BUSY_STAT) ||
459 drive->present || cmd == WIN_PIDENTIFY) { 462 drive->present || cmd == WIN_PIDENTIFY) {
460 /* send cmd and wait */ 463 /* send cmd and wait */
461 if ((rc = try_to_identify(drive, cmd))) { 464 if ((rc = try_to_identify(drive, cmd))) {
@@ -463,7 +466,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
463 rc = try_to_identify(drive,cmd); 466 rc = try_to_identify(drive,cmd);
464 } 467 }
465 468
466 stat = hwif->INB(IDE_STATUS_REG); 469 stat = ide_read_status(drive);
467 470
468 if (stat == (BUSY_STAT | READY_STAT)) 471 if (stat == (BUSY_STAT | READY_STAT))
469 return 4; 472 return 4;
@@ -482,7 +485,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
482 } 485 }
483 486
484 /* ensure drive IRQ is clear */ 487 /* ensure drive IRQ is clear */
485 stat = hwif->INB(IDE_STATUS_REG); 488 stat = ide_read_status(drive);
486 489
487 if (rc == 1) 490 if (rc == 1)
488 printk(KERN_ERR "%s: no response (status = 0x%02x)\n", 491 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 SELECT_DRIVE(&hwif->drives[0]); 499 SELECT_DRIVE(&hwif->drives[0]);
497 msleep(50); 500 msleep(50);
498 /* ensure drive irq is clear */ 501 /* ensure drive irq is clear */
499 (void) hwif->INB(IDE_STATUS_REG); 502 (void)ide_read_status(drive);
500 } 503 }
501 return rc; 504 return rc;
502} 505}
@@ -521,7 +524,7 @@ static void enable_nest (ide_drive_t *drive)
521 524
522 msleep(50); 525 msleep(50);
523 526
524 stat = hwif->INB(IDE_STATUS_REG); 527 stat = ide_read_status(drive);
525 528
526 if (!OK_STAT(stat, 0, BAD_STAT)) 529 if (!OK_STAT(stat, 0, BAD_STAT))
527 printk(KERN_CONT "failed (status = 0x%02x)\n", stat); 530 printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index bf40d8c824ad..66801c084dd8 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1178,7 +1178,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
1178#endif /* IDETAPE_DEBUG_LOG */ 1178#endif /* IDETAPE_DEBUG_LOG */
1179 1179
1180 /* Clear the interrupt */ 1180 /* Clear the interrupt */
1181 stat = hwif->INB(IDE_STATUS_REG); 1181 stat = ide_read_status(drive);
1182 1182
1183 if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { 1183 if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) {
1184 if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { 1184 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 idetape_pc_t *pc = tape->pc; 1598 idetape_pc_t *pc = tape->pc;
1599 u8 stat; 1599 u8 stat;
1600 1600
1601 stat = drive->hwif->INB(IDE_STATUS_REG); 1601 stat = ide_read_status(drive);
1602
1602 if (stat & SEEK_STAT) { 1603 if (stat & SEEK_STAT) {
1603 if (stat & ERR_STAT) { 1604 if (stat & ERR_STAT) {
1604 /* Error detected */ 1605 /* Error detected */
@@ -1758,7 +1759,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1758 * If the tape is still busy, postpone our request and service 1759 * If the tape is still busy, postpone our request and service
1759 * the other device meanwhile. 1760 * the other device meanwhile.
1760 */ 1761 */
1761 stat = drive->hwif->INB(IDE_STATUS_REG); 1762 stat = ide_read_status(drive);
1762 1763
1763 if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2)) 1764 if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2))
1764 set_bit(IDETAPE_IGNORE_DSC, &tape->flags); 1765 set_bit(IDETAPE_IGNORE_DSC, &tape->flags);
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 4e1da1c78cb5..2545dde6ee02 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -189,12 +189,11 @@ EXPORT_SYMBOL_GPL(do_rw_taskfile);
189 */ 189 */
190static ide_startstop_t set_multmode_intr(ide_drive_t *drive) 190static ide_startstop_t set_multmode_intr(ide_drive_t *drive)
191{ 191{
192 ide_hwif_t *hwif = HWIF(drive); 192 u8 stat = ide_read_status(drive);
193 u8 stat;
194 193
195 if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) { 194 if (OK_STAT(stat, READY_STAT, BAD_STAT))
196 drive->mult_count = drive->mult_req; 195 drive->mult_count = drive->mult_req;
197 } else { 196 else {
198 drive->mult_req = drive->mult_count = 0; 197 drive->mult_req = drive->mult_count = 0;
199 drive->special.b.recalibrate = 1; 198 drive->special.b.recalibrate = 1;
200 (void) ide_dump_status(drive, "set_multmode", stat); 199 (void) ide_dump_status(drive, "set_multmode", stat);
@@ -207,11 +206,10 @@ static ide_startstop_t set_multmode_intr(ide_drive_t *drive)
207 */ 206 */
208static ide_startstop_t set_geometry_intr(ide_drive_t *drive) 207static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
209{ 208{
210 ide_hwif_t *hwif = HWIF(drive);
211 int retries = 5; 209 int retries = 5;
212 u8 stat; 210 u8 stat;
213 211
214 while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--) 212 while (((stat = ide_read_status(drive)) & BUSY_STAT) && retries--)
215 udelay(10); 213 udelay(10);
216 214
217 if (OK_STAT(stat, READY_STAT, BAD_STAT)) 215 if (OK_STAT(stat, READY_STAT, BAD_STAT))
@@ -230,10 +228,9 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
230 */ 228 */
231static ide_startstop_t recal_intr(ide_drive_t *drive) 229static ide_startstop_t recal_intr(ide_drive_t *drive)
232{ 230{
233 ide_hwif_t *hwif = HWIF(drive); 231 u8 stat = ide_read_status(drive);
234 u8 stat;
235 232
236 if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), READY_STAT, BAD_STAT)) 233 if (!OK_STAT(stat, READY_STAT, BAD_STAT))
237 return ide_error(drive, "recal_intr", stat); 234 return ide_error(drive, "recal_intr", stat);
238 return ide_stopped; 235 return ide_stopped;
239} 236}
@@ -248,10 +245,12 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
248 u8 stat; 245 u8 stat;
249 246
250 local_irq_enable_in_hardirq(); 247 local_irq_enable_in_hardirq();
251 if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) { 248 stat = ide_read_status(drive);
249
250 if (!OK_STAT(stat, READY_STAT, BAD_STAT))
252 return ide_error(drive, "task_no_data_intr", stat); 251 return ide_error(drive, "task_no_data_intr", stat);
253 /* calls ide_end_drive_cmd */ 252 /* calls ide_end_drive_cmd */
254 } 253
255 if (args) 254 if (args)
256 ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG)); 255 ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG));
257 256
@@ -260,7 +259,6 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
260 259
261static u8 wait_drive_not_busy(ide_drive_t *drive) 260static u8 wait_drive_not_busy(ide_drive_t *drive)
262{ 261{
263 ide_hwif_t *hwif = HWIF(drive);
264 int retries; 262 int retries;
265 u8 stat; 263 u8 stat;
266 264
@@ -269,7 +267,9 @@ static u8 wait_drive_not_busy(ide_drive_t *drive)
269 * This can take up to 10 usec, but we will wait max 1 ms. 267 * This can take up to 10 usec, but we will wait max 1 ms.
270 */ 268 */
271 for (retries = 0; retries < 100; retries++) { 269 for (retries = 0; retries < 100; retries++) {
272 if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) 270 stat = ide_read_status(drive);
271
272 if (stat & BUSY_STAT)
273 udelay(10); 273 udelay(10);
274 else 274 else
275 break; 275 break;
@@ -430,7 +430,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive)
430{ 430{
431 ide_hwif_t *hwif = drive->hwif; 431 ide_hwif_t *hwif = drive->hwif;
432 struct request *rq = HWGROUP(drive)->rq; 432 struct request *rq = HWGROUP(drive)->rq;
433 u8 stat = hwif->INB(IDE_STATUS_REG); 433 u8 stat = ide_read_status(drive);
434 434
435 /* new way for dealing with premature shared PCI interrupts */ 435 /* new way for dealing with premature shared PCI interrupts */
436 if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { 436 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{ 465{
466 ide_hwif_t *hwif = drive->hwif; 466 ide_hwif_t *hwif = drive->hwif;
467 struct request *rq = HWGROUP(drive)->rq; 467 struct request *rq = HWGROUP(drive)->rq;
468 u8 stat = hwif->INB(IDE_STATUS_REG); 468 u8 stat = ide_read_status(drive);
469 469
470 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) 470 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
471 return task_error(drive, rq, __FUNCTION__, stat); 471 return task_error(drive, rq, __FUNCTION__, stat);
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 6c4f0f081785..68e5c632c5d5 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -287,7 +287,7 @@ static int idescsi_end_request(ide_drive_t *, int, int);
287static ide_startstop_t 287static ide_startstop_t
288idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) 288idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
289{ 289{
290 if (HWIF(drive)->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 290 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
291 /* force an abort */ 291 /* force an abort */
292 HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG); 292 HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG);
293 293
@@ -423,7 +423,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
423 } 423 }
424 424
425 /* Clear the interrupt */ 425 /* Clear the interrupt */
426 stat = drive->hwif->INB(IDE_STATUS_REG); 426 stat = ide_read_status(drive);
427 427
428 if ((stat & DRQ_STAT) == 0) { 428 if ((stat & DRQ_STAT) == 0) {
429 /* No more interrupts */ 429 /* No more interrupts */
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 2f66aaa1be2f..d2124920ff10 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1309,4 +1309,18 @@ static inline void ide_set_irq(ide_drive_t *drive, int on)
1309 drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG); 1309 drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG);
1310} 1310}
1311 1311
1312static inline u8 ide_read_status(ide_drive_t *drive)
1313{
1314 ide_hwif_t *hwif = drive->hwif;
1315
1316 return hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]);
1317}
1318
1319static inline u8 ide_read_altstatus(ide_drive_t *drive)
1320{
1321 ide_hwif_t *hwif = drive->hwif;
1322
1323 return hwif->INB(hwif->io_ports[IDE_CONTROL_OFFSET]);
1324}
1325
1312#endif /* _IDE_H */ 1326#endif /* _IDE_H */