]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/victor-dmm/api.c
Add sr_dev_acquisition_stop(), factor out SR_ERR_DEV_CLOSED check.
[libsigrok.git] / src / hardware / victor-dmm / api.c
index ff0302d913ef9d9574bb24eb9e7ceff2270362ea..1ea102ced9c81ef839f8b73aab0fc0203785913a 100644 (file)
@@ -32,8 +32,6 @@
 #define VICTOR_INTERFACE 0
 #define VICTOR_ENDPOINT (LIBUSB_ENDPOINT_IN | 1)
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi);
-
 static const uint32_t drvopts[] = {
        SR_CONF_MULTIMETER,
 };
@@ -223,13 +221,13 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
        devc = sdi->priv;
        if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) {
                /* USB device was unplugged. */
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        } else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
                sr_dbg("Got %d-byte packet.", transfer->actual_length);
                if (transfer->actual_length == DMM_DATA_SIZE) {
                        victor_dmm_receive_data(sdi, transfer->buffer);
                        if (sr_sw_limits_check(&devc->limits))
-                               dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                }
        }
        /* Anything else is either an error or a timeout, which is fine:
@@ -242,7 +240,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
                               libusb_error_name(ret));
                        g_free(transfer->buffer);
                        libusb_free_transfer(transfer);
-                       dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                }
        } else {
                /* This was the last transfer we're going to receive, so
@@ -269,7 +267,7 @@ static int handle_events(int fd, int revents, void *cb_data)
        drvc = di->context;
 
        if (sr_sw_limits_check(&devc->limits))
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        if (sdi->status == SR_ST_STOPPING) {
                usb_source_remove(sdi->session, drvc->sr_ctx);
@@ -324,11 +322,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) {
-               sr_err("Device not active, can't stop acquisition.");
-               return SR_ERR;
-       }
-
        sdi->status = SR_ST_STOPPING;
 
        return SR_OK;