set_bit(US_FLIDX_DISCONNECTING, &us->flags); usb_stor_release_resources(us); dissociate_dev(us); scsi_host_put(host); 
release_everything(us); 
static int storage_probe(struct usb_interface *intf,			 const struct usb_device_id *id){	struct Scsi_Host *host;	struct us_data *us;	const int id_index = id - storage_usb_ids; 	int result;	US_DEBUGP("USB Mass Storage device detected\n");	/*	 * Ask the SCSI layer to allocate a host structure, with extra	 * space at the end for our private us_data structure.	 */	host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));	if (!host) {		printk(KERN_WARNING USB_STORAGE			"Unable to allocate the scsi host\n");		return -ENOMEM;	}	us = host_to_us(host);	memset(us, 0, sizeof(struct us_data));	init_MUTEX(&(us->dev_semaphore));	init_MUTEX_LOCKED(&(us->sema));	init_completion(&(us->notify));	init_waitqueue_head(&us->delay_wait);	/* Associate the us_data structure with the USB device */	result = associate_dev(us, intf);	if (result)		goto BadDevice;	/*	 * Get the unusual_devs entries and the descriptors	 *	 * id_index is calculated in the declaration to be the index number	 * of the match from the usb_device_id table, so we can find the	 * corresponding entry in the private table.	 */	get_device_info(us, id_index);#ifdef CONFIG_USB_STORAGE_SDDR09	if (us->protocol == US_PR_EUSB_SDDR09 ||			us->protocol == US_PR_DPCM_USB) {		/* set the configuration -- STALL is an acceptable response here */		if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) {			US_DEBUGP("active config #%d != 1 ??\n", us->pusb_dev				->actconfig->desc.bConfigurationValue);			goto BadDevice;		}		result = usb_reset_configuration(us->pusb_dev);		US_DEBUGP("Result of usb_reset_configuration is %d\n", result);		if (result == -EPIPE) {			US_DEBUGP("-- stall on control interface\n");		} else if (result != 0) {			/* it's not a stall, but another error -- time to bail */			US_DEBUGP("-- Unknown error.  Rejecting device\n");			goto BadDevice;		}	}#endif	/* Get the transport, protocol, and pipe settings */	result = get_transport(us);	if (result)		goto BadDevice;	result = get_protocol(us);	if (result)		goto BadDevice;	result = get_pipes(us);	if (result)		goto BadDevice;	/* Acquire all the other resources and add the host */	result = usb_stor_acquire_resources(us);	if (result)		goto BadDevice;	result = scsi_add_host(host, &intf->dev);	if (result) {		printk(KERN_WARNING USB_STORAGE			"Unable to add the scsi host\n");		goto BadDevice;	}	/* Start up the thread for delayed SCSI-device scanning */	result = kernel_thread(usb_stor_scan_thread, us, CLONE_VM);	if (result < 0) {		printk(KERN_WARNING USB_STORAGE 		       "Unable to start the device-scanning thread\n");		scsi_remove_host(host);		goto BadDevice;	}	atomic_inc(&total_threads);	/* Wait for the thread to start */	wait_for_completion(&(us->notify));	return 0;	/* We come here if there are any problems */BadDevice:	US_DEBUGP("storage_probe() failed\n");	set_bit(US_FLIDX_DISCONNECTING, &us->flags);	usb_stor_release_resources(us);	dissociate_dev(us);	scsi_host_put(host);	return result;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/77f46328fb83b64befd889ebce6d7fb959932509/usb.c/buggy/drivers/usb/storage/usb.c