]> sigrok.org Git - libsigrok.git/blobdiff - hardware/link-mso19/link-mso19.c
sr: rename all sr_device_instance_* functions to sr_dev_inst_*
[libsigrok.git] / hardware / link-mso19 / link-mso19.c
index 7e8e797fb4a3f5a213fbac3174e61060d3323cbf..62c3882e59bf3bc1d0ea49153fe09ff23c12e566 100644 (file)
@@ -486,7 +486,7 @@ static int hw_init(const char *deviceinfo)
                        mso->protocol_trigger.spimode = 0;
                }
 
-               sdi = sr_device_instance_new(devcnt, SR_ST_INITIALIZING,
+               sdi = sr_dev_inst_new(devcnt, SR_ST_INITIALIZING,
                        manufacturer, product, hwrev);
                if (!sdi) {
                        sr_err("Unable to create device instance for %s",
@@ -497,7 +497,7 @@ static int hw_init(const char *deviceinfo)
                /* save a pointer to our private instance data */
                sdi->priv = mso;
 
-               sdi->serial = sr_serial_device_instance_new(path, -1);
+               sdi->serial = sr_serial_dev_inst_new(path, -1);
                if (!sdi->serial)
                        goto err_device_instance_free;
 
@@ -506,7 +506,7 @@ static int hw_init(const char *deviceinfo)
                continue;
 
 err_device_instance_free:
-               sr_device_instance_free(sdi);
+               sr_dev_inst_free(sdi);
 err_free_mso:
                g_free(mso);
        }
@@ -518,25 +518,30 @@ ret:
        return devcnt;
 }
 
-static void hw_cleanup(void)
+static int hw_cleanup(void)
 {
        GSList *l;
        struct sr_device_instance *sdi;
+       int ret = SR_OK;
 
        /* Properly close all devices. */
        for (l = device_instances; l; l = l->next) {
-               sdi = l->data;
+               if (!(sdi = l->data)) {
+                       /* Log error, but continue cleaning up the rest. */
+                       sr_err("mso19: %s: sdi was NULL, continuing", __func__);
+                       ret = SR_ERR_BUG;
+                       continue;
+               }
                if (sdi->serial->fd != -1)
                        serial_close(sdi->serial->fd);
-               if (sdi->priv != NULL)
-               {
-                       g_free(sdi->priv);
-                       sdi->priv = NULL;
-               }
-               sr_device_instance_free(sdi);
+               g_free(sdi->priv);
+               sdi->priv = NULL;
+               sr_dev_inst_free(sdi);
        }
        g_slist_free(device_instances);
        device_instances = NULL;
+
+       return SR_OK;
 }
 
 static int hw_opendev(int device_index)
@@ -545,7 +550,7 @@ static int hw_opendev(int device_index)
        struct mso *mso;
        int ret = SR_ERR;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_get_dev_inst(device_instances, device_index)))
                return ret;
 
        mso = sdi->priv;
@@ -585,7 +590,7 @@ static int hw_closedev(int device_index)
 {
        struct sr_device_instance *sdi;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_get_dev_inst(device_instances, device_index))) {
                sr_err("mso19: %s: sdi was NULL", __func__);
                return SR_ERR; /* TODO: SR_ERR_ARG? */
        }
@@ -607,7 +612,7 @@ static void *hw_get_device_info(int device_index, int device_info_id)
        struct mso *mso;
        void *info = NULL;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_get_dev_inst(device_instances, device_index)))
                return NULL;
        mso = sdi->priv;
 
@@ -638,7 +643,7 @@ static int hw_get_status(int device_index)
 {
        struct sr_device_instance *sdi;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_get_dev_inst(device_instances, device_index)))
                return SR_ST_NOT_FOUND;
 
        return sdi->status;
@@ -653,7 +658,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
 {
        struct sr_device_instance *sdi;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_get_dev_inst(device_instances, device_index)))
                return SR_ERR;
 
        switch (capability) {
@@ -750,7 +755,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
        struct sr_datafeed_header header;
        int ret = SR_ERR;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_get_dev_inst(device_instances, device_index)))
                return ret;
        mso = sdi->priv;
 
@@ -816,7 +821,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
 }
 
 /* FIXME */
-static void hw_stop_acquisition(int device_index, gpointer session_device_id)
+static int hw_stop_acquisition(int device_index, gpointer session_device_id)
 {
        struct sr_datafeed_packet packet;
 
@@ -824,6 +829,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
 
        packet.type = SR_DF_END;
        sr_session_bus(session_device_id, &packet);
+
+       return SR_OK;
 }
 
 SR_PRIV struct sr_device_plugin link_mso19_plugin_info = {