Commit 2338545a authored by Boaz Harrosh's avatar Boaz Harrosh Committed by James Bottomley

[SCSI] aha152x: use data accessors and !use_sg cleanup

And finally this is the regular !use_sg cleanup
and use of data accessors.
Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 45333ffa
...@@ -322,6 +322,12 @@ static LIST_HEAD(aha152x_host_list); ...@@ -322,6 +322,12 @@ static LIST_HEAD(aha152x_host_list);
(cmd) ? ((cmd)->device->id & 0x0f) : -1, \ (cmd) ? ((cmd)->device->id & 0x0f) : -1, \
(cmd) ? ((cmd)->device->lun & 0x07) : -1 (cmd) ? ((cmd)->device->lun & 0x07) : -1
static inline void
CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
{
scsi_set_resid(cmd, scsi_get_resid(cmd) + inc);
}
#define DELAY_DEFAULT 1000 #define DELAY_DEFAULT 1000
#if defined(PCMCIA) #if defined(PCMCIA)
...@@ -975,13 +981,13 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, ...@@ -975,13 +981,13 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
#if defined(AHA152X_DEBUG) #if defined(AHA152X_DEBUG)
if (HOSTDATA(shpnt)->debug & debug_queue) { if (HOSTDATA(shpnt)->debug & debug_queue) {
printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=", printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=",
CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len, SCpnt->use_sg, SCpnt->request_bufflen); CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len,
scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
__scsi_print_command(SCpnt->cmnd); __scsi_print_command(SCpnt->cmnd);
} }
#endif #endif
SCpnt->scsi_done = done; SCpnt->scsi_done = done;
SCpnt->resid = SCpnt->request_bufflen;
SCpnt->SCp.phase = not_issued | phase; SCpnt->SCp.phase = not_issued | phase;
SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */ SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */
SCpnt->SCp.Message = 0; SCpnt->SCp.Message = 0;
...@@ -1011,30 +1017,24 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, ...@@ -1011,30 +1017,24 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
SCp.buffers_residual : left buffers in list SCp.buffers_residual : left buffers in list
SCp.phase : current state of the command */ SCp.phase : current state of the command */
if (phase & (check_condition|resetting)) { if ((phase & (check_condition|resetting)) || !scsi_sglist(SCpnt)) {
if (phase & check_condition) { if (phase & check_condition) {
SCpnt->SCp.ptr = SCpnt->sense_buffer; SCpnt->SCp.ptr = SCpnt->sense_buffer;
SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer); SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer);
SCpnt->resid = sizeof(SCpnt->sense_buffer); scsi_set_resid(SCpnt, sizeof(SCpnt->sense_buffer));
} else { } else {
SCpnt->SCp.ptr = NULL; SCpnt->SCp.ptr = NULL;
SCpnt->SCp.this_residual = 0; SCpnt->SCp.this_residual = 0;
SCpnt->resid = 0; scsi_set_resid(SCpnt, 0);
} }
SCpnt->SCp.buffer = NULL; SCpnt->SCp.buffer = NULL;
SCpnt->SCp.buffers_residual = 0; SCpnt->SCp.buffers_residual = 0;
} else { } else {
if (SCpnt->use_sg) { scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer; SCpnt->SCp.buffer = scsi_sglist(SCpnt);
SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer); SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer);
SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1; SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
} else {
SCpnt->SCp.ptr = (char *) SCpnt->request_buffer;
SCpnt->SCp.this_residual = SCpnt->request_bufflen;
SCpnt->SCp.buffer = NULL;
SCpnt->SCp.buffers_residual = 0;
}
} }
DO_LOCK(flags); DO_LOCK(flags);
...@@ -1525,8 +1525,8 @@ static void busfree_run(struct Scsi_Host *shpnt) ...@@ -1525,8 +1525,8 @@ static void busfree_run(struct Scsi_Host *shpnt)
/* target sent DISCONNECT */ /* target sent DISCONNECT */
DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n", DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n",
CMDINFO(CURRENT_SC), CMDINFO(CURRENT_SC),
CURRENT_SC->resid, scsi_get_resid(CURRENT_SC),
CURRENT_SC->request_bufflen); scsi_bufflen(CURRENT_SC));
#if defined(AHA152X_STAT) #if defined(AHA152X_STAT)
HOSTDATA(shpnt)->disconnections++; HOSTDATA(shpnt)->disconnections++;
#endif #endif
...@@ -1564,7 +1564,7 @@ static void busfree_run(struct Scsi_Host *shpnt) ...@@ -1564,7 +1564,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
/* restore old command */ /* restore old command */
memcpy(cmd->cmnd, sc->aha_orig_cmnd, sizeof(cmd->cmnd)); memcpy(cmd->cmnd, sc->aha_orig_cmnd, sizeof(cmd->cmnd));
cmd->cmd_len = sc->aha_orig_cmd_len; cmd->cmd_len = sc->aha_orig_cmd_len;
cmd->resid = sc->aha_orig_resid; scsi_set_resid(cmd, sc->aha_orig_resid);
cmd->SCp.Status = SAM_STAT_CHECK_CONDITION; cmd->SCp.Status = SAM_STAT_CHECK_CONDITION;
...@@ -1594,7 +1594,7 @@ static void busfree_run(struct Scsi_Host *shpnt) ...@@ -1594,7 +1594,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
memcpy(sc->aha_orig_cmnd, ptr->cmnd, memcpy(sc->aha_orig_cmnd, ptr->cmnd,
sizeof(ptr->cmnd)); sizeof(ptr->cmnd));
sc->aha_orig_cmd_len = ptr->cmd_len; sc->aha_orig_cmd_len = ptr->cmd_len;
sc->aha_orig_resid = ptr->resid; sc->aha_orig_resid = scsi_get_resid(ptr);
ptr->cmnd[0] = REQUEST_SENSE; ptr->cmnd[0] = REQUEST_SENSE;
ptr->cmnd[1] = 0; ptr->cmnd[1] = 0;
...@@ -2179,7 +2179,8 @@ static void datai_init(struct Scsi_Host *shpnt) ...@@ -2179,7 +2179,8 @@ static void datai_init(struct Scsi_Host *shpnt)
DATA_LEN=0; DATA_LEN=0;
DPRINTK(debug_datai, DPRINTK(debug_datai,
DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n", DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n",
CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid); CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
scsi_get_resid(CURRENT_SC));
} }
static void datai_run(struct Scsi_Host *shpnt) static void datai_run(struct Scsi_Host *shpnt)
...@@ -2292,11 +2293,12 @@ static void datai_run(struct Scsi_Host *shpnt) ...@@ -2292,11 +2293,12 @@ static void datai_run(struct Scsi_Host *shpnt)
static void datai_end(struct Scsi_Host *shpnt) static void datai_end(struct Scsi_Host *shpnt)
{ {
CURRENT_SC->resid -= GETSTCNT(); CMD_INC_RESID(CURRENT_SC, -GETSTCNT());
DPRINTK(debug_datai, DPRINTK(debug_datai,
DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n", DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n",
CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid, GETSTCNT()); CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
scsi_get_resid(CURRENT_SC), GETSTCNT());
SETPORT(SXFRCTL0, CH1|CLRSTCNT); SETPORT(SXFRCTL0, CH1|CLRSTCNT);
SETPORT(DMACNTRL0, 0); SETPORT(DMACNTRL0, 0);
...@@ -2317,11 +2319,12 @@ static void datao_init(struct Scsi_Host *shpnt) ...@@ -2317,11 +2319,12 @@ static void datao_init(struct Scsi_Host *shpnt)
SETPORT(SIMODE0, 0); SETPORT(SIMODE0, 0);
SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE ); SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE );
DATA_LEN = CURRENT_SC->resid; DATA_LEN = scsi_get_resid(CURRENT_SC);
DPRINTK(debug_datao, DPRINTK(debug_datao,
DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n", DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n",
CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid); CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
scsi_get_resid(CURRENT_SC));
} }
static void datao_run(struct Scsi_Host *shpnt) static void datao_run(struct Scsi_Host *shpnt)
...@@ -2345,7 +2348,7 @@ static void datao_run(struct Scsi_Host *shpnt) ...@@ -2345,7 +2348,7 @@ static void datao_run(struct Scsi_Host *shpnt)
SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT); SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT);
SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++); SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++);
CURRENT_SC->SCp.this_residual--; CURRENT_SC->SCp.this_residual--;
CURRENT_SC->resid--; CMD_INC_RESID(CURRENT_SC, -1);
SETPORT(DMACNTRL0,WRITE_READ|ENDMA); SETPORT(DMACNTRL0,WRITE_READ|ENDMA);
} }
...@@ -2354,7 +2357,7 @@ static void datao_run(struct Scsi_Host *shpnt) ...@@ -2354,7 +2357,7 @@ static void datao_run(struct Scsi_Host *shpnt)
outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count);
CURRENT_SC->SCp.ptr += 2 * data_count; CURRENT_SC->SCp.ptr += 2 * data_count;
CURRENT_SC->SCp.this_residual -= 2 * data_count; CURRENT_SC->SCp.this_residual -= 2 * data_count;
CURRENT_SC->resid -= 2 * data_count; CMD_INC_RESID(CURRENT_SC, -2 * data_count);
} }
if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) {
...@@ -2380,35 +2383,34 @@ static void datao_run(struct Scsi_Host *shpnt) ...@@ -2380,35 +2383,34 @@ static void datao_run(struct Scsi_Host *shpnt)
static void datao_end(struct Scsi_Host *shpnt) static void datao_end(struct Scsi_Host *shpnt)
{ {
if(TESTLO(DMASTAT, DFIFOEMP)) { if(TESTLO(DMASTAT, DFIFOEMP)) {
int data_count = (DATA_LEN - CURRENT_SC->resid) - GETSTCNT(); int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
GETSTCNT();
DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n", DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n",
CMDINFO(CURRENT_SC), CMDINFO(CURRENT_SC),
data_count, data_count,
DATA_LEN-CURRENT_SC->resid, DATA_LEN - scsi_get_resid(CURRENT_SC),
GETSTCNT()); GETSTCNT());
CURRENT_SC->resid += data_count; CMD_INC_RESID(CURRENT_SC, data_count);
if(CURRENT_SC->use_sg) { data_count -= CURRENT_SC->SCp.ptr -
data_count -= CURRENT_SC->SCp.ptr - SG_ADDRESS(CURRENT_SC->SCp.buffer); SG_ADDRESS(CURRENT_SC->SCp.buffer);
while(data_count>0) { while(data_count>0) {
CURRENT_SC->SCp.buffer--; CURRENT_SC->SCp.buffer--;
CURRENT_SC->SCp.buffers_residual++; CURRENT_SC->SCp.buffers_residual++;
data_count -= CURRENT_SC->SCp.buffer->length; data_count -= CURRENT_SC->SCp.buffer->length;
} }
CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - data_count; CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + data_count; data_count;
} else { CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length +
CURRENT_SC->SCp.ptr -= data_count; data_count;
CURRENT_SC->SCp.this_residual += data_count;
}
} }
DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n", DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n",
CMDINFO(CURRENT_SC), CMDINFO(CURRENT_SC),
CURRENT_SC->request_bufflen, scsi_bufflen(CURRENT_SC),
CURRENT_SC->resid, scsi_get_resid(CURRENT_SC),
GETSTCNT()); GETSTCNT());
SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT);
...@@ -2935,7 +2937,7 @@ static void show_command(Scsi_Cmnd *ptr) ...@@ -2935,7 +2937,7 @@ static void show_command(Scsi_Cmnd *ptr)
__scsi_print_command(ptr->cmnd); __scsi_print_command(ptr->cmnd);
printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |", printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |",
ptr->request_bufflen, ptr->resid); scsi_bufflen(ptr), scsi_get_resid(ptr));
if (ptr->SCp.phase & not_issued) if (ptr->SCp.phase & not_issued)
printk("not issued|"); printk("not issued|");
...@@ -3005,7 +3007,8 @@ static int get_command(char *pos, Scsi_Cmnd * ptr) ...@@ -3005,7 +3007,8 @@ static int get_command(char *pos, Scsi_Cmnd * ptr)
SPRINTF("0x%02x ", ptr->cmnd[i]); SPRINTF("0x%02x ", ptr->cmnd[i]);
SPRINTF("); resid=%d; residual=%d; buffers=%d; phase |", SPRINTF("); resid=%d; residual=%d; buffers=%d; phase |",
ptr->resid, ptr->SCp.this_residual, ptr->SCp.buffers_residual); scsi_get_resid(ptr), ptr->SCp.this_residual,
ptr->SCp.buffers_residual);
if (ptr->SCp.phase & not_issued) if (ptr->SCp.phase & not_issued)
SPRINTF("not issued|"); SPRINTF("not issued|");
......
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