From: Gerhard Sittig Date: Sun, 9 Jan 2022 21:38:52 +0000 (+0100) Subject: kingst-la2016: move acquisition abort from api.c to protocol.c X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3ebc1cb204f4c81b0847d11b0f26b34e08731d34;p=libsigrok.git kingst-la2016: move acquisition abort from api.c to protocol.c There was the abort_acquisition() routine (whithout a prefix) and the la2016_abort_acquisition() routine (with a prefix). Fold the termination of USB reception into the drivers's SR_PRIV routine which resides in protocol.c, which eliminates the misplaced api.c implementation. Change a few more receive callback related routines from SR_PRIV to static now that their calls are intra compile unit. --- diff --git a/src/hardware/kingst-la2016/api.c b/src/hardware/kingst-la2016/api.c index 8cf7bda6..3296a756 100644 --- a/src/hardware/kingst-la2016/api.c +++ b/src/hardware/kingst-la2016/api.c @@ -540,12 +540,6 @@ static int config_list(uint32_t key, GVariant **data, return SR_OK; } -static void abort_acquisition(struct dev_context *devc) -{ - if (devc->transfer) - libusb_cancel_transfer(devc->transfer); -} - static int configure_channels(const struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -596,7 +590,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc->ctx = drvc->sr_ctx; if ((ret = la2016_start_acquisition(sdi)) != SR_OK) { - abort_acquisition(devc); + la2016_abort_acquisition(sdi); return ret; } @@ -614,7 +608,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) int ret; ret = la2016_abort_acquisition(sdi); - abort_acquisition(sdi->priv); return ret; } diff --git a/src/hardware/kingst-la2016/protocol.c b/src/hardware/kingst-la2016/protocol.c index 203a344c..c275407b 100644 --- a/src/hardware/kingst-la2016/protocol.c +++ b/src/hardware/kingst-la2016/protocol.c @@ -659,20 +659,43 @@ SR_PRIV int la2016_setup_acquisition(const struct sr_dev_inst *sdi) SR_PRIV int la2016_start_acquisition(const struct sr_dev_inst *sdi) { - return set_run_mode(sdi, 3); + int ret; + + ret = set_run_mode(sdi, 3); + if (ret != SR_OK) + return ret; + + return SR_OK; } -SR_PRIV int la2016_stop_acquisition(const struct sr_dev_inst *sdi) +static int la2016_stop_acquisition(const struct sr_dev_inst *sdi) { - return set_run_mode(sdi, 0); + int ret; + + ret = set_run_mode(sdi, 0); + if (ret != SR_OK) + return ret; + + return SR_OK; } SR_PRIV int la2016_abort_acquisition(const struct sr_dev_inst *sdi) { - return la2016_stop_acquisition(sdi); + int ret; + struct dev_context *devc; + + ret = la2016_stop_acquisition(sdi); + if (ret != SR_OK) + return ret; + + devc = sdi ? sdi->priv : NULL; + if (devc && devc->transfer) + libusb_cancel_transfer(devc->transfer); + + return SR_OK; } -SR_PRIV int la2016_has_triggered(const struct sr_dev_inst *sdi) +static int la2016_has_triggered(const struct sr_dev_inst *sdi) { uint16_t state; @@ -681,7 +704,7 @@ SR_PRIV int la2016_has_triggered(const struct sr_dev_inst *sdi) return (state & 0x3) == 1; } -SR_PRIV int la2016_start_retrieval(const struct sr_dev_inst *sdi, libusb_transfer_cb_fn cb) +static int la2016_start_retrieval(const struct sr_dev_inst *sdi, libusb_transfer_cb_fn cb) { struct dev_context *devc; struct sr_usb_dev_inst *usb; diff --git a/src/hardware/kingst-la2016/protocol.h b/src/hardware/kingst-la2016/protocol.h index e6ffff01..8a778f31 100644 --- a/src/hardware/kingst-la2016/protocol.h +++ b/src/hardware/kingst-la2016/protocol.h @@ -122,10 +122,7 @@ struct dev_context { SR_PRIV int la2016_upload_firmware(struct sr_context *sr_ctx, libusb_device *dev, uint16_t product_id); SR_PRIV int la2016_setup_acquisition(const struct sr_dev_inst *sdi); SR_PRIV int la2016_start_acquisition(const struct sr_dev_inst *sdi); -SR_PRIV int la2016_stop_acquisition(const struct sr_dev_inst *sdi); SR_PRIV int la2016_abort_acquisition(const struct sr_dev_inst *sdi); -SR_PRIV int la2016_has_triggered(const struct sr_dev_inst *sdi); -SR_PRIV int la2016_start_retrieval(const struct sr_dev_inst *sdi, libusb_transfer_cb_fn cb); SR_PRIV int la2016_receive_data(int fd, int revents, void *cb_data); SR_PRIV int la2016_init_device(const struct sr_dev_inst *sdi); SR_PRIV int la2016_deinit_device(const struct sr_dev_inst *sdi);