]> sigrok.org Git - libsigrok.git/blobdiff - hardware/center-3xx/api.c
Consistently use 'cg' for channel group variables.
[libsigrok.git] / hardware / center-3xx / api.c
index 4cd8ab122fa17b4a09196fea2b1fbfe5e0524b13..376563a78b62d9ddf24007783d7aa941c35149c8 100644 (file)
@@ -155,43 +155,17 @@ static GSList *dev_list(int idx)
        return ((struct drv_context *)(center_devs[idx].di->priv))->instances;
 }
 
-static int dev_open(struct sr_dev_inst *sdi)
-{
-       struct sr_serial_dev_inst *serial;
-
-       serial = sdi->conn;
-       if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
-               return SR_ERR;
-
-       sdi->status = SR_ST_ACTIVE;
-
-       return SR_OK;
-}
-
-static int dev_close(struct sr_dev_inst *sdi)
-{
-       struct sr_serial_dev_inst *serial;
-
-       serial = sdi->conn;
-       if (serial && serial->fd != -1) {
-               serial_close(serial);
-               sdi->status = SR_ST_INACTIVE;
-       }
-
-       return SR_OK;
-}
-
 static int cleanup(int idx)
 {
        return dev_clear(idx);
 }
 
 static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
-               const struct sr_probe_group *probe_group)
+               const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
 
-       (void)probe_group;
+       (void)cg;
 
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
@@ -217,10 +191,10 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
 }
 
 static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_probe_group *probe_group)
+               const struct sr_channel_group *cg)
 {
        (void)sdi;
-       (void)probe_group;
+       (void)cg;
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
@@ -257,7 +231,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
 
        /* Poll every 500ms, or whenever some data comes in. */
        serial = sdi->conn;
-       sr_source_add(serial->fd, G_IO_IN, 500,
+       serial_source_add(serial, G_IO_IN, 500,
                      center_devs[idx].receive_data, (void *)sdi);
 
        return SR_OK;
@@ -265,8 +239,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
-       return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close,
-                                              sdi->conn, LOG_PREFIX);
+       return std_serial_dev_acquisition_stop(sdi, cb_data,
+                       std_serial_dev_close, sdi->conn, LOG_PREFIX);
 }
 
 /* Driver-specific API function wrappers */
@@ -304,8 +278,8 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .config_get = NULL, \
        .config_set = config_set, \
        .config_list = config_list, \
-       .dev_open = dev_open, \
-       .dev_close = dev_close, \
+       .dev_open = std_serial_dev_open, \
+       .dev_close = std_serial_dev_close, \
        .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
        .dev_acquisition_stop = dev_acquisition_stop, \
        .priv = NULL, \