ChangeSet 1.1474.81.33, 2004/01/16 17:15:09-08:00, stern@rowland.harvard.edu [PATCH] USB Storage: Fix scatter-gather for non READ/WRITE in sddr55 These patch fixes the scatter-gather usage in the sddr55 driver for commands other than READ or WRITE. It also tidies up a few other commands. drivers/usb/storage/sddr55.c | 58 ++++++++++--------------------------------- 1 files changed, 14 insertions(+), 44 deletions(-) diff -Nru a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c --- a/drivers/usb/storage/sddr55.c Tue Jan 20 17:34:25 2004 +++ b/drivers/usb/storage/sddr55.c Tue Jan 20 17:34:25 2004 @@ -737,16 +737,15 @@ int sddr55_transport(Scsi_Cmnd *srb, struct us_data *us) { int result; - int i; - unsigned char inquiry_response[36] = { + static unsigned char inquiry_response[8] = { 0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00 }; - unsigned char mode_page_01[16] = { // write-protected for now + static unsigned char mode_page_01[16] = { // write-protected for now 0x03, 0x00, 0x80, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - unsigned char *ptr; + unsigned char *ptr = us->iobuf; unsigned long capacity; unsigned int lba; unsigned int pba; @@ -765,21 +764,13 @@ info = (struct sddr55_card_info *)(us->extra); - ptr = (unsigned char *)srb->request_buffer; - if (srb->cmnd[0] == REQUEST_SENSE) { - i = srb->cmnd[4]; - - if (i > sizeof info->sense_data) - i = sizeof info->sense_data; - - US_DEBUGP("SDDR55: request sense %02x/%02x/%02x\n", info->sense_data[2], info->sense_data[12], info->sense_data[13]); - info->sense_data[0] = 0x70; - info->sense_data[7] = 10; - - memcpy (ptr, info->sense_data, i); + memcpy (ptr, info->sense_data, sizeof info->sense_data); + ptr[0] = 0x70; + ptr[7] = 11; + usb_stor_set_xfer_buf (ptr, sizeof info->sense_data, srb); memset (info->sense_data, 0, sizeof info->sense_data); return USB_STOR_TRANSPORT_GOOD; @@ -791,8 +782,8 @@ respond to INQUIRY commands */ if (srb->cmnd[0] == INQUIRY) { - memset(inquiry_response+8, 0, 28); - fill_inquiry_response(us, inquiry_response, 36); + memcpy(ptr, inquiry_response, 8); + fill_inquiry_response(us, ptr, 36); return USB_STOR_TRANSPORT_GOOD; } @@ -841,17 +832,9 @@ capacity /= PAGESIZE; capacity--; - ptr[0] = MSB_of(capacity>>16); - ptr[1] = LSB_of(capacity>>16); - ptr[2] = MSB_of(capacity&0xFFFF); - ptr[3] = LSB_of(capacity&0xFFFF); - - // The page size - - ptr[4] = MSB_of(PAGESIZE>>16); - ptr[5] = LSB_of(PAGESIZE>>16); - ptr[6] = MSB_of(PAGESIZE&0xFFFF); - ptr[7] = LSB_of(PAGESIZE&0xFFFF); + ((u32 *) ptr)[0] = cpu_to_be32(capacity); + ((u32 *) ptr)[1] = cpu_to_be32(PAGESIZE); + usb_stor_set_xfer_buf(ptr, 8, srb); sddr55_read_map(us); @@ -860,20 +843,14 @@ if (srb->cmnd[0] == MODE_SENSE) { - mode_page_01[2] = (info->read_only || info->force_read_only) ? 0x80 : 0; + memcpy(ptr, mode_page_01, sizeof mode_page_01); + ptr[2] = (info->read_only || info->force_read_only) ? 0x80 : 0; if ( (srb->cmnd[2] & 0x3F) == 0x01 ) { US_DEBUGP( "SDDR55: Dummy up request for mode page 1\n"); - if (ptr==NULL || - srb->request_bufflencmnd[2] & 0x3F) == 0x3F ) { @@ -881,13 +858,6 @@ US_DEBUGP( "SDDR55: Dummy up request for all mode pages\n"); - if (ptr==NULL || - srb->request_bufflen