X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fchronovu-la8%2Fapi.c;h=b1f889198d13ed99cb56eed95db3c2433ea30685;hb=063e7aef6d41d4c44591ff93672079998bf9622f;hp=cd6eca5fc30eb61de9ab3f6ea81db9f0f548c4c0;hpb=035a1078fda93cf1da37d19b3a1d95311b99b00f;p=libsigrok.git diff --git a/hardware/chronovu-la8/api.c b/hardware/chronovu-la8/api.c index cd6eca5f..b1f88919 100644 --- a/hardware/chronovu-la8/api.c +++ b/hardware/chronovu-la8/api.c @@ -70,17 +70,7 @@ static int clear_instances(void) static int hw_init(struct sr_context *sr_ctx) { - struct drv_context *drvc; - - if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) { - sr_err("Driver context malloc failed."); - return SR_ERR_MALLOC; - } - - drvc->sr_ctx = sr_ctx; - di->priv = drvc; - - return SR_OK; + return std_hw_init(sr_ctx, di, DRIVER_LOG_DOMAIN); } static GSList *hw_scan(GSList *options) @@ -96,6 +86,7 @@ static GSList *hw_scan(GSList *options) (void)options; drvc = di->priv; + devices = NULL; /* Allocate memory for our private device context. */ @@ -169,8 +160,6 @@ static GSList *hw_scan(GSList *options) devices = g_slist_append(devices, sdi); drvc->instances = g_slist_append(drvc->instances, sdi); - sr_spew("Device init successful."); - /* Close device. We'll reopen it again when we need it. */ (void) la8_close(devc); /* Log, but ignore errors. */ @@ -293,20 +282,7 @@ static int config_get(int id, const void **data, const struct sr_dev_inst *sdi) struct dev_context *devc; switch (id) { - case SR_DI_HWCAPS: - *data = hwcaps; - break; - case SR_DI_SAMPLERATES: - fill_supported_samplerates_if_needed(); - *data = &samplerates; - sr_spew("%s: Returning samplerates.", __func__); - break; - case SR_DI_TRIGGER_TYPES: - *data = (char *)TRIGGER_TYPES; - sr_spew("%s: Returning trigger types: %s.", __func__, - TRIGGER_TYPES); - break; - case SR_DI_CUR_SAMPLERATE: + case SR_CONF_SAMPLERATE: if (sdi) { devc = sdi->priv; *data = &devc->cur_samplerate; @@ -365,6 +341,29 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi) return SR_OK; } +static int config_list(int key, const void **data, const struct sr_dev_inst *sdi) +{ + + (void)sdi; + + switch (key) { + case SR_CONF_DEVICE_OPTIONS: + *data = hwcaps; + break; + case SR_CONF_SAMPLERATE: + fill_supported_samplerates_if_needed(); + *data = &samplerates; + break; + case SR_CONF_TRIGGER_TYPE: + *data = (char *)TRIGGER_TYPE; + break; + default: + return SR_ERR_ARG; + } + + return SR_OK; +} + static int receive_data(int fd, int revents, void *cb_data) { int i, ret; @@ -514,6 +513,7 @@ SR_PRIV struct sr_dev_driver chronovu_la8_driver_info = { .dev_clear = clear_instances, .config_get = config_get, .config_set = config_set, + .config_list = config_list, .dev_open = hw_dev_open, .dev_close = hw_dev_close, .dev_acquisition_start = hw_dev_acquisition_start,