X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbrymen-bm86x%2Fapi.c;h=23b42e1390cddee7c0baee502e50d8c2d9fe47db;hb=f1ba6b4b2c9a8ecf90bb31efb218752aa7e49d1a;hp=fb9f2807efd87496a18e346a8597d7a319c61cbe;hpb=bee2b0168c087676c1b365861d8c2d4714afa9b9;p=libsigrok.git diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index fb9f2807..23b42e13 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -95,9 +95,7 @@ static int dev_open(struct sr_dev_inst *sdi) usb = sdi->conn; devc = sdi->priv; - if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb)) == SR_OK) - sdi->status = SR_ST_ACTIVE; - else + if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb)) < 0) return SR_ERR; /* Detach kernel drivers which grabbed this device (if any). */ @@ -122,7 +120,7 @@ static int dev_open(struct sr_dev_inst *sdi) } sr_dbg("Successfully claimed interface 0."); - return ret; + return SR_OK; } static int dev_close(struct sr_dev_inst *sdi) @@ -131,32 +129,23 @@ 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; if ((ret = libusb_release_interface(usb->devhdl, 0))) sr_err("Failed to release interface 0: %s.\n", libusb_error_name(ret)); - else - sr_dbg("Successfully released interface 0.\n"); if (!ret && devc->detached_kernel_driver) { - if ((ret = libusb_attach_kernel_driver(usb->devhdl, 0))) { + if ((ret = libusb_attach_kernel_driver(usb->devhdl, 0))) sr_err("Failed to attach kernel driver: %s.\n", libusb_error_name(ret)); - } else { + else devc->detached_kernel_driver = 0; - sr_dbg("Successfully attached kernel driver.\n"); - } } libusb_close(usb->devhdl); - sdi->status = SR_ST_INACTIVE; - - return ret; + return (ret == 0) ? SR_OK : SR_ERR; } static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, @@ -176,9 +165,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd (void)cg; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; return sr_sw_limits_config_set(&devc->sw_limits, key, data); @@ -210,9 +196,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; sr_sw_limits_acquisition_start(&devc->sw_limits); @@ -227,9 +210,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - std_session_send_df_end(sdi); sr_session_source_remove(sdi->session, -1);