--- R29/drivers/usb/storage/usb.c 2004-08-30 07:54:48.000000000 +0100 +++ R63/drivers/usb/storage/usb.c 2004-10-08 06:04:20.000000000 +0100 @@ -1,6 +1,6 @@ /* Driver for USB Mass Storage compliant devices * - * $Id: usb.c,v 1.2 2004/08/30 06:54:48 sure Exp $ + * $Id: usb.c,v 1.2 2004/10/08 03:41:34 pete Exp $ * * Current development and maintenance by: * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) @@ -561,7 +561,7 @@ GUID(guid); /* Global Unique Identifier */ unsigned int flags; struct us_unusual_dev *unusual_dev; - struct us_data *ss = NULL, *pre_ss, *tmp /* grant */; + struct us_data *ss = NULL; /* grant */; #ifdef CONFIG_USB_STORAGE_SDDR09 int result; #endif @@ -705,23 +705,11 @@ */ ss = us_list; /* modified to free unusable node by grant */ - pre_ss = us_list; + while ((ss != NULL) && ((ss->pusb_dev) || !GUID_EQUAL(guid, ss->guid))) - { - pre_ss = ss; ss = ss->next; - } - /* end mod */ -//super add -#if 0 - if (ss != NULL){ - scsi_unregister_module(MODULE_SCSI_HA, &(ss->htmplt)); - free_us_data( pre_ss, ss ); - usb_dec_dev_use(dev); - } -#endif -// + if (ss != NULL) { /* Existing device -- re-connect */ US_DEBUGP("Found existing GUID " GUID_FORMAT "\n", @@ -747,93 +735,6 @@ USB_ENDPOINT_NUMBER_MASK; ss->ep_int = ep_int; - /* grant 01/30 */ -#if 0 - if ( 0x32 != dev->bus->bus_name[6] ) - { - dev->devpath[0] = dev->bus->bus_name[6] + 1; - } - /* restrict device on certain port */ - if ( ss->htmplt.removable ^ (USB_DEVPATH_2 == dev->devpath[0]) ) - { - printk("* (old)%s disk not allowed on port:%s\n", ss->htmplt.removable ? "flash" : "hard", dev->devpath); - usb_dec_dev_use(dev); - scsi_unregister_module(MODULE_SCSI_HA, &(ss->htmplt)); - free_us_data( pre_ss, ss ); - return NULL; - } - if (ss->htmplt.removable){ - // add by super - remove_proc_entry("usb_conn",NULL); - *IXP425_GPIO_GPOUTR &= 0xfffb; - create_proc_read_entry("usb_conn", - 0, - NULL, - NULL, - NULL - ); - }else{ - remove_proc_entry("hd_conn",NULL); - *IXP425_GPIO_GPOUTR &= 0xfff7; - create_proc_read_entry("hd_conn", - 0, - NULL, - NULL, - NULL - ); - } - printk("rscsi_disk capacity is %d@@@@@@@@@@@@@@@@\n",ss->host->host_queue->sector_size); - if(ss->host->host_queue->sector_size<40000000){ - ss->htmplt.removable = 1; - } -#endif - /* restrict device on certain port */ - if ( ss->htmplt.removable && (USB_DEVPATH_1 == dev->devpath[0])) - if ( ss->htmplt.removable ^ (USB_DEVPATH_2 == dev->devpath[0]) ) - { - create_proc_read_entry("usb_err", - 0, - NULL, - NULL, - NULL - ); - printk("* (old)%s disk not allowed on port:%s\n", ss->htmplt.removable ? "flash" : "hard", dev->devpath); - usb_dec_dev_use(dev); - scsi_unregister_module(MODULE_SCSI_HA, &(ss->htmplt)); - free_us_data( pre_ss, ss ); - return NULL; - } - if (ss->htmplt.removable){ - printk("is removable disk \n"); - *IXP425_GPIO_GPOUTR &= 0xfffb; - create_proc_read_entry("usb_conn", - 0, - NULL, - NULL, - NULL - ); - }else { - printk("%x port connect\n",dev->devpath[0]); - if(0x31 == dev->devpath[0]){ - *IXP425_GPIO_GPOUTR &= 0xfff7; - create_proc_read_entry("hd_conn", - 0, - NULL, - NULL, - NULL - ); - }else{ - *IXP425_GPIO_GPOUTR &= 0xfffb; - create_proc_read_entry("hd2_conn", - 0, - NULL, - NULL, - NULL - ); - } - } - //end - /* allocate an IRQ callback if one is needed */ if ((ss->protocol == US_PR_CBI) && usb_stor_allocate_irq(ss)) { usb_dec_dev_use(dev); @@ -855,6 +756,23 @@ up(&(ss->dev_semaphore)); } else { +#if 0 + //grant,pete + if ( ss->htmplt.removable ^ (USB_DEVPATH_2 == dev->devpath[0]) ) + { + create_proc_read_entry("usb_err", + 0, + NULL, + NULL, + NULL + ); + printk("* (old)%s disk not allowed on port:%s\n", ss->htmplt.removable ? "flash" : "hard", dev->devpath); + usb_dec_dev_use(dev); + scsi_unregister_module(MODULE_SCSI_HA, &(ss->htmplt)); + return NULL; + } + // +#endif /* New device -- allocate memory and initialize */ US_DEBUGP("New GUID " GUID_FORMAT "\n", GUID_ARGS(guid)); @@ -1101,11 +1019,7 @@ sizeof(usb_stor_host_template)); /* Grab the next host number */ - //ss->host_number = my_host_number++; - - /* fix device name & host number by grant */ -// ss->host_number = dev->devpath[0] - USB_DEVPATH_1 ; - ss->host_number = USB_DEVPATH_2 - dev->devpath[0]; + ss->host_number = my_host_number++; /* We abuse this pointer so we can pass the ss pointer to * the host controller thread in us_detect. But how else are @@ -1117,7 +1031,6 @@ * the device if it needs initialization */ if (unusual_dev && unusual_dev->initFunction) unusual_dev->initFunction(ss); - printk("before kernel thread \n"); /* start up our control thread */ ss->pid = kernel_thread(usb_stor_control_thread, ss, CLONE_VM); @@ -1135,60 +1048,11 @@ /* now register - our detect function will be called */ ss->htmplt.module = THIS_MODULE; - /*debug by grant*/ -// printk("!! 1\n"); - /* grant 01/30 */ - // printk ("* bus = %c\n", dev->bus->bus_name[6]); - #if 0 - if ( 0x32 != dev->bus->bus_name[6] ) - { - dev->devpath[0] = dev->bus->bus_name[6] + 1; - // dev->devpath[0] = 0x32; - } -// printk("devpath = %c\n",dev->devpath[0]); -#endif ss->htmplt.port = dev->devpath[0]; - tmp = us_list; - pre_ss = tmp; - while ( NULL != tmp ) - { - /* free old device node by grant */ - if( (tmp->htmplt.port == ss->htmplt.port) && (!GUID_EQUAL(tmp->guid, ss->guid)) ) - { - scsi_unregister_module(MODULE_SCSI_HA, &(tmp->htmplt)); -// printk("* (2)scsi_unregister_module\n"); - free_us_data( pre_ss, tmp ); - break; - } - pre_ss = tmp; - tmp = tmp->next; - } - scsi_register_module(MODULE_SCSI_HA, &(ss->htmplt)); - /* check device port grant */ - if ( 1 == ss->host->porttype ) - { -// printk("* (usb)scsi_unregister_module\n"); - scsi_unregister_module(MODULE_SCSI_HA, &(ss->htmplt)); - kfree(ss->current_urb); - kfree(ss); - usb_dec_dev_use(dev); - return NULL; - } - - /* debug grant */ - i = 0; - tmp = us_list; - while ( NULL != tmp ) - { - i ++; - tmp = tmp->next; - } -// printk("* (usb)scsi_register_module okay! us_data:%d\n", i ); - /* lock access to the data structures */ down(&us_list_semaphore); @@ -1237,34 +1101,18 @@ } - /* Handle a disconnect event from the USB core */ static void storage_disconnect(struct usb_device *dev, void *ptr) { struct us_data *ss = ptr; -// struct us_data *pre_ss; + struct us_data *tmp,*pre_ss; int result; -//super add - char serial[USB_STOR_STRING_LEN]; /* serial number */ -// GUID(guid); /* Global Unique Identifier */ -//super modify - switch(dev->devpath[0]){ - case 0x31: - *IXP425_GPIO_GPOUTR |= 0x8; - remove_proc_entry("hd_conn",NULL); - break; - case 0x32: - *IXP425_GPIO_GPOUTR |= 0x4; - remove_proc_entry("usb_conn",NULL); - remove_proc_entry("hd2_conn",NULL); - break; - default: - break; - } -//end + //Pete + int i; + // + US_DEBUGP("storage_disconnect() called\n"); - memset(serial,0,USB_STOR_STRING_LEN); /* this is the odd case -- we disconnected but weren't using it */ if (!ss) { US_DEBUGP("-- device was not in use\n"); @@ -1274,6 +1122,35 @@ /* lock access to the device data structure */ down(&(ss->dev_semaphore)); + tmp = us_list; + pre_ss = tmp; + i = 0; + + while ( tmp != NULL ) + { + if( (tmp->htmplt.port == ss->htmplt.port) && (GUID_EQUAL(tmp->guid, ss->guid)) ) + { + scsi_unregister_module(MODULE_SCSI_HA, &(tmp->htmplt)); + if( ss == us_list ) + { + us_list = ss->next; + } + else if( ss->next == NULL ) + { + pre_ss->next = NULL; + } + else + { + pre_ss->next = ss->next; + } + + break; + } + i++; + pre_ss = tmp; + tmp = tmp->next; + } + if(ss->extra && ss->extra_destructor){ ss->extra_destructor(ss->extra); }