X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fkecheng-kc-330b%2Fapi.c;h=fa50dd698d7a56400e6fa890080404052657077c;hb=f1ba6b4b2c9a8ecf90bb31efb218752aa7e49d1a;hp=f67d253238dc1e3dfe88f73085585d6a6d9b55ea;hpb=dd5c48a6d567a3cac62c4b0058588273bbeea171;p=libsigrok.git diff --git a/src/hardware/kecheng-kc-330b/api.c b/src/hardware/kecheng-kc-330b/api.c index f67d2532..fa50dd69 100644 --- a/src/hardware/kecheng-kc-330b/api.c +++ b/src/hardware/kecheng-kc-330b/api.c @@ -112,7 +112,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) (void)options; drvc = di->context; - drvc->instances = NULL; devices = NULL; if ((usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_CONN))) { @@ -125,7 +124,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->status = SR_ST_INACTIVE; sdi->vendor = g_strdup(VENDOR); sdi->model = model; /* Already g_strndup()'d. */ - sdi->driver = di; sdi->inst_type = SR_INST_USB; sdi->conn = l->data; sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "SPL"); @@ -143,14 +141,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) /* TODO: Set date/time? */ - 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) @@ -174,9 +171,8 @@ static int dev_open(struct sr_dev_inst *sdi) sr_err("Failed to claim interface: %s.", libusb_error_name(ret)); return SR_ERR; } - sdi->status = SR_ST_ACTIVE; - return ret; + return SR_OK; } static int dev_close(struct sr_dev_inst *sdi) @@ -187,8 +183,7 @@ static int dev_close(struct sr_dev_inst *sdi) usb = sdi->conn; if (!usb->devhdl) - /* Nothing to do. */ - return SR_OK; + return SR_ERR_BUG; /* This allows a frontend to configure the device without ever * doing an acquisition step. */ @@ -199,7 +194,6 @@ static int dev_close(struct sr_dev_inst *sdi) libusb_release_interface(usb->devhdl, USB_INTERFACE); libusb_close(usb->devhdl); usb->devhdl = NULL; - sdi->status = SR_ST_INACTIVE; return SR_OK; } @@ -264,9 +258,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; - devc = sdi->priv; ret = SR_OK; switch (key) { @@ -383,16 +374,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) int req_len, buf_len, len, ret; unsigned char buf[9]; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - drvc = di->context; devc = sdi->priv; usb = sdi->conn; devc->num_samples = 0; - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); if (devc->data_source == DATA_SOURCE_LIVE) { /* Force configuration. */ @@ -415,7 +403,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc->stored_samples = (buf[7] << 8) | buf[8]; if (devc->stored_samples == 0) { /* Notify frontend of empty log by sending start/end packets. */ - std_session_send_df_end(sdi, LOG_PREFIX); + std_session_send_df_end(sdi); return SR_OK; } @@ -481,9 +469,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - /* Signal USB transfer handler to clean up and stop. */ sdi->status = SR_ST_STOPPING;