]> git.zerfleddert.de Git - usb-driver/commitdiff
fix handling of XILINX_USB_DEV environment variable
authorMichael Gernoth <michael@gernoth.net>
Sat, 12 Apr 2008 15:40:32 +0000 (17:40 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sat, 12 Apr 2008 15:40:32 +0000 (17:40 +0200)
xpcu.c

diff --git a/xpcu.c b/xpcu.c
index 6ee54d841fa9b1bf7e38b1ea9bb13c5f723b6c4e..8e400b24ec6cbf56a74da28ac69a72d6bab6eed3 100644 (file)
--- a/xpcu.c
+++ b/xpcu.c
@@ -300,15 +300,13 @@ static void xpcu_init(void) {
        usb_find_devices();
 
        busses = usb_get_busses();
        usb_find_devices();
 
        busses = usb_get_busses();
-
-       pthread_mutex_init(&dummy_interrupt, NULL);
 }
 
 
 int xpcu_find(struct event *e) {
        struct xpcu_event_s *xpcu_event = NULL;
        struct xpcu_s *xpcu = NULL;
 }
 
 
 int xpcu_find(struct event *e) {
        struct xpcu_event_s *xpcu_event = NULL;
        struct xpcu_s *xpcu = NULL;
-       char* devpos;
+       char* usbdev;
        struct usb_bus *bus;
        int busnum = -1, devnum = -1;
        int i;
        struct usb_bus *bus;
        int busnum = -1, devnum = -1;
        int i;
@@ -317,20 +315,15 @@ int xpcu_find(struct event *e) {
 
        xpcu_init();
 
 
        xpcu_init();
 
-       xpcu_event = malloc(sizeof(struct xpcu_event_s));
-       if (!xpcu_event)
-               return -ENOMEM;
-
-       bzero(xpcu_event, sizeof(struct xpcu_event_s));
-       xpcu_event->xpcu = NULL;
-       xpcu_event->count = 0;
-       xpcu_event->interrupt_count = 0;
-       pthread_mutex_init(&xpcu_event->interrupt, NULL);
-
-       devpos = getenv("XILINX_USB_DEV");
-       if (devpos != NULL) {
+       usbdev = getenv("XILINX_USB_DEV");
+       if (usbdev != NULL) {
                int j;
                char *devstr = NULL, *remainder;
                int j;
                char *devstr = NULL, *remainder;
+               char *devpos;
+
+               devpos = strdup(usbdev);
+               if (!devpos)
+                       return -ENOMEM;
 
                DPRINTF("XILINX_USB_DEV=%s\n", devpos);
 
 
                DPRINTF("XILINX_USB_DEV=%s\n", devpos);
 
@@ -356,8 +349,19 @@ int xpcu_find(struct event *e) {
                                }
                        }
                }
                                }
                        }
                }
+               free(devpos);
        }
 
        }
 
+       xpcu_event = malloc(sizeof(struct xpcu_event_s));
+       if (!xpcu_event)
+               return -ENOMEM;
+
+       bzero(xpcu_event, sizeof(struct xpcu_event_s));
+       xpcu_event->xpcu = NULL;
+       xpcu_event->count = 0;
+       xpcu_event->interrupt_count = 0;
+       pthread_mutex_init(&xpcu_event->interrupt, NULL);
+
        for (i = 0; i < e->dwNumMatchTables; i++) {
 
                DPRINTF("match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
        for (i = 0; i < e->dwNumMatchTables; i++) {
 
                DPRINTF("match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
Impressum, Datenschutz