]> sigrok.org Git - libsigrok.git/commitdiff
clear_helper(): Use a cast to shorten all implementations.
authorUwe Hermann <redacted>
Tue, 11 Jul 2017 19:30:30 +0000 (21:30 +0200)
committerUwe Hermann <redacted>
Thu, 13 Jul 2017 09:59:11 +0000 (11:59 +0200)
16 files changed:
src/hardware/asix-sigma/api.c
src/hardware/chronovu-la/api.c
src/hardware/demo/api.c
src/hardware/ftdi-la/api.c
src/hardware/fx2lafw/api.c
src/hardware/hameg-hmo/api.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/ikalogic-scanaplus/api.c
src/hardware/lecroy-xstream/api.c
src/hardware/pipistrello-ols/api.c
src/hardware/rigol-ds/api.c
src/hardware/scpi-pps/api.c
src/hardware/yokogawa-dlm/api.c

index cf02b1e513eff036f9ffb582cdfdd6c519e0ef92..98d5180bd2de156a302d26864bd526e64fa5b6e2 100644 (file)
@@ -59,18 +59,14 @@ static const int32_t trigger_matches[] = {
 };
 #endif
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        ftdi_deinit(&devc->ftdic);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
index d6ed20d9277807a6d674dc94b557046d5745ca20..2c4ec3db60e42aedac74981b5fbacaa33205e099 100644 (file)
@@ -43,19 +43,15 @@ static const int32_t trigger_matches[] = {
        SR_TRIGGER_FALLING,
 };
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        ftdi_free(devc->ftdic);
        g_free(devc->final_buf);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int add_device(int model, struct libusb_device_descriptor *des,
index 6549b5d784c5db8fe069dbd5a3223cca57e99d25..f88b4c2ea794de37992a0e0fafb4a4a4bfee367f 100644 (file)
@@ -180,14 +180,11 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return std_scan_complete(di, g_slist_append(NULL, sdi));
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
        GHashTableIter iter;
        void *value;
 
-       devc = priv;
-
        /* Analog generators. */
        g_hash_table_iter_init(&iter, devc->ch_ag);
        while (g_hash_table_iter_next(&iter, NULL, &value))
@@ -197,7 +194,7 @@ static void clear_helper(void *priv)
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 6b545afb08be17cdb82d351198269077ad7d0758..6eb2353d932b3d41a5ad6ec0a9f05aacd9593bda 100644 (file)
@@ -240,17 +240,14 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return std_scan_complete(di, devices);
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
        g_free(devc->data_buf);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index d824b02223bb69a7fd2a5173761cd98d449779e9..48df729e3164ca103269f73ce85df063513207c8 100644 (file)
@@ -345,17 +345,14 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return std_scan_complete(di, devices);
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
        g_slist_free(devc->enabled_analog_channels);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 7e062b8d6f258feb05989dc9571ec67e5298a665..22fcbc54b3c07472689c18bd61a3c16ed86870d4 100644 (file)
@@ -110,21 +110,16 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return sr_scpi_scan(di->context, options, hmo_probe_serial_device);
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        hmo_scope_state_free(devc->model_state);
-
        g_free(devc->analog_groups);
        g_free(devc->digital_groups);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index aa0977ad3cbbc457bf56ff20325bf5a80c7bfb0e..6bdcdb1f9dc7b24485e648e63001c69163c60538 100644 (file)
@@ -156,17 +156,14 @@ static int configure_channels(const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
        g_slist_free(devc->enabled_channels);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
index ea07b546fd57547514d2f310bb38c5123609b619..4b911c28db41ffaf5cc6e0d13585bc6e69753b91 100644 (file)
@@ -232,18 +232,15 @@ static int configure_channels(const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
        g_free(devc->triggersource);
        g_slist_free(devc->enabled_channels);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
index 505649ddc119dfa3b4ba493f8b943e50065b4ca9..484f8768f18dbb3a8d0383c7666f61966c9e7373 100644 (file)
@@ -218,10 +218,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return std_scan_complete(di, devices);
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc = priv;
-
        g_slist_free(devc->enabled_channel);
 }
 
@@ -238,7 +236,7 @@ static int dev_clear(const struct sr_dev_driver *di)
                }
        }
 
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 2078b8015c4e8a61d1115af31b6418a5ce63c78a..6c336cb107aff8c0d330da53823e415e669e840d 100644 (file)
@@ -152,19 +152,15 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return std_scan_complete(di, devices);
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        libusb_free_transfer(devc->xfer_in);
        libusb_free_transfer(devc->xfer_out);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index dd5d09ffef51342acb8a26a7af226387c2859310..e9c6af04c22f04c8a1b0436e6fafd5d0d7b058e8 100644 (file)
@@ -43,12 +43,8 @@ static const char *channel_names[] = {
 /* Note: The IKALOGIC ScanaPLUS always samples at 100MHz. */
 static const uint64_t samplerates[1] = { SR_MHZ(100) };
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        ftdi_free(devc->ftdic);
        g_free(devc->compressed_buf);
        g_free(devc->sample_buf);
@@ -56,7 +52,7 @@ static void clear_helper(void *priv)
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
index e00154b9bef88bc87d1d9066a4a5b31fa6daf65b..34b50b7ae33d91e6c325d05c79f81608b1befb9d 100644 (file)
@@ -115,20 +115,15 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return sr_scpi_scan(di->context, options, probe_serial_device);
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        lecroy_xstream_state_free(devc->model_state);
-
        g_free(devc->analog_groups);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
index 4440be67f52695fd4613dac506381a93c253efae..545dcd14c870896e19e4a4f98905a89125322fbc 100644 (file)
@@ -189,19 +189,15 @@ err_free_ftdi_buf:
        return NULL;
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        ftdi_free(devc->ftdic);
        g_free(devc->ftdi_buf);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 221b1234ac6177c30bccfc92b56cba6c00f60ca8..37a1984d631280a6e820f2b8ca4bd849c45f4700 100644 (file)
@@ -275,12 +275,10 @@ static const struct rigol_ds_model supported_models[] = {
 
 static struct sr_dev_driver rigol_ds_driver_info;
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
        unsigned int i;
 
-       devc = priv;
        g_free(devc->data);
        g_free(devc->buffer);
        for (i = 0; i < ARRAY_SIZE(devc->coupling); i++)
@@ -292,7 +290,7 @@ static void clear_helper(void *priv)
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
index 3642b31e9acb039dacac3d3f7c7566336a61b6e9..6b73f121d235344473e394d160e68131f063ffe7 100644 (file)
@@ -288,18 +288,15 @@ static int dev_close(struct sr_dev_inst *sdi)
        return sr_scpi_close(scpi);
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
        g_free(devc->channels);
        g_free(devc->channel_groups);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index cace9e586db695dbd7f68fa34471a315c2fd1e4e..76703d867f3de3584a0e42eb972ac3ce74cb8305 100644 (file)
@@ -121,21 +121,16 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return sr_scpi_scan(di->context, options, probe_usbtmc_device);
 }
 
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
 {
-       struct dev_context *devc;
-
-       devc = priv;
-
        dlm_scope_state_destroy(devc->model_state);
-
        g_free(devc->analog_groups);
        g_free(devc->digital_groups);
 }
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
-       return std_dev_clear_with_callback(di, clear_helper);
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)