]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/ide-scsi.c
Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-2.6-omap-h63xx.git] / drivers / scsi / ide-scsi.c
index 9706de9d98d51969044a68f8cf0663fac4dde80e..68e5c632c5d55ca7b909643c3cf2f2a1adff3889 100644 (file)
@@ -1,7 +1,6 @@
 /*
- * linux/drivers/scsi/ide-scsi.c       Version 0.9             Jul   4, 1999
- *
- * Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il>
+ * Copyright (C) 1996-1999  Gadi Oxman <gadio@netvision.net.il>
+ * Copyright (C) 2004-2005  Bartlomiej Zolnierkiewicz
  */
 
 /*
@@ -288,7 +287,7 @@ static int idescsi_end_request(ide_drive_t *, int, int);
 static ide_startstop_t
 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 */
                HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG);
 
@@ -395,14 +394,12 @@ static int idescsi_expiry(ide_drive_t *drive)
 static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
 {
        idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-       idescsi_pc_t *pc=scsi->pc;
+       ide_hwif_t *hwif = drive->hwif;
+       idescsi_pc_t *pc = scsi->pc;
        struct request *rq = pc->rq;
-       atapi_bcount_t bcount;
-       atapi_status_t status;
-       atapi_ireason_t ireason;
-       atapi_feature_t feature;
-
        unsigned int temp;
+       u16 bcount;
+       u8 stat, ireason;
 
 #if IDESCSI_DEBUG_LOG
        printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n");
@@ -425,30 +422,29 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                (void) HWIF(drive)->ide_dma_end(drive);
        }
 
-       feature.all = 0;
        /* Clear the interrupt */
-       status.all = HWIF(drive)->INB(IDE_STATUS_REG);
+       stat = ide_read_status(drive);
 
-       if (!status.b.drq) {
+       if ((stat & DRQ_STAT) == 0) {
                /* No more interrupts */
                if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
                        printk (KERN_INFO "Packet command completed, %d bytes transferred\n", pc->actually_transferred);
                local_irq_enable_in_hardirq();
-               if (status.b.check)
+               if (stat & ERR_STAT)
                        rq->errors++;
                idescsi_end_request (drive, 1, 0);
                return ide_stopped;
        }
-       bcount.b.low    = HWIF(drive)->INB(IDE_BCOUNTL_REG);
-       bcount.b.high   = HWIF(drive)->INB(IDE_BCOUNTH_REG);
-       ireason.all     = HWIF(drive)->INB(IDE_IREASON_REG);
+       bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) |
+                 hwif->INB(IDE_BCOUNTL_REG);
+       ireason = hwif->INB(IDE_IREASON_REG);
 
-       if (ireason.b.cod) {
+       if (ireason & CD) {
                printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n");
                return ide_do_reset (drive);
        }
-       if (ireason.b.io) {
-               temp = pc->actually_transferred + bcount.all;
+       if (ireason & IO) {
+               temp = pc->actually_transferred + bcount;
                if (temp > pc->request_transfer) {
                        if (temp > pc->buffer_size) {
                                printk(KERN_ERR "ide-scsi: The scsi wants to "
@@ -461,11 +457,13 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                                                idescsi_input_buffers(drive, pc, temp);
                                        else
                                                drive->hwif->atapi_input_bytes(drive, pc->current_position, temp);
-                                       printk(KERN_ERR "ide-scsi: transferred %d of %d bytes\n", temp, bcount.all);
+                                       printk(KERN_ERR "ide-scsi: transferred"
+                                                       " %d of %d bytes\n",
+                                                       temp, bcount);
                                }
                                pc->actually_transferred += temp;
                                pc->current_position += temp;
-                               idescsi_discard_data(drive, bcount.all - temp);
+                               idescsi_discard_data(drive, bcount - temp);
                                ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
                                return ide_started;
                        }
@@ -474,22 +472,24 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
 #endif /* IDESCSI_DEBUG_LOG */
                }
        }
-       if (ireason.b.io) {
+       if (ireason & IO) {
                clear_bit(PC_WRITING, &pc->flags);
                if (pc->sg)
-                       idescsi_input_buffers(drive, pc, bcount.all);
+                       idescsi_input_buffers(drive, pc, bcount);
                else
-                       HWIF(drive)->atapi_input_bytes(drive, pc->current_position, bcount.all);
+                       hwif->atapi_input_bytes(drive, pc->current_position,
+                                               bcount);
        } else {
                set_bit(PC_WRITING, &pc->flags);
                if (pc->sg)
-                       idescsi_output_buffers (drive, pc, bcount.all);
+                       idescsi_output_buffers(drive, pc, bcount);
                else
-                       HWIF(drive)->atapi_output_bytes(drive, pc->current_position, bcount.all);
+                       hwif->atapi_output_bytes(drive, pc->current_position,
+                                                bcount);
        }
        /* Update the current position */
-       pc->actually_transferred += bcount.all;
-       pc->current_position += bcount.all;
+       pc->actually_transferred += bcount;
+       pc->current_position += bcount;
 
        /* And set the interrupt handler again */
        ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
@@ -501,16 +501,16 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
        ide_hwif_t *hwif = drive->hwif;
        idescsi_scsi_t *scsi = drive_to_idescsi(drive);
        idescsi_pc_t *pc = scsi->pc;
-       atapi_ireason_t ireason;
        ide_startstop_t startstop;
+       u8 ireason;
 
        if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) {
                printk(KERN_ERR "ide-scsi: Strange, packet command "
                        "initiated yet DRQ isn't asserted\n");
                return startstop;
        }
-       ireason.all     = HWIF(drive)->INB(IDE_IREASON_REG);
-       if (!ireason.b.cod || ireason.b.io) {
+       ireason = hwif->INB(IDE_IREASON_REG);
+       if ((ireason & CD) == 0 || (ireason & IO)) {
                printk(KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while "
                                "issuing a packet command\n");
                return ide_do_reset (drive);
@@ -573,38 +573,29 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
 {
        idescsi_scsi_t *scsi = drive_to_idescsi(drive);
        ide_hwif_t *hwif = drive->hwif;
-       atapi_feature_t feature;
-       atapi_bcount_t bcount;
+       u16 bcount;
+       u8 dma = 0;
 
        scsi->pc=pc;                                                    /* Set the current packet command */
        pc->actually_transferred=0;                                     /* We haven't transferred any data yet */
        pc->current_position=pc->buffer;
-       bcount.all = min(pc->request_transfer, 63 * 1024);              /* Request to transfer the entire buffer at once */
+       /* Request to transfer the entire buffer at once */
+       bcount = min(pc->request_transfer, 63 * 1024);
 
-       feature.all = 0;
        if (drive->using_dma && !idescsi_map_sg(drive, pc)) {
                hwif->sg_mapped = 1;
-               feature.b.dma = !hwif->dma_setup(drive);
+               dma = !hwif->dma_setup(drive);
                hwif->sg_mapped = 0;
        }
 
-       SELECT_DRIVE(drive);
-       if (IDE_CONTROL_REG)
-               HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG);
+       ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma);
 
-       HWIF(drive)->OUTB(feature.all, IDE_FEATURE_REG);
-       HWIF(drive)->OUTB(bcount.b.high, IDE_BCOUNTH_REG);
-       HWIF(drive)->OUTB(bcount.b.low, IDE_BCOUNTL_REG);
-
-       if (feature.b.dma)
+       if (dma)
                set_bit(PC_DMA_OK, &pc->flags);
 
        if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) {
-               BUG_ON(HWGROUP(drive)->handler != NULL);
-               ide_set_handler(drive, &idescsi_transfer_pc,
-                               get_timeout(pc), idescsi_expiry);
-               /* Issue the packet command */
-               HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG);
+               ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc,
+                                   get_timeout(pc), idescsi_expiry);
                return ide_started;
        } else {
                /* Issue the packet command */
@@ -922,8 +913,8 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
        }
 
        /* kill current request */
-       blkdev_dequeue_request(req);
-       end_that_request_last(req, 0);
+       if (__blk_end_request(req, -EIO, 0))
+               BUG();
        if (blk_sense_request(req))
                kfree(scsi->pc->buffer);
        kfree(scsi->pc);
@@ -932,8 +923,8 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
 
        /* now nuke the drive queue */
        while ((req = elv_next_request(drive->queue))) {
-               blkdev_dequeue_request(req);
-               end_that_request_last(req, 0);
+               if (__blk_end_request(req, -EIO, 0))
+                       BUG();
        }
 
        HWGROUP(drive)->rq = NULL;