]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/conrad-digi-35-cpu/api.c
Pass driver struct pointer to driver callbacks.
[libsigrok.git] / src / hardware / conrad-digi-35-cpu / api.c
index 850e29b04c9165733dfca37dcbd075de6afcd8e1..a9ea575e5d9f5f82bdcc41471328e53a8d2898ba 100644 (file)
@@ -39,19 +39,17 @@ static const uint32_t devopts[] = {
 };
 
 SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info;
-static struct sr_dev_driver *di = &conrad_digi_35_cpu_driver_info;
 
-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;
        struct sr_config *src;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *l, *devices;
        const char *conn, *serialcomm;
@@ -83,8 +81,7 @@ static GSList *scan(GSList *options)
         * the device is there.
         */
 
-       if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
-               return NULL;
+       serial = sr_serial_dev_inst_new(conn, serialcomm);
 
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                return NULL;
@@ -101,22 +98,19 @@ static GSList *scan(GSList *options)
        sdi->conn = serial;
        sdi->priv = NULL;
        sdi->driver = di;
-       if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1")))
-               return NULL;
-       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);
 
        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 cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
 {
        return std_dev_clear(di, NULL);
 }