Simplify channel creation.

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.
This commit is contained in:
Martin Ling 2015-03-19 21:37:33 +00:00
parent bc49777251
commit 5e23fcab88
53 changed files with 110 additions and 270 deletions

View File

@ -42,7 +42,8 @@
*/
/** @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
@ -50,8 +51,8 @@
*
* @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;
@ -62,6 +63,8 @@ SR_PRIV struct sr_channel *sr_channel_new(int index, int type,
if (name)
ch->name = g_strdup(name);
sdi->channels = g_slist_append(sdi->channels, ch);
return ch;
}
@ -227,13 +230,10 @@ SR_API struct sr_dev_inst *sr_dev_inst_user_new(const char *vendor,
*/
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;
}

View File

@ -84,7 +84,6 @@ static GSList *scan(GSList *options)
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;
@ -150,8 +149,7 @@ static GSList *scan(GSList *options)
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;

View File

@ -55,7 +55,6 @@ static GSList *scan(GSList *options)
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;
@ -110,10 +109,8 @@ static GSList *scan(GSList *options)
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);

View File

@ -325,7 +325,6 @@ static int init(struct sr_context *sr_ctx)
static GSList *scan(GSList *options)
{
struct sr_dev_inst *sdi;
struct sr_channel *ch;
struct drv_context *drvc;
struct dev_context *devc;
GSList *devices;
@ -383,11 +382,9 @@ static GSList *scan(GSList *options)
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);

View File

@ -173,8 +173,7 @@ static GSList *scan(GSList *options, int modelid)
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);

View File

@ -201,13 +201,12 @@ static void append_channel(struct sr_dev_inst *sdi, struct sr_channel_group *cg,
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,

View File

@ -86,7 +86,6 @@ static GSList *scan(GSList *options)
struct sr_config *src;
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct sr_channel *ch;
int i, maxch;
devices = NULL;
@ -136,11 +135,9 @@ static GSList *scan(GSList *options)
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);

View File

@ -48,7 +48,6 @@ static GSList *scan(GSList *options)
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;
@ -80,10 +79,8 @@ static GSList *scan(GSList *options)
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;

View File

@ -44,7 +44,6 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
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;
@ -84,8 +83,7 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
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);

View File

@ -82,7 +82,6 @@ static GSList *scan(GSList *options)
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;
@ -122,8 +121,7 @@ static GSList *scan(GSList *options)
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;

View File

@ -72,7 +72,6 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
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;
@ -98,9 +97,8 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
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);

View File

@ -80,7 +80,6 @@ static int add_device(int idx, int model, GSList **devices)
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
struct sr_channel *ch;
ret = SR_OK;
@ -127,11 +126,9 @@ static int add_device(int idx, int model, GSList **devices)
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);

View File

@ -56,7 +56,6 @@ static GSList *scan(GSList *options)
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_config *src;
struct sr_channel *ch;
GSList *devices, *l;
const char *conn, *serialcomm;
@ -91,8 +90,7 @@ static GSList *scan(GSList *options)
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);

View File

@ -51,7 +51,6 @@ static GSList *scan(GSList *options)
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;
@ -100,8 +99,7 @@ static GSList *scan(GSList *options)
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);

View File

@ -320,8 +320,7 @@ static GSList *scan(GSList *options)
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);
@ -336,9 +335,8 @@ static GSList *scan(GSList *options)
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. */

View File

@ -69,7 +69,6 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
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;
@ -132,8 +131,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
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;

View File

@ -171,7 +171,6 @@ static GSList *scan(GSList *options)
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;
@ -288,11 +287,9 @@ static GSList *scan(GSList *options)
/* 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;

View File

@ -162,7 +162,6 @@ static GSList *scan_1x_2x_rs232(GSList *options)
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;
@ -236,8 +235,7 @@ static GSList *scan_1x_2x_rs232(GSList *options)
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);
}
@ -254,7 +252,6 @@ static GSList *scan_2x_bd232(GSList *options)
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;
@ -332,8 +329,7 @@ static GSList *scan_2x_bd232(GSList *options)
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));

View File

@ -616,9 +616,8 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
/* 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));
@ -643,9 +642,8 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
/* 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);

View File

@ -183,8 +183,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
* 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);

View File

@ -65,7 +65,6 @@ static GSList *scan(GSList *options)
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;
@ -119,12 +118,9 @@ static GSList *scan(GSList *options)
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;

View File

@ -74,7 +74,6 @@ static int init(struct sr_context *sr_ctx)
static GSList *scan(GSList *options)
{
struct sr_dev_inst *sdi;
struct sr_channel *ch;
struct drv_context *drvc;
struct dev_context *devc;
GSList *devices;
@ -127,11 +126,9 @@ static GSList *scan(GSList *options)
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);

View File

@ -113,7 +113,6 @@ static GSList *scan(GSList *options)
struct drv_context *drvc;
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_channel *ch;
GSList *usb_devices, *devices, *l;
char *model;
@ -136,8 +135,7 @@ static GSList *scan(GSList *options)
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;

View File

@ -293,7 +293,6 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
struct dev_context *devc;
const struct elusb_profile *profile;
struct sr_dev_inst *sdi;
struct sr_channel *ch;
int modelid, i;
char firmware[5];
@ -332,16 +331,12 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
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));

View File

@ -215,11 +215,9 @@ static GSList *scan(GSList *options)
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

View File

@ -92,7 +92,6 @@ static GSList *scan(GSList *options)
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;
@ -162,8 +161,7 @@ static GSList *scan(GSList *options)
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];

View File

@ -71,7 +71,6 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
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;
@ -100,13 +99,10 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
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);

View File

@ -470,8 +470,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
/* 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);

View File

@ -82,7 +82,6 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
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;
@ -155,8 +154,7 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
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;

View File

@ -98,7 +98,6 @@ static GSList *scan(GSList *options)
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;
@ -194,11 +193,9 @@ static GSList *scan(GSList *options)
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;
}

View File

@ -142,7 +142,6 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
{
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;
@ -215,11 +214,9 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
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) */
@ -253,11 +250,9 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
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 */

View File

@ -219,7 +219,6 @@ SR_PRIV int pols_convert_trigger(const struct sr_dev_inst *sdi)
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;
@ -288,11 +287,9 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
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) */
@ -324,11 +321,9 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
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 */

View File

@ -345,8 +345,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
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));
@ -362,9 +361,8 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
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);
}

View File

@ -145,7 +145,6 @@ static GSList *scan(GSList *options)
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;
@ -206,11 +205,9 @@ static GSList *scan(GSList *options)
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;

View File

@ -133,13 +133,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
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);
}
}

View File

@ -410,7 +410,6 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
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;
@ -472,8 +471,7 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
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);

View File

@ -79,30 +79,12 @@ static int init(struct sr_context *sr_ctx)
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));
@ -118,7 +100,11 @@ static struct sr_dev_inst *dev_inst_new(void)
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;
}

View File

@ -49,7 +49,6 @@ static GSList *scan(GSList *options)
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];
@ -103,42 +102,27 @@ static GSList *scan(GSList *options)
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);

View File

@ -59,7 +59,6 @@ SR_PRIV int testo_probe_channels(struct sr_dev_inst *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;
@ -136,8 +135,7 @@ SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi)
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,

View File

@ -51,7 +51,6 @@ static GSList *scan(GSList *options)
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;
@ -100,8 +99,7 @@ static GSList *scan(GSList *options)
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);

View File

@ -235,7 +235,6 @@ static GSList *scan(GSList *options, int dmm)
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;
@ -268,8 +267,7 @@ static GSList *scan(GSList *options, int dmm)
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);

View File

@ -53,7 +53,6 @@ static GSList *scan(GSList *options)
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;
@ -86,11 +85,8 @@ static GSList *scan(GSList *options)
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;

View File

@ -59,7 +59,6 @@ static GSList *scan(GSList *options)
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;
@ -92,8 +91,7 @@ static GSList *scan(GSList *options)
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);

View File

@ -669,9 +669,8 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
/* 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));
@ -698,9 +697,8 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
/* 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);

View File

@ -164,7 +164,6 @@ static int init(struct sr_context *sr_ctx)
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;
@ -247,11 +246,9 @@ static GSList *scan(GSList *options)
// 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);

View File

@ -39,7 +39,6 @@ struct context {
static int init(struct sr_input *in, GHashTable *options)
{
struct sr_channel *ch;
struct context *inc;
int num_channels, i;
char name[16];
@ -57,8 +56,7 @@ static int init(struct sr_input *in, GHashTable *options)
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;

View File

@ -51,7 +51,6 @@ static int format_match(GHashTable *metadata)
static int init(struct sr_input *in, GHashTable *options)
{
struct sr_channel *ch;
struct context *inc;
int num_channels, i;
char name[16];
@ -69,8 +68,7 @@ static int init(struct sr_input *in, GHashTable *options)
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;

View File

@ -472,7 +472,6 @@ static char *get_line_termination(GString *buf)
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;
@ -558,8 +557,7 @@ static int initial_parse(const struct sr_input *in, GString *buf)
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);

View File

@ -404,7 +404,6 @@ static void parse_contents(const struct sr_input *in, char *data)
static int init(struct sr_input *in, GHashTable *options)
{
struct sr_channel *ch;
int num_channels, i;
char name[16];
struct context *inc;
@ -434,8 +433,7 @@ static int init(struct sr_input *in, GHashTable *options)
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;

View File

@ -240,7 +240,6 @@ static int process_buffer(struct sr_input *in)
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;
@ -250,8 +249,7 @@ static int process_buffer(struct sr_input *in)
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);

View File

@ -792,16 +792,6 @@ static int receive_data(int fd, int revents, void *cb_data)
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)
@ -811,11 +801,8 @@ 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;
}

View File

@ -589,8 +589,8 @@ enum {
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 {

View File

@ -122,7 +122,6 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
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;
@ -212,9 +211,8 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
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) {