+ /* Probe for /dev/beaglelogic */
+ if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
+ return NULL;
+
+ sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, "BeagleLogic", "1.0");
+ sdi->driver = di;
+
+ /* Unless explicitly specified, keep max channels to 8 only */
+ maxch = 8;
+ for (l = options; l; l = l->next) {
+ src = l->data;
+ if (src->key == SR_CONF_NUM_LOGIC_CHANNELS)
+ maxch = g_variant_get_int32(src->data);
+ }
+
+ /* We need to test for number of channels by opening the node */
+ devc = beaglelogic_devc_alloc();
+
+ if (beaglelogic_open_nonblock(devc) != SR_OK) {
+ g_free(devc);
+ sr_dev_inst_free(sdi);
+
+ return NULL;
+ }
+
+ if (maxch > 8) {
+ maxch = NUM_CHANNELS;
+ devc->sampleunit = BL_SAMPLEUNIT_16_BITS;
+ } else {
+ maxch = 8;
+ devc->sampleunit = BL_SAMPLEUNIT_8_BITS;
+ }
+
+ beaglelogic_set_sampleunit(devc);
+ beaglelogic_close(devc);
+
+ /* Signal */
+ sr_info("BeagleLogic device found at "BEAGLELOGIC_DEV_NODE);
+
+ /* Fill the channels */
+ for (i = 0; i < maxch; i++) {
+ if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+ beaglelogic_channel_names[i])))
+ return NULL;
+ sdi->channels = g_slist_append(sdi->channels, ch);
+ }
+
+ sdi->priv = devc;
+ drvc->instances = g_slist_append(drvc->instances, sdi);
+ devices = g_slist_append(devices, sdi);