From: Gerd Hoffmann Date: Fri, 28 Oct 2011 14:13:50 +0000 (+0200) Subject: usb-host: fix host close X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~2149^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fafa0b6cb1a558e5702d30901aa2696cd241113;p=sdk%2Femulator%2Fqemu.git usb-host: fix host close The whole usb_host_close() function is skipped in case the device is not in attached state. This is wrong though, only then usb_device_detach() must be skipped, all other cleanup (especially device reset and closing the file handle) still needs to be done. There are code paths where usb_host_close() is called with the device in detached state already. This fixes usb-host devices not being released and returned to the host after removing them with device_del. Signed-off-by: Gerd Hoffmann --- diff --git a/usb-linux.c b/usb-linux.c index 7d4d1d7bcf..f086d57edb 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -1349,7 +1349,7 @@ static int usb_host_close(USBHostDevice *dev) { int i; - if (dev->fd == -1 || !dev->dev.attached) { + if (dev->fd == -1) { return -1; } @@ -1367,7 +1367,9 @@ static int usb_host_close(USBHostDevice *dev) } async_complete(dev); dev->closing = 0; - usb_device_detach(&dev->dev); + if (dev->dev.attached) { + usb_device_detach(&dev->dev); + } ioctl(dev->fd, USBDEVFS_RESET); close(dev->fd); dev->fd = -1;