diff --git a/include/libsigrok/libsigrok.h b/include/libsigrok/libsigrok.h index 6096b5bf..544bb08b 100644 --- a/include/libsigrok/libsigrok.h +++ b/include/libsigrok/libsigrok.h @@ -1156,11 +1156,9 @@ struct sr_dev_driver { /** Close device */ int (*dev_close) (struct sr_dev_inst *sdi); /** Begin data acquisition on the specified device. */ - int (*dev_acquisition_start) (const struct sr_dev_inst *sdi, - void *cb_data); + int (*dev_acquisition_start) (const struct sr_dev_inst *sdi); /** End data acquisition on the specified device. */ - int (*dev_acquisition_stop) (struct sr_dev_inst *sdi, - void *cb_data); + int (*dev_acquisition_stop) (struct sr_dev_inst *sdi); /* Dynamic */ /** Device driver context, considered private. Initialized by init(). */ diff --git a/src/hardware/agilent-dmm/agilent-dmm.h b/src/hardware/agilent-dmm/agilent-dmm.h index 77a4a3dc..2c5da1f8 100644 --- a/src/hardware/agilent-dmm/agilent-dmm.h +++ b/src/hardware/agilent-dmm/agilent-dmm.h @@ -55,9 +55,6 @@ struct dev_context { uint64_t limit_samples; uint64_t limit_msec; - /* Opaque pointer passed in by the frontend. */ - void *cb_data; - /* Runtime. */ uint64_t num_samples; int64_t jobqueue[8]; diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index dd39322c..6a34985f 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -227,18 +227,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { - struct dev_context *devc; struct sr_serial_dev_inst *serial; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - devc = sdi->priv; - devc->cb_data = cb_data; - - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; @@ -248,9 +244,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/agilent-dmm/sched.c b/src/hardware/agilent-dmm/sched.c index e5c0cc58..07dbbade 100644 --- a/src/hardware/agilent-dmm/sched.c +++ b/src/hardware/agilent-dmm/sched.c @@ -122,7 +122,7 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data) dispatch(sdi); if (devc->limit_samples && devc->num_samples >= devc->limit_samples) - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -305,7 +305,7 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match) analog.data = &fvalue; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index e033f5d3..d81d0763 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -225,7 +225,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_serial_dev_inst *serial; struct dev_context *devc; @@ -235,7 +235,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->session_cb_data = cb_data; /* * Reset the number of samples to take. If we've already collected our @@ -245,7 +244,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->num_samples = 0; devc->start_time = g_get_monotonic_time(); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 50ms, or whenever some data comes in. */ serial_source_add(sdi->session, serial, G_IO_IN, 50, @@ -254,9 +253,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/appa-55ii/protocol.c b/src/hardware/appa-55ii/protocol.c index 84826890..257f6057 100644 --- a/src/hardware/appa-55ii/protocol.c +++ b/src/hardware/appa-55ii/protocol.c @@ -120,7 +120,7 @@ static void appa_55ii_live_data(struct sr_dev_inst *sdi, const uint8_t *buf) packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->session_cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); devc->num_samples++; @@ -172,7 +172,7 @@ static void appa_55ii_log_data_parse(struct sr_dev_inst *sdi) packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->session_cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); devc->num_samples++; @@ -216,7 +216,7 @@ static void appa_55ii_log_end(struct sr_dev_inst *sdi) if (devc->data_source != DATA_SOURCE_MEMORY) return; - sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data); + sdi->driver->dev_acquisition_stop(sdi); } static const uint8_t *appa_55ii_parse_data(struct sr_dev_inst *sdi, @@ -303,7 +303,7 @@ SR_PRIV int appa_55ii_receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -311,8 +311,7 @@ SR_PRIV int appa_55ii_receive_data(int fd, int revents, void *cb_data) time = (g_get_monotonic_time() - devc->start_time) / 1000; if (time > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, - devc->session_cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/appa-55ii/protocol.h b/src/hardware/appa-55ii/protocol.h index 4e8b1292..23b59b95 100644 --- a/src/hardware/appa-55ii/protocol.h +++ b/src/hardware/appa-55ii/protocol.h @@ -42,7 +42,6 @@ struct dev_context { uint64_t limit_samples; /**< The sampling limit (in number of samples). */ uint64_t limit_msec; /**< The time limit (in milliseconds). */ gboolean data_source; /**< Whether to read live samples or memory */ - void *session_cb_data; /**< Opaque pointer passed in by the frontend. */ /* Operational state */ uint64_t num_samples; /**< The number of already received samples. */ diff --git a/src/hardware/arachnid-labs-re-load-pro/api.c b/src/hardware/arachnid-labs-re-load-pro/api.c index 1c351ffe..4e186051 100644 --- a/src/hardware/arachnid-labs-re-load-pro/api.c +++ b/src/hardware/arachnid-labs-re-load-pro/api.c @@ -340,14 +340,12 @@ static int config_set(uint32_t key, GVariant *data, return ret; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { int ret; struct dev_context *devc; struct sr_serial_dev_inst *serial; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -366,7 +364,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) serial_source_add(sdi->session, serial, G_IO_IN, 100, reloadpro_receive_data, (void *)sdi); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); memset(devc->buf, 0, RELOADPRO_BUFSIZE); devc->buflen = 0; @@ -376,9 +374,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/arachnid-labs-re-load-pro/protocol.c b/src/hardware/arachnid-labs-re-load-pro/protocol.c index 7ba13540..9431ff3f 100644 --- a/src/hardware/arachnid-labs-re-load-pro/protocol.c +++ b/src/hardware/arachnid-labs-re-load-pro/protocol.c @@ -266,7 +266,7 @@ SR_PRIV int reloadpro_receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -274,7 +274,7 @@ SR_PRIV int reloadpro_receive_data(int fd, int revents, void *cb_data) t = (g_get_monotonic_time() - devc->starttime) / 1000; if (t > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/asix-sigma/api.c b/src/hardware/asix-sigma/api.c index c7cc4d6d..506b6f65 100644 --- a/src/hardware/asix-sigma/api.c +++ b/src/hardware/asix-sigma/api.c @@ -301,7 +301,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct clockselect_50 clockselect; @@ -398,8 +398,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) gettimeofday(&devc->start_tv, 0); sigma_set_register(WRITE_MODE, 0x0d, devc); - devc->cb_data = cb_data; - std_session_send_df_header(sdi, LOG_PREFIX); /* Add capture source. */ @@ -410,12 +408,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - devc = sdi->priv; devc->state.state = SIGMA_IDLE; diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index 0e41207a..d9db069e 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -908,7 +908,7 @@ static int download_capture(struct sr_dev_inst *sdi) std_session_send_df_end(sdi, LOG_PREFIX); - sdi->driver->dev_acquisition_stop(sdi, sdi); + sdi->driver->dev_acquisition_stop(sdi); g_free(dram_line); diff --git a/src/hardware/asix-sigma/protocol.h b/src/hardware/asix-sigma/protocol.h index d654e609..9a2e5fc6 100644 --- a/src/hardware/asix-sigma/protocol.h +++ b/src/hardware/asix-sigma/protocol.h @@ -218,7 +218,6 @@ struct dev_context { struct sigma_trigger trigger; int use_triggers; struct sigma_state state; - void *cb_data; }; extern SR_PRIV const uint64_t samplerates[]; diff --git a/src/hardware/atten-pps3xxx/api.c b/src/hardware/atten-pps3xxx/api.c index c90ab12d..734d78b9 100644 --- a/src/hardware/atten-pps3xxx/api.c +++ b/src/hardware/atten-pps3xxx/api.c @@ -460,14 +460,12 @@ static int dev_close(struct sr_dev_inst *sdi) return std_serial_dev_close(sdi); } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; uint8_t packet[PACKET_SIZE]; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -480,7 +478,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) serial = sdi->conn; serial_source_add(sdi->session, serial, G_IO_IN, 50, atten_pps3xxx_receive_data, (void *)sdi); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Send a "channel" configuration packet now. */ memset(packet, 0, PACKET_SIZE); @@ -491,12 +489,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/baylibre-acme/api.c b/src/hardware/baylibre-acme/api.c index caafc703..bcd900d4 100644 --- a/src/hardware/baylibre-acme/api.c +++ b/src/hardware/baylibre-acme/api.c @@ -349,7 +349,7 @@ static int dev_acquisition_open(const struct sr_dev_inst *sdi) return 0; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct itimerspec tspec = { @@ -357,8 +357,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) .it_value = { 0, 0 } }; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -398,12 +396,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) diff --git a/src/hardware/baylibre-acme/protocol.c b/src/hardware/baylibre-acme/protocol.c index 0bef0b22..c09e91aa 100644 --- a/src/hardware/baylibre-acme/protocol.c +++ b/src/hardware/baylibre-acme/protocol.c @@ -750,7 +750,7 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data) */ for (i = 0; i < nrexpiration; i++) { framep.type = SR_DF_FRAME_BEGIN; - sr_session_send(cb_data, &framep); + sr_session_send(sdi, &framep); /* * Due to different units used in each channel we're sending @@ -773,18 +773,18 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data) chp->val = read_sample(ch); analog.data = &chp->val; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } framep.type = SR_DF_FRAME_END; - sr_session_send(cb_data, &framep); + sr_session_send(sdi, &framep); } devc->samples_read++; if (devc->limit_samples > 0 && devc->samples_read >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); devc->last_sample_fin = g_get_monotonic_time(); return TRUE; } else if (devc->limit_msec > 0) { @@ -793,7 +793,7 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data) if (elapsed_time >= devc->limit_msec) { sr_info("Sampling time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); devc->last_sample_fin = g_get_monotonic_time(); return TRUE; } diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index eb0d186a..8baf6523 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -337,19 +337,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * #define BUFUNIT_TIMEOUT_MS(devc) (100 + ((devc->bufunitsize * 1000) / \ (uint32_t)(devc->cur_samplerate))) -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; struct sr_trigger *trigger; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - /* Save user pointer */ - devc->cb_data = cb_data; - /* Clear capture state */ devc->bytes_read = 0; devc->offset = 0; @@ -370,7 +365,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->trigger_fired = FALSE; } else devc->trigger_fired = TRUE; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Trigger and add poll on file */ beaglelogic_start(devc); @@ -381,12 +376,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/beaglelogic/protocol.c b/src/hardware/beaglelogic/protocol.c index f440592f..ce6c2ae9 100644 --- a/src/hardware/beaglelogic/protocol.c +++ b/src/hardware/beaglelogic/protocol.c @@ -64,7 +64,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data) if (devc->trigger_fired) { /* Send the incoming transfer to the session bus. */ - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } else { /* Check for trigger */ trigger_offset = soft_trigger_logic_check(devc->stl, @@ -76,7 +76,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data) bytes_remaining); logic.data += trigger_offset; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->trigger_fired = TRUE; } @@ -101,7 +101,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data) if (devc->bytes_read >= devc->limit_samples * logic.unitsize || packetsize == 0) { /* Send EOA Packet, stop polling */ - std_session_send_df_end(devc->cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); sr_session_source_remove_pollfd(sdi->session, &devc->pollfd); } diff --git a/src/hardware/beaglelogic/protocol.h b/src/hardware/beaglelogic/protocol.h index 75e74725..e058a60a 100644 --- a/src/hardware/beaglelogic/protocol.h +++ b/src/hardware/beaglelogic/protocol.h @@ -59,8 +59,6 @@ struct dev_context { uint32_t offset; uint8_t *sample_buf; /* mmap'd kernel buffer here */ - void *cb_data; - /* Trigger logic */ struct soft_trigger_logic *stl; gboolean trigger_fired; diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index 4098b926..ea7866bd 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -249,12 +249,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -269,10 +267,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/brymen-bm86x/protocol.c b/src/hardware/brymen-bm86x/protocol.c index 17d1a905..b2b955f5 100644 --- a/src/hardware/brymen-bm86x/protocol.c +++ b/src/hardware/brymen-bm86x/protocol.c @@ -330,7 +330,7 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached, stopping."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -338,7 +338,7 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data) time = (g_get_monotonic_time() - devc->start_time) / 1000; if (time > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached, stopping."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/brymen-dmm/api.c b/src/hardware/brymen-dmm/api.c index 3700515f..ceb7d846 100644 --- a/src/hardware/brymen-dmm/api.c +++ b/src/hardware/brymen-dmm/api.c @@ -194,7 +194,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -203,7 +203,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; /* * Reset the number of samples to take. If we've already collected our @@ -213,7 +212,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->num_samples = 0; devc->starttime = g_get_monotonic_time(); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 50ms, or whenever some data comes in. */ serial = sdi->conn; @@ -223,9 +222,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/brymen-dmm/protocol.c b/src/hardware/brymen-dmm/protocol.c index 4db460af..1667bef6 100644 --- a/src/hardware/brymen-dmm/protocol.c +++ b/src/hardware/brymen-dmm/protocol.c @@ -42,7 +42,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi) /* Got a measurement. */ packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; } } @@ -139,7 +139,7 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached, stopping."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -147,7 +147,7 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data) time = (g_get_monotonic_time() - devc->starttime) / 1000; if (time > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached, stopping."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/brymen-dmm/protocol.h b/src/hardware/brymen-dmm/protocol.h index 24fe63d3..6f59206a 100644 --- a/src/hardware/brymen-dmm/protocol.h +++ b/src/hardware/brymen-dmm/protocol.h @@ -46,9 +46,6 @@ struct dev_context { /** The current sampling limit (in ms). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; diff --git a/src/hardware/cem-dt-885x/api.c b/src/hardware/cem-dt-885x/api.c index b9a7cb68..146c8046 100644 --- a/src/hardware/cem-dt-885x/api.c +++ b/src/hardware/cem-dt-885x/api.c @@ -378,7 +378,7 @@ 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 *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -387,12 +387,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; devc->state = ST_INIT; devc->num_samples = 0; devc->buf_len = 0; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; @@ -402,12 +401,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +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, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/cem-dt-885x/protocol.c b/src/hardware/cem-dt-885x/protocol.c index 68d003a0..25098185 100644 --- a/src/hardware/cem-dt-885x/protocol.c +++ b/src/hardware/cem-dt-885x/protocol.c @@ -140,12 +140,11 @@ static void process_mset(const struct sr_dev_inst *sdi) analog.data = &devc->last_spl; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; if (devc->limit_samples && devc->num_samples >= devc->limit_samples) - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi); break; case TOKEN_RECORDING_ON: devc->recording = TRUE; @@ -199,12 +198,11 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data, analog.data = fbuf; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples += analog.num_samples; if (devc->limit_samples && devc->num_samples >= devc->limit_samples) - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi); return; } @@ -317,8 +315,7 @@ static void process_byte(const struct sr_dev_inst *sdi, const unsigned char c, * records. Otherwise the frontend would have no * way to tell where stored data ends and live * measurements begin. */ - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi); } else if (c == RECORD_DATA) { devc->buf_len = 0; devc->state = ST_GET_LOG_RECORD_DATA; @@ -342,7 +339,7 @@ static void process_byte(const struct sr_dev_inst *sdi, const unsigned char c, src = sr_config_new(SR_CONF_SAMPLE_INTERVAL, g_variant_new_uint64(devc->buf[7] * 1000)); meta.config = g_slist_append(NULL, src); - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_free(src); devc->buf_len = 0; } diff --git a/src/hardware/cem-dt-885x/protocol.h b/src/hardware/cem-dt-885x/protocol.h index 69afacae..d6a94661 100644 --- a/src/hardware/cem-dt-885x/protocol.h +++ b/src/hardware/cem-dt-885x/protocol.h @@ -104,7 +104,6 @@ struct dev_context { gboolean enable_data_source_memory; /* Temporary state across callbacks */ - void *cb_data; unsigned char cmd; unsigned char token; int buf_len; diff --git a/src/hardware/center-3xx/api.c b/src/hardware/center-3xx/api.c index 7fe70fa9..bdcb0169 100644 --- a/src/hardware/center-3xx/api.c +++ b/src/hardware/center-3xx/api.c @@ -204,8 +204,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data, int idx) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -214,11 +213,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; devc->num_samples = 0; devc->starttime = g_get_monotonic_time(); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 500ms, or whenever some data comes in. */ serial = sdi->conn; @@ -228,9 +226,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } @@ -251,8 +249,8 @@ static GSList *dev_list_##X(const struct sr_dev_driver *d) { \ static int dev_clear_##X(const struct sr_dev_driver *d) { \ (void)d; return dev_clear(X); } #define HW_DEV_ACQUISITION_START(X) \ -static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ -void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } +static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \ +) { return dev_acquisition_start(sdi, X); } /* Driver structs and API function wrappers */ #define DRV(ID, ID_UPPER, NAME, LONGNAME) \ diff --git a/src/hardware/center-3xx/protocol.c b/src/hardware/center-3xx/protocol.c index 34478fae..0c491723 100644 --- a/src/hardware/center-3xx/protocol.c +++ b/src/hardware/center-3xx/protocol.c @@ -153,7 +153,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx) l = g_slist_append(l, g_slist_nth_data(sdi->channels, i)); analog.channels = l; analog.data = &(info.temp[i]); - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(l); } @@ -235,7 +235,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data) if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -243,7 +243,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data) t = (g_get_monotonic_time() - devc->starttime) / 1000; if (t > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/center-3xx/protocol.h b/src/hardware/center-3xx/protocol.h index acad71d4..f6564491 100644 --- a/src/hardware/center-3xx/protocol.h +++ b/src/hardware/center-3xx/protocol.h @@ -60,9 +60,6 @@ struct dev_context { /** The current sampling limit (in ms). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index 5914ef21..d8de0da1 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -47,7 +47,7 @@ static const int32_t trigger_matches[] = { SR_TRIGGER_FALLING, }; -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); +static int dev_acquisition_stop(struct sr_dev_inst *sdi); static void clear_helper(void *priv) { @@ -92,7 +92,6 @@ static int add_device(int model, struct libusb_device_descriptor *des, devc->cur_samplerate = 0; /* Set later (different for LA8/LA16). */ devc->limit_msec = 0; devc->limit_samples = 0; - devc->cb_data = NULL; memset(devc->mangled_buf, 0, BS); devc->final_buf = NULL; devc->trigger_pattern = 0x0000; /* Irrelevant, see trigger_mask. */ @@ -478,7 +477,7 @@ static int receive_data(int fd, int revents, void *cb_data) /* Get one block of data. */ if ((ret = cv_read_block(devc)) < 0) { sr_err("Failed to read data block: %d.", ret); - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); return FALSE; } @@ -499,14 +498,14 @@ static int receive_data(int fd, int revents, void *cb_data) * full 8MByte first, only then the whole buffer contains valid data. */ for (i = 0; i < NUM_BLOCKS; i++) - cv_send_block_to_session_bus(devc, i); + cv_send_block_to_session_bus(sdi, i); - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); return TRUE; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; uint8_t buf[8]; @@ -562,8 +561,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) sr_dbg("Hardware acquisition started successfully."); - devc->cb_data = cb_data; - std_session_send_df_header(sdi, LOG_PREFIX); /* Time when we should be done (for detecting trigger timeouts). */ @@ -578,10 +575,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - sr_dbg("Stopping acquisition."); sr_session_source_remove(sdi->session, -1); std_session_send_df_end(sdi, LOG_PREFIX); diff --git a/src/hardware/chronovu-la/protocol.c b/src/hardware/chronovu-la/protocol.c index a4689fa3..599472c5 100644 --- a/src/hardware/chronovu-la/protocol.c +++ b/src/hardware/chronovu-la/protocol.c @@ -401,16 +401,19 @@ SR_PRIV int cv_read_block(struct dev_context *devc) return SR_OK; } -SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block) +SR_PRIV void cv_send_block_to_session_bus(const struct sr_dev_inst *sdi, int block) { int i, idx; uint8_t sample, expected_sample, tmp8; struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; int trigger_point; /* Relative trigger point (in this block). */ + struct dev_context *devc; /* Note: Caller ensures devc/devc->ftdic != NULL and block > 0. */ + devc = sdi->priv; + /* TODO: Implement/test proper trigger support for the LA16. */ /* Check if we can find the trigger condition in this block. */ @@ -458,7 +461,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block) logic.length = BS; logic.unitsize = devc->prof->num_channels / 8; logic.data = devc->final_buf + (block * BS); - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); return; } @@ -481,7 +484,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block) logic.length = trigger_point; logic.unitsize = devc->prof->num_channels / 8; logic.data = devc->final_buf + (block * BS); - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } /* Send the SR_DF_TRIGGER packet to the session bus. */ @@ -489,7 +492,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block) (block * BS) + trigger_point); packet.type = SR_DF_TRIGGER; packet.payload = NULL; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); /* If at least one sample is located after the trigger... */ if (trigger_point < (BS - 1)) { @@ -502,6 +505,6 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block) logic.length = BS - trigger_point; logic.unitsize = devc->prof->num_channels / 8; logic.data = devc->final_buf + (block * BS) + trigger_point; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } } diff --git a/src/hardware/chronovu-la/protocol.h b/src/hardware/chronovu-la/protocol.h index bd1efff2..44e2c861 100644 --- a/src/hardware/chronovu-la/protocol.h +++ b/src/hardware/chronovu-la/protocol.h @@ -69,8 +69,6 @@ struct dev_context { /** The current sampling limit (in number of samples). */ uint64_t limit_samples; - void *cb_data; - /** * A buffer containing some (mangled) samples from the device. * Format: Pretty mangled-up (due to hardware reasons), see code. @@ -137,6 +135,6 @@ SR_PRIV int cv_write(struct dev_context *devc, uint8_t *buf, int size); SR_PRIV int cv_convert_trigger(const struct sr_dev_inst *sdi); SR_PRIV int cv_set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate); SR_PRIV int cv_read_block(struct dev_context *devc); -SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block); +SR_PRIV void cv_send_block_to_session_bus(const struct sr_dev_inst *sdi, int block); #endif diff --git a/src/hardware/colead-slm/api.c b/src/hardware/colead-slm/api.c index b75af7f6..c7019a31 100644 --- a/src/hardware/colead-slm/api.c +++ b/src/hardware/colead-slm/api.c @@ -171,18 +171,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { - struct dev_context *devc; struct sr_serial_dev_inst *serial; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - devc = sdi->priv; - devc->cb_data = cb_data; - - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 150ms, or whenever some data comes in. */ serial = sdi->conn; @@ -192,9 +188,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/colead-slm/protocol.c b/src/hardware/colead-slm/protocol.c index 481a6dd3..c7acc9e3 100644 --- a/src/hardware/colead-slm/protocol.c +++ b/src/hardware/colead-slm/protocol.c @@ -169,13 +169,11 @@ static void process_packet(const struct sr_dev_inst *sdi) packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; if (devc->num_samples >= devc->limit_samples) - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); - + sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi); } SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data) diff --git a/src/hardware/colead-slm/protocol.h b/src/hardware/colead-slm/protocol.h index 4cc49974..ab878e75 100644 --- a/src/hardware/colead-slm/protocol.h +++ b/src/hardware/colead-slm/protocol.h @@ -39,9 +39,6 @@ struct dev_context { /** The current sampling limit (in ms). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; int state; diff --git a/src/hardware/conrad-digi-35-cpu/api.c b/src/hardware/conrad-digi-35-cpu/api.c index 1f3abe81..3fc2cb7d 100644 --- a/src/hardware/conrad-digi-35-cpu/api.c +++ b/src/hardware/conrad-digi-35-cpu/api.c @@ -182,20 +182,16 @@ 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 *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/demo/demo.c b/src/hardware/demo/demo.c index 50780214..d0b1f7b8 100644 --- a/src/hardware/demo/demo.c +++ b/src/hardware/demo/demo.c @@ -177,7 +177,7 @@ static const uint8_t pattern_sigrok[] = { SR_PRIV struct sr_dev_driver demo_driver_info; -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); +static int dev_acquisition_stop(struct sr_dev_inst *sdi); static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) { @@ -757,7 +757,7 @@ static int prepare_data(int fd, int revents, void *cb_data) if (devc->cur_samplerate <= 0 || devc->logic_unitsize <= 0 || (devc->num_logic_channels <= 0 && devc->num_analog_channels <= 0)) { - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); return G_SOURCE_CONTINUE; } @@ -841,20 +841,18 @@ static int prepare_data(int fd, int revents, void *cb_data) } } sr_dbg("Requested number of samples reached."); - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); } return G_SOURCE_CONTINUE; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; GHashTableIter iter; void *value; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -877,10 +875,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - sr_dbg("Stopping acquisition."); sr_session_source_remove(sdi->session, -1); std_session_send_df_end(sdi, LOG_PREFIX); diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c index a7b2e14d..bc2e0e56 100644 --- a/src/hardware/fluke-dmm/api.c +++ b/src/hardware/fluke-dmm/api.c @@ -251,7 +251,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -260,9 +260,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; @@ -279,9 +278,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/fluke-dmm/fluke-dmm.h b/src/hardware/fluke-dmm/fluke-dmm.h index 823f1624..8f1571ce 100644 --- a/src/hardware/fluke-dmm/fluke-dmm.h +++ b/src/hardware/fluke-dmm/fluke-dmm.h @@ -52,9 +52,6 @@ struct dev_context { uint64_t limit_samples; uint64_t limit_msec; - /* Opaque pointer passed in by the frontend. */ - void *cb_data; - /* Runtime. */ uint64_t num_samples; char buf[FLUKEDMM_BUFSIZE]; diff --git a/src/hardware/fluke-dmm/fluke.c b/src/hardware/fluke-dmm/fluke.c index 7a1fbf92..3629b5f3 100644 --- a/src/hardware/fluke-dmm/fluke.c +++ b/src/hardware/fluke-dmm/fluke.c @@ -399,7 +399,7 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens) analog.mqflags = 0; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; } @@ -467,7 +467,7 @@ static void handle_line(const struct sr_dev_inst *sdi) /* Got a measurement. */ packet.type = SR_DF_ANALOG_OLD; packet.payload = analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; g_free(analog->data); g_free(analog); @@ -509,7 +509,7 @@ SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data) } if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } diff --git a/src/hardware/ftdi-la/api.c b/src/hardware/ftdi-la/api.c index afc6be45..2cea73ea 100644 --- a/src/hardware/ftdi-la/api.c +++ b/src/hardware/ftdi-la/api.c @@ -457,12 +457,10 @@ static int config_list(uint32_t key, GVariant **data, return ret; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) @@ -473,8 +471,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) ftdi_set_bitmode(devc->ftdic, 0, BITMODE_BITBANG); - devc->cb_data = cb_data; - /* Properly reset internal variables before every new acquisition. */ devc->samples_sent = 0; devc->bytes_received = 0; @@ -488,10 +484,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/ftdi-la/protocol.c b/src/hardware/ftdi-la/protocol.c index 273d79e7..8d81d877 100644 --- a/src/hardware/ftdi-la/protocol.c +++ b/src/hardware/ftdi-la/protocol.c @@ -20,19 +20,22 @@ #include #include "protocol.h" -static void send_samples(struct dev_context *devc, uint64_t samples_to_send) +static void send_samples(struct sr_dev_inst *sdi, uint64_t samples_to_send) { struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; + struct dev_context *devc; sr_spew("Sending %" PRIu64 " samples.", samples_to_send); + devc = sdi->priv; + packet.type = SR_DF_LOGIC; packet.payload = &logic; logic.length = samples_to_send; logic.unitsize = 1; logic.data = devc->data_buf; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->samples_sent += samples_to_send; devc->bytes_received -= samples_to_send; @@ -76,7 +79,7 @@ SR_PRIV int ftdi_la_receive_data(int fd, int revents, void *cb_data) if (bytes_read < 0) { sr_err("Failed to read FTDI data (%d): %s.", bytes_read, ftdi_get_error_string(devc->ftdic)); - sdi->driver->dev_acquisition_stop(sdi, sdi); + sdi->driver->dev_acquisition_stop(sdi); return FALSE; } if (bytes_read == 0) { @@ -89,12 +92,12 @@ SR_PRIV int ftdi_la_receive_data(int fd, int revents, void *cb_data) n = devc->samples_sent + devc->bytes_received; if (devc->limit_samples && (n >= devc->limit_samples)) { - send_samples(devc, devc->limit_samples - devc->samples_sent); + send_samples(sdi, devc->limit_samples - devc->samples_sent); sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } else { - send_samples(devc, devc->bytes_received); + send_samples(sdi, devc->bytes_received); } return TRUE; diff --git a/src/hardware/ftdi-la/protocol.h b/src/hardware/ftdi-la/protocol.h index 54c19ee3..aa72dffa 100644 --- a/src/hardware/ftdi-la/protocol.h +++ b/src/hardware/ftdi-la/protocol.h @@ -48,7 +48,6 @@ struct dev_context { unsigned char *data_buf; uint64_t samples_sent; uint64_t bytes_received; - void *cb_data; }; SR_PRIV int ftdi_la_set_samplerate(struct dev_context *devc); diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 976cfbf9..90d28507 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -844,7 +844,7 @@ static int configure_channels(const struct sr_dev_inst *sdi) return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_dev_driver *di; struct drv_context *drvc; @@ -860,7 +860,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc = sdi->priv; devc->ctx = drvc->sr_ctx; - devc->cb_data = cb_data; devc->sent_samples = 0; devc->empty_transfer_count = 0; devc->acq_aborted = FALSE; @@ -894,12 +893,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - devc = sdi->priv; if (devc->dslogic) diff --git a/src/hardware/fx2lafw/protocol.c b/src/hardware/fx2lafw/protocol.c index 513fd0e2..c496aa14 100644 --- a/src/hardware/fx2lafw/protocol.c +++ b/src/hardware/fx2lafw/protocol.c @@ -385,15 +385,19 @@ static void resubmit_transfer(struct libusb_transfer *transfer) } -SR_PRIV void mso_send_data_proc(struct dev_context *devc, +SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi, uint8_t *data, size_t length, size_t sample_width) { size_t i; + struct dev_context *devc; + + devc = sdi->priv; + sample_width = sample_width; length /= 2; /* Send the logic */ - for(i = 0; i < length; i++) { + for (i = 0; i < length; i++) { devc->logic_buffer[i] = data[i * 2]; /* Rescale to -10V - +10V from 0-255. */ devc->analog_buffer[i] = data[i * 2 + 1] - 128.0f / 12.8f; @@ -409,7 +413,8 @@ SR_PRIV void mso_send_data_proc(struct dev_context *devc, .type = SR_DF_LOGIC, .payload = &logic }; - sr_session_send(devc->cb_data, &logic_packet); + + sr_session_send(sdi, &logic_packet); const struct sr_datafeed_analog_old analog = { .channels = devc->enabled_analog_channels, @@ -424,11 +429,11 @@ SR_PRIV void mso_send_data_proc(struct dev_context *devc, .type = SR_DF_ANALOG_OLD, .payload = &analog }; - sr_session_send(devc->cb_data, &analog_packet); + sr_session_send(sdi, &analog_packet); } -SR_PRIV void la_send_data_proc(struct dev_context *devc, +SR_PRIV void la_send_data_proc(struct sr_dev_inst *sdi, uint8_t *data, size_t length, size_t sample_width) { const struct sr_datafeed_logic logic = { @@ -442,7 +447,7 @@ SR_PRIV void la_send_data_proc(struct dev_context *devc, .payload = &logic }; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transfer) @@ -512,10 +517,8 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf else num_samples = cur_sample_count; - devc->send_data_proc(devc, - (uint8_t*)transfer->buffer, - num_samples * unitsize, - unitsize); + devc->send_data_proc(sdi, (uint8_t *)transfer->buffer, + num_samples * unitsize, unitsize); devc->sent_samples += num_samples; } } else { @@ -528,10 +531,9 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf num_samples > devc->limit_samples - devc->sent_samples) num_samples = devc->limit_samples - devc->sent_samples; - devc->send_data_proc(devc, - (uint8_t*)transfer->buffer + trigger_offset * unitsize, - num_samples * unitsize, - unitsize); + devc->send_data_proc(sdi, (uint8_t *)transfer->buffer + + trigger_offset * unitsize, + num_samples * unitsize, unitsize); devc->sent_samples += num_samples; devc->trigger_fired = TRUE; diff --git a/src/hardware/fx2lafw/protocol.h b/src/hardware/fx2lafw/protocol.h index 4c2f65f1..2e424ac3 100644 --- a/src/hardware/fx2lafw/protocol.h +++ b/src/hardware/fx2lafw/protocol.h @@ -122,11 +122,10 @@ struct dev_context { int submitted_transfers; int empty_transfer_count; - void *cb_data; unsigned int num_transfers; struct libusb_transfer **transfers; struct sr_context *ctx; - void (*send_data_proc)(struct dev_context *devc, + void (*send_data_proc)(struct sr_dev_inst *sdi, uint8_t *data, size_t length, size_t sample_width); uint8_t *logic_buffer; float *analog_buffer; @@ -148,9 +147,9 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf SR_PRIV size_t fx2lafw_get_buffer_size(struct dev_context *devc); SR_PRIV unsigned int fx2lafw_get_number_of_transfers(struct dev_context *devc); SR_PRIV unsigned int fx2lafw_get_timeout(struct dev_context *devc); -SR_PRIV void la_send_data_proc(struct dev_context *devc, uint8_t *data, size_t length, - size_t sample_width); -SR_PRIV void mso_send_data_proc(struct dev_context *devc, uint8_t *data, size_t length, - size_t sample_width); +SR_PRIV void la_send_data_proc(struct sr_dev_inst *sdi, uint8_t *data, + size_t length, size_t sample_width); +SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi, uint8_t *data, + size_t length, size_t sample_width); #endif diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index d4e44b25..2b7bfca6 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -460,8 +460,7 @@ static int config_list_bd(uint32_t key, GVariant **data, const struct sr_dev_ins return SR_OK; } -static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -470,11 +469,10 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi, return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; devc->settings_ok = FALSE; devc->buflen = 0; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Start timer, if required. */ if (devc->limit_msec) @@ -488,8 +486,7 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi, return SR_OK; } -static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -498,11 +495,10 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi, return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; devc->settings_ok = FALSE; devc->buflen = 0; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Start timer, if required. */ if (devc->limit_msec) @@ -517,7 +513,7 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi, return req_meas14(sdi); } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -525,7 +521,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) if (sdi && (devc = sdi->priv) && devc->limit_msec) g_timer_stop(devc->elapsed_msec); - return std_serial_dev_acquisition_stop(sdi, cb_data, dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/gmc-mh-1x-2x/protocol.c b/src/hardware/gmc-mh-1x-2x/protocol.c index c5554cb9..1607bfa4 100644 --- a/src/hardware/gmc-mh-1x-2x/protocol.c +++ b/src/hardware/gmc-mh-1x-2x/protocol.c @@ -668,7 +668,7 @@ static void send_value(struct sr_dev_inst *sdi) memset(&packet, 0, sizeof(struct sr_datafeed_packet)); packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; } @@ -1173,12 +1173,12 @@ SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data) /* If number of samples or time limit reached, stop acquisition. */ if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); if (devc->limit_msec) { elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL); if ((elapsed_s * 1000) >= devc->limit_msec) - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); } return TRUE; @@ -1224,12 +1224,12 @@ SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data) /* If number of samples or time limit reached, stop acquisition. */ if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); if (devc->limit_msec) { elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL); if ((elapsed_s * 1000) >= devc->limit_msec) - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); } /* Request next data set, if required */ diff --git a/src/hardware/gmc-mh-1x-2x/protocol.h b/src/hardware/gmc-mh-1x-2x/protocol.h index 7e75fc4b..b368576b 100644 --- a/src/hardware/gmc-mh-1x-2x/protocol.h +++ b/src/hardware/gmc-mh-1x-2x/protocol.h @@ -90,9 +90,6 @@ struct dev_context { uint64_t limit_samples; /**< Target number of samples */ uint64_t limit_msec; /**< Target sampling time */ - /* Opaque pointer passed in by frontend. */ - void *cb_data; - /* Operational state */ gboolean settings_ok; /**< Settings msg received yet. */ int msg_type; /**< Message type (MSGID_INF, ...). */ diff --git a/src/hardware/gwinstek-gds-800/api.c b/src/hardware/gwinstek-gds-800/api.c index 89d6a07a..e2d28f3f 100644 --- a/src/hardware/gwinstek-gds-800/api.c +++ b/src/hardware/gwinstek-gds-800/api.c @@ -209,13 +209,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_scpi_dev_inst *scpi; struct dev_context *devc; - (void)cb_data; - scpi = sdi->conn; devc = sdi->priv; @@ -231,14 +229,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct sr_scpi_dev_inst *scpi; struct dev_context *devc; struct sr_datafeed_packet packet; - (void)cb_data; - scpi = sdi->conn; devc = sdi->priv; diff --git a/src/hardware/gwinstek-gds-800/protocol.c b/src/hardware/gwinstek-gds-800/protocol.c index 358e962a..77058577 100644 --- a/src/hardware/gwinstek-gds-800/protocol.c +++ b/src/hardware/gwinstek-gds-800/protocol.c @@ -23,7 +23,7 @@ #define ANALOG_CHANNELS 2 #define VERTICAL_DIVISIONS 10 -static int read_data(struct sr_dev_inst *sdi, void *cb_data, +static int read_data(struct sr_dev_inst *sdi, struct sr_scpi_dev_inst *scpi, struct dev_context *devc, int data_size) { @@ -34,7 +34,7 @@ static int read_data(struct sr_dev_inst *sdi, void *cb_data, data_size - devc->cur_rcv_buffer_position); if (len < 0) { sr_err("Read data error."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); devc->cur_rcv_buffer_position = 0; return SR_ERR; } @@ -54,7 +54,7 @@ static int read_data(struct sr_dev_inst *sdi, void *cb_data, return SR_OK; } else { sr_err("Too many bytes read."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); devc->cur_rcv_buffer_position = 0; return SR_ERR; } @@ -92,17 +92,17 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data) case START_ACQUISITION: if (sr_scpi_send(scpi, ":TRIG:MOD 3") != SR_OK) { sr_err("Failed to set trigger mode to SINGLE."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } if (sr_scpi_send(scpi, ":STOP") != SR_OK) { sr_err("Failed to put the trigger system into STOP state."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } if (sr_scpi_send(scpi, ":RUN") != SR_OK) { sr_err("Failed to put the trigger system into RUN state."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -113,12 +113,12 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data) if (((struct sr_channel *)g_slist_nth_data(sdi->channels, devc->cur_acq_channel))->enabled) { if (sr_scpi_send(scpi, ":ACQ%d:MEM?", devc->cur_acq_channel+1) != SR_OK) { sr_err("Failed to acquire memory."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } if (sr_scpi_read_begin(scpi) != SR_OK) { sr_err("Could not begin reading SCPI response."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } devc->state = WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE; @@ -132,7 +132,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data) /* All frames accquired. */ sr_spew("All frames acquired."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } else { /* Start acquiring next frame. */ @@ -154,19 +154,19 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data) } break; case WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE: - if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK) { + if (read_data(sdi, scpi, devc, 1) == SR_OK) { if (devc->rcv_buffer[0] == '#') devc->state = WAIT_FOR_TRANSFER_OF_DATA_SIZE_DIGIT_COMPLETE; } break; case WAIT_FOR_TRANSFER_OF_DATA_SIZE_DIGIT_COMPLETE: - if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK) { + if (read_data(sdi, scpi, devc, 1) == SR_OK) { if (devc->rcv_buffer[0] != '4' && devc->rcv_buffer[0] != '5' && devc->rcv_buffer[0] != '6') { sr_err("Data size digits is not 4, 5 or 6 but " "'%c'.", devc->rcv_buffer[0]); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } else { devc->data_size_digits = devc->rcv_buffer[0] - '0'; @@ -175,18 +175,18 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data) } break; case WAIT_FOR_TRANSFER_OF_DATA_SIZE_COMPLETE: - if (read_data(sdi, cb_data, scpi, devc, devc->data_size_digits) == SR_OK) { + if (read_data(sdi, scpi, devc, devc->data_size_digits) == SR_OK) { devc->rcv_buffer[devc->data_size_digits] = 0; if (sr_atoi(devc->rcv_buffer, &devc->data_size) != SR_OK) { sr_err("Could not parse data size '%s'", devc->rcv_buffer); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } else devc->state = WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE; } break; case WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE: - if (read_data(sdi, cb_data, scpi, devc, sizeof(float)) == SR_OK) { + if (read_data(sdi, scpi, devc, sizeof(float)) == SR_OK) { /* * Contrary to the documentation, this field is * transfered with most significant byte first! @@ -206,21 +206,21 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data) } break; case WAIT_FOR_TRANSFER_OF_CHANNEL_INDICATOR_COMPLETE: - if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK) + if (read_data(sdi, scpi, devc, 1) == SR_OK) devc->state = WAIT_FOR_TRANSFER_OF_RESERVED_DATA_COMPLETE; break; case WAIT_FOR_TRANSFER_OF_RESERVED_DATA_COMPLETE: - if (read_data(sdi, cb_data, scpi, devc, 3) == SR_OK) + if (read_data(sdi, scpi, devc, 3) == SR_OK) devc->state = WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE; break; case WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE: - if (read_data(sdi, cb_data, scpi, devc, devc->data_size - 8) == SR_OK) { + if (read_data(sdi, scpi, devc, devc->data_size - 8) == SR_OK) { /* Fetch data needed for conversion from device. */ snprintf(command, sizeof(command), ":CHAN%d:SCAL?", devc->cur_acq_channel + 1); if (sr_scpi_get_string(scpi, command, &response) != SR_OK) { sr_err("Failed to get volts per division."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } volts_per_division = g_ascii_strtod(response, &end_ptr); @@ -245,7 +245,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data) analog.mqflags = 0; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); /* All channels acquired. */ @@ -255,7 +255,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data) if (devc->cur_acq_frame == devc->frame_limit - 1) { /* All frames acquired. */ sr_spew("All frames acquired."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } else { /* Start acquiring next frame. */ diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index b234caa2..a9bcca8c 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -710,7 +710,7 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi) return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { GSList *l; gboolean digital_added; @@ -757,20 +757,18 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50, hmo_receive_data, (void *)sdi); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); devc->current_channel = devc->enabled_channels; return hmo_request_data(sdi); } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_scpi_dev_inst *scpi; - (void)cb_data; - std_session_send_df_end(sdi, LOG_PREFIX); if (sdi->status != SR_ST_ACTIVE) diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index a073d0de..9137b3b7 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -773,7 +773,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data) analog.mqflags = 0; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); g_array_free(data, TRUE); data = NULL; @@ -792,7 +792,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data) logic.data = data->data; packet.type = SR_DF_LOGIC; packet.payload = &logic; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); g_array_free(data, TRUE); data = NULL; break; @@ -808,7 +808,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data) devc->current_channel = devc->current_channel->next; hmo_request_data(sdi); } else if (++devc->num_frames == devc->frame_limit) { - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); } else { devc->current_channel = devc->enabled_channels; hmo_request_data(sdi); diff --git a/src/hardware/hantek-6xxx/api.c b/src/hardware/hantek-6xxx/api.c index 71e62c52..bdc10af4 100644 --- a/src/hardware/hantek-6xxx/api.c +++ b/src/hardware/hantek-6xxx/api.c @@ -78,7 +78,7 @@ SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info; static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount); -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); +static int dev_acquisition_stop(struct sr_dev_inst *sdi); static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof) { @@ -611,7 +611,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf, analog.data[data_offset++] = (ch2_bit * *(buf + i * 2 + 1) - ch2_center); } - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_free(analog.data); } @@ -699,7 +699,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) PRIu64 " <= %" PRIu64, devc->limit_samples, devc->samp_received); send_data(sdi, devc->sample_buf, devc->limit_samples); - sdi->driver->dev_acquisition_stop(sdi, NULL); + sdi->driver->dev_acquisition_stop(sdi); } else if (devc->limit_msec && (g_get_monotonic_time() - devc->aq_started) / 1000 >= devc->limit_msec) { sr_info("Requested time limit reached, stopping. %d <= %d", @@ -708,7 +708,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) send_data(sdi, devc->sample_buf, devc->samp_received); g_free(devc->sample_buf); devc->sample_buf = NULL; - sdi->driver->dev_acquisition_stop(sdi, NULL); + sdi->driver->dev_acquisition_stop(sdi); } else { read_channel(sdi, data_amount(sdi)); } @@ -770,7 +770,7 @@ static int handle_event(int fd, int revents, void *cb_data) return TRUE; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_dev_driver *di = sdi->driver; @@ -780,7 +780,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; if (configure_channels(sdi) != SR_OK) { sr_err("Failed to configure channels."); @@ -790,7 +789,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (hantek_6xxx_init(sdi) != SR_OK) return SR_ERR; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); devc->samp_received = 0; devc->dev_state = FLUSH; @@ -805,12 +804,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR; diff --git a/src/hardware/hantek-6xxx/protocol.h b/src/hardware/hantek-6xxx/protocol.h index c798a184..530bd67d 100644 --- a/src/hardware/hantek-6xxx/protocol.h +++ b/src/hardware/hantek-6xxx/protocol.h @@ -101,7 +101,6 @@ struct hantek_6xxx_profile { struct dev_context { const struct hantek_6xxx_profile *profile; - void *cb_data; GSList *enabled_channels; /* * We can't keep track of an FX2-based device after upgrading diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index 082d05b6..b88a902b 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -162,7 +162,7 @@ static const char *coupling[] = { SR_PRIV struct sr_dev_driver hantek_dso_driver_info; -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); +static int dev_acquisition_stop(struct sr_dev_inst *sdi); static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof) { @@ -755,7 +755,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf, analog.data[data_offset++] = ch2; } } - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_free(analog.data); } @@ -844,7 +844,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) /* Mark the end of this frame. */ packet.type = SR_DF_FRAME_END; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); if (devc->limit_frames && ++devc->num_frames == devc->limit_frames) { /* Terminate session */ @@ -967,7 +967,7 @@ static int handle_event(int fd, int revents, void *cb_data) return TRUE; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_dev_driver *di = sdi->driver; @@ -977,7 +977,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; if (configure_channels(sdi) != SR_OK) { sr_err("Failed to configure channels."); @@ -993,17 +992,15 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->dev_state = CAPTURE; usb_source_add(sdi->session, drvc->sr_ctx, TICK, handle_event, (void *)sdi); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR; diff --git a/src/hardware/hantek-dso/dso.h b/src/hardware/hantek-dso/dso.h index 44cced48..78e438bd 100644 --- a/src/hardware/hantek-dso/dso.h +++ b/src/hardware/hantek-dso/dso.h @@ -162,7 +162,6 @@ struct dso_profile { struct dev_context { const struct dso_profile *profile; - void *cb_data; uint64_t limit_frames; uint64_t num_frames; GSList *enabled_channels; diff --git a/src/hardware/hp-3457a/api.c b/src/hardware/hp-3457a/api.c index eae8195c..05a45e62 100644 --- a/src/hardware/hp-3457a/api.c +++ b/src/hardware/hp-3457a/api.c @@ -376,7 +376,7 @@ static void create_channel_index_list(GSList *channels, GArray **arr) * channel in the scan list to the A/D converter. This way, we do not need to * occupy the HP-IB bus to send channel select commands. */ -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { int ret; gboolean front_selected, rear_selected; @@ -387,8 +387,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) GArray *ch_list; GSList *channels; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -448,16 +446,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; devc = sdi->priv; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - g_slist_free(devc->active_channels); return SR_OK; diff --git a/src/hardware/hp-3457a/protocol.c b/src/hardware/hp-3457a/protocol.c index d9aa8338..bf673fde 100644 --- a/src/hardware/hp-3457a/protocol.c +++ b/src/hardware/hp-3457a/protocol.c @@ -388,7 +388,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data) struct sr_scpi_dev_inst *scpi; struct dev_context *devc; struct channel_context *chanc; - struct sr_dev_inst *sdi = cb_data; + struct sr_dev_inst *sdi; (void)fd; (void)revents; @@ -435,7 +435,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data) ret = sr_scpi_get_double(scpi, NULL, &devc->last_channel_sync); if (ret != SR_OK) { sr_err("Cannot check channel synchronization."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return FALSE; } devc->acq_state = ACQ_GOT_CHANNEL_SYNC; @@ -456,7 +456,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data) sr_err("Expected channel %u, but device says %u", chanc->index, (unsigned int)devc->last_channel_sync); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return FALSE; } /* All is good. Back to business. */ @@ -464,7 +464,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data) } if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) { - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return FALSE; } diff --git a/src/hardware/hung-chang-dso-2100/api.c b/src/hardware/hung-chang-dso-2100/api.c index 9f2d56a0..fecd593c 100644 --- a/src/hardware/hung-chang-dso-2100/api.c +++ b/src/hardware/hung-chang-dso-2100/api.c @@ -686,7 +686,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; int ret; @@ -702,7 +702,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->factor /= relays[(devc->cctl[devc->channel - 1] >> 4) & 0x03]; } devc->frame = 0; - devc->cb_data = cb_data; devc->state_known = TRUE; devc->step = 0; devc->adc2 = FALSE; @@ -712,7 +711,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (ret != SR_OK) return ret; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); sr_session_source_add(sdi->session, -1, 0, 8, hung_chang_dso_2100_poll, (void *)sdi); @@ -720,22 +719,21 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi, - void *cb_data) +SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi) { if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - std_session_send_df_end(cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); sr_session_source_remove(sdi->session, -1); hung_chang_dso_2100_move_to(sdi, 1); return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return hung_chang_dso_2100_dev_acquisition_stop(sdi, cb_data); + return hung_chang_dso_2100_dev_acquisition_stop(sdi); } SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = { diff --git a/src/hardware/hung-chang-dso-2100/protocol.c b/src/hardware/hung-chang-dso-2100/protocol.c index c1c8dacb..31f161e8 100644 --- a/src/hardware/hung-chang-dso-2100/protocol.c +++ b/src/hardware/hung-chang-dso-2100/protocol.c @@ -348,7 +348,7 @@ static void push_samples(const struct sr_dev_inst *sdi, uint8_t *buf, size_t num while (num--) data[num] = (buf[num] - 0x80) * factor; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf) @@ -393,7 +393,7 @@ static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf) }; push_samples(sdi, buf, 6); - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); buf += 6; num -= 6; } @@ -439,7 +439,7 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data) return FALSE; } - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); if (devc->channel) { while (read_subframe(sdi, buf)) { @@ -453,10 +453,10 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data) } packet.type = SR_DF_FRAME_END; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); if (++devc->frame >= devc->frame_limit) - hung_chang_dso_2100_dev_acquisition_stop(sdi, devc->cb_data); + hung_chang_dso_2100_dev_acquisition_stop(sdi); else hung_chang_dso_2100_move_to(sdi, 0x21); diff --git a/src/hardware/hung-chang-dso-2100/protocol.h b/src/hardware/hung-chang-dso-2100/protocol.h index 5636699a..f210b650 100644 --- a/src/hardware/hung-chang-dso-2100/protocol.h +++ b/src/hardware/hung-chang-dso-2100/protocol.h @@ -52,7 +52,6 @@ struct dev_context { gboolean adc2; /* Temporary state across callbacks */ - void *cb_data; float *samples; float factor; gboolean state_known; @@ -64,6 +63,6 @@ SR_PRIV void hung_chang_dso_2100_write_mbox(struct parport *port, uint8_t val); SR_PRIV uint8_t hung_chang_dso_2100_read_mbox(struct parport *port, float timeout); SR_PRIV int hung_chang_dso_2100_move_to(const struct sr_dev_inst *sdi, uint8_t target); SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data); -SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_data); +SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi); #endif diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c index 3b866d0a..f7480db3 100644 --- a/src/hardware/ikalogic-scanalogic2/api.c +++ b/src/hardware/ikalogic-scanalogic2/api.c @@ -383,7 +383,7 @@ 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 *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; struct drv_context *drvc; @@ -398,7 +398,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc = sdi->priv; drvc = di->context; - devc->cb_data = cb_data; devc->wait_data_ready_locked = TRUE; devc->stopping_in_progress = FALSE; devc->transfer_error = FALSE; @@ -466,17 +465,15 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) sr_dbg("Acquisition started successfully."); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); devc->next_state = STATE_SAMPLE; return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/ikalogic-scanalogic2/protocol.c b/src/hardware/ikalogic-scanalogic2/protocol.c index f8833806..4e8b64b7 100644 --- a/src/hardware/ikalogic-scanalogic2/protocol.c +++ b/src/hardware/ikalogic-scanalogic2/protocol.c @@ -27,14 +27,11 @@ extern uint64_t sl2_samplerates[NUM_SAMPLERATES]; static void stop_acquisition(struct sr_dev_inst *sdi) { struct drv_context *drvc = sdi->driver->context; - struct dev_context *devc; - - devc = sdi->priv; /* Remove USB file descriptors from polling. */ usb_source_remove(sdi->session, drvc->sr_ctx); - std_session_send_df_end(devc->cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); sdi->status = SR_ST_ACTIVE; } @@ -42,14 +39,11 @@ static void stop_acquisition(struct sr_dev_inst *sdi) static void abort_acquisition(struct sr_dev_inst *sdi) { struct drv_context *drvc = sdi->driver->context; - struct dev_context *devc; - - devc = sdi->priv; /* Remove USB file descriptors from polling. */ usb_source_remove(sdi->session, drvc->sr_ctx); - std_session_send_df_end(devc->cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); sdi->driver->dev_close(sdi); } @@ -134,7 +128,7 @@ static void process_sample_data(const struct sr_dev_inst *sdi) if (devc->trigger_type != TRIGGER_TYPE_NONE && devc->pre_trigger_samples == 0) { packet.type = SR_DF_TRIGGER; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } } @@ -172,10 +166,10 @@ static void process_sample_data(const struct sr_dev_inst *sdi) logic.length = n; logic.unitsize = 1; logic.data = buffer; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); packet.type = SR_DF_TRIGGER; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); n = 0; } @@ -188,7 +182,7 @@ static void process_sample_data(const struct sr_dev_inst *sdi) logic.length = n; logic.unitsize = 1; logic.data = buffer; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } } diff --git a/src/hardware/ikalogic-scanalogic2/protocol.h b/src/hardware/ikalogic-scanalogic2/protocol.h index 66a5cecf..60793375 100644 --- a/src/hardware/ikalogic-scanalogic2/protocol.h +++ b/src/hardware/ikalogic-scanalogic2/protocol.h @@ -147,8 +147,6 @@ struct dev_context { /* Time that the trigger will be delayed in milliseconds. */ uint16_t after_trigger_delay; - void *cb_data; - /* Array to provide an index based access to all channels. */ const struct sr_channel *channels[NUM_CHANNELS]; diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index c445b993..ec649d41 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -46,7 +46,7 @@ static const uint64_t samplerates[1] = { SR_MHZ(100) }; SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info; -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); +static int dev_acquisition_stop(struct sr_dev_inst *sdi); static void clear_helper(void *priv) { @@ -350,7 +350,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { int ret; struct dev_context *devc; @@ -365,8 +365,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* TODO: Configure channels later (thresholds etc.). */ - devc->cb_data = cb_data; - /* Properly reset internal variables before every new acquisition. */ devc->compressed_bytes_ignored = 0; devc->samples_sent = 0; @@ -386,10 +384,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - sr_dbg("Stopping acquisition."); sr_session_source_remove(sdi->session, -1); std_session_send_df_end(sdi, LOG_PREFIX); diff --git a/src/hardware/ikalogic-scanaplus/protocol.c b/src/hardware/ikalogic-scanaplus/protocol.c index 0b81ebde..9e9b0ea5 100644 --- a/src/hardware/ikalogic-scanaplus/protocol.c +++ b/src/hardware/ikalogic-scanaplus/protocol.c @@ -107,10 +107,13 @@ static void scanaplus_uncompress_block(struct dev_context *devc, } } -static void send_samples(struct dev_context *devc, uint64_t samples_to_send) +static void send_samples(const struct sr_dev_inst *sdi, uint64_t samples_to_send) { struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; + struct dev_context *devc; + + devc = sdi->priv; sr_spew("Sending %" PRIu64 " samples.", samples_to_send); @@ -119,7 +122,7 @@ static void send_samples(struct dev_context *devc, uint64_t samples_to_send) logic.length = samples_to_send * 2; logic.unitsize = 2; /* We need 2 bytes for 9 channels. */ logic.data = devc->sample_buf; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->samples_sent += samples_to_send; devc->bytes_received -= samples_to_send * 2; @@ -317,7 +320,7 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data) if (bytes_read < 0) { sr_err("Failed to read FTDI data (%d): %s.", bytes_read, ftdi_get_error_string(devc->ftdic)); - sdi->driver->dev_acquisition_stop(sdi, sdi); + sdi->driver->dev_acquisition_stop(sdi); return FALSE; } if (bytes_read == 0) { @@ -354,17 +357,17 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data) max = (SR_MHZ(100) / 1000) * devc->limit_msec; if (devc->limit_samples && (n >= devc->limit_samples)) { - send_samples(devc, devc->limit_samples - devc->samples_sent); + send_samples(sdi, devc->limit_samples - devc->samples_sent); sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } else if (devc->limit_msec && (n >= max)) { - send_samples(devc, max - devc->samples_sent); + send_samples(sdi, max - devc->samples_sent); sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } else { - send_samples(devc, devc->bytes_received / 2); + send_samples(sdi, devc->bytes_received / 2); } return TRUE; diff --git a/src/hardware/ikalogic-scanaplus/protocol.h b/src/hardware/ikalogic-scanaplus/protocol.h index cdd684d0..705c2bd0 100644 --- a/src/hardware/ikalogic-scanaplus/protocol.h +++ b/src/hardware/ikalogic-scanaplus/protocol.h @@ -43,8 +43,6 @@ struct dev_context { /** The current sampling limit (in number of samples). */ uint64_t limit_samples; - void *cb_data; - uint8_t *compressed_buf; uint64_t compressed_bytes_ignored; uint8_t *sample_buf; diff --git a/src/hardware/kecheng-kc-330b/api.c b/src/hardware/kecheng-kc-330b/api.c index df11489d..1214fadb 100644 --- a/src/hardware/kecheng-kc-330b/api.c +++ b/src/hardware/kecheng-kc-330b/api.c @@ -413,7 +413,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; struct drv_context *drvc; @@ -434,10 +434,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc = sdi->priv; usb = sdi->conn; - devc->cb_data = cb_data; devc->num_samples = 0; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); if (devc->data_source == DATA_SOURCE_LIVE) { /* Force configuration. */ @@ -460,7 +459,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->stored_samples = (buf[7] << 8) | buf[8]; if (devc->stored_samples == 0) { /* Notify frontend of empty log by sending start/end packets. */ - std_session_send_df_end(cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); return SR_OK; } @@ -475,7 +474,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) packet.type = SR_DF_META; packet.payload = &meta; meta.config = g_slist_append(NULL, src); - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_free(src); } @@ -522,12 +521,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/kecheng-kc-330b/protocol.c b/src/hardware/kecheng-kc-330b/protocol.c index bcc68469..e1c8da17 100644 --- a/src/hardware/kecheng-kc-330b/protocol.c +++ b/src/hardware/kecheng-kc-330b/protocol.c @@ -53,7 +53,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data) if (sdi->status == SR_ST_STOPPING) { libusb_free_transfer(devc->xfer); usb_source_remove(sdi->session, drvc->sr_ctx); - std_session_send_df_end(cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); sdi->status = SR_ST_ACTIVE; return TRUE; } @@ -69,8 +69,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data) if (ret != 0 || len != 1) { sr_dbg("Failed to request new acquisition: %s", libusb_error_name(ret)); - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } libusb_submit_transfer(devc->xfer); @@ -91,8 +90,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data) if (ret != 0 || len != 4) { sr_dbg("Failed to request next chunk: %s", libusb_error_name(ret)); - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } libusb_submit_transfer(devc->xfer); @@ -119,8 +117,7 @@ static void send_data(const struct sr_dev_inst *sdi, void *buf, unsigned int buf analog.data = buf; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); - + sr_session_send(sdi, &packet); } SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer *transfer) @@ -137,8 +134,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer switch (transfer->status) { case LIBUSB_TRANSFER_NO_DEVICE: /* USB device was unplugged. */ - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop(sdi); return; case LIBUSB_TRANSFER_COMPLETED: case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */ @@ -159,8 +155,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer send_data(sdi, fvalue, 1); devc->num_samples++; if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop(sdi); } else { /* let USB event handler fire off another * request when the time is right. */ @@ -180,8 +175,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer send_data(sdi, fvalue, 1); devc->num_samples += num_samples; if (devc->num_samples >= devc->stored_samples) { - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop(sdi); } else { /* let USB event handler fire off another * request when the time is right. */ diff --git a/src/hardware/kecheng-kc-330b/protocol.h b/src/hardware/kecheng-kc-330b/protocol.h index a718bdba..07597c6b 100644 --- a/src/hardware/kecheng-kc-330b/protocol.h +++ b/src/hardware/kecheng-kc-330b/protocol.h @@ -81,7 +81,6 @@ struct dev_context { gboolean config_dirty; uint64_t num_samples; uint64_t stored_samples; - void *cb_data; struct libusb_transfer *xfer; unsigned char buf[128]; diff --git a/src/hardware/kern-scale/api.c b/src/hardware/kern-scale/api.c index b5e5c280..03a68d8a 100644 --- a/src/hardware/kern-scale/api.c +++ b/src/hardware/kern-scale/api.c @@ -183,7 +183,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -192,7 +192,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; serial = sdi->conn; sr_spew("Set O1 mode (continuous values, stable and unstable ones)."); @@ -203,7 +202,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->num_samples = 0; devc->starttime = g_get_monotonic_time(); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 50ms, or whenever some data comes in. */ serial_source_add(sdi->session, serial, G_IO_IN, 50, @@ -212,9 +211,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/kern-scale/protocol.c b/src/hardware/kern-scale/protocol.c index 8845ae39..95374444 100644 --- a/src/hardware/kern-scale/protocol.c +++ b/src/hardware/kern-scale/protocol.c @@ -53,7 +53,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, /* Got a measurement. */ packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; } } @@ -124,7 +124,7 @@ SR_PRIV int kern_scale_receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -132,7 +132,7 @@ SR_PRIV int kern_scale_receive_data(int fd, int revents, void *cb_data) time = (g_get_monotonic_time() - devc->starttime) / 1000; if (time > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/kern-scale/protocol.h b/src/hardware/kern-scale/protocol.h index fce47003..fe8ae8db 100644 --- a/src/hardware/kern-scale/protocol.h +++ b/src/hardware/kern-scale/protocol.h @@ -55,9 +55,6 @@ struct dev_context { /** The time limit (in milliseconds). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c index d9d3a9ce..42dd581a 100644 --- a/src/hardware/korad-kaxxxxp/api.c +++ b/src/hardware/korad-kaxxxxp/api.c @@ -381,7 +381,7 @@ static int config_list(uint32_t key, GVariant **data, return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -390,9 +390,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); devc->starttime = g_get_monotonic_time(); devc->num_samples = 0; @@ -406,12 +405,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +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, cb_data, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/korad-kaxxxxp/protocol.c b/src/hardware/korad-kaxxxxp/protocol.c index 60c45455..709805a9 100644 --- a/src/hardware/korad-kaxxxxp/protocol.c +++ b/src/hardware/korad-kaxxxxp/protocol.c @@ -378,7 +378,7 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -386,7 +386,7 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data) t = (g_get_monotonic_time() - devc->starttime) / 1000; if (t > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/korad-kaxxxxp/protocol.h b/src/hardware/korad-kaxxxxp/protocol.h index 77c4eb6f..307424a0 100644 --- a/src/hardware/korad-kaxxxxp/protocol.h +++ b/src/hardware/korad-kaxxxxp/protocol.h @@ -83,8 +83,6 @@ struct dev_context { int64_t req_sent_at; gboolean reply_pending; - void *cb_data; - /* Operational state */ float current; /**< Last current value [A] read from device. */ float current_max; /**< Output current set. */ diff --git a/src/hardware/lascar-el-usb/api.c b/src/hardware/lascar-el-usb/api.c index 40670cec..d2ed3033 100644 --- a/src/hardware/lascar-el-usb/api.c +++ b/src/hardware/lascar-el-usb/api.c @@ -323,7 +323,7 @@ static int lascar_proc_config(const struct sr_dev_inst *sdi) return ret; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; struct sr_datafeed_packet packet; @@ -349,26 +349,25 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) drvc = di->context; devc = sdi->priv; usb = sdi->conn; - devc->cb_data = cb_data; if (lascar_proc_config(sdi) != SR_OK) return SR_ERR; sr_dbg("Starting log retrieval."); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); interval = (devc->config[0x1c] | (devc->config[0x1d] << 8)) * 1000; packet.type = SR_DF_META; packet.payload = &meta; src = sr_config_new(SR_CONF_SAMPLE_INTERVAL, g_variant_new_uint64(interval)); meta.config = g_slist_append(NULL, src); - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_free(src); if (devc->logged_samples == 0) { /* This ensures the frontend knows the session is done. */ - std_session_send_df_end(devc->cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); return SR_OK; } @@ -434,7 +433,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) buf = g_malloc(4096); libusb_fill_bulk_transfer(xfer_in, usb->devhdl, LASCAR_EP_IN, - buf, 4096, lascar_el_usb_receive_transfer, cb_data, 100); + buf, 4096, lascar_el_usb_receive_transfer, + (struct sr_dev_inst *)sdi, 100); if ((ret = libusb_submit_transfer(xfer_in) != 0)) { sr_err("Unable to submit transfer: %s.", libusb_error_name(ret)); libusb_free_transfer(xfer_in); @@ -445,10 +445,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; - (void)cb_data; if (!di->context) { sr_err("Driver was not initialized."); diff --git a/src/hardware/lascar-el-usb/protocol.c b/src/hardware/lascar-el-usb/protocol.c index 9fd9b696..e4fae68f 100644 --- a/src/hardware/lascar-el-usb/protocol.c +++ b/src/hardware/lascar-el-usb/protocol.c @@ -430,7 +430,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf, else analog.unit = SR_UNIT_CELSIUS; analog.data = temp; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); } @@ -440,7 +440,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf, analog.mq = SR_MQ_RELATIVE_HUMIDITY; analog.unit = SR_UNIT_PERCENTAGE; analog.data = rh; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); } @@ -463,7 +463,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf, if (analog.data[i] < 0.0) analog.data[i] = 0.0; } - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_free(analog.data); break; default: @@ -487,7 +487,7 @@ SR_PRIV int lascar_el_usb_handle_events(int fd, int revents, void *cb_data) if (sdi->status == SR_ST_STOPPING) { usb_source_remove(sdi->session, drvc->sr_ctx); - std_session_send_df_end(cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); } memset(&tv, 0, sizeof(struct timeval)); @@ -511,7 +511,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer * switch (transfer->status) { case LIBUSB_TRANSFER_NO_DEVICE: /* USB device was unplugged. */ - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); return; case LIBUSB_TRANSFER_COMPLETED: case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */ @@ -530,7 +530,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer * devc->rcvd_bytes, devc->log_size, devc->rcvd_samples, devc->logged_samples); if (devc->rcvd_bytes >= devc->log_size) - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); } if (sdi->status == SR_ST_ACTIVE) { @@ -540,7 +540,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer * libusb_error_name(ret)); g_free(transfer->buffer); libusb_free_transfer(transfer); - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); } } else { /* This was the last transfer we're going to receive, so diff --git a/src/hardware/lascar-el-usb/protocol.h b/src/hardware/lascar-el-usb/protocol.h index 482c4a97..c4eec74b 100644 --- a/src/hardware/lascar-el-usb/protocol.h +++ b/src/hardware/lascar-el-usb/protocol.h @@ -41,7 +41,6 @@ /** Private, per-device-instance driver context. */ struct dev_context { - void *cb_data; const struct elusb_profile *profile; /* Generic EL-USB */ unsigned char config[MAX_CONFIGBLOCK_SIZE]; @@ -80,6 +79,6 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer * SR_PRIV int lascar_start_logging(const struct sr_dev_inst *sdi); SR_PRIV int lascar_stop_logging(const struct sr_dev_inst *sdi); SR_PRIV int lascar_is_logging(const struct sr_dev_inst *sdi); -SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); +SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi); #endif diff --git a/src/hardware/lecroy-logicstudio/api.c b/src/hardware/lecroy-logicstudio/api.c index 53e7b017..b6eff9dd 100644 --- a/src/hardware/lecroy-logicstudio/api.c +++ b/src/hardware/lecroy-logicstudio/api.c @@ -498,7 +498,7 @@ static int receive_usb_data(int fd, int revents, void *cb_data) (void)fd; (void)revents; - drvc = (struct drv_context *) cb_data; + drvc = (struct drv_context *)cb_data; tv.tv_sec = 0; tv.tv_usec = 0; @@ -509,7 +509,7 @@ static int receive_usb_data(int fd, int revents, void *cb_data) return TRUE; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct drv_context *drvc; int ret; @@ -522,16 +522,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if ((ret = lls_start_acquisition(sdi)) < 0) return ret; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); return usb_source_add(sdi->session, drvc->sr_ctx, 100, receive_usb_data, drvc); } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index 4fcc87a0..e0791acc 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -391,7 +391,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; int ret = SR_ERR; @@ -446,22 +446,20 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Reset trigger state. */ devc->trigger_state = 0x00; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Our first channel is analog, the other 8 are of type 'logic'. */ /* TODO. */ serial_source_add(sdi->session, devc->serial, G_IO_IN, -1, - mso_receive_data, cb_data); + mso_receive_data, sdi); return SR_OK; } /* This stops acquisition on ALL devices, ignoring dev_index. */ -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - stop_acquisition(sdi); return SR_OK; diff --git a/src/hardware/link-mso19/protocol.c b/src/hardware/link-mso19/protocol.c index 0c28585e..dbc8f79c 100644 --- a/src/hardware/link-mso19/protocol.c +++ b/src/hardware/link-mso19/protocol.c @@ -416,13 +416,13 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data) logic.length = 1024; logic.unitsize = 1; logic.data = logic_out; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples += 1024; if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi, sdi); } return TRUE; diff --git a/src/hardware/link-mso19/protocol.h b/src/hardware/link-mso19/protocol.h index e32f39e9..4c8a66b2 100644 --- a/src/hardware/link-mso19/protocol.h +++ b/src/hardware/link-mso19/protocol.h @@ -115,7 +115,6 @@ struct dev_context { double dso_trigger_voltage; uint16_t dso_trigger_width; struct mso_prototrig protocol_trigger; - void *cb_data; uint16_t buffer_n; char buffer[4096]; }; diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c index ad425c16..125febbe 100644 --- a/src/hardware/manson-hcs-3xxx/api.c +++ b/src/hardware/manson-hcs-3xxx/api.c @@ -387,7 +387,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -396,9 +396,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); devc->starttime = g_get_monotonic_time(); devc->num_samples = 0; @@ -413,9 +412,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/manson-hcs-3xxx/protocol.c b/src/hardware/manson-hcs-3xxx/protocol.c index 657ae318..5fa53d29 100644 --- a/src/hardware/manson-hcs-3xxx/protocol.c +++ b/src/hardware/manson-hcs-3xxx/protocol.c @@ -227,7 +227,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -235,7 +235,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data) t = (g_get_monotonic_time() - devc->starttime) / 1000; if (t > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/manson-hcs-3xxx/protocol.h b/src/hardware/manson-hcs-3xxx/protocol.h index 8e614ce2..ee9e0cb2 100644 --- a/src/hardware/manson-hcs-3xxx/protocol.h +++ b/src/hardware/manson-hcs-3xxx/protocol.h @@ -75,8 +75,6 @@ struct dev_context { int64_t req_sent_at; gboolean reply_pending; - void *cb_data; - float current; /**< Last current value [A] read from device. */ float current_max; /**< Output current set. */ float current_max_device;/**< Device-provided maximum output current. */ diff --git a/src/hardware/maynuo-m97/api.c b/src/hardware/maynuo-m97/api.c index 4b92446e..ffc5b8f0 100644 --- a/src/hardware/maynuo-m97/api.c +++ b/src/hardware/maynuo-m97/api.c @@ -453,14 +453,12 @@ 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 *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_modbus_dev_inst *modbus; int ret; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -479,12 +477,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return maynuo_m97_capture_start(sdi); } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct sr_modbus_dev_inst *modbus; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/maynuo-m97/protocol.c b/src/hardware/maynuo-m97/protocol.c index 085d379f..57f93b14 100644 --- a/src/hardware/maynuo-m97/protocol.c +++ b/src/hardware/maynuo-m97/protocol.c @@ -178,7 +178,7 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data) devc->expecting_registers = 0; if (sr_modbus_read_holding_registers(modbus, -1, 4, registers) == SR_OK) { packet.type = SR_DF_FRAME_BEGIN; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); maynuo_m97_session_send_value(sdi, sdi->channels->data, RBFL(registers + 0), @@ -188,13 +188,13 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data) SR_MQ_CURRENT, SR_UNIT_AMPERE); packet.type = SR_DF_FRAME_END; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; } if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -202,7 +202,7 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data) t = (g_get_monotonic_time() - devc->starttime) / 1000; if (t > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/mic-985xx/api.c b/src/hardware/mic-985xx/api.c index fcb0db46..aafb08a9 100644 --- a/src/hardware/mic-985xx/api.c +++ b/src/hardware/mic-985xx/api.c @@ -212,8 +212,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data, int idx) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -222,11 +221,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; devc->num_samples = 0; devc->starttime = g_get_monotonic_time(); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; @@ -236,9 +234,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } @@ -263,8 +261,8 @@ static int config_list_##X(uint32_t key, GVariant **data, \ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { \ return config_list(key, data, sdi, cg, X); } #define HW_DEV_ACQUISITION_START(X) \ -static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ -void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } +static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \ +) { return dev_acquisition_start(sdi, X); } /* Driver structs and API function wrappers */ #define DRV(ID, ID_UPPER, NAME, LONGNAME) \ diff --git a/src/hardware/mic-985xx/protocol.c b/src/hardware/mic-985xx/protocol.c index 4ee11b70..151b7c83 100644 --- a/src/hardware/mic-985xx/protocol.c +++ b/src/hardware/mic-985xx/protocol.c @@ -127,7 +127,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx) meaning.mq = SR_MQ_TEMPERATURE; meaning.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */ analog.data = &temperature; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(l); /* Humidity. */ @@ -138,7 +138,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx) meaning.mq = SR_MQ_RELATIVE_HUMIDITY; meaning.unit = SR_UNIT_PERCENTAGE; analog.data = &humidity; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(l); } @@ -213,7 +213,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data) if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -221,7 +221,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data) t = (g_get_monotonic_time() - devc->starttime) / 1000; if (t > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/mic-985xx/protocol.h b/src/hardware/mic-985xx/protocol.h index f0e31a61..d522c0a4 100644 --- a/src/hardware/mic-985xx/protocol.h +++ b/src/hardware/mic-985xx/protocol.h @@ -60,9 +60,6 @@ struct dev_context { /** The current sampling limit (in ms). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c index 0ecfcb09..bbbdb660 100644 --- a/src/hardware/motech-lps-30x/api.c +++ b/src/hardware/motech-lps-30x/api.c @@ -796,7 +796,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -811,7 +811,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) serial = sdi->conn; serial_source_add(sdi->session, serial, G_IO_IN, 50, motech_lps_30x_receive_data, (void *)sdi); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Start timer, if required. */ if (devc->limit_msec) @@ -823,7 +823,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -831,7 +831,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) if (sdi && (devc = sdi->priv) && devc->limit_msec) g_timer_stop(devc->elapsed_msec); - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/motech-lps-30x/protocol.c b/src/hardware/motech-lps-30x/protocol.c index 4b9da802..03e9cdd5 100644 --- a/src/hardware/motech-lps-30x/protocol.c +++ b/src/hardware/motech-lps-30x/protocol.c @@ -181,12 +181,12 @@ SR_PRIV int motech_lps_30x_receive_data(int fd, int revents, void *cb_data) /* If number of samples or time limit reached, stop acquisition. */ if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); if (devc->limit_msec) { elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL); if ((elapsed_s * 1000) >= devc->limit_msec) - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); } /* Only request the next packet if required. */ diff --git a/src/hardware/norma-dmm/api.c b/src/hardware/norma-dmm/api.c index 3e6eab78..04775a64 100644 --- a/src/hardware/norma-dmm/api.c +++ b/src/hardware/norma-dmm/api.c @@ -249,7 +249,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -258,9 +258,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Start timer, if required. */ if (devc->limit_msec) @@ -274,7 +273,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -282,7 +281,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) if (sdi && (devc = sdi->priv) && devc->limit_msec) g_timer_stop(devc->elapsed_msec); - return std_serial_dev_acquisition_stop(sdi, cb_data, dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/norma-dmm/protocol.c b/src/hardware/norma-dmm/protocol.c index 4dc717c9..60bae0b3 100644 --- a/src/hardware/norma-dmm/protocol.c +++ b/src/hardware/norma-dmm/protocol.c @@ -366,7 +366,7 @@ static void nma_process_line(const struct sr_dev_inst *sdi) memset(&packet, 0, sizeof(struct sr_datafeed_packet)); packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); /* Finish processing. */ devc->num_samples++; @@ -414,14 +414,14 @@ SR_PRIV int norma_dmm_receive_data(int fd, int revents, void *cb_data) /* If number of samples or time limit reached, stop acquisition. */ terminating = FALSE; if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) { - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); terminating = TRUE; } if (devc->limit_msec) { elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL); if ((elapsed_s * 1000) >= devc->limit_msec) { - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); terminating = TRUE; } } diff --git a/src/hardware/norma-dmm/protocol.h b/src/hardware/norma-dmm/protocol.h index 7c52b47f..082e736a 100644 --- a/src/hardware/norma-dmm/protocol.h +++ b/src/hardware/norma-dmm/protocol.h @@ -64,9 +64,6 @@ struct dev_context { uint64_t limit_samples; /**< Target number of samples */ uint64_t limit_msec; /**< Target sampling time */ - /* Opaque pointer passed in by frontend. */ - void *cb_data; - /* Operational state */ int last_req; /**< Last request. */ int64_t req_sent_at; /**< Request sent. */ diff --git a/src/hardware/openbench-logic-sniffer/api.c b/src/hardware/openbench-logic-sniffer/api.c index af1ce784..cb687568 100644 --- a/src/hardware/openbench-logic-sniffer/api.c +++ b/src/hardware/openbench-logic-sniffer/api.c @@ -463,7 +463,7 @@ static int set_trigger(const struct sr_dev_inst *sdi, int stage) return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -569,21 +569,19 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0; memset(devc->sample, 0, 4); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* If the device stops sending for longer than it takes to send a byte, * that means it's finished. But wait at least 100 ms to be safe. */ serial_source_add(sdi->session, serial, G_IO_IN, 100, - ols_receive_data, cb_data); + ols_receive_data, (struct sr_dev_inst *)sdi); return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - abort_acquisition(sdi); return SR_OK; diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index 7f274258..15f1b3c0 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -472,12 +472,12 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } /* Send the trigger. */ packet.type = SR_DF_TRIGGER; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); /* Send post-trigger samples. */ packet.type = SR_DF_LOGIC; @@ -486,7 +486,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + devc->trigger_at * 4 + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } else { /* no trigger was used */ packet.type = SR_DF_LOGIC; @@ -495,7 +495,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } g_free(devc->raw_sample_buf); diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index 865c3bf6..c9a14931 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -535,7 +535,7 @@ static int disable_trigger(const struct sr_dev_inst *sdi, int stage) return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; uint32_t samplecount, readcount, delaycount; @@ -688,16 +688,16 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0; memset(devc->sample, 0, 4); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Hook up a dummy handler to receive data from the device. */ sr_session_source_add(sdi->session, -1, 0, 10, p_ols_receive_data, - cb_data); + (struct sr_dev_inst *)sdi); return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -712,7 +712,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) sr_session_source_remove(sdi->session, -1); - std_session_send_df_end(cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); return SR_OK; } diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index 17fe031d..d49d0e6a 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -427,7 +427,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) if (bytes_read < 0) { sr_err("Failed to read FTDI data (%d): %s.", bytes_read, ftdi_get_error_string(devc->ftdic)); - sdi->driver->dev_acquisition_stop(sdi, sdi); + sdi->driver->dev_acquisition_stop(sdi); return FALSE; } if (bytes_read == 0) { @@ -648,12 +648,12 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } /* Send the trigger. */ packet.type = SR_DF_TRIGGER; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); /* Send post-trigger samples. */ packet.type = SR_DF_LOGIC; @@ -662,7 +662,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + devc->trigger_at * 4 + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } else { /* no trigger was used */ packet.type = SR_DF_LOGIC; @@ -671,11 +671,11 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } g_free(devc->raw_sample_buf); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); } return TRUE; diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 259ca169..8c328277 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -921,7 +921,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_scpi_dev_inst *scpi; struct dev_context *devc; @@ -1031,7 +1031,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50, rigol_ds_receive, (void *)sdi); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); devc->channel_entry = devc->enabled_channels; @@ -1040,18 +1040,16 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Start of first frame. */ packet.type = SR_DF_FRAME_BEGIN; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_scpi_dev_inst *scpi; - (void)cb_data; - devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) { diff --git a/src/hardware/rigol-ds/protocol.c b/src/hardware/rigol-ds/protocol.c index 4a307178..b633977d 100644 --- a/src/hardware/rigol-ds/protocol.c +++ b/src/hardware/rigol-ds/protocol.c @@ -617,8 +617,8 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) if (len == -1) { sr_err("Read error, aborting capture."); packet.type = SR_DF_FRAME_END; - sr_session_send(cb_data, &packet); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sr_session_send(sdi, &packet); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } /* At slow timebases in live capture the DS2072 @@ -650,8 +650,8 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) if (len == -1) { sr_err("Read error, aborting capture."); packet.type = SR_DF_FRAME_END; - sr_session_send(cb_data, &packet); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sr_session_send(sdi, &packet); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -677,7 +677,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) analog.mqflags = 0; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); } else { logic.length = len; @@ -688,7 +688,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) logic.data = devc->buffer; packet.type = SR_DF_LOGIC; packet.payload = &logic; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } if (devc->num_block_read == devc->num_block_bytes) { @@ -707,8 +707,8 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) if (!sr_scpi_read_complete(scpi)) { sr_err("Read should have been completed"); packet.type = SR_DF_FRAME_END; - sr_session_send(cb_data, &packet); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sr_session_send(sdi, &packet); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } devc->num_block_read = 0; @@ -742,11 +742,11 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) } else { /* Done with this frame. */ packet.type = SR_DF_FRAME_END; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); if (++devc->num_frames == devc->limit_frames) { /* Last frame, stop capture. */ - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); } else { /* Get the next frame, starting with the first channel. */ devc->channel_entry = devc->enabled_channels; @@ -755,7 +755,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) /* Start of next frame. */ packet.type = SR_DF_FRAME_BEGIN; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } } diff --git a/src/hardware/rigol-ds/protocol.h b/src/hardware/rigol-ds/protocol.h index 5e5f01ba..a0859361 100644 --- a/src/hardware/rigol-ds/protocol.h +++ b/src/hardware/rigol-ds/protocol.h @@ -108,7 +108,6 @@ struct dev_context { /* Acquisition settings */ GSList *enabled_channels; uint64_t limit_frames; - void *cb_data; enum data_source data_source; uint64_t analog_frame_size; uint64_t digital_frame_size; diff --git a/src/hardware/saleae-logic16/api.c b/src/hardware/saleae-logic16/api.c index bf41b759..dbd85fb3 100644 --- a/src/hardware/saleae-logic16/api.c +++ b/src/hardware/saleae-logic16/api.c @@ -688,7 +688,7 @@ static int receive_data(int fd, int revents, void *cb_data) return TRUE; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; struct dev_context *devc; @@ -714,7 +714,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; } - devc->cb_data = cb_data; devc->sent_samples = 0; devc->empty_transfer_count = 0; devc->cur_channel = 0; @@ -789,7 +788,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) usb_source_add(sdi->session, devc->ctx, timeout, receive_data, (void *)sdi); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); if ((ret = logic16_start_acquisition(sdi)) != SR_OK) { abort_acquisition(devc); @@ -799,12 +798,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { int ret; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/saleae-logic16/protocol.c b/src/hardware/saleae-logic16/protocol.c index d75be36d..a14d0e08 100644 --- a/src/hardware/saleae-logic16/protocol.c +++ b/src/hardware/saleae-logic16/protocol.c @@ -933,7 +933,7 @@ SR_PRIV void LIBUSB_CALL logic16_receive_transfer(struct libusb_transfer *transf logic.length = new_samples * 2; logic.unitsize = 2; logic.data = devc->convbuffer; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->sent_samples += new_samples; } else { trigger_offset = soft_trigger_logic_check(devc->stl, @@ -949,7 +949,7 @@ SR_PRIV void LIBUSB_CALL logic16_receive_transfer(struct libusb_transfer *transf logic.length = num_samples * 2; logic.unitsize = 2; logic.data = devc->convbuffer + trigger_offset * 2; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->sent_samples += num_samples; devc->trigger_fired = TRUE; diff --git a/src/hardware/saleae-logic16/protocol.h b/src/hardware/saleae-logic16/protocol.h index 9f834164..9eead9a9 100644 --- a/src/hardware/saleae-logic16/protocol.h +++ b/src/hardware/saleae-logic16/protocol.h @@ -87,7 +87,6 @@ struct dev_context { struct soft_trigger_logic *stl; gboolean trigger_fired; - void *cb_data; unsigned int num_transfers; struct libusb_transfer **transfers; struct sr_context *ctx; diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 475cdca3..112bedc0 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -576,7 +576,7 @@ 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 *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_scpi_dev_inst *scpi; @@ -589,7 +589,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc = sdi->priv; scpi = sdi->conn; - devc->cb_data = cb_data; if ((ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 10, scpi_pps_receive_data, (void *)sdi)) != SR_OK) @@ -616,13 +615,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct sr_scpi_dev_inst *scpi; float f; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/scpi-pps/protocol.h b/src/hardware/scpi-pps/protocol.h index f939b0d7..ba190513 100644 --- a/src/hardware/scpi-pps/protocol.h +++ b/src/hardware/scpi-pps/protocol.h @@ -139,9 +139,6 @@ struct dev_context { /* Model-specific information */ const struct scpi_pps *device; - /* Acquisition settings */ - void *cb_data; - /* Operational state */ gboolean beeper_was_set; struct channel_spec *channels; diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index f53381bf..eaf913f2 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -211,7 +211,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -220,7 +220,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->cb_data = cb_data; /* * Reset the number of samples to take. If we've already collected our @@ -230,7 +229,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->num_samples = 0; devc->starttime = g_get_monotonic_time(); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 50ms, or whenever some data comes in. */ serial = sdi->conn; @@ -240,9 +239,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/serial-dmm/protocol.c b/src/hardware/serial-dmm/protocol.c index 8e9b3979..1e343a2f 100644 --- a/src/hardware/serial-dmm/protocol.c +++ b/src/hardware/serial-dmm/protocol.c @@ -69,7 +69,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, /* Got a measurement. */ packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; } } @@ -186,7 +186,7 @@ int receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -194,7 +194,7 @@ int receive_data(int fd, int revents, void *cb_data) time = (g_get_monotonic_time() - devc->starttime) / 1000; if (time > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/serial-dmm/protocol.h b/src/hardware/serial-dmm/protocol.h index 3c2d88b8..da6742c3 100644 --- a/src/hardware/serial-dmm/protocol.h +++ b/src/hardware/serial-dmm/protocol.h @@ -64,9 +64,6 @@ struct dev_context { /** The time limit (in milliseconds). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index 7e619037..8ee85a62 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -767,10 +767,8 @@ static int config_list(uint32_t key, GVariant **data, * configured trigger conditions are met, or immediately if no triggers * are configured. */ -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -781,12 +779,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Request that a running capture operation be stopped. */ -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) diff --git a/src/hardware/teleinfo/api.c b/src/hardware/teleinfo/api.c index 1becb31e..1d8f91df 100644 --- a/src/hardware/teleinfo/api.c +++ b/src/hardware/teleinfo/api.c @@ -194,7 +194,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_serial_dev_inst *serial = sdi->conn; struct dev_context *devc; @@ -203,7 +203,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - devc->session_cb_data = cb_data; /* * Reset the number of samples to take. If we've already collected our @@ -213,7 +212,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->num_samples = 0; devc->start_time = g_get_monotonic_time(); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 50ms, or whenever some data comes in. */ serial_source_add(sdi->session, serial, G_IO_IN, 50, @@ -222,9 +221,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/teleinfo/protocol.c b/src/hardware/teleinfo/protocol.c index 21b695bd..fbbc044d 100644 --- a/src/hardware/teleinfo/protocol.c +++ b/src/hardware/teleinfo/protocol.c @@ -58,12 +58,10 @@ static struct sr_channel *teleinfo_find_channel(struct sr_dev_inst *sdi, static void teleinfo_send_value(struct sr_dev_inst *sdi, const char *channel_name, float value, int mq, int unit) { - struct dev_context *devc; struct sr_datafeed_packet packet; struct sr_datafeed_analog_old analog; struct sr_channel *ch; - devc = sdi->priv; ch = teleinfo_find_channel(sdi, channel_name); if (!ch || !ch->enabled) @@ -78,7 +76,7 @@ static void teleinfo_send_value(struct sr_dev_inst *sdi, const char *channel_nam packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->session_cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); } @@ -221,7 +219,7 @@ SR_PRIV int teleinfo_receive_data(int fd, int revents, void *cb_data) if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -229,7 +227,7 @@ SR_PRIV int teleinfo_receive_data(int fd, int revents, void *cb_data) time = (g_get_monotonic_time() - devc->start_time) / 1000; if (time > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/teleinfo/protocol.h b/src/hardware/teleinfo/protocol.h index 84a7546e..b4aa0fef 100644 --- a/src/hardware/teleinfo/protocol.h +++ b/src/hardware/teleinfo/protocol.h @@ -42,7 +42,6 @@ struct dev_context { /* Acquisition settings */ uint64_t limit_samples; /**< The sampling limit (in number of samples). */ uint64_t limit_msec; /**< The time limit (in milliseconds). */ - void *session_cb_data; /**< Opaque pointer passed in by the frontend. */ /* Operational state */ enum optarif optarif; /**< The device mode (which measures are reported) */ diff --git a/src/hardware/testo/api.c b/src/hardware/testo/api.c index 691ba8f5..c43c3c7e 100644 --- a/src/hardware/testo/api.c +++ b/src/hardware/testo/api.c @@ -24,7 +24,7 @@ #define SERIALCOMM "115200/8n1" SR_PRIV struct sr_dev_driver testo_driver_info; -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); +static int dev_acquisition_stop(struct sr_dev_inst *sdi); static const uint32_t scanopts[] = { SR_CONF_CONN, @@ -363,7 +363,7 @@ static void receive_data(struct sr_dev_inst *sdi, unsigned char *data, int len) devc->reply_size = 0; if (devc->limit_samples && devc->num_samples >= devc->limit_samples) - dev_acquisition_stop(sdi, devc->cb_data); + dev_acquisition_stop(sdi); else testo_request_packet(sdi); @@ -383,7 +383,7 @@ SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) { /* USB device was unplugged. */ - dev_acquisition_stop(sdi, devc->cb_data); + dev_acquisition_stop(sdi); } else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) { /* First two bytes in any transfer are FTDI status bytes. */ if (transfer->actual_length > 2) @@ -398,7 +398,7 @@ SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) libusb_error_name(ret)); g_free(transfer->buffer); libusb_free_transfer(transfer); - dev_acquisition_stop(sdi, devc->cb_data); + dev_acquisition_stop(sdi); } } else { /* This was the last transfer we're going to receive, so @@ -428,7 +428,7 @@ static int handle_events(int fd, int revents, void *cb_data) if (devc->limit_msec) { now = g_get_monotonic_time() / 1000; if (now > devc->end_time) - dev_acquisition_stop(sdi, devc->cb_data); + dev_acquisition_stop(sdi); } if (sdi->status == SR_ST_STOPPING) { @@ -444,7 +444,7 @@ static int handle_events(int fd, int revents, void *cb_data) return TRUE; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; struct drv_context *drvc; @@ -465,12 +465,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc = sdi->priv; usb = sdi->conn; - devc->cb_data = cb_data; devc->end_time = 0; devc->num_samples = 0; devc->reply_size = 0; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); usb_source_add(sdi->session, drvc->sr_ctx, 100, handle_events, (void *)sdi); @@ -497,10 +496,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; - (void)cb_data; if (!di->context) { sr_err("Driver was not initialized."); diff --git a/src/hardware/testo/protocol.c b/src/hardware/testo/protocol.c index be36023f..4a1af4c4 100644 --- a/src/hardware/testo/protocol.c +++ b/src/hardware/testo/protocol.c @@ -158,8 +158,7 @@ SR_PRIV int testo_request_packet(const struct sr_dev_inst *sdi) receive_transfer, (void *)sdi, 100); if ((ret = libusb_submit_transfer(devc->out_transfer) != 0)) { sr_err("Failed to request packet: %s.", libusb_error_name(ret)); - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi); return SR_ERR; } sr_dbg("Requested new packet."); diff --git a/src/hardware/testo/protocol.h b/src/hardware/testo/protocol.h index 06a29644..8cfc3511 100644 --- a/src/hardware/testo/protocol.h +++ b/src/hardware/testo/protocol.h @@ -59,7 +59,6 @@ struct dev_context { /* Acquisition settings */ uint64_t limit_msec; uint64_t limit_samples; - void *cb_data; /* Operational state */ gint64 end_time; diff --git a/src/hardware/tondaj-sl-814/api.c b/src/hardware/tondaj-sl-814/api.c index 979a8bea..e417d96f 100644 --- a/src/hardware/tondaj-sl-814/api.c +++ b/src/hardware/tondaj-sl-814/api.c @@ -161,18 +161,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { - struct dev_context *devc; struct sr_serial_dev_inst *serial; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - devc = sdi->priv; - devc->cb_data = cb_data; - - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 500ms, or whenever some data comes in. */ serial = sdi->conn; @@ -182,9 +178,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/hardware/tondaj-sl-814/protocol.c b/src/hardware/tondaj-sl-814/protocol.c index d09d19bf..d6f470d2 100644 --- a/src/hardware/tondaj-sl-814/protocol.c +++ b/src/hardware/tondaj-sl-814/protocol.c @@ -104,7 +104,7 @@ static void decode_packet(struct sr_dev_inst *sdi) analog.data = &floatval; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; } @@ -204,7 +204,7 @@ SR_PRIV int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data) /* Stop acquisition if we acquired enough samples. */ if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); } return TRUE; diff --git a/src/hardware/tondaj-sl-814/protocol.h b/src/hardware/tondaj-sl-814/protocol.h index 77c6ca08..27174a2f 100644 --- a/src/hardware/tondaj-sl-814/protocol.h +++ b/src/hardware/tondaj-sl-814/protocol.h @@ -35,9 +35,6 @@ struct dev_context { /** The current sampling limit (in ms). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index f3416c26..a77aebba 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -189,12 +189,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; devc = sdi->priv; - devc->cb_data = cb_data; devc->starttime = g_get_monotonic_time(); std_session_send_df_header(sdi, LOG_PREFIX); @@ -205,10 +204,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - (void)cb_data; - sr_dbg("Stopping acquisition."); std_session_send_df_end(sdi, LOG_PREFIX); sr_session_source_remove(sdi->session, -1); diff --git a/src/hardware/uni-t-dmm/protocol.c b/src/hardware/uni-t-dmm/protocol.c index 4bbe20d6..c417ea15 100644 --- a/src/hardware/uni-t-dmm/protocol.c +++ b/src/hardware/uni-t-dmm/protocol.c @@ -87,7 +87,7 @@ static void decode_packet(struct sr_dev_inst *sdi, const uint8_t *buf) analog.data = &floatval; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); /* Increase sample count. */ devc->num_samples++; @@ -288,14 +288,14 @@ SR_PRIV int uni_t_dmm_receive_data(int fd, int revents, void *cb_data) /* Abort acquisition if we acquired enough samples. */ if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { sr_info("Requested number of samples reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); } if (devc->limit_msec) { time_ms = (g_get_monotonic_time() - devc->starttime) / 1000; if (time_ms > (int64_t)devc->limit_msec) { sr_info("Requested time limit reached."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } } diff --git a/src/hardware/uni-t-dmm/protocol.h b/src/hardware/uni-t-dmm/protocol.h index f8fdbb5a..853809e3 100644 --- a/src/hardware/uni-t-dmm/protocol.h +++ b/src/hardware/uni-t-dmm/protocol.h @@ -54,9 +54,6 @@ struct dev_context { /** The current sampling limit (in ms). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index ea57ed03..fe752415 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -271,7 +271,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; struct drv_context *drvc; @@ -287,7 +287,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc = sdi->priv; usb = sdi->conn; - devc->cb_data = cb_data; devc->num_samples = 0; devc->packet_len = 0; @@ -302,7 +301,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; } - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); if (!(devc->xfer = libusb_alloc_transfer(0))) return SR_ERR; @@ -334,11 +333,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/uni-t-ut32x/protocol.c b/src/hardware/uni-t-ut32x/protocol.c index 14e70cf2..34fa14d4 100644 --- a/src/hardware/uni-t-ut32x/protocol.c +++ b/src/hardware/uni-t-ut32x/protocol.c @@ -130,7 +130,7 @@ static void process_packet(struct sr_dev_inst *sdi) analog.data = &temp; packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); g_slist_free(analog.channels); } } @@ -140,8 +140,7 @@ static void process_packet(struct sr_dev_inst *sdi) * memory slots come through as "----" measurements. */ devc->num_samples++; if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { - sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi, - devc->cb_data); + sdi->driver->dev_acquisition_stop(sdi); } } @@ -218,7 +217,7 @@ SR_PRIV int uni_t_ut32x_handle_events(int fd, int revents, void *cb_data) if (sdi->status == SR_ST_STOPPING) { usb_source_remove(sdi->session, drvc->sr_ctx); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Tell the device to stop sending USB packets. */ usb = sdi->conn; diff --git a/src/hardware/uni-t-ut32x/protocol.h b/src/hardware/uni-t-ut32x/protocol.h index 4010e179..a2bad330 100644 --- a/src/hardware/uni-t-ut32x/protocol.h +++ b/src/hardware/uni-t-ut32x/protocol.h @@ -58,7 +58,6 @@ struct dev_context { uint64_t num_samples; unsigned char buf[8]; struct libusb_transfer *xfer; - void *cb_data; /* Temporary state across callbacks */ unsigned char packet[32]; diff --git a/src/hardware/victor-dmm/api.c b/src/hardware/victor-dmm/api.c index f9435256..1bc03442 100644 --- a/src/hardware/victor-dmm/api.c +++ b/src/hardware/victor-dmm/api.c @@ -33,7 +33,7 @@ #define VICTOR_ENDPOINT (LIBUSB_ENDPOINT_IN | 1) SR_PRIV struct sr_dev_driver victor_dmm_driver_info; -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); +static int dev_acquisition_stop(struct sr_dev_inst *sdi); static const uint32_t drvopts[] = { SR_CONF_MULTIMETER, @@ -292,14 +292,14 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) devc = sdi->priv; if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) { /* USB device was unplugged. */ - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); } else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) { sr_dbg("Got %d-byte packet.", transfer->actual_length); if (transfer->actual_length == DMM_DATA_SIZE) { victor_dmm_receive_data(sdi, transfer->buffer); if (devc->limit_samples) { if (devc->num_samples >= devc->limit_samples) - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); } } } @@ -313,7 +313,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) libusb_error_name(ret)); g_free(transfer->buffer); libusb_free_transfer(transfer); - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); } } else { /* This was the last transfer we're going to receive, so @@ -343,7 +343,7 @@ static int handle_events(int fd, int revents, void *cb_data) if (devc->limit_msec) { now = g_get_monotonic_time() / 1000; if (now > devc->end_time) - dev_acquisition_stop(sdi, sdi); + dev_acquisition_stop(sdi); } if (sdi->status == SR_ST_STOPPING) { @@ -359,10 +359,9 @@ static int handle_events(int fd, int revents, void *cb_data) return TRUE; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; - struct dev_context *devc; struct drv_context *drvc = di->context; struct sr_usb_dev_inst *usb; struct libusb_transfer *transfer; @@ -377,11 +376,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; } - devc = sdi->priv; usb = sdi->conn; - devc->cb_data = cb_data; - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); usb_source_add(sdi->session, drvc->sr_ctx, 100, handle_events, (void *)sdi); @@ -394,7 +391,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) * handling above. */ libusb_fill_interrupt_transfer(transfer, usb->devhdl, VICTOR_ENDPOINT, buf, DMM_DATA_SIZE, receive_transfer, - cb_data, 100); + (struct sr_dev_inst *)sdi, 100); if ((ret = libusb_submit_transfer(transfer) != 0)) { sr_err("Unable to submit transfer: %s.", libusb_error_name(ret)); libusb_free_transfer(transfer); @@ -405,10 +402,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; - (void)cb_data; if (!di->context) { sr_err("Driver was not initialized."); diff --git a/src/hardware/victor-dmm/protocol.c b/src/hardware/victor-dmm/protocol.c index b0eb384a..c25ac52c 100644 --- a/src/hardware/victor-dmm/protocol.c +++ b/src/hardware/victor-dmm/protocol.c @@ -262,7 +262,7 @@ static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data) packet.type = SR_DF_ANALOG; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); devc->num_samples++; } diff --git a/src/hardware/victor-dmm/protocol.h b/src/hardware/victor-dmm/protocol.h index 38fd5241..1ee36267 100644 --- a/src/hardware/victor-dmm/protocol.h +++ b/src/hardware/victor-dmm/protocol.h @@ -36,9 +36,6 @@ struct dev_context { /** The current sampling limit (in ms). */ uint64_t limit_msec; - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The current number of already received samples. */ uint64_t num_samples; gint64 end_time; diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index 2a3d2e55..34801afe 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -621,7 +621,7 @@ static int dlm_check_channels(GSList *channels) return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { GSList *l; gboolean digital_added; @@ -629,8 +629,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) struct dev_context *devc; struct sr_scpi_dev_inst *scpi; - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -673,12 +671,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; - std_session_send_df_end(sdi, LOG_PREFIX); if (sdi->status != SR_ST_ACTIVE) diff --git a/src/hardware/yokogawa-dlm/protocol.c b/src/hardware/yokogawa-dlm/protocol.c index e63e6357..7d6c7e94 100644 --- a/src/hardware/yokogawa-dlm/protocol.c +++ b/src/hardware/yokogawa-dlm/protocol.c @@ -1166,7 +1166,7 @@ SR_PRIV int dlm_data_receive(int fd, int revents, void *cb_data) * As of now we only support importing the current acquisition * data so we're going to stop at this point. */ - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } else devc->current_channel = devc->current_channel->next; diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index ca3d5ad2..22ec33b5 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -512,7 +512,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_usb_dev_inst *usb; @@ -574,11 +574,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) sr_info("Ramsize trigger = 0x%x.", ramsize_trigger); sr_info("Memory size = 0x%x.", memory_size); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Check for empty capture */ if ((status & STATUS_READY) && !stop_address) { - std_session_send_df_end(cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); return SR_OK; } @@ -661,7 +661,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) logic.length = (trigger_offset - samples_read) * 4; logic.unitsize = 4; logic.data = buf + buf_offset; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); len -= logic.length; samples_read += logic.length / 4; buf_offset += logic.length; @@ -671,7 +671,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Send out trigger */ packet.type = SR_DF_TRIGGER; packet.payload = NULL; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } /* Send out data (or data after trigger) */ @@ -680,24 +680,24 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) logic.length = len; logic.unitsize = 4; logic.data = buf + buf_offset; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); samples_read += len / 4; } analyzer_read_stop(usb->devhdl); g_free(buf); - std_session_send_df_end(cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); return SR_OK; } /* TODO: This stops acquisition on ALL devices, ignoring dev_index. */ -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_usb_dev_inst *usb; - std_session_send_df_end(cb_data, LOG_PREFIX); + std_session_send_df_end(sdi, LOG_PREFIX); if (!(devc = sdi->priv)) { sr_err("%s: sdi->priv was NULL", __func__); diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c index cbe51179..ceffa411 100644 --- a/src/lcr/es51919.c +++ b/src/lcr/es51919.c @@ -415,9 +415,6 @@ static const char *const models[] = { /** Private, per-device-instance driver context. */ struct dev_context { - /** Opaque pointer passed in by the frontend. */ - void *cb_data; - /** The number of frames. */ struct dev_limit_counter frame_count; @@ -595,11 +592,7 @@ static gboolean packet_valid(const uint8_t *pkt) static int do_config_update(struct sr_dev_inst *sdi, uint32_t key, GVariant *var) { - struct dev_context *devc; - - devc = sdi->priv; - - return send_config_update_key(devc->cb_data, key, var); + return send_config_update_key(sdi, key, var); } static int send_freq_update(struct sr_dev_inst *sdi, unsigned int freq) @@ -654,14 +647,14 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt) if (analog.mq >= 0) { if (!frame) { packet.type = SR_DF_FRAME_BEGIN; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); frame = TRUE; } packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } g_slist_free(analog.channels); @@ -671,21 +664,21 @@ static void handle_packet(struct sr_dev_inst *sdi, const uint8_t *pkt) if (analog.mq >= 0) { if (!frame) { packet.type = SR_DF_FRAME_BEGIN; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); frame = TRUE; } packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); } g_slist_free(analog.channels); if (frame) { packet.type = SR_DF_FRAME_END; - sr_session_send(devc->cb_data, &packet); + sr_session_send(sdi, &packet); dev_limit_counter_inc(&devc->frame_count); } } @@ -729,7 +722,7 @@ static int receive_data(int fd, int revents, void *cb_data) if (dev_limit_counter_limit_reached(&devc->frame_count) || dev_time_limit_reached(&devc->time_count)) - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sdi->driver->dev_acquisition_stop(sdi); return TRUE; } @@ -910,8 +903,7 @@ SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data, return SR_OK; } -SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -922,12 +914,10 @@ SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi, if (!(devc = sdi->priv)) return SR_ERR_BUG; - devc->cb_data = cb_data; - dev_limit_counter_start(&devc->frame_count); dev_time_counter_start(&devc->time_count); - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Poll every 50ms, or whenever some data comes in. */ serial = sdi->conn; @@ -937,9 +927,8 @@ SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi, return SR_OK; } -SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi, - void *cb_data) +SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi) { - return std_serial_dev_acquisition_stop(sdi, cb_data, + return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close, sdi->conn, LOG_PREFIX); } diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 63234153..7c8c0eb2 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -1228,10 +1228,8 @@ SR_PRIV int es51919_serial_config_set(uint32_t key, GVariant *data, SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg); -SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data); -SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi, - void *cb_data); +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); /*--- hardware/dmm/ut372.c --------------------------------------------------*/ diff --git a/src/session.c b/src/session.c index 5a68c8df..23dc0c3a 100644 --- a/src/session.c +++ b/src/session.c @@ -365,8 +365,7 @@ SR_API int sr_session_dev_add(struct sr_session *session, sr_strerror(ret)); return ret; } - if ((ret = sdi->driver->dev_acquisition_start(sdi, - sdi)) != SR_OK) { + if ((ret = sdi->driver->dev_acquisition_start(sdi)) != SR_OK) { sr_err("Failed to start acquisition of device in " "running session (%s)", sr_strerror(ret)); return ret; @@ -813,7 +812,7 @@ SR_API int sr_session_start(struct sr_session *session) /* Have all devices start acquisition. */ for (l = session->devs; l; l = l->next) { sdi = l->data; - ret = sdi->driver->dev_acquisition_start(sdi, sdi); + ret = sdi->driver->dev_acquisition_start(sdi); if (ret != SR_OK) { sr_err("Could not start %s device %s acquisition.", sdi->driver->name, sdi->connection_id); @@ -828,7 +827,7 @@ SR_API int sr_session_start(struct sr_session *session) for (l = session->devs; l != lend; l = l->next) { sdi = l->data; if (sdi->driver->dev_acquisition_stop) - sdi->driver->dev_acquisition_stop(sdi, sdi); + sdi->driver->dev_acquisition_stop(sdi); } /* TODO: Handle delayed stops. Need to iterate the event * sources... */ @@ -912,7 +911,7 @@ static gboolean session_stop_sync(void *user_data) for (node = session->devs; node; node = node->next) { sdi = node->data; if (sdi->driver && sdi->driver->dev_acquisition_stop) - sdi->driver->dev_acquisition_stop(sdi, sdi); + sdi->driver->dev_acquisition_stop(sdi); } return G_SOURCE_REMOVE; diff --git a/src/session_driver.c b/src/session_driver.c index 3b801ffc..d56c22c2 100644 --- a/src/session_driver.c +++ b/src/session_driver.c @@ -336,15 +336,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct session_vdev *vdev; int ret; GSList *l; struct sr_channel *ch; - (void)cb_data; - vdev = sdi->priv; vdev->bytes_read = 0; vdev->cur_analog_channel = 0; @@ -375,11 +373,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct session_vdev *vdev; - (void)cb_data; vdev = sdi->priv; vdev->finished = TRUE;