]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/ikalogic-scanaplus/api.c
Simplify channel creation.
[libsigrok.git] / src / hardware / ikalogic-scanaplus / api.c
index d8165c7d855a33718d3d8ce676151f6c245eb9cc..3bd1b2733c0fb1e34d08e08398a7b35fae47da86 100644 (file)
@@ -74,7 +74,6 @@ static int init(struct sr_context *sr_ctx)
 static GSList *scan(GSList *options)
 {
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        struct drv_context *drvc;
        struct dev_context *devc;
        GSList *devices;
@@ -88,10 +87,7 @@ static GSList *scan(GSList *options)
        devices = NULL;
 
        /* Allocate memory for our private device context. */
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto err_free_nothing;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Allocate memory for the incoming compressed samples. */
        if (!(devc->compressed_buf = g_try_malloc0(COMPRESSED_BUF_SIZE))) {
@@ -130,12 +126,9 @@ static GSList *scan(GSList *options)
        sdi->driver = di;
        sdi->priv = devc;
 
-       for (i = 0; channel_names[i]; i++) {
-               if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
-                                          channel_names[i])))
-                       return NULL;
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
+       for (i = 0; channel_names[i]; i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
+                                   channel_names[i]);
 
        devices = g_slist_append(devices, sdi);
        drvc->instances = g_slist_append(drvc->instances, sdi);
@@ -154,7 +147,6 @@ err_free_compressed_buf:
        g_free(devc->compressed_buf);
 err_free_devc:
        g_free(devc);
-err_free_nothing:
 
        return NULL;
 }