Commit 5f366a64 authored by Matthew Dharm's avatar Matthew Dharm Committed by Greg Kroah-Hartman

[PATCH] USB: remove now-dead mode-translation code

This patch removes all of the mode-translation logic.  It's no longer
needed, as the upper-level drivers now all issue the proper 10-byte
commands.  This is a large patch, but what it's doing is removing a great
deal of unneeded code -- about 650+ lines removed, according to diffstat.

Those of you who are having some trouble getting your DVD-RAMs detected
properly should have all your problems solved by an upcoming patch from the
SCSI folks.  It may look like that problem is related to this patch, but it
isn't -- it's a side-effect of another SCSI patch to consolidate code.

Special thanks to James Bottomley for being patient enough to work with me
on these issues on the SCSI layer.

This, BTW, makes US_FL_MODE_XLATE a NOP.  The symbol is kept for the
purpose of allowing unusual_devs.h to be consistent between 2.4 and 2.5

There are still a few places where more code could (potentially) be
removed.  I need to mull over the UFI specification to be sure, tho.
parent 61e36850
......@@ -130,8 +130,9 @@ static void fix_read_capacity(Scsi_Cmnd *srb)
void usb_stor_qic157_command(Scsi_Cmnd *srb, struct us_data *us)
{
/* Pad the ATAPI command with zeros
*
* NOTE: This only works because a Scsi_Cmnd struct field contains
* a unsigned char cmnd[12], so we know we have storage available
* a unsigned char cmnd[16], so we know we have storage available
*/
for (; srb->cmd_len<12; srb->cmd_len++)
srb->cmnd[srb->cmd_len] = 0;
......@@ -149,13 +150,10 @@ void usb_stor_qic157_command(Scsi_Cmnd *srb, struct us_data *us)
void usb_stor_ATAPI_command(Scsi_Cmnd *srb, struct us_data *us)
{
int old_cmnd = 0;
/* Fix some commands -- this is a form of mode translation
* ATAPI devices only accept 12 byte long commands
/* Pad the ATAPI command with zeros
*
* NOTE: This only works because a Scsi_Cmnd struct field contains
* a unsigned char cmnd[12], so we know we have storage available
* a unsigned char cmnd[16], so we know we have storage available
*/
/* Pad the ATAPI command with zeros */
......@@ -165,60 +163,10 @@ void usb_stor_ATAPI_command(Scsi_Cmnd *srb, struct us_data *us)
/* set command length to 12 bytes */
srb->cmd_len = 12;
/* determine the correct (or minimum) data length for these commands */
switch (srb->cmnd[0]) {
/* change MODE_SENSE/MODE_SELECT from 6 to 10 byte commands */
case MODE_SENSE:
case MODE_SELECT:
/* save the command so we can tell what it was */
old_cmnd = srb->cmnd[0];
srb->cmnd[11] = 0;
srb->cmnd[10] = 0;
srb->cmnd[9] = 0;
srb->cmnd[8] = srb->cmnd[4];
srb->cmnd[7] = 0;
srb->cmnd[6] = 0;
srb->cmnd[5] = 0;
srb->cmnd[4] = 0;
srb->cmnd[3] = 0;
srb->cmnd[2] = srb->cmnd[2];
srb->cmnd[1] = srb->cmnd[1];
srb->cmnd[0] = srb->cmnd[0] | 0x40;
break;
/* change READ_6/WRITE_6 to READ_10/WRITE_10, which
* are ATAPI commands */
case WRITE_6:
case READ_6:
srb->cmnd[11] = 0;
srb->cmnd[10] = 0;
srb->cmnd[9] = 0;
srb->cmnd[8] = srb->cmnd[4];
srb->cmnd[7] = 0;
srb->cmnd[6] = 0;
srb->cmnd[5] = srb->cmnd[3];
srb->cmnd[4] = srb->cmnd[2];
srb->cmnd[3] = srb->cmnd[1] & 0x1F;
srb->cmnd[2] = 0;
srb->cmnd[1] = srb->cmnd[1] & 0xE0;
srb->cmnd[0] = srb->cmnd[0] | 0x20;
break;
} /* end switch on cmnd[0] */
/* convert MODE_SELECT data here */
if (old_cmnd == MODE_SELECT)
usb_stor_scsiSense6to10(srb);
/* send the command to the transport layer */
usb_stor_invoke_transport(srb, us);
if (srb->result == SAM_STAT_GOOD) {
/* Fix the MODE_SENSE data if we translated the command */
if (old_cmnd == MODE_SENSE)
usb_stor_scsiSense10to6(srb);
if (srb->result == SAM_STAT_GOOD) {
/* fix the INQUIRY data if necessary */
fix_inquiry_data(srb);
}
......@@ -227,19 +175,23 @@ void usb_stor_ATAPI_command(Scsi_Cmnd *srb, struct us_data *us)
void usb_stor_ufi_command(Scsi_Cmnd *srb, struct us_data *us)
{
int old_cmnd = 0;
/* fix some commands -- this is a form of mode translation
* UFI devices only accept 12 byte long commands
*
* NOTE: This only works because a Scsi_Cmnd struct field contains
* a unsigned char cmnd[12], so we know we have storage available
* a unsigned char cmnd[16], so we know we have storage available
*/
/* Pad the ATAPI command with zeros */
for (; srb->cmd_len<12; srb->cmd_len++)
srb->cmnd[srb->cmd_len] = 0;
/* set command length to 12 bytes (this affects the transport layer) */
srb->cmd_len = 12;
/* determine the correct (or minimum) data length for these commands */
/* XXX We should be constantly re-evaluating the need for these */
/* determine the correct data length for these commands */
switch (srb->cmnd[0]) {
/* for INQUIRY, UFI devices only ever return 36 bytes */
......@@ -247,33 +199,6 @@ void usb_stor_ufi_command(Scsi_Cmnd *srb, struct us_data *us)
srb->cmnd[4] = 36;
break;
/* change MODE_SENSE/MODE_SELECT from 6 to 10 byte commands */
case MODE_SENSE:
case MODE_SELECT:
/* save the command so we can tell what it was */
old_cmnd = srb->cmnd[0];
srb->cmnd[11] = 0;
srb->cmnd[10] = 0;
srb->cmnd[9] = 0;
/* if we're sending data, we send all. If getting data,
* get the minimum */
if (srb->cmnd[0] == MODE_SELECT)
srb->cmnd[8] = srb->cmnd[4];
else
srb->cmnd[8] = 8;
srb->cmnd[7] = 0;
srb->cmnd[6] = 0;
srb->cmnd[5] = 0;
srb->cmnd[4] = 0;
srb->cmnd[3] = 0;
srb->cmnd[2] = srb->cmnd[2];
srb->cmnd[1] = srb->cmnd[1];
srb->cmnd[0] = srb->cmnd[0] | 0x40;
break;
/* again, for MODE_SENSE_10, we get the minimum (8) */
case MODE_SENSE_10:
srb->cmnd[7] = 0;
......@@ -284,38 +209,12 @@ void usb_stor_ufi_command(Scsi_Cmnd *srb, struct us_data *us)
case REQUEST_SENSE:
srb->cmnd[4] = 18;
break;
/* change READ_6/WRITE_6 to READ_10/WRITE_10, which
* are UFI commands */
case WRITE_6:
case READ_6:
srb->cmnd[11] = 0;
srb->cmnd[10] = 0;
srb->cmnd[9] = 0;
srb->cmnd[8] = srb->cmnd[4];
srb->cmnd[7] = 0;
srb->cmnd[6] = 0;
srb->cmnd[5] = srb->cmnd[3];
srb->cmnd[4] = srb->cmnd[2];
srb->cmnd[3] = srb->cmnd[1] & 0x1F;
srb->cmnd[2] = 0;
srb->cmnd[1] = srb->cmnd[1] & 0xE0;
srb->cmnd[0] = srb->cmnd[0] | 0x20;
break;
} /* end switch on cmnd[0] */
/* convert MODE_SELECT data here */
if (old_cmnd == MODE_SELECT)
usb_stor_scsiSense6to10(srb);
/* send the command to the transport layer */
usb_stor_invoke_transport(srb, us);
if (srb->result == SAM_STAT_GOOD) {
/* Fix the MODE_SENSE data if we translated the command */
if (old_cmnd == MODE_SENSE)
usb_stor_scsiSense10to6(srb);
if (srb->result == SAM_STAT_GOOD) {
/* Fix the data for an INQUIRY, if necessary */
fix_inquiry_data(srb);
}
......@@ -323,68 +222,10 @@ void usb_stor_ufi_command(Scsi_Cmnd *srb, struct us_data *us)
void usb_stor_transparent_scsi_command(Scsi_Cmnd *srb, struct us_data *us)
{
int old_cmnd = 0;
/* This code supports devices which do not support {READ|WRITE}_6
* Apparently, neither Windows or MacOS will use these commands,
* so some devices do not support them
*/
if (us->flags & US_FL_MODE_XLATE) {
US_DEBUGP("Invoking Mode Translation\n");
/* save the old command for later */
old_cmnd = srb->cmnd[0];
switch (srb->cmnd[0]) {
/* change READ_6/WRITE_6 to READ_10/WRITE_10 */
case WRITE_6:
case READ_6:
srb->cmd_len = 12;
srb->cmnd[11] = 0;
srb->cmnd[10] = 0;
srb->cmnd[9] = 0;
srb->cmnd[8] = srb->cmnd[4];
srb->cmnd[7] = 0;
srb->cmnd[6] = 0;
srb->cmnd[5] = srb->cmnd[3];
srb->cmnd[4] = srb->cmnd[2];
srb->cmnd[3] = srb->cmnd[1] & 0x1F;
srb->cmnd[2] = 0;
srb->cmnd[1] = srb->cmnd[1] & 0xE0;
srb->cmnd[0] = srb->cmnd[0] | 0x20;
break;
/* convert MODE_SELECT data here */
case MODE_SENSE:
case MODE_SELECT:
srb->cmd_len = 12;
srb->cmnd[11] = 0;
srb->cmnd[10] = 0;
srb->cmnd[9] = 0;
srb->cmnd[8] = srb->cmnd[4];
srb->cmnd[7] = 0;
srb->cmnd[6] = 0;
srb->cmnd[5] = 0;
srb->cmnd[4] = 0;
srb->cmnd[3] = 0;
srb->cmnd[2] = srb->cmnd[2];
srb->cmnd[1] = srb->cmnd[1];
srb->cmnd[0] = srb->cmnd[0] | 0x40;
break;
} /* switch (srb->cmnd[0]) */
} /* if (us->flags & US_FL_MODE_XLATE) */
/* convert MODE_SELECT data here */
if ((us->flags & US_FL_MODE_XLATE) && (old_cmnd == MODE_SELECT))
usb_stor_scsiSense6to10(srb);
/* send the command to the transport layer */
usb_stor_invoke_transport(srb, us);
if (srb->result == SAM_STAT_GOOD) {
/* Fix the MODE_SENSE data if we translated the command */
if ((us->flags & US_FL_MODE_XLATE) && (old_cmnd == MODE_SENSE))
usb_stor_scsiSense10to6(srb);
if (srb->result == SAM_STAT_GOOD) {
/* Fix the INQUIRY data if necessary */
fix_inquiry_data(srb);
......
......@@ -263,7 +263,6 @@ static int proc_info (struct Scsi_Host *hostptr, char *buffer, char **start, off
#define DO_FLAG(a) if (f & US_FL_##a) pos += sprintf(pos, " " #a)
DO_FLAG(SINGLE_LUN);
DO_FLAG(MODE_XLATE);
DO_FLAG(SCM_MULT_TARG);
DO_FLAG(FIX_INQUIRY);
DO_FLAG(FIX_CAPACITY);
......@@ -346,499 +345,3 @@ unsigned char usb_stor_sense_invalidCDB[18] = {
[12] = 0x24 /* Invalid Field in CDB */
};
#define USB_STOR_SCSI_SENSE_HDRSZ 4
#define USB_STOR_SCSI_SENSE_10_HDRSZ 8
struct usb_stor_scsi_sense_hdr
{
__u8* dataLength;
__u8* mediumType;
__u8* devSpecParms;
__u8* blkDescLength;
};
typedef struct usb_stor_scsi_sense_hdr Usb_Stor_Scsi_Sense_Hdr;
union usb_stor_scsi_sense_hdr_u
{
Usb_Stor_Scsi_Sense_Hdr hdr;
__u8* array[USB_STOR_SCSI_SENSE_HDRSZ];
};
typedef union usb_stor_scsi_sense_hdr_u Usb_Stor_Scsi_Sense_Hdr_u;
struct usb_stor_scsi_sense_hdr_10
{
__u8* dataLengthMSB;
__u8* dataLengthLSB;
__u8* mediumType;
__u8* devSpecParms;
__u8* reserved1;
__u8* reserved2;
__u8* blkDescLengthMSB;
__u8* blkDescLengthLSB;
};
typedef struct usb_stor_scsi_sense_hdr_10 Usb_Stor_Scsi_Sense_Hdr_10;
union usb_stor_scsi_sense_hdr_10_u
{
Usb_Stor_Scsi_Sense_Hdr_10 hdr;
__u8* array[USB_STOR_SCSI_SENSE_10_HDRSZ];
};
typedef union usb_stor_scsi_sense_hdr_10_u Usb_Stor_Scsi_Sense_Hdr_10_u;
void usb_stor_scsiSenseParseBuffer( Scsi_Cmnd* , Usb_Stor_Scsi_Sense_Hdr_u*,
Usb_Stor_Scsi_Sense_Hdr_10_u*, int* );
int usb_stor_scsiSense10to6( Scsi_Cmnd* the10 )
{
__u8 *buffer=0;
int outputBufferSize = 0;
int length=0;
struct scatterlist *sg = 0;
int i=0, j=0, element=0;
Usb_Stor_Scsi_Sense_Hdr_u the6Locations;
Usb_Stor_Scsi_Sense_Hdr_10_u the10Locations;
int sb=0,si=0,db=0,di=0;
int sgLength=0;
US_DEBUGP("-- converting 10 byte sense data to 6 byte\n");
the10->cmnd[0] = the10->cmnd[0] & 0xBF;
/* Determine buffer locations */
usb_stor_scsiSenseParseBuffer( the10, &the6Locations, &the10Locations,
&length );
/* Work out minimum buffer to output */
outputBufferSize = *the10Locations.hdr.dataLengthLSB;
outputBufferSize += USB_STOR_SCSI_SENSE_HDRSZ;
/* Check to see if we need to trucate the output */
if ( outputBufferSize > length )
{
printk( KERN_WARNING USB_STORAGE
"Had to truncate MODE_SENSE_10 buffer into MODE_SENSE.\n" );
printk( KERN_WARNING USB_STORAGE
"outputBufferSize is %d and length is %d.\n",
outputBufferSize, length );
}
outputBufferSize = length;
/* Data length */
if ( *the10Locations.hdr.dataLengthMSB != 0 ) /* MSB must be zero */
{
printk( KERN_WARNING USB_STORAGE
"Command will be truncated to fit in SENSE6 buffer.\n" );
*the6Locations.hdr.dataLength = 0xff;
}
else
{
*the6Locations.hdr.dataLength = *the10Locations.hdr.dataLengthLSB;
}
/* Medium type and DevSpecific parms */
*the6Locations.hdr.mediumType = *the10Locations.hdr.mediumType;
*the6Locations.hdr.devSpecParms = *the10Locations.hdr.devSpecParms;
/* Block descriptor length */
if ( *the10Locations.hdr.blkDescLengthMSB != 0 ) /* MSB must be zero */
{
printk( KERN_WARNING USB_STORAGE
"Command will be truncated to fit in SENSE6 buffer.\n" );
*the6Locations.hdr.blkDescLength = 0xff;
}
else
{
*the6Locations.hdr.blkDescLength = *the10Locations.hdr.blkDescLengthLSB;
}
if ( the10->use_sg == 0 )
{
buffer = the10->request_buffer;
/* Copy the rest of the data */
memmove( &(buffer[USB_STOR_SCSI_SENSE_HDRSZ]),
&(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
outputBufferSize - USB_STOR_SCSI_SENSE_HDRSZ );
/* initialise last bytes left in buffer due to smaller header */
memset( &(buffer[outputBufferSize
-(USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ)]),
0,
USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ );
}
else
{
sg = (struct scatterlist *) the10->request_buffer;
/* scan through this scatterlist and figure out starting positions */
for ( i=0; i < the10->use_sg; i++)
{
sgLength = sg[i].length;
for ( j=0; j<sgLength; j++ )
{
/* get to end of header */
if ( element == USB_STOR_SCSI_SENSE_HDRSZ )
{
db=i;
di=j;
}
if ( element == USB_STOR_SCSI_SENSE_10_HDRSZ )
{
sb=i;
si=j;
/* we've found both sets now, exit loops */
j=sgLength;
i=the10->use_sg;
}
element++;
}
}
/* Now we know where to start the copy from */
element = USB_STOR_SCSI_SENSE_HDRSZ;
while ( element < outputBufferSize
-(USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ) )
{
/* check limits */
if ( sb >= the10->use_sg ||
si >= sg[sb].length ||
db >= the10->use_sg ||
di >= sg[db].length )
{
printk( KERN_ERR USB_STORAGE
"Buffer overrun averted, this shouldn't happen!\n" );
break;
}
/* copy one byte */
{
char *src = sg_address(sg[sb]) + si;
char *dst = sg_address(sg[db]) + di;
*dst = *src;
}
/* get next destination */
if ( sg[db].length-1 == di )
{
db++;
di=0;
}
else
{
di++;
}
/* get next source */
if ( sg[sb].length-1 == si )
{
sb++;
si=0;
}
else
{
si++;
}
element++;
}
/* zero the remaining bytes */
while ( element < outputBufferSize )
{
/* check limits */
if ( db >= the10->use_sg ||
di >= sg[db].length )
{
printk( KERN_ERR USB_STORAGE
"Buffer overrun averted, this shouldn't happen!\n" );
break;
}
*(char*)(sg_address(sg[db])) = 0;
/* get next destination */
if ( sg[db].length-1 == di )
{
db++;
di=0;
}
else
{
di++;
}
element++;
}
}
/* All done any everything was fine */
return 0;
}
int usb_stor_scsiSense6to10( Scsi_Cmnd* the6 )
{
/* will be used to store part of buffer */
__u8 tempBuffer[USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ],
*buffer=0;
int outputBufferSize = 0;
int length=0;
struct scatterlist *sg = 0;
int i=0, j=0, element=0;
Usb_Stor_Scsi_Sense_Hdr_u the6Locations;
Usb_Stor_Scsi_Sense_Hdr_10_u the10Locations;
int sb=0,si=0,db=0,di=0;
int lsb=0,lsi=0,ldb=0,ldi=0;
US_DEBUGP("-- converting 6 byte sense data to 10 byte\n");
the6->cmnd[0] = the6->cmnd[0] | 0x40;
/* Determine buffer locations */
usb_stor_scsiSenseParseBuffer( the6, &the6Locations, &the10Locations,
&length );
/* Work out minimum buffer to output */
outputBufferSize = *the6Locations.hdr.dataLength;
outputBufferSize += USB_STOR_SCSI_SENSE_10_HDRSZ;
/* Check to see if we need to trucate the output */
if ( outputBufferSize > length )
{
printk( KERN_WARNING USB_STORAGE
"Had to truncate MODE_SENSE into MODE_SENSE_10 buffer.\n" );
printk( KERN_WARNING USB_STORAGE
"outputBufferSize is %d and length is %d.\n",
outputBufferSize, length );
}
outputBufferSize = length;
/* Block descriptor length - save these before overwriting */
tempBuffer[2] = *the10Locations.hdr.blkDescLengthMSB;
tempBuffer[3] = *the10Locations.hdr.blkDescLengthLSB;
*the10Locations.hdr.blkDescLengthLSB = *the6Locations.hdr.blkDescLength;
*the10Locations.hdr.blkDescLengthMSB = 0;
/* reserved - save these before overwriting */
tempBuffer[0] = *the10Locations.hdr.reserved1;
tempBuffer[1] = *the10Locations.hdr.reserved2;
*the10Locations.hdr.reserved1 = *the10Locations.hdr.reserved2 = 0;
/* Medium type and DevSpecific parms */
*the10Locations.hdr.devSpecParms = *the6Locations.hdr.devSpecParms;
*the10Locations.hdr.mediumType = *the6Locations.hdr.mediumType;
/* Data length */
*the10Locations.hdr.dataLengthLSB = *the6Locations.hdr.dataLength;
*the10Locations.hdr.dataLengthMSB = 0;
if ( !the6->use_sg )
{
buffer = the6->request_buffer;
/* Copy the rest of the data */
memmove( &(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
&(buffer[USB_STOR_SCSI_SENSE_HDRSZ]),
outputBufferSize-USB_STOR_SCSI_SENSE_10_HDRSZ );
/* Put the first four bytes (after header) in place */
memcpy( &(buffer[USB_STOR_SCSI_SENSE_10_HDRSZ]),
tempBuffer,
USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ );
}
else
{
sg = (struct scatterlist *) the6->request_buffer;
/* scan through this scatterlist and figure out ending positions */
for ( i=0; i < the6->use_sg; i++)
{
for ( j=0; j<sg[i].length; j++ )
{
/* get to end of header */
if ( element == USB_STOR_SCSI_SENSE_HDRSZ )
{
ldb=i;
ldi=j;
}
if ( element == USB_STOR_SCSI_SENSE_10_HDRSZ )
{
lsb=i;
lsi=j;
/* we've found both sets now, exit loops */
j=sg[i].length;
i=the6->use_sg;
break;
}
element++;
}
}
/* scan through this scatterlist and figure out starting positions */
element = length-1;
/* destination is the last element */
db=the6->use_sg-1;
di=sg[db].length-1;
for ( i=the6->use_sg-1; i >= 0; i--)
{
for ( j=sg[i].length-1; j>=0; j-- )
{
/* get to end of header and find source for copy */
if ( element == length - 1
- (USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ) )
{
sb=i;
si=j;
/* we've found both sets now, exit loops */
j=-1;
i=-1;
}
element--;
}
}
/* Now we know where to start the copy from */
element = length-1
- (USB_STOR_SCSI_SENSE_10_HDRSZ-USB_STOR_SCSI_SENSE_HDRSZ);
while ( element >= USB_STOR_SCSI_SENSE_10_HDRSZ )
{
/* check limits */
if ( ( sb <= lsb && si < lsi ) ||
( db <= ldb && di < ldi ) )
{
printk( KERN_ERR USB_STORAGE
"Buffer overrun averted, this shouldn't happen!\n" );
break;
}
/* copy one byte */
{
char *src = sg_address(sg[sb]) + si;
char *dst = sg_address(sg[db]) + di;
*dst = *src;
}
/* get next destination */
if ( di == 0 )
{
db--;
di=sg[db].length-1;
}
else
{
di--;
}
/* get next source */
if ( si == 0 )
{
sb--;
si=sg[sb].length-1;
}
else
{
si--;
}
element--;
}
/* copy the remaining four bytes */
while ( element >= USB_STOR_SCSI_SENSE_HDRSZ )
{
/* check limits */
if ( db <= ldb && di < ldi )
{
printk( KERN_ERR USB_STORAGE
"Buffer overrun averted, this shouldn't happen!\n" );
break;
}
{
char *dst = sg_address(sg[db]) + di;
*dst = tempBuffer[element-USB_STOR_SCSI_SENSE_HDRSZ];
}
/* get next destination */
if ( di == 0 )
{
db--;
di=sg[db].length-1;
}
else
{
di--;
}
element--;
}
}
/* All done and everything was fine */
return 0;
}
void usb_stor_scsiSenseParseBuffer( Scsi_Cmnd* srb, Usb_Stor_Scsi_Sense_Hdr_u* the6,
Usb_Stor_Scsi_Sense_Hdr_10_u* the10,
int* length_p )
{
int i = 0, j=0, element=0;
struct scatterlist *sg = 0;
int length = 0;
__u8* buffer=0;
/* are we scatter-gathering? */
if ( srb->use_sg != 0 )
{
/* loop over all the scatter gather structures and
* get pointer to the data members in the headers
* (also work out the length while we're here)
*/
sg = (struct scatterlist *) srb->request_buffer;
for (i = 0; i < srb->use_sg; i++)
{
length += sg[i].length;
/* We only do the inner loop for the headers */
if ( element < USB_STOR_SCSI_SENSE_10_HDRSZ )
{
/* scan through this scatterlist */
for ( j=0; j<sg[i].length; j++ )
{
if ( element < USB_STOR_SCSI_SENSE_HDRSZ )
{
/* fill in the pointers for both header types */
the6->array[element] = sg_address(sg[i]) + j;
the10->array[element] = sg_address(sg[i]) + j;
}
else if ( element < USB_STOR_SCSI_SENSE_10_HDRSZ )
{
/* only the longer headers still cares now */
the10->array[element] = sg_address(sg[i]) + j;
}
/* increase element counter */
element++;
}
}
}
}
else
{
length = srb->request_bufflen;
buffer = srb->request_buffer;
if ( length < USB_STOR_SCSI_SENSE_10_HDRSZ )
printk( KERN_ERR USB_STORAGE
"Buffer length smaller than header!!" );
for( i=0; i<USB_STOR_SCSI_SENSE_10_HDRSZ; i++ )
{
if ( i < USB_STOR_SCSI_SENSE_HDRSZ )
{
the6->array[i] = &(buffer[i]);
the10->array[i] = &(buffer[i]);
}
else
{
the10->array[i] = &(buffer[i]);
}
}
}
/* Set value of length passed in */
*length_p = length;
}
......@@ -69,11 +69,10 @@ struct us_unusual_dev {
/* Flag definitions: these entries are static */
#define US_FL_SINGLE_LUN 0x00000001 /* allow access to only LUN 0 */
#define US_FL_MODE_XLATE 0x00000002 /* translate _6 to _10 commands for
Win/MacOS compatibility */
#define US_FL_MODE_XLATE 0 /* [no longer used] */
#define US_FL_IGNORE_SER 0 /* [no longer used] */
#define US_FL_SCM_MULT_TARG 0x00000020 /* supports multiple targets */
#define US_FL_FIX_INQUIRY 0x00000040 /* INQUIRY response needs fixing */
#define US_FL_FIX_INQUIRY 0x00000040 /* INQUIRY response needs faking */
#define US_FL_FIX_CAPACITY 0x00000080 /* READ CAPACITY response too big */
/* Dynamic flag definitions: used in set_bit() etc. */
......
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