]> sigrok.org Git - libsigrok.git/commitdiff
dev_acquisition_{start,stop}(): Drop duplicate 'cb_data' parameter.
authorUwe Hermann <redacted>
Sun, 27 Mar 2016 22:40:16 +0000 (00:40 +0200)
committerUwe Hermann <redacted>
Fri, 29 Apr 2016 17:20:53 +0000 (19:20 +0200)
These are always 'sdi', which is passed in already.

138 files changed:
include/libsigrok/libsigrok.h
src/hardware/agilent-dmm/agilent-dmm.h
src/hardware/agilent-dmm/api.c
src/hardware/agilent-dmm/sched.c
src/hardware/appa-55ii/api.c
src/hardware/appa-55ii/protocol.c
src/hardware/appa-55ii/protocol.h
src/hardware/arachnid-labs-re-load-pro/api.c
src/hardware/arachnid-labs-re-load-pro/protocol.c
src/hardware/asix-sigma/api.c
src/hardware/asix-sigma/protocol.c
src/hardware/asix-sigma/protocol.h
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/baylibre-acme/protocol.c
src/hardware/beaglelogic/api.c
src/hardware/beaglelogic/protocol.c
src/hardware/beaglelogic/protocol.h
src/hardware/brymen-bm86x/api.c
src/hardware/brymen-bm86x/protocol.c
src/hardware/brymen-dmm/api.c
src/hardware/brymen-dmm/protocol.c
src/hardware/brymen-dmm/protocol.h
src/hardware/cem-dt-885x/api.c
src/hardware/cem-dt-885x/protocol.c
src/hardware/cem-dt-885x/protocol.h
src/hardware/center-3xx/api.c
src/hardware/center-3xx/protocol.c
src/hardware/center-3xx/protocol.h
src/hardware/chronovu-la/api.c
src/hardware/chronovu-la/protocol.c
src/hardware/chronovu-la/protocol.h
src/hardware/colead-slm/api.c
src/hardware/colead-slm/protocol.c
src/hardware/colead-slm/protocol.h
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/demo.c
src/hardware/fluke-dmm/api.c
src/hardware/fluke-dmm/fluke-dmm.h
src/hardware/fluke-dmm/fluke.c
src/hardware/ftdi-la/api.c
src/hardware/ftdi-la/protocol.c
src/hardware/ftdi-la/protocol.h
src/hardware/fx2lafw/api.c
src/hardware/fx2lafw/protocol.c
src/hardware/fx2lafw/protocol.h
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/gmc-mh-1x-2x/protocol.c
src/hardware/gmc-mh-1x-2x/protocol.h
src/hardware/gwinstek-gds-800/api.c
src/hardware/gwinstek-gds-800/protocol.c
src/hardware/hameg-hmo/api.c
src/hardware/hameg-hmo/protocol.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-6xxx/protocol.h
src/hardware/hantek-dso/api.c
src/hardware/hantek-dso/dso.h
src/hardware/hp-3457a/api.c
src/hardware/hp-3457a/protocol.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/hung-chang-dso-2100/protocol.c
src/hardware/hung-chang-dso-2100/protocol.h
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/ikalogic-scanalogic2/protocol.c
src/hardware/ikalogic-scanalogic2/protocol.h
src/hardware/ikalogic-scanaplus/api.c
src/hardware/ikalogic-scanaplus/protocol.c
src/hardware/ikalogic-scanaplus/protocol.h
src/hardware/kecheng-kc-330b/api.c
src/hardware/kecheng-kc-330b/protocol.c
src/hardware/kecheng-kc-330b/protocol.h
src/hardware/kern-scale/api.c
src/hardware/kern-scale/protocol.c
src/hardware/kern-scale/protocol.h
src/hardware/korad-kaxxxxp/api.c
src/hardware/korad-kaxxxxp/protocol.c
src/hardware/korad-kaxxxxp/protocol.h
src/hardware/lascar-el-usb/api.c
src/hardware/lascar-el-usb/protocol.c
src/hardware/lascar-el-usb/protocol.h
src/hardware/lecroy-logicstudio/api.c
src/hardware/link-mso19/api.c
src/hardware/link-mso19/protocol.c
src/hardware/link-mso19/protocol.h
src/hardware/manson-hcs-3xxx/api.c
src/hardware/manson-hcs-3xxx/protocol.c
src/hardware/manson-hcs-3xxx/protocol.h
src/hardware/maynuo-m97/api.c
src/hardware/maynuo-m97/protocol.c
src/hardware/mic-985xx/api.c
src/hardware/mic-985xx/protocol.c
src/hardware/mic-985xx/protocol.h
src/hardware/motech-lps-30x/api.c
src/hardware/motech-lps-30x/protocol.c
src/hardware/norma-dmm/api.c
src/hardware/norma-dmm/protocol.c
src/hardware/norma-dmm/protocol.h
src/hardware/openbench-logic-sniffer/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/pipistrello-ols/api.c
src/hardware/pipistrello-ols/protocol.c
src/hardware/rigol-ds/api.c
src/hardware/rigol-ds/protocol.c
src/hardware/rigol-ds/protocol.h
src/hardware/saleae-logic16/api.c
src/hardware/saleae-logic16/protocol.c
src/hardware/saleae-logic16/protocol.h
src/hardware/scpi-pps/api.c
src/hardware/scpi-pps/protocol.h
src/hardware/serial-dmm/api.c
src/hardware/serial-dmm/protocol.c
src/hardware/serial-dmm/protocol.h
src/hardware/sysclk-lwla/api.c
src/hardware/teleinfo/api.c
src/hardware/teleinfo/protocol.c
src/hardware/teleinfo/protocol.h
src/hardware/testo/api.c
src/hardware/testo/protocol.c
src/hardware/testo/protocol.h
src/hardware/tondaj-sl-814/api.c
src/hardware/tondaj-sl-814/protocol.c
src/hardware/tondaj-sl-814/protocol.h
src/hardware/uni-t-dmm/api.c
src/hardware/uni-t-dmm/protocol.c
src/hardware/uni-t-dmm/protocol.h
src/hardware/uni-t-ut32x/api.c
src/hardware/uni-t-ut32x/protocol.c
src/hardware/uni-t-ut32x/protocol.h
src/hardware/victor-dmm/api.c
src/hardware/victor-dmm/protocol.c
src/hardware/victor-dmm/protocol.h
src/hardware/yokogawa-dlm/api.c
src/hardware/yokogawa-dlm/protocol.c
src/hardware/zeroplus-logic-cube/api.c
src/lcr/es51919.c
src/libsigrok-internal.h
src/session.c
src/session_driver.c

index 6096b5bfc40b2ba3d52157f20fd1ef19e97e7150..544bb08bfc8a36c74dd6f8ffc20fce1e48342d52 100644 (file)
@@ -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(). */
index 77a4a3dc577d908fe84950cffd4f603e5c7da858..2c5da1f8b68722dad1486c03dc7aaffade8cd3d0 100644 (file)
@@ -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];
index dd39322cf3f5b6a2e65b030abcd46482d15fde45..6a34985f8096a153466e6fc074f6c4a1065dbaa6 100644 (file)
@@ -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);
 }
 
index e5c0cc580cc5a8efa2cb6ebc762a17e2496a2ed0..07dbbade1299ae5a4e2d28c196b2b177e9cebf30 100644 (file)
@@ -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++;
 
index e033f5d37d8f3216f8f1c9e5732007e80d038bda..d81d076346b3fa35e265a37fe1be94235c3cf7f0 100644 (file)
@@ -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);
 }
 
index 84826890be9ad624ad4f29248e7827099f4d99b5..257f60577e99c2c443f49e41f9c8bf5914a5a2b8 100644 (file)
@@ -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;
                }
        }
index 4e8b1292ee862132cbaf9f1e31baf6d3c3d9ddf3..23b59b95733fd466c0bf9c6a8092ff308fcf0ccf 100644 (file)
@@ -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. */
index 1c351ffe675fb91fa8d621e32d1bb7c6c168dd59..4e186051a71d55b982f3b96827509194c60056eb 100644 (file)
@@ -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);
 }
 
index 7ba13540cb5530087a5c17ad817e952f1c23f552..9431ff3f55ed27933e6f8be4aa5b141449c8d905 100644 (file)
@@ -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;
                }
        }
index c7cc4d6da1f1c9050f50b61b249d599a22e55ff5..506b6f658f70299cc1bf2990b0fd1c7cbce4573d 100644 (file)
@@ -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;
 
index 0e41207af456e951362c2210bfbe072e1e55af23..d9db069eb4cd00b2f73cfcfa2d8b09964b5e0cb6 100644 (file)
@@ -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);
 
index d654e6091ba0ffed5ed183a270c06a30b6841147..9a2e5fc6a352deaa3b3610ff062f09fd3b46f84e 100644 (file)
@@ -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[];
index c90ab12d9cdd78878d3059ddf2d51d835b1eb526..734d78b9262e3ca9091b41e4ca9084848c08f99f 100644 (file)
@@ -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;
 
index caafc7037fd65408eae48c559e491554653ff8a7..bcd900d4c4ac53c0a3cfa0da83a324c7585baec0 100644 (file)
@@ -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)
index 0bef0b22bdfe7cb9aef7170d47c571463b48ada8..c09e91aad58699116e381c4e45c74f11d3d8947b 100644 (file)
@@ -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;
                }
index eb0d186a90f55a7f0fcc2e9fdd5a4cea1becbaae..8baf6523e9adcd383712ab172d4072d43188c1d3 100644 (file)
@@ -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;
 
index f440592f30a3c571ade26cf4f43a9a25f721e1eb..ce6c2ae9881067137eb06ea399d715f63a1d41e8 100644 (file)
@@ -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);
        }
 
index 75e74725f86c221902b05b6e17e4decf3af771a8..e058a60ab6560af593b1a8e83716f0ab5fa70dbc 100644 (file)
@@ -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;
index 4098b9269b88d3ceb74ef990a129b6902d07102c..ea7866bd8835a061c43042809acbd50c3f094b6b 100644 (file)
@@ -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;
 
index 17d1a905c66419a93ece6cd25ddb4677b8b69324..b2b955f5ac6b38b090cd9e970e29a0dd8342ad15 100644 (file)
@@ -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;
                }
        }
index 3700515f2da1242f410e1aa2714e186e28b29a46..ceb7d846b5533cb36d4de6e60814f226e797f971 100644 (file)
@@ -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);
 }
 
index 4db460afd63c255fcdcd7f0edeb72e5cedd27517..1667bef688cbbe9fc6c6d0a5a6188a53b5d7d7cf 100644 (file)
@@ -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;
                }
        }
index 24fe63d3206856765b9dc925ef45fa8b99d06b71..6f59206a943818c54bccaf45981b17aabd0623b2 100644 (file)
@@ -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;
 
index b9a7cb684ebfed683f7526a8c6cea336f839a4f3..146c80464fc321ed431fb800553df9719b680bb8 100644 (file)
@@ -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);
 }
 
index 68d003a0d0243d50c05cb58169b5ba9fe180722d..2509818505f3c19935b2f4a59a55da88ba64e7cc 100644 (file)
@@ -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;
                }
index 69afacaefc32471a7d47880aeac7f661800284aa..d6a9466175dae456c72cf4a5974ba9ebbacf386b 100644 (file)
@@ -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;
index 7fe70fa9a8030bc01223d053849973c7eb8dcecc..bdcb0169d21c3c70f786d728c92105008d48626b 100644 (file)
@@ -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) \
index 34478faeca681c1fcfa7020e179fd8d3b585ebf5..0c491723d4a8d18858d573b2a3210fd0022491f1 100644 (file)
@@ -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;
                }
        }
index acad71d4ece59ed4001d5673701ae7f0a7246bf2..f6564491752c1bd259b01497e77f96367650720c 100644 (file)
@@ -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;
 
index 5914ef21d4ca3faf812d01bf47b3f78d1f464a76..d8de0da1f96f655965174da40491fda2419017db 100644 (file)
@@ -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);
index a4689fa3b2140cd5a2a8e05fa29efe112fb300a1..599472c50458339e62d68220a8e40d86a653beee 100644 (file)
@@ -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);
        }
 }
index bd1efff26b1ae83ea0fe7a96e62e5258572ada4e..44e2c861b3c639561a8b9db08cb5c7d9625a8b7a 100644 (file)
@@ -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
index b75af7f6d2b8043c9f1f19d4dde441bcfe0399c8..c7019a31f1a36c00393e47f66195919766cca9a6 100644 (file)
@@ -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);
 }
 
index 481a6dd36ec72dfe06c3333c432c95acdd93cdd3..c7acc9e3d5b159f36b9f4043c4bc8b1b0b8d59ff 100644 (file)
@@ -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)
index 4cc49974a2682e608591ee3299c69e91236d386c..ab878e759f2efa42bb5a80ddf029db8639629594 100644 (file)
@@ -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;
index 1f3abe8156c9363145091df19f4c3b03f64c5da5..3fc2cb7df32ba2d9888621784d6368f80809f944 100644 (file)
@@ -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;
 
index 50780214d72787a0da64e5223412128d879e2abb..d0b1f7b878c78be87ab23db0bf45973397c59c18 100644 (file)
@@ -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);
index a7b2e14d0d103dbfb25479a6cd9d475e0405d795..bc2e0e56de6634aa37fc185a6eab8e8c9717daa9 100644 (file)
@@ -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);
 }
 
index 823f1624940ab3c5541a25b24a1fe78e957bd3b5..8f1571cefc56ece7c6d6f9799a54df04add5cb4a 100644 (file)
@@ -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];
index 7a1fbf92022b0111115581eb5cc3a2f8f999e966..3629b5f373e1cbbf8e6cd2908efbaaa5569b7708 100644 (file)
@@ -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;
        }
 
index afc6be45c0cba28b81b695f2fa446edbea56fb70..2cea73ea1cd62a05121d364d759223805412737c 100644 (file)
@@ -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;
 
index 273d79e7c4a74f923753e71338568578d9420ebd..8d81d87752e6d91829d55f781c4738b31f3d4c27 100644 (file)
 #include <ftdi.h>
 #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;
index 54c19ee3fda1b834d6add381544b9280c13e9c40..aa72dffa723b83b2ac3e397816dca1df04048fa6 100644 (file)
@@ -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);
index 976cfbf9d28d735628c841b08b17849ecb8ad178..90d28507628dfc1989591a48d64146f69c07b3c2 100644 (file)
@@ -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)
index 513fd0e2821f8fe039b45b4e58a33423ea152ac0..c496aa14f9885a28dec90e024b8baba48ec921b7 100644 (file)
@@ -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;
index 4c2f65f1f490608ec2e4ee308a825231a360963e..2e424ac32b790436120d16865a2da028342ccd85 100644 (file)
@@ -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
index d4e44b2512b93da5c72e5b240abc2dfc5b8cc224..2b7bfca6c6ebead378b8babaeca3a4f29a434783 100644 (file)
@@ -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);
 }
 
index c5554cb926140dd96f05b7b5272a61e2c26f5d2b..1607bfa430adf632379a77d56344a110bb0a626e 100644 (file)
@@ -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 */
index 7e75fc4b389c9f9afd57a1848996590081c47e89..b368576b92858395010a43e624d0279e931c5de9 100644 (file)
@@ -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, ...). */
index 89d6a07a21bd8150afda02806a6d469abd534c71..e2d28f3f196661070869ddf90f720e51cfc0088e 100644 (file)
@@ -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;
 
index 358e962a54df7c2fa3f65cf5048cb20b7dac5496..77058577e44d8584805f623dca855354617f1b38 100644 (file)
@@ -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. */
index b234caa21f09e257c4a5b82595435c48b86c9139..a9bcca8c1703c9b1ec8525b65c85c8e5c2298c9c 100644 (file)
@@ -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)
index a073d0de60bea7f71f421cc070b7c2263cbdd802..9137b3b7c9e72e16b3dad518604096fc3716b38f 100644 (file)
@@ -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);
index 71e62c52225af3396f867cf6679903ee4d5dd9c2..bdc10af4d9655268aab8bedc4714e64af1db20bf 100644 (file)
@@ -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;
 
index c798a184dcdee6645e33c2162145586cda2b9d81..530bd67dcc068b034b957944e34da407e9480b48 100644 (file)
@@ -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
index 082d05b6add33ca84080a3a14fa7bd6ae244a128..b88a902b25c718323ebd11c049f5279b4efcb9f6 100644 (file)
@@ -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;
 
index 44cced48400605bad020554ade3fd3e950ab764e..78e438bd62537d0fcfb1ce99bbe2a57932c7f28e 100644 (file)
@@ -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;
index eae8195ce48a716b2d8b8159425caa2f9de6f592..05a45e6295905f7ef31086b14b6e5fb114a620c0 100644 (file)
@@ -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;
index d9aa83383ac6ac3a492b8ad4d68ebcd995bc902a..bf673fdee45e2a57242140b1a51abdf96b838ab6 100644 (file)
@@ -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;
        }
 
index 9f2d56a063eb810e0c8a0e041836fca9e79b1c70..fecd593c375f4b4803cc378fef3ef30eca0ff575 100644 (file)
@@ -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 = {
index c1c8dacb6df40f6dc8375215ae7a1636323dbe57..31f161e8f1dca4f03ec5cbab4acf242f6ddf24a2 100644 (file)
@@ -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);
 
index 5636699a87b4126be9c2aeaa7f397bdf5a8e3b26..f210b650a3d6e1bea2e9f6327016e2abab3e9962 100644 (file)
@@ -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
index 3b866d0a48abd4f6ae02cc1ca267353b52ff8fdc..f7480db3d4c06ac3e80ba3d3691453c2cf428b8d 100644 (file)
@@ -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;
 
index f8833806dda30973a8ba63535402d9f46ff4b5f1..4e8b64b7df1cac3db767a7c878951a518ea23d06 100644 (file)
@@ -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);
        }
 }
 
index 66a5cecf57919f0b2a6cbcf50d6d56624bc15805..607933755cd93ca3aaa6f91567acef959081f852 100644 (file)
@@ -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];
 
index c445b99353b4ee77bc90bb8acf27229af9e768b9..ec649d41f582fd4f8295c99320622e8c7897efa3 100644 (file)
@@ -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);
index 0b81ebde211ece7f2ac01dd2871c787085289117..9e9b0ea5ca08a96dcadbb3554848380e23becd07 100644 (file)
@@ -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;
index cdd684d0b1acecb3a976630dee49056042b95407..705c2bd02565c7d9bd40bfdb4a87ef82013bef88 100644 (file)
@@ -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;
index df11489d46e4ca744b82fd9e08bfc465b6ea6729..1214fadbe1662e4a821bb4d5232994ac97d2687e 100644 (file)
@@ -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;
 
index bcc6846988c6a6856503f1ebeee9084b0e09fe33..e1c8da17b910b4e25b703c923760591939976fa9 100644 (file)
@@ -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. */
index a718bdba0ee26162901bbcd82af5b1d138598627..07597c6ba1dd4fd539cbb82ca7036fc2504b1609 100644 (file)
@@ -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];
 
index b5e5c28095092b8d6addafe109aad3cea3bb4390..03a68d8a7dee98c7d8ab785565b7257ce2dc1a60 100644 (file)
@@ -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);
 }
 
index 8845ae39f6676e1f794635baf64d0c6d5dd9bb1b..953744446e5f5f61f058c0171faea803dedae429 100644 (file)
@@ -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;
                }
        }
index fce47003a669e68dbd4ce6076ce507532e5eec2a..fe8ae8db9d93328229dea9f754c7550495c399bb 100644 (file)
@@ -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;
 
index d9d3a9ce5bc8bf8278342f5e02273a395fa3ed1b..42dd581a91fc9db56ceed0073fc5378404046a59 100644 (file)
@@ -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);
 }
 
index 60c4545581fbe92e6675dcc441059683823fd62f..709805a93cc2588eb65673e750aed4d006c192f6 100644 (file)
@@ -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;
                }
        }
index 77c4eb6f7d229a71f58ddb155aa957e743584c07..307424a0200f1e27605aba18b9dbd221e94c5738 100644 (file)
@@ -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. */
index 40670cec39f23daa292d4345a9411ed466bde971..d2ed3033f8499e9a91ddd0e7e4aebf997b251ab1 100644 (file)
@@ -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.");
index 9fd9b696466a09eac8921d0d26c263bde7b46d10..e4fae68f5720d4df39e9fbac0d3001d94d43274a 100644 (file)
@@ -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
index 482c4a9788fd923445a9ba3178346ddaa355a49f..c4eec74b629288f844ece0ab8406456990b8a6d8 100644 (file)
@@ -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
index 53e7b017d15cfb9dbbc68439ca54dd2538a0cd3e..b6eff9dd2e138da5400fe0bdfc8cedb2e65cbef1 100644 (file)
@@ -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;
 
index 4fcc87a076f13c090f2bdb2aa82d2df682b484ac..e0791acc86ec5e0a209903c128fccfa6c4bd5809 100644 (file)
@@ -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;
index 0c28585e774bcf69fd1eb263c6885332ed3d90d6..dbc8f79cf91cb48398e36dca16e9787b1cd37a18 100644 (file)
@@ -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;
index e32f39e9f9829ab7c76a3cd9fa41c61419d25cf5..4c8a66b26a22f0e241501be5dcc2e50f27492cea 100644 (file)
@@ -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];
 };
index ad425c163abc1a1ce72c7eb4b69fb34d9ec3a3af..125febbeba0e67c0f49246dccad322fbddcb2d2b 100644 (file)
@@ -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);
 }
 
index 657ae318895252abf2dc37cacf58312f27fe04ac..5fa53d29ab38d0f5233c085e8c5ec23b3197f1cd 100644 (file)
@@ -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;
                }
        }
index 8e614ce2a335621932a9869c99358d6aea5ac268..ee9e0cb20b8ce9b432882d9dc75594d73b77ede3 100644 (file)
@@ -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. */
index 4b92446e93ea37ef0ecc03e09f8303e0905cf331..ffc5b8f033c7c6ca94ac752658c90770ea5bc173 100644 (file)
@@ -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;
 
index 085d379f1c36635a0c07876329c4c8529bd5b924..57f93b14286d9af9ddea74ebbc06c6c7f62b6bd6 100644 (file)
@@ -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;
                }
        }
index fcb0db46e78d95e99872d743c4e62e4a6c639b83..aafb08a91a363f10f63299f6c07cbcad180ac51f 100644 (file)
@@ -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) \
index 4ee11b70c8e3ce2e626570487e82db5298db0d9f..151b7c837af7cbf8f021c5c900c0e2fea0848f62 100644 (file)
@@ -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;
                }
        }
index f0e31a61e8cf5bcded1b4054c45c7422644ede2c..d522c0a4e537ff6ee524fbc0efa0c1a5421f4fc9 100644 (file)
@@ -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;
 
index 0ecfcb09e315e4f35394de42d2d08fbeee729f11..bbbdb660e69b2c9982f93e9903ccb64e1def0b7c 100644 (file)
@@ -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);
 }
 
index 4b9da80258b0409adbafedaa432e53ad21e1f3cd..03e9cdd54885a39ef5e1a4a84d6df7bc80b201c4 100644 (file)
@@ -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. */
index 3e6eab7805c100c807b4302add1a41f438341105..04775a6418f51bb2b5b67ac278c4a885896ff5fb 100644 (file)
@@ -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);
 }
 
index 4dc717c9d0aa9967d992e306a385c0d7b4d813e6..60bae0b3460078f258a43a61de0b138630bb3c03 100644 (file)
@@ -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;
                }
        }
index 7c52b47ffec61a48b206f22c78feb2c8b0fce4fb..082e736a617e0e71911e95dbd338ede9ef76041b 100644 (file)
@@ -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. */
index af1ce7842f475522102664bd7abf6ba41a6ec20f..cb687568505a3c7f2bfb40a954f1c538d909c49a 100644 (file)
@@ -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;
index 7f274258ddafe8b1245ff887fc663d55394db9db..15f1b3c03e9ff42b27569ed6b0010cc880e9b925 100644 (file)
@@ -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);
 
index 865c3bf6bef9219daa57ca68d7204bb198c5e7f7..c9a14931e2f69eeffa6d0a02f645ea95e81e7f51 100644 (file)
@@ -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;
 }
index 17fe031db4b70587ce5f80c06b13002ca56f95c8..d49d0e6ab4d07c0d17cc640a7141e3d64db632ec 100644 (file)
@@ -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;
index 259ca1690dfb4100a64dcf6d9f98bb11d8a187c5..8c3282779abeae19cc9684494f43e13e07aeb637 100644 (file)
@@ -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) {
index 4a307178b604b8d2f636e07fa943cea21e4ddadc..b633977d662399f7459762baf0ab3fb71f9b1632 100644 (file)
@@ -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);
                }
        }
 
index 5e5f01ba3b4fc0a5575c156c393cf9a927cd91fd..a085936197abe4ff9244b23492872678c6fe8297 100644 (file)
@@ -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;
index bf41b759a3dda3c94c11399791999ecd95799183..dbd85fb3b2233862734d61722724b22c0128714c 100644 (file)
@@ -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;
 
index d75be36dda6c2d00d4398f4dc3cb23a7755cdc37..a14d0e087c87eb6f180424f9a0e866cda69a4994 100644 (file)
@@ -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;
index 9f834164c83d14bb3603a75f1815348b13f74e02..9eead9a9e772ffc80b728c12c058f1df36cbf758 100644 (file)
@@ -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;
index 475cdca3eb9064bbb8cfac3b90b2d8c1b07a3196..112bedc0e25b13712123d21fbec6ea3d3d2fd86e 100644 (file)
@@ -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;
 
index f939b0d729722ff89d7c2fd231dcac5de5e53436..ba1905132442019ceff60732cb9b2fe389a92fcb 100644 (file)
@@ -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;
index f53381bf93856f3b2d1ae935ec8d8a5deca49f4a..eaf913f271ab1fff7ed54e6acc24bd95cad69f51 100644 (file)
@@ -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);
 }
 
index 8e9b3979efe303ca4c33526e5c7293113076fd46..1e343a2f3f89254923965dc77a352888069a5aaf 100644 (file)
@@ -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;
                }
        }
index 3c2d88b80876cf111cc25e9f25696dc31ec952b6..da6742c35b6732f776eea17a66b5ca4e6b872f1c 100644 (file)
@@ -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;
 
index 7e6190378b2063dfab166a9608cb066716798c63..8ee85a62be0c08aa0ec214798fdce4757c52e71d 100644 (file)
@@ -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)
index 1becb31e2542781bc5f0a3194b005c71ee921395..1d8f91df22eb6222385e6850d816f5d000d89e90 100644 (file)
@@ -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);
 }
 
index 21b695bd5be5041d72a2c24a2a1699624725e308..fbbc044d4b96f75b6daf57e8e760556d39efecdb 100644 (file)
@@ -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;
                }
        }
index 84a7546e2c2bfa4a03c3244a895f578df74765cf..b4aa0fef1244148d3573de4ed6f0f58e39701731 100644 (file)
@@ -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) */
index 691ba8f5e85ae66bbddf47c43c5ff5023b9b9a54..c43c3c7eb803fd43ddf2acada10f4976196be1d4 100644 (file)
@@ -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.");
index be36023f7bd56849b74e3b960cd78ba60a878af1..4a1af4c49245fc5edeb63178a51fbfb511d3533c 100644 (file)
@@ -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.");
index 06a29644c17b0f646a0c727651304849281e25bd..8cfc3511279170eb398873b7244f87f0e1418ce7 100644 (file)
@@ -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;
index 979a8bea030d9b08e4af315b792384a468b6fd12..e417d96f3999b6fe2d8e8a0343c64d0ad1de303e 100644 (file)
@@ -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);
 }
 
index d09d19bf2c9a5ddf550a245123e9c44847477a0d..d6f470d26a7ad0eb7822b5446f8850a3c67bb93d 100644 (file)
@@ -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;
index 77c6ca08fec8d24246bde7b32700fba3784275ce..27174a2fef62b36824ece3d1a10d53ea0a6b6425 100644 (file)
@@ -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;
 
index f3416c265359b3306992ba30e4e4689518221315..a77aebbae5cc320fc5de61e3bc201f1c3ef09f00 100644 (file)
@@ -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);
index 4bbe20d6b2f8f0e341f964f59d18855af89eebdd..c417ea153629daae86d5efb28ea01be69d86bc07 100644 (file)
@@ -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;
                }
        }
index f8fdbb5ad6c111b37282f2f0e2e1df5ec33551c0..853809e36c0c5849c89736d8cb12ad9f0bc6c781 100644 (file)
@@ -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;
 
index ea57ed033def29ccc15eb2d37fed0017204926d2..fe75241537aa13eb385e59a607dc10a8c60ba652 100644 (file)
@@ -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;
 
index 14e70cf221ed13f9d41adf1082098ce215f8648e..34fa14d4c2f726b339da203a9bd302bb36e601e9 100644 (file)
@@ -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;
index 4010e179fc535414ea0ad5bc867709cdd52497f3..a2bad3306ac5c89b561e37bedd909f8a65ad81bb 100644 (file)
@@ -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];
index f94352565c73d59bb41cb15ba55003f5e41cdd2a..1bc034424a1784e745f38917715d1c6a5cd87cb6 100644 (file)
@@ -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.");
index b0eb384ad24d306f0b917bab8ae17799e25feb64..c25ac52c464a13c998ae51c406c61fd9328da75c 100644 (file)
@@ -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++;
 }
index 38fd5241a10aee3443f602ea4a07a5b0fa607ce3..1ee36267f25dc37f781a86ac5d6860dc77d7168b 100644 (file)
@@ -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;
index 2a3d2e55f00a6a39eb6385d199a128a3a236caea..34801afe02461cfc04a85807bfde0444997f1de2 100644 (file)
@@ -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)
index e63e6357f0cc3a130ec49feaa38706fffb23911c..7d6c7e9452acb749302f8b5c0f26b35cf91519c9 100644 (file)
@@ -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;
index ca3d5ad2f8403c231c3a1b4c76c1702bc80488f5..22ec33b544ac3d8218b9bb0fe960d3254f63cd0e 100644 (file)
@@ -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__);
index cbe51179b7bfb403c1fa43e778f6edbf8feba00c..ceffa411764f23b7fe8344a3045b397b2895dc11 100644 (file)
@@ -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);
 }
index 63234153d44da4051a8d9ff35b48fcd21f54cca0..7c8c0eb2e13efc0fb9140b99fd46f2b517060501 100644 (file)
@@ -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 --------------------------------------------------*/
 
index 5a68c8df4e142081c704cd56771efdadc51bc66b..23dc0c3a025b99d53245c426e40b3197ac37e168 100644 (file)
@@ -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;
index 3b801ffcb36dcada6fe6c3b55ef2c5a335034f21..d56c22c23866f088323f4c8ab43d669396572f13 100644 (file)
@@ -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;