]> sigrok.org Git - libsigrok.git/commitdiff
Simplify channel creation.
authorMartin Ling <redacted>
Thu, 19 Mar 2015 21:37:33 +0000 (21:37 +0000)
committerMartin Ling <redacted>
Thu, 19 Mar 2015 21:37:33 +0000 (21:37 +0000)
We always follow sr_channel_new() with a call to add the channel to the sdi.
Tidy up a bit by adding this functionality to sr_channel_new() instead.

53 files changed:
src/device.c
src/hardware/agilent-dmm/api.c
src/hardware/appa-55ii/api.c
src/hardware/asix-sigma/asix-sigma.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/protocol.c
src/hardware/beaglelogic/api.c
src/hardware/brymen-bm86x/api.c
src/hardware/brymen-dmm/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/center-3xx/api.c
src/hardware/chronovu-la/api.c
src/hardware/colead-slm/api.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/demo.c
src/hardware/fluke-dmm/api.c
src/hardware/fx2lafw/api.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/hameg-hmo/protocol.c
src/hardware/hantek-dso/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/ikalogic-scanaplus/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/lascar-el-usb/protocol.c
src/hardware/link-mso19/api.c
src/hardware/manson-hcs-3xxx/api.c
src/hardware/mic-985xx/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/norma-dmm/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/pipistrello-ols/protocol.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic16/api.c
src/hardware/scpi-pps/api.c
src/hardware/serial-dmm/api.c
src/hardware/sysclk-lwla/api.c
src/hardware/teleinfo/api.c
src/hardware/testo/protocol.c
src/hardware/tondaj-sl-814/api.c
src/hardware/uni-t-dmm/api.c
src/hardware/uni-t-ut32x/api.c
src/hardware/victor-dmm/api.c
src/hardware/yokogawa-dlm/protocol.c
src/hardware/zeroplus-logic-cube/api.c
src/input/binary.c
src/input/chronovu_la8.c
src/input/csv.c
src/input/vcd.c
src/input/wav.c
src/lcr/es51919.c
src/libsigrok-internal.h
src/session_file.c

index 9dd2201e528b05a0848a4cf0e34135dd7232fde9..1c84a7df48d6823f03543f6c580ffe72f94dd5ad 100644 (file)
@@ -42,7 +42,8 @@
  */
 
 /** @private
- *  Allocate and initialize new struct sr_channel
+ *  Allocate and initialize new struct sr_channel and add to sdi.
+ *  @param[in]  sdi The device instance the channel is connected to.
  *  @param[in]  index @copydoc sr_channel::index
  *  @param[in]  type @copydoc sr_channel::type
  *  @param[in]  enabled @copydoc sr_channel::enabled
@@ -50,8 +51,8 @@
  *
  *  @return A new struct sr_channel*.
  */
-SR_PRIV struct sr_channel *sr_channel_new(int index, int type,
-               gboolean enabled, const char *name)
+SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi,
+               int index, int type, gboolean enabled, const char *name)
 {
        struct sr_channel *ch;
 
@@ -62,6 +63,8 @@ SR_PRIV struct sr_channel *sr_channel_new(int index, int type,
        if (name)
                ch->name = g_strdup(name);
 
+       sdi->channels = g_slist_append(sdi->channels, ch);
+
        return ch;
 }
 
@@ -227,13 +230,10 @@ SR_API struct sr_dev_inst *sr_dev_inst_user_new(const char *vendor,
  */
 SR_API int sr_dev_inst_channel_add(struct sr_dev_inst *sdi, int index, int type, const char *name)
 {
-       struct sr_channel *ch;
-
        if (!sdi || sdi->inst_type != SR_INST_USER || index < 0)
                return SR_ERR_ARG;
 
-       ch = sr_channel_new(index, type, TRUE, name);
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, index, type, TRUE, name);
 
        return SR_OK;
 }
index 374c206a8a6de90eef5f0099ce9e6424b8c5e929..7cfb69d81280f06f5f56ad10fd8df7a85d197863 100644 (file)
@@ -84,7 +84,6 @@ static GSList *scan(GSList *options)
        struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_config *src;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *l, *devices;
        int len, i;
@@ -150,8 +149,7 @@ static GSList *scan(GSList *options)
                        sdi->conn = serial;
                        sdi->priv = devc;
                        sdi->driver = di;
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                       sdi->channels = g_slist_append(sdi->channels, ch);
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                        drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                        break;
index 771a686c44d5d98837744708db6e8721e756f05a..b9f767d2035be8a98ae9163ec342ea4efbe1a671 100644 (file)
@@ -55,7 +55,6 @@ static GSList *scan(GSList *options)
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        struct sr_config *src;
        GSList *devices, *l;
        const char *conn, *serialcomm;
@@ -110,10 +109,8 @@ static GSList *scan(GSList *options)
        sdi->priv = devc;
        sdi->driver = di;
 
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T1");
-       sdi->channels = g_slist_append(sdi->channels, ch);
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T2");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "T1");
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "T2");
 
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
index 0e6180cbe1b1e0c74c0fb50601b87ea695eb8793..e1355e9fb0f1240ddd20b2346910518da9b9617d 100644 (file)
@@ -325,7 +325,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;
@@ -383,11 +382,9 @@ static GSList *scan(GSList *options)
        sdi->model = g_strdup(USB_MODEL_NAME);
        sdi->driver = di;
 
-       for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+       for (i = 0; i < ARRAY_SIZE(channel_names); i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                                    channel_names[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
 
        devices = g_slist_append(devices, sdi);
        drvc->instances = g_slist_append(drvc->instances, sdi);
index b72eeb4a59107aff7b415438e23efeb0c904dd71..1eafaaff8d42fbc291396e3d2f98f0131f782984 100644 (file)
@@ -173,8 +173,7 @@ static GSList *scan(GSList *options, int modelid)
        sdi->conn = serial;
        for (i = 0; i < MAX_CHANNELS; i++) {
                snprintf(channel, 10, "CH%d", i + 1);
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel);
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel);
                cg = g_malloc(sizeof(struct sr_channel_group));
                cg->name = g_strdup(channel);
                cg->channels = g_slist_append(NULL, ch);
index 3ceee6c14b7f6d34e4ca5c987f79a18be4f46bb0..461a7b5e4dc10392292a796bdacf9caf45f97a46 100644 (file)
@@ -201,13 +201,12 @@ static void append_channel(struct sr_dev_inst *sdi, struct sr_channel_group *cg,
        cp->ch_type = type;
        cp->probe = cg->priv;
 
-       ch = sr_channel_new(devc->num_channels++,
+       ch = sr_channel_new(sdi, devc->num_channels++,
                            SR_CHANNEL_ANALOG, TRUE, name);
        g_free(name);
 
        ch->priv = cp;
        cg->channels = g_slist_append(cg->channels, ch);
-       sdi->channels = g_slist_append(sdi->channels, ch);
 }
 
 SR_PRIV gboolean bl_acme_register_probe(struct sr_dev_inst *sdi, int type,
index 098efa0627927cc3bb3453ff8d8a0b76d9207baa..e6668ae637e804c2f42667e30d2b21ef7ed5097a 100644 (file)
@@ -86,7 +86,6 @@ static GSList *scan(GSList *options)
        struct sr_config *src;
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
-       struct sr_channel *ch;
        int i, maxch;
 
        devices = NULL;
@@ -136,11 +135,9 @@ static GSList *scan(GSList *options)
        sr_info("BeagleLogic device found at "BEAGLELOGIC_DEV_NODE);
 
        /* Fill the channels */
-       for (i = 0; i < maxch; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+       for (i = 0; i < maxch; i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                                beaglelogic_channel_names[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
 
        sdi->priv = devc;
        drvc->instances = g_slist_append(drvc->instances, sdi);
index 65fcb428ef078af0817dad445e9c4fecfd14b8d5..87d2e5af0ce597102d975e5abf20c43d40672af8 100644 (file)
@@ -48,7 +48,6 @@ static GSList *scan(GSList *options)
        struct sr_dev_inst *sdi;
        struct sr_usb_dev_inst *usb;
        struct sr_config *src;
-       struct sr_channel *ch;
        const char *conn;
 
        drvc = di->priv;
@@ -80,10 +79,8 @@ static GSList *scan(GSList *options)
                devc = g_malloc0(sizeof(struct dev_context));
                sdi->priv = devc;
                sdi->driver = di;
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P2");
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P2");
 
                sdi->inst_type = SR_INST_USB;
                sdi->conn = usb;
index aef784e8ca314396e6ac7b08fc2291f5a069c58a..058835ee9ffb171eedafadc8f67ab9c5461d53c4 100644 (file)
@@ -44,7 +44,6 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
        struct drv_context *drvc;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
        int ret;
@@ -84,8 +83,7 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
        drvc = di->priv;
        sdi->priv = devc;
        sdi->driver = di;
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
index d91c5509b1f55fa908adb1377aad0637313b4e01..5c259542b8babca76036fd096284490780d42290 100644 (file)
@@ -82,7 +82,6 @@ static GSList *scan(GSList *options)
        struct sr_config *src;
        struct sr_serial_dev_inst *serial;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        GSList *l, *devices;
        gint64 start;
        const char *conn;
@@ -122,8 +121,7 @@ static GSList *scan(GSList *options)
                        sdi->inst_type = SR_INST_SERIAL;
                        sdi->priv = devc;
                        sdi->driver = di;
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL");
-                       sdi->channels = g_slist_append(sdi->channels, ch);
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
                        drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                        break;
index c4008d485e9c58fc79d7504f0e809ebdf01e57a2..cc9e3d7a67e570a4b64928fe455422493228800e 100644 (file)
@@ -72,7 +72,6 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct dev_context *devc;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
 
@@ -98,9 +97,8 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        sdi->driver = center_devs[idx].di;
 
        for (i = 0; i <  center_devs[idx].num_channels; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG,
+               sr_channel_new(sdi, i, SR_CHANNEL_ANALOG,
                                    TRUE, channel_names[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
        }
 
        drvc->instances = g_slist_append(drvc->instances, sdi);
index c9d7ec11cbd1aca58d38544ad67adcfd91831f54..14f1066eaa8809a565f2744d7aa9780bcf31d88a 100644 (file)
@@ -80,7 +80,6 @@ static int add_device(int idx, int model, GSList **devices)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct dev_context *devc;
-       struct sr_channel *ch;
 
        ret = SR_OK;
 
@@ -127,11 +126,9 @@ static int add_device(int idx, int model, GSList **devices)
        sdi->driver = di;
        sdi->priv = devc;
 
-       for (i = 0; i < devc->prof->num_channels; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+       for (i = 0; i < devc->prof->num_channels; i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                                    cv_channel_names[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
 
        *devices = g_slist_append(*devices, sdi);
        drvc->instances = g_slist_append(drvc->instances, sdi);
index 34bebd8e6484227438d1996c80222fc1fdaebdbb..6e907cec355e476b2339edab89d1f10cc0edcd95 100644 (file)
@@ -56,7 +56,6 @@ static GSList *scan(GSList *options)
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        struct sr_config *src;
-       struct sr_channel *ch;
        GSList *devices, *l;
        const char *conn, *serialcomm;
 
@@ -91,8 +90,7 @@ static GSList *scan(GSList *options)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->priv = devc;
        sdi->driver = di;
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
index ed7378ee596e5a9f786102cd90e5e75c0c528a84..dc52426441205759a2c21adc3b0efb134122a010 100644 (file)
@@ -51,7 +51,6 @@ static GSList *scan(GSList *options)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct sr_config *src;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *l, *devices;
        const char *conn, *serialcomm;
@@ -100,8 +99,7 @@ static GSList *scan(GSList *options)
        sdi->conn = serial;
        sdi->priv = NULL;
        sdi->driver = di;
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
index 95c9fcfee9e3330102a8456763efb8814c733b6d..fb1bb05fa5091125b0adbd00294ebaff37a8d29f 100644 (file)
@@ -320,8 +320,7 @@ static GSList *scan(GSList *options)
        cg->name = g_strdup("Logic");
        for (i = 0; i < num_logic_channels; i++) {
                sprintf(channel_name, "D%d", i);
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
                cg->channels = g_slist_append(cg->channels, ch);
        }
        sdi->channel_groups = g_slist_append(NULL, cg);
@@ -336,9 +335,8 @@ static GSList *scan(GSList *options)
        devc->ch_ag = g_hash_table_new(g_direct_hash, g_direct_equal);
        for (i = 0; i < num_analog_channels; i++) {
                snprintf(channel_name, 16, "A%d", i);
-               ch = sr_channel_new(i + num_logic_channels, SR_CHANNEL_ANALOG,
+               ch = sr_channel_new(sdi, i + num_logic_channels, SR_CHANNEL_ANALOG,
                                TRUE, channel_name);
-               sdi->channels = g_slist_append(sdi->channels, ch);
                acg->channels = g_slist_append(acg->channels, ch);
 
                /* Every analog channel gets its own channel group as well. */
index e590a4cc8aff6cb4fc4e7a1c014c7c2870e34705..bb903d2f7c98ae2d5b6bb5c1bab9eec9c4f8f9ee 100644 (file)
@@ -69,7 +69,6 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct dev_context *devc;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
        int retry, len, i, s;
@@ -132,8 +131,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
                                sdi->conn = serial;
                                sdi->priv = devc;
                                sdi->driver = di;
-                               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                               sdi->channels = g_slist_append(sdi->channels, ch);
+                               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                                drvc->instances = g_slist_append(drvc->instances, sdi);
                                devices = g_slist_append(devices, sdi);
                                break;
index 46520eb44b1b01fc36eeafed2addd59f672b019b..8e9b5be4a6688651b28096461b931ceb3b9e9efe 100644 (file)
@@ -171,7 +171,6 @@ static GSList *scan(GSList *options)
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        struct sr_usb_dev_inst *usb;
-       struct sr_channel *ch;
        struct sr_config *src;
        const struct fx2lafw_profile *prof;
        GSList *l, *devices, *conn_devices;
@@ -288,11 +287,9 @@ static GSList *scan(GSList *options)
 
                /* Fill in channellist according to this device's profile. */
                num_logic_channels = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
-               for (j = 0; j < num_logic_channels; j++) {
-                       ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
+               for (j = 0; j < num_logic_channels; j++)
+                       sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
                                        channel_names[j]);
-                       sdi->channels = g_slist_append(sdi->channels, ch);
-               }
 
                devc = fx2lafw_dev_new();
                devc->profile = prof;
index 91267d98c3e2df3580ceb6ea9b30f0901df84e68..96d7656c1bbccb189763998b7ed79781a87061df 100644 (file)
@@ -162,7 +162,6 @@ static GSList *scan_1x_2x_rs232(GSList *options)
        struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_config *src;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *l, *devices;
        const char *conn, *serialcomm;
@@ -236,8 +235,7 @@ static GSList *scan_1x_2x_rs232(GSList *options)
                sdi->conn = serial;
                sdi->priv = devc;
                sdi->driver = &gmc_mh_1x_2x_rs232_driver_info;
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
@@ -254,7 +252,6 @@ static GSList *scan_2x_bd232(GSList *options)
        struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_config *src;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *l, *devices;
        const char *conn, *serialcomm;
@@ -332,8 +329,7 @@ static GSList *scan_2x_bd232(GSList *options)
                        sdi->conn = serial;
                        sdi->priv = devc;
                        sdi->driver = &gmc_mh_2x_bd232_driver_info;
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                       sdi->channels = g_slist_append(sdi->channels, ch);
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                        drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                        devc = g_malloc0(sizeof(struct dev_context));
index 28c9fd611950b270efbb441d8102f7be31b4640e..783c3ebc26399f5d9211f1c92567900f07bd65f7 100644 (file)
@@ -616,9 +616,8 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
 
        /* Add analog channels. */
        for (i = 0; i < scope_models[model_index].analog_channels; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
                           (*scope_models[model_index].analog_names)[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
 
                devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
 
@@ -643,9 +642,8 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
 
        /* Add digital channels. */
        for (i = 0; i < scope_models[model_index].digital_channels; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                           (*scope_models[model_index].digital_names)[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
 
                devc->digital_groups[i < 8 ? 0 : 1]->channels = g_slist_append(
                        devc->digital_groups[i < 8 ? 0 : 1]->channels, ch);
index d375c2aac718105ff37c796badee684c14d71f3e..e2d091424ac8821c520f20d23b34f1091c3c6048 100644 (file)
@@ -183,8 +183,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
         * a trigger source internal to the device.
         */
        for (i = 0; channel_names[i]; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
                cg = g_malloc0(sizeof(struct sr_channel_group));
                cg->name = g_strdup(channel_names[i]);
                cg->channels = g_slist_append(cg->channels, ch);
index 798ae8bd9468d7414aed939ddd924ee308b48c08..b9418db2b91ec5dd34843f422db25eae3ff44d79 100644 (file)
@@ -65,7 +65,6 @@ static GSList *scan(GSList *options)
        GSList *usb_devices, *devices, *l;
        struct drv_context *drvc;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
        struct device_info dev_info;
@@ -119,12 +118,9 @@ static GSList *scan(GSList *options)
                sdi->inst_type = SR_INST_USB;
                sdi->conn = usb;
 
-               for (i = 0; channel_names[i]; i++) {
-                       ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
-                               channel_names[i]);
-                       sdi->channels = g_slist_append(sdi->channels, ch);
-                       devc->channels[i] = ch;
-               }
+               for (i = 0; channel_names[i]; i++)
+                       devc->channels[i] = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC,
+                               TRUE, channel_names[i]);
 
                devc->state = STATE_IDLE;
                devc->next_state = STATE_IDLE;
index ea508c0935c21e3b5323b66eb642ae0b94f66c00..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;
@@ -127,11 +126,9 @@ static GSList *scan(GSList *options)
        sdi->driver = di;
        sdi->priv = devc;
 
-       for (i = 0; channel_names[i]; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+       for (i = 0; channel_names[i]; i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                                    channel_names[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
 
        devices = g_slist_append(devices, sdi);
        drvc->instances = g_slist_append(drvc->instances, sdi);
index 0f8304fc9d1ddc56adbf59bd61951219cd00733d..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;
 
@@ -136,8 +135,7 @@ static GSList *scan(GSList *options)
                        sdi->driver = di;
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL");
-                       sdi->channels = g_slist_append(sdi->channels, ch);
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
                        devc = g_malloc0(sizeof(struct dev_context));
                        sdi->priv = devc;
                        devc->limit_samples = 0;
index 801f83b024ad714f5e7a358d9ffcf929812e6199..576d974943230a38c3a78863ead382071a928237 100644 (file)
@@ -293,7 +293,6 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
        struct dev_context *devc;
        const struct elusb_profile *profile;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        int modelid, i;
        char firmware[5];
 
@@ -332,16 +331,12 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
 
                if (profile->logformat == LOG_TEMP_RH) {
                        /* Model this as two channels: temperature and humidity. */
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temp");
-                       sdi->channels = g_slist_append(NULL, ch);
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Hum");
-                       sdi->channels = g_slist_append(sdi->channels, ch);
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "Temp");
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "Hum");
                } else if (profile->logformat == LOG_CO) {
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CO");
-                       sdi->channels = g_slist_append(NULL, ch);
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CO");
                } else {
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                       sdi->channels = g_slist_append(NULL, ch);
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                }
 
                devc = g_malloc0(sizeof(struct dev_context));
index 451cc9347a163d94e8f13196f866aee77cf2a610..aa8cb77865199427fa674d53dc6f9a43c93d8565 100644 (file)
@@ -215,11 +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;
-                       ch = sr_channel_new(i, chtype, TRUE,
+                       sr_channel_new(sdi, i, chtype, TRUE,
                                            mso19_channel_names[i]);
-                       sdi->channels = g_slist_append(sdi->channels, ch);
                }
 
                //Add the driver
index d3e5f8fa70213d94408eda213170e10328e4d3e9..d3bd5e1f4a3adf24497425e19985ec279bbaa1e9 100644 (file)
@@ -92,7 +92,6 @@ static GSList *scan(GSList *options)
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        struct sr_config *src;
-       struct sr_channel *ch;
        GSList *devices, *l;
        const char *conn, *serialcomm;
        struct sr_serial_dev_inst *serial;
@@ -162,8 +161,7 @@ static GSList *scan(GSList *options)
        sdi->conn = serial;
        sdi->driver = di;
 
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
 
        devc = g_malloc0(sizeof(struct dev_context));
        devc->model = &models[model_id];
index 3bc65faa6c1fa086d60f231ead05555c62fb296b..737febafc5818d4a3694b1d01eeb31f44ba8057f 100644 (file)
@@ -71,7 +71,6 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct dev_context *devc;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
 
@@ -100,13 +99,10 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
        sdi->priv = devc;
        sdi->driver = mic_devs[idx].di;
 
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temperature");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "Temperature");
 
-       if (mic_devs[idx].has_humidity) {
-               ch = sr_channel_new(1, SR_CHANNEL_ANALOG, TRUE, "Humidity");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
+       if (mic_devs[idx].has_humidity)
+               sr_channel_new(sdi, 1, SR_CHANNEL_ANALOG, TRUE, "Humidity");
 
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
index f118ebe33bb7593eae4e6d313800527008232122..d54b267c884acc6d773211989b5c2591556858f6 100644 (file)
@@ -470,8 +470,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
        /* Setup channels and channel groups. */
        for (cnt = 0; cnt < models[modelid].num_channels; cnt++) {
                snprintf(channel, sizeof(channel), "CH%d", cnt + 1);
-               ch = sr_channel_new(cnt, SR_CHANNEL_ANALOG, TRUE, channel);
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               ch = sr_channel_new(sdi, cnt, SR_CHANNEL_ANALOG, TRUE, channel);
 
                devc->channel_status[cnt].info = g_slist_append(NULL, ch);
 
index 83e11351060bff50bce99157b9a582e75f1359a2..174425b709e4087d9e2aaf9352d21c69f2cd1144 100644 (file)
@@ -82,7 +82,6 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
        struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_config *src;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *l, *devices;
        int len, cnt;
@@ -155,8 +154,7 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
                        sdi->conn = serial;
                        sdi->priv = devc;
                        sdi->driver = drv;
-                       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                       sdi->channels = g_slist_append(sdi->channels, ch);
+                       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                        drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                        break;
index ca5f4799c584d5f42989e36dd5670055bd5f093d..487f5b2e88f7270d19b9c3f9adb08cbba1d0d087 100644 (file)
@@ -98,7 +98,6 @@ static GSList *scan(GSList *options)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct dev_context *devc;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *l, *devices;
        int ret, i;
@@ -194,11 +193,9 @@ static GSList *scan(GSList *options)
                sdi->model = g_strdup("Logic Analyzer");
                sdi->version = g_strdup("v1.0");
                sdi->driver = di;
-               for (i = 0; i < 32; i++) {
-                       ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+               for (i = 0; i < 32; i++)
+                       sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                                        ols_channel_names[i]);
-                       sdi->channels = g_slist_append(sdi->channels, ch);
-               }
                devc = ols_dev_new();
                sdi->priv = devc;
        }
index b732da59c19e5a271b553a9be7288186e6cb6530..d9c2c2bb18bb246a133a2aa6f14703817aff9240 100644 (file)
@@ -142,7 +142,6 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
-       struct sr_channel *ch;
        uint32_t tmp_int, ui;
        uint8_t key, type, token;
        int delay_ms;
@@ -215,11 +214,9 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
                        switch (token) {
                        case 0x00:
                                /* Number of usable channels */
-                               for (ui = 0; ui < tmp_int; ui++) {
-                                       ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+                               for (ui = 0; ui < tmp_int; ui++)
+                                       sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
                                                        ols_channel_names[ui]);
-                                       sdi->channels = g_slist_append(sdi->channels, ch);
-                               }
                                break;
                        case 0x01:
                                /* Amount of sample memory available (bytes) */
@@ -253,11 +250,9 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
                        switch (token) {
                        case 0x00:
                                /* Number of usable channels */
-                               for (ui = 0; ui < tmp_c; ui++) {
-                                       ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+                               for (ui = 0; ui < tmp_c; ui++)
+                                       sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
                                                        ols_channel_names[ui]);
-                                       sdi->channels = g_slist_append(sdi->channels, ch);
-                               }
                                break;
                        case 0x01:
                                /* protocol version */
index 272c8a8c3baa6f34206a9552cb12b3146de00f58..1d0c9f208839200ee97c5de38fc66d479b55f187 100644 (file)
@@ -219,7 +219,6 @@ SR_PRIV int pols_convert_trigger(const struct sr_dev_inst *sdi)
 SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, struct dev_context *devc)
 {
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        uint32_t tmp_int, ui;
        uint8_t key, type, token;
        GString *tmp_str, *devname, *version;
@@ -288,11 +287,9 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
                        switch (token) {
                        case 0x00:
                                /* Number of usable channels */
-                               for (ui = 0; ui < tmp_int; ui++) {
-                                       ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+                               for (ui = 0; ui < tmp_int; ui++)
+                                       sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
                                                        p_ols_channel_names[ui]);
-                                       sdi->channels = g_slist_append(sdi->channels, ch);
-                               }
                                break;
                        case 0x01:
                                /* Amount of sample memory available (bytes) */
@@ -324,11 +321,9 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
                        switch (token) {
                        case 0x00:
                                /* Number of usable channels */
-                               for (ui = 0; ui < tmp_c; ui++) {
-                                       ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+                               for (ui = 0; ui < tmp_c; ui++)
+                                       sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
                                                        p_ols_channel_names[ui]);
-                                       sdi->channels = g_slist_append(sdi->channels, ch);
-                               }
                                break;
                        case 0x01:
                                /* protocol version */
index a8f8bcdee73e4b18ec33a7f194a158be174b0368..5da9a5eaec94619afb190138859caaff21f15291 100644 (file)
@@ -345,8 +345,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        for (i = 0; i < model->analog_channels; i++) {
                if (!(channel_name = g_strdup_printf("CH%d", i + 1)))
                        return NULL;
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel_name);
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_name);
 
                devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
 
@@ -362,9 +361,8 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) {
                        if (!(channel_name = g_strdup_printf("D%d", i)))
                                return NULL;
-                       ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
+                       ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
                        g_free(channel_name);
-                       sdi->channels = g_slist_append(sdi->channels, ch);
                        devc->digital_group->channels = g_slist_append(
                                        devc->digital_group->channels, ch);
                }
index f33894ea0e0a8f294c4aa5beeaa5c8d191dba14c..cf6063af4790b9e5116bdb12a5725d05fbe8efc0 100644 (file)
@@ -145,7 +145,6 @@ static GSList *scan(GSList *options)
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        struct sr_usb_dev_inst *usb;
-       struct sr_channel *ch;
        struct sr_config *src;
        GSList *l, *devices, *conn_devices;
        struct libusb_device_descriptor des;
@@ -206,11 +205,9 @@ static GSList *scan(GSList *options)
                sdi->driver = di;
                sdi->connection_id = g_strdup(connection_id);
 
-               for (j = 0; channel_names[j]; j++) {
-                       ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
+               for (j = 0; channel_names[j]; j++)
+                       sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
                                            channel_names[j]);
-                       sdi->channels = g_slist_append(sdi->channels, ch);
-               }
 
                devc = g_malloc0(sizeof(struct dev_context));
                devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
index c8070a063335538109aaa278ae96f4a112e9e7ae..4647031c289df9d7a30926e49c91ed9fdbb42915 100644 (file)
@@ -133,13 +133,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                                continue;
                        g_snprintf(ch_name, 16, "%s%s", pci[i].prefix,
                                        channels[ch_num].name);
-                       ch = sr_channel_new(ch_idx++, SR_CHANNEL_ANALOG, TRUE, ch_name);
+                       ch = sr_channel_new(sdi, ch_idx++, SR_CHANNEL_ANALOG, TRUE,
+                                       ch_name);
                        pch = g_malloc0(sizeof(struct pps_channel));
                        pch->hw_output_idx = ch_num;
                        pch->hwname = channels[ch_num].name;
                        pch->mq = pci[i].mq;
                        ch->priv = pch;
-                       sdi->channels = g_slist_append(sdi->channels, ch);
                }
        }
 
index 4bbf230f2b705f3c610df454751006fcda537786..0387c95ae039af0f94c7c59965388f9932872431 100644 (file)
@@ -410,7 +410,6 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct dev_context *devc;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
        int dropped, ret;
@@ -472,8 +471,7 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
        sdi->conn = serial;
        sdi->priv = devc;
        sdi->driver = dmms[dmm].di;
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
index 1e3dd1d28ff6f725aa2d6b7571f5ebc3e7605e08..959b566dcd451b568bb5e4f4d9c6d55a14cf3c72 100644 (file)
@@ -79,30 +79,12 @@ static int init(struct sr_context *sr_ctx)
        return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
-static GSList *gen_channel_list(int num_channels)
-{
-       GSList *list;
-       struct sr_channel *ch;
-       int i;
-       char name[8];
-
-       list = NULL;
-
-       for (i = num_channels; i > 0; --i) {
-               /* The LWLA series simply number channels from CH1 to CHxx. */
-               g_snprintf(name, sizeof(name), "CH%d", i);
-
-               ch = sr_channel_new(i - 1, SR_CHANNEL_LOGIC, TRUE, name);
-               list = g_slist_prepend(list, ch);
-       }
-
-       return list;
-}
-
 static struct sr_dev_inst *dev_inst_new(void)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
+       int i;
+       char name[8];
 
        /* Allocate memory for our private driver context. */
        devc = g_malloc0(sizeof(struct dev_context));
@@ -118,7 +100,11 @@ static struct sr_dev_inst *dev_inst_new(void)
        devc->samplerate = DEFAULT_SAMPLERATE;
 
        sdi->priv = devc;
-       sdi->channels = gen_channel_list(NUM_CHANNELS);
+       for (i = NUM_CHANNELS; i > 0; --i) {
+               /* The LWLA series simply number channels from CH1 to CHxx. */
+               g_snprintf(name, sizeof(name), "CH%d", i);
+               sr_channel_new(sdi, i - 1, SR_CHANNEL_LOGIC, TRUE, name);
+       }
 
        return sdi;
 }
index 5e1dfba1acd4b8692d6edac5730906f86a8d9dd4..c1d9b040914f378a0523821aaf1bbea6d1d9813e 100644 (file)
@@ -49,7 +49,6 @@ static GSList *scan(GSList *options)
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        GSList *devices = NULL, *l;
        const char *conn = NULL, *serialcomm = NULL;
        uint8_t buf[292];
@@ -103,42 +102,27 @@ static GSList *scan(GSList *options)
        sdi->priv = devc;
        sdi->driver = di;
 
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P");
 
        if (devc->optarif == OPTARIF_BASE) {
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "BASE");
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "BASE");
        } else if (devc->optarif == OPTARIF_HC) {
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HP");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HC");
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HP");
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HC");
        } else if (devc->optarif == OPTARIF_EJP) {
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HN");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPM");
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HN");
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPM");
        } else if (devc->optarif == OPTARIF_BBR) {
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJB");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJW");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJR");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJB");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJW");
-               sdi->channels = g_slist_append(sdi->channels, ch);
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJR");
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJB");
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJW");
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJR");
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJB");
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJW");
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJR");
        }
 
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "IINST");
-       sdi->channels = g_slist_append(sdi->channels, ch);
-
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "PAPP");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "IINST");
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "PAPP");
 
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
index bdfaf1fd3103cf9340c686adaa05c39b538166bb..1505e5bc9b4ebbbe2dbceabf036b789dba5f3068 100644 (file)
@@ -59,7 +59,6 @@ SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
-       struct sr_channel *ch;
        int unit, packet_len, len, i;
        unsigned char packet[MAX_REPLY_SIZE], buf[MAX_REPLY_SIZE];
        char *probe_name;
@@ -136,8 +135,7 @@ SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi)
                        sr_dbg("Unsupported measurement unit %d", unit);
                        return SR_ERR;
                }
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, probe_name);
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, probe_name);
        }
        devc->num_channels = packet[6];
        sr_dbg("Found %d channel%s.", devc->num_channels,
index 2ea66ebf59be08f444e1d3469ca49b927c3201ee..cccaeb1d23f47a16d5683827ccdb13a2d95bb563 100644 (file)
@@ -51,7 +51,6 @@ static GSList *scan(GSList *options)
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        struct sr_config *src;
-       struct sr_channel *ch;
        GSList *devices, *l;
        const char *conn, *serialcomm;
        struct sr_serial_dev_inst *serial;
@@ -100,8 +99,7 @@ static GSList *scan(GSList *options)
 
        sdi->priv = devc;
        sdi->driver = di;
-       ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-       sdi->channels = g_slist_append(sdi->channels, ch);
+       sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
index a34873b4c7da835f9943af1a216583e996236ee7..f7b8a94106b46cb2a9faecac4a4c207c4216daf1 100644 (file)
@@ -235,7 +235,6 @@ static GSList *scan(GSList *options, int dmm)
        struct drv_context *drvc;
        struct sr_usb_dev_inst *usb;
        struct sr_config *src;
-       struct sr_channel *ch;
        const char *conn;
 
        drvc = udmms[dmm].di->priv;
@@ -268,8 +267,7 @@ static GSList *scan(GSList *options, int dmm)
                sdi->model = g_strdup(udmms[dmm].device);
                sdi->priv = devc;
                sdi->driver = udmms[dmm].di;
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                sdi->inst_type = SR_INST_USB;
                sdi->conn = usb;
                drvc->instances = g_slist_append(drvc->instances, sdi);
index aa38cf5fb7bd04bb11be8c00b39bdc1d00ce4456..e67a99e3c374bc10aac289c03cc25bdb43892998 100644 (file)
@@ -53,7 +53,6 @@ static GSList *scan(GSList *options)
        struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        struct sr_config *src;
        GSList *usb_devices, *devices, *l;
        int i;
@@ -86,11 +85,8 @@ static GSList *scan(GSList *options)
                        sdi->driver = di;
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
-                       for (i = 0; i < 3; i++) {
-                               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
-                                               channels[i]);
-                               sdi->channels = g_slist_append(sdi->channels, ch);
-                       }
+                       for (i = 0; i < 3; i++)
+                               sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channels[i]);
                        devc = g_malloc0(sizeof(struct dev_context));
                        sdi->priv = devc;
                        devc->limit_samples = 0;
index f2e3d783bb4e816c81667e2434a197dccbe1a840..2552027cec4284f6c2bb382d7257b44997575495 100644 (file)
@@ -59,7 +59,6 @@ static GSList *scan(GSList *options)
        struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        struct libusb_device_descriptor des;
        libusb_device **devlist;
        GSList *devices;
@@ -92,8 +91,7 @@ static GSList *scan(GSList *options)
                devc = g_malloc0(sizeof(struct dev_context));
                sdi->priv = devc;
 
-               ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
-               sdi->channels = g_slist_append(NULL, ch);
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
 
                sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
                                libusb_get_device_address(devlist[i]), NULL);
index 9f5daf1ce9d88bf1093497a08995263d3aa821f5..8acaf023553c6c75243b12440dc684f30d9dd8ab 100644 (file)
@@ -669,9 +669,8 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
 
        /* Add analog channels. */
        for (i = 0; i < scope_models[model_index].analog_channels; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
                                (*scope_models[model_index].analog_names)[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
 
                devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
 
@@ -698,9 +697,8 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
 
        /* Add digital channels. */
        for (i = 0; i < scope_models[model_index].digital_channels; i++) {
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+               ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                                (*scope_models[model_index].digital_names)[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
 
                devc->digital_groups[i / 8]->channels = g_slist_append(
                                devc->digital_groups[i / 8]->channels, ch);
index fa6ef1dc3c76a58ea02c47fb5d3cf412dbe5d999..fd3ef08bcb325578ca66bf0fa502e9f06a4d3fce 100644 (file)
@@ -164,7 +164,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;
        const struct zp_model *prof;
@@ -247,11 +246,9 @@ static GSList *scan(GSList *options)
                // memset(devc->trigger_buffer, 0, NUM_TRIGGER_STAGES);
 
                /* Fill in channellist according to this device's profile. */
-               for (j = 0; j < devc->num_channels; j++) {
-                       ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
+               for (j = 0; j < devc->num_channels; j++)
+                       sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
                                        channel_names[j]);
-                       sdi->channels = g_slist_append(sdi->channels, ch);
-               }
 
                devices = g_slist_append(devices, sdi);
                drvc->instances = g_slist_append(drvc->instances, sdi);
index f9e49de17cb84d766b5a59601c569cb490957050..d7080b0b22bf6c83df05abd26d471c272024c99b 100644 (file)
@@ -39,7 +39,6 @@ struct context {
 
 static int init(struct sr_input *in, GHashTable *options)
 {
-       struct sr_channel *ch;
        struct context *inc;
        int num_channels, i;
        char name[16];
@@ -57,8 +56,7 @@ static int init(struct sr_input *in, GHashTable *options)
 
        for (i = 0; i < num_channels; i++) {
                snprintf(name, 16, "%d", i);
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name);
-               in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+               sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
        }
 
        return SR_OK;
index c28f0e0a811b8afa43006ef86095ab231bbdedf0..244abf19070f7e9f552be0a61d469b3a496a1995 100644 (file)
@@ -51,7 +51,6 @@ static int format_match(GHashTable *metadata)
 
 static int init(struct sr_input *in, GHashTable *options)
 {
-       struct sr_channel *ch;
        struct context *inc;
        int num_channels, i;
        char name[16];
@@ -69,8 +68,7 @@ static int init(struct sr_input *in, GHashTable *options)
 
        for (i = 0; i < num_channels; i++) {
                snprintf(name, 16, "%d", i);
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name);
-               in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+               sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
        }
 
        return SR_OK;
index e89f99aa6852ed02be46c3bbea4f835292375ebc..47fee73e7304aba095e998a7d65e50191428341f 100644 (file)
@@ -472,7 +472,6 @@ static char *get_line_termination(GString *buf)
 static int initial_parse(const struct sr_input *in, GString *buf)
 {
        struct context *inc;
-       struct sr_channel *ch;
        GString *channel_name;
        gsize num_columns, l, i;
        unsigned int line_number;
@@ -558,8 +557,7 @@ static int initial_parse(const struct sr_input *in, GString *buf)
                        g_string_assign(channel_name, columns[i]);
                else
                        g_string_printf(channel_name, "%zu", i);
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name->str);
-               in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+               sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name->str);
        }
        g_string_free(channel_name, TRUE);
 
index f1d0b06cfad9a21add050fdea81ae086e21a24a8..e69a80715676152df8d37a4a8acc644978d503d4 100644 (file)
@@ -404,7 +404,6 @@ static void parse_contents(const struct sr_input *in, char *data)
 
 static int init(struct sr_input *in, GHashTable *options)
 {
-       struct sr_channel *ch;
        int num_channels, i;
        char name[16];
        struct context *inc;
@@ -434,8 +433,7 @@ static int init(struct sr_input *in, GHashTable *options)
 
        for (i = 0; i < num_channels; i++) {
                snprintf(name, 16, "%d", i);
-               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name);
-               in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+               sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
        }
 
        return SR_OK;
index da5a3d5fbe291aff3eee0d4fe4e01eb3841967bb..0c23010eb6f7c5f1dab218356c54c1cf80a4a212 100644 (file)
@@ -240,7 +240,6 @@ static int process_buffer(struct sr_input *in)
        struct context *inc;
        struct sr_datafeed_packet packet;
        struct sr_datafeed_meta meta;
-       struct sr_channel *ch;
        struct sr_config *src;
        int offset, chunk_samples, total_samples, processed, max_chunk_samples;
        int num_samples, i;
@@ -250,8 +249,7 @@ static int process_buffer(struct sr_input *in)
        if (!inc->started) {
                for (i = 0; i < inc->num_channels; i++) {
                        snprintf(channelname, 8, "CH%d", i + 1);
-                       ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channelname);
-                       in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+                       sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
                }
 
                std_session_send_df_header(in->sdi, LOG_PREFIX);
index 862374129e3f836a226333cb413c86299dafbcb2..c6fddc11c87a882e18f562fbf97058fbe99cc69c 100644 (file)
@@ -792,16 +792,6 @@ static int receive_data(int fd, int revents, void *cb_data)
        return TRUE;
 }
 
-static int add_channel(struct sr_dev_inst *sdi, int idx, const char *name)
-{
-       struct sr_channel *ch;
-
-       ch = sr_channel_new(idx, SR_CHANNEL_ANALOG, TRUE, name);
-       sdi->channels = g_slist_append(sdi->channels, ch);
-
-       return SR_OK;
-}
-
 static const char *const channel_names[] = { "P1", "P2" };
 
 static int setup_channels(struct sr_dev_inst *sdi)
@@ -811,11 +801,8 @@ static int setup_channels(struct sr_dev_inst *sdi)
 
        ret = SR_ERR_BUG;
 
-       for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
-               ret = add_channel(sdi, i, channel_names[i]);
-               if (ret != SR_OK)
-                       break;
-       }
+       for (i = 0; i < ARRAY_SIZE(channel_names); i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
 
        return ret;
 }
index 574497c11afa4d5a7bf1a76cead3e33724bde32a..e6f2dbe264f7d8a42d1fd1178c9ba13e05e6cada 100644 (file)
@@ -589,8 +589,8 @@ enum {
        SR_CHANNEL_SET_ENABLED = 1 << 0,
 };
 
-SR_PRIV struct sr_channel *sr_channel_new(int index, int type,
-               gboolean enabled, const char *name);
+SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi,
+               int index, int type, gboolean enabled, const char *name);
 
 /** Device instance data */
 struct sr_dev_inst {
index 26c0df7a3d88806b65e617f25815e86bbc0e66e7..e27ed85c0adf3f256b6a76cefbfab62f8922816a 100644 (file)
@@ -122,7 +122,6 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
        struct zip_file *zf;
        struct zip_stat zs;
        struct sr_dev_inst *sdi;
-       struct sr_channel *ch;
        int ret, i, j;
        uint64_t tmp_u64, total_channels, p;
        char **sections, **keys, *metafile, *val;
@@ -212,9 +211,8 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
                                                        g_variant_new_uint64(total_channels), sdi, NULL);
                                        for (p = 0; p < total_channels; p++) {
                                                snprintf(channelname, SR_MAX_CHANNELNAME_LEN, "%" PRIu64, p);
-                                               ch = sr_channel_new(p, SR_CHANNEL_LOGIC, FALSE,
+                                               sr_channel_new(sdi, p, SR_CHANNEL_LOGIC, FALSE,
                                                                channelname);
-                                               sdi->channels = g_slist_append(sdi->channels, ch);
                                        }
                                } else if (!strncmp(keys[j], "probe", 5)) {
                                        if (!sdi) {