]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/ftdi-la/api.c
drivers: Use ARRAY_AND_SIZE where possible.
[libsigrok.git] / src / hardware / ftdi-la / api.c
index 31195e20e77aa1a71e153b0a87bd2e76afd0be1c..1341730bf36dcfc7ab574a260c972ad6058b99ad 100644 (file)
@@ -28,8 +28,11 @@ static const uint32_t scanopts[] = {
        SR_CONF_CONN,
 };
 
-static const uint32_t devopts[] = {
+static const uint32_t drvopts[] = {
        SR_CONF_LOGIC_ANALYZER,
+};
+
+static const uint32_t devopts[] = {
        SR_CONF_CONTINUOUS,
        SR_CONF_LIMIT_SAMPLES | SR_CONF_SET,
        SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
@@ -108,7 +111,6 @@ static void scan_device(struct ftdi_context *ftdic,
                return;
        }
 
-       /* Allocate memory for our private device context. */
        devc = g_malloc0(sizeof(struct dev_context));
 
        /* Allocate memory for the incoming data. */
@@ -135,7 +137,6 @@ static void scan_device(struct ftdi_context *ftdic,
        }
        sr_dbg("Found an FTDI device: %s.", model);
 
-       /* Register the device with libsigrok. */
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = vendor;
@@ -211,7 +212,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                }
        }
 
-       /* Allocate memory for the FTDI context (ftdic) and initialize it. */
        ftdic = ftdi_new();
        if (!ftdic) {
                sr_err("Failed to initialize libftdi.");
@@ -270,7 +270,6 @@ static int dev_open(struct sr_dev_inst *sdi)
                goto err_ftdi_free;
        }
 
-       /* Purge RX/TX buffers in the FTDI chip. */
        ret = ftdi_usb_purge_buffers(devc->ftdic);
        if (ret < 0) {
                sr_err("Failed to purge FTDI RX/TX buffers (%d): %s.",
@@ -278,7 +277,6 @@ static int dev_open(struct sr_dev_inst *sdi)
                goto err_dev_open_close_ftdic;
        }
 
-       /* Reset the FTDI bitmode. */
        ret = ftdi_set_bitmode(devc->ftdic, 0x00, BITMODE_RESET);
        if (ret < 0) {
                sr_err("Failed to reset the FTDI chip bitmode (%d): %s.",
@@ -385,19 +383,12 @@ static int config_set(uint32_t key, GVariant *data,
 static int config_list(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       GVariant *gvar;
-       GVariantBuilder gvb;
-
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
        case SR_CONF_DEVICE_OPTIONS:
-               return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NULL, devopts);
+               return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
        case SR_CONF_SAMPLERATE:
-               g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
-               gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
-                       samplerates, ARRAY_SIZE(samplerates), sizeof(uint64_t));
-               g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar);
-               *data = g_variant_builder_end(&gvb);
+               *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
                break;
        default:
                return SR_ERR_NA;