]> sigrok.org Git - libsigrok.git/blobdiff - hardware/chronovu-la8/chronovu-la8.c
sr: rename more functions to sr_thing_action format
[libsigrok.git] / hardware / chronovu-la8 / chronovu-la8.c
index b0609f7e175ad1ca3d1158be515af294b655a318..189d7a8cdc53caaf2f404ef27c18a764f3199c11 100644 (file)
@@ -136,7 +136,7 @@ static int capabilities[] = {
 
 /* Function prototypes. */
 static int la8_close_usb_reset_sequencer(struct la8 *la8);
-static void hw_stop_acquisition(int device_index, gpointer session_data);
+static int hw_stop_acquisition(int device_index, gpointer session_data);
 static int la8_reset(struct la8 *la8);
 
 static void fill_supported_samplerates_if_needed(void)
@@ -527,7 +527,7 @@ static int hw_init(const char *deviceinfo)
        sr_dbg("la8: found device");
 
        /* Register the device with libsigrok. */
-       sdi = sr_device_instance_new(0, SR_ST_INITIALIZING,
+       sdi = sr_dev_inst_new(0, SR_ST_INITIALIZING,
                        USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION);
        if (!sdi) {
                sr_err("la8: %s: sr_device_instance_new failed", __func__);
@@ -564,7 +564,7 @@ static int hw_opendev(int device_index)
        struct sr_device_instance *sdi;
        struct la8 *la8;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
                sr_err("la8: %s: sdi was NULL", __func__);
                return SR_ERR; /* TODO: SR_ERR_ARG? */
        }
@@ -651,7 +651,7 @@ static int hw_closedev(int device_index)
        struct sr_device_instance *sdi;
        struct la8 *la8;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
                sr_err("la8: %s: sdi was NULL", __func__);
                return SR_ERR; /* TODO: SR_ERR_ARG? */
        }
@@ -679,17 +679,20 @@ static int hw_closedev(int device_index)
        return SR_OK;
 }
 
-static void hw_cleanup(void)
+static int hw_cleanup(void)
 {
        GSList *l;
        struct sr_device_instance *sdi;
+       int ret = SR_OK;
 
        sr_spew("la8: entering %s", __func__);
 
        /* Properly close all devices. */
        for (l = device_instances; l; l = l->next) {
-               if ((sdi = l->data) == NULL) {
+               if (!(sdi = l->data)) {
+                       /* Log error, but continue cleaning up the rest. */
                        sr_err("la8: %s: sdi was NULL, continuing", __func__);
+                       ret = SR_ERR_BUG;
                        continue;
                }
 #if 0
@@ -703,10 +706,12 @@ static void hw_cleanup(void)
                        sr_err("la8: %s: sdi->priv was NULL, nothing "
                               "to do", __func__);
 #endif
-               sr_device_instance_free(sdi); /* Returns void. */
+               sr_dev_inst_free(sdi); /* Returns void. */
        }
        g_slist_free(device_instances); /* Returns void. */
        device_instances = NULL;
+
+       return ret;
 }
 
 static void *hw_get_device_info(int device_index, int device_info_id)
@@ -717,7 +722,7 @@ static void *hw_get_device_info(int device_index, int device_info_id)
 
        sr_spew("la8: entering %s", __func__);
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
                sr_err("la8: %s: sdi was NULL", __func__);
                return NULL;
        }
@@ -761,7 +766,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_dev_inst_get(device_instances, device_index))) {
                sr_err("la8: %s: sdi was NULL, device not found", __func__);
                return SR_ST_NOT_FOUND;
        }
@@ -785,7 +790,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
 
        sr_spew("la8: entering %s", __func__);
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
                sr_err("la8: %s: sdi was NULL", __func__);
                return SR_ERR; /* TODO: SR_ERR_ARG? */
        }
@@ -1039,7 +1044,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data)
 
        sr_spew("la8: entering %s", __func__);
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
                sr_err("la8: %s: sdi was NULL", __func__);
                return SR_ERR; /* TODO: SR_ERR_ARG? */
        }
@@ -1103,7 +1108,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data)
        return SR_OK;
 }
 
-static void hw_stop_acquisition(int device_index, gpointer session_data)
+static int hw_stop_acquisition(int device_index, gpointer session_data)
 {
        struct sr_device_instance *sdi;
        struct la8 *la8;
@@ -1111,20 +1116,22 @@ static void hw_stop_acquisition(int device_index, gpointer session_data)
 
        sr_dbg("la8: stopping acquisition");
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
                sr_err("la8: %s: sdi was NULL", __func__);
-               return;
+               return SR_ERR_BUG;
        }
 
        if (!(la8 = sdi->priv)) {
                sr_err("la8: %s: sdi->priv was NULL", __func__);
-               return;
+               return SR_ERR_BUG;
        }
 
        /* Send end packet to the session bus. */
        sr_dbg("la8: %s: sending SR_DF_END", __func__);
        packet.type = SR_DF_END;
        sr_session_bus(session_data, &packet);
+
+       return SR_OK;
 }
 
 SR_PRIV struct sr_device_plugin chronovu_la8_plugin_info = {