]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/scsi/ide-scsi.c
ide: add ide_atapi_{discard_data,write_zeros} inline helpers
[mv-sheeva.git] / drivers / scsi / ide-scsi.c
index 02e91893064d89d6a80a25ef78daee53b1b9f0a8..3c3b3502c4d4137e108d1f415ce30d01f35b842c 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
  */
 
 /*
@@ -153,18 +152,6 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive)
  */
 #define IDESCSI_PC_RQ                  90
 
-static void idescsi_discard_data (ide_drive_t *drive, unsigned int bcount)
-{
-       while (bcount--)
-               (void) HWIF(drive)->INB(IDE_DATA_REG);
-}
-
-static void idescsi_output_zeros (ide_drive_t *drive, unsigned int bcount)
-{
-       while (bcount--)
-               HWIF(drive)->OUTB(0, IDE_DATA_REG);
-}
-
 /*
  *     PIO data transfer routines using the scatter gather table.
  */
@@ -201,7 +188,7 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
 
        if (bcount) {
                printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
-               idescsi_discard_data (drive, bcount);
+               ide_atapi_discard_data(drive, bcount);
        }
 }
 
@@ -238,7 +225,7 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
 
        if (bcount) {
                printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
-               idescsi_output_zeros (drive, bcount);
+               ide_atapi_write_zeros(drive, bcount);
        }
 }
 
@@ -288,7 +275,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);
 
@@ -424,7 +411,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
        }
 
        /* Clear the interrupt */
-       stat = drive->hwif->INB(IDE_STATUS_REG);
+       stat = ide_read_status(drive);
 
        if ((stat & DRQ_STAT) == 0) {
                /* No more interrupts */
@@ -464,7 +451,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                                }
                                pc->actually_transferred += temp;
                                pc->current_position += temp;
-                               idescsi_discard_data(drive, bcount - temp);
+                               ide_atapi_discard_data(drive, bcount - temp);
                                ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
                                return ide_started;
                        }
@@ -589,19 +576,14 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
                hwif->sg_mapped = 0;
        }
 
-       SELECT_DRIVE(drive);
-
        ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, 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 */
@@ -919,8 +901,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);
@@ -929,8 +911,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;