Consistency and whitespace fixes for switch statements.
This commit is contained in:
parent
d0148a506e
commit
93b118da4f
|
@ -92,80 +92,79 @@ static void process_packet(const struct sr_dev_inst *sdi)
|
||||||
* weighting. */
|
* weighting. */
|
||||||
mode = devc->buf[2] & 0x0f;
|
mode = devc->buf[2] & 0x0f;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
||||||
break;
|
break;
|
||||||
case 0x1:
|
case 0x1:
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
||||||
break;
|
break;
|
||||||
case 0x2:
|
case 0x2:
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
|
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
||||||
break;
|
break;
|
||||||
case 0x3:
|
case 0x3:
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
|
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
||||||
break;
|
break;
|
||||||
case 0x4:
|
case 0x4:
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
|
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
||||||
break;
|
break;
|
||||||
case 0x5:
|
case 0x5:
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
|
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
||||||
break;
|
break;
|
||||||
case 0x6:
|
case 0x6:
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
|
analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
|
||||||
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
||||||
break;
|
break;
|
||||||
case 0x7:
|
case 0x7:
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
|
analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
|
||||||
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
||||||
break;
|
break;
|
||||||
case 0x8:
|
case 0x8:
|
||||||
/* 10-second mean, but we don't have MQ flags to express it. */
|
/* 10-second mean, but we don't have MQ flags to express it. */
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_LAT \
|
analog.mqflags |= SR_MQFLAG_SPL_LAT \
|
||||||
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
||||||
break;
|
break;
|
||||||
case 0x9:
|
case 0x9:
|
||||||
/* Mean over a time period between 11 seconds and 24 hours.
|
/* Mean over a time period between 11 seconds and 24 hours.
|
||||||
* Which is so silly that there's no point in expressing
|
* Which is so silly that there's no point in expressing
|
||||||
* either this or the previous case. */
|
* either this or the previous case. */
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_LAT \
|
analog.mqflags |= SR_MQFLAG_SPL_LAT \
|
||||||
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_F;
|
||||||
break;
|
break;
|
||||||
case 0xa:
|
case 0xa:
|
||||||
/* 10-second mean. */
|
/* 10-second mean. */
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_LAT \
|
analog.mqflags |= SR_MQFLAG_SPL_LAT \
|
||||||
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
||||||
break;
|
break;
|
||||||
case 0xb:
|
case 0xb:
|
||||||
/* Mean over a time period between 11 seconds and 24 hours. */
|
/* Mean over a time period between 11 seconds and 24 hours. */
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_LAT \
|
analog.mqflags |= SR_MQFLAG_SPL_LAT \
|
||||||
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
| SR_MQFLAG_SPL_FREQ_WEIGHT_A \
|
||||||
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
| SR_MQFLAG_SPL_TIME_WEIGHT_S;
|
||||||
break;
|
break;
|
||||||
case 0xc:
|
case 0xc:
|
||||||
/* Internal calibration on 1kHz sine at 94dB, not useful
|
/* Internal calibration on 1kHz sine at 94dB, not useful
|
||||||
* to anything but the device. */
|
* to anything but the device. */
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
|
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
|
||||||
break;
|
break;
|
||||||
case 0xd:
|
case 0xd:
|
||||||
/* Internal calibration on 1kHz sine at 94dB, not useful
|
/* Internal calibration on 1kHz sine at 94dB, not useful
|
||||||
* to anything but the device. */
|
* to anything but the device. */
|
||||||
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
|
analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sr_dbg("unknown configuration 0x%.2x", mode);
|
sr_dbg("unknown configuration 0x%.2x", mode);
|
||||||
return;
|
return;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.type = SR_DF_ANALOG;
|
packet.type = SR_DF_ANALOG;
|
||||||
|
|
|
@ -212,7 +212,6 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
|
||||||
}
|
}
|
||||||
ag->num_samples = last_end;
|
ag->num_samples = last_end;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PATTERN_SINE:
|
case PATTERN_SINE:
|
||||||
frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
|
frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
|
||||||
|
|
||||||
|
@ -231,7 +230,6 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
|
||||||
|
|
||||||
ag->num_samples = num_samples;
|
ag->num_samples = num_samples;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PATTERN_TRIANGLE:
|
case PATTERN_TRIANGLE:
|
||||||
frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
|
frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
|
||||||
|
|
||||||
|
@ -246,7 +244,6 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
|
||||||
|
|
||||||
ag->num_samples = num_samples;
|
ag->num_samples = num_samples;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PATTERN_SAWTOOTH:
|
case PATTERN_SAWTOOTH:
|
||||||
frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
|
frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
|
||||||
|
|
||||||
|
|
|
@ -518,30 +518,30 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
arg = g_variant_get_uint64(data);
|
arg = g_variant_get_uint64(data);
|
||||||
for (i = 0; i < ARRAY_SIZE(samplerates); i++) {
|
for (i = 0; i < ARRAY_SIZE(samplerates); i++) {
|
||||||
if (samplerates[i] == arg) {
|
if (samplerates[i] == arg) {
|
||||||
devc->cur_samplerate = arg;
|
devc->cur_samplerate = arg;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (i == ARRAY_SIZE(samplerates))
|
}
|
||||||
ret = SR_ERR_ARG;
|
if (i == ARRAY_SIZE(samplerates))
|
||||||
break;
|
ret = SR_ERR_ARG;
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
break;
|
||||||
devc->limit_samples = g_variant_get_uint64(data);
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
break;
|
devc->limit_samples = g_variant_get_uint64(data);
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
break;
|
||||||
devc->capture_ratio = g_variant_get_uint64(data);
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
if (devc->capture_ratio > 100) {
|
devc->capture_ratio = g_variant_get_uint64(data);
|
||||||
devc->capture_ratio = 0;
|
if (devc->capture_ratio > 100) {
|
||||||
ret = SR_ERR;
|
devc->capture_ratio = 0;
|
||||||
} else
|
ret = SR_ERR;
|
||||||
ret = SR_OK;
|
} else
|
||||||
break;
|
ret = SR_OK;
|
||||||
default:
|
break;
|
||||||
ret = SR_ERR_NA;
|
default:
|
||||||
|
ret = SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -568,22 +568,27 @@ static void decode_rs_2x_TR2(uint8_t rs, struct dev_context *devc)
|
||||||
case SR_MQ_CURRENT:
|
case SR_MQ_CURRENT:
|
||||||
if (devc->scale1000 == -1) /* mA */
|
if (devc->scale1000 == -1) /* mA */
|
||||||
switch (range) {
|
switch (range) {
|
||||||
case 0: case 1: /* 100, 300 µA */
|
case 0:
|
||||||
|
case 1: /* 100, 300 µA */
|
||||||
devc->scale *= pow(10.0, -6);
|
devc->scale *= pow(10.0, -6);
|
||||||
break;
|
break;
|
||||||
case 2: case 3: /* 1, 3 mA */
|
case 2:
|
||||||
|
case 3: /* 1, 3 mA */
|
||||||
devc->scale *= pow(10.0, -5);
|
devc->scale *= pow(10.0, -5);
|
||||||
break;
|
break;
|
||||||
case 4: case 5: /* 10, 30 mA */
|
case 4:
|
||||||
|
case 5: /* 10, 30 mA */
|
||||||
devc->scale *= pow(10.0, -4);
|
devc->scale *= pow(10.0, -4);
|
||||||
break;
|
break;
|
||||||
case 6: case 7: /* 100, 300 mA */
|
case 6:
|
||||||
|
case 7: /* 100, 300 mA */
|
||||||
devc->scale *= pow(10.0, -3);
|
devc->scale *= pow(10.0, -3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else /* A */
|
else /* A */
|
||||||
switch (range) {
|
switch (range) {
|
||||||
case 0: case 1: /* 1, 3 A */
|
case 0:
|
||||||
|
case 1: /* 1, 3 A */
|
||||||
devc->scale *= pow(10.0, -5);
|
devc->scale *= pow(10.0, -5);
|
||||||
break;
|
break;
|
||||||
case 2: /* 10 A */
|
case 2: /* 10 A */
|
||||||
|
|
|
@ -649,7 +649,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
|
devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
|
||||||
|
@ -683,7 +683,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
|
devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
|
||||||
|
|
|
@ -77,7 +77,10 @@ static void process_line(struct sr_dev_inst *sdi)
|
||||||
case 1: /* Waiting for data reply to request */
|
case 1: /* Waiting for data reply to request */
|
||||||
/* Convert numbers */
|
/* Convert numbers */
|
||||||
switch (devc->acq_req) {
|
switch (devc->acq_req) {
|
||||||
case AQ_U1: case AQ_U2: case AQ_I1: case AQ_I2:
|
case AQ_U1:
|
||||||
|
case AQ_U2:
|
||||||
|
case AQ_I1:
|
||||||
|
case AQ_I2:
|
||||||
if (sr_atod(devc->buf, &dbl) != SR_OK) {
|
if (sr_atod(devc->buf, &dbl) != SR_OK) {
|
||||||
sr_err("Failed to convert '%s' to double, errno=%d %s",
|
sr_err("Failed to convert '%s' to double, errno=%d %s",
|
||||||
devc->buf, errno, strerror(errno));
|
devc->buf, errno, strerror(errno));
|
||||||
|
|
|
@ -107,8 +107,12 @@ static int capture_setup(const struct sr_dev_inst *sdi)
|
||||||
/* Set bits to select external TRG input edge. */
|
/* Set bits to select external TRG input edge. */
|
||||||
if (devc->cfg_trigger_source == TRIGGER_EXT_TRG)
|
if (devc->cfg_trigger_source == TRIGGER_EXT_TRG)
|
||||||
switch (devc->cfg_trigger_slope) {
|
switch (devc->cfg_trigger_slope) {
|
||||||
case EDGE_POSITIVE: trigger_mask |= (uint64_t)1 << 35; break;
|
case EDGE_POSITIVE:
|
||||||
case EDGE_NEGATIVE: trigger_mask |= (uint64_t)1 << 34; break;
|
trigger_mask |= (uint64_t)1 << 35;
|
||||||
|
break;
|
||||||
|
case EDGE_NEGATIVE:
|
||||||
|
trigger_mask |= (uint64_t)1 << 34;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
command[19] = LWLA_WORD_0(trigger_mask);
|
command[19] = LWLA_WORD_0(trigger_mask);
|
||||||
|
|
Loading…
Reference in New Issue