+ }
+
+ buf[len] = 0;
+ tokens = g_strsplit(buf, delimiter, 0);
+ close(fd);
+
+ for (num_tokens = 0; tokens[num_tokens] != NULL; num_tokens++);
+
+ if (!(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, tokens[0],
+ num_tokens > 1 ? tokens[1] : NULL,
+ num_tokens > 3 ? tokens[3] : NULL))) {
+ g_strfreev(tokens);
+ g_free(device);
+ return NULL;
+ }
+ g_strfreev(tokens);
+
+ if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
+ sr_err("Device context malloc failed.");
+ g_free(device);
+ return NULL;
+ }
+
+ devc->device = device;
+
+ sdi->priv = devc;
+ sdi->driver = di;
+
+ for (i = 0; i < 2; i++) {
+ if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE,
+ i == 0 ? "CH1" : "CH2")))
+ return NULL;
+ sdi->probes = g_slist_append(sdi->probes, probe);
+ }
+
+ drvc->instances = g_slist_append(drvc->instances, sdi);
+ devices = g_slist_append(devices, sdi);