sr: cleanup callback: Return int.
This commit is contained in:
parent
3010f21c91
commit
57ab7d9f92
|
@ -150,15 +150,19 @@ static int hw_closedev(int device_index)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
struct sr_device_instance *sdi;
|
||||
|
||||
if (!(sdi = sr_get_device_instance(device_instances, 0)))
|
||||
return;
|
||||
if (!(sdi = sr_get_device_instance(device_instances, 0))) {
|
||||
sr_err("alsa: %s: sdi was NULL", __func__);
|
||||
return SR_ERR_BUG;
|
||||
}
|
||||
|
||||
g_free(sdi->priv);
|
||||
sr_device_instance_free(sdi);
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static void *hw_get_device_info(int device_index, int device_info_id)
|
||||
|
|
|
@ -721,20 +721,27 @@ static int hw_closedev(int device_index)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
GSList *l;
|
||||
struct sr_device_instance *sdi;
|
||||
int ret = SR_OK;
|
||||
|
||||
/* Properly close all devices. */
|
||||
for (l = device_instances; l; l = l->next) {
|
||||
sdi = l->data;
|
||||
if (sdi->priv != NULL)
|
||||
if (!(sdi = l->data)) {
|
||||
/* Log error, but continue cleaning up the rest. */
|
||||
sr_err("asix: %s: sdi was NULL, continuing", __func__);
|
||||
ret = SR_ERR_BUG;
|
||||
continue;
|
||||
}
|
||||
g_free(sdi->priv);
|
||||
sr_device_instance_free(sdi);
|
||||
}
|
||||
g_slist_free(device_instances);
|
||||
device_instances = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *hw_get_device_info(int device_index, int device_info_id)
|
||||
|
|
|
@ -679,17 +679,20 @@ static int hw_closedev(int device_index)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
GSList *l;
|
||||
struct sr_device_instance *sdi;
|
||||
int ret = SR_OK;
|
||||
|
||||
sr_spew("la8: entering %s", __func__);
|
||||
|
||||
/* Properly close all devices. */
|
||||
for (l = device_instances; l; l = l->next) {
|
||||
if ((sdi = l->data) == NULL) {
|
||||
if (!(sdi = l->data)) {
|
||||
/* Log error, but continue cleaning up the rest. */
|
||||
sr_err("la8: %s: sdi was NULL, continuing", __func__);
|
||||
ret = SR_ERR_BUG;
|
||||
continue;
|
||||
}
|
||||
#if 0
|
||||
|
@ -707,6 +710,8 @@ static void hw_cleanup(void)
|
|||
}
|
||||
g_slist_free(device_instances); /* Returns void. */
|
||||
device_instances = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *hw_get_device_info(int device_index, int device_info_id)
|
||||
|
|
|
@ -174,9 +174,10 @@ static int hw_closedev(int device_index)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
/* Nothing needed so far. */
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static void *hw_get_device_info(int device_index, int device_info_id)
|
||||
|
|
|
@ -518,25 +518,30 @@ ret:
|
|||
return devcnt;
|
||||
}
|
||||
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
GSList *l;
|
||||
struct sr_device_instance *sdi;
|
||||
int ret = SR_OK;
|
||||
|
||||
/* Properly close all devices. */
|
||||
for (l = device_instances; l; l = l->next) {
|
||||
sdi = l->data;
|
||||
if (!(sdi = l->data)) {
|
||||
/* Log error, but continue cleaning up the rest. */
|
||||
sr_err("mso19: %s: sdi was NULL, continuing", __func__);
|
||||
ret = SR_ERR_BUG;
|
||||
continue;
|
||||
}
|
||||
if (sdi->serial->fd != -1)
|
||||
serial_close(sdi->serial->fd);
|
||||
if (sdi->priv != NULL)
|
||||
{
|
||||
g_free(sdi->priv);
|
||||
sdi->priv = NULL;
|
||||
}
|
||||
sr_device_instance_free(sdi);
|
||||
}
|
||||
g_slist_free(device_instances);
|
||||
device_instances = NULL;
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_opendev(int device_index)
|
||||
|
|
|
@ -521,16 +521,29 @@ static int hw_closedev(int device_index)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
GSList *l;
|
||||
struct sr_device_instance *sdi;
|
||||
struct ols_device *ols;
|
||||
int ret = SR_OK;
|
||||
|
||||
/* Properly close and free all devices. */
|
||||
for (l = device_instances; l; l = l->next) {
|
||||
sdi = l->data;
|
||||
ols = sdi->priv;
|
||||
if (!(sdi = l->data)) {
|
||||
/* Log error, but continue cleaning up the rest. */
|
||||
sr_err("ols: %s: sdi was NULL, continuing", __func__);
|
||||
ret = SR_ERR_BUG;
|
||||
continue;
|
||||
}
|
||||
if (!(ols = sdi->priv)) {
|
||||
/* Log error, but continue cleaning up the rest. */
|
||||
sr_err("ols: %s: sdi->priv was NULL, continuing",
|
||||
__func__);
|
||||
ret = SR_ERR_BUG;
|
||||
continue;
|
||||
}
|
||||
/* TODO: Check for serial != NULL. */
|
||||
if (ols->serial->fd != -1)
|
||||
serial_close(ols->serial->fd);
|
||||
sr_serial_device_instance_free(ols->serial);
|
||||
|
@ -538,6 +551,8 @@ static void hw_cleanup(void)
|
|||
}
|
||||
g_slist_free(device_instances);
|
||||
device_instances = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *hw_get_device_info(int device_index, int device_info_id)
|
||||
|
|
|
@ -460,16 +460,28 @@ static int hw_closedev(int device_index)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
GSList *l;
|
||||
struct sr_device_instance *sdi;
|
||||
struct fx2_device *fx2;
|
||||
int ret = SR_OK;
|
||||
|
||||
/* Properly close and free all devices. */
|
||||
for (l = device_instances; l; l = l->next) {
|
||||
sdi = l->data;
|
||||
fx2 = sdi->priv;
|
||||
if (!(sdi = l->data)) {
|
||||
/* Log error, but continue cleaning up the rest. */
|
||||
sr_err("fx2: %s: sdi was NULL, continuing", __func__);
|
||||
ret = SR_ERR_BUG;
|
||||
continue;
|
||||
}
|
||||
if (!(fx2 = sdi->priv)) {
|
||||
/* Log error, but continue cleaning up the rest. */
|
||||
sr_err("fx2: %s: sdi->priv was NULL, continuing",
|
||||
__func__);
|
||||
ret = SR_ERR_BUG;
|
||||
continue;
|
||||
}
|
||||
close_device(sdi);
|
||||
sr_usb_device_instance_free(fx2->usb);
|
||||
sr_device_instance_free(sdi);
|
||||
|
@ -481,6 +493,8 @@ static void hw_cleanup(void)
|
|||
if (usb_context)
|
||||
libusb_exit(usb_context);
|
||||
usb_context = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *hw_get_device_info(int device_index, int device_info_id)
|
||||
|
|
|
@ -485,10 +485,12 @@ static int hw_closedev(int device_index)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
/* TODO: Error handling. */
|
||||
|
||||
/* Properly close all devices... */
|
||||
for (l = device_instances; l; l = l->next)
|
||||
close_device((struct sr_device_instance *)l->data);
|
||||
|
@ -502,6 +504,8 @@ static void hw_cleanup(void)
|
|||
if (usb_context)
|
||||
libusb_exit(usb_context);
|
||||
usb_context = NULL;
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static void *hw_get_device_info(int device_index, int device_info_id)
|
||||
|
|
|
@ -138,7 +138,7 @@ static int feed_chunk(int fd, int revents, void *session_data)
|
|||
}
|
||||
|
||||
/* driver callbacks */
|
||||
static void hw_cleanup(void);
|
||||
static int hw_cleanup(void);
|
||||
|
||||
/**
|
||||
* TODO.
|
||||
|
@ -149,7 +149,6 @@ static void hw_cleanup(void);
|
|||
*/
|
||||
static int hw_init(const char *deviceinfo)
|
||||
{
|
||||
|
||||
sessionfile = g_strdup(deviceinfo);
|
||||
|
||||
return 0;
|
||||
|
@ -159,10 +158,12 @@ static int hw_init(const char *deviceinfo)
|
|||
* TODO.
|
||||
*
|
||||
*/
|
||||
static void hw_cleanup(void)
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
/* TODO: Error handling. */
|
||||
|
||||
for (l = device_instances; l; l = l->next)
|
||||
sr_device_instance_free(l->data);
|
||||
|
||||
|
@ -172,6 +173,8 @@ static void hw_cleanup(void)
|
|||
sr_session_source_remove(-1);
|
||||
|
||||
g_free(sessionfile);
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_opendev(int device_index)
|
||||
|
|
Loading…
Reference in New Issue