]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/motech-lps-30x/api.c
Add helper function for scan completion
[libsigrok.git] / src / hardware / motech-lps-30x / api.c
index d8aceb50fa9d21cbfc9225949d11c49ab9d44553..ee1f4f7edf8384cce9a340b7f607db7bb4a3daa7 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, ...);
@@ -133,11 +130,6 @@ static const struct lps_modelspec models[] = {
        },
 };
 
-static int init_lps301(struct sr_dev_driver *di, struct sr_context *sr_ctx)
-{
-       return std_init(di, sr_ctx);
-}
-
 /** Send command to device with va_list.
  */
 SR_PRIV int lps_send_va(struct sr_serial_dev_inst *serial, const char *fmt, va_list args)
@@ -374,7 +366,6 @@ 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;
@@ -391,9 +382,6 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
        conn = serialcomm = NULL;
        devices = NULL;
 
-       drvc = drv->context;
-       drvc->instances = NULL;
-
        sr_spew("scan() called!");
 
        /* Process and check options. */
@@ -455,7 +443,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;
 
@@ -481,7 +468,6 @@ 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 */
@@ -492,7 +478,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
        if (!devices)
                sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(drv, devices);
 
 exit_err:
        sr_info("%s: Error!", __func__);
@@ -705,7 +691,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));
@@ -806,11 +792,11 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        sdi->conn, LOG_PREFIX);
 }
 
-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,
-       .init = init_lps301,
+       .init = std_init,
        .cleanup = std_cleanup,
        .scan = scan_lps301,
        .dev_list = std_dev_list,
@@ -824,3 +810,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);