X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbeaglelogic%2Fapi.c;h=0d022f2b336967e0aea956071d21ca92589c55eb;hb=093e1cba6b7bf14cfb77fa36f59b0c16e6fca7cc;hp=e862d99ea90ea84af2a36ff032f9a642d3249466;hpb=e32862ebccac5ae063abc68d9ce13a66ad46bb97;p=libsigrok.git diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index e862d99e..0d022f2b 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -73,17 +73,12 @@ static struct dev_context *beaglelogic_devc_alloc(void) static GSList *scan(struct sr_dev_driver *di, GSList *options) { - struct drv_context *drvc; - GSList *devices, *l; + GSList *l; struct sr_config *src; struct sr_dev_inst *sdi; struct dev_context *devc; int i, maxch; - devices = NULL; - drvc = di->context; - drvc->instances = NULL; - /* Probe for /dev/beaglelogic */ if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS)) return NULL; @@ -92,7 +87,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->status = SR_ST_INACTIVE; sdi->model = g_strdup("BeagleLogic"); sdi->version = g_strdup("1.0"); - sdi->driver = di; /* Unless explicitly specified, keep max channels to 8 only */ maxch = 8; @@ -132,10 +126,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) channel_names[i]); sdi->priv = devc; - drvc->instances = g_slist_append(drvc->instances, sdi); - devices = g_slist_append(devices, sdi); - return devices; + return std_scan_complete(di, g_slist_append(NULL, sdi)); } static int dev_open(struct sr_dev_inst *sdi) @@ -174,12 +166,12 @@ static int dev_close(struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; - if (sdi->status == SR_ST_ACTIVE) { - /* Close the memory mapping and the file */ - beaglelogic_munmap(devc); - beaglelogic_close(devc); - } + /* Close the memory mapping and the file */ + beaglelogic_munmap(devc); + beaglelogic_close(devc); + sdi->status = SR_ST_INACTIVE; + return SR_OK; } @@ -218,9 +210,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd (void)cg; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - switch (key) { case SR_CONF_SAMPLERATE: devc->cur_samplerate = g_variant_get_uint64(data); @@ -302,9 +291,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) struct dev_context *devc = sdi->priv; struct sr_trigger *trigger; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - /* Clear capture state */ devc->bytes_read = 0; devc->offset = 0; @@ -325,7 +311,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc->trigger_fired = FALSE; } else devc->trigger_fired = TRUE; - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); /* Trigger and add poll on file */ beaglelogic_start(devc); @@ -340,9 +326,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - /* Execute a stop on BeagleLogic */ beaglelogic_stop(devc); @@ -351,12 +334,12 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) /* Remove session source and send EOT packet */ sr_session_source_remove_pollfd(sdi->session, &devc->pollfd); - std_session_send_df_end(sdi, LOG_PREFIX); + std_session_send_df_end(sdi); return SR_OK; } -SR_PRIV struct sr_dev_driver beaglelogic_driver_info = { +static struct sr_dev_driver beaglelogic_driver_info = { .name = "beaglelogic", .longname = "BeagleLogic", .api_version = 1, @@ -373,3 +356,4 @@ SR_PRIV struct sr_dev_driver beaglelogic_driver_info = { .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, }; +SR_REGISTER_DEV_DRIVER(beaglelogic_driver_info);