]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/kecheng-kc-330b/api.c
scpi-pps: Add profile for Rigol DP821A.
[libsigrok.git] / src / hardware / kecheng-kc-330b / api.c
index 0e5baef5ea697079dede396d27f09a75efa6c9ca..7f49364a9dda516ddf61068f51f52128bca45ee9 100644 (file)
@@ -113,7 +113,6 @@ static GSList *scan(GSList *options)
        struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        GSList *usb_devices, *devices, *l;
        char *model;
 
@@ -129,21 +128,15 @@ static GSList *scan(GSList *options)
                for (l = usb_devices; l; l = l->next) {
                        if (scan_kecheng(l->data, &model) != SR_OK)
                                continue;
-                       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR,
-                                       model, NULL)))
-                               return NULL;
-                       g_free(model);
+                       sdi = g_malloc0(sizeof(struct sr_dev_inst));
+                       sdi->status = SR_ST_INACTIVE;
+                       sdi->vendor = g_strdup(VENDOR);
+                       sdi->model = model; /* Already g_strndup()'d. */
                        sdi->driver = di;
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
-                       if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
-                               return NULL;
-                       sdi->channels = g_slist_append(sdi->channels, ch);
-
-                       if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-                               sr_dbg("Device context malloc failed.");
-                               return NULL;
-                       }
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
+                       devc = g_malloc0(sizeof(struct dev_context));
                        sdi->priv = devc;
                        devc->limit_samples = 0;
                        /* The protocol provides no way to read the current