From: Uwe Hermann Date: Tue, 11 Jul 2017 19:21:00 +0000 (+0200) Subject: std: Factor out some API call dummy implementations. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4d67b9d9dcfbb26f21b5092b79c10da8544e7df1;p=libsigrok.git std: Factor out some API call dummy implementations. --- diff --git a/src/hardware/baylibre-acme/api.c b/src/hardware/baylibre-acme/api.c index c45ab77d..93570f93 100644 --- a/src/hardware/baylibre-acme/api.c +++ b/src/hardware/baylibre-acme/api.c @@ -126,20 +126,6 @@ err_out: return NULL; } -static int dev_open(struct sr_dev_inst *sdi) -{ - (void)sdi; - - return SR_OK; -} - -static int dev_close(struct sr_dev_inst *sdi) -{ - (void)sdi; - - return SR_OK; -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) @@ -375,8 +361,8 @@ static struct sr_dev_driver baylibre_acme_driver_info = { .config_get = config_get, .config_set = config_set, .config_list = config_list, - .dev_open = dev_open, - .dev_close = dev_close, + .dev_open = std_dummy_dev_open, + .dev_close = std_dummy_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, diff --git a/src/hardware/conrad-digi-35-cpu/api.c b/src/hardware/conrad-digi-35-cpu/api.c index cc5e4ebf..b488bcd1 100644 --- a/src/hardware/conrad-digi-35-cpu/api.c +++ b/src/hardware/conrad-digi-35-cpu/api.c @@ -158,20 +158,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return ret; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi) -{ - (void)sdi; - - return SR_OK; -} - -static int dev_acquisition_stop(struct sr_dev_inst *sdi) -{ - (void)sdi; - - return SR_OK; -} - static struct sr_dev_driver conrad_digi_35_cpu_driver_info = { .name = "conrad-digi-35-cpu", .longname = "Conrad DIGI 35 CPU", @@ -186,8 +172,8 @@ static struct sr_dev_driver conrad_digi_35_cpu_driver_info = { .config_list = config_list, .dev_open = std_serial_dev_open, .dev_close = std_serial_dev_close, - .dev_acquisition_start = dev_acquisition_start, - .dev_acquisition_stop = dev_acquisition_stop, + .dev_acquisition_start = std_dummy_dev_acquisition_start, + .dev_acquisition_stop = std_dummy_dev_acquisition_stop, .context = NULL, }; SR_REGISTER_DEV_DRIVER(conrad_digi_35_cpu_driver_info); diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index b0a59316..3dd32433 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -180,20 +180,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, g_slist_append(NULL, sdi)); } -static int dev_open(struct sr_dev_inst *sdi) -{ - (void)sdi; - - return SR_OK; -} - -static int dev_close(struct sr_dev_inst *sdi) -{ - (void)sdi; - - return SR_OK; -} - static void clear_helper(void *priv) { struct dev_context *devc; @@ -544,8 +530,8 @@ static struct sr_dev_driver demo_driver_info = { .config_get = config_get, .config_set = config_set, .config_list = config_list, - .dev_open = dev_open, - .dev_close = dev_close, + .dev_open = std_dummy_dev_open, + .dev_close = std_dummy_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, diff --git a/src/hardware/rohde-schwarz-sme-0x/api.c b/src/hardware/rohde-schwarz-sme-0x/api.c index d449fddc..25096dd1 100644 --- a/src/hardware/rohde-schwarz-sme-0x/api.c +++ b/src/hardware/rohde-schwarz-sme-0x/api.c @@ -248,13 +248,6 @@ static int config_list(uint32_t key, GVariant **data, return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi) -{ - (void)sdi; - - return SR_OK; -} - SR_PRIV struct sr_dev_driver rohde_schwarz_sme_0x_driver_info = { .name = "rohde-schwarz-sme-0x", .longname = "Rohde&Schwarz SME-0x", @@ -269,7 +262,7 @@ SR_PRIV struct sr_dev_driver rohde_schwarz_sme_0x_driver_info = { .config_list = config_list, .dev_open = dev_open, .dev_close = dev_close, - .dev_acquisition_start = dev_acquisition_start, + .dev_acquisition_start = std_dummy_dev_acquisition_start, .dev_acquisition_stop = std_serial_dev_acquisition_stop, .context = NULL, }; diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index aff78b61..1dc14872 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -106,15 +106,6 @@ static int dev_open(struct sr_dev_inst *sdi) return sr_usb_open(drvc->sr_ctx->libusb_ctx, usb); } -static int dev_close(struct sr_dev_inst *sdi) -{ - (void)sdi; - - /* TODO */ - - return SR_OK; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -188,7 +179,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) .config_set = config_set, \ .config_list = config_list, \ .dev_open = dev_open, \ - .dev_close = dev_close, \ + .dev_close = std_dummy_dev_close /* TODO */, \ .dev_acquisition_start = dev_acquisition_start, \ .dev_acquisition_stop = dev_acquisition_stop, \ .context = NULL, \ diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 7dc3928a..6ce65ff7 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -930,6 +930,10 @@ typedef void (*std_dev_clear_callback)(void *priv); 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); +SR_PRIV int std_dummy_dev_open(struct sr_dev_inst *sdi); +SR_PRIV int std_dummy_dev_close(struct sr_dev_inst *sdi); +SR_PRIV int std_dummy_dev_acquisition_start(const struct sr_dev_inst *sdi); +SR_PRIV int std_dummy_dev_acquisition_stop(struct sr_dev_inst *sdi); #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); diff --git a/src/std.c b/src/std.c index f68cc12b..8ce27615 100644 --- a/src/std.c +++ b/src/std.c @@ -93,6 +93,62 @@ SR_PRIV int std_cleanup(const struct sr_dev_driver *di) return ret; } +/** + * Dummmy driver dev_open() callback API helper. + * + * @param[in] sdi The device instance to use. May be NULL (unused). + * + * @retval SR_OK Success. + */ +SR_PRIV int std_dummy_dev_open(struct sr_dev_inst *sdi) +{ + (void)sdi; + + return SR_OK; +} + +/** + * Dummmy driver dev_close() callback API helper. + * + * @param[in] sdi The device instance to use. May be NULL (unused). + * + * @retval SR_OK Success. + */ +SR_PRIV int std_dummy_dev_close(struct sr_dev_inst *sdi) +{ + (void)sdi; + + return SR_OK; +} + +/** + * Dummmy driver dev_acquisition_start() callback API helper. + * + * @param[in] sdi The device instance to use. May be NULL (unused). + * + * @retval SR_OK Success. + */ +SR_PRIV int std_dummy_dev_acquisition_start(const struct sr_dev_inst *sdi) +{ + (void)sdi; + + return SR_OK; +} + +/** + * Dummmy driver dev_acquisition_stop() callback API helper. + * + * @param[in] sdi The device instance to use. May be NULL (unused). + * + * @retval SR_OK Success. + */ +SR_PRIV int std_dummy_dev_acquisition_stop(struct sr_dev_inst *sdi) +{ + (void)sdi; + + return SR_OK; +} + /** * Standard API helper for sending an SR_DF_HEADER packet. *