-static void scan_device(struct sr_dev_driver *di, struct libusb_device *dev, GSList **devices)
+static void scan_device(struct ftdi_context *ftdic,
+ struct libusb_device *dev, GSList **devices)
{
struct libusb_device_descriptor usb_desc;
const struct ftdi_chip_desc *desc;
struct dev_context *devc;
char *vendor, *model, *serial_num;
struct sr_dev_inst *sdi;
{
struct libusb_device_descriptor usb_desc;
const struct ftdi_chip_desc *desc;
struct dev_context *devc;
char *vendor, *model, *serial_num;
struct sr_dev_inst *sdi;
- rv = ftdi_usb_get_strings(devc->ftdic, dev, vendor, 32,
- model, 32, serial_num, 32);
+ rv = ftdi_usb_get_strings(ftdic, dev, vendor, 32,
+ model, 32, serial_num, 32);
for (char *const *chan = &(desc->channel_names[0]); *chan; chan++)
sr_channel_new(sdi, chan - &(desc->channel_names[0]),
SR_CHANNEL_LOGIC, TRUE, *chan);
*devices = g_slist_append(*devices, sdi);
for (char *const *chan = &(desc->channel_names[0]); *chan; chan++)
sr_channel_new(sdi, chan - &(desc->channel_names[0]),
SR_CHANNEL_LOGIC, TRUE, *chan);
*devices = g_slist_append(*devices, sdi);
ret = ftdi_usb_find_all(ftdic, &devlist, 0, 0);
if (ret < 0) {
sr_err("Failed to list devices (%d): %s", ret,
ftdi_get_error_string(ftdic));
ret = ftdi_usb_find_all(ftdic, &devlist, 0, 0);
if (ret < 0) {
sr_err("Failed to list devices (%d): %s", ret,
ftdi_get_error_string(ftdic));
usb = l->data;
if (usb->bus == libusb_get_bus_number(devlist[i])
&& usb->address == libusb_get_device_address(devlist[i])) {
usb = l->data;
if (usb->bus == libusb_get_bus_number(devlist[i])
&& usb->address == libusb_get_device_address(devlist[i])) {
- return scan_all(di, options);
+ devices = scan_all(ftdic, options);
+
+ ftdi_free(ftdic);
+
+ return std_scan_complete(di, devices);
if (ret < 0) {
/* Log errors, except for -3 ("device not found"). */
if (ret != -3)
sr_err("Failed to open device (%d): %s", ret,
ftdi_get_error_string(devc->ftdic));
if (ret < 0) {
/* Log errors, except for -3 ("device not found"). */
if (ret != -3)
sr_err("Failed to open device (%d): %s", ret,
ftdi_get_error_string(devc->ftdic));
/* Hook up a dummy handler to receive data from the device. */
sr_session_source_add(sdi->session, -1, G_IO_IN, 0,
/* Hook up a dummy handler to receive data from the device. */
sr_session_source_add(sdi->session, -1, G_IO_IN, 0,
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);