break;
case SR_CONF_CLOCK_EDGE:
idx = devc->cfg_clock_edge;
- if (idx >= G_N_ELEMENTS(signal_edge_names))
+ if (idx >= ARRAY_SIZE(signal_edge_names))
return SR_ERR_BUG;
*data = g_variant_new_string(signal_edge_names[idx]);
break;
case SR_CONF_TRIGGER_SOURCE:
idx = devc->cfg_trigger_source;
- if (idx >= G_N_ELEMENTS(trigger_source_names))
+ if (idx >= ARRAY_SIZE(trigger_source_names))
return SR_ERR_BUG;
*data = g_variant_new_string(trigger_source_names[idx]);
break;
case SR_CONF_TRIGGER_SLOPE:
idx = devc->cfg_trigger_slope;
- if (idx >= G_N_ELEMENTS(signal_edge_names))
+ if (idx >= ARRAY_SIZE(signal_edge_names))
return SR_ERR_BUG;
*data = g_variant_new_string(signal_edge_names[idx]);
break;
switch (key) {
case SR_CONF_SAMPLERATE:
value = g_variant_get_uint64(data);
- if (value < samplerates[G_N_ELEMENTS(samplerates) - 1]
+ if (value < samplerates[ARRAY_SIZE(samplerates) - 1]
|| value > samplerates[0])
return SR_ERR_SAMPLERATE;
devc->samplerate = value;
break;
case SR_CONF_CLOCK_EDGE:
idx = lookup_index(data, signal_edge_names,
- G_N_ELEMENTS(signal_edge_names));
+ ARRAY_SIZE(signal_edge_names));
if (idx < 0)
return SR_ERR_ARG;
devc->cfg_clock_edge = idx;
break;
case SR_CONF_TRIGGER_SOURCE:
idx = lookup_index(data, trigger_source_names,
- G_N_ELEMENTS(trigger_source_names));
+ ARRAY_SIZE(trigger_source_names));
if (idx < 0)
return SR_ERR_ARG;
devc->cfg_trigger_source = idx;
break;
case SR_CONF_TRIGGER_SLOPE:
idx = lookup_index(data, signal_edge_names,
- G_N_ELEMENTS(signal_edge_names));
+ ARRAY_SIZE(signal_edge_names));
if (idx < 0)
return SR_ERR_ARG;
devc->cfg_trigger_slope = idx;
break;
case SR_CONF_DEVICE_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts, G_N_ELEMENTS(devopts), sizeof(uint32_t));
+ devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
break;
case SR_CONF_SAMPLERATE:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
- samplerates, G_N_ELEMENTS(samplerates),
+ samplerates, ARRAY_SIZE(samplerates),
sizeof(uint64_t));
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_TRIGGER_SOURCE:
*data = g_variant_new_strv(trigger_source_names,
- G_N_ELEMENTS(trigger_source_names));
+ ARRAY_SIZE(trigger_source_names));
break;
case SR_CONF_TRIGGER_SLOPE:
case SR_CONF_CLOCK_EDGE:
*data = g_variant_new_strv(signal_edge_names,
- G_N_ELEMENTS(signal_edge_names));
+ ARRAY_SIZE(signal_edge_names));
break;
default:
return SR_ERR_NA;
command[0] = LWLA_WORD(CMD_READ_REG);
command[1] = LWLA_WORD(reg);
- ret = lwla_send_command(usb, command, G_N_ELEMENTS(command));
+ ret = lwla_send_command(usb, command, ARRAY_SIZE(command));
if (ret != SR_OK)
return ret;
- ret = lwla_receive_reply(usb, reply, G_N_ELEMENTS(reply), 1);
+ ret = lwla_receive_reply(usb, reply, ARRAY_SIZE(reply), 1);
if (ret == SR_OK)
*value = LWLA_TO_UINT32(reply[0]);
command[2] = LWLA_WORD_0(value);
command[3] = LWLA_WORD_1(value);
- return lwla_send_command(usb, command, G_N_ELEMENTS(command));
+ return lwla_send_command(usb, command, ARRAY_SIZE(command));
}
SR_PRIV int lwla_write_regs(const struct sr_usb_dev_inst *usb,
/* Fill remaining 64-bit words with zeroes. */
memset(&command[27], 0, 16 * sizeof(uint16_t));
- return lwla_send_command(sdi->conn, command, G_N_ELEMENTS(command));
+ return lwla_send_command(sdi->conn, command, ARRAY_SIZE(command));
}
/* Issue a register write command as an asynchronous USB transfer.
regvals[6].reg = REG_DIV_BYPASS;
regvals[6].val = acq->bypass_clockdiv;
- ret = lwla_write_regs(usb, regvals, G_N_ELEMENTS(regvals));
+ ret = lwla_write_regs(usb, regvals, ARRAY_SIZE(regvals));
if (ret != SR_OK)
return ret;