X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ffx2lafw%2Fapi.c;h=baa1476d0bbd022ada03d6ed382e31354f5c30cf;hb=0f34cb472368be61aa2e7bc9d9d1b25bb28aa560;hp=8e9b5be4a6688651b28096461b931ceb3b9e9efe;hpb=5e23fcab889c62864b92aa3ad6902ce3e9f5be49;p=libsigrok.git diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 8e9b5be4..baa1476d 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -106,9 +106,8 @@ static const uint32_t devopts[] = { }; static const char *channel_names[] = { - "0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "10", "11", "12", "13", "14", "15", - NULL, + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", "10", "11", "12", "13", "14", "15", }; static const int32_t soft_trigger_matches[] = { @@ -158,14 +157,13 @@ static const uint64_t dslogic_samplerates[] = { }; SR_PRIV struct sr_dev_driver fx2lafw_driver_info; -static struct sr_dev_driver *di = &fx2lafw_driver_info; -static int init(struct sr_context *sr_ctx) +static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) { return std_init(sr_ctx, di, LOG_PREFIX); } -static GSList *scan(GSList *options) +static GSList *scan(struct sr_dev_driver *di, GSList *options) { struct drv_context *drvc; struct dev_context *devc; @@ -340,13 +338,14 @@ static GSList *scan(GSList *options) return devices; } -static GSList *dev_list(void) +static GSList *dev_list(const struct sr_dev_driver *di) { return ((struct drv_context *)(di->priv))->instances; } static int dev_open(struct sr_dev_inst *sdi) { + struct sr_dev_driver *di = sdi->driver; struct sr_usb_dev_inst *usb; struct dev_context *devc; int ret; @@ -440,7 +439,7 @@ static int dev_close(struct sr_dev_inst *sdi) return SR_OK; } -static int cleanup(void) +static int cleanup(const struct sr_dev_driver *di) { int ret; struct drv_context *drvc; @@ -451,7 +450,6 @@ static int cleanup(void) ret = std_dev_clear(di, NULL); g_free(drvc); - di->priv = NULL; return ret; } @@ -519,30 +517,30 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd ret = SR_OK; switch (key) { - case SR_CONF_SAMPLERATE: - arg = g_variant_get_uint64(data); - for (i = 0; i < ARRAY_SIZE(samplerates); i++) { - if (samplerates[i] == arg) { - devc->cur_samplerate = arg; - break; - } + case SR_CONF_SAMPLERATE: + arg = g_variant_get_uint64(data); + for (i = 0; i < ARRAY_SIZE(samplerates); i++) { + if (samplerates[i] == arg) { + devc->cur_samplerate = arg; + break; } - if (i == ARRAY_SIZE(samplerates)) - ret = SR_ERR_ARG; - break; - case SR_CONF_LIMIT_SAMPLES: - devc->limit_samples = g_variant_get_uint64(data); - break; - case SR_CONF_CAPTURE_RATIO: - devc->capture_ratio = g_variant_get_uint64(data); - if (devc->capture_ratio > 100) { - devc->capture_ratio = 0; - ret = SR_ERR; - } else - ret = SR_OK; - break; - default: - ret = SR_ERR_NA; + } + if (i == ARRAY_SIZE(samplerates)) + ret = SR_ERR_ARG; + break; + case SR_CONF_LIMIT_SAMPLES: + devc->limit_samples = g_variant_get_uint64(data); + break; + case SR_CONF_CAPTURE_RATIO: + devc->capture_ratio = g_variant_get_uint64(data); + if (devc->capture_ratio > 100) { + devc->capture_ratio = 0; + ret = SR_ERR; + } else + ret = SR_OK; + break; + default: + ret = SR_ERR_NA; } return ret; @@ -599,9 +597,8 @@ static int receive_data(int fd, int revents, void *cb_data) (void)fd; (void)revents; - (void)cb_data; - drvc = di->priv; + drvc = (struct drv_context *)cb_data; tv.tv_sec = tv.tv_usec = 0; libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv); @@ -735,6 +732,7 @@ static int dslogic_trigger_request(const struct sr_dev_inst *sdi) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { + struct sr_dev_driver *di; struct drv_context *drvc; struct dev_context *devc; int timeout, ret; @@ -742,6 +740,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; + di = sdi->driver; drvc = di->priv; devc = sdi->priv; @@ -752,7 +751,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->acq_aborted = FALSE; timeout = fx2lafw_get_timeout(devc); - usb_source_add(sdi->session, devc->ctx, timeout, receive_data, NULL); + usb_source_add(sdi->session, devc->ctx, timeout, receive_data, drvc); if (devc->dslogic) { dslogic_trigger_request(sdi);