]> sigrok.org Git - libsigrok.git/commitdiff
std: Factor out some API call dummy implementations.
authorUwe Hermann <redacted>
Tue, 11 Jul 2017 19:21:00 +0000 (21:21 +0200)
committerUwe Hermann <redacted>
Thu, 13 Jul 2017 09:59:11 +0000 (11:59 +0200)
src/hardware/baylibre-acme/api.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/api.c
src/hardware/rohde-schwarz-sme-0x/api.c
src/hardware/uni-t-dmm/api.c
src/libsigrok-internal.h
src/std.c

index c45ab77d1da29715c4b7a1310fee35e0ef02ae14..93570f93ea3366247135f179e90252d5ae6aee8e 100644 (file)
@@ -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,
index cc5e4ebf35d02b2de3894b64c73819475f65b756..b488bcd11f624ff9a9fef4e51f255550585c1977 100644 (file)
@@ -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);
index b0a59316e490c68e9690d4904e06d1956163307e..3dd32433a5a503a37e81cb2c5e5db5d98218a5b4 100644 (file)
@@ -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,
index d449fddc58642b19e70161e045c9741e20e19da4..25096dd1c5e678d31f85f1418f8795de20539359 100644 (file)
@@ -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,
 };
index aff78b61d8454441c74392a8f8b9edeb1036d8ce..1dc14872d8163cd82ea862c5b709999e9054c863 100644 (file)
@@ -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, \
index 7dc3928abb875282bd9cc943adec7ee09b24f35a..6ce65ff7b072e3481a5d284e1e3f96c00801dccc 100644 (file)
@@ -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);
index f68cc12bd8954c29c684043fe368ef514427dca5..8ce27615e2a7069df2fc3eb9fa8ab618c00b6c3b 100644 (file)
--- 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.
  *