]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/chronovu-la/api.c
Fix #442 by renaming sr_dev_driver.priv to .context
[libsigrok.git] / src / hardware / chronovu-la / api.c
index c9d7ec11cbd1aca58d38544ad67adcfd91831f54..c4cc2ab097e4a33b6d5ac110c7f0e3694911dc7c 100644 (file)
@@ -39,7 +39,7 @@ static const int32_t trigger_matches[] = {
 };
 
 /* The ChronoVu LA8/LA16 can have multiple VID/PID pairs. */
-static struct {
+static const struct {
        uint16_t vid;
        uint16_t pid;
        int model;
@@ -63,12 +63,12 @@ static void clear_helper(void *priv)
        g_free(devc->final_buf);
 }
 
-static int dev_clear(void)
+static int dev_clear(const struct sr_dev_driver *di)
 {
        return std_dev_clear(di, clear_helper);
 }
 
-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);
 }
@@ -80,11 +80,10 @@ 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;
 
-       drvc = di->priv;
+       drvc = di->context;
 
        /* Allocate memory for our private device context. */
        devc = g_malloc0(sizeof(struct dev_context));
@@ -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,
-                                   cv_channel_names[i]);
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
+       for (i = 0; i < devc->prof->num_channels; i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
+                               cv_channel_names[i]);
 
        *devices = g_slist_append(*devices, sdi);
        drvc->instances = g_slist_append(drvc->instances, sdi);
@@ -145,13 +142,14 @@ err_free_devc:
        return ret;
 }
 
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        int ret;
        unsigned int i;
        GSList *devices;
        struct ftdi_context *ftdic;
 
+       (void)di;
        (void)options;
 
        devices = NULL;
@@ -191,9 +189,9 @@ 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;
+       return ((struct drv_context *)(di->context))->instances;
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
@@ -270,9 +268,9 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
 {
-       return dev_clear();
+       return dev_clear(di);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
@@ -544,5 +542,5 @@ SR_PRIV struct sr_dev_driver chronovu_la_driver_info = {
        .dev_close = dev_close,
        .dev_acquisition_start = dev_acquisition_start,
        .dev_acquisition_stop = dev_acquisition_stop,
-       .priv = NULL,
+       .context = NULL,
 };