/* Called by the usb core when the device is removed from the system.  */
static void usb_alphatrack_disconnect(struct usb_interface *intf)
/* Called by the usb core when the device is removed from the system.  */
static void usb_alphatrack_disconnect(struct usb_interface *intf)
{
	struct usb_alphatrack *dev;
	int minor;
	mutex_lock(&disconnect_mutex);
	dev = usb_get_intfdata(intf);
	usb_set_intfdata(intf, NULL);
	down(&dev->sem);
	minor = intf->minor;
	usb_deregister_dev(intf, &usb_alphatrack_class);
	if (!dev->open_count) {
		up(&dev->sem);
		usb_alphatrack_delete(dev);
	} else {
		dev->intf = NULL;
		up(&dev->sem);
	}
	atomic_set(&dev->writes_pending, 0);
	mutex_unlock(&disconnect_mutex);
	dev_info(&intf->dev, "Alphatrack Surface #%d now disconnected\n",
		 (minor - USB_ALPHATRACK_MINOR_BASE));
}