From: Martin Ling Date: Sat, 7 Dec 2013 18:47:43 +0000 (+0000) Subject: Use std_serial_dev_close() to replace matching dev_close functions. X-Git-Tag: libsigrok-0.3.0~459 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bf2c987fdef6787a5ce826ed9d98a70f52a1ff96;p=libsigrok.git Use std_serial_dev_close() to replace matching dev_close functions. --- diff --git a/hardware/agilent-dmm/api.c b/hardware/agilent-dmm/api.c index d4c9427d..2c37fe3a 100644 --- a/hardware/agilent-dmm/api.c +++ b/hardware/agilent-dmm/api.c @@ -182,19 +182,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - 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); } @@ -304,7 +291,7 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .priv = NULL, diff --git a/hardware/brymen-dmm/api.c b/hardware/brymen-dmm/api.c index c676d47e..1e1dbf65 100644 --- a/hardware/brymen-dmm/api.c +++ b/hardware/brymen-dmm/api.c @@ -162,19 +162,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - 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); } @@ -286,7 +273,7 @@ SR_PRIV struct sr_dev_driver brymen_bm857_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .priv = NULL, diff --git a/hardware/cem-dt-885x/api.c b/hardware/cem-dt-885x/api.c index 9ff8e089..f4c170de 100644 --- a/hardware/cem-dt-885x/api.c +++ b/hardware/cem-dt-885x/api.c @@ -165,19 +165,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) 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); return SR_OK; @@ -447,7 +434,7 @@ SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .priv = NULL, diff --git a/hardware/center-3xx/api.c b/hardware/center-3xx/api.c index 0960af82..ab6f4989 100644 --- a/hardware/center-3xx/api.c +++ b/hardware/center-3xx/api.c @@ -168,19 +168,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - return std_dev_acquisition_stop_serial(sdi, cb_data, dev_close, - sdi->conn, LOG_PREFIX); + return std_dev_acquisition_stop_serial(sdi, cb_data, + std_serial_dev_close, sdi->conn, LOG_PREFIX); } /* Driver-specific API function wrappers */ @@ -305,7 +292,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \ .config_set = config_set, \ .config_list = config_list, \ .dev_open = dev_open, \ - .dev_close = dev_close, \ + .dev_close = std_serial_dev_close, \ .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \ .dev_acquisition_stop = dev_acquisition_stop, \ .priv = NULL, \ diff --git a/hardware/colead-slm/api.c b/hardware/colead-slm/api.c index 9848cc59..fe3fd3d2 100644 --- a/hardware/colead-slm/api.c +++ b/hardware/colead-slm/api.c @@ -129,19 +129,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - 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); } @@ -252,7 +239,7 @@ SR_PRIV struct sr_dev_driver colead_slm_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .priv = NULL, diff --git a/hardware/fluke-dmm/api.c b/hardware/fluke-dmm/api.c index 0e6c938a..90692e79 100644 --- a/hardware/fluke-dmm/api.c +++ b/hardware/fluke-dmm/api.c @@ -215,19 +215,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - 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); } @@ -344,7 +331,7 @@ SR_PRIV struct sr_dev_driver flukedmm_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .priv = NULL, diff --git a/hardware/gmc-mh-1x-2x/api.c b/hardware/gmc-mh-1x-2x/api.c index 615209ec..acdf8413 100644 --- a/hardware/gmc-mh-1x-2x/api.c +++ b/hardware/gmc-mh-1x-2x/api.c @@ -234,14 +234,9 @@ static int dev_open(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi) { - struct sr_serial_dev_inst *serial; struct dev_context *devc; - serial = sdi->conn; - if (serial && serial->fd != -1) { - serial_close(serial); - sdi->status = SR_ST_INACTIVE; - } + std_serial_dev_close(sdi); sdi->status = SR_ST_INACTIVE; diff --git a/hardware/link-mso19/api.c b/hardware/link-mso19/api.c index 56d7700a..e283a2cb 100644 --- a/hardware/link-mso19/api.c +++ b/hardware/link-mso19/api.c @@ -51,8 +51,6 @@ static const uint64_t samplerates[] = { SR_PRIV struct sr_dev_driver 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(). */ static int dev_clear(void) { @@ -79,7 +77,7 @@ static int dev_clear(void) ret = SR_ERR_BUG; continue; } - dev_close(sdi); + std_serial_dev_close(sdi); sr_serial_dev_inst_free(devc->serial); sr_dev_inst_free(sdi); } @@ -272,20 +270,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { return dev_clear(); @@ -501,7 +485,7 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .priv = NULL, diff --git a/hardware/mic-985xx/api.c b/hardware/mic-985xx/api.c index 7983c4ae..d59c0bfc 100644 --- a/hardware/mic-985xx/api.c +++ b/hardware/mic-985xx/api.c @@ -170,19 +170,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - 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); } @@ -307,7 +294,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \ .config_set = config_set, \ .config_list = config_list, \ .dev_open = dev_open, \ - .dev_close = dev_close, \ + .dev_close = std_serial_dev_close, \ .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \ .dev_acquisition_stop = dev_acquisition_stop, \ .priv = NULL, \ diff --git a/hardware/norma-dmm/api.c b/hardware/norma-dmm/api.c index ed8378ca..d0089c62 100644 --- a/hardware/norma-dmm/api.c +++ b/hardware/norma-dmm/api.c @@ -183,14 +183,9 @@ static int dev_open(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi) { - struct sr_serial_dev_inst *serial; struct dev_context *devc; - serial = sdi->conn; - if (serial && serial->fd != -1) { - serial_close(serial); - sdi->status = SR_ST_INACTIVE; - } + std_serial_dev_close(sdi); /* Free dynamically allocated resources. */ if ((devc = sdi->priv) && devc->version) { diff --git a/hardware/openbench-logic-sniffer/api.c b/hardware/openbench-logic-sniffer/api.c index e199f09b..7ae5e08c 100644 --- a/hardware/openbench-logic-sniffer/api.c +++ b/hardware/openbench-logic-sniffer/api.c @@ -222,19 +222,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { return dev_clear(); @@ -564,7 +551,7 @@ SR_PRIV struct sr_dev_driver ols_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .priv = NULL, diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index 9ec347d7..c85e9448 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -393,19 +393,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - 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); } @@ -543,7 +530,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \ .config_set = config_set, \ .config_list = config_list, \ .dev_open = dev_open, \ - .dev_close = dev_close, \ + .dev_close = std_serial_dev_close, \ .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \ .dev_acquisition_stop = dev_acquisition_stop, \ .priv = NULL, \ diff --git a/hardware/teleinfo/api.c b/hardware/teleinfo/api.c index 861f4104..bf70660f 100644 --- a/hardware/teleinfo/api.c +++ b/hardware/teleinfo/api.c @@ -186,18 +186,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - 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); } @@ -306,7 +294,7 @@ SR_PRIV struct sr_dev_driver teleinfo_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, }; diff --git a/hardware/tondaj-sl-814/api.c b/hardware/tondaj-sl-814/api.c index 533f69fb..aa27c17c 100644 --- a/hardware/tondaj-sl-814/api.c +++ b/hardware/tondaj-sl-814/api.c @@ -141,19 +141,6 @@ static int dev_open(struct sr_dev_inst *sdi) 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) { 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) { - 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); } @@ -248,7 +235,7 @@ SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = { .config_set = config_set, .config_list = config_list, .dev_open = dev_open, - .dev_close = dev_close, + .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .priv = NULL, diff --git a/std.c b/std.c index 1067c271..415d1138 100644 --- a/std.c +++ b/std.c @@ -231,7 +231,7 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, 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;