struct gendisk *disk = sc->disk; 
struct list_head *p; struct ub_lun *lun; struct gendisk *disk; 
static void ub_disconnect(struct usb_interface *intf){	struct ub_dev *sc = usb_get_intfdata(intf);	struct gendisk *disk = sc->disk;	unsigned long flags;	/*	 * Prevent ub_bd_release from pulling the rug from under us.	 * XXX This is starting to look like a kref.	 * XXX Why not to take this ref at probe time?	 */	spin_lock_irqsave(&ub_lock, flags);	sc->openc++;	spin_unlock_irqrestore(&ub_lock, flags);	/*	 * Fence stall clearnings, operations triggered by unlinkings and so on.	 * We do not attempt to unlink any URBs, because we do not trust the	 * unlink paths in HC drivers. Also, we get -84 upon disconnect anyway.	 */	atomic_set(&sc->poison, 1);	/*	 * Blow away queued commands.	 *	 * Actually, this never works, because before we get here	 * the HCD terminates outstanding URB(s). It causes our	 * SCSI command queue to advance, commands fail to submit,	 * and the whole queue drains. So, we just use this code to	 * print warnings.	 */	spin_lock_irqsave(&sc->lock, flags);	{		struct ub_scsi_cmd *cmd;		int cnt = 0;		while ((cmd = ub_cmdq_pop(sc)) != NULL) {			cmd->error = -ENOTCONN;			cmd->state = UB_CMDST_DONE;			ub_cmdtr_state(sc, cmd);			ub_cmdq_pop(sc);			(*cmd->done)(sc, cmd);			cnt++;		}		if (cnt != 0) {			printk(KERN_WARNING "%s: "			    "%d was queued after shutdown\n", sc->name, cnt);		}	}	spin_unlock_irqrestore(&sc->lock, flags);	/*	 * Unregister the upper layer.	 */	if (disk->flags & GENHD_FL_UP)		del_gendisk(disk);	/*	 * I wish I could do:	 *    set_bit(QUEUE_FLAG_DEAD, &q->queue_flags);	 * As it is, we rely on our internal poisoning and let	 * the upper levels to spin furiously failing all the I/O.	 */	/*	 * Taking a lock on a structure which is about to be freed	 * is very nonsensual. Here it is largely a way to do a debug freeze,	 * and a bracket which shows where the nonsensual code segment ends.	 *	 * Testing for -EINPROGRESS is always a bug, so we are bending	 * the rules a little.	 */	spin_lock_irqsave(&sc->lock, flags);	if (sc->work_urb.status == -EINPROGRESS) {	/* janitors: ignore */		printk(KERN_WARNING "%s: "		    "URB is active after disconnect\n", sc->name);	}	spin_unlock_irqrestore(&sc->lock, flags);	/*	 * There is virtually no chance that other CPU runs times so long	 * after ub_urb_complete should have called del_timer, but only if HCD	 * didn't forget to deliver a callback on unlink.	 */	del_timer_sync(&sc->work_timer);	/*	 * At this point there must be no commands coming from anyone	 * and no URBs left in transit.	 */	device_remove_file(&sc->intf->dev, &dev_attr_diag);	usb_set_intfdata(intf, NULL);	// usb_put_intf(sc->intf);	sc->intf = NULL;	usb_put_dev(sc->dev);	sc->dev = NULL;	ub_put(sc);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/f4800078d9ed4bd20b1b27f56e7b68cfa0d73038/ub.c/clean/drivers/block/ub.c