]> sigrok.org Git - libsigrok.git/commitdiff
Add helper function for scan completion
authorLars-Peter Clausen <redacted>
Sun, 15 May 2016 16:33:31 +0000 (18:33 +0200)
committerUwe Hermann <redacted>
Fri, 27 May 2016 12:44:24 +0000 (14:44 +0200)
A common task during device scan is to add the newly discovered devices to
the instance list of the driver. Currently this is done by each driver on
its own. This patch introduces a new helper function std_scan_complete()
which takes care of this. The function should be called at the end of a
driver's scan() callback before returning the device list.

Doing this with a helper function provides guaranteed consistent behaviour
among drivers and hopefully paves the way to moving more standard
functionality directly into the sigrok core.

Another common task that every driver has to do for each device instance is
to initialize the device's driver field. So this is done in the new helper
function as well.

All drivers that can make use of the new helper are updated.

Signed-off-by: Lars-Peter Clausen <redacted>
53 files changed:
src/hardware/agilent-dmm/api.c
src/hardware/appa-55ii/api.c
src/hardware/arachnid-labs-re-load-pro/api.c
src/hardware/asix-sigma/api.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/beaglelogic/api.c
src/hardware/brymen-bm86x/api.c
src/hardware/brymen-dmm/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/center-3xx/api.c
src/hardware/chronovu-la/api.c
src/hardware/colead-slm/api.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/demo.c
src/hardware/deree-de5000/api.c
src/hardware/fluke-dmm/api.c
src/hardware/ftdi-la/api.c
src/hardware/fx2lafw/api.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/ikalogic-scanaplus/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/kern-scale/api.c
src/hardware/korad-kaxxxxp/api.c
src/hardware/lascar-el-usb/api.c
src/hardware/lascar-el-usb/protocol.c
src/hardware/lecroy-logicstudio/api.c
src/hardware/link-mso19/api.c
src/hardware/manson-hcs-3xxx/api.c
src/hardware/mic-985xx/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/norma-dmm/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/pce-322a/api.c
src/hardware/pipistrello-ols/api.c
src/hardware/pipistrello-ols/protocol.c
src/hardware/saleae-logic16/api.c
src/hardware/serial-dmm/api.c
src/hardware/sysclk-lwla/api.c
src/hardware/teleinfo/api.c
src/hardware/testo/api.c
src/hardware/tondaj-sl-814/api.c
src/hardware/uni-t-dmm/api.c
src/hardware/uni-t-ut32x/api.c
src/hardware/victor-dmm/api.c
src/hardware/zeroplus-logic-cube/api.c
src/libsigrok-internal.h
src/std.c

index 78e7efe8e4a79cace8ec0ac56b7e0c623a1fb321..1165dc5ae3056702f0050bd1a9d53fa1b2fb9ed7 100644 (file)
@@ -73,7 +73,6 @@ static const struct agdmm_profile supported_agdmm[] = {
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_config *src;
        struct sr_serial_dev_inst *serial;
@@ -82,8 +81,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        const char *conn, *serialcomm;
        char *buf, **tokens;
 
-       drvc = di->context;
-
        devices = NULL;
        conn = serialcomm = NULL;
        for (l = options; l; l = l->next) {
@@ -136,9 +133,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        sdi->inst_type = SR_INST_SERIAL;
                        sdi->conn = serial;
                        sdi->priv = devc;
-                       sdi->driver = di;
                        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                       drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                        break;
                }
@@ -150,7 +145,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        if (!devices)
                sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
index c5700011219e0d60dc45a2aa082c590aed6dfc7e..d93644d5a3e3fd72f8521df8c772a38b0dbac89b 100644 (file)
@@ -99,18 +99,16 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->priv = devc;
-       sdi->driver = di;
 
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "T1");
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "T2");
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
 scan_cleanup:
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 6deb681543553df3f5e6f15c21b73946559fa764..923f6b01e68bff16c095e6c38430520ed32fed7d 100644 (file)
@@ -130,7 +130,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->vendor = g_strdup("Arachnid Labs");
        sdi->model = g_strdup("Re:load Pro");
        sdi->version = g_strdup(buf + 8);
-       sdi->driver = di;
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
 
@@ -146,14 +145,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        devc = g_malloc0(sizeof(struct dev_context));
        sdi->priv = devc;
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
        serial_close(serial);
        if (!devices)
                sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 255d3d542e3216081f33000d5530443e6dc659bc..8f04809e070d7ad39f93f10e3975dbe8f3aa97e9 100644 (file)
@@ -64,7 +64,6 @@ static int dev_clear(const struct sr_dev_driver *di)
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        GSList *devices;
        struct ftdi_device_list *devlist;
@@ -75,8 +74,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        (void)options;
 
-       drvc = di->context;
-
        devices = NULL;
 
        devc = g_malloc0(sizeof(struct dev_context));
@@ -119,19 +116,17 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->status = SR_ST_INITIALIZING;
        sdi->vendor = g_strdup(USB_VENDOR_NAME);
        sdi->model = g_strdup(USB_MODEL_NAME);
-       sdi->driver = di;
 
        for (i = 0; i < ARRAY_SIZE(channel_names); i++)
                sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_names[i]);
 
        devices = g_slist_append(devices, sdi);
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        sdi->priv = devc;
 
        /* We will open the device again when we need it. */
        ftdi_list_free(&devlist);
 
-       return devices;
+       return std_scan_complete(di, devices);
 
 free:
        ftdi_deinit(&devc->ftdic);
index 7fd3b678c8693cae66300abc9321ccdcb212b86c..3b9f11333e55b086003db45b568a928ab6877f8e 100644 (file)
@@ -158,7 +158,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options, int modelid)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("Atten");
        sdi->model = g_strdup(model->name);
-       sdi->driver = di;
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        for (i = 0; i < MAX_CHANNELS; i++) {
@@ -176,14 +175,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options, int modelid)
        devc->config = g_malloc0(sizeof(struct per_channel_config) * model->num_channels);
        devc->delay_ms = delay_ms;
        sdi->priv = devc;
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
        serial_close(serial);
        if (!devices)
                sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static GSList *scan_3203(struct sr_dev_driver *di, GSList *options)
index 1d83228c8b1baa9654a9210198c71ec53478f443..2072ccbd858664d73798dde913e1a307838e3228 100644 (file)
@@ -53,7 +53,6 @@ static const uint64_t samplerates[] = {
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        GSList *devices;
@@ -62,7 +61,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        (void)options;
 
-       drvc = di->context;
        devices = NULL;
 
        devc = g_malloc0(sizeof(struct dev_context));
@@ -72,7 +70,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("BayLibre");
        sdi->model = g_strdup("ACME");
-       sdi->driver = di;
        sdi->priv = devc;
 
        status = bl_acme_is_sane();
@@ -124,9 +121,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                goto err_out;
 
        devices = g_slist_append(devices, sdi);
-       drvc->instances = g_slist_append(drvc->instances, sdi);
 
-       return devices;
+       return std_scan_complete(di, devices);
 
 err_out:
        g_free(devc);
index 10f9a0fbe3a80db0b07470b601a942d6535137f2..a94a917ad811b8fc0bf153a345adfed4145ddf17 100644 (file)
@@ -73,7 +73,6 @@ static struct dev_context *beaglelogic_devc_alloc(void)
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
-       struct drv_context *drvc;
        GSList *devices, *l;
        struct sr_config *src;
        struct sr_dev_inst *sdi;
@@ -81,7 +80,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        int i, maxch;
 
        devices = NULL;
-       drvc = di->context;
 
        /* Probe for /dev/beaglelogic */
        if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
@@ -91,7 +89,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->status = SR_ST_INACTIVE;
        sdi->model = g_strdup("BeagleLogic");
        sdi->version = g_strdup("1.0");
-       sdi->driver = di;
 
        /* Unless explicitly specified, keep max channels to 8 only */
        maxch = 8;
@@ -131,10 +128,9 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                channel_names[i]);
 
        sdi->priv = devc;
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 64acf323423edf227e0732a3fdd1c5d2fda3e0cd..a9ac15b3b37ad9754a750459161468e003fb96c1 100644 (file)
@@ -70,7 +70,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->model = g_strdup("BM869");
                devc = g_malloc0(sizeof(struct dev_context));
                sdi->priv = devc;
-               sdi->driver = di;
                sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P2");
 
@@ -79,11 +78,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
                sr_sw_limits_init(&devc->sw_limits);
 
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 0e9034d3fe97d08829ed5f66c5b50098d76ccf08..54f15c5171c0e4d644b4cb2146eb00ec9e1e7f45 100644 (file)
@@ -37,7 +37,6 @@ static GSList *brymen_scan(struct sr_dev_driver *di, const char *conn,
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
-       struct drv_context *drvc;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
        int ret;
@@ -75,17 +74,14 @@ static GSList *brymen_scan(struct sr_dev_driver *di, const char *conn,
        sr_sw_limits_init(&devc->sw_limits);
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-       drvc = di->context;
        sdi->priv = devc;
-       sdi->driver = di;
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
 scan_cleanup:
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
index af3626b24dc0f09d4c8ce51aeaadb0551a4c06e0..9ee036b6b25b3f8198a96648b7e3837c12db9bde 100644 (file)
@@ -114,9 +114,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        sdi->conn = sr_serial_dev_inst_new(conn, SERIALCOMM);
                        sdi->inst_type = SR_INST_SERIAL;
                        sdi->priv = devc;
-                       sdi->driver = di;
                        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
-                       drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                        break;
                }
@@ -126,7 +124,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 27c8d7e65e11e8963e9b61c1a086ce75730cca19..6b9c0e3981caba693e5de4187dd0a24b1bd73a25 100644 (file)
@@ -60,7 +60,6 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
 {
        int i;
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
@@ -70,7 +69,6 @@ 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->context;
        devices = NULL;
        serial_flush(serial);
 
@@ -84,12 +82,10 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        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]);
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
        serial_close(serial);
@@ -126,7 +122,7 @@ static GSList *scan(GSList *options, int idx)
                devices = center_scan(conn, center_devs[idx].conn, idx);
        }
 
-       return devices;
+       return std_scan_complete(center_devs[idx].di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
index d1a7ec712cbf6ea82128ddef4418332dc7db17ec..ea247d42be898213f75e114195490c04c06a00ee 100644 (file)
@@ -61,20 +61,17 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear(di, clear_helper);
 }
 
-static int add_device(struct sr_dev_driver *di, int model,
-       struct libusb_device_descriptor *des, const char *serial_num,
-       const char *connection_id, libusb_device *usbdev, GSList **devices)
+static int add_device(int model, struct libusb_device_descriptor *des,
+       const char *serial_num, const char *connection_id, libusb_device *usbdev,
+       GSList **devices)
 {
        int ret;
        unsigned int i;
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
 
        ret = SR_OK;
 
-       drvc = di->context;
-
        /* Allocate memory for our private device context. */
        devc = g_malloc0(sizeof(struct dev_context));
 
@@ -116,7 +113,6 @@ static int add_device(struct sr_dev_driver *di, int model,
        sdi->connection_id = g_strdup(connection_id);
        sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(usbdev),
                libusb_get_device_address(usbdev), NULL);
-       sdi->driver = di;
        sdi->priv = devc;
 
        for (i = 0; i < devc->prof->num_channels; i++)
@@ -124,7 +120,6 @@ static int add_device(struct sr_dev_driver *di, int model,
                                cv_channel_names[i]);
 
        *devices = g_slist_append(*devices, sdi);
-       drvc->instances = g_slist_append(drvc->instances, sdi);
 
        if (ret == SR_OK)
                return SR_OK;
@@ -224,7 +219,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                       libusb_get_bus_number(devlist[i]),
                       libusb_get_device_address(devlist[i]), connection_id);
 
-               if ((ret = add_device(di, model, &des, serial_num, connection_id,
+               if ((ret = add_device(model, &des, serial_num, connection_id,
                                        devlist[i], &devices)) < 0) {
                        sr_dbg("Failed to add device: %d.", ret);
                }
@@ -233,7 +228,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        libusb_free_device_list(devlist, 1);
        g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index bc59fd63c7f7def667d5be4cc29c33e49883be49..ded82dd09b6642bb99633b0b51ba65d53ba1e44b 100644 (file)
@@ -44,15 +44,12 @@ static const uint32_t devopts[] = {
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        struct sr_config *src;
        GSList *devices, *l;
        const char *conn, *serialcomm;
 
-       drvc = di->context;
-
        devices = NULL;
 
        conn = serialcomm = NULL;
@@ -81,12 +78,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->conn = sr_serial_dev_inst_new(conn, serialcomm);
        sdi->inst_type = SR_INST_SERIAL;
        sdi->priv = devc;
-       sdi->driver = di;
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
index 44f9f26646fa7683eecd063fe646dff14c60b326..442f6c78b6fc4f5d85746afdd4541ff62d852726 100644 (file)
@@ -90,12 +90,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->model = g_strdup("DIGI 35 CPU");
        sdi->conn = serial;
        sdi->priv = NULL;
-       sdi->driver = di;
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
index 9fa744b1f4e965b448b5509ba277d068adedbc75..083527c8368bf425822110a751adb3ff7dbe70d3 100644 (file)
@@ -284,7 +284,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INACTIVE;
        sdi->model = g_strdup("Demo device");
-       sdi->driver = di;
 
        devc = g_malloc0(sizeof(struct dev_context));
        devc->cur_samplerate = SR_KHZ(200);
@@ -346,9 +345,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        sdi->priv = devc;
        devices = g_slist_append(devices, sdi);
-       drvc->instances = g_slist_append(drvc->instances, sdi);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 675b332e63782b708f8c8ef6cc80f276be8adf7f..2544b5e16992f2735484dc14052943aca77789d0 100644 (file)
 #include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 
-static void std_dev_attach(struct sr_dev_driver *di, struct sr_dev_inst *sdi)
-{
-       struct drv_context *drvc;
-
-       drvc = di->context;
-
-       sdi->driver = di;
-       drvc->instances = g_slist_append(drvc->instances, sdi);
-}
-
 #define LOG_PREFIX "deree-de5000"
 
 static int dev_clear(const struct sr_dev_driver *di)
@@ -49,9 +39,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        if (!(sdi = es51919_serial_scan(options, "DER EE", "DE-5000")))
                return NULL;
 
-       std_dev_attach(di, sdi);
-
-       return g_slist_append(NULL, sdi);
+       return std_scan_complete(di, g_slist_append(NULL, sdi));
 }
 
 static struct sr_dev_driver deree_de5000_driver_info = {
index de4efcd55458c15b1d29f907332dc4159b85ca50..71bd79af5be351c375a51701e51e99bc6a884b45 100644 (file)
@@ -124,9 +124,7 @@ static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
                                sdi->inst_type = SR_INST_SERIAL;
                                sdi->conn = serial;
                                sdi->priv = devc;
-                               sdi->driver = di;
                                sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                               drvc->instances = g_slist_append(drvc->instances, sdi);
                                devices = g_slist_append(devices, sdi);
                                break;
                        }
@@ -140,7 +138,7 @@ static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
        if (!devices)
                sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
index 5f5639f93cee1d7ffe8e773503dff9f9a42ca2dc..78dc23f779f74f4e3bcf9ee06a9557131db1e42b 100644 (file)
@@ -82,7 +82,7 @@ static const struct ftdi_chip_desc *chip_descs[] = {
        &ft232r_desc,
 };
 
-static void scan_device(struct sr_dev_driver *di, struct ftdi_context *ftdic,
+static void scan_device(struct ftdi_context *ftdic,
        struct libusb_device *dev, GSList **devices)
 {
        struct libusb_device_descriptor usb_desc;
@@ -90,10 +90,8 @@ static void scan_device(struct sr_dev_driver *di, struct ftdi_context *ftdic,
        struct dev_context *devc;
        char *vendor, *model, *serial_num;
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        int rv;
 
-       drvc = di->context;
        libusb_get_device_descriptor(dev, &usb_desc);
 
        desc = NULL;
@@ -143,7 +141,6 @@ static void scan_device(struct sr_dev_driver *di, struct ftdi_context *ftdic,
        sdi->vendor = vendor;
        sdi->model = model;
        sdi->serial_num = serial_num;
-       sdi->driver = di;
        sdi->priv = devc;
        sdi->connection_id = g_strdup_printf("d:%u/%u",
                libusb_get_bus_number(dev), libusb_get_device_address(dev));
@@ -153,7 +150,6 @@ static void scan_device(struct sr_dev_driver *di, struct ftdi_context *ftdic,
                                SR_CHANNEL_LOGIC, TRUE, *chan);
 
        *devices = g_slist_append(*devices, sdi);
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        return;
 
 err_free_strings:
@@ -164,8 +160,7 @@ err_free_strings:
        g_free(devc);
 }
 
-static GSList *scan_all(struct ftdi_context *ftdic, struct sr_dev_driver *di,
-       GSList *options)
+static GSList *scan_all(struct ftdi_context *ftdic, GSList *options)
 {
        GSList *devices;
        struct ftdi_device_list *devlist = 0;
@@ -187,7 +182,7 @@ static GSList *scan_all(struct ftdi_context *ftdic, struct sr_dev_driver *di,
 
        curdev = devlist;
        while (curdev) {
-               scan_device(di, ftdic, curdev->dev, &devices);
+               scan_device(ftdic, curdev->dev, &devices);
                curdev = curdev->next;
        }
 
@@ -234,17 +229,17 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                usb = l->data;
                                if (usb->bus == libusb_get_bus_number(devlist[i])
                                        && usb->address == libusb_get_device_address(devlist[i])) {
-                                       scan_device(di, ftdic, devlist[i], &devices);
+                                       scan_device(ftdic, devlist[i], &devices);
                                }
                        }
                }
                libusb_free_device_list(devlist, 1);
        } else
-               devices = scan_all(ftdic, di, options);
+               devices = scan_all(ftdic, options);
 
        ftdi_free(ftdic);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static void clear_helper(void *priv)
index 262f3cd662ce2a3d6c32f52ac445780bc2ffdaf7..46b9ee34e15dc318fb88e506cb3a0ef5a026ef0d 100644 (file)
@@ -323,7 +323,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->vendor = g_strdup(prof->vendor);
                sdi->model = g_strdup(prof->model);
                sdi->version = g_strdup(prof->model_version);
-               sdi->driver = di;
                sdi->serial_num = g_strdup(serial_num);
                sdi->connection_id = g_strdup(connection_id);
 
@@ -359,7 +358,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                if ((prof->dev_caps & DEV_CAPS_16BIT) || (prof->dev_caps & DEV_CAPS_AX_ANALOG))
                        devc->sample_wide = TRUE;
                sdi->priv = devc;
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
 
                if (!strcmp(prof->model, "DSLogic")
@@ -403,7 +401,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        libusb_free_device_list(devlist, 1);
        g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static void clear_dev_context(void *priv)
index 7ba93e4ed87492265127be296899e586e98ca67d..3d18ebdab81858057d0ec04311b46638a35631a8 100644 (file)
@@ -217,13 +217,11 @@ static GSList *scan_1x_2x_rs232(struct sr_dev_driver *di, GSList *options)
                devc->settings_ok = FALSE;
                sdi->conn = serial;
                sdi->priv = devc;
-               sdi->driver = di;
                sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 /**
@@ -310,9 +308,7 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
                        sdi->version = g_strdup_printf("Firmware %d.%d", devc->fw_ver_maj, devc->fw_ver_min);
                        sdi->conn = serial;
                        sdi->priv = devc;
-                       sdi->driver = di;
                        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                       drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                        devc = g_malloc0(sizeof(struct dev_context));
                        sdi = g_malloc0(sizeof(struct sr_dev_inst));
@@ -327,7 +323,7 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
                sr_dev_inst_free(sdi);
        }
 
-       return devices;
+       return std_scan_complete(di, devices);
 
 exit_err:
        sr_info("scan_2x_bd232(): Error!");
index 65b5f04be96c2a44089526f37d21c462a1438d05..5c2a478ad904c5870e715181f4840ab2a817fd89 100644 (file)
@@ -78,13 +78,11 @@ static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount);
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi);
 
-static struct sr_dev_inst *hantek_6xxx_dev_new(struct sr_dev_driver *di,
-       const struct hantek_6xxx_profile *prof)
+static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof)
 {
        struct sr_dev_inst *sdi;
        struct sr_channel *ch;
        struct sr_channel_group *cg;
-       struct drv_context *drvc;
        struct dev_context *devc;
        unsigned int i;
 
@@ -92,7 +90,6 @@ static struct sr_dev_inst *hantek_6xxx_dev_new(struct sr_dev_driver *di,
        sdi->status = SR_ST_INITIALIZING;
        sdi->vendor = g_strdup(prof->vendor);
        sdi->model = g_strdup(prof->model);
-       sdi->driver = di;
 
        for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
                ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
@@ -119,8 +116,6 @@ static struct sr_dev_inst *hantek_6xxx_dev_new(struct sr_dev_driver *di,
        devc->samplerate = DEFAULT_SAMPLERATE;
 
        sdi->priv = devc;
-       drvc = sdi->driver->context;
-       drvc->instances = g_slist_append(drvc->instances, sdi);
 
        return sdi;
 }
@@ -222,7 +217,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                /* Device matches the pre-firmware profile. */
                                prof = &dev_profiles[j];
                                sr_dbg("Found a %s %s.", prof->vendor, prof->model);
-                               sdi = hantek_6xxx_dev_new(di, prof);
+                               sdi = hantek_6xxx_dev_new(prof);
                                sdi->connection_id = g_strdup(connection_id);
                                devices = g_slist_append(devices, sdi);
                                devc = sdi->priv;
@@ -241,7 +236,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                /* Device matches the post-firmware profile. */
                                prof = &dev_profiles[j];
                                sr_dbg("Found a %s %s.", prof->vendor, prof->model);
-                               sdi = hantek_6xxx_dev_new(di, prof);
+                               sdi = hantek_6xxx_dev_new(prof);
                                sdi->connection_id = g_strdup(connection_id);
                                sdi->status = SR_ST_INACTIVE;
                                devices = g_slist_append(devices, sdi);
@@ -258,7 +253,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        }
        libusb_free_device_list(devlist, 1);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 275bbf99d5f7775bf72ecbf1b5990764e9e29208..eb6c8b631b8705ea1309b7d9e7e527d5c72d2bac 100644 (file)
@@ -162,13 +162,11 @@ static const char *coupling[] = {
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi);
 
-static struct sr_dev_inst *dso_dev_new(struct sr_dev_driver *di,
-       const struct dso_profile *prof)
+static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
 {
        struct sr_dev_inst *sdi;
        struct sr_channel *ch;
        struct sr_channel_group *cg;
-       struct drv_context *drvc;
        struct dev_context *devc;
        unsigned int i;
 
@@ -176,7 +174,6 @@ static struct sr_dev_inst *dso_dev_new(struct sr_dev_driver *di,
        sdi->status = SR_ST_INITIALIZING;
        sdi->vendor = g_strdup(prof->vendor);
        sdi->model = g_strdup(prof->model);
-       sdi->driver = di;
 
        /*
         * Add only the real channels -- EXT isn't a source of data, only
@@ -208,8 +205,6 @@ static struct sr_dev_inst *dso_dev_new(struct sr_dev_driver *di,
        devc->triggersource = g_strdup(DEFAULT_TRIGGER_SOURCE);
        devc->triggerposition = DEFAULT_HORIZ_TRIGGERPOS;
        sdi->priv = devc;
-       drvc = di->context;
-       drvc->instances = g_slist_append(drvc->instances, sdi);
 
        return sdi;
 }
@@ -313,7 +308,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                /* Device matches the pre-firmware profile. */
                                prof = &dev_profiles[j];
                                sr_dbg("Found a %s %s.", prof->vendor, prof->model);
-                               sdi = dso_dev_new(di, prof);
+                               sdi = dso_dev_new(prof);
                                sdi->connection_id = g_strdup(connection_id);
                                devices = g_slist_append(devices, sdi);
                                devc = sdi->priv;
@@ -332,7 +327,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                /* Device matches the post-firmware profile. */
                                prof = &dev_profiles[j];
                                sr_dbg("Found a %s %s.", prof->vendor, prof->model);
-                               sdi = dso_dev_new(di, prof);
+                               sdi = dso_dev_new(prof);
                                sdi->connection_id = g_strdup(connection_id);
                                sdi->status = SR_ST_INACTIVE;
                                devices = g_slist_append(devices, sdi);
@@ -349,7 +344,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        }
        libusb_free_device_list(devlist, 1);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 039ba3856d8d6a6af1b5726f90a4a99801b7df33..842bdc212bfecce7872b81f3e7fc4bd7947542c6 100644 (file)
@@ -102,14 +102,12 @@ static const uint8_t coupling_map[] = {
        0x00, 0x08, 0x04
 };
 
-static GSList *scan_port(GSList *devices, struct sr_dev_driver *di,
-                        struct parport *port)
+static GSList *scan_port(GSList *devices, struct parport *port)
 {
        struct sr_dev_inst *sdi;
        struct sr_channel *ch;
        struct sr_channel_group *cg;
        struct dev_context *devc;
-       struct drv_context *drvc;
        int i;
 
        if (ieee1284_open(port, 0, &i) != E1284_OK) {
@@ -135,8 +133,6 @@ static GSList *scan_port(GSList *devices, struct sr_dev_driver *di,
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("Hung-Chang");
        sdi->model = g_strdup("DSO-2100");
-       sdi->driver = di;
-       drvc = di->context;
        sdi->inst_type = 0; /* FIXME */
        sdi->conn = port;
        ieee1284_ref(port);
@@ -169,7 +165,6 @@ static GSList *scan_port(GSList *devices, struct sr_dev_driver *di,
        devc->last_step = 0; /* buffersize = 1000 */
        sdi->priv = devc;
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
 fail3:
@@ -209,7 +204,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        for (i = 0; i < ports.portc; i++)
                if (!strcmp(ports.portv[i]->name, conn)) {
                        port_found = TRUE;
-                       devices = scan_port(devices, di, ports.portv[i]);
+                       devices = scan_port(devices, ports.portv[i]);
                }
 
        if (!port_found) {
@@ -220,7 +215,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        ieee1284_free_ports(&ports);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static void clear_private(void *priv)
index 0c6b8987e08149be2c38c3792f26174227882983..2d194abd5bfe180869ac065cb6e03e8db5368b81 100644 (file)
@@ -106,7 +106,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->version = g_strdup_printf("%u.%u", dev_info.fw_ver_major, dev_info.fw_ver_minor);
                sdi->serial_num = g_strdup_printf("%d", dev_info.serial);
                sdi->priv = devc;
-               sdi->driver = di;
                sdi->inst_type = SR_INST_USB;
                sdi->conn = usb;
 
@@ -145,13 +144,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                devc->xfer_data_out = devc->xfer_buf_out +
                        LIBUSB_CONTROL_SETUP_SIZE;
 
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
 
        g_slist_free(usb_devices);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static void clear_dev_context(void *priv)
index 9b4af07de364754aa143bc8165f583814833cc93..30b62e3ca82fce1109639fe6cfe0cb91049b90de 100644 (file)
@@ -115,19 +115,17 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(USB_VENDOR_NAME);
        sdi->model = g_strdup(USB_MODEL_NAME);
-       sdi->driver = di;
        sdi->priv = devc;
 
        for (i = 0; i < ARRAY_SIZE(channel_names); i++)
                sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_names[i]);
 
        devices = g_slist_append(devices, sdi);
-       drvc->instances = g_slist_append(drvc->instances, sdi);
 
        /* Close device. We'll reopen it again when we need it. */
        scanaplus_close(devc);
 
-       return devices;
+       return std_scan_complete(di, devices);
 
        scanaplus_close(devc);
 err_free_ftdic:
index fcd08eca2e59f3edc94a7b5048ce8b7ff2aa369a..4dacfdc0f90bbb8d6a9312dcd42837754d537d1e 100644 (file)
@@ -124,7 +124,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        sdi->status = SR_ST_INACTIVE;
                        sdi->vendor = g_strdup(VENDOR);
                        sdi->model = model; /* Already g_strndup()'d. */
-                       sdi->driver = di;
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
                        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
@@ -142,14 +141,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
                        /* TODO: Set date/time? */
 
-                       drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                }
                g_slist_free(usb_devices);
        } else
                g_slist_free_full(usb_devices, g_free);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 4d1d6bbcbb8f825746709f5b4aacd1707087d4ae..7fa66bb3a8c498d58ce27b9e1b37478090bcbbd9 100644 (file)
@@ -43,7 +43,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        GSList *l, *devices;
        const char *conn, *serialcomm;
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        int ret;
@@ -77,7 +76,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        sr_info("Probing serial port %s.", conn);
 
-       drvc = di->context;
        devices = NULL;
        serial_flush(serial);
 
@@ -104,15 +102,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->priv = devc;
-       sdi->driver = di;
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "Mass");
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
 scan_cleanup:
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
index bd80b6e1b5e22e0db693f6222b9105586de625bc..be472568ba93ffe832707cd54c978a1632f9f946 100644 (file)
@@ -64,7 +64,6 @@ static const struct korad_kaxxxxp_model models[] = {
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
-       struct drv_context *drvc;
        struct dev_context *devc;
        GSList *devices, *l;
        struct sr_dev_inst *sdi;
@@ -78,7 +77,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        devices = NULL;
        conn = NULL;
        serialcomm = NULL;
-       drvc = di->context;
 
        for (l = options; l; l = l->next) {
                src = l->data;
@@ -140,7 +138,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->model = g_strdup(models[model_id].name);
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-       sdi->driver = di;
 
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
 
@@ -154,14 +151,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        /* Get current status of device. */
        if (korad_kaxxxxp_get_all_values(serial, devc) < 0)
                goto exit_err;
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
        serial_close(serial);
        if (!devices)
                sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 
 exit_err:
        sr_dev_inst_free(sdi);
index 1fd86b7ea00052975b12d3780283cff3b7fd3929..32bb958bce913a6c1a8f36cc3c56bd13547deb52 100644 (file)
@@ -72,14 +72,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        }
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = usb;
-                       drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                }
                g_slist_free(usb_devices);
        } else
                g_slist_free_full(usb_devices, g_free);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index ba9b84f96ffd119b061aebdcbf067b47ee75500a..ceaf9d72d34cce64760d0bdc95ab5df6ae95ac99 100644 (file)
@@ -327,7 +327,6 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
                sdi->vendor = g_strdup(LASCAR_VENDOR);
                sdi->model = g_strdup(profile->modelname);
                sdi->version = g_strdup(firmware);
-               sdi->driver = di;
 
                if (profile->logformat == LOG_TEMP_RH) {
                        /* Model this as two channels: temperature and humidity. */
index 69852b28ad49dd76b19aaca3e1d32241586f44c7..60325fe4b66bd23ff3d84f548de6630eb0f8e871 100644 (file)
@@ -71,9 +71,8 @@ static const uint64_t samplerates[] = {
        SR_MHZ(500),
 };
 
-static struct sr_dev_inst *create_device(struct sr_dev_driver *di,
-               struct sr_usb_dev_inst *usb, enum sr_dev_inst_status status,
-               int64_t fw_updated)
+static struct sr_dev_inst *create_device(struct sr_usb_dev_inst *usb,
+               enum sr_dev_inst_status status, int64_t fw_updated)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
@@ -84,7 +83,6 @@ static struct sr_dev_inst *create_device(struct sr_dev_driver *di,
        sdi->status = status;
        sdi->vendor = g_strdup("LeCroy");
        sdi->model = g_strdup("LogicStudio16");
-       sdi->driver = di;
        sdi->inst_type = SR_INST_USB;
        sdi->conn = usb;
 
@@ -140,7 +138,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        usb = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
                                libusb_get_device_address(devlist[i]), NULL);
 
-                       sdi = create_device(di, usb, SR_ST_INACTIVE, 0);
+                       sdi = create_device(usb, SR_ST_INACTIVE, 0);
                        break;
                case LOGICSTUDIO16_PID_LACK_FIRMWARE:
                        r = ezusb_upload_firmware(drvc->sr_ctx, devlist[i],
@@ -161,7 +159,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        usb = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
                                UNKNOWN_ADDRESS, NULL);
 
-                       sdi = create_device(di, usb, SR_ST_INITIALIZING,
+                       sdi = create_device(usb, SR_ST_INITIALIZING,
                                g_get_monotonic_time());
                        break;
                default:
@@ -174,13 +172,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
                sdi->connection_id = g_strdup(connection_id);
 
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
 
        libusb_free_device_list(devlist, 1);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int open_device(struct sr_dev_inst *sdi)
index 99af8dc006368302ec99758208ee4793ee32801a..a3b00869b76ad34c488fdc2d015314fa0ffece96 100644 (file)
@@ -159,21 +159,15 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->vendor = g_strdup(manufacturer);
                sdi->model = g_strdup(product);
                sdi->version = g_strdup(hwrev);
-               sdi->driver = di;
                sdi->priv = devc;
 
                for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
                        chtype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC;
                        sr_channel_new(sdi, i, chtype, TRUE, channel_names[i]);
                }
-
-               //Add the driver
-               struct drv_context *drvc = di->context;
-               drvc->instances = g_slist_append(drvc->instances, sdi);
-               devices = g_slist_append(devices, sdi);
        }
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 0b0a053e7bd2630854eab1abf8365ebdfd9a6d22..b6449cf6a79d9daf428384971b4b035a1cd630e5 100644 (file)
@@ -76,7 +76,6 @@ static const struct hcs_model models[] = {
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        int i, model_id;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        struct sr_config *src;
@@ -85,7 +84,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        struct sr_serial_dev_inst *serial;
        char reply[50], **tokens, *dummy;
 
-       drvc = di->context;
        devices = NULL;
        conn = NULL;
        serialcomm = NULL;
@@ -146,7 +144,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->model = g_strdup(models[model_id].name);
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-       sdi->driver = di;
 
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
 
@@ -177,14 +174,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        devc->voltage_max_device = g_strtod(tokens[0], &dummy) * devc->model->voltage[2];
        g_strfreev(tokens);
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
        serial_close(serial);
        if (!devices)
                sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 
 exit_err:
        sr_dev_inst_free(sdi);
index 329a14b6da8335109fdc89291169d44587512aef..d29cc7ef6b2f675c90c69c2b7441063c735b0d9f 100644 (file)
@@ -60,7 +60,6 @@ SR_PRIV const struct mic_dev_info mic_devs[] = {
 static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
 {
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
@@ -70,7 +69,6 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                return NULL;
 
-       drvc = mic_devs[idx].di->context;
        devices = NULL;
        serial_flush(serial);
 
@@ -89,19 +87,17 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->priv = devc;
-       sdi->driver = mic_devs[idx].di;
 
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "Temperature");
 
        if (mic_devs[idx].has_humidity)
                sr_channel_new(sdi, 1, SR_CHANNEL_ANALOG, TRUE, "Humidity");
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(mic_devs[idx].di, devices);
 }
 
 static GSList *scan(GSList *options, int idx)
index ce3294e979271921e299d74e62e0f815b37b54d4..ee1f4f7edf8384cce9a340b7f607db7bb4a3daa7 100644 (file)
@@ -366,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;
@@ -383,8 +382,6 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
        conn = serialcomm = NULL;
        devices = NULL;
 
-       drvc = drv->context;
-
        sr_spew("scan() called!");
 
        /* Process and check options. */
@@ -446,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;
 
@@ -472,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 */
@@ -483,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__);
index 024bcaed13c139387514bf1b208c476511de0ccd..2d154a408914e69dbda876741c9f7435be30f0a0 100644 (file)
@@ -68,7 +68,6 @@ static const char *get_typestr(int type, struct sr_dev_driver *drv)
 static GSList *scan(struct sr_dev_driver *drv, GSList *options)
 {
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_config *src;
        struct sr_serial_dev_inst *serial;
@@ -79,7 +78,6 @@ static GSList *scan(struct sr_dev_driver *drv, GSList *options)
        char req[10];
 
        devices = NULL;
-       drvc = drv->context;
        conn = serialcomm = NULL;
 
        for (l = options; l; l = l->next) {
@@ -138,9 +136,7 @@ static GSList *scan(struct sr_dev_driver *drv, GSList *options)
                        devc->version = g_strdup(&buf[9]);
                        sdi->conn = serial;
                        sdi->priv = devc;
-                       sdi->driver = drv;
                        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-                       drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                        break;
                }
@@ -163,7 +159,7 @@ static GSList *scan(struct sr_dev_driver *drv, GSList *options)
        if (!devices)
                sr_serial_dev_inst_free(serial);
 
-       return devices;
+       return std_scan_complete(drv, devices);
 }
 
 static int dev_close(struct sr_dev_inst *sdi)
index 56161c5bcd7d5bbfda08e84e6ab0362881d4d426..ecd8a081c8418cead64ab8c262e0103d89511c1d 100644 (file)
@@ -89,7 +89,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_config *src;
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct sr_serial_dev_inst *serial;
        GSList *l, *devices;
        int ret;
@@ -97,8 +96,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        const char *conn, *serialcomm;
        char buf[8];
 
-       drvc = di->context;
-
        devices = NULL;
 
        conn = serialcomm = NULL;
@@ -182,7 +179,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->vendor = g_strdup("Sump");
                sdi->model = g_strdup("Logic Analyzer");
                sdi->version = g_strdup("v1.0");
-               sdi->driver = di;
                for (i = 0; i < ARRAY_SIZE(ols_channel_names); i++)
                        sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                                        ols_channel_names[i]);
@@ -195,12 +191,11 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
@@ -570,7 +565,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver ols_driver_info = {
+static struct sr_dev_driver ols_driver_info = {
        .name = "ols",
        .longname = "Openbench Logic Sniffer",
        .api_version = 1,
index 15f1b3c03e9ff42b27569ed6b0010cc880e9b925..f88729d573039467bfc63d91e83e44efc0d3bbeb 100644 (file)
@@ -20,8 +20,6 @@
 #include <config.h>
 #include "protocol.h"
 
-extern SR_PRIV struct sr_dev_driver ols_driver_info;
-
 SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial,
                uint8_t command)
 {
@@ -149,7 +147,6 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INACTIVE;
-       sdi->driver = &ols_driver_info;
        devc = ols_dev_new();
        sdi->priv = devc;
 
index 8e408c1a7c51b8217f839e325735e189c89871fa..25094470ea7e565a8fe4e1c2e88923cfa3a0d5f6 100644 (file)
@@ -59,7 +59,6 @@ static const uint64_t meas_ranges[][2] = {
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_config *src;
        struct sr_serial_dev_inst *serial;
@@ -82,7 +81,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                return NULL;
 
        devices = NULL;
-       drvc = di->context;
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INACTIVE;
@@ -93,14 +91,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->conn = sr_serial_dev_inst_new(conn, SERIALCOMM);
        sdi->inst_type = SR_INST_SERIAL;
        sdi->priv = devc;
-       sdi->driver = di;
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
index eb81c781b5388116da19ab23207873a994871f5a..91c7dc2f17a11c3a22b8e3e3ad258c69e2b11d2c 100644 (file)
@@ -78,7 +78,6 @@ static const uint64_t samplerates[] = {
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        GSList *devices;
        int ret, i;
@@ -87,8 +86,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        (void)options;
 
-       drvc = di->context;
-
        devices = NULL;
 
        /* Allocate memory for our private device context. */
@@ -177,10 +174,9 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sr_dbg("Failed to set default samplerate (%"PRIu64").",
                                DEFAULT_SAMPLERATE);
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
-       return devices;
+       return std_scan_complete(di, devices);
 
 err_close_ftdic:
        p_ols_close(devc);
index d49d0e6ab4d07c0d17cc640a7141e3d64db632ec..421934b2318d3bd2cea53927cea4b0150e937610 100644 (file)
@@ -20,8 +20,6 @@
 #include <config.h>
 #include "protocol.h"
 
-extern SR_PRIV struct sr_dev_driver p_ols_driver_info;
-
 SR_PRIV int write_shortcommand(struct dev_context *devc, uint8_t command)
 {
        uint8_t buf[1];
@@ -227,7 +225,6 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INACTIVE;
-       sdi->driver = &p_ols_driver_info;
        sdi->priv = devc;
 
        devname = g_string_new("");
index 906313d61a7c4b980059fc7ed8d8ede0c3313b63..3eb9f4034364b882e30cfeefadbf9bdc706bf298 100644 (file)
@@ -191,7 +191,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->status = SR_ST_INITIALIZING;
                sdi->vendor = g_strdup("Saleae");
                sdi->model = g_strdup("Logic16");
-               sdi->driver = di;
                sdi->connection_id = g_strdup(connection_id);
 
                for (j = 0; j < ARRAY_SIZE(channel_names); j++)
@@ -201,7 +200,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                devc = g_malloc0(sizeof(struct dev_context));
                devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
                sdi->priv = devc;
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
 
                if (check_conf_profile(devlist[i])) {
@@ -227,7 +225,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        libusb_free_device_list(devlist, 1);
        g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int logic16_dev_open(struct sr_dev_inst *sdi)
index 3ccce70c1bbe514df930dd1327d9ad1c734195eb..af70fc302a0a7c811a0b7a7f4958e0dcaa403f46 100644 (file)
@@ -48,7 +48,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        GSList *l, *devices;
        const char *conn, *serialcomm;
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        int dropped, ret;
@@ -82,7 +81,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        sr_info("Probing serial port %s.", conn);
 
-       drvc = di->context;
        devices = NULL;
        serial_flush(serial);
 
@@ -130,15 +128,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->priv = devc;
-       sdi->driver = di;
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
 scan_cleanup:
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
index c66cbeb06a6ab71a15fd45b935732dc4815277e6..2b20db838e99cf5441f0bb40d415b63e94c9abce 100644 (file)
@@ -194,15 +194,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        continue; /* no match */
 
                /* Register device instance with driver. */
-               sdi->driver = di;
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
 
        libusb_free_device_list(devlist, 1);
        g_slist_free_full(conn_devices, (GDestroyNotify)&sr_usb_dev_inst_free);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 /* Destroy the private device context.
index f5920c5b52105d8507d8dfbc916be044b0a9a953..8934433764cd0a57756d2bcbb23a9498868ea53f 100644 (file)
@@ -38,7 +38,6 @@ static const uint32_t devopts[] = {
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
        struct sr_dev_inst *sdi;
@@ -73,7 +72,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        sr_info("Probing serial port %s.", conn);
 
-       drvc = di->context;
        serial_flush(serial);
 
        /* Let's get a bit of data and see if we can find a packet. */
@@ -92,7 +90,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->priv = devc;
-       sdi->driver = di;
 
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P");
 
@@ -116,13 +113,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "IINST");
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "PAPP");
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
 scan_cleanup:
        serial_close(serial);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
index 505df6757a6ae7744825cfbf882e31df0f1b6065..4d9a7a42a6469294db89e1130c1cdfd30c42ac51 100644 (file)
@@ -128,13 +128,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->priv = devc;
                if (testo_probe_channels(sdi) != SR_OK)
                        continue;
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
        libusb_free_device_list(devlist, 1);
        g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index d79bc03d53ac4b60714cf829a826dc4c5e089a50..cdb6f18652c5e68f6d0d29f8d7061bae9c7be918 100644 (file)
@@ -92,12 +92,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        sdi->conn = serial;
 
        sdi->priv = devc;
-       sdi->driver = di;
        sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
-       drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
index c708d879d0beb8ed45b10f32163326ac517bc3e8..02e301cc2a7841ab8d149adb8a63af6b84e2b901 100644 (file)
@@ -87,15 +87,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->vendor = g_strdup(dmm->vendor);
                sdi->model = g_strdup(dmm->device);
                sdi->priv = devc;
-               sdi->driver = di;
                sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                sdi->inst_type = SR_INST_USB;
                sdi->conn = usb;
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 147ac7dfe6f041be7b3e4d24d6bf7ef028fdc885..bc4ad43816004da970501cf8a417a74d7679b1a0 100644 (file)
@@ -70,7 +70,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        sdi->status = SR_ST_INACTIVE;
                        sdi->vendor = g_strdup(VENDOR);
                        sdi->model = g_strdup(MODEL);
-                       sdi->driver = di;
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
                        for (i = 0; i < ARRAY_SIZE(channel_names); i++)
@@ -80,14 +79,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        sdi->priv = devc;
                        devc->limit_samples = 0;
                        devc->data_source = DEFAULT_DATA_SOURCE;
-                       drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
                }
                g_slist_free(usb_devices);
        } else
                g_slist_free_full(usb_devices, g_free);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 6a70b14537a1659cd895e3a64c3bc3c08c1186c5..3a132a179ca13d1ea451a7a8850080bd7ec6b3f5 100644 (file)
@@ -76,7 +76,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi = g_malloc0(sizeof(struct sr_dev_inst));
                sdi->status = SR_ST_INACTIVE;
                sdi->vendor = g_strdup(VICTOR_VENDOR);
-               sdi->driver = di;
                sdi->connection_id = g_strdup(connection_id);
                devc = g_malloc0(sizeof(struct dev_context));
                sr_sw_limits_init(&devc->limits);
@@ -87,12 +86,11 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                libusb_get_device_address(devlist[i]), NULL);
                sdi->inst_type = SR_INST_USB;
 
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
        libusb_free_device_list(devlist, 1);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 2cbb5f614357f83c290ae26a55ce1996ce8bbfb7..547d8152c91d1a576f9d6cdcafe39f5b03655fa4 100644 (file)
@@ -212,7 +212,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                sdi->status = SR_ST_INACTIVE;
                sdi->vendor = g_strdup(VENDOR_NAME);
                sdi->model = g_strdup(prof->model_name);
-               sdi->driver = di;
                sdi->serial_num = g_strdup(serial_num);
                sdi->connection_id = g_strdup(connection_id);
 
@@ -238,7 +237,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                        channel_names[j]);
 
                devices = g_slist_append(devices, sdi);
-               drvc->instances = g_slist_append(drvc->instances, sdi);
                sdi->inst_type = SR_INST_USB;
                sdi->conn = sr_usb_dev_inst_new(
                        libusb_get_bus_number(devlist[i]),
@@ -246,7 +244,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        }
        libusb_free_device_list(devlist, 1);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 68f0a296c1cc208c2571ca38352b6530b1ba82ad..ad578e98244ae3b3f47452377daf02279c6b3c14 100644 (file)
@@ -938,6 +938,7 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
                std_dev_clear_callback clear_private);
 SR_PRIV GSList *std_dev_list(const struct sr_dev_driver *di);
 SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi);
+SR_PRIV GSList *std_scan_complete(struct sr_dev_driver *di, GSList *devices);
 
 /*--- resource.c ------------------------------------------------------------*/
 
index a03e509c732b4c0693ef6ee69638bffa9acc236a..4af3c6816266aa91ed097957f1583614c888a7a3 100644 (file)
--- a/src/std.c
+++ b/src/std.c
@@ -349,3 +349,51 @@ SR_PRIV GSList *std_dev_list(const struct sr_dev_driver *di)
 
        return drvc->instances;
 }
+
+/**
+ * Standard scan() callback API helper.
+ *
+ * This function can be used to perform common tasks required by a driver's
+ * scan() callback. It will initialize the driver for each device on the list
+ * and add the devices on the list to the driver's device instance list.
+ * Usually it should be used as the last step in the scan() callback, right
+ * before returning.
+ *
+ * Note: This function can only be used if std_init() has been called
+ * previously by the driver.
+ *
+ * Example:
+ * @code{c}
+ * static GSList *scan(struct sr_dev_driver *di, GSList *options)
+ * {
+ *     struct GSList *device;
+ *     struct sr_dev_inst *sdi;
+ *
+ *     sdi = g_new0(sr_dev_inst, 1);
+ *     sdi->vendor = ...;
+ *     ...
+ *     devices = g_slist_append(devices, sdi);
+ *     ...
+ *     return std_scan_complete(di, devices);
+ * }
+ * @endcode
+ *
+ * @param di The driver instance to use.
+ * @param devices List of newly discovered devices (struct sr_dev_inst).
+ *
+ * @return The @p devices list.
+ */
+SR_PRIV GSList *std_scan_complete(struct sr_dev_driver *di, GSList *devices)
+{
+       struct drv_context *drvc = di->context;
+       GSList *l;
+
+       for (l = devices; l; l = l->next) {
+               struct sr_dev_inst *sdi = l->data;
+               sdi->driver = di;
+       }
+
+       drvc->instances = g_slist_concat(drvc->instances, g_slist_copy(devices));
+
+       return devices;
+}