]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/sysclk-lwla/api.c
fx2lafw: Replace obsoleted strncmp() calls.
[libsigrok.git] / src / hardware / sysclk-lwla / api.c
index 3bb0c4f3f32b7e2a12ead8fa01766fa791a4477c..1e3dd1d28ff6f725aa2d6b7571f5ebc3e7605e08 100644 (file)
@@ -31,14 +31,14 @@ static const uint32_t scanopts[] = {
 
 static const uint32_t devopts[] = {
        SR_CONF_LOGIC_ANALYZER,
-       SR_CONF_SAMPLERATE,
-       SR_CONF_EXTERNAL_CLOCK,
-       SR_CONF_CLOCK_EDGE,
-       SR_CONF_TRIGGER_MATCH,
-       SR_CONF_TRIGGER_SOURCE,
-       SR_CONF_TRIGGER_SLOPE,
-       SR_CONF_LIMIT_MSEC,
-       SR_CONF_LIMIT_SAMPLES,
+       SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_EXTERNAL_CLOCK | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_CLOCK_EDGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
+       SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
 };
 
 static const int32_t trigger_matches[] = {
@@ -99,26 +99,19 @@ static GSList *gen_channel_list(int num_channels)
        return list;
 }
 
-static struct sr_dev_inst *dev_inst_new(int device_index)
+static struct sr_dev_inst *dev_inst_new(void)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
 
        /* Allocate memory for our private driver context. */
-       devc = g_try_new0(struct dev_context, 1);
-       if (!devc) {
-               sr_err("Device context malloc failed.");
-               return NULL;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Register the device with libsigrok. */
-       sdi = sr_dev_inst_new(device_index, SR_ST_INACTIVE,
-                             VENDOR_NAME, MODEL_NAME, NULL);
-       if (!sdi) {
-               sr_err("Failed to instantiate device.");
-               g_free(devc);
-               return NULL;
-       }
+       sdi = g_malloc0(sizeof(struct sr_dev_inst));
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(VENDOR_NAME);
+       sdi->model = g_strdup(MODEL_NAME);
 
        /* Enable all channels to match the default channel configuration. */
        devc->channel_mask = ALL_CHANNELS_MASK;
@@ -138,7 +131,6 @@ static GSList *scan(GSList *options)
        struct sr_usb_dev_inst *usb;
        struct sr_config *src;
        const char *conn;
-       int device_index;
 
        drvc = di->priv;
        conn = USB_VID_PID;
@@ -152,13 +144,12 @@ static GSList *scan(GSList *options)
        }
        usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn);
        devices = NULL;
-       device_index = g_slist_length(drvc->instances);
 
        for (node = usb_devices; node != NULL; node = node->next) {
                usb = node->data;
 
                /* Create sigrok device instance. */
-               sdi = dev_inst_new(device_index);
+               sdi = dev_inst_new();
                if (!sdi) {
                        sr_usb_dev_inst_free(usb);
                        continue;