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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2016-05-28 13:54:08 +02:00 committed by Uwe Hermann
parent 15f96409dc
commit 1b38775baa
22 changed files with 23 additions and 35 deletions

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 */

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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, \

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 */

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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, \

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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);
}

View File

@ -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);

View File

@ -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;
}