drivers: Use NUM_CHANNELS in favor of hardcoded values.

This commit is contained in:
Uwe Hermann 2017-08-03 21:08:44 +02:00
parent bd633efa32
commit b3fd09937c
6 changed files with 8 additions and 6 deletions

View File

@ -233,7 +233,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
/* Logic channels, all in one channel group. */
cg = g_malloc0(sizeof(struct sr_channel_group));
cg->name = g_strdup("Logic");
for (j = 0; j < 16; j++) {
for (j = 0; j < NUM_CHANNELS; j++) {
sprintf(channel_name, "%d", j);
ch = sr_channel_new(sdi, j, SR_CHANNEL_LOGIC,
TRUE, channel_name);

View File

@ -530,7 +530,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
return;
}
for (int ch = 0; ch < 2; ch++) {
for (int ch = 0; ch < NUM_CHANNELS; ch++) {
if (!devc->ch_enabled[ch])
continue;

View File

@ -613,7 +613,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
/* TODO: Check malloc return value. */
analog.data = g_try_malloc(num_samples * sizeof(float));
for (int ch = 0; ch < 2; ch++) {
for (int ch = 0; ch < NUM_CHANNELS; ch++) {
if (!devc->ch_enabled[ch])
continue;

View File

@ -27,8 +27,6 @@
#include "libsigrok-internal.h"
#include "protocol.h"
#define NUM_CHANNELS 2
static int send_begin(const struct sr_dev_inst *sdi)
{
struct sr_usb_dev_inst *usb;

View File

@ -51,6 +51,8 @@
/* All models have this for their "fast" mode. */
#define FRAMESIZE_SMALL (10 * 1024)
#define NUM_CHANNELS 2
enum control_requests {
CTRL_READ_EEPROM = 0xa2,
CTRL_GETSPEED = 0xb2,

View File

@ -35,6 +35,8 @@
#define UNKNOWN_ADDRESS 0xff
#define MAX_RENUM_DELAY_MS 3000
#define NUM_CHANNELS 16
static const uint32_t drvopts[] = {
SR_CONF_LOGIC_ANALYZER,
};
@ -89,7 +91,7 @@ static struct sr_dev_inst *create_device(struct sr_usb_dev_inst *usb,
sdi->inst_type = SR_INST_USB;
sdi->conn = usb;
for (i = 0; i < 16; i++) {
for (i = 0; i < NUM_CHANNELS; i++) {
snprintf(channel_name, sizeof(channel_name), "D%i", i);
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
}