ide: remove IDE_TFLAG_NO_SELECT_MASK taskfile flag
[safe/jmp/linux-2.6] / drivers / scsi / ide-scsi.c
index 5ec421c..3222aa5 100644 (file)
 #define IDESCSI_DEBUG_LOG              0
 
 /*
- *     Packet command status bits.
- */
-#define PC_DMA_IN_PROGRESS             0       /* 1 while DMA in progress */
-#define PC_WRITING                     1       /* Data direction */
-#define PC_TIMEDOUT                    3       /* command timed out */
-#define PC_DMA_OK                      4       /* Use DMA */
-
-/*
  *     SCSI command transformation layer
  */
 #define IDESCSI_SG_TRANSFORM           1       /* /dev/sg transformation */
@@ -142,6 +134,7 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive)
 static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
                unsigned int bcount)
 {
+       ide_hwif_t *hwif = drive->hwif;
        int count;
        char *buf;
 
@@ -153,14 +146,12 @@ static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
                        local_irq_save(flags);
                        buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) +
                                        pc->sg->offset;
-                       drive->hwif->atapi_input_bytes(drive,
-                                               buf + pc->b_count, count);
+                       hwif->input_data(drive, NULL, buf + pc->b_count, count);
                        kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
                        local_irq_restore(flags);
                } else {
                        buf = sg_virt(pc->sg);
-                       drive->hwif->atapi_input_bytes(drive,
-                                               buf + pc->b_count, count);
+                       hwif->input_data(drive, NULL, buf + pc->b_count, count);
                }
                bcount -= count; pc->b_count += count;
                if (pc->b_count == pc->sg->length) {
@@ -173,13 +164,14 @@ static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
 
        if (bcount) {
                printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
-               ide_atapi_discard_data(drive, bcount);
+               ide_pad_transfer(drive, 0, bcount);
        }
 }
 
 static void idescsi_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
                unsigned int bcount)
 {
+       ide_hwif_t *hwif = drive->hwif;
        int count;
        char *buf;
 
@@ -191,14 +183,12 @@ static void idescsi_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
                        local_irq_save(flags);
                        buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) +
                                                pc->sg->offset;
-                       drive->hwif->atapi_output_bytes(drive,
-                                               buf + pc->b_count, count);
+                       hwif->output_data(drive, NULL, buf + pc->b_count, count);
                        kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
                        local_irq_restore(flags);
                } else {
                        buf = sg_virt(pc->sg);
-                       drive->hwif->atapi_output_bytes(drive,
-                                               buf + pc->b_count, count);
+                       hwif->output_data(drive, NULL, buf + pc->b_count, count);
                }
                bcount -= count; pc->b_count += count;
                if (pc->b_count == pc->sg->length) {
@@ -211,7 +201,7 @@ static void idescsi_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
 
        if (bcount) {
                printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
-               ide_atapi_write_zeros(drive, bcount);
+               ide_pad_transfer(drive, 1, bcount);
        }
 }
 
@@ -238,13 +228,14 @@ static int idescsi_check_condition(ide_drive_t *drive,
                kfree(pc);
                return -ENOMEM;
        }
-       ide_init_drive_cmd(rq);
+       blk_rq_init(NULL, rq);
        rq->special = (char *) pc;
        pc->rq = rq;
        pc->buf = buf;
        pc->c[0] = REQUEST_SENSE;
        pc->c[4] = pc->req_xfer = pc->buf_size = SCSI_SENSE_BUFFERSIZE;
        rq->cmd_type = REQ_TYPE_SENSE;
+       rq->cmd_flags |= REQ_PREEMPT;
        pc->timeout = jiffies + WAIT_READY;
        /* NOTE! Save the failed packet command in "rq->buffer" */
        rq->buffer = (void *) failed_cmd->special;
@@ -266,8 +257,8 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
 
        if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
                /* force an abort */
-               hwif->OUTB(WIN_IDLEIMMEDIATE,
-                          hwif->io_ports[IDE_COMMAND_OFFSET]);
+               hwif->OUTBSYNC(drive, WIN_IDLEIMMEDIATE,
+                              hwif->io_ports.command_addr);
 
        rq->errors++;
 
@@ -319,8 +310,10 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
                pc = opc;
                rq = pc->rq;
                pc->scsi_cmd->result = (CHECK_CONDITION << 1) |
-                                       ((test_bit(PC_TIMEDOUT, &pc->flags)?DID_TIME_OUT:DID_OK) << 16);
-       } else if (test_bit(PC_TIMEDOUT, &pc->flags)) {
+                               (((pc->flags & PC_FLAG_TIMEDOUT) ?
+                                 DID_TIME_OUT :
+                                 DID_OK) << 16);
+       } else if (pc->flags & PC_FLAG_TIMEDOUT) {
                if (log)
                        printk (KERN_WARNING "ide-scsi: %s: timed out for %lu\n",
                                        drive->name, pc->scsi_cmd->serial_number);
@@ -362,7 +355,7 @@ static int idescsi_expiry(ide_drive_t *drive)
 #if IDESCSI_DEBUG_LOG
        printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", pc->scsi_cmd->serial_number, jiffies);
 #endif
-       set_bit(PC_TIMEDOUT, &pc->flags);
+       pc->flags |= PC_FLAG_TIMEDOUT;
 
        return 0;                                       /* we do not want the ide subsystem to retry */
 }
@@ -384,7 +377,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
        printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n");
 #endif /* IDESCSI_DEBUG_LOG */
 
-       if (test_bit(PC_TIMEDOUT, &pc->flags)){
+       if (pc->flags & PC_FLAG_TIMEDOUT) {
 #if IDESCSI_DEBUG_LOG
                printk(KERN_WARNING "idescsi_pc_intr: got timed out packet  %lu at %lu\n",
                                pc->scsi_cmd->serial_number, jiffies);
@@ -393,12 +386,13 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                idescsi_end_request (drive, 1, 0);
                return ide_stopped;
        }
-       if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
+       if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
+               pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
 #if IDESCSI_DEBUG_LOG
                printk ("ide-scsi: %s: DMA complete\n", drive->name);
 #endif /* IDESCSI_DEBUG_LOG */
                pc->xferred = pc->req_xfer;
-               (void) HWIF(drive)->ide_dma_end(drive);
+               (void)hwif->dma_ops->dma_end(drive);
        }
 
        /* Clear the interrupt */
@@ -415,9 +409,9 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                idescsi_end_request (drive, 1, 0);
                return ide_stopped;
        }
-       bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) |
-                 hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
-       ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
+       bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
+                 hwif->INB(hwif->io_ports.lbam_addr);
+       ireason = hwif->INB(hwif->io_ports.nsect_addr);
 
        if (ireason & CD) {
                printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n");
@@ -432,19 +426,20 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                                        "- discarding data\n");
                                temp = pc->buf_size - pc->xferred;
                                if (temp) {
-                                       clear_bit(PC_WRITING, &pc->flags);
+                                       pc->flags &= ~PC_FLAG_WRITING;
                                        if (pc->sg)
                                                idescsi_input_buffers(drive, pc,
                                                                        temp);
                                        else
-                                               drive->hwif->atapi_input_bytes(drive, pc->cur_pos, temp);
+                                               hwif->input_data(drive, NULL,
+                                                       pc->cur_pos, temp);
                                        printk(KERN_ERR "ide-scsi: transferred"
                                                        " %d of %d bytes\n",
                                                        temp, bcount);
                                }
                                pc->xferred += temp;
                                pc->cur_pos += temp;
-                               ide_atapi_discard_data(drive, bcount - temp);
+                               ide_pad_transfer(drive, 0, bcount - temp);
                                ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
                                return ide_started;
                        }
@@ -454,19 +449,17 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                }
        }
        if (ireason & IO) {
-               clear_bit(PC_WRITING, &pc->flags);
+               pc->flags &= ~PC_FLAG_WRITING;
                if (pc->sg)
                        idescsi_input_buffers(drive, pc, bcount);
                else
-                       hwif->atapi_input_bytes(drive, pc->cur_pos,
-                                               bcount);
+                       hwif->input_data(drive, NULL, pc->cur_pos, bcount);
        } else {
-               set_bit(PC_WRITING, &pc->flags);
+               pc->flags |= PC_FLAG_WRITING;
                if (pc->sg)
                        idescsi_output_buffers(drive, pc, bcount);
                else
-                       hwif->atapi_output_bytes(drive, pc->cur_pos,
-                                                bcount);
+                       hwif->output_data(drive, NULL, pc->cur_pos, bcount);
        }
        /* Update the current position */
        pc->xferred += bcount;
@@ -490,7 +483,7 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
                        "initiated yet DRQ isn't asserted\n");
                return startstop;
        }
-       ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
+       ireason = hwif->INB(hwif->io_ports.nsect_addr);
        if ((ireason & CD) == 0 || (ireason & IO)) {
                printk(KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while "
                                "issuing a packet command\n");
@@ -499,11 +492,13 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
        BUG_ON(HWGROUP(drive)->handler != NULL);
        /* Set the interrupt routine */
        ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
+
        /* Send the actual packet */
-       drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12);
-       if (test_bit (PC_DMA_OK, &pc->flags)) {
-               set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
-               hwif->dma_start(drive);
+       hwif->output_data(drive, NULL, scsi->pc->c, 12);
+
+       if (pc->flags & PC_FLAG_DMA_OK) {
+               pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
+               hwif->dma_ops->dma_start(drive);
        }
        return ide_started;
 }
@@ -512,10 +507,10 @@ static inline int idescsi_set_direction(struct ide_atapi_pc *pc)
 {
        switch (pc->c[0]) {
                case READ_6: case READ_10: case READ_12:
-                       clear_bit(PC_WRITING, &pc->flags);
+                       pc->flags &= ~PC_FLAG_WRITING;
                        return 0;
                case WRITE_6: case WRITE_10: case WRITE_12:
-                       set_bit(PC_WRITING, &pc->flags);
+                       pc->flags |= PC_FLAG_WRITING;
                        return 0;
                default:
                        return 1;
@@ -565,14 +560,14 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
 
        if (drive->using_dma && !idescsi_map_sg(drive, pc)) {
                hwif->sg_mapped = 1;
-               dma = !hwif->dma_setup(drive);
+               dma = !hwif->dma_ops->dma_setup(drive);
                hwif->sg_mapped = 0;
        }
 
-       ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma);
+       ide_pktcmd_tf_load(drive, 0, bcount, dma);
 
        if (dma)
-               set_bit(PC_DMA_OK, &pc->flags);
+               pc->flags |= PC_FLAG_DMA_OK;
 
        if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) {
                ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc,
@@ -580,7 +575,7 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
                return ide_started;
        } else {
                /* Issue the packet command */
-               hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]);
+               ide_execute_pkt_cmd(drive);
                return idescsi_transfer_pc(drive);
        }
 }
@@ -791,7 +786,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
                }
        }
 
-       ide_init_drive_cmd (rq);
+       blk_rq_init(NULL, rq);
        rq->special = (char *) pc;
        rq->cmd_type = REQ_TYPE_SPECIAL;
        spin_unlock_irq(host->host_lock);