- if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- g_warning("failed to get device descriptor: %d",
- err);
- continue;
- }
-
- if (des.idVendor == USB_VENDOR
- && des.idProduct == USB_PRODUCT) {
- if (skip != device_index) {
- /*
- * Skip past devices of this type that
- * aren't the one we want.
- */
- skip++;
- continue;
- }
-
- /*
- * Should check the bus here, since we know
- * that already... but what are we going to do
- * if it doesn't match after the right number
- * of skips?
- */
- if (!(err = libusb_open(devlist[i],
- &(sdi->usb->devhdl)))) {
- sdi->usb->address = libusb_get_device_address(devlist [i]);
- sdi->status = ST_ACTIVE;
- g_message("opened device %d on %d.%d "
- "interface %d",
- sdi->index, sdi->usb->bus,
- sdi->usb->address, USB_INTERFACE);
- } else {
- g_warning("failed to open device: %d",
- err);
- sdi = NULL;
- }
- }
+ /* TODO: Error handling. */
+ err = opendev2(device_index, &sdi, devlist[i], &des,
+ &skip, USB_VENDOR, USB_PRODUCT,
+ USB_INTERFACE);