patch-2.4.8 linux/drivers/usb/storage/usb.c

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

diff -u --recursive --new-file v2.4.7/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.61 2001/01/13 00:10:59 mdharm Exp $
+ * $Id: usb.c,v 1.67 2001/07/29 23:41:52 mdharm Exp $
  *
  * Current development and maintenance by:
  *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
@@ -53,6 +53,7 @@
 #include "protocol.h"
 #include "debug.h"
 #include "initializers.h"
+
 #ifdef CONFIG_USB_STORAGE_HP8200e
 #include "shuttle_usbat.h"
 #endif
@@ -65,12 +66,22 @@
 #ifdef CONFIG_USB_STORAGE_FREECOM
 #include "freecom.h"
 #endif
+#ifdef CONFIG_USB_STORAGE_ISD200
+#include "isd200.h"
+#endif
+#ifdef CONFIG_USB_STORAGE_DATAFAB
+#include "datafab.h"
+#endif
+#ifdef CONFIG_USB_STORAGE_JUMPSHOT
+#include "jumpshot.h"
+#endif
+
 
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <linux/slab.h>
+#include <linux/malloc.h>
 
 /* Some informational data */
 MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
@@ -151,7 +162,7 @@
 
 /* The vendor name should be kept at eight characters or less, and
  * the product name should be kept at 16 characters or less. If a device
- * has the US_FL_DUMMY_INQUIRY flag, then the vendor and product names
+ * has the US_FL_FIX_INQUIRY flag, then the vendor and product names
  * normally generated by a device thorugh the INQUIRY response will be
  * taken from this list, and this is the reason for the above size
  * restriction. However, if the flag is not present, then you
@@ -281,7 +292,6 @@
 
 static int usb_stor_control_thread(void * __us)
 {
-	wait_queue_t wait;
 	struct us_data *us = (struct us_data *)__us;
 	int action;
 
@@ -302,17 +312,17 @@
 	unlock_kernel();
 
 	/* set up for wakeups by new commands */
-	init_waitqueue_entry(&wait, current);
-	init_waitqueue_head(&(us->wqh));
-	add_wait_queue(&(us->wqh), &wait);
+	init_MUTEX_LOCKED(&us->sema);
 
 	/* signal that we've started the thread */
-	up(&(us->notify));
+	complete(&(us->notify));
 	set_current_state(TASK_INTERRUPTIBLE);
 
 	for(;;) {
 		US_DEBUGP("*** thread sleeping.\n");
-		schedule();
+		if(down_interruptible(&us->sema))
+			break;
+			
 		US_DEBUGP("*** thread awakened.\n");
 
 		/* lock access to the queue element */
@@ -378,6 +388,24 @@
 				break;
 			}
 
+			/* Handle those devices which need us to fake their
+			 * inquiry data */
+			if ((us->srb->cmnd[0] == INQUIRY) &&
+			    (us->flags & US_FL_FIX_INQUIRY)) {
+			    	unsigned char data_ptr[36] = {
+				    0x00, 0x80, 0x02, 0x02,
+				    0x1F, 0x00, 0x00, 0x00};
+
+			    	US_DEBUGP("Faking INQUIRY command\n");
+				fill_inquiry_response(us, data_ptr, 36);
+				us->srb->result = GOOD << 1;
+
+				set_current_state(TASK_INTERRUPTIBLE);
+				us->srb->scsi_done(us->srb);
+				us->srb = NULL;
+				break;
+			}
+
 			/* lock the device pointers */
 			down(&(us->dev_semaphore));
 
@@ -417,7 +445,7 @@
 			} else {
 				US_DEBUGP("scsi command aborted\n");
 				set_current_state(TASK_INTERRUPTIBLE);
-				up(&(us->notify));
+				complete(&(us->notify));
 			}
 			us->srb = NULL;
 			break;
@@ -435,17 +463,16 @@
 
 		/* exit if we get a signal to exit */
 		if (action == US_ACT_EXIT) {
-			US_DEBUGP("-- US_ACT_EXIT command recieved\n");
+			US_DEBUGP("-- US_ACT_EXIT command received\n");
 			break;
 		}
 	} /* for (;;) */
 
 	/* clean up after ourselves */
 	set_current_state(TASK_INTERRUPTIBLE);
-	remove_wait_queue(&(us->wqh), &wait);
 
 	/* notify the exit routine that we're actually exiting now */
-	up(&(us->notify));
+	complete(&(us->notify));
 
 	return 0;
 }	
@@ -717,7 +744,7 @@
 		}
 
 		/* Initialize the mutexes only when the struct is new */
-		init_MUTEX_LOCKED(&(ss->notify));
+		init_completion(&(ss->notify));
 		init_MUTEX_LOCKED(&(ss->ip_waitq));
 		init_MUTEX(&(ss->queue_exclusion));
 		init_MUTEX(&(ss->irq_urb_sem));
@@ -831,6 +858,24 @@
                         break;
 #endif
 
+#ifdef CONFIG_USB_STORAGE_DATAFAB
+                case US_PR_DATAFAB:
+                        ss->transport_name  = "Datafab Bulk-Only";
+                        ss->transport = datafab_transport;
+                        ss->transport_reset = usb_stor_Bulk_reset;
+                        ss->max_lun = 1;
+                        break;
+#endif
+
+#ifdef CONFIG_USB_STORAGE_JUMPSHOT
+                case US_PR_JUMPSHOT:
+                        ss->transport_name  = "Lexar Jumpshot Control/Bulk";
+                        ss->transport = jumpshot_transport;
+                        ss->transport_reset = usb_stor_Bulk_reset;
+                        ss->max_lun = 1;
+                        break;
+#endif
+
 		default:
 			ss->transport_name = "Unknown";
 			kfree(ss->current_urb);
@@ -879,6 +924,13 @@
 			ss->proto_handler = usb_stor_ufi_command;
 			break;
 
+#ifdef CONFIG_USB_STORAGE_ISD200
+                case US_SC_ISD200:
+                        ss->protocol_name = "ISD200 ATA/ATAPI";
+                        ss->proto_handler = isd200_ata_command;
+                        break;
+#endif
+
 		default:
 			ss->protocol_name = "Unknown";
 			kfree(ss->current_urb);
@@ -907,7 +959,7 @@
 		ss->host_number = my_host_number++;
 
 		/* We abuse this pointer so we can pass the ss pointer to 
-		 * the host controler thread in us_detect.  But how else are
+		 * the host controller thread in us_detect.  But how else are
 		 * we to do it?
 		 */
 		(struct us_data *)ss->htmplt.proc_dir = ss; 
@@ -930,7 +982,7 @@
 		}
 
 		/* wait for the thread to start */
-		down(&(ss->notify));
+		wait_for_completion(&(ss->notify));
 
 		/* now register	 - our detect function will be called */
 		ss->htmplt.module = THIS_MODULE;

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