[EDGE_NEGATIVE] = "f",
};
-/* Initialize the SysClk LWLA driver.
- */
-static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
-{
- return std_init(sr_ctx, di, LOG_PREFIX);
-}
-
/* Create a new sigrok device instance for the indicated LWLA model.
*/
static struct sr_dev_inst *dev_inst_new(const struct model_info *model)
continue; /* no match */
/* Register device instance with driver. */
- sdi->driver = di;
- drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
}
libusb_free_device_list(devlist, 1);
g_slist_free_full(conn_devices, (GDestroyNotify)&sr_usb_dev_inst_free);
- return devices;
+ return std_scan_complete(di, devices);
}
/* Destroy the private device context.
devc = sdi->priv;
usb = sdi->conn;
- if (sdi->status != SR_ST_INACTIVE) {
- sr_err("Device already open.");
- return SR_ERR;
- }
-
/* Try the whole shebang three times, fingers crossed. */
for (i = 0; i < 3; i++) {
ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb);
/* This delay appears to be necessary for reliable operation. */
g_usleep(30 * 1000);
- sdi->status = SR_ST_ACTIVE;
-
devc->active_fpga_config = FPGA_NOCONF;
devc->short_transfer_quirk = FALSE;
devc->state = STATE_IDLE;
break;
/* Rinse and repeat. */
- sdi->status = SR_ST_INACTIVE;
sr_usb_close(usb);
}
return ret;
}
-/* Shutdown and close device.
- */
+/* Shutdown and close device. */
static int dev_close(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
devc = sdi->priv;
usb = sdi->conn;
- if (sdi->status == SR_ST_INACTIVE) {
- sr_dbg("Device already closed.");
- return SR_OK;
- }
if (devc->acquisition) {
sr_err("Cannot close device during acquisition!");
/* Request stop, leak handle, and prepare for the worst. */
return SR_ERR_BUG;
}
- sdi->status = SR_ST_INACTIVE;
-
/* Download of the shutdown bitstream, if any. */
ret = (*devc->model->apply_fpga_config)(sdi);
if (ret != SR_OK)
sr_warn("Unable to shut down device.");
libusb_release_interface(usb->devhdl, USB_INTERFACE);
+
sr_usb_close(usb);
- return ret;
+ return SR_OK;
}
/* Check whether the device options contain a specific key.
devc = sdi->priv;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
if (devc->acquisition) {
sr_err("Acquisition still in progress?");
return SR_ERR;
*/
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
- sr_info("Starting acquisition.");
-
return lwla_start_acquisition(sdi);
}
devc = sdi->priv;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
if (devc->state != STATE_IDLE && !devc->cancel_requested) {
devc->cancel_requested = TRUE;
- sr_dbg("Stopping acquisition.");
+ sr_dbg("Requesting cancel.");
}
return SR_OK;
/* SysClk LWLA driver descriptor.
*/
-SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info = {
+static struct sr_dev_driver sysclk_lwla_driver_info = {
.name = "sysclk-lwla",
.longname = "SysClk LWLA series",
.api_version = 1,
- .init = init,
+ .init = std_init,
.cleanup = std_cleanup,
.scan = scan,
.dev_list = std_dev_list,
.dev_acquisition_stop = dev_acquisition_stop,
.context = NULL,
};
+SR_REGISTER_DEV_DRIVER(sysclk_lwla_driver_info);