Commit 5151c536 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB storage: Update scatter-gather handling in the isd200 driver

This patch fixes the scatter-gather handling in isd200, replacing an
incorrect routine there with calls to the new routine added in the
previous patch.  It also removes a couple of places where the driver
returned data for commands that shouldn't get any (TEST-UNIT-READY and
START-STOP).

This has not been tested.
parent 2505f3df
...@@ -543,7 +543,6 @@ void isd200_invoke_transport( struct us_data *us, ...@@ -543,7 +543,6 @@ void isd200_invoke_transport( struct us_data *us,
int result; int result;
/* send the command to the transport layer */ /* send the command to the transport layer */
srb->resid = 0;
memcpy(srb->cmnd, ataCdb, sizeof(ataCdb->generic)); memcpy(srb->cmnd, ataCdb, sizeof(ataCdb->generic));
srb->cmd_len = sizeof(ataCdb->generic); srb->cmd_len = sizeof(ataCdb->generic);
transferStatus = usb_stor_Bulk_transport(srb, us); transferStatus = usb_stor_Bulk_transport(srb, us);
...@@ -1116,60 +1115,6 @@ int isd200_get_inquiry_data( struct us_data *us ) ...@@ -1116,60 +1115,6 @@ int isd200_get_inquiry_data( struct us_data *us )
} }
/**************************************************************************
* isd200_data_copy
*
* Copy data into the srb request buffer. Use scatter gather if required.
*
* RETURNS:
* void
*/
void isd200_data_copy(Scsi_Cmnd *srb, char * src, int length)
{
unsigned int len = length;
struct scatterlist *sg;
if (srb->use_sg) {
int i;
unsigned int total = 0;
/* Add up the sizes of all the sg segments */
sg = (struct scatterlist *) srb->request_buffer;
for (i = 0; i < srb->use_sg; i++)
total += sg[i].length;
if (length > total)
len = total;
total = 0;
/* Copy data into sg buffer(s) */
for (i = 0; i < srb->use_sg; i++) {
if ((len > total) && (len > 0)) {
/* transfer the lesser of the next buffer or the
* remaining data */
if (len - total >= sg[i].length) {
memcpy(sg_address(sg[i]), src + total, sg[i].length);
total += sg[i].length;
} else {
memcpy(sg_address(sg[i]), src + total, len - total);
total = len;
}
}
else
break;
}
} else {
/* Make sure length does not exceed buffer length */
if (length > srb->request_bufflen)
len = srb->request_bufflen;
if (len > 0)
memcpy(srb->request_buffer, src, len);
}
}
/************************************************************************** /**************************************************************************
* isd200_scsi_to_ata * isd200_scsi_to_ata
* *
...@@ -1198,11 +1143,9 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1198,11 +1143,9 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
case INQUIRY: case INQUIRY:
US_DEBUGP(" ATA OUT - INQUIRY\n"); US_DEBUGP(" ATA OUT - INQUIRY\n");
if (srb->request_bufflen > sizeof(struct inquiry_data))
srb->request_bufflen = sizeof(struct inquiry_data);
/* copy InquiryData */ /* copy InquiryData */
isd200_data_copy(srb, (char *) &info->InquiryData, srb->request_bufflen); usb_stor_set_xfer_buf((unsigned char *) &info->InquiryData,
sizeof(info->InquiryData), srb);
srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
sendToTransport = FALSE; sendToTransport = FALSE;
break; break;
...@@ -1211,7 +1154,7 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1211,7 +1154,7 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
US_DEBUGP(" ATA OUT - SCSIOP_MODE_SENSE\n"); US_DEBUGP(" ATA OUT - SCSIOP_MODE_SENSE\n");
/* Initialize the return buffer */ /* Initialize the return buffer */
isd200_data_copy(srb, (char *) &senseData, 8); usb_stor_set_xfer_buf(senseData, sizeof(senseData), srb);
if (info->DeviceFlags & DF_MEDIA_STATUS_ENABLED) if (info->DeviceFlags & DF_MEDIA_STATUS_ENABLED)
{ {
...@@ -1231,9 +1174,6 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1231,9 +1174,6 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
case TEST_UNIT_READY: case TEST_UNIT_READY:
US_DEBUGP(" ATA OUT - SCSIOP_TEST_UNIT_READY\n"); US_DEBUGP(" ATA OUT - SCSIOP_TEST_UNIT_READY\n");
/* Initialize the return buffer */
isd200_data_copy(srb, (char *) &senseData, 8);
if (info->DeviceFlags & DF_MEDIA_STATUS_ENABLED) if (info->DeviceFlags & DF_MEDIA_STATUS_ENABLED)
{ {
ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand; ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
...@@ -1266,10 +1206,8 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1266,10 +1206,8 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
readCapacityData.LogicalBlockAddress = cpu_to_be32(capacity); readCapacityData.LogicalBlockAddress = cpu_to_be32(capacity);
readCapacityData.BytesPerBlock = cpu_to_be32(0x200); readCapacityData.BytesPerBlock = cpu_to_be32(0x200);
if (srb->request_bufflen > sizeof(struct read_capacity_data)) usb_stor_set_xfer_buf((unsigned char *) &readCapacityData,
srb->request_bufflen = sizeof(struct read_capacity_data); sizeof(readCapacityData), srb);
isd200_data_copy(srb, (char *) &readCapacityData, srb->request_bufflen);
srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
sendToTransport = FALSE; sendToTransport = FALSE;
} }
...@@ -1363,9 +1301,6 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1363,9 +1301,6 @@ int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
US_DEBUGP(" ATA OUT - SCSIOP_START_STOP_UNIT\n"); US_DEBUGP(" ATA OUT - SCSIOP_START_STOP_UNIT\n");
US_DEBUGP(" srb->cmnd[4] = 0x%X\n", srb->cmnd[4]); US_DEBUGP(" srb->cmnd[4] = 0x%X\n", srb->cmnd[4]);
/* Initialize the return buffer */
isd200_data_copy(srb, (char *) &senseData, 8);
if ((srb->cmnd[4] & 0x3) == 0x2) { if ((srb->cmnd[4] & 0x3) == 0x2) {
US_DEBUGP(" Media Eject\n"); US_DEBUGP(" Media Eject\n");
ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand; ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
...@@ -1500,6 +1435,7 @@ void isd200_ata_command(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1500,6 +1435,7 @@ void isd200_ata_command(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("ERROR Driver not initialized\n"); US_DEBUGP("ERROR Driver not initialized\n");
/* Convert command */ /* Convert command */
srb->resid = 0;
sendToTransport = isd200_scsi_to_ata(srb, us, &ataCdb); sendToTransport = isd200_scsi_to_ata(srb, us, &ataCdb);
/* send the command to the transport layer */ /* send the command to the transport layer */
......
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