Commit afd9a033 authored by Boaz Harrosh's avatar Boaz Harrosh Committed by James Bottomley

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

  - use scsi_cmnd data accessors
  - Clean the !use_sg code paths
Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
[jejb: merge conflict fix]
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent bd441dea
...@@ -446,7 +446,8 @@ static void mts_data_done( struct urb* transfer ) ...@@ -446,7 +446,8 @@ static void mts_data_done( struct urb* transfer )
MTS_INT_INIT(); MTS_INT_INIT();
if ( context->data_length != transfer->actual_length ) { if ( context->data_length != transfer->actual_length ) {
context->srb->resid = context->data_length - transfer->actual_length; scsi_set_resid(context->srb, context->data_length -
transfer->actual_length);
} else if ( unlikely(status) ) { } else if ( unlikely(status) ) {
context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16; context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16;
} }
...@@ -490,7 +491,8 @@ static void mts_command_done( struct urb *transfer ) ...@@ -490,7 +491,8 @@ static void mts_command_done( struct urb *transfer )
context->data_pipe, context->data_pipe,
context->data, context->data,
context->data_length, context->data_length,
context->srb->use_sg > 1 ? mts_do_sg : mts_data_done); scsi_sg_count(context->srb) > 1 ?
mts_do_sg : mts_data_done);
} else { } else {
mts_get_status(transfer); mts_get_status(transfer);
} }
...@@ -505,21 +507,23 @@ static void mts_do_sg (struct urb* transfer) ...@@ -505,21 +507,23 @@ static void mts_do_sg (struct urb* transfer)
int status = transfer->status; int status = transfer->status;
MTS_INT_INIT(); MTS_INT_INIT();
MTS_DEBUG("Processing fragment %d of %d\n", context->fragment,context->srb->use_sg); MTS_DEBUG("Processing fragment %d of %d\n", context->fragment,
scsi_sg_count(context->srb));
if (unlikely(status)) { if (unlikely(status)) {
context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16; context->srb->result = (status == -ENOENT ? DID_ABORT : DID_ERROR)<<16;
mts_transfer_cleanup(transfer); mts_transfer_cleanup(transfer);
} }
sg = context->srb->request_buffer; sg = scsi_sglist(context->srb);
context->fragment++; context->fragment++;
mts_int_submit_urb(transfer, mts_int_submit_urb(transfer,
context->data_pipe, context->data_pipe,
page_address(sg[context->fragment].page) + page_address(sg[context->fragment].page) +
sg[context->fragment].offset, sg[context->fragment].offset,
sg[context->fragment].length, sg[context->fragment].length,
context->fragment + 1 == context->srb->use_sg ? mts_data_done : mts_do_sg); context->fragment + 1 == scsi_sg_count(context->srb) ?
mts_data_done : mts_do_sg);
return; return;
} }
...@@ -547,20 +551,12 @@ mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc) ...@@ -547,20 +551,12 @@ mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc)
desc->context.srb = srb; desc->context.srb = srb;
desc->context.fragment = 0; desc->context.fragment = 0;
if (!srb->use_sg) { if (!scsi_bufflen(srb)) {
if ( !srb->request_bufflen ){
desc->context.data = NULL; desc->context.data = NULL;
desc->context.data_length = 0; desc->context.data_length = 0;
return; return;
} else { } else {
desc->context.data = srb->request_buffer; sg = scsi_sglist(srb);
desc->context.data_length = srb->request_bufflen;
MTS_DEBUG("length = %d or %d\n",
srb->request_bufflen, srb->bufflen);
}
} else {
MTS_DEBUG("Using scatter/gather\n");
sg = srb->request_buffer;
desc->context.data = page_address(sg[0].page) + sg[0].offset; desc->context.data = page_address(sg[0].page) + sg[0].offset;
desc->context.data_length = sg[0].length; desc->context.data_length = sg[0].length;
} }
......
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