SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
-static int check_manufacturer(const char *manufacturer)
-{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(manufacturers); i++)
- if (!strcmp(manufacturer, manufacturers[i]))
- return SR_OK;
-
- return SR_ERR;
-}
-
-static struct sr_dev_inst *probe_serial_device(struct sr_scpi_dev_inst *scpi)
+static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
goto fail;
}
- if (check_manufacturer(hw_info->manufacturer) != SR_OK)
+ if (std_str_idx_s(hw_info->manufacturer, ARRAY_AND_SIZE(manufacturers)) < 0)
goto fail;
sdi = g_malloc0(sizeof(struct sr_dev_inst));
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
- return sr_scpi_scan(di->context, options, probe_serial_device);
+ return sr_scpi_scan(di->context, options, probe_device);
}
static void clear_helper(struct dev_context *devc)
break;
case SR_CONF_TRIGGER_SOURCE:
tmp = g_variant_get_string(data, NULL);
- for (i = 0; (*model->trigger_sources)[i]; i++) {
+ for (i = 0; i < model->num_trigger_sources; i++) {
if (g_strcmp0(tmp, (*model->trigger_sources)[i]) != 0)
continue;
state->trigger_source = i;
break;
case SR_CONF_TRIGGER_SLOPE:
tmp = g_variant_get_string(data, NULL);
- for (i = 0; (*model->trigger_slopes)[i]; i++) {
+ for (i = 0; i < model->num_trigger_slopes; i++) {
if (g_strcmp0(tmp, (*model->trigger_slopes)[i]) != 0)
continue;
state->trigger_slope = i;
case SR_CONF_COUPLING:
tmp = g_variant_get_string(data, NULL);
- for (i = 0; (*model->coupling_options)[i]; i++) {
+ for (i = 0; i < model->num_coupling_options; i++) {
if (strcmp(tmp, (*model->coupling_options)[i]) != 0)
continue;
for (j = 1; j <= model->analog_channels; j++) {
case SR_CONF_DEVICE_OPTIONS:
if (!cg)
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog),
- sizeof(uint32_t));
+ *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
break;
case SR_CONF_COUPLING:
- *data = g_variant_new_strv(*model->coupling_options,
- g_strv_length((char **)*model->coupling_options));
+ *data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options);
break;
case SR_CONF_TRIGGER_SOURCE:
if (!model)
return SR_ERR_ARG;
- *data = g_variant_new_strv(*model->trigger_sources,
- g_strv_length((char **)*model->trigger_sources));
+ *data = g_variant_new_strv(*model->trigger_sources, model->num_trigger_sources);
break;
case SR_CONF_TRIGGER_SLOPE:
if (!model)
return SR_ERR_ARG;
- *data = g_variant_new_strv(*model->trigger_slopes,
- g_strv_length((char **)*model->trigger_slopes));
+ *data = g_variant_new_strv(*model->trigger_slopes, model->num_trigger_slopes);
break;
case SR_CONF_TIMEBASE:
if (!model)
default:
return SR_ERR_NA;
}
+
return SR_OK;
}