fx2lafw: a device scan always invalidates any previous scans
This commit is contained in:
parent
6e9339aae2
commit
f69b47f0f8
|
@ -376,6 +376,41 @@ static struct context *fx2lafw_dev_new(void)
|
||||||
return ctx;
|
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
|
* API callbacks
|
||||||
*/
|
*/
|
||||||
|
@ -405,6 +440,9 @@ static GSList *hw_scan(GSList *options)
|
||||||
/* Avoid compiler warnings. */
|
/* Avoid compiler warnings. */
|
||||||
(void)options;
|
(void)options;
|
||||||
|
|
||||||
|
/* This scan always invalidates any previous scans. */
|
||||||
|
clear_instances();
|
||||||
|
|
||||||
/* Find all fx2lafw compatible devices and upload firmware to them. */
|
/* Find all fx2lafw compatible devices and upload firmware to them. */
|
||||||
devices = NULL;
|
devices = NULL;
|
||||||
libusb_get_device_list(usb_context, &devlist);
|
libusb_get_device_list(usb_context, &devlist);
|
||||||
|
@ -561,33 +599,9 @@ static int hw_dev_close(int dev_index)
|
||||||
|
|
||||||
static int hw_cleanup(void)
|
static int hw_cleanup(void)
|
||||||
{
|
{
|
||||||
GSList *l;
|
int ret;
|
||||||
struct sr_dev_inst *sdi;
|
|
||||||
struct context *ctx;
|
|
||||||
int ret = SR_OK;
|
|
||||||
|
|
||||||
for (l = fdi->instances; l; l = l->next) {
|
ret = clear_instances();
|
||||||
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;
|
|
||||||
|
|
||||||
if (usb_context)
|
if (usb_context)
|
||||||
libusb_exit(usb_context);
|
libusb_exit(usb_context);
|
||||||
|
|
Loading…
Reference in New Issue