special usb hub handling, IDE disks, and retries all over the place
[linux-2.4.git] / drivers / usb / usb.c
index 695db60..cfca8fd 100644 (file)
 #include <linux/devfs_fs_kernel.h>
 #include <linux/spinlock.h>
 
 #include <linux/devfs_fs_kernel.h>
 #include <linux/spinlock.h>
 
+//+Wilson10292003
+#undef DBG
+//Wilson10292003+
+
+//+Wilson12032003
+extern void led_status(int);   
+//extern int HubFlag;
+#define        LED_OFF         0
+#define        LED_GREEN       1
+#define LED_RED                2
+#define LED_HUB                3
+//Wilson12032003+
+
+//+Wilson12192003
+//extern int ScsiOk;
+//Wilson12192003+
+
 #ifdef CONFIG_USB_DEBUG
        #define DEBUG
 #else
 #ifdef CONFIG_USB_DEBUG
        #define DEBUG
 #else
@@ -812,7 +829,10 @@ int usb_find_interface_driver_for_ifnum(struct usb_device *dev, unsigned ifnum)
  */
 static void call_policy_interface (char *verb, struct usb_device *dev, int interface)
 {
  */
 static void call_policy_interface (char *verb, struct usb_device *dev, int interface)
 {
-       char *argv [3], **envp, *buf, *scratch;
+       //+Wilson11132003
+       //char *argv [3], **envp, *buf, *scratch;
+       char *argv[5], **envp, *buf, *scratch;
+       //Wilson11132003+
        int i = 0, value;
 
        if (!hotplug_path [0])
        int i = 0, value;
 
        if (!hotplug_path [0])
@@ -843,7 +863,23 @@ static void call_policy_interface (char *verb, struct usb_device *dev, int inter
        /* only one standardized param to hotplug command: type */
        argv [0] = hotplug_path;
        argv [1] = "usb";
        /* only one standardized param to hotplug command: type */
        argv [0] = hotplug_path;
        argv [1] = "usb";
-       argv [2] = 0;
+       //argv [2] = 0; //+Wilson10282003
+       argv[2] = verb; //+Wilson10282003
+       argv[3] = 0;    //+Wilson11132003
+       
+       //+Wilson11072003
+       #if 01
+       if((dev->devnum == 1) || (dev->HubFlag == 1)) //+Wilson12032003
+       {
+               argv[3] = "host_hub";
+               dev->HubFlag = 0;       //+Wilson12032003
+       }
+       else 
+               argv[3] = 0;    
+               
+       argv[4] = 0;
+       #endif
+       //Wilson11072003+
 
        /* minimal command environment */
        envp [i++] = "HOME=/";
 
        /* minimal command environment */
        envp [i++] = "HOME=/";
@@ -901,6 +937,31 @@ static void call_policy_interface (char *verb, struct usb_device *dev, int inter
        envp [i++] = 0;
        /* assert: (scratch - buf) < sizeof buf */
 
        envp [i++] = 0;
        /* assert: (scratch - buf) < sizeof buf */
 
+       //+Wilson12192003
+        #if 0
+       do {
+               if(dev->HubFlag == 1)
+               {
+                       printk("HubFlag = %d  ",dev->HubFlag);
+                       dev->HubFlag = 0;
+                       break;
+               }
+               
+               if(dev->ScsiMount == 1 || dev->ScsiUmount == 1)
+               {
+                       printk("ScsiMount = %d  ScsiUmount = %d  ",dev->ScsiMount, dev->ScsiUmount);
+                       dev->ScsiMount = 0;
+                       dev->ScsiUmount = 0;
+                       break;
+               }
+               wait_ms(10);
+               retries--;
+       } while(retries);
+       printk(" retries = %d\n",retries);
+        #endif
+       //Wilson12192003+
+               
+
        /* NOTE: user mode daemons can call the agents too */
 
        dbg ("kusbd: %s %s %d", argv [0], verb, dev->devnum);
        /* NOTE: user mode daemons can call the agents too */
 
        dbg ("kusbd: %s %s %d", argv [0], verb, dev->devnum);
@@ -2232,6 +2293,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
 int usb_new_device(struct usb_device *dev)
 {
        int err;
 int usb_new_device(struct usb_device *dev)
 {
        int err;
+       int retries = 3; //+Wilson02192004
 
        /* USB v1.1 5.5.3 */
        /* We read the first 8 bytes from the device descriptor to get to */
 
        /* USB v1.1 5.5.3 */
        /* We read the first 8 bytes from the device descriptor to get to */
@@ -2240,7 +2302,14 @@ int usb_new_device(struct usb_device *dev)
        dev->epmaxpacketin [0] = 8;
        dev->epmaxpacketout[0] = 8;
 
        dev->epmaxpacketin [0] = 8;
        dev->epmaxpacketout[0] = 8;
 
+       //call_policy("failure", dev);  //+Wilson11042003
+       wait_ms(10);    //+Wilson03172004, due to some flash drives failed to work 
+       
+       do { //+Wilson 10/16/2003
        err = usb_set_address(dev);
        err = usb_set_address(dev);
+               retries--;      //+Wilson02192004
+       } while((err<0) && retries);    //+Wilson 10/16/2003
+
        if (err < 0) {
                err("USB device not accepting new address=%d (error=%d)",
                        dev->devnum, err);
        if (err < 0) {
                err("USB device not accepting new address=%d (error=%d)",
                        dev->devnum, err);