X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fmotech-lps-30x%2Fapi.c;h=ee873e8684a0b98131f4c853c758fc6935610ef4;hb=515ab0889ebde4b373d620044a1a98da37153056;hp=d040fe6e754d6cad5adc2b731b764b94549b3204;hpb=4f840ce965b1c30c5ab75afecc56193cbaf5c1b3;p=libsigrok.git diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c index d040fe6e..ee873e86 100644 --- a/src/hardware/motech-lps-30x/api.c +++ b/src/hardware/motech-lps-30x/api.c @@ -27,7 +27,6 @@ #include #include #include - #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, { @@ -441,11 +440,10 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o goto exit_err; } - 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)); @@ -624,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) @@ -653,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; @@ -729,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, @@ -766,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; }