X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbeaglelogic%2Fapi.c;h=0be82c13ca9d2c8302a7756a125f876260437b41;hb=5a64d1d954f6ab1e3ccb8aa8a0f71d1d0c8c91b1;hp=5527dcea46a28354e6fc984a740e406cba9101ed;hpb=00f2e9bc6b97649d16a4407f26ebf5514fd634c0;p=libsigrok.git diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index 5527dcea..0be82c13 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -59,31 +59,18 @@ static const uint64_t samplerates[] = { SR_HZ(1), }; -static struct dev_context *beaglelogic_devc_alloc(void) -{ - struct dev_context *devc; - - devc = g_malloc0(sizeof(struct dev_context)); - - /* Default non-zero values (if any) */ - devc->fd = -1; - devc->limit_samples = (uint64_t)10000000; - devc->tcp_buffer = 0; - - return devc; -} - static GSList *scan(struct sr_dev_driver *di, GSList *options) { GSList *l; struct sr_config *src; struct sr_dev_inst *sdi; struct dev_context *devc; - const char *conn = NULL; + const char *conn; gchar **params; int i, maxch; maxch = NUM_CHANNELS; + conn = NULL; for (l = options; l; l = l->next) { src = l->data; if (src->key == SR_CONF_NUM_LOGIC_CHANNELS) @@ -93,7 +80,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) } /* Probe for /dev/beaglelogic if not connecting via TCP */ - if (conn == NULL) { + if (!conn) { + params = NULL; if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS)) return NULL; } else { @@ -110,19 +98,21 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) } } - if (maxch > 8) - maxch = NUM_CHANNELS; - else - maxch = 8; + maxch = (maxch > 8) ? NUM_CHANNELS : 8; sdi = g_new0(struct sr_dev_inst, 1); sdi->status = SR_ST_INACTIVE; sdi->model = g_strdup("BeagleLogic"); sdi->version = g_strdup("1.0"); - devc = beaglelogic_devc_alloc(); + devc = g_malloc0(sizeof(struct dev_context)); + + /* Default non-zero values (if any) */ + devc->fd = -1; + devc->limit_samples = 10000000; + devc->tcp_buffer = 0; - if (conn == NULL) { + if (!conn) { devc->beaglelogic = &beaglelogic_native_ops; sr_info("BeagleLogic device found at "BEAGLELOGIC_DEV_NODE); } else { @@ -141,6 +131,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sr_info("BeagleLogic device found at %s : %s", devc->address, devc->port); } + /* Fill the channels */ for (i = 0; i < maxch; i++) sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, @@ -149,6 +140,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->priv = devc; return std_scan_complete(di, g_slist_append(NULL, sdi)); + err_free: g_free(sdi->model); g_free(sdi->version); @@ -337,9 +329,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc->beaglelogic->set_sampleunit(devc); /* If continuous sampling, set the limit_samples to max possible value */ - if (devc->triggerflags == BL_TRIGGERFLAGS_CONTINUOUS) { - devc->limit_samples = (uint64_t)-1; - } + if (devc->triggerflags == BL_TRIGGERFLAGS_CONTINUOUS) + devc->limit_samples = UINT64_MAX; /* Configure triggers & send header packet */ if ((trigger = sr_session_trigger_get(sdi->session))) {