]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/motech-lps-30x/api.c
Various #include file cosmetic fixes.
[libsigrok.git] / src / hardware / motech-lps-30x / api.c
index c23f84a1ca49da8e1f7e8e06cd0079f4f8dbb754..ee873e8684a0b98131f4c853c758fc6935610ef4 100644 (file)
@@ -27,7 +27,6 @@
 #include <errno.h>
 #include <math.h>
 #include <string.h>
-
 #include "protocol.h"
 
 /* Forward declarations */
@@ -59,7 +58,7 @@ static const uint32_t scanopts[] = {
 static const uint32_t devopts[] = {
        /* Device class */
        SR_CONF_POWER_SUPPLY,
-       /* Aquisition modes. */
+       /* Acquisition modes. */
        SR_CONF_CONTINUOUS,
        SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
@@ -88,7 +87,7 @@ static const char *channel_modes[] = {
        "Track2",
 };
 
-static struct lps_modelspec models[] = {
+static const struct lps_modelspec models[] = {
        { LPS_UNKNOWN, "Dummy", 0,
                {
 
@@ -444,7 +443,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
                g_strstrip(buf);
                verstr = buf + 4;
        }
-       else  /* Bug in device FW 1.17: Quering version string fails while output is active.
+       else  /* Bug in device FW 1.17: Querying version string fails while output is active.
                Therefore just print an error message, but do not exit with error. */
                sr_err("Failed to query for hardware version: %d %s", errno, strerror(errno));
 
@@ -623,24 +622,15 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                /* No channel group: global options. */
                switch (key) {
                case SR_CONF_LIMIT_MSEC:
-                       if (g_variant_get_uint64(data) == 0) {
-                               sr_err("LIMIT_MSEC can't be 0.");
-                               return SR_ERR;
-                       }
                        devc->limit_msec = g_variant_get_uint64(data);
-                       sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                               devc->limit_msec);
                        break;
                case SR_CONF_LIMIT_SAMPLES:
                        devc->limit_samples = g_variant_get_uint64(data);
-                       sr_dbg("Setting sample limit to %" PRIu64 ".",
-                               devc->limit_samples);
                        break;
                case SR_CONF_OUTPUT_CHANNEL_CONFIG:
                        sval = g_variant_get_string(data, NULL);
                        found = FALSE;
-                       for (idx = 0; idx < (int)ARRAY_SIZE(channel_modes); idx++)
-                       {
+                       for (idx = 0; idx < (int)ARRAY_SIZE(channel_modes); idx++) {
                                if (!strcmp(sval, channel_modes[idx])) {
                                        found = TRUE;
                                        if (devc->tracking_mode == idx)
@@ -652,9 +642,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                                if (devc->model->modelid <= LPS_303) /* Only first setting possible for smaller models. */
                                        break;
                        }
-                       if (!found) {
+                       if (!found)
                                return SR_ERR_ARG;
-                       }
                        break;
                default:
                        return SR_ERR_NA;
@@ -728,29 +717,27 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        GVariant *gvar;
        GVariantBuilder gvb;
 
-       (void)data;
-
        /* Driver options, no device instance necessary. */
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                                 scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
+                       scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
                return SR_OK;
        case SR_CONF_DEVICE_OPTIONS:
                if (sdi != NULL)
                        break;
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
+                       drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
                return SR_OK;
        default:
-               if (sdi == NULL)
+               if (!sdi)
                        return SR_ERR_ARG;
-
                devc = sdi->priv;
+               break;
        }
 
        /* Device options, independent from channel groups. */
-       if (cg == NULL) {
+       if (!cg) {
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
                        *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -765,7 +752,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                                *data = g_variant_new_strv(channel_modes, ARRAY_SIZE(channel_modes));
                        }
                        return SR_OK;
-                       break;
                default:
                        return SR_ERR_NA;
                }