Yet another patch from Alan Stern to fix the non-READ/WRITE command paths for sg-compliance.
Again, this driver doesn't handle MODE_SENSE_10 properly. A patch to fix
that will follow shortly.
Matt
----- Forwarded message from Alan Stern <[EMAIL PROTECTED]> -----
Date: Tue, 9 Dec 2003 12:12:24 -0500 (EST)
From: Alan Stern <[EMAIL PROTECTED]>
Subject: PATCH: (as158) Fix scatter-gather for non READ/WRITE in sddr55
To: Matthew Dharm <[EMAIL PROTECTED]>
cc: USB Storage List <[EMAIL PROTECTED]>
X-Spam-Status: No, hits=-1.5 required=5.0
tests=AWL,PATCH_UNIFIED_DIFF,SPAM_PHRASE_00_01,USER_AGENT_PINE
version=2.44
Matt:
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.
Alan Stern
--- 2.6/drivers/usb/storage3/sddr55.c Mon Dec 8 14:13:14 2003
+++ 2.6/drivers/usb/storage/sddr55.c Tue Dec 9 12:04:00 2003
@@ -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_bufflen<sizeof(mode_page_01)) {
- set_sense_info (5, 0x24, 0); /* invalid field in
command */
- return USB_STOR_TRANSPORT_FAILED;
- }
-
- memcpy(ptr, mode_page_01, sizeof(mode_page_01));
return USB_STOR_TRANSPORT_GOOD;
} else if ( (srb->cmnd[2] & 0x3F) == 0x3F ) {
@@ -881,13 +858,6 @@
US_DEBUGP(
"SDDR55: Dummy up request for all mode pages\n");
- if (ptr==NULL ||
- srb->request_bufflen<sizeof(mode_page_01)) {
- set_sense_info (5, 0x24, 0); /* invalid field in
command */
- return USB_STOR_TRANSPORT_FAILED;
- }
-
- memcpy(ptr, mode_page_01, sizeof(mode_page_01));
return USB_STOR_TRANSPORT_GOOD;
}
----- End forwarded message -----
--
Matthew Dharm Home: [EMAIL PROTECTED]
Maintainer, Linux USB Mass Storage Driver
S: Another stupid question?
G: There's no such thing as a stupid question, only stupid people.
-- Stef and Greg
User Friendly, 7/15/1998
pgp00000.pgp
Description: PGP signature
