]> cvs.zerfleddert.de Git - usb-driver/blobdiff - usb-driver.c
release usb-device on close
[usb-driver] / usb-driver.c
index a0524bf67d521ed5cc84a0aa5cf0f10267768936..1162d51b98836e377911c0321e996c07058cf569 100644 (file)
@@ -450,8 +450,15 @@ static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
                                ret = (*ioctl_func) (fd, request, wdioctl);
 #else
                                if (usbdevice) {
                                ret = (*ioctl_func) (fd, request, wdioctl);
 #else
                                if (usbdevice) {
-                                       if (!usb_devhandle)
+                                       if (!usb_devhandle) {
                                                usb_devhandle = usb_open(usbdevice);
                                                usb_devhandle = usb_open(usbdevice);
+#ifndef NO_USB_RESET
+                                               if (usb_devhandle) {
+                                                       usb_reset(usb_devhandle);
+                                                       usb_devhandle = usb_open(usbdevice);
+                                               }
+#endif
+                                       }
 
                                        usbinterface = usbdevice->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber;
                                        usbalternate = usi->dwAlternateSetting;
 
                                        usbinterface = usbdevice->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber;
                                        usbalternate = usi->dwAlternateSetting;
@@ -851,8 +858,10 @@ int close(int fd) {
        if (fd == windrvrfd && windrvrfd >= 0) {
                DPRINTF("close windrvrfd\n");
 
        if (fd == windrvrfd && windrvrfd >= 0) {
                DPRINTF("close windrvrfd\n");
 
-               if (usb_devhandle)
+               if (usb_devhandle) {
+                       usb_claim(0);
                        usb_close(usb_devhandle);
                        usb_close(usb_devhandle);
+               }
 
                usb_devhandle = NULL;
                usbinterface = -1;
 
                usb_devhandle = NULL;
                usbinterface = -1;
Impressum, Datenschutz