]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/beaglelogic/api.c
serial-dmm: Use g_malloc()/g_free().
[libsigrok.git] / src / hardware / beaglelogic / api.c
index 098efa0627927cc3bb3453ff8d8a0b76d9207baa..d10d071bff0b54eca7e1aa109742950b8be758ee 100644 (file)
@@ -21,7 +21,6 @@
 #include "beaglelogic.h"
 
 SR_PRIV struct sr_dev_driver beaglelogic_driver_info;
-static struct sr_dev_driver *di = &beaglelogic_driver_info;
 
 /* Scan options */
 static const uint32_t scanopts[] = {
@@ -61,7 +60,7 @@ static const uint64_t samplerates[] = {
        SR_HZ(1),
 };
 
-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);
 }
@@ -79,14 +78,13 @@ static struct dev_context *beaglelogic_devc_alloc(void)
        return devc;
 }
 
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct drv_context *drvc;
        GSList *devices, *l;
        struct sr_config *src;
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
-       struct sr_channel *ch;
        int i, maxch;
 
        devices = NULL;
@@ -136,11 +134,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);
@@ -149,12 +145,12 @@ 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;
 }
 
-static int dev_clear(void)
+static int dev_clear(const struct sr_dev_driver *di)
 {
        return std_dev_clear(di, NULL);
 }
@@ -203,7 +199,7 @@ 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)
 {
        struct drv_context *drvc;
        struct sr_dev_inst *sdi;
@@ -223,8 +219,6 @@ static int cleanup(void)
        g_slist_free(drvc->instances);
        drvc->instances = NULL;
 
-       di->priv = NULL;
-
        return SR_OK;
 }