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). */
}
sr_dbg("Successfully claimed interface 0.");
- return ret;
+ return SR_OK;
}
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,
(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);
{
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);
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);