#include <errno.h>
#include <math.h>
#include <string.h>
-
#include "protocol.h"
/* Forward declarations */
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,
"Track2",
};
-static struct lps_modelspec models[] = {
+static const struct lps_modelspec models[] = {
{ LPS_UNKNOWN, "Dummy", 0,
{
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));
/* 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)
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;
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,
*data = g_variant_new_strv(channel_modes, ARRAY_SIZE(channel_modes));
}
return SR_OK;
- break;
default:
return SR_ERR_NA;
}