qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/2] Return usb device to host on exit


From: Shahar Havivi
Subject: [Qemu-devel] [PATCH 2/2] Return usb device to host on exit
Date: Sat, 12 Jun 2010 12:59:50 +0300
User-agent: Mutt/1.5.20 (2009-08-17)

Signed-off-by: Shahar Havivi <address@hidden>
---
 usb-linux.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index 22a85e3..2a595f0 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -286,6 +286,17 @@ static void async_cancel(USBPacket *unused, void *opaque)
     }
 }
 
+static void usb_host_cleanup(void)
+{
+    struct USBHostDevice *s;
+
+    QTAILQ_FOREACH(s, &hostdevs, next) {
+        if (s->fd != -1) {
+            ioctl(s->fd, USBDEVFS_RESET);
+        }
+    }
+}
+
 static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
 {
     int dev_descr_len, config_descr_len;
@@ -1066,6 +1077,7 @@ USBDevice *usb_host_device_open(const char *devname)
     qdev_prop_set_uint32(&dev->qdev, "vendorid",  filter.vendor_id);
     qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);
     qdev_init_nofail(&dev->qdev);
+    atexit(usb_host_cleanup);
     return dev;
 
 fail:
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]