]> sigrok.org Git - libsigrok.git/commitdiff
Allow for sdi->priv helper function in std_dev_clear
authorBert Vermeulen <redacted>
Tue, 16 Apr 2013 22:41:01 +0000 (00:41 +0200)
committerBert Vermeulen <redacted>
Tue, 16 Apr 2013 22:49:41 +0000 (00:49 +0200)
libsigrok-internal.h
std.c

index 9d0cec32733f1291bb26b537f6adcda239fa3ef1..0dc7bb0f6b9b2eb64563e7a651dae535e1153e71 100644 (file)
@@ -117,26 +117,28 @@ SR_PRIV struct sr_config *sr_config_new(int key, GVariant *data);
 SR_PRIV void sr_config_free(struct sr_config *src);
 SR_PRIV int sr_source_remove(int fd);
 SR_PRIV int sr_source_add(int fd, int events, int timeout,
-                         sr_receive_data_callback_t cb, void *cb_data);
+               sr_receive_data_callback_t cb, void *cb_data);
 
 /*--- session.c -------------------------------------------------------------*/
 
 SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi,
-                           const struct sr_datafeed_packet *packet);
+               const struct sr_datafeed_packet *packet);
 SR_PRIV int sr_session_stop_sync(void);
 
 /*--- std.c -----------------------------------------------------------------*/
 
 typedef int (*dev_close_t)(struct sr_dev_inst *sdi);
+typedef void (*std_dev_clear_t)(void *priv);
 
 SR_PRIV int std_hw_init(struct sr_context *sr_ctx, struct sr_dev_driver *di,
-                       const char *prefix);
+               const char *prefix);
 SR_PRIV int std_hw_dev_acquisition_stop_serial(struct sr_dev_inst *sdi,
-                       void *cb_data, dev_close_t hw_dev_close_fn,
-                       struct sr_serial_dev_inst *serial, const char *prefix);
+               void *cb_data, dev_close_t hw_dev_close_fn,
+               struct sr_serial_dev_inst *serial, const char *prefix);
 SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
-                                      const char *prefix);
-SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver);
+               const char *prefix);
+SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
+               std_dev_clear_t clear_private);
 
 /*--- hardware/common/serial.c ----------------------------------------------*/
 
diff --git a/std.c b/std.c
index f3519a1df805ea86f0e96b9c3861f0931248ba3f..1b85cfcc4466664c170c0f575cd58fe3914cba25 100644 (file)
--- a/std.c
+++ b/std.c
@@ -174,7 +174,8 @@ SR_PRIV int std_hw_dev_acquisition_stop_serial(struct sr_dev_inst *sdi,
  *
  * @return SR_OK on success.
  */
-SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver)
+SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
+               std_dev_clear_t clear_private)
 {
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
@@ -203,6 +204,8 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver)
                        else if (sdi->inst_type == SR_INST_SERIAL)
                                sr_serial_dev_inst_free(sdi->conn);
                }
+               if (clear_private)
+                       clear_private(sdi->priv);
                sdi = l->data;
                sr_dev_inst_free(sdi);
        }