+ if (dev.fd != -1) {
+ /* deal with pending URBs */
+ if (pending_urbs & (1 << URB_DATA_IN))
+ ioctl(dev.fd, USBDEVFS_DISCARDURB, &urb[URB_DATA_IN]);
+ if (pending_urbs & (1 << URB_DBG_IN))
+ ioctl(dev.fd, USBDEVFS_DISCARDURB, &urb[URB_DBG_IN]);
+ for (i = 0; i < URB_CNT; i++) {
+ if (pending_urbs & (1 << i)) {
+ ret = ioctl(dev.fd, USBDEVFS_REAPURB, &reaped_urb);
+ if (ret != 0)
+ perror("USBDEVFS_REAPURB");
+ }
+ }
+
+ close(dev.fd);
+ }
+