]> sigrok.org Git - libsigrok.git/commitdiff
Use std_serial_dev_close() to replace matching dev_close functions.
authorMartin Ling <redacted>
Sat, 7 Dec 2013 18:47:43 +0000 (18:47 +0000)
committerMartin Ling <redacted>
Sat, 7 Dec 2013 19:43:47 +0000 (19:43 +0000)
15 files changed:
hardware/agilent-dmm/api.c
hardware/brymen-dmm/api.c
hardware/cem-dt-885x/api.c
hardware/center-3xx/api.c
hardware/colead-slm/api.c
hardware/fluke-dmm/api.c
hardware/gmc-mh-1x-2x/api.c
hardware/link-mso19/api.c
hardware/mic-985xx/api.c
hardware/norma-dmm/api.c
hardware/openbench-logic-sniffer/api.c
hardware/serial-dmm/api.c
hardware/teleinfo/api.c
hardware/tondaj-sl-814/api.c
std.c

index d4c9427d49b95b89ac515e8446abfde55e35f375..2c37fe3a5b164aaa219698cefee871df040283c7 100644 (file)
@@ -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,
index c676d47ea93cc062531009c475eea8a1028939f4..1e1dbf6577ee8e15b0488f36ba08d1fdb3181770 100644 (file)
@@ -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,
index 9ff8e089f3dede5b96c4a85ba125a03e73803118..f4c170de2c5d3d177fa7f16043d8d33f1c8e6d6c 100644 (file)
@@ -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,
index 0960af82af3d56037f1cd0b70f66908b2bfc683e..ab6f4989354328bb626fdd62a8b6f59362d32a0e 100644 (file)
@@ -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, \
index 9848cc59c1aff42db0cb2f99d3359a5be1be30b9..fe3fd3d280fae35fe308fc6b944a38dc7c5300fd 100644 (file)
@@ -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,
index 0e6c938a161d85c6d44cb304dc781ef5f1c5fd90..90692e79b640e0fe125fe909de69610f8f136b28 100644 (file)
@@ -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,
index 615209ec079df84235c19b8f7ad429b268363f83..acdf8413b078c18fc2fce0b01ce298806d6c984e 100644 (file)
@@ -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;
 
index 56d7700adb84ab740e9f799e8e8c3aa5c2226d00..e283a2cb7fb9cacf94ef2409c18da3c6124eba04 100644 (file)
@@ -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,
index 7983c4aec7e7d6bd808550ce1af6002169738261..d59c0bfc7c31fb0356ab5ce5073494d2f06bca69 100644 (file)
@@ -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, \
index ed8378ca231b46faa2f982a3d6e61a9ee27fdef2..d0089c62949e5245f0965ecc8bd7b440c3a71b51 100644 (file)
@@ -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) {
index e199f09b69e899f5ec25a75a6052592b69d4912b..7ae5e08cd317bbe585cf47a4a54b20bd91e75694 100644 (file)
@@ -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,
index 9ec347d7d4fe24d11cbf7630ea160dd4d8498c56..c85e94483936db95b5a16f13d68b0e9e7d16a130 100644 (file)
@@ -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, \
index 861f41044cdb6812e931b251062778c771329474..bf70660fc2a4daf6582d04d59222f5189bac1f83 100644 (file)
@@ -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,
 };
index 533f69fb108f24b75321f38de3c8838f91376900..aa27c17c30db8656165407febf69ab86f419624d 100644 (file)
@@ -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 1067c271542c2ff41ce03fdc7fe528a1b63ddbd0..415d1138b5529a372eb2c2d2b50a49e3444070ed 100644 (file)
--- 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;