X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fikalogic-scanalogic2%2Fapi.c;h=798ae8bd9468d7414aed939ddd924ee308b48c08;hb=5fabeeac6af940b52f67ac8c925952accc9b39b3;hp=25cebb5facc83398b36638a479b8a8dae54a2983;hpb=584560f142e1b17b9f4ef9069bd3724f2f77e750;p=libsigrok.git diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c index 25cebb5f..798ae8bd 100644 --- a/src/hardware/ikalogic-scanalogic2/api.c +++ b/src/hardware/ikalogic-scanalogic2/api.c @@ -19,12 +19,12 @@ #include "protocol.h" -static const uint32_t hwcaps[] = { +static const uint32_t devopts[] = { SR_CONF_LOGIC_ANALYZER, - SR_CONF_SAMPLERATE, - SR_CONF_LIMIT_SAMPLES, - SR_CONF_TRIGGER_MATCH, - SR_CONF_CAPTURE_RATIO, + 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, + SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET, }; static const int32_t trigger_matches[] = { @@ -69,15 +69,13 @@ static GSList *scan(GSList *options) struct dev_context *devc; struct sr_usb_dev_inst *usb; struct device_info dev_info; - int ret, device_index, i; - char *fw_ver_str; + int ret, i; (void)options; devices = NULL; drvc = di->priv; drvc->instances = NULL; - device_index = 0; usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_VID_PID); @@ -93,11 +91,7 @@ static GSList *scan(GSList *options) continue; } - if (!(devc = g_try_malloc(sizeof(struct dev_context)))) { - sr_err("Device instance malloc failed."); - sr_usb_dev_inst_free(usb); - continue; - } + devc = g_malloc0(sizeof(struct dev_context)); if (!(devc->xfer_in = libusb_alloc_transfer(0))) { sr_err("Transfer malloc failed."); @@ -114,29 +108,12 @@ static GSList *scan(GSList *options) continue; } - fw_ver_str = g_strdup_printf("%u.%u", dev_info.fw_ver_major, - dev_info.fw_ver_minor); - if (!fw_ver_str) { - sr_err("Firmware string malloc failed."); - sr_usb_dev_inst_free(usb); - libusb_free_transfer(devc->xfer_in); - libusb_free_transfer(devc->xfer_out); - g_free(devc); - continue; - } - - sdi = sr_dev_inst_new(device_index, SR_ST_INACTIVE, VENDOR_NAME, - MODEL_NAME, fw_ver_str); - g_free(fw_ver_str); - if (!sdi) { - sr_err("sr_dev_inst_new failed."); - sr_usb_dev_inst_free(usb); - libusb_free_transfer(devc->xfer_in); - libusb_free_transfer(devc->xfer_out); - g_free(devc); - continue; - } - + sdi = g_malloc0(sizeof(struct sr_dev_inst)); + sdi->status = SR_ST_INACTIVE; + sdi->vendor = g_strdup(VENDOR_NAME); + sdi->model = g_strdup(MODEL_NAME); + sdi->version = g_strdup_printf("%u.%u", dev_info.fw_ver_major, dev_info.fw_ver_minor); + sdi->serial_num = g_strdup_printf("%d", dev_info.serial); sdi->priv = devc; sdi->driver = di; sdi->inst_type = SR_INST_USB; @@ -182,8 +159,6 @@ static GSList *scan(GSList *options) drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); - - device_index++; } g_slist_free(usb_devices); @@ -386,7 +361,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * switch (key) { case SR_CONF_DEVICE_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - hwcaps, ARRAY_SIZE(hwcaps), sizeof(uint32_t)); + devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); break; case SR_CONF_SAMPLERATE: g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));