patch-2.4.0-test6 linux/drivers/usb/storage/usb.c

Next file: linux/drivers/usb/storage/usb.h
Previous file: linux/drivers/usb/storage/transport.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test5/linux/drivers/usb/storage/usb.c linux/drivers/usb/storage/usb.c
@@ -1,6 +1,6 @@
 /* Driver for USB Mass Storage compliant devices
  *
- * $Id: usb.c,v 1.11 2000/07/24 20:37:24 mdharm Exp $
+ * $Id: usb.c,v 1.16 2000/08/01 22:01:19 mdharm Exp $
  *
  * Current development and maintainance by:
  *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
@@ -50,8 +50,11 @@
 #include "transport.h"
 #include "protocol.h"
 #include "debug.h"
-#if defined(CONFIG_USB_STORAGE_HP8200e) || defined(CONFIG_USB_STORAGE_SDDR09)
-#include "scm.h"
+#ifdef CONFIG_USB_STORAGE_HP8200e
+#include "shuttle_usbat.h"
+#endif
+#ifdef CONFIG_USB_STORAGE_SDDR09
+#include "sddr09.h"
 #endif
 
 #include <linux/module.h>
@@ -117,9 +120,9 @@
 
 	/* signal that we've started the thread */
 	up(&(us->notify));
+	set_current_state(TASK_INTERRUPTIBLE);
 
 	for(;;) {
-		set_current_state(TASK_INTERRUPTIBLE);
 		US_DEBUGP("*** thread sleeping.\n");
 		schedule();
 		US_DEBUGP("*** thread awakened.\n");
@@ -137,15 +140,27 @@
 
 		switch (action) {
 		case US_ACT_COMMAND:
+			/* reject the command if the direction indicator 
+			 * is UNKNOWN
+			 */
+			if (us->srb->sc_data_direction == SCSI_DATA_UNKNOWN) {
+				US_DEBUGP("UNKNOWN data direction\n");
+				us->srb->result = DID_ERROR;
+				set_current_state(TASK_INTERRUPTIBLE);
+				us->srb->scsi_done(us->srb);
+				us->srb = NULL;
+				break;
+			}
+			
 			/* reject if target != 0 or if LUN is higher than
 			 * the maximum known LUN
 			 */
 			if (us->srb->target || (us->srb->lun > us->max_lun)) {
 				US_DEBUGP("Bad device number (%d/%d)\n",
 					  us->srb->target, us->srb->lun);
-
 				us->srb->result = DID_BAD_TARGET << 16;
 
+				set_current_state(TASK_INTERRUPTIBLE);
 				us->srb->scsi_done(us->srb);
 				us->srb = NULL;
 				break;
@@ -155,6 +170,8 @@
 			if ((us->srb->cmnd[0] == START_STOP) &&
 			    (us->flags & US_FL_START_STOP)) {
 				us->srb->result = GOOD;
+
+				set_current_state(TASK_INTERRUPTIBLE);
 				us->srb->scsi_done(us->srb);
 				us->srb = NULL;
 				break;
@@ -194,9 +211,11 @@
 			if (us->srb->result != DID_ABORT << 16) {
 				US_DEBUGP("scsi cmd done, result=0x%x\n", 
 					   us->srb->result);
+				set_current_state(TASK_INTERRUPTIBLE);
 				us->srb->scsi_done(us->srb);
 			} else {
 				US_DEBUGP("scsi command aborted\n");
+				set_current_state(TASK_INTERRUPTIBLE);
 				up(&(us->notify));
 			}
 			us->srb = NULL;
@@ -253,12 +272,12 @@
 		US_SC_UFI,  US_PR_CBI, US_FL_SINGLE_LUN},
 	{ 0x0693, 0x0002, 0x0100, 0x0100, "Hagiwara FlashGate SmartMedia",
 		US_SC_SCSI, US_PR_BULK, US_FL_ALT_LENGTH},
-	{ 0x0781, 0x0001, 0x0200, 0x0200, "Sandisk ImageMate (SDDR-01)",
+	{ 0x0781, 0x0001, 0x0200, 0x0200, "Sandisk ImageMate (SDDR-05a)",
 		US_SC_SCSI, US_PR_CB, US_FL_SINGLE_LUN | US_FL_START_STOP},
 #ifdef CONFIG_USB_STORAGE_SDDR09
 	{ 0x0781, 0x0200, 0x0100, 0x0100, "Sandisk ImageMate (SDDR-09)",
-		US_SC_SCSI, US_PR_SCM_SCSI,
-		US_FL_SINGLE_LUN | US_FL_START_STOP | US_FL_NEED_INIT},
+		US_SC_SCSI, US_PR_EUSB_SDDR09,
+		US_FL_SINGLE_LUN | US_FL_START_STOP},
 #endif
 	{ 0x0781, 0x0002, 0x0009, 0x0009, "Sandisk Imagemate (SDDR-31)",
 		US_SC_SCSI, US_PR_BULK, US_FL_IGNORE_SER},
@@ -447,7 +466,7 @@
 
 	/* set the interface -- STALL is an acceptable response here */
 #ifdef CONFIG_USB_STORAGE_SDDR09
-	if (protocol != US_PR_SCM_SCSI)
+	if (protocol != US_PR_EUSB_SDDR09)
 		result = usb_set_interface(dev, 
 			altsetting->bInterfaceNumber, 0);
 	else
@@ -631,8 +650,8 @@
 #endif
 
 #ifdef CONFIG_USB_STORAGE_SDDR09
-		case US_PR_SCM_SCSI:
-			ss->transport_name = "SCM/SCSI";
+		case US_PR_EUSB_SDDR09:
+			ss->transport_name = "EUSB/SDDR09";
 			ss->transport = sddr09_transport;
 			ss->transport_reset = usb_stor_CB_reset;
 			ss->max_lun = 1;
@@ -666,13 +685,7 @@
 
 		case US_SC_QIC:
 			ss->protocol_name = "QIC-157";
-			US_DEBUGP("Sorry, device not supported.	 Please\n");
-			US_DEBUGP("contact mdharm-usb@one-eyed-alien.net\n");
-			US_DEBUGP("if you see this message.\n");
-			up(&us_list_semaphore);
-			kfree(ss->current_urb);
-			kfree(ss);
-			return NULL;
+			ss->proto_handler = usb_stor_qic157_command;
 			break;
 
 		case US_SC_8070:
@@ -843,6 +856,16 @@
                 /* Now that scsi_unregister_module is done with the host
                  * template, we can free the us_data structure (the host
                  * template is inline in this structure). */
+
+		/* If there's extra data in the us_data structure then
+		 * free that first */
+
+		if (us_list->extra) {
+			if (us_list->extra_destructor)
+				(*us_list->extra_destructor)(
+					us_list->extra);
+			kfree(us_list->extra);
+		}
                 kfree (us_list);
 
 		/* advance the list pointer */
@@ -855,3 +878,6 @@
 
 module_init(usb_stor_init) ;
 module_exit(usb_stor_exit) ;
+
+MODULE_AUTHOR("Michael Gee <michael@linuxspecific.com>, David L. Brown, Jr. <usb-storage@davidb.org>, Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
+MODULE_DESCRIPTION("USB Mass Storage driver");

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)