]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/link-mso19/api.c
Use driver name as the log prefix in standard functions
[libsigrok.git] / src / hardware / link-mso19 / api.c
index f2b372eb303c89c2bf1a9b00611cac194444acaa..7924b2311a2b1a4f72b056f37253682454243a8d 100644 (file)
@@ -50,39 +50,6 @@ static const uint64_t samplerates[] = {
        SR_HZ(100),
 };
 
-/* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */
-static int dev_clear(const struct sr_dev_driver *di)
-{
-       struct drv_context *drvc = di->context;
-       GSList *l;
-       struct sr_dev_inst *sdi;
-       struct dev_context *devc;
-       int ret = SR_OK;
-
-       /* Properly close and free all devices. */
-       for (l = drvc->instances; l; l = l->next) {
-               if (!(sdi = l->data)) {
-                       /* Log error, but continue cleaning up the rest. */
-                       sr_err("%s: sdi was NULL, continuing", __func__);
-                       ret = SR_ERR_BUG;
-                       continue;
-               }
-               if (!(devc = sdi->priv)) {
-                       /* Log error, but continue cleaning up the rest. */
-                       sr_err("%s: sdi->priv was NULL, continuing", __func__);
-                       ret = SR_ERR_BUG;
-                       continue;
-               }
-               std_serial_dev_close(sdi);
-               sr_serial_dev_inst_free(devc->serial);
-               sr_dev_inst_free(sdi);
-       }
-       g_slist_free(drvc->instances);
-       drvc->instances = NULL;
-
-       return ret;
-}
-
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        int i;
@@ -192,30 +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);
-
-               if (!sdi) {
-                       sr_err("Unable to create device instance for %s",
-                              sysname);
-                       sr_dev_inst_free(sdi);
-                       g_free(devc);
-                       return devices;
-               }
-
-               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)
@@ -428,7 +380,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        /* Reset trigger state. */
        devc->trigger_state = 0x00;
 
-       std_session_send_df_header(sdi, LOG_PREFIX);
+       std_session_send_df_header(sdi);
 
        /* Our first channel is analog, the other 8 are of type 'logic'. */
        /* TODO. */
@@ -447,7 +399,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
+static struct sr_dev_driver link_mso19_driver_info = {
        .name = "link-mso19",
        .longname = "Link Instruments MSO-19",
        .api_version = 1,
@@ -455,7 +407,6 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
        .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = std_dev_list,
-       .dev_clear = dev_clear,
        .config_get = config_get,
        .config_set = config_set,
        .config_list = config_list,
@@ -465,3 +416,4 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(link_mso19_driver_info);