if (!sdi || !sdi->driver || !sdi->driver->dev_open)
return SR_ERR;
+ if (sdi->status == SR_ST_ACTIVE) {
+ sr_err("%s: Device instance already active, can't re-open.",
+ sdi->driver->name);
+ return SR_ERR;
+ }
+
+ sr_dbg("%s: Opening device.", sdi->driver->name)
+
ret = sdi->driver->dev_open(sdi);
return ret;
devc = sdi->priv;
usb = sdi->conn;
- if (sdi->status == SR_ST_ACTIVE)
- /* Device is already in use. */
- return SR_ERR;
-
device_count = libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
if (device_count < 0) {
sr_err("Failed to get device list: %s.",
devc = sdi->priv;
usb = sdi->conn;
- if (sdi->status == SR_ST_ACTIVE)
- /* Device is already in use. */
- return SR_ERR;
-
device_count = libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
if (device_count < 0) {
sr_err("Failed to get device list: %s.",
static int dev_open(struct sr_dev_inst *sdi)
{
- if (sdi->status != SR_ST_ACTIVE && sr_scpi_open(sdi->conn) != SR_OK)
+ if (sr_scpi_open(sdi->conn) != SR_OK)
return SR_ERR;
if (hmo_scope_state_get(sdi) != SR_OK)
devc = sdi->priv;
usb = sdi->conn;
- if (sdi->status == SR_ST_ACTIVE)
- /* Already in use. */
- return SR_ERR;
-
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
for (i = 0; devlist[i]; i++) {
libusb_get_device_descriptor(devlist[i], &des);
devc = sdi->priv;
usb = sdi->conn;
- if (sdi->status == SR_ST_ACTIVE)
- /* already in use */
- return SR_ERR;
-
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
for (i = 0; devlist[i]; i++) {
libusb_get_device_descriptor(devlist[i], &des);
struct dev_context *devc = sdi->priv;
int i;
- if (sdi->status != SR_ST_INACTIVE)
- goto fail1;
-
if (ieee1284_open(sdi->conn, 0, &i) != E1284_OK)
goto fail1;
size_t i;
int r;
- if (sdi->status == SR_ST_ACTIVE)
- return SR_ERR;
-
drvc = sdi->driver->context;
usb = sdi->conn;
static int dev_open(struct sr_dev_inst *sdi)
{
- if (sdi->status != SR_ST_ACTIVE && sr_scpi_open(sdi->conn) != SR_OK)
+ if (sr_scpi_open(sdi->conn) != SR_OK)
return SR_ERR;
if (lecroy_xstream_state_get(sdi) != SR_OK)
devc = sdi->priv;
- if (p_ols_open(devc) != SR_OK) {
+ if (p_ols_open(devc) != SR_OK)
return SR_ERR;
- } else {
- sdi->status = SR_ST_ACTIVE;
- return SR_OK;
- }
+
+ sdi->status = SR_ST_ACTIVE;
+
+ return SR_OK;
}
static int dev_close(struct sr_dev_inst *sdi)
static int dev_open(struct sr_dev_inst *sdi)
{
- if ((sdi->status != SR_ST_ACTIVE) && (sr_scpi_open(sdi->conn) != SR_OK))
+ if (sr_scpi_open(sdi->conn) != SR_OK)
return SR_ERR;
sdi->status = SR_ST_ACTIVE;
drvc = di->context;
usb = sdi->conn;
- if (sdi->status == SR_ST_ACTIVE)
- /* Device is already in use. */
- return SR_ERR;
-
device_count = libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
if (device_count < 0) {
sr_err("Failed to get device list: %s.",
struct sr_scpi_dev_inst *scpi;
GVariant *beeper;
- if (sdi->status != SR_ST_INACTIVE)
- return SR_ERR;
-
scpi = sdi->conn;
if (sr_scpi_open(scpi) < 0)
return SR_ERR;
devc = sdi->priv;
usb = sdi->conn;
- if (sdi->status != SR_ST_INACTIVE) {
- sr_err("Device already open.");
- return SR_ERR;
- }
-
/* Try the whole shebang three times, fingers crossed. */
for (i = 0; i < 3; i++) {
ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb);
usb = sdi->conn;
sr_dbg("Probing for channels.");
- if (sdi->driver->dev_open(sdi) != SR_OK)
+ if (sr_dev_open(sdi) != SR_OK)
return SR_ERR;
if (testo_set_serial_params(usb) != SR_OK)
return SR_ERR;
static int dev_open(struct sr_dev_inst *sdi)
{
- if (sdi->status != SR_ST_ACTIVE && sr_scpi_open(sdi->conn) != SR_OK)
+ if (sr_scpi_open(sdi->conn) != SR_OK)
return SR_ERR;
if (dlm_scope_state_query(sdi) != SR_OK)