From ce3ecb70494b5bcf483607d6ecf0906394623601 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Thu, 26 Mar 2015 21:57:56 +0100 Subject: [PATCH] sysclk-lwla: Use ARRAY_SIZE instead of G_N_ELEMENTS. Both do exactly the same, but we consistently use ARRAY_SIZE in the rest of the code-base. --- src/hardware/sysclk-lwla/api.c | 22 +++++++++++----------- src/hardware/sysclk-lwla/lwla.c | 6 +++--- src/hardware/sysclk-lwla/protocol.c | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index 7da96eec..066f914d 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -277,19 +277,19 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s 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; @@ -336,7 +336,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd 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; @@ -359,21 +359,21 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd 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; @@ -438,12 +438,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * 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); @@ -455,12 +455,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * 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; diff --git a/src/hardware/sysclk-lwla/lwla.c b/src/hardware/sysclk-lwla/lwla.c index e0e1c87b..4cc1b656 100644 --- a/src/hardware/sysclk-lwla/lwla.c +++ b/src/hardware/sysclk-lwla/lwla.c @@ -193,12 +193,12 @@ SR_PRIV int lwla_read_reg(const struct sr_usb_dev_inst *usb, 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]); @@ -216,7 +216,7 @@ SR_PRIV int lwla_write_reg(const struct sr_usb_dev_inst *usb, 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, diff --git a/src/hardware/sysclk-lwla/protocol.c b/src/hardware/sysclk-lwla/protocol.c index a8659a6b..dba336d9 100644 --- a/src/hardware/sysclk-lwla/protocol.c +++ b/src/hardware/sysclk-lwla/protocol.c @@ -134,7 +134,7 @@ static int capture_setup(const struct sr_dev_inst *sdi) /* 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. @@ -894,7 +894,7 @@ SR_PRIV int lwla_setup_acquisition(const struct sr_dev_inst *sdi) 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;