From: Kumar Abhishek Date: Thu, 20 Jul 2017 14:29:48 +0000 (+0000) Subject: beaglelogic: Update scan() to return all 14 channels by default X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6eab3021ec2fd45f1b16fb21741aa8881d4f92a1;p=libsigrok.git beaglelogic: Update scan() to return all 14 channels by default This is unlike the previous behavior to return 8 channels and then use logic_channels to get all the 14 channels Signed-off-by: Kumar Abhishek --- diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index 2f632e7c..be80d00f 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -83,41 +83,24 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS)) return NULL; - sdi = g_malloc0(sizeof(struct sr_dev_inst)); - sdi->status = SR_ST_INACTIVE; - sdi->model = g_strdup("BeagleLogic"); - sdi->version = g_strdup("1.0"); - - /* Unless explicitly specified, keep max channels to 8 only */ - maxch = 8; + maxch = NUM_CHANNELS; 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) { + if (maxch > 8) maxch = NUM_CHANNELS; - devc->sampleunit = BL_SAMPLEUNIT_16_BITS; - } else { + else maxch = 8; - devc->sampleunit = BL_SAMPLEUNIT_8_BITS; - } - beaglelogic_set_sampleunit(devc); - beaglelogic_close(devc); + sdi = g_new0(struct sr_dev_inst, 1); + sdi->status = SR_ST_INACTIVE; + sdi->model = g_strdup("BeagleLogic"); + sdi->version = g_strdup("1.0"); - sr_info("BeagleLogic device found at "BEAGLELOGIC_DEV_NODE); + devc = beaglelogic_devc_alloc(); for (i = 0; i < maxch; i++) sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, @@ -125,6 +108,9 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->priv = devc; + /* Signal */ + sr_info("BeagleLogic device found at "BEAGLELOGIC_DEV_NODE); + return std_scan_complete(di, g_slist_append(NULL, sdi)); }