]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/link-mso19/api.c
Simplify a few config_set() callbacks.
[libsigrok.git] / src / hardware / link-mso19 / api.c
index 46270ffeb7fed89836e65cd3d295f8f6123b33d8..98e253fee3e77593d7b6f44e447960d546f799c5 100644 (file)
@@ -38,7 +38,7 @@ static const uint32_t devopts[] = {
  *
  * See also: http://www.linkinstruments.com/images/mso19_1113.gif
  */
-SR_PRIV const char *mso19_channel_names[NUM_CHANNELS + 1] = {
+SR_PRIV const char *mso19_channel_names[] = {
        /* Note: DSO needs to be first. */
        "DSO", "0", "1", "2", "3", "4", "5", "6", "7", NULL,
 };
@@ -50,10 +50,9 @@ static const uint64_t samplerates[] = {
 };
 
 SR_PRIV struct sr_dev_driver link_mso19_driver_info;
-static struct sr_dev_driver *di = &link_mso19_driver_info;
 
 /* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */
-static int dev_clear(void)
+static int dev_clear(const struct sr_dev_driver *di)
 {
        GSList *l;
        struct sr_dev_inst *sdi;
@@ -88,12 +87,12 @@ static int dev_clear(void)
        return ret;
 }
 
-static int init(struct sr_context *sr_ctx)
+static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
 {
        return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        int i;
        GSList *devices = NULL;
@@ -195,10 +194,7 @@ 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 = g_malloc0(sizeof(struct sr_dev_inst));
                sdi->status = SR_ST_INACTIVE;
@@ -218,11 +214,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
@@ -234,7 +228,7 @@ static GSList *scan(GSList *options)
        return devices;
 }
 
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
 {
        return ((struct drv_context *)(di->priv))->instances;
 }
@@ -270,7 +264,7 @@ static int dev_open(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
 {
        return dev_clear();
 }
@@ -326,8 +320,6 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
                        ret = SR_ERR_ARG;
                } else {
                        devc->limit_samples = num_samples;
-                       sr_dbg("setting limit_samples to %i\n",
-                              num_samples);
                        ret = SR_OK;
                }
                break;