return std_scan_complete(di, devices);
}
-/* Destroy the private device context.
- */
-static void clear_dev_context(void *priv)
+static void clear_helper(void *priv)
{
struct dev_context *devc;
sr_err("Cannot clear device context during acquisition!");
return; /* Leak and pray. */
}
- sr_dbg("Device context cleared.");
g_free(devc);
}
-/* Destroy all device instances.
- */
static int dev_clear(const struct sr_dev_driver *di)
{
- return std_dev_clear(di, &clear_dev_context);
+ return std_dev_clear_with_callback(di, clear_helper);
}
/* Drain any pending data from the USB transfer buffers on the device.
/* This delay appears to be necessary for reliable operation. */
g_usleep(30 * 1000);
- sdi->status = SR_ST_ACTIVE;
-
devc->active_fpga_config = FPGA_NOCONF;
devc->short_transfer_quirk = FALSE;
devc->state = STATE_IDLE;
break;
/* Rinse and repeat. */
- sdi->status = SR_ST_INACTIVE;
sr_usb_close(usb);
}
return ret;
}
-/* Shutdown and close device.
- */
+/* Shutdown and close device. */
static int dev_close(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
return SR_ERR_BUG;
}
- sdi->status = SR_ST_INACTIVE;
-
/* Download of the shutdown bitstream, if any. */
ret = (*devc->model->apply_fpga_config)(sdi);
if (ret != SR_OK)
sr_warn("Unable to shut down device.");
libusb_release_interface(usb->devhdl, USB_INTERFACE);
+
sr_usb_close(usb);
- return ret;
+ return SR_OK;
}
/* Check whether the device options contain a specific key.