X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Funi-t-ut32x%2Fapi.c;h=bc4ad43816004da970501cf8a417a74d7679b1a0;hb=15a5bfe4815f9991a9bb532c05d6244a1818a0e4;hp=f19dabeff55015f0bad2d20de530650b8821aec5;hpb=c01bf34ca264b268fee2e71ab918c71d28dc3018;p=libsigrok.git diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index f19dabef..bc4ad438 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -37,13 +37,6 @@ static const char *data_sources[] = { "Memory", }; -SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info; - -static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) -{ - return std_init(sr_ctx, di, LOG_PREFIX); -} - static GSList *scan(struct sr_dev_driver *di, GSList *options) { struct drv_context *drvc; @@ -55,7 +48,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) const char *conn; drvc = di->context; - drvc->instances = NULL; conn = NULL; for (l = options; l; l = l->next) { @@ -78,7 +70,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->status = SR_ST_INACTIVE; sdi->vendor = g_strdup(VENDOR); sdi->model = g_strdup(MODEL); - sdi->driver = di; sdi->inst_type = SR_INST_USB; sdi->conn = l->data; for (i = 0; i < ARRAY_SIZE(channel_names); i++) @@ -88,28 +79,22 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->priv = devc; devc->limit_samples = 0; devc->data_source = DEFAULT_DATA_SOURCE; - drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); } g_slist_free(usb_devices); } else g_slist_free_full(usb_devices, g_free); - return devices; + return std_scan_complete(di, devices); } static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; - struct drv_context *drvc; + struct drv_context *drvc = di->context; struct sr_usb_dev_inst *usb; int ret; - if (!(drvc = di->context)) { - sr_err("Driver was not initialized."); - return SR_ERR; - } - usb = sdi->conn; if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK) @@ -145,14 +130,8 @@ static int dev_open(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi) { - struct sr_dev_driver *di = sdi->driver; struct sr_usb_dev_inst *usb; - if (!di->context) { - sr_err("Driver was not initialized."); - return SR_ERR; - } - usb = sdi->conn; if (!usb->devhdl) /* Nothing to do. */ @@ -194,7 +173,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - struct sr_dev_driver *di = sdi->driver; struct dev_context *devc; const char *tmp_str; @@ -203,11 +181,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!di->context) { - sr_err("Driver was not initialized."); - return SR_ERR; - } - devc = sdi->priv; switch (key) { @@ -324,11 +297,11 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) return SR_OK; } -SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info = { +static struct sr_dev_driver uni_t_ut32x_driver_info = { .name = "uni-t-ut32x", .longname = "UNI-T UT32x", .api_version = 1, - .init = init, + .init = std_init, .cleanup = std_cleanup, .scan = scan, .dev_list = std_dev_list, @@ -342,3 +315,4 @@ SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info = { .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, }; +SR_REGISTER_DEV_DRIVER(uni_t_ut32x_driver_info);