We always follow sr_channel_new() with a call to add the channel to the sdi.
Tidy up a bit by adding this functionality to sr_channel_new() instead.
*/
/** @private
- * Allocate and initialize new struct sr_channel
+ * Allocate and initialize new struct sr_channel and add to sdi.
+ * @param[in] sdi The device instance the channel is connected to.
* @param[in] index @copydoc sr_channel::index
* @param[in] type @copydoc sr_channel::type
* @param[in] enabled @copydoc sr_channel::enabled
*
* @return A new struct sr_channel*.
*/
-SR_PRIV struct sr_channel *sr_channel_new(int index, int type,
- gboolean enabled, const char *name)
+SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi,
+ int index, int type, gboolean enabled, const char *name)
{
struct sr_channel *ch;
if (name)
ch->name = g_strdup(name);
+ sdi->channels = g_slist_append(sdi->channels, ch);
+
return ch;
}
*/
SR_API int sr_dev_inst_channel_add(struct sr_dev_inst *sdi, int index, int type, const char *name)
{
- struct sr_channel *ch;
-
if (!sdi || sdi->inst_type != SR_INST_USER || index < 0)
return SR_ERR_ARG;
- ch = sr_channel_new(index, type, TRUE, name);
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, index, type, TRUE, name);
return SR_OK;
}
struct drv_context *drvc;
struct dev_context *devc;
struct sr_config *src;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *l, *devices;
int len, i;
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
break;
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
struct sr_config *src;
GSList *devices, *l;
const char *conn, *serialcomm;
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T1");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T2");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "T1");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "T2");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
static GSList *scan(GSList *options)
{
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
struct drv_context *drvc;
struct dev_context *devc;
GSList *devices;
sdi->model = g_strdup(USB_MODEL_NAME);
sdi->driver = di;
- for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+ for (i = 0; i < ARRAY_SIZE(channel_names); i++)
+ sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
devices = g_slist_append(devices, sdi);
drvc->instances = g_slist_append(drvc->instances, sdi);
sdi->conn = serial;
for (i = 0; i < MAX_CHANNELS; i++) {
snprintf(channel, 10, "CH%d", i + 1);
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel);
- sdi->channels = g_slist_append(sdi->channels, ch);
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel);
cg = g_malloc(sizeof(struct sr_channel_group));
cg->name = g_strdup(channel);
cg->channels = g_slist_append(NULL, ch);
cp->ch_type = type;
cp->probe = cg->priv;
- ch = sr_channel_new(devc->num_channels++,
+ ch = sr_channel_new(sdi, devc->num_channels++,
SR_CHANNEL_ANALOG, TRUE, name);
g_free(name);
ch->priv = cp;
cg->channels = g_slist_append(cg->channels, ch);
- sdi->channels = g_slist_append(sdi->channels, ch);
}
SR_PRIV gboolean bl_acme_register_probe(struct sr_dev_inst *sdi, int type,
struct sr_config *src;
struct sr_dev_inst *sdi;
struct dev_context *devc;
- struct sr_channel *ch;
int i, maxch;
devices = NULL;
sr_info("BeagleLogic device found at "BEAGLELOGIC_DEV_NODE);
/* Fill the channels */
- for (i = 0; i < maxch; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+ for (i = 0; i < maxch; i++)
+ sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
beaglelogic_channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
sdi->priv = devc;
drvc->instances = g_slist_append(drvc->instances, sdi);
struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb;
struct sr_config *src;
- struct sr_channel *ch;
const char *conn;
drvc = di->priv;
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P2");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P2");
sdi->inst_type = SR_INST_USB;
sdi->conn = usb;
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct drv_context *drvc;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *devices;
int ret;
drvc = di->priv;
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
struct sr_config *src;
struct sr_serial_dev_inst *serial;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
GSList *l, *devices;
gint64 start;
const char *conn;
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
break;
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *devices;
sdi->driver = center_devs[idx].di;
for (i = 0; i < center_devs[idx].num_channels; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG,
+ sr_channel_new(sdi, i, SR_CHANNEL_ANALOG,
TRUE, channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
}
drvc->instances = g_slist_append(drvc->instances, sdi);
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
- struct sr_channel *ch;
ret = SR_OK;
sdi->driver = di;
sdi->priv = devc;
- for (i = 0; i < devc->prof->num_channels; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+ for (i = 0; i < devc->prof->num_channels; i++)
+ sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
cv_channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
*devices = g_slist_append(*devices, sdi);
drvc->instances = g_slist_append(drvc->instances, sdi);
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_config *src;
- struct sr_channel *ch;
GSList *devices, *l;
const char *conn, *serialcomm;
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct sr_config *src;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *l, *devices;
const char *conn, *serialcomm;
sdi->conn = serial;
sdi->priv = NULL;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
cg->name = g_strdup("Logic");
for (i = 0; i < num_logic_channels; i++) {
sprintf(channel_name, "D%d", i);
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
- sdi->channels = g_slist_append(sdi->channels, ch);
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
cg->channels = g_slist_append(cg->channels, ch);
}
sdi->channel_groups = g_slist_append(NULL, cg);
devc->ch_ag = g_hash_table_new(g_direct_hash, g_direct_equal);
for (i = 0; i < num_analog_channels; i++) {
snprintf(channel_name, 16, "A%d", i);
- ch = sr_channel_new(i + num_logic_channels, SR_CHANNEL_ANALOG,
+ ch = sr_channel_new(sdi, i + num_logic_channels, SR_CHANNEL_ANALOG,
TRUE, channel_name);
- sdi->channels = g_slist_append(sdi->channels, ch);
acg->channels = g_slist_append(acg->channels, ch);
/* Every analog channel gets its own channel group as well. */
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *devices;
int retry, len, i, s;
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
break;
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb;
- struct sr_channel *ch;
struct sr_config *src;
const struct fx2lafw_profile *prof;
GSList *l, *devices, *conn_devices;
/* Fill in channellist according to this device's profile. */
num_logic_channels = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
- for (j = 0; j < num_logic_channels; j++) {
- ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
+ for (j = 0; j < num_logic_channels; j++)
+ sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
devc = fx2lafw_dev_new();
devc->profile = prof;
struct drv_context *drvc;
struct dev_context *devc;
struct sr_config *src;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *l, *devices;
const char *conn, *serialcomm;
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = &gmc_mh_1x_2x_rs232_driver_info;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
}
struct drv_context *drvc;
struct dev_context *devc;
struct sr_config *src;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *l, *devices;
const char *conn, *serialcomm;
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = &gmc_mh_2x_bd232_driver_info;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
devc = g_malloc0(sizeof(struct dev_context));
/* Add analog channels. */
for (i = 0; i < scope_models[model_index].analog_channels; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
/* Add digital channels. */
for (i = 0; i < scope_models[model_index].digital_channels; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
(*scope_models[model_index].digital_names)[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
devc->digital_groups[i < 8 ? 0 : 1]->channels = g_slist_append(
devc->digital_groups[i < 8 ? 0 : 1]->channels, ch);
* a trigger source internal to the device.
*/
for (i = 0; channel_names[i]; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
cg = g_malloc0(sizeof(struct sr_channel_group));
cg->name = g_strdup(channel_names[i]);
cg->channels = g_slist_append(cg->channels, ch);
GSList *usb_devices, *devices, *l;
struct drv_context *drvc;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
struct device_info dev_info;
sdi->inst_type = SR_INST_USB;
sdi->conn = usb;
- for (i = 0; channel_names[i]; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
- channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- devc->channels[i] = ch;
- }
+ for (i = 0; channel_names[i]; i++)
+ devc->channels[i] = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC,
+ TRUE, channel_names[i]);
devc->state = STATE_IDLE;
devc->next_state = STATE_IDLE;
static GSList *scan(GSList *options)
{
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
struct drv_context *drvc;
struct dev_context *devc;
GSList *devices;
sdi->driver = di;
sdi->priv = devc;
- for (i = 0; channel_names[i]; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+ for (i = 0; channel_names[i]; i++)
+ sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
devices = g_slist_append(devices, sdi);
drvc->instances = g_slist_append(drvc->instances, sdi);
struct drv_context *drvc;
struct dev_context *devc;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
GSList *usb_devices, *devices, *l;
char *model;
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = l->data;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
devc->limit_samples = 0;
struct dev_context *devc;
const struct elusb_profile *profile;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
int modelid, i;
char firmware[5];
if (profile->logformat == LOG_TEMP_RH) {
/* Model this as two channels: temperature and humidity. */
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temp");
- sdi->channels = g_slist_append(NULL, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Hum");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "Temp");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "Hum");
} else if (profile->logformat == LOG_CO) {
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CO");
- sdi->channels = g_slist_append(NULL, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CO");
} else {
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(NULL, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
}
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
for (i = 0; i < NUM_CHANNELS; i++) {
- struct sr_channel *ch;
chtype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC;
- ch = sr_channel_new(i, chtype, TRUE,
+ sr_channel_new(sdi, i, chtype, TRUE,
mso19_channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
}
//Add the driver
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_config *src;
- struct sr_channel *ch;
GSList *devices, *l;
const char *conn, *serialcomm;
struct sr_serial_dev_inst *serial;
sdi->conn = serial;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
devc = g_malloc0(sizeof(struct dev_context));
devc->model = &models[model_id];
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *devices;
sdi->priv = devc;
sdi->driver = mic_devs[idx].di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temperature");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "Temperature");
- if (mic_devs[idx].has_humidity) {
- ch = sr_channel_new(1, SR_CHANNEL_ANALOG, TRUE, "Humidity");
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
+ if (mic_devs[idx].has_humidity)
+ sr_channel_new(sdi, 1, SR_CHANNEL_ANALOG, TRUE, "Humidity");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
/* Setup channels and channel groups. */
for (cnt = 0; cnt < models[modelid].num_channels; cnt++) {
snprintf(channel, sizeof(channel), "CH%d", cnt + 1);
- ch = sr_channel_new(cnt, SR_CHANNEL_ANALOG, TRUE, channel);
- sdi->channels = g_slist_append(sdi->channels, ch);
+ ch = sr_channel_new(sdi, cnt, SR_CHANNEL_ANALOG, TRUE, channel);
devc->channel_status[cnt].info = g_slist_append(NULL, ch);
struct drv_context *drvc;
struct dev_context *devc;
struct sr_config *src;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *l, *devices;
int len, cnt;
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = drv;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
break;
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *l, *devices;
int ret, i;
sdi->model = g_strdup("Logic Analyzer");
sdi->version = g_strdup("v1.0");
sdi->driver = di;
- for (i = 0; i < 32; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+ for (i = 0; i < 32; i++)
+ sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
ols_channel_names[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
devc = ols_dev_new();
sdi->priv = devc;
}
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
- struct sr_channel *ch;
uint32_t tmp_int, ui;
uint8_t key, type, token;
int delay_ms;
switch (token) {
case 0x00:
/* Number of usable channels */
- for (ui = 0; ui < tmp_int; ui++) {
- ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+ for (ui = 0; ui < tmp_int; ui++)
+ sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
ols_channel_names[ui]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
break;
case 0x01:
/* Amount of sample memory available (bytes) */
switch (token) {
case 0x00:
/* Number of usable channels */
- for (ui = 0; ui < tmp_c; ui++) {
- ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+ for (ui = 0; ui < tmp_c; ui++)
+ sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
ols_channel_names[ui]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
break;
case 0x01:
/* protocol version */
SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, struct dev_context *devc)
{
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
uint32_t tmp_int, ui;
uint8_t key, type, token;
GString *tmp_str, *devname, *version;
switch (token) {
case 0x00:
/* Number of usable channels */
- for (ui = 0; ui < tmp_int; ui++) {
- ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+ for (ui = 0; ui < tmp_int; ui++)
+ sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
p_ols_channel_names[ui]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
break;
case 0x01:
/* Amount of sample memory available (bytes) */
switch (token) {
case 0x00:
/* Number of usable channels */
- for (ui = 0; ui < tmp_c; ui++) {
- ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+ for (ui = 0; ui < tmp_c; ui++)
+ sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
p_ols_channel_names[ui]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
break;
case 0x01:
/* protocol version */
for (i = 0; i < model->analog_channels; i++) {
if (!(channel_name = g_strdup_printf("CH%d", i + 1)))
return NULL;
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channel_name);
- sdi->channels = g_slist_append(sdi->channels, ch);
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_name);
devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) {
if (!(channel_name = g_strdup_printf("D%d", i)))
return NULL;
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
g_free(channel_name);
- sdi->channels = g_slist_append(sdi->channels, ch);
devc->digital_group->channels = g_slist_append(
devc->digital_group->channels, ch);
}
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb;
- struct sr_channel *ch;
struct sr_config *src;
GSList *l, *devices, *conn_devices;
struct libusb_device_descriptor des;
sdi->driver = di;
sdi->connection_id = g_strdup(connection_id);
- for (j = 0; channel_names[j]; j++) {
- ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
+ for (j = 0; channel_names[j]; j++)
+ sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
devc = g_malloc0(sizeof(struct dev_context));
devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
continue;
g_snprintf(ch_name, 16, "%s%s", pci[i].prefix,
channels[ch_num].name);
- ch = sr_channel_new(ch_idx++, SR_CHANNEL_ANALOG, TRUE, ch_name);
+ ch = sr_channel_new(sdi, ch_idx++, SR_CHANNEL_ANALOG, TRUE,
+ ch_name);
pch = g_malloc0(sizeof(struct pps_channel));
pch->hw_output_idx = ch_num;
pch->hwname = channels[ch_num].name;
pch->mq = pci[i].mq;
ch->priv = pch;
- sdi->channels = g_slist_append(sdi->channels, ch);
}
}
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *devices;
int dropped, ret;
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = dmms[dmm].di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
return std_init(sr_ctx, di, LOG_PREFIX);
}
-static GSList *gen_channel_list(int num_channels)
-{
- GSList *list;
- struct sr_channel *ch;
- int i;
- char name[8];
-
- list = NULL;
-
- for (i = num_channels; i > 0; --i) {
- /* The LWLA series simply number channels from CH1 to CHxx. */
- g_snprintf(name, sizeof(name), "CH%d", i);
-
- ch = sr_channel_new(i - 1, SR_CHANNEL_LOGIC, TRUE, name);
- list = g_slist_prepend(list, ch);
- }
-
- return list;
-}
-
static struct sr_dev_inst *dev_inst_new(void)
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
+ int i;
+ char name[8];
/* Allocate memory for our private driver context. */
devc = g_malloc0(sizeof(struct dev_context));
devc->samplerate = DEFAULT_SAMPLERATE;
sdi->priv = devc;
- sdi->channels = gen_channel_list(NUM_CHANNELS);
+ for (i = NUM_CHANNELS; i > 0; --i) {
+ /* The LWLA series simply number channels from CH1 to CHxx. */
+ g_snprintf(name, sizeof(name), "CH%d", i);
+ sr_channel_new(sdi, i - 1, SR_CHANNEL_LOGIC, TRUE, name);
+ }
return sdi;
}
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
GSList *devices = NULL, *l;
const char *conn = NULL, *serialcomm = NULL;
uint8_t buf[292];
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P");
if (devc->optarif == OPTARIF_BASE) {
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "BASE");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "BASE");
} else if (devc->optarif == OPTARIF_HC) {
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HP");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HC");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HP");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HC");
} else if (devc->optarif == OPTARIF_EJP) {
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HN");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPM");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HN");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPM");
} else if (devc->optarif == OPTARIF_BBR) {
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJB");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJW");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJR");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJB");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJW");
- sdi->channels = g_slist_append(sdi->channels, ch);
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJR");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJB");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJW");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HPJR");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJB");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJW");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "HCJR");
}
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "IINST");
- sdi->channels = g_slist_append(sdi->channels, ch);
-
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "PAPP");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "IINST");
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "PAPP");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
{
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
- struct sr_channel *ch;
int unit, packet_len, len, i;
unsigned char packet[MAX_REPLY_SIZE], buf[MAX_REPLY_SIZE];
char *probe_name;
sr_dbg("Unsupported measurement unit %d", unit);
return SR_ERR;
}
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, probe_name);
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, probe_name);
}
devc->num_channels = packet[6];
sr_dbg("Found %d channel%s.", devc->num_channels,
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_config *src;
- struct sr_channel *ch;
GSList *devices, *l;
const char *conn, *serialcomm;
struct sr_serial_dev_inst *serial;
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
struct drv_context *drvc;
struct sr_usb_dev_inst *usb;
struct sr_config *src;
- struct sr_channel *ch;
const char *conn;
drvc = udmms[dmm].di->priv;
sdi->model = g_strdup(udmms[dmm].device);
sdi->priv = devc;
sdi->driver = udmms[dmm].di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->inst_type = SR_INST_USB;
sdi->conn = usb;
drvc->instances = g_slist_append(drvc->instances, sdi);
struct drv_context *drvc;
struct dev_context *devc;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
struct sr_config *src;
GSList *usb_devices, *devices, *l;
int i;
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = l->data;
- for (i = 0; i < 3; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
- channels[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
+ for (i = 0; i < 3; i++)
+ sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channels[i]);
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
devc->limit_samples = 0;
struct drv_context *drvc;
struct dev_context *devc;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
struct libusb_device_descriptor des;
libusb_device **devlist;
GSList *devices;
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- sdi->channels = g_slist_append(NULL, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
libusb_get_device_address(devlist[i]), NULL);
/* Add analog channels. */
for (i = 0; i < scope_models[model_index].analog_channels; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
/* Add digital channels. */
for (i = 0; i < scope_models[model_index].digital_channels; i++) {
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+ ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
(*scope_models[model_index].digital_names)[i]);
- sdi->channels = g_slist_append(sdi->channels, ch);
devc->digital_groups[i / 8]->channels = g_slist_append(
devc->digital_groups[i / 8]->channels, ch);
static GSList *scan(GSList *options)
{
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
struct drv_context *drvc;
struct dev_context *devc;
const struct zp_model *prof;
// memset(devc->trigger_buffer, 0, NUM_TRIGGER_STAGES);
/* Fill in channellist according to this device's profile. */
- for (j = 0; j < devc->num_channels; j++) {
- ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
+ for (j = 0; j < devc->num_channels; j++)
+ sr_channel_new(sdi, j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j]);
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
devices = g_slist_append(devices, sdi);
drvc->instances = g_slist_append(drvc->instances, sdi);
static int init(struct sr_input *in, GHashTable *options)
{
- struct sr_channel *ch;
struct context *inc;
int num_channels, i;
char name[16];
for (i = 0; i < num_channels; i++) {
snprintf(name, 16, "%d", i);
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name);
- in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+ sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
}
return SR_OK;
static int init(struct sr_input *in, GHashTable *options)
{
- struct sr_channel *ch;
struct context *inc;
int num_channels, i;
char name[16];
for (i = 0; i < num_channels; i++) {
snprintf(name, 16, "%d", i);
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name);
- in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+ sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
}
return SR_OK;
static int initial_parse(const struct sr_input *in, GString *buf)
{
struct context *inc;
- struct sr_channel *ch;
GString *channel_name;
gsize num_columns, l, i;
unsigned int line_number;
g_string_assign(channel_name, columns[i]);
else
g_string_printf(channel_name, "%zu", i);
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name->str);
- in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+ sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name->str);
}
g_string_free(channel_name, TRUE);
static int init(struct sr_input *in, GHashTable *options)
{
- struct sr_channel *ch;
int num_channels, i;
char name[16];
struct context *inc;
for (i = 0; i < num_channels; i++) {
snprintf(name, 16, "%d", i);
- ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name);
- in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+ sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
}
return SR_OK;
struct context *inc;
struct sr_datafeed_packet packet;
struct sr_datafeed_meta meta;
- struct sr_channel *ch;
struct sr_config *src;
int offset, chunk_samples, total_samples, processed, max_chunk_samples;
int num_samples, i;
if (!inc->started) {
for (i = 0; i < inc->num_channels; i++) {
snprintf(channelname, 8, "CH%d", i + 1);
- ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channelname);
- in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+ sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
}
std_session_send_df_header(in->sdi, LOG_PREFIX);
return TRUE;
}
-static int add_channel(struct sr_dev_inst *sdi, int idx, const char *name)
-{
- struct sr_channel *ch;
-
- ch = sr_channel_new(idx, SR_CHANNEL_ANALOG, TRUE, name);
- sdi->channels = g_slist_append(sdi->channels, ch);
-
- return SR_OK;
-}
-
static const char *const channel_names[] = { "P1", "P2" };
static int setup_channels(struct sr_dev_inst *sdi)
ret = SR_ERR_BUG;
- for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
- ret = add_channel(sdi, i, channel_names[i]);
- if (ret != SR_OK)
- break;
- }
+ for (i = 0; i < ARRAY_SIZE(channel_names); i++)
+ sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
return ret;
}
SR_CHANNEL_SET_ENABLED = 1 << 0,
};
-SR_PRIV struct sr_channel *sr_channel_new(int index, int type,
- gboolean enabled, const char *name);
+SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi,
+ int index, int type, gboolean enabled, const char *name);
/** Device instance data */
struct sr_dev_inst {
struct zip_file *zf;
struct zip_stat zs;
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
int ret, i, j;
uint64_t tmp_u64, total_channels, p;
char **sections, **keys, *metafile, *val;
g_variant_new_uint64(total_channels), sdi, NULL);
for (p = 0; p < total_channels; p++) {
snprintf(channelname, SR_MAX_CHANNELNAME_LEN, "%" PRIu64, p);
- ch = sr_channel_new(p, SR_CHANNEL_LOGIC, FALSE,
+ sr_channel_new(sdi, p, SR_CHANNEL_LOGIC, FALSE,
channelname);
- sdi->channels = g_slist_append(sdi->channels, ch);
}
} else if (!strncmp(keys[j], "probe", 5)) {
if (!sdi) {