X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fsaleae-logic16%2Fapi.c;h=3597d3f1245357ca7f24e3c1f96defe930df4fea;hb=4b1a9d5d8641080bf10e269aa12a3fc17460365f;hp=dbd85fb3b2233862734d61722724b22c0128714c;hpb=695dc859c15ba4190f5c1aa2e1a6e2dc6a6e5845;p=libsigrok.git diff --git a/src/hardware/saleae-logic16/api.c b/src/hardware/saleae-logic16/api.c index dbd85fb3..3597d3f1 100644 --- a/src/hardware/saleae-logic16/api.c +++ b/src/hardware/saleae-logic16/api.c @@ -39,8 +39,6 @@ #define MAX_RENUM_DELAY_MS 3000 #define NUM_SIMUL_TRANSFERS 32 -SR_PRIV struct sr_dev_driver saleae_logic16_driver_info; - static const uint32_t scanopts[] = { SR_CONF_CONN, }; @@ -88,18 +86,15 @@ static const uint64_t samplerates[] = { SR_MHZ(10), SR_KHZ(12500), SR_MHZ(16), + SR_MHZ(20), SR_MHZ(25), SR_MHZ(32), SR_MHZ(40), + SR_MHZ(50), SR_MHZ(80), SR_MHZ(100), }; -static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) -{ - return std_init(sr_ctx, di, LOG_PREFIX); -} - static gboolean check_conf_profile(libusb_device *dev) { struct libusb_device_descriptor des; @@ -196,7 +191,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->status = SR_ST_INITIALIZING; sdi->vendor = g_strdup("Saleae"); sdi->model = g_strdup("Logic16"); - sdi->driver = di; sdi->connection_id = g_strdup(connection_id); for (j = 0; j < ARRAY_SIZE(channel_names); j++) @@ -206,7 +200,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) devc = g_malloc0(sizeof(struct dev_context)); devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V; sdi->priv = devc; - drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); if (check_conf_profile(devlist[i])) { @@ -232,12 +225,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) libusb_free_device_list(devlist, 1); g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free); - return devices; -} - -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; + return std_scan_complete(di, devices); } static int logic16_dev_open(struct sr_dev_inst *sdi) @@ -402,21 +390,6 @@ static int dev_close(struct sr_dev_inst *sdi) return SR_OK; } -static int cleanup(const struct sr_dev_driver *di) -{ - int ret; - struct drv_context *drvc; - - if (!(drvc = di->context)) - /* Can get called on an unused driver, doesn't matter. */ - return SR_OK; - - ret = std_dev_clear(di, NULL); - g_free(drvc); - - return ret; -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -788,7 +761,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) usb_source_add(sdi->session, devc->ctx, timeout, receive_data, (void *)sdi); - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); if ((ret = logic16_start_acquisition(sdi)) != SR_OK) { abort_acquisition(devc); @@ -812,14 +785,14 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) return ret; } -SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = { +static struct sr_dev_driver saleae_logic16_driver_info = { .name = "saleae-logic16", .longname = "Saleae Logic16", .api_version = 1, - .init = init, - .cleanup = cleanup, + .init = std_init, + .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, @@ -830,3 +803,4 @@ SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = { .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, }; +SR_REGISTER_DEV_DRIVER(saleae_logic16_driver_info);