]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/chronovu-la/api.c
drivers: Always use same scanopts/drvopts/devopts/devopts_cg* order.
[libsigrok.git] / src / hardware / chronovu-la / api.c
index 8824abbd0d3f274ab2269bc84a7b64ea45e04f45..d02ef3ef587fa9a4039a7e940e852972f6ca9886 100644 (file)
 #include <config.h>
 #include "protocol.h"
 
-static const uint32_t drvopts[] = {
-       SR_CONF_LOGIC_ANALYZER,
-};
-
 static const uint32_t scanopts[] = {
        SR_CONF_CONN,
 };
 
+static const uint32_t drvopts[] = {
+       SR_CONF_LOGIC_ANALYZER,
+};
+
 static const uint32_t devopts[] = {
        SR_CONF_LIMIT_MSEC | SR_CONF_SET,
        SR_CONF_LIMIT_SAMPLES | SR_CONF_SET | SR_CONF_LIST,
@@ -43,19 +43,15 @@ static const int32_t trigger_matches[] = {
        SR_TRIGGER_FALLING,
 };
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        ftdi_free(devc->ftdic);
        g_free(devc->final_buf);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int add_device(int model, struct libusb_device_descriptor *des,
@@ -361,25 +357,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        GVariantBuilder gvb;
        struct dev_context *devc;
 
-       (void)cg;
+       devc = (sdi) ? sdi->priv : NULL;
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
-               break;
        case SR_CONF_DEVICE_OPTIONS:
-               if (!sdi)
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                       drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
-               else
-                       *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                       devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
-               break;
+               return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
        case SR_CONF_SAMPLERATE:
-               if (!sdi)
-                       return SR_ERR_BUG;
-               devc = sdi->priv;
                cv_fill_samplerates_if_needed(sdi);
                g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
                gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
@@ -390,7 +374,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = g_variant_builder_end(&gvb);
                break;
        case SR_CONF_LIMIT_SAMPLES:
-               if (!sdi || !sdi->priv || !(devc = sdi->priv) || !devc->prof)
+               if (!devc->prof)
                        return SR_ERR_BUG;
                grange[0] = g_variant_new_uint64(0);
                if (devc->prof->model == CHRONOVU_LA8)
@@ -400,7 +384,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = g_variant_new_tuple(grange, 2);
                break;
        case SR_CONF_TRIGGER_MATCH:
-               if (!sdi || !sdi->priv || !(devc = sdi->priv) || !devc->prof)
+               if (!devc->prof)
                        return SR_ERR_BUG;
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
                                trigger_matches, devc->prof->num_trigger_matches,