return ctx;
}
+static int clear_instances(void)
+{
+ GSList *l;
+ struct sr_dev_inst *sdi;
+ struct context *ctx;
+ int ret;
+
+ ret = SR_OK;
+ for (l = fdi->instances; l; l = l->next) {
+ if (!(sdi = l->data)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("fx2lafw: %s: sdi was NULL, continuing.",
+ __func__);
+ ret = SR_ERR_BUG;
+ continue;
+ }
+ if (!(ctx = sdi->priv)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("fx2lafw: %s: sdi->priv was NULL, continuing",
+ __func__);
+ ret = SR_ERR_BUG;
+ continue;
+ }
+ close_dev(sdi);
+ sdi = l->data;
+ sr_dev_inst_free(sdi);
+ }
+
+ g_slist_free(fdi->instances);
+ fdi->instances = NULL;
+
+ return ret;
+}
+
+
/*
* API callbacks
*/
/* Avoid compiler warnings. */
(void)options;
+ /* This scan always invalidates any previous scans. */
+ clear_instances();
+
/* Find all fx2lafw compatible devices and upload firmware to them. */
devices = NULL;
libusb_get_device_list(usb_context, &devlist);
static int hw_cleanup(void)
{
- GSList *l;
- struct sr_dev_inst *sdi;
- struct context *ctx;
- int ret = SR_OK;
-
- for (l = fdi->instances; l; l = l->next) {
- if (!(sdi = l->data)) {
- /* Log error, but continue cleaning up the rest. */
- sr_err("fx2lafw: %s: sdi was NULL, continuing.",
- __func__);
- ret = SR_ERR_BUG;
- continue;
- }
- if (!(ctx = sdi->priv)) {
- /* Log error, but continue cleaning up the rest. */
- sr_err("fx2lafw: %s: sdi->priv was NULL, continuing",
- __func__);
- ret = SR_ERR_BUG;
- continue;
- }
- close_dev(sdi);
- sdi = l->data;
- sr_dev_inst_free(sdi);
- }
+ int ret;
- g_slist_free(fdi->instances);
- fdi->instances = NULL;
+ ret = clear_instances();
if (usb_context)
libusb_exit(usb_context);