]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
libsigrok: Rename open/close to opendev/closedev.
[libsigrok.git] / hardware / asix-sigma / asix-sigma.c
index 598d0b065ad22c0ee68524a05cf31892d07b3da2..50bb932db26030405a611ebd684c916a8ff02521 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /*
- * ASIX Sigma Logic Analyzer Driver
+ * ASIX SIGMA Logic Analyzer Driver
  */
 
 #include "config.h"
@@ -333,11 +333,14 @@ static int bin2bitbang(const char *filename,
 
        if (!(compressed_buf = g_try_malloc(file_size))) {
                sr_err("asix: %s: compressed_buf malloc failed", __func__);
+               fclose(f);
                return SR_ERR_MALLOC;
        }
 
        if (!(firmware = g_try_malloc(buffer_size))) {
                sr_err("asix: %s: firmware malloc failed", __func__);
+               fclose(f);
+               g_free(compressed_buf);
                return SR_ERR_MALLOC;
        }
 
@@ -364,6 +367,8 @@ static int bin2bitbang(const char *filename,
        *buf = p = (unsigned char *)g_try_malloc(*buf_size);
        if (!p) {
                sr_err("asix: %s: buf/p malloc failed", __func__);
+               g_free(compressed_buf);
+               g_free(firmware);
                return SR_ERR_MALLOC;
        }
 
@@ -432,7 +437,7 @@ static int hw_init(const char *deviceinfo)
 
        return 1;
 free:
-       free(sigma);
+       g_free(sigma);
        return 0;
 }
 
@@ -616,7 +621,7 @@ static int configure_probes(struct sr_device_instance *sdi, GSList *probes)
                if (sigma->cur_samplerate >= SR_MHZ(100)) {
                        /* Fast trigger support. */
                        if (trigger_set) {
-                               sr_warn("Asix Sigma only supports a single "
+                               sr_warn("ASIX SIGMA only supports a single "
                                        "pin trigger in 100 and 200MHz mode.");
                                return SR_ERR;
                        }
@@ -625,7 +630,7 @@ static int configure_probes(struct sr_device_instance *sdi, GSList *probes)
                        else if (probe->trigger[0] == 'r')
                                sigma->trigger.risingmask |= probebit;
                        else {
-                               sr_warn("Asix Sigma only supports "
+                               sr_warn("ASIX SIGMA only supports "
                                        "rising/falling trigger in 100 "
                                        "and 200MHz mode.");
                                return SR_ERR;
@@ -657,7 +662,7 @@ static int configure_probes(struct sr_device_instance *sdi, GSList *probes)
                          * does not permit ORed triggers.
                          */
                        if (trigger_set > 1) {
-                               sr_warn("Asix Sigma only supports 1 rising/"
+                               sr_warn("ASIX SIGMA only supports 1 rising/"
                                        "falling triggers.");
                                return SR_ERR;
                        }
@@ -1357,17 +1362,17 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
 }
 
 struct sr_device_plugin asix_sigma_plugin_info = {
-       "asix-sigma",
-       "ASIX SIGMA",
-       1,
-       hw_init,
-       hw_cleanup,
-       hw_opendev,
-       hw_closedev,
-       hw_get_device_info,
-       hw_get_status,
-       hw_get_capabilities,
-       hw_set_configuration,
-       hw_start_acquisition,
-       hw_stop_acquisition,
+       .name = "asix-sigma",
+       .longname = "ASIX SIGMA",
+       .api_version = 1,
+       .init = hw_init,
+       .cleanup = hw_cleanup,
+       .opendev = hw_opendev,
+       .closedev = hw_closedev,
+       .get_device_info = hw_get_device_info,
+       .get_status = hw_get_status,
+       .get_capabilities = hw_get_capabilities,
+       .set_configuration = hw_set_configuration,
+       .start_acquisition = hw_start_acquisition,
+       .stop_acquisition = hw_stop_acquisition,
 };