]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/motech-lps-30x/api.c
std_serial_dev_acquisition_stop(): Remove serial parameter
[libsigrok.git] / src / hardware / motech-lps-30x / api.c
index 57bc1d2654e9f9a966c85e7c9e7bf078970b41c8..c5e7b61771628425c003d2f863dd9c322c0981be 100644 (file)
@@ -28,9 +28,6 @@
 #include <math.h>
 #include <string.h>
 #include "protocol.h"
-
-/* Forward declarations */
-SR_PRIV struct sr_dev_driver motech_lps_301_driver_info;
 SR_PRIV int lps_read_reply(struct sr_serial_dev_inst *serial, char **buf, int *buflen);
 SR_PRIV int lps_send_va(struct sr_serial_dev_inst *serial, const char *fmt, va_list args);
 SR_PRIV int lps_cmd_ok(struct sr_serial_dev_inst *serial, const char *fmt, ...);
@@ -369,12 +366,10 @@ SR_PRIV int lps_read_reply(struct sr_serial_dev_inst *serial, char **buf, int *b
 static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *options)
 {
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        struct sr_channel *ch;
        struct sr_channel_group *cg;
-       GSList *devices;
        const char *conn, *serialcomm;
        int cnt, ret;
        gchar buf[LINELEN_MAX];
@@ -384,10 +379,6 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
        sdi = NULL;
        devc = NULL;
        conn = serialcomm = NULL;
-       devices = NULL;
-
-       drvc = drv->context;
-       drvc->instances = NULL;
 
        sr_spew("scan() called!");
 
@@ -450,7 +441,6 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
        sdi->vendor = g_strdup(VENDOR_MOTECH);
        sdi->model = g_strdup(models[modelid].modelstr);
        sdi->version = g_strdup(verstr);
-       sdi->driver = drv;
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
 
@@ -476,18 +466,13 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
                sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
        }
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
-       devices = g_slist_append(devices, sdi);
-
        /* Query status */
        if (lps_query_status(sdi) != SR_OK)
                goto exit_err;
 
        serial_close(serial);
-       if (!devices)
-               sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(drv, g_slist_append(NULL, sdi));
 
 exit_err:
        sr_info("%s: Error!", __func__);
@@ -700,7 +685,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
                return SR_OK;
        case SR_CONF_DEVICE_OPTIONS:
-               if (sdi != NULL)
+               if (sdi)
                        break;
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
                        drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
@@ -785,7 +770,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        serial = sdi->conn;
        serial_source_add(sdi->session, serial, G_IO_IN, 50,
                        motech_lps_30x_receive_data, (void *)sdi);
-       std_session_send_df_header(sdi, LOG_PREFIX);
+       std_session_send_df_header(sdi);
 
        sr_sw_limits_acquisition_start(&devc->limits);
 
@@ -797,11 +782,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close,
-                       sdi->conn, LOG_PREFIX);
+       return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close);
 }
 
-SR_PRIV struct sr_dev_driver motech_lps_301_driver_info = {
+static struct sr_dev_driver motech_lps_301_driver_info = {
        .name = "motech-lps-301",
        .longname = "Motech LPS-301",
        .api_version = 1,
@@ -819,3 +803,4 @@ SR_PRIV struct sr_dev_driver motech_lps_301_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(motech_lps_301_driver_info);