]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/manson-hcs-3xxx/api.c
Remove unnecessary dev_clear() callbacks
[libsigrok.git] / src / hardware / manson-hcs-3xxx / api.c
index 0662a81e1a0472a4c23c5388fca0874fe5997e74..d3901954288801c49370695d767985234fa10065 100644 (file)
@@ -70,16 +70,11 @@ static const struct hcs_model models[] = {
        { MANSON_HCS_3600, "HCS-3600-USB", "3600", { 1, 16, 0.1 }, { 0, 60,   0.10 } },
        { MANSON_HCS_3602, "HCS-3602-USB", "3602", { 1, 32, 0.1 }, { 0, 30,   0.10 } },
        { MANSON_HCS_3604, "HCS-3604-USB", "3604", { 1, 60, 0.1 }, { 0, 15,   0.10 } },
-       { 0, NULL, NULL, { 0, 0, 0 }, { 0, 0, 0 }, },
+       ALL_ZERO
 };
 
 SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info;
 
-static int dev_clear(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
 {
        return std_init(sr_ctx, di, LOG_PREFIX);
@@ -145,12 +140,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                if (!strcmp(models[i].id, tokens[0]))
                        model_id = i;
        }
-       g_strfreev(tokens);
-
        if (model_id < 0) {
-               sr_err("Unknown model id '%s' detected, aborting.", tokens[0]);
+               sr_err("Unknown model ID '%s' detected, aborting.", tokens[0]);
+               g_strfreev(tokens);
                return NULL;
        }
+       g_strfreev(tokens);
 
        /* Init device instance, etc. */
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
@@ -173,8 +168,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
            (hcs_read_reply(serial, 2, reply, sizeof(reply)) < 0))
                goto exit_err;
        tokens = g_strsplit((const gchar *)&reply, "\r", 2);
-       if (hcs_parse_volt_curr_mode(sdi, tokens) < 0)
+       if (hcs_parse_volt_curr_mode(sdi, tokens) < 0) {
+               g_strfreev(tokens);
                goto exit_err;
+       }
        g_strfreev(tokens);
 
        /* Get max. voltage and current. */
@@ -208,11 +205,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -385,7 +377,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)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
@@ -394,10 +386,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                return SR_ERR_DEV_CLOSED;
 
        devc = sdi->priv;
-       devc->cb_data = cb_data;
 
-       /* Send header packet to the session bus. */
-       std_session_send_df_header(cb_data, LOG_PREFIX);
+       std_session_send_df_header(sdi, LOG_PREFIX);
 
        devc->starttime = g_get_monotonic_time();
        devc->num_samples = 0;
@@ -412,9 +402,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        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);
 }
 
@@ -423,10 +413,9 @@ SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info = {
        .longname = "Manson HCS-3xxx",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
-       .dev_clear = dev_clear,
        .config_get = config_get,
        .config_set = config_set,
        .config_list = config_list,