X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/blobdiff_plain/6c235d59caa48963278183c19762c80dbabdec2e..4f3471859a885ff6a84306d0e7d00e6e2e9a17f8:/usb-driver.c diff --git a/usb-driver.c b/usb-driver.c index 53a0309..9ed0c35 100644 --- a/usb-driver.c +++ b/usb-driver.c @@ -55,7 +55,6 @@ static FILE *modulesfp = NULL; static FILE *baseaddrfp = NULL; static int baseaddrnum = 0; static int modules_read = 0; -static unsigned long card_type; static int ints_enabled = 0; static pthread_mutex_t int_wait = PTHREAD_MUTEX_INITIALIZER; @@ -229,20 +228,7 @@ static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { #ifndef NO_WINDRVR ret = (*ioctl_func) (fd, request, wdioctl); #else - if (xpcu->dev) { - if (!xpcu->handle) { - xpcu->handle = usb_open(xpcu->dev); -#ifndef NO_USB_RESET - if (xpcu->handle) { - usb_reset(xpcu->handle); - xpcu->handle = usb_open(xpcu->dev); - } -#endif - } - - xpcu->interface = xpcu->dev->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber; - xpcu->alternate = usi->dwAlternateSetting; - } + xpcu_set_interface(xpcu, usi); #endif DPRINTF("unique: %lu, interfacenum: %lu, alternatesetting: %lu, options: %lx\n", usi->dwUniqueID, usi->dwInterfaceNum, @@ -364,7 +350,7 @@ static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { /* TODO: check interfaceClass! */ DPRINTF("found device with libusb\n"); xpcu->dev = dev; - card_type = e->dwCardType; + xpcu->card_type = e->dwCardType; } } } @@ -525,7 +511,7 @@ static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { if (xpcu->dev) { struct usb_interface *interface = xpcu->dev->config->interface; - e->dwCardType = card_type; + e->dwCardType = xpcu->card_type; e->dwAction = 1; e->dwEventId = 109; e->u.Usb.dwUniqueID = 110; @@ -633,13 +619,9 @@ int close(int fd) { if (fd == windrvrfd && windrvrfd >= 0) { DPRINTF("close windrvrfd\n"); - if (xpcu->handle) { - xpcu_claim(xpcu, XPCU_RELEASE); - usb_close(xpcu->handle); - } + if (xpcu) + xpcu_close(xpcu); - xpcu->handle = NULL; - xpcu->interface = -1; xpcu = NULL; windrvrfd = -1; }