From: Lars-Peter Clausen Date: Sat, 28 May 2016 11:54:08 +0000 (+0200) Subject: std_serial_dev_acquisition_stop(): Remove dev_close_fn parameter X-Git-Tag: libsigrok-0.5.0~354 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1b38775baa3016fb4d613c971dce5a4f26cacb7b;p=libsigrok.git std_serial_dev_acquisition_stop(): Remove dev_close_fn parameter All callers of std_serial_dev_acquisition_stop() currently pass the same callback for the dev_close_fn parameter as the dev_close callback of their sr_dev_driver struct. Remove the dev_close_fn parameter and invoke the drivers dev_close() callback directly. This simplifies the API and ensures consistent behaviour between different drivers. Signed-off-by: Lars-Peter Clausen --- diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index bfd22424..27db6162 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -210,7 +210,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver agdmm_driver_info = { diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index 9e4dec62..ca1ac401 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -217,8 +217,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, - std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver appa_55ii_driver_info = { diff --git a/src/hardware/arachnid-labs-re-load-pro/api.c b/src/hardware/arachnid-labs-re-load-pro/api.c index 49d39086..49db531f 100644 --- a/src/hardware/arachnid-labs-re-load-pro/api.c +++ b/src/hardware/arachnid-labs-re-load-pro/api.c @@ -337,8 +337,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, - std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver arachnid_labs_re_load_pro_driver_info = { diff --git a/src/hardware/brymen-dmm/api.c b/src/hardware/brymen-dmm/api.c index cb7f875a..d4825362 100644 --- a/src/hardware/brymen-dmm/api.c +++ b/src/hardware/brymen-dmm/api.c @@ -178,7 +178,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver brymen_bm857_driver_info = { diff --git a/src/hardware/cem-dt-885x/api.c b/src/hardware/cem-dt-885x/api.c index f7769b08..8c649c85 100644 --- a/src/hardware/cem-dt-885x/api.c +++ b/src/hardware/cem-dt-885x/api.c @@ -369,7 +369,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver cem_dt_885x_driver_info = { diff --git a/src/hardware/center-3xx/api.c b/src/hardware/center-3xx/api.c index 98d0d40e..c503da66 100644 --- a/src/hardware/center-3xx/api.c +++ b/src/hardware/center-3xx/api.c @@ -185,8 +185,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, - std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } /* Driver-specific API function wrappers */ diff --git a/src/hardware/colead-slm/api.c b/src/hardware/colead-slm/api.c index 59481dfa..3bfa91a1 100644 --- a/src/hardware/colead-slm/api.c +++ b/src/hardware/colead-slm/api.c @@ -139,7 +139,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver colead_slm_driver_info = { diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c index a0369971..423ca309 100644 --- a/src/hardware/fluke-dmm/api.c +++ b/src/hardware/fluke-dmm/api.c @@ -246,7 +246,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver flukedmm_driver_info = { diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index 00789d45..6b2508dd 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -470,7 +470,7 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = { diff --git a/src/hardware/kern-scale/api.c b/src/hardware/kern-scale/api.c index 584702da..ed6c70e8 100644 --- a/src/hardware/kern-scale/api.c +++ b/src/hardware/kern-scale/api.c @@ -176,7 +176,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } #define SCALE(ID, CHIPSET, VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, \ diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c index dbff9dbb..da6c0de9 100644 --- a/src/hardware/korad-kaxxxxp/api.c +++ b/src/hardware/korad-kaxxxxp/api.c @@ -365,8 +365,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - return std_serial_dev_acquisition_stop(sdi, - std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver korad_kaxxxxp_driver_info = { diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c index f22d7334..d49f6129 100644 --- a/src/hardware/manson-hcs-3xxx/api.c +++ b/src/hardware/manson-hcs-3xxx/api.c @@ -371,8 +371,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, - std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver manson_hcs_3xxx_driver_info = { diff --git a/src/hardware/mic-985xx/api.c b/src/hardware/mic-985xx/api.c index 40a6bc3d..4a070bcc 100644 --- a/src/hardware/mic-985xx/api.c +++ b/src/hardware/mic-985xx/api.c @@ -197,7 +197,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } /* Driver-specific API function wrappers */ diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c index c5e7b617..1b227e78 100644 --- a/src/hardware/motech-lps-30x/api.c +++ b/src/hardware/motech-lps-30x/api.c @@ -782,7 +782,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver motech_lps_301_driver_info = { diff --git a/src/hardware/norma-dmm/api.c b/src/hardware/norma-dmm/api.c index 1ff354c4..a4f33c07 100644 --- a/src/hardware/norma-dmm/api.c +++ b/src/hardware/norma-dmm/api.c @@ -221,7 +221,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver norma_dmm_driver_info = { diff --git a/src/hardware/pce-322a/api.c b/src/hardware/pce-322a/api.c index 77d885ee..f40db9e6 100644 --- a/src/hardware/pce-322a/api.c +++ b/src/hardware/pce-322a/api.c @@ -321,7 +321,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver pce_322a_driver_info = { diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 650aaf24..570ec785 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -197,7 +197,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } #define DMM(ID, CHIPSET, VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, TIMEOUT, \ diff --git a/src/hardware/teleinfo/api.c b/src/hardware/teleinfo/api.c index a1461f83..51ea1186 100644 --- a/src/hardware/teleinfo/api.c +++ b/src/hardware/teleinfo/api.c @@ -181,8 +181,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, - std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver teleinfo_driver_info = { diff --git a/src/hardware/tondaj-sl-814/api.c b/src/hardware/tondaj-sl-814/api.c index ad03350f..68c02026 100644 --- a/src/hardware/tondaj-sl-814/api.c +++ b/src/hardware/tondaj-sl-814/api.c @@ -151,7 +151,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } static struct sr_dev_driver tondaj_sl_814_driver_info = { diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c index 7c084f7f..ad364611 100644 --- a/src/lcr/es51919.c +++ b/src/lcr/es51919.c @@ -926,6 +926,5 @@ SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi) SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, - std_serial_dev_close); + return std_serial_dev_acquisition_stop(sdi); } diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 49629d65..08c9b788 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -926,8 +926,7 @@ SR_PRIV int std_init(struct sr_dev_driver *di, struct sr_context *sr_ctx); SR_PRIV int std_cleanup(const struct sr_dev_driver *di); #ifdef HAVE_LIBSERIALPORT SR_PRIV int std_serial_dev_open(struct sr_dev_inst *sdi); -SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi, - dev_close_callback dev_close_fn); +SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi); #endif SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi); SR_PRIV int std_session_send_df_end(const struct sr_dev_inst *sdi); diff --git a/src/std.c b/src/std.c index 218f8f3f..7cd23131 100644 --- a/src/std.c +++ b/src/std.c @@ -203,17 +203,13 @@ SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi) * * @param sdi The device instance for which acquisition should stop. * Must not be NULL. - * @param cb_data Opaque 'cb_data' pointer. Must not be NULL. - * @param dev_close_fn Function pointer to the driver's dev_close(). - * Must not be NULL. * * @retval SR_OK Success. * @retval SR_ERR_ARG Invalid arguments. * @retval SR_ERR_DEV_CLOSED Device is closed. * @retval SR_ERR Other errors. */ -SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi, - dev_close_callback dev_close_fn) +SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi) { struct sr_serial_dev_inst *serial = sdi->conn; const char *prefix = sdi->driver->name; @@ -231,7 +227,7 @@ SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi, return ret; } - if ((ret = dev_close_fn(sdi)) < 0) { + if ((ret = sdi->driver->dev_close(sdi)) < 0) { sr_err("%s: Failed to close device: %d.", prefix, ret); return ret; }