Use std_serial_dev_close() to replace matching dev_close functions.

This commit is contained in:
Martin Ling 2013-12-07 18:47:43 +00:00
parent 043e899a51
commit bf2c987fde
15 changed files with 27 additions and 195 deletions

View File

@ -182,19 +182,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -287,7 +274,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
} }
@ -304,7 +291,7 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL, .priv = NULL,

View File

@ -162,19 +162,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -269,7 +256,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
} }
@ -286,7 +273,7 @@ SR_PRIV struct sr_dev_driver brymen_bm857_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL, .priv = NULL,

View File

@ -165,19 +165,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -428,7 +415,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
if (sdi->status != SR_ST_ACTIVE) if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
return SR_OK; return SR_OK;
@ -447,7 +434,7 @@ SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL, .priv = NULL,

View File

@ -168,19 +168,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(int idx) static int cleanup(int idx)
{ {
return dev_clear(idx); return dev_clear(idx);
@ -265,8 +252,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data,
sdi->conn, LOG_PREFIX); std_serial_dev_close, sdi->conn, LOG_PREFIX);
} }
/* Driver-specific API function wrappers */ /* Driver-specific API function wrappers */
@ -305,7 +292,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
.config_set = config_set, \ .config_set = config_set, \
.config_list = config_list, \ .config_list = config_list, \
.dev_open = dev_open, \ .dev_open = dev_open, \
.dev_close = dev_close, \ .dev_close = std_serial_dev_close, \
.dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \ .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
.dev_acquisition_stop = dev_acquisition_stop, \ .dev_acquisition_stop = dev_acquisition_stop, \
.priv = NULL, \ .priv = NULL, \

View File

@ -129,19 +129,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -235,7 +222,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
} }
@ -252,7 +239,7 @@ SR_PRIV struct sr_dev_driver colead_slm_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL, .priv = NULL,

View File

@ -215,19 +215,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -327,7 +314,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
} }
@ -344,7 +331,7 @@ SR_PRIV struct sr_dev_driver flukedmm_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL, .priv = NULL,

View File

@ -234,14 +234,9 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_serial_dev_inst *serial;
struct dev_context *devc; struct dev_context *devc;
serial = sdi->conn; std_serial_dev_close(sdi);
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
sdi->status = SR_ST_INACTIVE; sdi->status = SR_ST_INACTIVE;

View File

@ -51,8 +51,6 @@ static const uint64_t samplerates[] = {
SR_PRIV struct sr_dev_driver link_mso19_driver_info; SR_PRIV struct sr_dev_driver link_mso19_driver_info;
static struct sr_dev_driver *di = &link_mso19_driver_info; static struct sr_dev_driver *di = &link_mso19_driver_info;
static int dev_close(struct sr_dev_inst *sdi);
/* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */ /* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */
static int dev_clear(void) static int dev_clear(void)
{ {
@ -79,7 +77,7 @@ static int dev_clear(void)
ret = SR_ERR_BUG; ret = SR_ERR_BUG;
continue; continue;
} }
dev_close(sdi); std_serial_dev_close(sdi);
sr_serial_dev_inst_free(devc->serial); sr_serial_dev_inst_free(devc->serial);
sr_dev_inst_free(sdi); sr_dev_inst_free(sdi);
} }
@ -272,20 +270,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
devc = sdi->priv;
if (devc->serial && devc->serial->fd != -1) {
serial_close(devc->serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -501,7 +485,7 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL, .priv = NULL,

View File

@ -170,19 +170,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(int idx) static int cleanup(int idx)
{ {
return dev_clear(idx); return dev_clear(idx);
@ -267,7 +254,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
} }
@ -307,7 +294,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
.config_set = config_set, \ .config_set = config_set, \
.config_list = config_list, \ .config_list = config_list, \
.dev_open = dev_open, \ .dev_open = dev_open, \
.dev_close = dev_close, \ .dev_close = std_serial_dev_close, \
.dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \ .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
.dev_acquisition_stop = dev_acquisition_stop, \ .dev_acquisition_stop = dev_acquisition_stop, \
.priv = NULL, \ .priv = NULL, \

View File

@ -183,14 +183,9 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_serial_dev_inst *serial;
struct dev_context *devc; struct dev_context *devc;
serial = sdi->conn; std_serial_dev_close(sdi);
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
/* Free dynamically allocated resources. */ /* Free dynamically allocated resources. */
if ((devc = sdi->priv) && devc->version) { if ((devc = sdi->priv) && devc->version) {

View File

@ -222,19 +222,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -564,7 +551,7 @@ SR_PRIV struct sr_dev_driver ols_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL, .priv = NULL,

View File

@ -393,19 +393,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(int dmm) static int cleanup(int dmm)
{ {
return dev_clear(dmm); return dev_clear(dmm);
@ -503,7 +490,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
} }
@ -543,7 +530,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
.config_set = config_set, \ .config_set = config_set, \
.config_list = config_list, \ .config_list = config_list, \
.dev_open = dev_open, \ .dev_open = dev_open, \
.dev_close = dev_close, \ .dev_close = std_serial_dev_close, \
.dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \ .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
.dev_acquisition_stop = dev_acquisition_stop, \ .dev_acquisition_stop = dev_acquisition_stop, \
.priv = NULL, \ .priv = NULL, \

View File

@ -186,18 +186,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -290,7 +278,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
} }
@ -306,7 +294,7 @@ SR_PRIV struct sr_dev_driver teleinfo_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
}; };

View File

@ -141,19 +141,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
if (serial && serial->fd != -1) {
serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
return SR_OK;
}
static int cleanup(void) static int cleanup(void)
{ {
return dev_clear(); return dev_clear();
@ -231,7 +218,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, return std_dev_acquisition_stop_serial(sdi, cb_data, std_serial_dev_close,
sdi->conn, LOG_PREFIX); sdi->conn, LOG_PREFIX);
} }
@ -248,7 +235,7 @@ SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = {
.config_set = config_set, .config_set = config_set,
.config_list = config_list, .config_list = config_list,
.dev_open = dev_open, .dev_open = dev_open,
.dev_close = dev_close, .dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start, .dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop, .dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL, .priv = NULL,

2
std.c
View File

@ -231,7 +231,7 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
return ret; return ret;
} }
SR_PRIV int std_serial_close(struct sr_dev_inst *sdi) SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;