void sr_device_close_all(void)
{
+ int ret;
struct sr_device *device;
while (devices) {
device = devices->data;
- if (device->plugin && device->plugin->closedev)
- device->plugin->closedev(device->plugin_index);
+ if (device->plugin && device->plugin->closedev) {
+ ret = device->plugin->closedev(device->plugin_index);
+ if (ret != SR_OK) {
+ sr_err("dev: %s: could not close device %d",
+ __func__, device->plugin_index);
+ }
+ }
sr_device_destroy(device);
}
}
return SR_OK;
}
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
{
struct sr_device_instance *sdi;
struct alsa *alsa;
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
- return;
- alsa = sdi->priv;
- if (!alsa)
- return;
+ if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+ sr_err("alsa: %s: sdi was NULL", __func__);
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
+ }
+ if (!(alsa = sdi->priv)) {
+ sr_err("alsa: %s: sdi->priv was NULL", __func__);
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
+ }
+
+ // TODO: Return values of snd_*?
if (alsa->hw_params)
snd_pcm_hw_params_free(alsa->hw_params);
if (alsa->capture_handle)
snd_pcm_close(alsa->capture_handle);
+
+ return SR_OK;
}
static void hw_cleanup(void)
return SR_OK;
}
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
{
struct sr_device_instance *sdi;
struct sigma *sigma;
- if ((sdi = sr_get_device_instance(device_instances, device_index)))
- {
- sigma = sdi->priv;
- if (sdi->status == SR_ST_ACTIVE)
- ftdi_usb_close(&sigma->ftdic);
+ if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+ sr_err("asix: %s: sdi was NULL", __func__);
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
+ }
- sdi->status = SR_ST_INACTIVE;
+ if (!(sigma = sdi->priv)) {
+ sr_err("asix: %s: sdi->priv was NULL", __func__);
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
}
+
+ /* TODO */
+ if (sdi->status == SR_ST_ACTIVE)
+ ftdi_usb_close(&sigma->ftdic);
+
+ sdi->status = SR_ST_INACTIVE;
+
+ return SR_OK;
}
static void hw_cleanup(void)
return SR_OK;
}
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
{
struct sr_device_instance *sdi;
struct la8 *la8;
if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
- return;
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
}
if (!(la8 = sdi->priv)) {
sr_err("la8: %s: sdi->priv was NULL", __func__);
- return;
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
}
sr_dbg("la8: closing device");
if (sdi->status == SR_ST_ACTIVE) {
sr_dbg("la8: %s: status ACTIVE, closing device", __func__);
+ /* TODO: Really ignore errors here, or return SR_ERR? */
(void) la8_close_usb_reset_sequencer(la8); /* Ignore errors. */
} else {
sr_dbg("la8: %s: status not ACTIVE, nothing to do", __func__);
sr_dbg("la8: %s: freeing sample buffers", __func__);
free(la8->final_buf);
+
+ return SR_OK;
}
static void hw_cleanup(void)
device_index = device_index;
/* Nothing needed so far. */
+
return SR_OK;
}
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
{
/* Avoid compiler warnings. */
device_index = device_index;
/* Nothing needed so far. */
+
+ return SR_OK;
}
static void hw_cleanup(void)
return SR_OK;
}
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
{
struct sr_device_instance *sdi;
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
- return;
+ if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+ sr_err("mso19: %s: sdi was NULL", __func__);
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
+ }
+ /* TODO */
if (sdi->serial->fd != -1) {
serial_close(sdi->serial->fd);
sdi->serial->fd = -1;
sdi->status = SR_ST_INACTIVE;
}
+
+ return SR_OK;
}
static void *hw_get_device_info(int device_index, int device_info_id)
return SR_OK;
}
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
{
struct sr_device_instance *sdi;
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
- return;
+ if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+ sr_err("ols: %s: sdi was NULL", __func__);
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
+ }
+ /* TODO */
if (sdi->serial->fd != -1) {
serial_close(sdi->serial->fd);
sdi->serial->fd = -1;
sdi->status = SR_ST_INACTIVE;
}
+
+ return SR_OK;
}
static void hw_cleanup(void)
return SR_OK;
}
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
{
struct sr_device_instance *sdi;
- if ((sdi = sr_get_device_instance(device_instances, device_index)))
- close_device(sdi);
+ if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+ sr_err("logic: %s: sdi was NULL", __func__);
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
+ }
+
+ /* TODO */
+ close_device(sdi);
+
+ return SR_OK;
}
static void hw_cleanup(void)
return SR_OK;
}
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
{
struct sr_device_instance *sdi;
- if ((sdi = sr_get_device_instance(device_instances, device_index)))
- close_device(sdi);
+ if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+ sr_err("lap-c: %s: sdi was NULL", __func__);
+ return SR_ERR; /* TODO: SR_ERR_ARG? */
+ }
+
+ /* TODO */
+ close_device(sdi);
+
+ return SR_OK;
}
static void hw_cleanup(void)
/* Device-specific */
int (*opendev) (int device_index);
- void (*closedev) (int device_index);
+ int (*closedev) (int device_index);
void *(*get_device_info) (int device_index, int device_info_id);
int (*get_status) (int device_index);
int *(*get_capabilities) (void);