X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Funi-t-ut32x%2Fapi.c;h=aa38cf5fb7bd04bb11be8c00b39bdc1d00ce4456;hb=1f501d72ef58861e27c6c7fcbb26780ad41010ef;hp=81024dc7cc0548afb6d2515d636bc96519c9f4db;hpb=155b680da482cea2381becb73c51cfb838bff31e;p=libsigrok.git diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index 81024dc7..aa38cf5f 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -21,11 +21,11 @@ #include -static const int32_t hwcaps[] = { +static const uint32_t devopts[] = { SR_CONF_THERMOMETER, - SR_CONF_LIMIT_SAMPLES, SR_CONF_CONTINUOUS, - SR_CONF_DATA_SOURCE, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_DATA_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, }; static char *channels[] = { @@ -79,25 +79,19 @@ static GSList *scan(GSList *options) /* We have a list of sr_usb_dev_inst matching the connection * string. Wrap them in sr_dev_inst and we're done. */ for (l = usb_devices; l; l = l->next) { - if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, VENDOR, - MODEL, NULL))) - return NULL; + sdi = g_malloc0(sizeof(struct sr_dev_inst)); + sdi->status = SR_ST_INACTIVE; + sdi->vendor = g_strdup(VENDOR); + sdi->model = g_strdup(MODEL); sdi->driver = di; sdi->inst_type = SR_INST_USB; sdi->conn = l->data; for (i = 0; i < 3; i++) { - if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, - channels[i]))) { - sr_dbg("Channel malloc failed."); - return NULL; - } + ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, + channels[i]); sdi->channels = g_slist_append(sdi->channels, ch); } - - if (!(devc = g_try_malloc(sizeof(struct dev_context)))) { - sr_dbg("Device context malloc failed."); - return NULL; - } + devc = g_malloc0(sizeof(struct dev_context)); sdi->priv = devc; devc->limit_samples = 0; devc->data_source = DEFAULT_DATA_SOURCE; @@ -199,7 +193,7 @@ static int cleanup(void) return ret; } -static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, +static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; @@ -224,7 +218,7 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, return SR_OK; } -static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, +static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; @@ -265,7 +259,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, return ret; } -static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, +static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -274,8 +268,8 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, switch (key) { case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, - hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); break; case SR_CONF_DATA_SOURCE: *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));