]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/link-mso19/api.c
Construct driver array at runtime, from an array of per-file arrays.
[libsigrok.git] / src / hardware / link-mso19 / api.c
index 08fcb4b74ac347a9b4dc09ec293061cba506e8fb..aa8cb77865199427fa674d53dc6f9a43c93d8565 100644 (file)
@@ -178,10 +178,7 @@ static GSList *scan(GSList *options)
 
                //Create the device context and set its params
                struct dev_context *devc;
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                       sr_err("Device context malloc failed.");
-                       return devices;
-               }
+               devc = g_malloc0(sizeof(struct dev_context));
 
                if (mso_parse_serial(iSerial, iProduct, devc) != SR_OK) {
                        sr_err("Invalid iSerial: %s.", iSerial);
@@ -198,13 +195,13 @@ static GSList *scan(GSList *options)
                        devc->protocol_trigger.mask[i] = 0xff;
                }
 
-               if (!(devc->serial = sr_serial_dev_inst_new(conn, serialcomm))) {
-                       g_free(devc);
-                       return devices;
-               }
+               devc->serial = sr_serial_dev_inst_new(conn, serialcomm);
 
-               struct sr_dev_inst *sdi = sr_dev_inst_new(0, SR_ST_INACTIVE,
-                                               manufacturer, product, hwrev);
+               struct sr_dev_inst *sdi = g_malloc0(sizeof(struct sr_dev_inst));
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup(manufacturer);
+               sdi->model = g_strdup(product);
+               sdi->version = g_strdup(hwrev);
 
                if (!sdi) {
                        sr_err("Unable to create device instance for %s",
@@ -218,12 +215,9 @@ static GSList *scan(GSList *options)
                sdi->priv = devc;
 
                for (i = 0; i < NUM_CHANNELS; i++) {
-                       struct sr_channel *ch;
                        chtype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC;
-                       if (!(ch = sr_channel_new(i, chtype, TRUE,
-                                                  mso19_channel_names[i])))
-                               return 0;
-                       sdi->channels = g_slist_append(sdi->channels, ch);
+                       sr_channel_new(sdi, i, chtype, TRUE,
+                                           mso19_channel_names[i]);
                }
 
                //Add the driver