aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-iops.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:52 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:52 -0400
commitb73c7ee25da6133f97f47ffd3557288417da7c76 (patch)
tree0d348c81294d246b8417aff6e24502c93b312505 /drivers/ide/ide-iops.c
parentc6dfa867bb45f4bff2e48f3bc89ab1d6a7ab4c21 (diff)
ide: add ->read_status method
* Remove ide_read_status() inline helper. * Add ->read_status method for reading ATA Status register and use it instead of ->INB. While at it: * Don't use HWGROUP() macro. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-iops.c')
-rw-r--r--drivers/ide/ide-iops.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index d8db25581909..086eceaeeafd 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -111,6 +111,14 @@ static void ide_exec_command(ide_hwif_t *hwif, u8 cmd)
111 outb(cmd, hwif->io_ports.command_addr); 111 outb(cmd, hwif->io_ports.command_addr);
112} 112}
113 113
114static u8 ide_read_status(ide_hwif_t *hwif)
115{
116 if (hwif->host_flags & IDE_HFLAG_MMIO)
117 return readb((void __iomem *)hwif->io_ports.status_addr);
118 else
119 return inb(hwif->io_ports.status_addr);
120}
121
114static u8 ide_read_sff_dma_status(ide_hwif_t *hwif) 122static u8 ide_read_sff_dma_status(ide_hwif_t *hwif)
115{ 123{
116 if (hwif->host_flags & IDE_HFLAG_MMIO) 124 if (hwif->host_flags & IDE_HFLAG_MMIO)
@@ -340,6 +348,7 @@ static void ata_output_data(ide_drive_t *drive, struct request *rq,
340void default_hwif_transport(ide_hwif_t *hwif) 348void default_hwif_transport(ide_hwif_t *hwif)
341{ 349{
342 hwif->exec_command = ide_exec_command; 350 hwif->exec_command = ide_exec_command;
351 hwif->read_status = ide_read_status;
343 hwif->read_sff_dma_status = ide_read_sff_dma_status; 352 hwif->read_sff_dma_status = ide_read_sff_dma_status;
344 353
345 hwif->tf_load = ide_tf_load; 354 hwif->tf_load = ide_tf_load;
@@ -505,7 +514,7 @@ int drive_is_ready (ide_drive_t *drive)
505 stat = ide_read_altstatus(drive); 514 stat = ide_read_altstatus(drive);
506 else 515 else
507 /* Note: this may clear a pending IRQ!! */ 516 /* Note: this may clear a pending IRQ!! */
508 stat = ide_read_status(drive); 517 stat = hwif->read_status(hwif);
509 518
510 if (stat & BUSY_STAT) 519 if (stat & BUSY_STAT)
511 /* drive busy: definitely not interrupting */ 520 /* drive busy: definitely not interrupting */
@@ -530,24 +539,25 @@ EXPORT_SYMBOL(drive_is_ready);
530 */ 539 */
531static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) 540static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat)
532{ 541{
542 ide_hwif_t *hwif = drive->hwif;
533 unsigned long flags; 543 unsigned long flags;
534 int i; 544 int i;
535 u8 stat; 545 u8 stat;
536 546
537 udelay(1); /* spec allows drive 400ns to assert "BUSY" */ 547 udelay(1); /* spec allows drive 400ns to assert "BUSY" */
538 stat = ide_read_status(drive); 548 stat = hwif->read_status(hwif);
539 549
540 if (stat & BUSY_STAT) { 550 if (stat & BUSY_STAT) {
541 local_irq_set(flags); 551 local_irq_set(flags);
542 timeout += jiffies; 552 timeout += jiffies;
543 while ((stat = ide_read_status(drive)) & BUSY_STAT) { 553 while ((stat = hwif->read_status(hwif)) & BUSY_STAT) {
544 if (time_after(jiffies, timeout)) { 554 if (time_after(jiffies, timeout)) {
545 /* 555 /*
546 * One last read after the timeout in case 556 * One last read after the timeout in case
547 * heavy interrupt load made us not make any 557 * heavy interrupt load made us not make any
548 * progress during the timeout.. 558 * progress during the timeout..
549 */ 559 */
550 stat = ide_read_status(drive); 560 stat = hwif->read_status(hwif);
551 if (!(stat & BUSY_STAT)) 561 if (!(stat & BUSY_STAT))
552 break; 562 break;
553 563
@@ -567,7 +577,7 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
567 */ 577 */
568 for (i = 0; i < 10; i++) { 578 for (i = 0; i < 10; i++) {
569 udelay(1); 579 udelay(1);
570 stat = ide_read_status(drive); 580 stat = hwif->read_status(hwif);
571 581
572 if (OK_STAT(stat, good, bad)) { 582 if (OK_STAT(stat, good, bad)) {
573 *rstat = stat; 583 *rstat = stat;
@@ -718,7 +728,7 @@ int ide_driveid_update(ide_drive_t *drive)
718 } while (stat & BUSY_STAT); 728 } while (stat & BUSY_STAT);
719 729
720 msleep(50); /* wait for IRQ and DRQ_STAT */ 730 msleep(50); /* wait for IRQ and DRQ_STAT */
721 stat = ide_read_status(drive); 731 stat = hwif->read_status(hwif);
722 732
723 if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { 733 if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
724 SELECT_MASK(drive, 0); 734 SELECT_MASK(drive, 0);
@@ -733,7 +743,7 @@ int ide_driveid_update(ide_drive_t *drive)
733 return 0; 743 return 0;
734 } 744 }
735 hwif->input_data(drive, NULL, id, SECTOR_SIZE); 745 hwif->input_data(drive, NULL, id, SECTOR_SIZE);
736 (void)ide_read_status(drive); /* clear drive IRQ */ 746 (void)hwif->read_status(hwif); /* clear drive IRQ */
737 local_irq_enable(); 747 local_irq_enable();
738 local_irq_restore(flags); 748 local_irq_restore(flags);
739 ide_fix_driveid(id); 749 ide_fix_driveid(id);
@@ -943,12 +953,13 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int);
943 */ 953 */
944static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) 954static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
945{ 955{
946 ide_hwgroup_t *hwgroup = HWGROUP(drive); 956 ide_hwif_t *hwif = drive->hwif;
957 ide_hwgroup_t *hwgroup = hwif->hwgroup;
947 u8 stat; 958 u8 stat;
948 959
949 SELECT_DRIVE(drive); 960 SELECT_DRIVE(drive);
950 udelay (10); 961 udelay (10);
951 stat = ide_read_status(drive); 962 stat = hwif->read_status(hwif);
952 963
953 if (OK_STAT(stat, 0, BUSY_STAT)) 964 if (OK_STAT(stat, 0, BUSY_STAT))
954 printk("%s: ATAPI reset complete\n", drive->name); 965 printk("%s: ATAPI reset complete\n", drive->name);
@@ -994,7 +1005,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
994 } 1005 }
995 } 1006 }
996 1007
997 tmp = ide_read_status(drive); 1008 tmp = hwif->read_status(hwif);
998 1009
999 if (!OK_STAT(tmp, 0, BUSY_STAT)) { 1010 if (!OK_STAT(tmp, 0, BUSY_STAT)) {
1000 if (time_before(jiffies, hwgroup->poll_timeout)) { 1011 if (time_before(jiffies, hwgroup->poll_timeout)) {
@@ -1208,7 +1219,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
1208 * about locking issues (2.5 work ?). 1219 * about locking issues (2.5 work ?).
1209 */ 1220 */
1210 mdelay(1); 1221 mdelay(1);
1211 stat = hwif->INB(hwif->io_ports.status_addr); 1222 stat = hwif->read_status(hwif);
1212 if ((stat & BUSY_STAT) == 0) 1223 if ((stat & BUSY_STAT) == 0)
1213 return 0; 1224 return 0;
1214 /* 1225 /*