ide-scsi: use pc->callback

* Add ide_scsi_callback() pc->callback implementation, then update
  idescsi_check_condition() and idescsi_queue() to setup ->callback.

* Convert idescsi_pc_intr() to use pc->callback.

This is a preparation for adding generic ide_pc_intr() helper.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 4c93067e
...@@ -183,6 +183,24 @@ static void ide_scsi_hex_dump(u8 *data, int len) ...@@ -183,6 +183,24 @@ static void ide_scsi_hex_dump(u8 *data, int len)
print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0);
} }
static int idescsi_end_request(ide_drive_t *, int, int);
static void ide_scsi_callback(ide_drive_t *drive)
{
idescsi_scsi_t *scsi = drive_to_idescsi(drive);
struct ide_atapi_pc *pc = scsi->pc;
if (pc->flags & PC_FLAG_TIMEDOUT)
debug_log("%s: got timed out packet %lu at %lu\n", __func__,
pc->scsi_cmd->serial_number, jiffies);
/* end this request now - scsi should retry it*/
else if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
printk(KERN_INFO "Packet command completed, %d bytes"
" transferred\n", pc->xferred);
idescsi_end_request(drive, 1, 0);
}
static int idescsi_check_condition(ide_drive_t *drive, static int idescsi_check_condition(ide_drive_t *drive,
struct request *failed_cmd) struct request *failed_cmd)
{ {
...@@ -210,6 +228,7 @@ static int idescsi_check_condition(ide_drive_t *drive, ...@@ -210,6 +228,7 @@ static int idescsi_check_condition(ide_drive_t *drive,
rq->cmd_type = REQ_TYPE_SENSE; rq->cmd_type = REQ_TYPE_SENSE;
rq->cmd_flags |= REQ_PREEMPT; rq->cmd_flags |= REQ_PREEMPT;
pc->timeout = jiffies + WAIT_READY; pc->timeout = jiffies + WAIT_READY;
pc->callback = ide_scsi_callback;
/* NOTE! Save the failed packet command in "rq->buffer" */ /* NOTE! Save the failed packet command in "rq->buffer" */
rq->buffer = (void *) failed_cmd->special; rq->buffer = (void *) failed_cmd->special;
pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd; pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd;
...@@ -222,8 +241,6 @@ static int idescsi_check_condition(ide_drive_t *drive, ...@@ -222,8 +241,6 @@ static int idescsi_check_condition(ide_drive_t *drive,
return 0; return 0;
} }
static int idescsi_end_request(ide_drive_t *, int, int);
static ide_startstop_t static ide_startstop_t
idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
{ {
...@@ -350,10 +367,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -350,10 +367,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
debug_log("Reached %s interrupt handler\n", __func__); debug_log("Reached %s interrupt handler\n", __func__);
if (pc->flags & PC_FLAG_TIMEDOUT) { if (pc->flags & PC_FLAG_TIMEDOUT) {
debug_log("%s: got timed out packet %lu at %lu\n", __func__, pc->callback(drive);
pc->scsi_cmd->serial_number, jiffies);
/* end this request now - scsi should retry it*/
idescsi_end_request (drive, 1, 0);
return ide_stopped; return ide_stopped;
} }
if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
...@@ -369,14 +383,11 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -369,14 +383,11 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
if ((stat & DRQ_STAT) == 0) { if ((stat & DRQ_STAT) == 0) {
/* No more interrupts */ /* No more interrupts */
if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
printk(KERN_INFO "Packet command completed, %d bytes"
" transferred\n", pc->xferred);
pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
local_irq_enable_in_hardirq(); local_irq_enable_in_hardirq();
if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR))
rq->errors++; rq->errors++;
idescsi_end_request (drive, 1, 0); pc->callback(drive);
return ide_stopped; return ide_stopped;
} }
if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
...@@ -718,6 +729,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd, ...@@ -718,6 +729,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
pc->scsi_cmd = cmd; pc->scsi_cmd = cmd;
pc->done = done; pc->done = done;
pc->timeout = jiffies + cmd->timeout_per_command; pc->timeout = jiffies + cmd->timeout_per_command;
pc->callback = ide_scsi_callback;
if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) {
printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment