struct sr_serial_dev_inst *serial;
struct sr_channel_group *cg;
struct sr_channel *ch;
- GSList *l, *devices;
+ GSList *l;
int ret, len;
const char *conn, *serialcomm;
char buf[100];
char *bufptr;
double version;
- devices = NULL;
drvc = di->context;
conn = serialcomm = NULL;
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
- devices = g_slist_append(devices, sdi);
serial_close(serial);
- if (!devices)
- sr_serial_dev_inst_free(serial);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static int config_list(uint32_t key, GVariant **data,
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
- GSList *devices;
struct ftdi_device_list *devlist;
char serial_txt[10];
uint32_t serial;
(void)options;
- devices = NULL;
-
devc = g_malloc0(sizeof(struct dev_context));
ftdi_init(&devc->ftdic);
for (i = 0; i < ARRAY_SIZE(channel_names); i++)
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_names[i]);
- devices = g_slist_append(devices, sdi);
sdi->priv = devc;
/* We will open the device again when we need it. */
ftdi_list_free(&devlist);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
free:
ftdi_deinit(&devc->ftdic);
struct sr_channel *ch;
struct sr_channel_group *cg;
struct sr_serial_dev_inst *serial;
- GSList *l, *devices;
+ GSList *l;
const struct pps_model *model;
uint8_t packet[PACKET_SIZE];
unsigned int i;
const char *conn, *serialcomm;
char channel[10];
- devices = NULL;
drvc = di->context;
conn = serialcomm = NULL;
devc->config = g_malloc0(sizeof(struct per_channel_config) * model->num_channels);
devc->delay_ms = delay_ms;
sdi->priv = devc;
- devices = g_slist_append(devices, sdi);
serial_close(serial);
- if (!devices)
- sr_serial_dev_inst_free(serial);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static GSList *scan_3203(struct sr_dev_driver *di, GSList *options)
{
struct dev_context *devc;
struct sr_dev_inst *sdi;
- GSList *devices;
gboolean status;
int i;
(void)options;
- devices = NULL;
-
devc = g_malloc0(sizeof(struct dev_context));
devc->samplerate = SR_HZ(10);
if (!sdi->channel_groups)
goto err_out;
- devices = g_slist_append(devices, sdi);
-
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
err_out:
g_free(devc);
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
- GSList *devices, *l;
+ GSList *l;
struct sr_config *src;
struct sr_dev_inst *sdi;
struct dev_context *devc;
int i, maxch;
- devices = NULL;
-
/* Probe for /dev/beaglelogic */
if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
return NULL;
channel_names[i]);
sdi->priv = devc;
- devices = g_slist_append(devices, sdi);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static int dev_open(struct sr_dev_inst *sdi)
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
- GSList *devices;
serial = sr_serial_dev_inst_new(conn, serialcomm);
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- devices = NULL;
serial_flush(serial);
sr_info("Found device on port %s.", conn);
for (i = 0; i < center_devs[idx].num_channels; i++)
sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
- devices = g_slist_append(devices, sdi);
-
serial_close(serial);
- return devices;
+ return g_slist_append(NULL, sdi);
}
static GSList *scan(GSList *options, int idx)
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_config *src;
- GSList *devices, *l;
+ GSList *l;
const char *conn, *serialcomm;
- devices = NULL;
-
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
src = l->data;
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
- devices = g_slist_append(devices, sdi);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
struct drv_context *drvc;
struct sr_config *src;
struct sr_serial_dev_inst *serial;
- GSList *l, *devices;
+ GSList *l;
const char *conn, *serialcomm;
- devices = NULL;
drvc = di->context;
conn = serialcomm = NULL;
sdi->conn = serial;
sdi->priv = NULL;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
- devices = g_slist_append(devices, sdi);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
struct sr_channel_group *cg, *acg;
struct sr_config *src;
struct analog_gen *ag;
- GSList *devices, *l;
+ GSList *l;
int num_logic_channels, num_analog_channels, pattern, i;
char channel_name[16];
}
}
- devices = NULL;
-
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->model = g_strdup("Demo device");
}
sdi->priv = devc;
- devices = g_slist_append(devices, sdi);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static int dev_open(struct sr_dev_inst *sdi)
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
- GSList *devices;
unsigned int i;
int ret;
drvc = di->context;
- devices = NULL;
-
/* Allocate memory for our private device context. */
devc = g_malloc0(sizeof(struct dev_context));
for (i = 0; i < ARRAY_SIZE(channel_names); i++)
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_names[i]);
- devices = g_slist_append(devices, sdi);
-
/* Close device. We'll reopen it again when we need it. */
scanaplus_close(devc);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
scanaplus_close(devc);
err_free_ftdic:
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct dev_context *devc;
- GSList *devices, *l;
+ GSList *l;
struct sr_dev_inst *sdi;
struct sr_config *src;
const char *conn, *serialcomm;
int i, model_id;
unsigned int len;
- devices = NULL;
conn = NULL;
serialcomm = NULL;
/* Get current status of device. */
if (korad_kaxxxxp_get_all_values(serial, devc) < 0)
goto exit_err;
- devices = g_slist_append(devices, sdi);
serial_close(serial);
- if (!devices)
- sr_serial_dev_inst_free(serial);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
exit_err:
sr_dev_inst_free(sdi);
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_config *src;
- GSList *devices, *l;
+ GSList *l;
const char *conn, *serialcomm;
struct sr_serial_dev_inst *serial;
char reply[50], **tokens, *dummy;
- devices = NULL;
conn = NULL;
serialcomm = NULL;
devc = NULL;
devc->voltage_max_device = g_strtod(tokens[0], &dummy) * devc->model->voltage[2];
g_strfreev(tokens);
- devices = g_slist_append(devices, sdi);
-
serial_close(serial);
- if (!devices)
- sr_serial_dev_inst_free(serial);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
exit_err:
sr_dev_inst_free(sdi);
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
- GSList *devices;
serial = sr_serial_dev_inst_new(conn, serialcomm);
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- devices = NULL;
serial_flush(serial);
/* TODO: Query device type. */
if (mic_devs[idx].has_humidity)
sr_channel_new(sdi, 1, SR_CHANNEL_ANALOG, TRUE, "Humidity");
- devices = g_slist_append(devices, sdi);
-
serial_close(serial);
- return std_scan_complete(mic_devs[idx].di, devices);
+ return std_scan_complete(mic_devs[idx].di, g_slist_append(NULL, sdi));
}
static GSList *scan(GSList *options, int idx)
struct sr_serial_dev_inst *serial;
struct sr_channel *ch;
struct sr_channel_group *cg;
- GSList *devices;
const char *conn, *serialcomm;
int cnt, ret;
gchar buf[LINELEN_MAX];
sdi = NULL;
devc = NULL;
conn = serialcomm = NULL;
- devices = NULL;
sr_spew("scan() called!");
sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
}
- devices = g_slist_append(devices, sdi);
-
/* Query status */
if (lps_query_status(sdi) != SR_OK)
goto exit_err;
serial_close(serial);
- if (!devices)
- sr_serial_dev_inst_free(serial);
- return std_scan_complete(drv, devices);
+ return std_scan_complete(drv, g_slist_append(NULL, sdi));
exit_err:
sr_info("%s: Error!", __func__);
struct sr_config *src;
struct sr_dev_inst *sdi;
struct sr_serial_dev_inst *serial;
- GSList *l, *devices;
+ GSList *l;
int ret;
unsigned int i;
const char *conn, *serialcomm;
char buf[8];
- devices = NULL;
-
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
src = l->data;
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
- devices = g_slist_append(devices, sdi);
-
serial_close(serial);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
struct sr_config *src;
struct sr_serial_dev_inst *serial;
struct sr_dev_inst *sdi;
- GSList *l, *devices;
+ GSList *l;
const char *conn;
conn = NULL;
if (serial_open(serial, SERIAL_RDONLY) != SR_OK)
return NULL;
- devices = NULL;
-
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("PCE");
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL");
- devices = g_slist_append(devices, sdi);
serial_close(serial);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static int dev_clear(const struct sr_dev_driver *di)
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_config *src;
- GSList *devices, *l;
+ GSList *l;
const char *conn, *serialcomm;
struct sr_serial_dev_inst *serial;
drvc = di->context;
- devices = NULL;
-
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
if (!(src = l->data)) {
sdi->priv = devc;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
- devices = g_slist_append(devices, sdi);
- return std_scan_complete(di, devices);
+ return std_scan_complete(di, g_slist_append(NULL, sdi));
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,