brymen-bm86x: add some error checking

This commit is contained in:
Aurelien Jacobs 2015-08-14 01:03:57 +02:00 committed by Uwe Hermann
parent c442ffda0f
commit 6d930b4159
1 changed files with 5 additions and 0 deletions

View File

@ -109,6 +109,8 @@ static int dev_open(struct sr_dev_inst *sdi)
if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb)) == SR_OK)
sdi->status = SR_ST_ACTIVE;
else
return SR_ERR;
/* Detach kernel drivers which grabbed this device (if any). */
if (libusb_kernel_driver_active(usb->devhdl, 0) == 1) {
@ -141,6 +143,9 @@ static int dev_close(struct sr_dev_inst *sdi)
struct dev_context *devc;
int ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
usb = sdi->conn;
devc = sdi->priv;