ide: drop 'timeout' and 'expiry' arguments from ide_pc_intr()
[safe/jmp/linux-2.6] / drivers / scsi / ide-scsi.c
index 26e8c3c..f71d1b3 100644 (file)
@@ -82,7 +82,6 @@ typedef struct ide_scsi_obj {
        struct gendisk          *disk;
        struct Scsi_Host        *host;
 
-       struct ide_atapi_pc *pc;                /* Current packet command */
        unsigned long transform;                /* SCSI cmd translation layer */
        unsigned long log;                      /* log flags */
 } idescsi_scsi_t;
@@ -130,50 +129,6 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive)
        return scsihost_to_idescsi(ide_drive->driver_data);
 }
 
-/*
- *     PIO data transfer routine using the scatter gather table.
- */
-static void ide_scsi_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
-                               unsigned int bcount, int write)
-{
-       ide_hwif_t *hwif = drive->hwif;
-       const struct ide_tp_ops *tp_ops = hwif->tp_ops;
-       xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data;
-       struct scatterlist *sg = pc->sg;
-       char *buf;
-       int count;
-
-       while (bcount) {
-               count = min(sg->length - pc->b_count, bcount);
-               if (PageHighMem(sg_page(sg))) {
-                       unsigned long flags;
-
-                       local_irq_save(flags);
-                       buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
-                       xf(drive, NULL, buf + pc->b_count, count);
-                       kunmap_atomic(buf - sg->offset, KM_IRQ0);
-                       local_irq_restore(flags);
-               } else {
-                       buf = sg_virt(sg);
-                       xf(drive, NULL, buf + pc->b_count, count);
-               }
-               bcount -= count; pc->b_count += count;
-               if (pc->b_count == sg->length) {
-                       if (!--pc->sg_cnt)
-                               break;
-                       pc->sg = sg = sg_next(sg);
-                       pc->b_count = 0;
-               }
-       }
-
-       if (bcount) {
-               printk(KERN_ERR "%s: scatter gather table too small, %s\n",
-                               drive->name, write ? "padding with zeros"
-                                                  : "discarding data");
-               ide_pad_transfer(drive, write, bcount);
-       }
-}
-
 static void ide_scsi_hex_dump(u8 *data, int len)
 {
        print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0);
@@ -181,10 +136,10 @@ static void ide_scsi_hex_dump(u8 *data, int len)
 
 static int idescsi_end_request(ide_drive_t *, int, int);
 
-static void ide_scsi_callback(ide_drive_t *drive)
+static void ide_scsi_callback(ide_drive_t *drive, int dsc)
 {
        idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-       struct ide_atapi_pc *pc = scsi->pc;
+       struct ide_atapi_pc *pc = drive->pc;
 
        if (pc->flags & PC_FLAG_TIMEDOUT)
                debug_log("%s: got timed out packet %lu at %lu\n", __func__,
@@ -311,47 +266,23 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
        spin_unlock_irqrestore(host->host_lock, flags);
        kfree(pc);
        blk_put_request(rq);
-       scsi->pc = NULL;
+       drive->pc = NULL;
        return 0;
 }
 
-static inline unsigned long get_timeout(struct ide_atapi_pc *pc)
-{
-       return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies);
-}
-
-static int idescsi_expiry(ide_drive_t *drive)
-{
-       idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-       struct ide_atapi_pc   *pc   = scsi->pc;
-
-       debug_log("%s called for %lu at %lu\n", __func__,
-                 pc->scsi_cmd->serial_number, jiffies);
-
-       pc->flags |= PC_FLAG_TIMEDOUT;
-
-       return 0;                                       /* we do not want the ide subsystem to retry */
-}
-
 /*
  *     Our interrupt handler.
  */
 static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
 {
-       idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-       struct ide_atapi_pc *pc = scsi->pc;
-
-       return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc),
-                          idescsi_expiry, NULL, NULL, NULL,
-                          ide_scsi_io_buffers);
+       return ide_pc_intr(drive, idescsi_pc_intr, NULL, NULL, ide_io_buffers);
 }
 
 static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
 {
-       idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-
-       return ide_transfer_pc(drive, scsi->pc, idescsi_pc_intr,
-                              get_timeout(scsi->pc), idescsi_expiry);
+       return ide_transfer_pc(drive, idescsi_pc_intr,
+                              ide_scsi_get_timeout(drive->pc),
+                              ide_scsi_expiry);
 }
 
 static inline int idescsi_set_direction(struct ide_atapi_pc *pc)
@@ -396,13 +327,11 @@ static int idescsi_map_sg(ide_drive_t *drive, struct ide_atapi_pc *pc)
 static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
                struct ide_atapi_pc *pc)
 {
-       idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-
        /* Set the current packet command */
-       scsi->pc = pc;
+       drive->pc = pc;
 
-       return ide_issue_pc(drive, pc, idescsi_transfer_pc,
-                           get_timeout(pc), idescsi_expiry);
+       return ide_issue_pc(drive, idescsi_transfer_pc,
+                           ide_scsi_get_timeout(pc), ide_scsi_expiry);
 }
 
 /*
@@ -444,25 +373,25 @@ static int set_##name(ide_drive_t *drive, int arg) \
        return 0; \
 }
 
-#define ide_scsi_devset_rw(_name, _min, _max, _field) \
+#define ide_scsi_devset_rw_field(_name, _field) \
 ide_scsi_devset_get(_name, _field); \
 ide_scsi_devset_set(_name, _field); \
-IDE_DEVSET(_name, S_RW, _min, _max, get_##_name, set_##_name)
-
-ide_devset_rw(bios_cyl,                0, 1023, bios_cyl);
-ide_devset_rw(bios_head,       0,  255, bios_head);
-ide_devset_rw(bios_sect,       0,   63, bios_sect);
-
-ide_scsi_devset_rw(transform,  0,    3, transform);
-ide_scsi_devset_rw(log,                0,    1, log);
-
-static const struct ide_devset *idescsi_settings[] = {
-       &ide_devset_bios_cyl,
-       &ide_devset_bios_head,
-       &ide_devset_bios_sect,
-       &ide_devset_log,
-       &ide_devset_transform,
-       NULL
+IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name);
+
+ide_devset_rw_field(bios_cyl, bios_cyl);
+ide_devset_rw_field(bios_head, bios_head);
+ide_devset_rw_field(bios_sect, bios_sect);
+
+ide_scsi_devset_rw_field(transform, transform);
+ide_scsi_devset_rw_field(log, log);
+
+static const struct ide_proc_devset idescsi_settings[] = {
+       IDE_PROC_DEVSET(bios_cyl,  0, 1023),
+       IDE_PROC_DEVSET(bios_head, 0,  255),
+       IDE_PROC_DEVSET(bios_sect, 0,   63),
+       IDE_PROC_DEVSET(log,       0,    1),
+       IDE_PROC_DEVSET(transform, 0,    3),
+       { 0 },
 };
 #endif
 
@@ -666,6 +595,8 @@ static int idescsi_eh_abort (struct scsi_cmnd *cmd)
        int             busy;
        int             ret   = FAILED;
 
+       struct ide_atapi_pc *pc;
+
        /* In idescsi_eh_abort we try to gently pry our command from the ide subsystem */
 
        if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
@@ -686,26 +617,27 @@ static int idescsi_eh_abort (struct scsi_cmnd *cmd)
        spin_lock_irq(&ide_lock);
 
        /* If there is no pc running we're done (our interrupt took care of it) */
-       if (!scsi->pc) {
+       pc = drive->pc;
+       if (pc == NULL) {
                ret = SUCCESS;
                goto ide_unlock;
        }
 
        /* It's somewhere in flight. Does ide subsystem agree? */
-       if (scsi->pc->scsi_cmd->serial_number == cmd->serial_number && !busy &&
-           elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != scsi->pc->rq) {
+       if (pc->scsi_cmd->serial_number == cmd->serial_number && !busy &&
+           elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != pc->rq) {
                /*
                 * FIXME - not sure this condition can ever occur
                 */
                printk (KERN_ERR "ide-scsi: cmd aborted!\n");
 
-               if (blk_sense_request(scsi->pc->rq))
-                       kfree(scsi->pc->buf);
+               if (blk_sense_request(pc->rq))
+                       kfree(pc->buf);
                /* we need to call blk_put_request twice. */
-               blk_put_request(scsi->pc->rq);
-               blk_put_request(scsi->pc->rq);
-               kfree(scsi->pc);
-               scsi->pc = NULL;
+               blk_put_request(pc->rq);
+               blk_put_request(pc->rq);
+               kfree(pc);
+               drive->pc = NULL;
 
                ret = SUCCESS;
        }
@@ -727,6 +659,8 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
        int             ready = 0;
        int             ret   = SUCCESS;
 
+       struct ide_atapi_pc *pc;
+
        /* In idescsi_eh_reset we forcefully remove the command from the ide subsystem and reset the device. */
 
        if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
@@ -741,7 +675,9 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
        spin_lock_irq(cmd->device->host->host_lock);
        spin_lock(&ide_lock);
 
-       if (!scsi->pc || (req = scsi->pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) {
+       pc = drive->pc;
+
+       if (pc == NULL || (req = pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) {
                printk (KERN_WARNING "ide-scsi: No active request in idescsi_eh_reset\n");
                spin_unlock(&ide_lock);
                spin_unlock_irq(cmd->device->host->host_lock);
@@ -752,9 +688,9 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
        if (__blk_end_request(req, -EIO, 0))
                BUG();
        if (blk_sense_request(req))
-               kfree(scsi->pc->buf);
-       kfree(scsi->pc);
-       scsi->pc = NULL;
+               kfree(pc->buf);
+       kfree(pc);
+       drive->pc = NULL;
        blk_put_request(req);
 
        /* now nuke the drive queue */