#ifndef NO_WINDRVR
ret = (*ioctl_func) (fd, request, wdioctl);
#else
- xpcu_transfer(xpcu, ut);
+ ret = xpcu_transfer(xpcu, ut);
#endif
#ifdef DEBUG
#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",
#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,
#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,
ugdd->dwUniqueID, ugdd->dwBytes,
ugdd->dwOptions);
- ugdd->dwBytes = xpcu_deviceinfo(xpcu, ugdd);
+ ret = xpcu_deviceinfo(xpcu, ugdd);
}
break;
#ifndef NO_WINDRVR
ret = (*ioctl_func) (fd, request, wdioctl);
#else
- xpcu_close(xpcu, e);
+ ret = xpcu_close(xpcu, e);
#endif
}
break;
#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",
#ifndef NO_WINDRVR
ret = (*ioctl_func) (fd, request, wdioctl);
#else
- xpcu_found(xpcu, e);
+ ret = xpcu_found(xpcu, e);
#endif
#ifdef DEBUG
if (ugdd->dwUniqueID != (unsigned long)xpcu)
return -ENODEV;
+
+ if (!xpcu)
+ return -ENODEV;
if (ugdd->dwBytes)
buf = ugdd->pBuf;
}
}
- return len;
+ ugdd->dwBytes = len;
+
+ return 0;
}
static int xpcu_claim(struct xpcu_s *xpcu, int claim) {
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 */
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)
- return;
+ return -ENODEV;
+
+ if (!xpcu)
+ return -ENODEV;
if (xpcu->dev) {
if (!xpcu->handle) {
xpcu->interface = xpcu->dev->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber;
xpcu->alternate = usi->dwAlternateSetting;
}
+
+ return 0;
}
static void xpcu_init(void) {
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;
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)
- return;
+ return -ENODEV;
+
+ if (!xpcu)
+ return -ENODEV;
if(xpcu) {
if (xpcu->handle) {
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)
- return;
+ return -ENODEV;
if (xpcu)
interrupt = &xpcu->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)
- return;
+ return -ENODEV;
if (xpcu) {
if (it->dwCounter == 0) {
pthread_mutex_lock(&dummy_interrupt);
pthread_mutex_unlock(&dummy_interrupt);
}
+
+ return 0;
}
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);
-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);