X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=main.c;h=e699d2f0e6d905b5ab06775c9c65f30bb54c7267;hp=51053bc9a8a3ed2135622ffd7f841eff8d1d91d7;hb=c83f755098b3c5d10b3ad022c0f4e934edc94148;hpb=d486cbddfe380de95a98646f7626426955e563ee diff --git a/main.c b/main.c index 51053bc..e699d2f 100644 --- a/main.c +++ b/main.c @@ -74,40 +74,11 @@ int select_channels(struct sr_dev_inst *sdi) return SR_OK; } -gboolean config_key_has_cap(struct sr_dev_driver *driver, - const struct sr_dev_inst *sdi, struct sr_channel_group *cg, - uint32_t key, uint32_t capability) -{ - GVariant *gvar_opts; - const uint32_t *opts; - gsize num_opts, i; - gboolean result; - - if (sr_config_list(driver, sdi, cg, SR_CONF_DEVICE_OPTIONS, - &gvar_opts) != SR_OK) - return FALSE; - - opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t)); - result = FALSE; - for (i = 0; i < num_opts; i++) { - if ((opts[i] & SR_CONF_MASK) == key) { - if ((opts[i] & capability) == capability) - result = TRUE; - else - result = FALSE; - break; - } - } - g_variant_unref(gvar_opts); - - return result; -} - int maybe_config_get(struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, struct sr_channel_group *cg, uint32_t key, GVariant **gvar) { - if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_GET)) + if (sr_dev_config_capabilities_list(sdi, cg, key) & SR_CONF_GET) return sr_config_get(driver, sdi, cg, key, gvar); return SR_ERR_NA; @@ -117,7 +88,9 @@ int maybe_config_set(struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, struct sr_channel_group *cg, uint32_t key, GVariant *gvar) { - if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_SET)) + (void)driver; + + if (sr_dev_config_capabilities_list(sdi, cg, key) & SR_CONF_SET) return sr_config_set(sdi, cg, key, gvar); return SR_ERR_NA; @@ -127,7 +100,7 @@ int maybe_config_list(struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, struct sr_channel_group *cg, uint32_t key, GVariant **gvar) { - if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_LIST)) + if (sr_dev_config_capabilities_list(sdi, cg, key) & SR_CONF_LIST) return sr_config_list(driver, sdi, cg, key, gvar); return SR_ERR_NA; @@ -241,7 +214,7 @@ int main(int argc, char **argv) } if (register_pds(opt_pds, opt_pd_annotations) != 0) goto done; - if (setup_pd_stack(opt_pds, opt_pd_stack, opt_pd_annotations) != 0) + if (setup_pd_stack(opt_pds, opt_pd_annotations) != 0) goto done; /* Only one output type is ever shown. */