]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/ikalogic-scanaplus/api.c
Fix #442 by renaming sr_dev_driver.priv to .context
[libsigrok.git] / src / hardware / ikalogic-scanaplus / api.c
index 3bd1b2733c0fb1e34d08e08398a7b35fae47da86..456eb58cd6279520928ef858761a222f13bb2ae6 100644 (file)
@@ -38,14 +38,12 @@ static const uint32_t devopts[] = {
 /* Channels are numbered 1-9. */
 static const char *channel_names[] = {
        "1", "2", "3", "4", "5", "6", "7", "8", "9",
-       NULL,
 };
 
 /* Note: The IKALOGIC ScanaPLUS always samples at 100MHz. */
-static uint64_t samplerates[1] = { SR_MHZ(100) };
+static const uint64_t samplerates[1] = { SR_MHZ(100) };
 
 SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info;
-static struct sr_dev_driver *di = &ikalogic_scanaplus_driver_info;
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
 
@@ -61,17 +59,17 @@ static void clear_helper(void *priv)
        g_free(devc);
 }
 
-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);
 }
 
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
@@ -82,7 +80,7 @@ static GSList *scan(GSList *options)
 
        (void)options;
 
-       drvc = di->priv;
+       drvc = di->context;
 
        devices = NULL;
 
@@ -126,9 +124,8 @@ static GSList *scan(GSList *options)
        sdi->driver = di;
        sdi->priv = devc;
 
-       for (i = 0; channel_names[i]; i++)
-               sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
-                                   channel_names[i]);
+       for (i = 0; i < ARRAY_SIZE(channel_names); 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);
@@ -151,9 +148,9 @@ err_free_devc:
        return NULL;
 }
 
-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)
@@ -263,9 +260,9 @@ static int dev_close(struct sr_dev_inst *sdi)
        return ret;
 }
 
-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,
@@ -423,5 +420,5 @@ SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info = {
        .dev_close = dev_close,
        .dev_acquisition_start = dev_acquisition_start,
        .dev_acquisition_stop = dev_acquisition_stop,
-       .priv = NULL,
+       .context = NULL,
 };