return ret;
}
+
+SR_API GSList *sr_dev_inst_list(const struct sr_dev_driver *driver)
+{
+
+ if (driver && driver->dev_list)
+ return driver->dev_list();
+ else
+ return NULL;
+}
+
+SR_API int sr_dev_inst_clear(const struct sr_dev_driver *driver)
+{
+
+ if (driver && driver->dev_clear)
+ return driver->dev_clear();
+ else
+ return SR_OK;
+}
+
return SR_OK;
}
-static void clear_instances(void)
+static int clear_instances(void)
{
GSList *l;
struct sr_dev_inst *sdi;
g_slist_free(drvc->instances);
drvc->instances = NULL;
+ return SR_OK;
}
static int hw_init(void)
return NULL;
}
+static GSList *hw_dev_list(void)
+{
+ struct drv_context *drvc;
+
+ drvc = adi->priv;
+
+ return drvc->instances;
+}
+
static int upload_firmware(int firmware_idx, struct dev_context *devc)
{
int ret;
.init = hw_init,
.cleanup = hw_cleanup,
.scan = hw_scan,
+ .dev_list = hw_dev_list,
+ .dev_clear = clear_instances,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data);
-static void clear_instances(void)
+static int clear_instances(void)
{
GSList *l;
struct sr_dev_inst *sdi;
g_slist_free(drvc->instances);
drvc->instances = NULL;
+ return SR_OK;
}
static int hw_init(void)
return NULL;
}
+static GSList *hw_dev_list(void)
+{
+ struct drv_context *drvc;
+
+ drvc = cdi->priv;
+
+ return drvc->instances;
+}
+
static int hw_dev_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
.init = hw_init,
.cleanup = hw_cleanup,
.scan = hw_scan,
+ .dev_list = hw_dev_list,
+ .dev_clear = clear_instances,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
return devices;
}
+static GSList *hw_dev_list(void)
+{
+ struct drv_context *drvc;
+
+ drvc = ddi->priv;
+
+ return drvc->instances;
+}
+
static int hw_dev_open(struct sr_dev_inst *sdi)
{
/* Avoid compiler warnings. */
.init = hw_init,
.cleanup = hw_cleanup,
.scan = hw_scan,
+ .dev_list = hw_dev_list,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
return devices;
}
+static GSList *hw_dev_list(void)
+{
+ struct drv_context *drvc;
+
+ drvc = fdi->priv;
+
+ return drvc->instances;
+}
+
static int hw_dev_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
.init = hw_init,
.cleanup = hw_cleanup,
.scan = hw_scan,
+ .dev_list = hw_dev_list,
+ .dev_clear = clear_instances,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
return devices;
}
+static int clear_instances(void)
+{
+ GSList *l;
+ struct sr_dev_inst *sdi;
+ struct dev_context *devc;
+ struct drv_context *drvc;
+
+ if (!(drvc = gdi->priv))
+ return SR_OK;
+
+ /* Properly close and free all devices. */
+ for (l = drvc->instances; l; l = l->next) {
+ if (!(sdi = l->data)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("genericdmm: sdi was NULL, continuing.");
+ continue;
+ }
+ if (!(devc = sdi->priv)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("genericdmm: sdi->priv was NULL, continuing.");
+ continue;
+ }
+
+ if (devc->profile) {
+ switch (devc->profile->transport) {
+ case DMM_TRANSPORT_USBHID:
+ /* TODO */
+ sr_usb_dev_inst_free(devc->usb);
+ break;
+ case DMM_TRANSPORT_SERIAL:
+ if (devc->serial && devc->serial->fd != -1)
+ serial_close(devc->serial->fd);
+ sr_serial_dev_inst_free(devc->serial);
+ break;
+ }
+ }
+
+ sr_dev_inst_free(sdi);
+ }
+
+ g_slist_free(drvc->instances);
+ drvc->instances = NULL;
+
+ return SR_OK;
+}
+
static int hw_init(void)
{
struct drv_context *drvc;
return devices;
}
+static GSList *hw_dev_list(void)
+{
+ struct drv_context *drvc;
+
+ drvc = gdi->priv;
+
+ return drvc->instances;
+}
+
static int hw_dev_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
return SR_ERR_BUG;
}
- sr_dbg("genericdmm: Opening serial port '%s'.", devc->serial->port);
-
switch (devc->profile->transport) {
case DMM_TRANSPORT_USBHID:
/* TODO */
break;
case DMM_TRANSPORT_SERIAL:
/* TODO: O_NONBLOCK? */
+ sr_dbg("genericdmm: Opening serial port '%s'.", devc->serial->port);
devc->serial->fd = serial_open(devc->serial->port, O_RDWR | O_NONBLOCK);
if (devc->serial->fd == -1) {
sr_err("genericdmm: Couldn't open serial port '%s'.",
static int hw_cleanup(void)
{
- GSList *l;
- struct sr_dev_inst *sdi;
- struct dev_context *devc;
- struct drv_context *drvc;
-
- if (!(drvc = gdi->priv))
- return SR_OK;
-
- /* Properly close and free all devices. */
- for (l = drvc->instances; l; l = l->next) {
- if (!(sdi = l->data)) {
- /* Log error, but continue cleaning up the rest. */
- sr_err("genericdmm: sdi was NULL, continuing.");
- continue;
- }
- if (!(devc = sdi->priv)) {
- /* Log error, but continue cleaning up the rest. */
- sr_err("genericdmm: sdi->priv was NULL, continuing.");
- continue;
- }
- if (devc->profile) {
- switch (devc->profile->transport) {
- case DMM_TRANSPORT_USBHID:
- /* TODO */
- sr_usb_dev_inst_free(devc->usb);
- break;
- case DMM_TRANSPORT_SERIAL:
- if (devc->serial && devc->serial->fd != -1)
- serial_close(devc->serial->fd);
- sr_serial_dev_inst_free(devc->serial);
- break;
- }
- }
-
- sr_dev_inst_free(sdi);
- }
-
- g_slist_free(drvc->instances);
- drvc->instances = NULL;
+ clear_instances();
if (genericdmm_usb_context)
libusb_exit(genericdmm_usb_context);
.init = hw_init,
.cleanup = hw_cleanup,
.scan = hw_scan,
+ .dev_list = hw_dev_list,
+ .dev_clear = clear_instances,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
}
/* Properly close and free all devices. */
-static void clear_instances(void)
+static int clear_instances(void)
{
struct sr_dev_inst *sdi;
struct drv_context *drvc;
g_slist_free(drvc->instances);
drvc->instances = NULL;
+ return SR_OK;
}
static int hw_init(void)
return devices;
}
+static GSList *hw_dev_list(void)
+{
+ struct drv_context *drvc;
+
+ drvc = hdi->priv;
+
+ return drvc->instances;
+}
+
static int hw_dev_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
.init = hw_init,
.cleanup = hw_cleanup,
.scan = hw_scan,
+ .dev_list = hw_dev_list,
+ .dev_clear = clear_instances,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
return devices;
}
+static GSList *hw_dev_list(void)
+{
+ struct drv_context *drvc;
+
+ drvc = odi->priv;
+
+ return drvc->instances;
+}
+
static int hw_dev_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
.init = hw_init,
.cleanup = hw_cleanup,
.scan = hw_scan,
+ .dev_list = hw_dev_list,
+ .dev_clear = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
return SR_OK;
}
-static void clear_instances(void)
+static int clear_instances(void)
{
GSList *l;
struct sr_dev_inst *sdi;
g_slist_free(drvc->instances);
drvc->instances = NULL;
+ return SR_OK;
}
/*
return devices;
}
+static GSList *hw_dev_list(void)
+{
+ struct drv_context *drvc;
+
+ drvc = zdi->priv;
+
+ return drvc->instances;
+}
+
static int hw_dev_open(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
.init = hw_init,
.cleanup = hw_cleanup,
.scan = hw_scan,
+ .dev_list = hw_dev_list,
+ .dev_clear = hw_cleanup,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
int (*init) (void);
int (*cleanup) (void);
GSList *(*scan) (GSList *options);
+ GSList *(*dev_list) (void);
+ int (*dev_clear) (void);
/* Device-specific */
int (*dev_open) (struct sr_dev_inst *sdi);
SR_API gboolean sr_dev_has_hwcap(const struct sr_dev_inst *sdi, int hwcap);
SR_API int sr_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value);
+SR_API GSList *sr_dev_inst_list(const struct sr_dev_driver *driver);
+SR_API int sr_dev_inst_clear(const struct sr_dev_driver *driver);
/*--- filter.c --------------------------------------------------------------*/