]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/sysclk-lwla/api.c
sr_dev_close(): Set status to SR_ST_INACTIVE.
[libsigrok.git] / src / hardware / sysclk-lwla / api.c
index da2019fba31eb51fbc44b82d1a37cae4309168c5..34dc884d83e58a89d573a6be8d78115288492d4c 100644 (file)
@@ -273,11 +273,6 @@ static int dev_open(struct sr_dev_inst *sdi)
        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);
@@ -308,8 +303,6 @@ static int dev_open(struct sr_dev_inst *sdi)
                /* This delay appears to be necessary for reliable operation. */
                g_usleep(30 * 1000);
 
-               sdi->status = SR_ST_ACTIVE;
-
                devc->active_fpga_config = FPGA_NOCONF;
                devc->short_transfer_quirk = FALSE;
                devc->state = STATE_IDLE;
@@ -322,7 +315,6 @@ static int dev_open(struct sr_dev_inst *sdi)
                        break;
 
                /* Rinse and repeat. */
-               sdi->status = SR_ST_INACTIVE;
                sr_usb_close(usb);
        }
 
@@ -332,8 +324,7 @@ static int dev_open(struct sr_dev_inst *sdi)
        return ret;
 }
 
-/* Shutdown and close device.
- */
+/* Shutdown and close device. */
 static int dev_close(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
@@ -350,17 +341,16 @@ static int dev_close(struct sr_dev_inst *sdi)
                return SR_ERR_BUG;
        }
 
-       sdi->status = SR_ST_INACTIVE;
-
        /* Download of the shutdown bitstream, if any. */
        ret = (*devc->model->apply_fpga_config)(sdi);
        if (ret != SR_OK)
                sr_warn("Unable to shut down device.");
 
        libusb_release_interface(usb->devhdl, USB_INTERFACE);
+
        sr_usb_close(usb);
 
-       return ret;
+       return SR_OK;
 }
 
 /* Check whether the device options contain a specific key.