+
+ if (libusb_init(&usb_context) != 0) {
+ sr_warn("Failed to initialize USB.");
+ return 0;
+ }
+
+ /* Find all fx2lafw compatible devices and upload firware to all of them. */
+ libusb_get_device_list(usb_context, &devlist);
+ for (i = 0; devlist[i]; i++) {
+
+ if ((err = libusb_get_device_descriptor(
+ devlist[i], &des)) != 0) {
+ sr_warn("failed to get device descriptor: %d", err);
+ continue;
+ }
+
+ fx2lafw_prof = NULL;
+ for (j = 0; supported_fx2[j].vid; j++) {
+ if (des.idVendor == supported_fx2[j].vid &&
+ des.idProduct == supported_fx2[j].pid) {
+ fx2lafw_prof = &supported_fx2[j];
+ }
+ }
+
+ /* Skip if the device was not found */
+ if(!fx2lafw_prof)
+ continue;
+
+ sdi = sr_dev_inst_new(devcnt, SR_ST_INITIALIZING,
+ fx2lafw_prof->vendor, fx2lafw_prof->model,
+ fx2lafw_prof->model_version);
+ if(!sdi)
+ return 0;
+
+ fx2lafw_dev = fx2lafw_device_new();
+ fx2lafw_dev->profile = fx2lafw_prof;
+ sdi->priv = fx2lafw_dev;
+ device_instances = g_slist_append(device_instances, sdi);
+
+ devcnt++;
+ }
+ libusb_free_device_list(devlist, 1);
+
+ return devcnt;