]> sigrok.org Git - libsigrok.git/blobdiff - hardware/chronovu-la8/chronovu-la8.c
sr: la8: remove debug output when no device is found
[libsigrok.git] / hardware / chronovu-la8 / chronovu-la8.c
index 23ac8c793a9bdd44e0d66e44526c17f562a459ac..6d639af7cb2982a3c648180c2da20be12b49920e 100644 (file)
@@ -328,8 +328,6 @@ static int la8_close_usb_reset_sequencer(struct la8 *la8)
        uint8_t buf[8] = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
        int ret;
 
-       sr_spew("la8: entering %s", __func__);
-
        if (!la8) {
                sr_err("la8: %s: la8 was NULL", __func__);
                return SR_ERR_ARG;
@@ -359,8 +357,6 @@ static int la8_close_usb_reset_sequencer(struct la8 *la8)
                if ((ret = ftdi_usb_close(la8->ftdic)) < 0)
                        sr_err("la8: %s: ftdi_usb_close: (%d) %s", __func__,
                               ret, ftdi_get_error_string(la8->ftdic));
-       } else {
-               sr_spew("la8: %s: usb_dev was NULL, nothing to do", __func__);
        }
 
        ftdi_free(la8->ftdic); /* Returns void. */
@@ -477,8 +473,6 @@ static int hw_init(const char *deviceinfo)
        struct sr_device_instance *sdi;
        struct la8 *la8;
 
-       sr_spew("la8: entering %s", __func__);
-
        /* Avoid compiler errors. */
        (void)deviceinfo;
 
@@ -519,15 +513,13 @@ static int hw_init(const char *deviceinfo)
        /* Check for the device and temporarily open it. */
        if ((ret = ftdi_usb_open_desc(la8->ftdic, USB_VENDOR_ID,
                        USB_PRODUCT_ID, USB_DESCRIPTION, NULL)) < 0) {
-               sr_dbg("la8: %s: ftdi_usb_open_desc: (%d) %s",
-                      __func__, ret, ftdi_get_error_string(la8->ftdic));
                (void) la8_close_usb_reset_sequencer(la8); /* Ignore errors. */
                goto err_free_ftdic;
        }
        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 +556,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 +643,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,34 +671,26 @@ 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;
-
-       sr_spew("la8: entering %s", __func__);
+       int ret = SR_OK;
 
        /* 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
-               /*
-                * Fixes a segfault as it's free()d elsewhere already.
-                * TODO: Document who is supposed to free this, and when.
-                */
-               if (sdi->priv != NULL)
-                       g_free(sdi->priv);
-               else
-                       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 +701,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 +745,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 +769,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 +1023,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? */
        }
@@ -1111,7 +1095,7 @@ static int 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 SR_ERR_BUG;
        }