/*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
*
* Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
*
static int clear_instances(void)
{
- GSList *l;
- struct sr_dev_inst *sdi;
- struct drv_context *drvc;
- struct dev_context *devc;
- struct sr_usb_dev_inst *usb;
-
- drvc = di->priv;
- for (l = drvc->instances; l; l = l->next) {
- sdi = l->data;
- if (!(devc = sdi->priv)) {
- /* Log error, but continue cleaning up the rest. */
- sr_err("%s: sdi->priv was NULL, continuing", __func__);
- continue;
- }
- usb = sdi->conn;
- sr_usb_dev_inst_free(usb);
- /* Properly close all devices... */
- hw_dev_close(sdi);
- /* ...and free all their memory. */
- sr_dev_inst_free(sdi);
- }
- g_slist_free(drvc->instances);
- drvc->instances = NULL;
-
- return SR_OK;
+ return std_dev_clear(di, NULL);
}
static int hw_init(struct sr_context *sr_ctx)
devices = NULL;
- clear_instances();
-
/* Find all ZEROPLUS analyzers and add them to device list. */
devcnt = 0;
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); /* TODO: Errors. */
static int hw_cleanup(void)
{
- struct drv_context *drvc;
-
- if (!(drvc = di->priv))
- return SR_OK;
-
- clear_instances();
-
- return SR_OK;
+ return clear_instances();
}
static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- if (!sdi) {
- sr_err("%s: sdi was NULL", __func__);
- return SR_ERR_ARG;
- }
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
if (!(devc = sdi->priv)) {
sr_err("%s: sdi->priv was NULL", __func__);
unsigned int packet_num, n;
unsigned char *buf;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (!(devc = sdi->priv)) {
sr_err("%s: sdi->priv was NULL", __func__);
return SR_ERR_ARG;
analyzer_get_trigger_address(usb->devhdl));
/* Send header packet to the session bus. */
- std_session_send_df_header(cb_data, DRIVER_LOG_DOMAIN);
+ std_session_send_df_header(cb_data, LOG_PREFIX);
if (!(buf = g_try_malloc(PACKET_SIZE))) {
sr_err("Packet buffer malloc failed.");