usbfs: send disconnect signals when device is unregistered
[deliverable/linux.git] / drivers / usb / core / devio.c
index 9218cca210431dea3b840e85b4fa9a0f0653a3fd..bbd029f68faaeb4755ee4bf01d3f83c829e7e5f9 100644 (file)
@@ -19,8 +19,6 @@
  *      along with this program; if not, write to the Free Software
  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- *  $Id: devio.c,v 1.7 2000/02/01 17:28:48 fliegl Exp $
- *
  *  This file implements the usbfs/x/y files, where
  *  x is the bus number and y the device number.
  *
 /* Mutual exclusion for removal, open, and release */
 DEFINE_MUTEX(usbfs_mutex);
 
+struct dev_state {
+       struct list_head list;      /* state list */
+       struct usb_device *dev;
+       struct file *file;
+       spinlock_t lock;            /* protects the async urb lists */
+       struct list_head async_pending;
+       struct list_head async_completed;
+       wait_queue_head_t wait;     /* wake up if a request completed */
+       unsigned int discsignr;
+       struct pid *disc_pid;
+       uid_t disc_uid, disc_euid;
+       void __user *disccontext;
+       unsigned long ifclaimed;
+       u32 secid;
+};
+
 struct async {
        struct list_head asynclist;
        struct dev_state *ps;
@@ -874,7 +888,7 @@ static int proc_connectinfo(struct dev_state *ps, void __user *arg)
 
 static int proc_resetdevice(struct dev_state *ps)
 {
-       return usb_reset_composite_device(ps->dev, NULL);
+       return usb_reset_device(ps->dev);
 }
 
 static int proc_setintf(struct dev_state *ps, void __user *arg)
@@ -1682,6 +1696,28 @@ const struct file_operations usbdev_file_operations = {
        .release =      usbdev_release,
 };
 
+void usb_fs_classdev_common_remove(struct usb_device *udev)
+{
+       struct dev_state *ps;
+       struct siginfo sinfo;
+
+       while (!list_empty(&udev->filelist)) {
+               ps = list_entry(udev->filelist.next, struct dev_state, list);
+               destroy_all_async(ps);
+               wake_up_all(&ps->wait);
+               list_del_init(&ps->list);
+               if (ps->discsignr) {
+                       sinfo.si_signo = ps->discsignr;
+                       sinfo.si_errno = EPIPE;
+                       sinfo.si_code = SI_ASYNCIO;
+                       sinfo.si_addr = ps->disccontext;
+                       kill_pid_info_as_uid(ps->discsignr, &sinfo,
+                                       ps->disc_pid, ps->disc_uid,
+                                       ps->disc_euid, ps->secid);
+               }
+       }
+}
+
 #ifdef CONFIG_USB_DEVICE_CLASS
 static struct class *usb_classdev_class;
 
@@ -1701,6 +1737,7 @@ static int usb_classdev_add(struct usb_device *dev)
 static void usb_classdev_remove(struct usb_device *dev)
 {
        device_unregister(dev->usb_classdev);
+       usb_fs_classdev_common_remove(dev);
 }
 
 static int usb_classdev_notify(struct notifier_block *self,
This page took 0.027825 seconds and 5 git commands to generate.