]> git.zerfleddert.de Git - usb-driver/commitdiff
make it possible to return an error everywhere
authorMichael Gernoth <michael@gernoth.net>
Sat, 12 Apr 2008 13:13:26 +0000 (15:13 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sat, 12 Apr 2008 13:13:26 +0000 (15:13 +0200)
usb-driver.c
xpcu.c
xpcu.h

index 0383d123d034d62188bc63fc6c09b86ca1a149f3..b4d34146efb65c1502f462c1ebe30ab55360236f 100644 (file)
@@ -156,7 +156,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
-                               xpcu_transfer(xpcu, ut);
+                               ret = xpcu_transfer(xpcu, ut);
 #endif
 
 #ifdef DEBUG
 #endif
 
 #ifdef DEBUG
@@ -184,7 +184,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
-                               xpcu_int_state(xpcu, it, ENABLE_INTERRUPT);
+                               ret = xpcu_int_state(xpcu, it, ENABLE_INTERRUPT);
 #endif
 
                                DPRINTF("<- Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
 #endif
 
                                DPRINTF("<- Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
@@ -207,7 +207,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
-                               xpcu_int_state(xpcu, it, DISABLE_INTERRUPT);
+                               ret = xpcu_int_state(xpcu, it, DISABLE_INTERRUPT);
 #endif
                                DPRINTF("<- Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
                                it->hInterrupt, it->dwOptions,
 #endif
                                DPRINTF("<- Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
                                it->hInterrupt, it->dwOptions,
@@ -227,7 +227,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
-                               xpcu_set_interface(xpcu, usi);
+                               ret = xpcu_set_interface(xpcu, usi);
 #endif
                                DPRINTF("<- unique: 0x%lx, interfacenum: %lu, alternatesetting: %lu, options: %lx\n",
                                usi->dwUniqueID, usi->dwInterfaceNum,
 #endif
                                DPRINTF("<- unique: 0x%lx, interfacenum: %lu, alternatesetting: %lu, options: %lx\n",
                                usi->dwUniqueID, usi->dwInterfaceNum,
@@ -245,7 +245,7 @@ static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
                                ugdd->dwUniqueID, ugdd->dwBytes,
                                ugdd->dwOptions);
 
                                ugdd->dwUniqueID, ugdd->dwBytes,
                                ugdd->dwOptions);
 
-                               ugdd->dwBytes = xpcu_deviceinfo(xpcu, ugdd);
+                               ret = xpcu_deviceinfo(xpcu, ugdd);
 
                        }
                        break;
 
                        }
                        break;
@@ -333,7 +333,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
-                               xpcu_close(xpcu, e);
+                               ret = xpcu_close(xpcu, e);
 #endif
                        }
                        break;
 #endif
                        }
                        break;
@@ -351,7 +351,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
-                               xpcu_int_wait(xpcu, it);
+                               ret = xpcu_int_wait(xpcu, it);
 #endif
 
                                DPRINTF("<- INT_WAIT_RETURN: Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
 #endif
 
                                DPRINTF("<- INT_WAIT_RETURN: Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
@@ -413,7 +413,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
-                               xpcu_found(xpcu, e);
+                               ret = xpcu_found(xpcu, e);
 #endif
 
 #ifdef DEBUG
 #endif
 
 #ifdef DEBUG
diff --git a/xpcu.c b/xpcu.c
index 9cea2c1b26d22868eca1b97a47217a0b71731574..719829bccbdd0eaa8f9f8af02fcace46fc78cae3 100644 (file)
--- a/xpcu.c
+++ b/xpcu.c
@@ -21,6 +21,9 @@ int xpcu_deviceinfo(struct xpcu_s *xpcu, struct usb_get_device_data *ugdd) {
 
        if (ugdd->dwUniqueID != (unsigned long)xpcu)
                return -ENODEV;
 
        if (ugdd->dwUniqueID != (unsigned long)xpcu)
                return -ENODEV;
+       
+       if (!xpcu)
+               return -ENODEV;
 
        if (ugdd->dwBytes)
                buf = ugdd->pBuf;
 
        if (ugdd->dwBytes)
                buf = ugdd->pBuf;
@@ -176,7 +179,9 @@ int xpcu_deviceinfo(struct xpcu_s *xpcu, struct usb_get_device_data *ugdd) {
                }
        }
 
                }
        }
 
-       return len;
+       ugdd->dwBytes = len;
+
+       return 0;
 }
 
 static int xpcu_claim(struct xpcu_s *xpcu, int claim) {
 }
 
 static int xpcu_claim(struct xpcu_s *xpcu, int claim) {
@@ -217,6 +222,9 @@ int xpcu_transfer(struct xpcu_s *xpcu, struct usb_transfer *ut) {
 
        if (ut->dwUniqueID != (unsigned long)xpcu)
                return -ENODEV;
 
        if (ut->dwUniqueID != (unsigned long)xpcu)
                return -ENODEV;
+       
+       if (!xpcu)
+               return -ENODEV;
 
        xpcu_claim(xpcu, XPCU_CLAIM);
        /* http://www.jungo.com/support/documentation/windriver/802/wdusb_man_mhtml/node55.html#SECTION001213000000000000000 */
 
        xpcu_claim(xpcu, XPCU_CLAIM);
        /* http://www.jungo.com/support/documentation/windriver/802/wdusb_man_mhtml/node55.html#SECTION001213000000000000000 */
@@ -248,9 +256,12 @@ 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) {
+int xpcu_set_interface(struct xpcu_s *xpcu, struct usb_set_interface *usi) {
        if (usi->dwUniqueID != (unsigned long)xpcu)
        if (usi->dwUniqueID != (unsigned long)xpcu)
-               return;
+               return -ENODEV;
+       
+       if (!xpcu)
+               return -ENODEV;
 
        if (xpcu->dev) {
                if (!xpcu->handle) {
 
        if (xpcu->dev) {
                if (!xpcu->handle) {
@@ -266,6 +277,8 @@ void xpcu_set_interface(struct xpcu_s *xpcu, struct usb_set_interface *usi) {
                xpcu->interface = xpcu->dev->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber;
                xpcu->alternate = usi->dwAlternateSetting;
        }
                xpcu->interface = xpcu->dev->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber;
                xpcu->alternate = usi->dwAlternateSetting;
        }
+
+       return 0;
 }
 
 static void xpcu_init(void) {
 }
 
 static void xpcu_init(void) {
@@ -385,7 +398,7 @@ struct xpcu_s *xpcu_find(struct event *e) {
        return &xpcu;
 }
 
        return &xpcu;
 }
 
-void xpcu_found(struct xpcu_s *xpcu, struct event *e) {
+int xpcu_found(struct xpcu_s *xpcu, struct event *e) {
        if (e->handle && e->handle == (unsigned long)xpcu && xpcu->dev) {
                struct usb_interface *interface = xpcu->dev->config->interface;
 
        if (e->handle && e->handle == (unsigned long)xpcu && xpcu->dev) {
                struct usb_interface *interface = xpcu->dev->config->interface;
 
@@ -401,11 +414,16 @@ void xpcu_found(struct xpcu_s *xpcu, struct event *e) {
                e->matchTables[0].bInterfaceSubClass = interface->altsetting[0].bInterfaceSubClass;
                e->matchTables[0].bInterfaceProtocol = interface->altsetting[0].bInterfaceProtocol;
        }
                e->matchTables[0].bInterfaceSubClass = interface->altsetting[0].bInterfaceSubClass;
                e->matchTables[0].bInterfaceProtocol = interface->altsetting[0].bInterfaceProtocol;
        }
+
+       return 0;
 }
 
 }
 
-void xpcu_close(struct xpcu_s *xpcu, struct event *e) {
+int xpcu_close(struct xpcu_s *xpcu, struct event *e) {
        if (e->handle != (unsigned long)xpcu)
        if (e->handle != (unsigned long)xpcu)
-               return;
+               return -ENODEV;
+       
+       if (!xpcu)
+               return -ENODEV;
 
        if(xpcu) {
                if (xpcu->handle) {
 
        if(xpcu) {
                if (xpcu->handle) {
@@ -418,13 +436,15 @@ void xpcu_close(struct xpcu_s *xpcu, struct event *e) {
                xpcu->alternate = -1;
                busses = NULL;
        }
                xpcu->alternate = -1;
                busses = NULL;
        }
+
+       return 0;
 }
 
 }
 
-void xpcu_int_state(struct xpcu_s *xpcu, struct interrupt *it, int enable) {
+int xpcu_int_state(struct xpcu_s *xpcu, struct interrupt *it, int enable) {
        static pthread_mutex_t *interrupt = &dummy_interrupt;
 
        if (it->hInterrupt != (unsigned long)xpcu)
        static pthread_mutex_t *interrupt = &dummy_interrupt;
 
        if (it->hInterrupt != (unsigned long)xpcu)
-               return;
+               return -ENODEV;
        
        if (xpcu)
                interrupt = &xpcu->interrupt;
        
        if (xpcu)
                interrupt = &xpcu->interrupt;
@@ -439,11 +459,13 @@ void xpcu_int_state(struct xpcu_s *xpcu, struct interrupt *it, int enable) {
                if (pthread_mutex_trylock(interrupt) == EBUSY)
                        pthread_mutex_unlock(interrupt);
        }
                if (pthread_mutex_trylock(interrupt) == EBUSY)
                        pthread_mutex_unlock(interrupt);
        }
+
+       return 0;
 }
 
 }
 
-void xpcu_int_wait(struct xpcu_s *xpcu, struct interrupt *it) {
+int xpcu_int_wait(struct xpcu_s *xpcu, struct interrupt *it) {
        if (it->hInterrupt != (unsigned long)xpcu)
        if (it->hInterrupt != (unsigned long)xpcu)
-               return;
+               return -ENODEV;
        
        if (xpcu) {
                if (it->dwCounter == 0) {
        
        if (xpcu) {
                if (it->dwCounter == 0) {
@@ -456,4 +478,6 @@ void xpcu_int_wait(struct xpcu_s *xpcu, struct interrupt *it) {
                pthread_mutex_lock(&dummy_interrupt);
                pthread_mutex_unlock(&dummy_interrupt);
        }
                pthread_mutex_lock(&dummy_interrupt);
                pthread_mutex_unlock(&dummy_interrupt);
        }
+
+       return 0;
 }
 }
diff --git a/xpcu.h b/xpcu.h
index cde14214a2ce63e08a43dbe550fdddda0b4d740d..30ff4f181cfa63097e8dc8d2148c52fdf89c853b 100644 (file)
--- a/xpcu.h
+++ b/xpcu.h
@@ -15,9 +15,9 @@ struct xpcu_s {
 
 int __attribute__ ((visibility ("hidden"))) xpcu_deviceinfo(struct xpcu_s *xpcu, struct usb_get_device_data *ugdd);
 int __attribute__ ((visibility ("hidden"))) xpcu_transfer(struct xpcu_s *xpcu, struct usb_transfer *ut);
 
 int __attribute__ ((visibility ("hidden"))) xpcu_deviceinfo(struct xpcu_s *xpcu, struct usb_get_device_data *ugdd);
 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);
+int __attribute__ ((visibility ("hidden"))) xpcu_set_interface(struct xpcu_s *xpcu, struct usb_set_interface *usi);
 struct xpcu_s __attribute__ ((visibility ("hidden"))) *xpcu_find(struct event *e);
 struct xpcu_s __attribute__ ((visibility ("hidden"))) *xpcu_find(struct event *e);
-void __attribute__ ((visibility ("hidden"))) xpcu_found(struct xpcu_s *xpcu, struct event *e);
-void __attribute__ ((visibility ("hidden"))) xpcu_close(struct xpcu_s *xpcu, struct event *e);
-void __attribute__ ((visibility ("hidden"))) xpcu_int_state(struct xpcu_s *xpcu, struct interrupt *it, int enable);
-void __attribute__ ((visibility ("hidden"))) xpcu_int_wait(struct xpcu_s *xpcu, struct interrupt *it);
+int __attribute__ ((visibility ("hidden"))) xpcu_found(struct xpcu_s *xpcu, struct event *e);
+int __attribute__ ((visibility ("hidden"))) xpcu_close(struct xpcu_s *xpcu, struct event *e);
+int __attribute__ ((visibility ("hidden"))) xpcu_int_state(struct xpcu_s *xpcu, struct interrupt *it, int enable);
+int __attribute__ ((visibility ("hidden"))) xpcu_int_wait(struct xpcu_s *xpcu, struct interrupt *it);
Impressum, Datenschutz