X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fbeaglelogic%2Fapi.c;h=ff8f0424d32049c834a365fe8eefa03c0e4dfe48;hb=f1ba6b4b2c9a8ecf90bb31efb218752aa7e49d1a;hp=10f9a0fbe3a80db0b07470b601a942d6535137f2;hpb=566007e15e8ec0a23b064ba8ea44baae305508b5;p=libsigrok.git diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index 10f9a0fb..ff8f0424 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -73,16 +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; - /* Probe for /dev/beaglelogic */ if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS)) return NULL; @@ -91,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; @@ -131,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) @@ -164,8 +157,6 @@ static int dev_open(struct sr_dev_inst *sdi) return SR_ERR; } - /* We're good to go now */ - sdi->status = SR_ST_ACTIVE; return SR_OK; } @@ -173,12 +164,10 @@ 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); - } - sdi->status = SR_ST_INACTIVE; + /* Close the memory mapping and the file */ + beaglelogic_munmap(devc); + beaglelogic_close(devc); + return SR_OK; } @@ -217,9 +206,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); @@ -301,9 +287,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; @@ -324,7 +307,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); @@ -339,9 +322,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); @@ -350,7 +330,7 @@ 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; }