X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fhantek-dso%2Fapi.c;h=3da04264b5279b3c43af0f2ae1da43f0d3a721d1;hb=2388ae860c369171d8728539ce2e9aab5810896b;hp=5d09e80ad173b977bba63e489c65d9b5d2fa70ae;hpb=8f996b89481670219c7576e2c68b128a0a2ce026;p=libsigrok.git diff --git a/hardware/hantek-dso/api.c b/hardware/hantek-dso/api.c index 5d09e80a..3da04264 100644 --- a/hardware/hantek-dso/api.c +++ b/hardware/hantek-dso/api.c @@ -595,10 +595,6 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, (void)probe_group; - if (!sdi) - return SR_ERR_ARG; - - devc = sdi->priv; switch (key) { case SR_CONF_SCAN_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, @@ -609,6 +605,9 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, devopts, ARRAY_SIZE(devopts), sizeof(int32_t)); break; case SR_CONF_BUFFERSIZE: + if (!sdi) + return SR_ERR_ARG; + devc = sdi->priv; *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64, devc->profile->buffersizes, 2, sizeof(uint64_t)); break; @@ -806,8 +805,7 @@ static int handle_event(int fd, int revents, void *cb_data) struct timeval tv; struct dev_context *devc; struct drv_context *drvc = di->priv; - const struct libusb_pollfd **lupfd; - int num_probes, i; + int num_probes; uint32_t trigger_offset; uint8_t capturestate; @@ -823,10 +821,7 @@ static int handle_event(int fd, int revents, void *cb_data) * TODO: Doesn't really cancel pending transfers so they might * come in after SR_DF_END is sent. */ - lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx); - for (i = 0; lupfd[i]; i++) - sr_source_remove(lupfd[i]->fd); - free(lupfd); + usb_source_remove(drvc->sr_ctx); packet.type = SR_DF_END; sr_session_send(sdi, &packet); @@ -916,10 +911,8 @@ static int handle_event(int fd, int revents, void *cb_data) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { - const struct libusb_pollfd **lupfd; struct dev_context *devc; struct drv_context *drvc = di->priv; - int i; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -939,11 +932,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; devc->dev_state = CAPTURE; - lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx); - for (i = 0; lupfd[i]; i++) - sr_source_add(lupfd[i]->fd, lupfd[i]->events, TICK, - handle_event, (void *)sdi); - free(lupfd); + usb_source_add(drvc->sr_ctx, TICK, handle_event, (void *)sdi); /* Send header packet to the session bus. */ std_session_send_df_header(cb_data, LOG_PREFIX);