]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/center-3xx/api.c
Remove unnecessary dev_clear() callbacks
[libsigrok.git] / src / hardware / center-3xx / api.c
index 3827c63959006e78790c0703ed319b5887bba42d..7f08d9dad70832af465e9833bf60c87b31ee86ba 100644 (file)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <config.h>
 #include "protocol.h"
 
 static const uint32_t scanopts[] = {
@@ -37,7 +38,6 @@ static const uint32_t devopts[] = {
 
 static const char *channel_names[] = {
        "T1", "T2", "T3", "T4",
-       NULL,
 };
 
 SR_PRIV struct sr_dev_driver center_309_driver_info;
@@ -56,11 +56,6 @@ SR_PRIV const struct center_dev_info center_devs[] = {
        },
 };
 
-static int dev_clear(int idx)
-{
-       return std_dev_clear(center_devs[idx].di, NULL);
-}
-
 static int init(struct sr_context *sr_ctx, int idx)
 {
        return std_init(sr_ctx, center_devs[idx].di, LOG_PREFIX);
@@ -80,7 +75,7 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                return NULL;
 
-       drvc = center_devs[idx].di->priv;
+       drvc = center_devs[idx].di->context;
        devices = NULL;
        serial_flush(serial);
 
@@ -96,10 +91,8 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        sdi->priv = devc;
        sdi->driver = center_devs[idx].di;
 
-       for (i = 0; i <  center_devs[idx].num_channels; i++) {
-               sr_channel_new(sdi, i, SR_CHANNEL_ANALOG,
-                                   TRUE, channel_names[i]);
-       }
+       for (i = 0; i < center_devs[idx].num_channels; i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
 
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
@@ -143,12 +136,7 @@ static GSList *scan(GSList *options, int idx)
 
 static GSList *dev_list(int idx)
 {
-       return ((struct drv_context *)(center_devs[idx].di->priv))->instances;
-}
-
-static int cleanup(int idx)
-{
-       return dev_clear(idx);
+       return ((struct drv_context *)(center_devs[idx].di->context))->instances;
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
@@ -206,8 +194,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        return SR_OK;
 }
 
-static int dev_acquisition_start(const struct sr_dev_inst *sdi,
-                                   void *cb_data, int idx)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
 {
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
@@ -216,12 +203,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
                return SR_ERR_DEV_CLOSED;
 
        devc = sdi->priv;
-       devc->cb_data = cb_data;
        devc->num_samples = 0;
        devc->starttime = g_get_monotonic_time();
 
-       /* Send header packet to the session bus. */
-       std_session_send_df_header(cb_data, LOG_PREFIX);
+       std_session_send_df_header(sdi, LOG_PREFIX);
 
        /* Poll every 500ms, or whenever some data comes in. */
        serial = sdi->conn;
@@ -231,50 +216,40 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
        return SR_OK;
 }
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       return std_serial_dev_acquisition_stop(sdi, cb_data,
+       return std_serial_dev_acquisition_stop(sdi,
                        std_serial_dev_close, sdi->conn, LOG_PREFIX);
 }
 
 /* Driver-specific API function wrappers */
 #define HW_INIT(X) \
 static int init_##X(struct sr_dev_driver *d, \
-               struct sr_context *sr_ctx) { \
-       (void) d; return init(sr_ctx, X); }
-#define HW_CLEANUP(X) \
-static int cleanup_##X(const struct sr_dev_driver *d) { \
-       (void) d; return cleanup(X); }
+       struct sr_context *sr_ctx) { (void)d; return init(sr_ctx, X); }
 #define HW_SCAN(X) \
 static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \
-       (void) d; return scan(options, X); }
+       (void)d; return scan(options, X); }
 #define HW_DEV_LIST(X) \
 static GSList *dev_list_##X(const struct sr_dev_driver *d) { \
-       (void) d; return dev_list(X); }
-#define HW_DEV_CLEAR(X) \
-static int dev_clear_##X(const struct sr_dev_driver *d) { \
-       (void) d; return dev_clear(X); }
+       (void)d; return dev_list(X); }
 #define HW_DEV_ACQUISITION_START(X) \
-static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
-void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
+static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
+) { return dev_acquisition_start(sdi, X); }
 
 /* Driver structs and API function wrappers */
 #define DRV(ID, ID_UPPER, NAME, LONGNAME) \
 HW_INIT(ID_UPPER) \
-HW_CLEANUP(ID_UPPER) \
 HW_SCAN(ID_UPPER) \
 HW_DEV_LIST(ID_UPPER) \
-HW_DEV_CLEAR(ID_UPPER) \
 HW_DEV_ACQUISITION_START(ID_UPPER) \
 SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .name = NAME, \
        .longname = LONGNAME, \
        .api_version = 1, \
        .init = init_##ID_UPPER, \
-       .cleanup = cleanup_##ID_UPPER, \
+       .cleanup = std_cleanup, \
        .scan = scan_##ID_UPPER, \
        .dev_list = dev_list_##ID_UPPER, \
-       .dev_clear = dev_clear_##ID_UPPER, \
        .config_get = NULL, \
        .config_set = config_set, \
        .config_list = config_list, \
@@ -282,7 +257,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .dev_close = std_serial_dev_close, \
        .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
        .dev_acquisition_stop = dev_acquisition_stop, \
-       .priv = NULL, \
+       .context = NULL, \
 };
 
 DRV(center_309, CENTER_309, "center-309", "Center 309")