/* Called by the usb core when the device is removed from the system.  */
static void ld_usb_disconnect(struct usb_interface *intf)
/* Called by the usb core when the device is removed from the system.  */
static void ld_usb_disconnect(struct usb_interface *intf)
{
	struct ld_usb *dev;
	int minor;
	dev = usb_get_intfdata(intf);
	usb_set_intfdata(intf, NULL);
	minor = intf->minor;
	usb_deregister_dev(intf, &ld_usb_class);
	mutex_lock(&dev->mutex);
	if (!dev->open_count) {
		mutex_unlock(&dev->mutex);
		ld_usb_delete(dev);
	} else {
		dev->intf = NULL;
		wake_up_interruptible_all(&dev->read_wait);
		wake_up_interruptible_all(&dev->write_wait);
		mutex_unlock(&dev->mutex);
	}
	dev_info(&intf->dev, "LD USB Device #%d now disconnected\n",
		 (minor - USB_LD_MINOR_BASE));
}