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;
if (!serialcomm)
serialcomm = SERIALCOMM;
- sdi = sr_dev_inst_new();
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Tondaj");
sdi->model = g_strdup("SL-814");
+ devc = g_malloc0(sizeof(struct dev_context));
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
-
- if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
- return NULL;
+ serial = sr_serial_dev_inst_new(conn, serialcomm);
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
sdi->priv = devc;
sdi->driver = di;
- ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
- if (!ch) {
- sr_err("Failed to create channel.");
- return NULL;
- }
- 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);