]> git.zerfleddert.de Git - usb-driver/commitdiff
add xpcu_set_interface
authorMichael Gernoth <michael@gernoth.net>
Fri, 11 Apr 2008 13:36:07 +0000 (15:36 +0200)
committerMichael Gernoth <michael@gernoth.net>
Fri, 11 Apr 2008 13:36:07 +0000 (15:36 +0200)
usb-driver.c
xpcu.c
xpcu.h

index 566b10b0d8e056c49675198f0a0f0adac1f7bedb..1a37f54255ec4d098792163def8066eed65b0a0d 100644 (file)
@@ -229,20 +229,7 @@ static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
 #ifndef NO_WINDRVR
                                ret = (*ioctl_func) (fd, request, wdioctl);
 #else
 #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,
 #endif
                                DPRINTF("unique: %lu, interfacenum: %lu, alternatesetting: %lu, options: %lx\n",
                                usi->dwUniqueID, usi->dwInterfaceNum,
diff --git a/xpcu.c b/xpcu.c
index 17ab7cb7a2f6de6839387ef9106bb8410e220200..de23d9eb8f69009d73362e3c6ce8fcde92c4a387 100644 (file)
--- a/xpcu.c
+++ b/xpcu.c
@@ -232,6 +232,23 @@ int xpcu_transfer(struct xpcu_s *xpcu, struct usb_transfer *ut) {
        return ret;
 }
 
        return ret;
 }
 
+void xpcu_set_interface(struct xpcu_s *xpcu, struct usb_set_interface *usi) {
+       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;
+       }
+}
+
 struct xpcu_s *xpcu_open(void) {
        static struct xpcu_s xpcu;
 
 struct xpcu_s *xpcu_open(void) {
        static struct xpcu_s xpcu;
 
diff --git a/xpcu.h b/xpcu.h
index fb8fd554eeddc99ef9089b22cd78c48d22663625..eeb25eba81cb31b081fb5acb2e99803c7f5ea039 100644 (file)
--- a/xpcu.h
+++ b/xpcu.h
@@ -11,5 +11,6 @@ struct xpcu_s {
 
 int __attribute__ ((visibility ("hidden"))) xpcu_deviceinfo(struct xpcu_s *xpcu, unsigned char *buf);
 int __attribute__ ((visibility ("hidden"))) xpcu_transfer(struct xpcu_s *xpcu, struct usb_transfer *ut);
 
 int __attribute__ ((visibility ("hidden"))) xpcu_deviceinfo(struct xpcu_s *xpcu, unsigned char *buf);
 int __attribute__ ((visibility ("hidden"))) xpcu_transfer(struct xpcu_s *xpcu, struct usb_transfer *ut);
+void __attribute__ ((visibility ("hidden"))) xpcu_set_interface(struct xpcu_s *xpcu, struct usb_set_interface *usi);
 struct xpcu_s __attribute__ ((visibility ("hidden"))) *xpcu_open(void);
 void __attribute__ ((visibility ("hidden"))) xpcu_close(struct xpcu_s *xpcu);
 struct xpcu_s __attribute__ ((visibility ("hidden"))) *xpcu_open(void);
 void __attribute__ ((visibility ("hidden"))) xpcu_close(struct xpcu_s *xpcu);
Impressum, Datenschutz