From: Bert Vermeulen Date: Tue, 16 Apr 2013 22:41:01 +0000 (+0200) Subject: Allow for sdi->priv helper function in std_dev_clear X-Git-Tag: dsupstream~120 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ae5859fff08a8ccc8cba081d7500f75cc46114f7;p=libsigrok.git Allow for sdi->priv helper function in std_dev_clear --- diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 9d0cec32..0dc7bb0f 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -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 f3519a1d..1b85cfcc 100644 --- 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); }