Address several style nits: Use size types where appropriate. Avoid
repeated complex expressions in the profile lookup. Don't mix different
types of iterations in a for() loop (traversal of a channels list, and
indexing the channels' blob access details). Rename a generic identifier
in the probe routine.
static const struct rdtech_um_profile *find_profile(uint16_t id)
{
static const struct rdtech_um_profile *find_profile(uint16_t id)
{
+ size_t i;
+ const struct rdtech_um_profile *profile;
for (i = 0; i < ARRAY_SIZE(um_profiles); i++) {
for (i = 0; i < ARRAY_SIZE(um_profiles); i++) {
- if (um_profiles[i].model_id == id)
- return &um_profiles[i];
+ profile = &um_profiles[i];
+ if (profile->model_id == id)
+ return profile;
const struct rdtech_um_profile *p;
uint8_t request;
uint8_t buf[RDTECH_UM_BUFSIZE];
const struct rdtech_um_profile *p;
uint8_t request;
uint8_t buf[RDTECH_UM_BUFSIZE];
uint16_t model_id;
request = UM_CMD_POLL;
uint16_t model_id;
request = UM_CMD_POLL;
- len = serial_read_blocking(serial, buf, UM_POLL_LEN, UM_TIMEOUT_MS);
- if (len != UM_POLL_LEN) {
+ rcvd = serial_read_blocking(serial, buf, UM_POLL_LEN, UM_TIMEOUT_MS);
+ if (rcvd != UM_POLL_LEN) {
sr_err("Failed to read probe response.");
return NULL;
}
sr_err("Failed to read probe response.");
return NULL;
}
- if (!p->csum_ok(buf, len)) {
+ if (!p->csum_ok(buf, rcvd)) {
sr_err("Probe response fails checksum verification.");
return NULL;
}
sr_err("Probe response fails checksum verification.");
return NULL;
}
static void handle_poll_data(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
static void handle_poll_data(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
GSList *ch;
devc = sdi->priv;
GSList *ch;
devc = sdi->priv;
- for (ch = sdi->channels, i = 0; ch; ch = g_slist_next(ch), i++) {
+ ch_idx = 0;
+ for (ch = sdi->channels; ch; ch = g_slist_next(ch)) {
bv_send_analog_channel(sdi, ch->data,
bv_send_analog_channel(sdi, ch->data,
- &devc->profile->channels[i],
+ &devc->profile->channels[ch_idx],
devc->buf, devc->buflen);
devc->buf, devc->buflen);
}
sr_sw_limits_update_samples_read(&devc->limits, 1);
}
sr_sw_limits_update_samples_read(&devc->limits, 1);