saleae-logic16: claim device before using it
The kernel warns: [ 7461.925685] usb 2-4: usbfs: process 11303 (sigrok-cli) did not claim interface 0 before use
This commit is contained in:
parent
5542bee61b
commit
0c30b35fce
|
@ -308,6 +308,20 @@ static int logic16_dev_open(struct sr_dev_inst *sdi)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
|
||||||
|
if (ret == LIBUSB_ERROR_BUSY) {
|
||||||
|
sr_err("Unable to claim USB interface. Another "
|
||||||
|
"program or driver has already claimed it.");
|
||||||
|
break;
|
||||||
|
} else if (ret == LIBUSB_ERROR_NO_DEVICE) {
|
||||||
|
sr_err("Device has been disconnected.");
|
||||||
|
break;
|
||||||
|
} else if (ret != 0) {
|
||||||
|
sr_err("Unable to claim interface: %s.",
|
||||||
|
libusb_error_name(ret));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = logic16_init_device(sdi)) != SR_OK) {
|
if ((ret = logic16_init_device(sdi)) != SR_OK) {
|
||||||
sr_err("Failed to init device.");
|
sr_err("Failed to init device.");
|
||||||
break;
|
break;
|
||||||
|
@ -321,21 +335,25 @@ static int logic16_dev_open(struct sr_dev_inst *sdi)
|
||||||
}
|
}
|
||||||
libusb_free_device_list(devlist, 1);
|
libusb_free_device_list(devlist, 1);
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE) {
|
||||||
|
if (usb->devhdl) {
|
||||||
|
libusb_release_interface(usb->devhdl, USB_INTERFACE);
|
||||||
|
libusb_close(usb->devhdl);
|
||||||
|
usb->devhdl = NULL;
|
||||||
|
}
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_open(struct sr_dev_inst *sdi)
|
static int dev_open(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_usb_dev_inst *usb;
|
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
int ret;
|
||||||
int64_t timediff_us, timediff_ms;
|
int64_t timediff_us, timediff_ms;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
usb = sdi->conn;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the firmware was recently uploaded, wait up to MAX_RENUM_DELAY_MS
|
* If the firmware was recently uploaded, wait up to MAX_RENUM_DELAY_MS
|
||||||
|
@ -371,25 +389,6 @@ static int dev_open(struct sr_dev_inst *sdi)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
|
|
||||||
if (ret != 0) {
|
|
||||||
switch (ret) {
|
|
||||||
case LIBUSB_ERROR_BUSY:
|
|
||||||
sr_err("Unable to claim USB interface. Another "
|
|
||||||
"program or driver has already claimed it.");
|
|
||||||
break;
|
|
||||||
case LIBUSB_ERROR_NO_DEVICE:
|
|
||||||
sr_err("Device has been disconnected.");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sr_err("Unable to claim interface: %s.",
|
|
||||||
libusb_error_name(ret));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SR_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (devc->cur_samplerate == 0) {
|
if (devc->cur_samplerate == 0) {
|
||||||
/* Samplerate hasn't been set; default to the slowest one. */
|
/* Samplerate hasn't been set; default to the slowest one. */
|
||||||
devc->cur_samplerate = samplerates[0];
|
devc->cur_samplerate = samplerates[0];
|
||||||
|
|
Loading…
Reference in New Issue