X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fchronovu-la%2Fapi.c;h=14f1066eaa8809a565f2744d7aa9780bcf31d88a;hb=16aca7661b7ab34a399c323bb9214721e2b1be0c;hp=ae977a4b96ec39e59722bee9d3f00683b44e8c52;hpb=f254bc4bba68d2cade0c8f7993d8fa8d3d9b556a;p=libsigrok.git diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index ae977a4b..14f1066e 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -25,10 +25,10 @@ static struct sr_dev_driver *di = &chronovu_la_driver_info; static const uint32_t devopts[] = { SR_CONF_LOGIC_ANALYZER, - SR_CONF_SAMPLERATE, - SR_CONF_TRIGGER_MATCH, - SR_CONF_LIMIT_MSEC, /* TODO: Not yet implemented. */ - SR_CONF_LIMIT_SAMPLES, /* TODO: Not yet implemented. */ + SR_CONF_LIMIT_MSEC | SR_CONF_SET, + SR_CONF_LIMIT_SAMPLES | SR_CONF_SET | SR_CONF_LIST, + SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, + SR_CONF_TRIGGER_MATCH | SR_CONF_LIST, }; static const int32_t trigger_matches[] = { @@ -80,14 +80,13 @@ static int add_device(int idx, int model, GSList **devices) struct sr_dev_inst *sdi; struct drv_context *drvc; struct dev_context *devc; - struct sr_channel *ch; ret = SR_OK; drvc = di->priv; /* Allocate memory for our private device context. */ - devc = g_try_malloc(sizeof(struct dev_context)); + devc = g_malloc0(sizeof(struct dev_context)); /* Set some sane defaults. */ devc->prof = &cv_profiles[model]; @@ -120,34 +119,23 @@ static int add_device(int idx, int model, GSList **devices) devc->cur_samplerate = devc->prof->max_samplerate; /* Register the device with libsigrok. */ - sdi = sr_dev_inst_new(0, SR_ST_INITIALIZING, - "ChronoVu", devc->prof->modelname, NULL); - if (!sdi) { - sr_err("Failed to create device instance."); - ret = SR_ERR; - goto err_free_final_buf; - } + sdi = g_malloc0(sizeof(struct sr_dev_inst)); + sdi->status = SR_ST_INITIALIZING; + sdi->vendor = g_strdup("ChronoVu"); + sdi->model = g_strdup(devc->prof->modelname); sdi->driver = di; sdi->priv = devc; - for (i = 0; i < devc->prof->num_channels; i++) { - if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, - cv_channel_names[i]))) { - ret = SR_ERR; - goto err_free_dev_inst; - } - sdi->channels = g_slist_append(sdi->channels, ch); - } + for (i = 0; i < devc->prof->num_channels; i++) + sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, + cv_channel_names[i]); *devices = g_slist_append(*devices, sdi); drvc->instances = g_slist_append(drvc->instances, sdi); - return SR_OK; + if (ret == SR_OK) + return SR_OK; -err_free_dev_inst: - sr_dev_inst_free(sdi); -err_free_final_buf: - g_free(devc->final_buf); err_free_devc: g_free(devc); @@ -210,8 +198,6 @@ static int dev_open(struct sr_dev_inst *sdi) struct dev_context *devc; int ret; - ret = SR_ERR; - if (!(devc = sdi->priv)) return SR_ERR_BUG; @@ -254,7 +240,8 @@ static int dev_open(struct sr_dev_inst *sdi) sdi->status = SR_ST_ACTIVE; - return SR_OK; + if (ret == SR_OK) + return SR_OK; err_ftdi_free: ftdi_free(devc->ftdic); /* Close device (if open), free FTDI context. */ @@ -379,7 +366,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_TRIGGER_MATCH: if (!sdi || !sdi->priv || !(devc = sdi->priv) || !devc->prof) return SR_ERR_BUG; - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, trigger_matches, devc->prof->num_trigger_matches, sizeof(int32_t)); break;