]> sigrok.org Git - libsigrok.git/commitdiff
Introduce standard cleanup helper
authorLars-Peter Clausen <redacted>
Fri, 29 Apr 2016 11:36:05 +0000 (13:36 +0200)
committerLars-Peter Clausen <redacted>
Tue, 3 May 2016 19:24:39 +0000 (21:24 +0200)
std_init() allocates a drv_context struct which needs to be freed by the
driver in its cleanup struct. But the vast majority of drivers does never
does this causing memory leaks.

Instead of addressing the issue by manually adding code to free the struct
to each driver introduce a new helper function std_cleanup() that takes
care of this. In addition to freeing the drv_context struct std_cleanup()
also invokes sr_dev_clear() which takes care of freeing all devices
attached to the driver.

Combining both operations in the same helper function allows to use
std_cleanup() as the cleanup callback for all existing drivers, which
reduces the amount of boiler-plate code quite a bit.

All drivers are updated to use the new helper function.

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

index 7ca471c305c5e139c59f2cfcd629c0b98f3c3b5d..d2a11cc7c71e0482b45afc44d3c90206f1e0b1de 100644 (file)
@@ -166,11 +166,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -254,7 +249,7 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = {
        .longname = "Agilent U12xx series DMMs",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 87f5ea49ca610381e9db9ce6366efe5d8191e567..27b4399abe97e056222e5ca4724c9620101cead1 100644 (file)
@@ -126,11 +126,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -264,7 +259,7 @@ SR_PRIV struct sr_dev_driver appa_55ii_driver_info = {
        .longname = "APPA 55II",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 3686b34854148fdd0243ad1fde405823c5c7f94f..960c22435872810d1f05edda5c21eb5ec4ef7d3d 100644 (file)
@@ -174,11 +174,6 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear(di, NULL);
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_list(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
@@ -385,7 +380,7 @@ SR_PRIV struct sr_dev_driver arachnid_labs_re_load_pro_driver_info = {
        .longname = "Arachnid Labs Re:load Pro",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 506b6f658f70299cc1bf2990b0fd1c7cbce4573d..25b5cad3b22b366445c1fce26fcaea5bf7eb8536 100644 (file)
@@ -188,11 +188,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -425,7 +420,7 @@ SR_PRIV struct sr_dev_driver asix_sigma_driver_info = {
        .longname = "ASIX SIGMA/SIGMA2",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 734d78b9262e3ca9091b41e4ca9084848c08f99f..ce0531c967195cad2487a5bb85f632750fcbf2b2 100644 (file)
@@ -204,11 +204,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -507,7 +502,7 @@ SR_PRIV struct sr_dev_driver atten_pps3203_driver_info = {
        .longname = "Atten PPS3203T-3S",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan_3203,
        .dev_list = dev_list,
        .dev_clear = NULL,
index c886bfcc26a4076309135c444932a4a24b792a14..23c75d84877979b173d06e7fb3350412e54dee98 100644 (file)
@@ -170,13 +170,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       dev_clear(di);
-
-       return SR_OK;
-}
-
 static int config_get(uint32_t key, GVariant **data,
                      const struct sr_dev_inst *sdi,
                      const struct sr_channel_group *cg)
@@ -422,7 +415,7 @@ SR_PRIV struct sr_dev_driver baylibre_acme_driver_info = {
        .longname = "BayLibre ACME (Another Cute Measurement Equipment)",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index e729d4e2185101231ddbddefc5fbef9e84657f2e..2285c193b266a098cad64e0073be38df66cdff70 100644 (file)
@@ -200,11 +200,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -383,7 +378,7 @@ SR_PRIV struct sr_dev_driver beaglelogic_driver_info = {
        .longname = "BeagleLogic",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index ea7866bd8835a061c43042809acbd50c3f094b6b..8b6f5ee30f02b9b064acb0a0c1b2e6f6b3ad7fb6 100644 (file)
@@ -172,11 +172,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return ret;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -284,7 +279,7 @@ SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info = {
        .longname = "Brymen BM86X",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 1dcf205ca3000da0c14f2365283d490b1f5eed4d..9868cdf1480d182c84c642ac1f181ef91be7c04e 100644 (file)
@@ -136,11 +136,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -233,7 +228,7 @@ SR_PRIV struct sr_dev_driver brymen_bm857_driver_info = {
        .longname = "Brymen BM857",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 11f80045b5868e1c198c20a77d94c5ff51b25d62..59137d6da2ac236e4330c17542ce615d572e2b82 100644 (file)
@@ -141,11 +141,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -402,7 +397,7 @@ SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info = {
        .longname = "CEM DT-885x",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index d4451cbe72b539c8755e078f81271b2d5384133f..0e63122a74900fb89e7f2bef9824f02d37c7507e 100644 (file)
@@ -144,11 +144,6 @@ static GSList *dev_list(int idx)
        return ((struct drv_context *)(center_devs[idx].di->context))->instances;
 }
 
-static int cleanup(int idx)
-{
-       return dev_clear(idx);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -236,9 +231,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 #define HW_INIT(X) \
 static int init_##X(struct sr_dev_driver *d, \
        struct sr_context *sr_ctx) { (void)d; return init(sr_ctx, X); }
-#define HW_CLEANUP(X) \
-static int cleanup_##X(const struct sr_dev_driver *d) { \
-       (void)d; return cleanup(X); }
 #define HW_SCAN(X) \
 static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \
        (void)d; return scan(options, X); }
@@ -255,7 +247,6 @@ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
 /* Driver structs and API function wrappers */
 #define DRV(ID, ID_UPPER, NAME, LONGNAME) \
 HW_INIT(ID_UPPER) \
-HW_CLEANUP(ID_UPPER) \
 HW_SCAN(ID_UPPER) \
 HW_DEV_LIST(ID_UPPER) \
 HW_DEV_CLEAR(ID_UPPER) \
@@ -265,7 +256,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .longname = LONGNAME, \
        .api_version = 1, \
        .init = init_##ID_UPPER, \
-       .cleanup = cleanup_##ID_UPPER, \
+       .cleanup = std_cleanup, \
        .scan = scan_##ID_UPPER, \
        .dev_list = dev_list_##ID_UPPER, \
        .dev_clear = dev_clear_##ID_UPPER, \
index 040a9c4b087f66b2c87c40555ada19a5ce78025a..bd922d0570bb4363c2d7e31fe6fbfa86a5fac63a 100644 (file)
@@ -323,11 +323,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -588,7 +583,7 @@ SR_PRIV struct sr_dev_driver chronovu_la_driver_info = {
        .longname = "ChronoVu LA8/LA16",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index ca75d33e4001e29d84b002289861a55d528dded0..4a0b61e5a8c99458aecdcad78a761ac30233feb7 100644 (file)
@@ -101,11 +101,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -186,7 +181,7 @@ SR_PRIV struct sr_dev_driver colead_slm_driver_info = {
        .longname = "Colead SLM",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 3fc2cb7df32ba2d9888621784d6368f80809f944..0195f4809d471b2b708d78e17898d23a6698d357 100644 (file)
@@ -111,11 +111,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -203,7 +198,7 @@ SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
        .longname = "Conrad DIGI 35 CPU",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index e9cbd7680326a3741c175f569ad4f3dcd81c9233..15a4c60d3f9aac4838d81a395d9bd75ef1dac905 100644 (file)
@@ -394,11 +394,6 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear(di, clear_helper);
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -894,7 +889,7 @@ SR_PRIV struct sr_dev_driver demo_driver_info = {
        .longname = "Demo driver and pattern generator",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 8619ccfbd3f66537aff0ef2597cdc590a01c1784..8c24eb18d2631a0a341a8c5ba66b9cfef3116bb8 100644 (file)
@@ -54,11 +54,6 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear(di, es51919_serial_clean);
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_dev_inst *sdi;
@@ -76,7 +71,7 @@ SR_PRIV struct sr_dev_driver deree_de5000_driver_info = {
        .longname = "DER EE DE-5000",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 765a26a9840c31747321b822b4dd400d392ef112..dc55aa4143cf3ad16727907945e222f09f4c6d35 100644 (file)
@@ -194,11 +194,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -289,7 +284,7 @@ SR_PRIV struct sr_dev_driver flukedmm_driver_info = {
        .longname = "Fluke 18x/28x series DMMs",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 144279851e29567dc0a9edd485b3fab7069cd250..547e25e4c4ffe06e7d40720350aee6173b3cf11a 100644 (file)
@@ -348,15 +348,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       dev_clear(di);
-
-       /* TODO: Free other driver resources, if any. */
-
-       return SR_OK;
-}
-
 static int config_get(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
@@ -506,7 +497,7 @@ SR_PRIV struct sr_dev_driver ftdi_la_driver_info = {
        .longname = "FTDI LA",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 90d28507628dfc1989591a48d64146f69c07b3c2..fcc98fa9a0861753d6159cb052156d06369a665b 100644 (file)
@@ -509,21 +509,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       int ret;
-       struct drv_context *drvc;
-
-       if (!(drvc = di->context))
-               return SR_OK;
-
-       ret = std_dev_clear(di, NULL);
-
-       g_free(drvc);
-
-       return ret;
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -912,7 +897,7 @@ SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
        .longname = "fx2lafw (generic driver for FX2 based LAs)",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 28927fc53d58247850e0e4308f63d9677af29412..b8f71c2fda17c648d2c610e9622fd6c9183e0612 100644 (file)
@@ -374,11 +374,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -529,7 +524,7 @@ SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = {
        .longname = "Gossen Metrawatt Metrahit 1x/2x, RS232 interface",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan_1x_2x_rs232,
        .dev_list = dev_list,
        .dev_clear = NULL,
@@ -548,7 +543,7 @@ SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info = {
        .longname = "Gossen Metrawatt Metrahit 2x, BD232/SI232-II interface",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan_2x_bd232,
        .dev_list = dev_list,
        .dev_clear = NULL,
index e2d28f3f196661070869ddf90f720e51cfc0088e..2b93f10fd5d0aface3f679981e7807b45b18c597 100644 (file)
@@ -135,13 +135,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       dev_clear(di);
-
-       return SR_OK;
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -262,7 +255,7 @@ SR_PRIV struct sr_dev_driver gwinstek_gds_800_driver_info = {
        .longname = "GW Instek GDS-800 series",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index a9bcca8c1703c9b1ec8525b65c85c8e5c2298c9c..2ea5ca79efaf3c8ab3694f9292138e78976553c4 100644 (file)
@@ -166,13 +166,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       dev_clear(di);
-
-       return SR_OK;
-}
-
 static int check_channel_group(struct dev_context *devc,
                             const struct sr_channel_group *cg)
 {
@@ -790,7 +783,7 @@ SR_PRIV struct sr_dev_driver hameg_hmo_driver_info = {
        .longname = "Hameg HMO",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index bdc10af4d9655268aab8bedc4714e64af1db20bf..4d15383406b8dfe213901dbf44a77cd5124d3ecb 100644 (file)
@@ -328,11 +328,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -824,7 +819,7 @@ SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info = {
        .longname = "Hantek 6xxx",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index b88a902b25c718323ebd11c049f5279b4efcb9f6..10e5193994cd75a96b9bdae00984a0451ac8ffa2 100644 (file)
@@ -418,11 +418,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -1015,7 +1010,7 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
        .longname = "Hantek DSO",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index b152be9236427aafa61f02fcfc051c18d8128852..19188e39d9b1e3fd6b4ec2785df257ac7c41c361 100644 (file)
@@ -244,11 +244,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
@@ -462,7 +457,7 @@ SR_PRIV struct sr_dev_driver hp_3457a_driver_info = {
        .longname = "HP 3457A",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index fecd593c375f4b4803cc378fef3ef30eca0ff575..55b9922b3a24fe736383ce2924380bf6b1369344 100644 (file)
@@ -311,18 +311,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       struct drv_context *drvc = di->context;
-       int ret;
-
-       ret = dev_clear(di);
-
-       g_free(drvc);
-
-       return ret;
-}
-
 static int find_in_array(GVariant *data, const GVariantType *type,
                         const void *arr, int n)
 {
@@ -741,7 +729,7 @@ SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = {
        .longname = "Hung-Chang DSO-2100",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index f7480db3d4c06ac3e80ba3d3691453c2cf428b8d..a9d3fcb74bb600c84c376a4cdda254795ca79bf2 100644 (file)
@@ -281,11 +281,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -489,7 +484,7 @@ SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info = {
        .longname = "IKALOGIC Scanalogic-2",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index ec649d41f582fd4f8295c99320622e8c7897efa3..2bdf28d954cf19469c6bf64d7df8eb1f7a31a1f5 100644 (file)
@@ -261,11 +261,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return ret;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -398,7 +393,7 @@ SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info = {
        .longname = "IKALOGIC ScanaPLUS",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 1214fadbe1662e4a821bb4d5232994ac97d2687e..d30f1604ec8aaaeea00e008902038125a5a6e1eb 100644 (file)
@@ -227,21 +227,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       int ret;
-       struct drv_context *drvc;
-
-       if (!(drvc = di->context))
-               /* Can get called on an unused driver, doesn't matter. */
-               return SR_OK;
-
-       ret = std_dev_clear(di, NULL);
-       g_free(drvc);
-
-       return ret;
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -550,7 +535,7 @@ SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info = {
        .longname = "Kecheng KC-330B",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 6a0351580383e419fa7643738c67a073f5042e7b..3ab8857b2c5122e2d8e8371af8818354abb3dbea 100644 (file)
@@ -129,11 +129,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -225,7 +220,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        .longname = VENDOR " " MODEL, \
                        .api_version = 1, \
                        .init = init, \
-                       .cleanup = cleanup, \
+                       .cleanup = std_cleanup, \
                        .scan = scan, \
                        .dev_list = dev_list, \
                        .dev_clear = dev_clear, \
index 5aa5b217cd2f09e888202e23a65173cb8503b7cb..f5c63f9fcf7687db323b1382566dfaf7bbf11138 100644 (file)
@@ -188,12 +188,6 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear(di, NULL);
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       dev_clear(di);
-       return SR_OK;
-}
-
 static int config_get(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
@@ -419,7 +413,7 @@ SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info = {
        .longname = "Korad KAxxxxP",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index d2ed3033f8499e9a91ddd0e7e4aebf997b251ab1..6244172098f4eed6bdabab0294e80cb93e702d11 100644 (file)
@@ -144,21 +144,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       int ret;
-       struct drv_context *drvc;
-
-       if (!(drvc = di->context))
-               /* Can get called on an unused driver, doesn't matter. */
-               return SR_OK;
-
-       ret = std_dev_clear(di, NULL);
-       g_free(drvc);
-
-       return ret;
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -470,7 +455,7 @@ SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info = {
        .longname = "Lascar EL-USB",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index b6eff9dd2e138da5400fe0bdfc8cedb2e65cbef1..06f9b503d3d9004186b5e638bd576c767cbb35c3 100644 (file)
@@ -380,20 +380,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       struct drv_context *drvc;
-       int ret;
-
-       drvc = di->context;
-
-       ret = dev_clear(di);
-
-       g_free(drvc);
-
-       return ret;
-}
-
 static int config_get(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
@@ -541,7 +527,7 @@ SR_PRIV struct sr_dev_driver lecroy_logicstudio_driver_info = {
        .longname = "LeCroy LogicStudio",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index e0791acc86ec5e0a209903c128fccfa6c4bd5809..5107d309f0d15ec172fa36ec60a0db0ac71199ab 100644 (file)
@@ -264,11 +264,6 @@ static int dev_open(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear();
-}
-
 static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -470,7 +465,7 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
        .longname = "Link Instruments MSO-19",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index cc9ab74a0283d906f0fcb128f057e583b89a3791..72091de41d271bef5a86fdfdff71d08328241a39 100644 (file)
@@ -210,11 +210,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -423,7 +418,7 @@ SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info = {
        .longname = "Manson HCS-3xxx",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index d275760abc5ba9b7f8e41d2f2212567278698678..d2212ca650b6701f07e9819893d18fad39e583e3 100644 (file)
@@ -253,11 +253,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -496,7 +491,7 @@ SR_PRIV struct sr_dev_driver maynuo_m97_driver_info = {
        .longname = "maynuo M97/M98 series",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index b8e694653ee0f66a017575a8d0feb244067a5bf5..07d2a8e197755b56b6c416a34062bf898e0c3f99 100644 (file)
@@ -150,11 +150,6 @@ static GSList *dev_list(int idx)
        return ((struct drv_context *)(mic_devs[idx].di->context))->instances;
 }
 
-static int cleanup(int idx)
-{
-       return dev_clear(idx);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -244,9 +239,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 #define HW_INIT(X) \
 static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \
        (void)di; return init(sr_ctx, X); }
-#define HW_CLEANUP(X) \
-static int cleanup_##X(const struct sr_dev_driver *di) { \
-       (void)di; return cleanup(X); }
 #define HW_SCAN(X) \
 static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \
        (void)di; return scan(options, X); }
@@ -267,7 +259,6 @@ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
 /* Driver structs and API function wrappers */
 #define DRV(ID, ID_UPPER, NAME, LONGNAME) \
 HW_INIT(ID_UPPER) \
-HW_CLEANUP(ID_UPPER) \
 HW_SCAN(ID_UPPER) \
 HW_DEV_LIST(ID_UPPER) \
 HW_DEV_CLEAR(ID_UPPER) \
@@ -278,7 +269,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .longname = LONGNAME, \
        .api_version = 1, \
        .init = init_##ID_UPPER, \
-       .cleanup = cleanup_##ID_UPPER, \
+       .cleanup = std_cleanup, \
        .scan = scan_##ID_UPPER, \
        .dev_list = dev_list_##ID_UPPER, \
        .dev_clear = dev_clear_##ID_UPPER, \
index 7f9c33f68d43943fb0fc47cdf6394bb2fe3b61cb..693f6e4a85baff11fe1a03e2d3c268e6700d0b0a 100644 (file)
@@ -538,11 +538,6 @@ static int dev_clear_lps301(const struct sr_dev_driver *di)
        return std_dev_clear(di, (std_dev_clear_callback)dev_clear_private);
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear_lps301(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -840,7 +835,7 @@ SR_PRIV struct sr_dev_driver motech_lps_301_driver_info = {
        .longname = "Motech LPS-301",
        .api_version = 1,
        .init = init_lps301,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan_lps301,
        .dev_list = dev_list_lps301,
        .dev_clear = dev_clear_lps301,
index 8a93f790dcc740d17963e7f854784d9f0a083dd6..67735d49da30418dd229b91322e90e24f7dd91e3 100644 (file)
@@ -193,11 +193,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -290,7 +285,7 @@ SR_PRIV struct sr_dev_driver norma_dmm_driver_info = {
        .longname = "Norma DM9x0 DMMs",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
@@ -309,7 +304,7 @@ SR_PRIV struct sr_dev_driver siemens_b102x_driver_info = {
        .longname = "Siemens B102x DMMs",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index cb687568505a3c7f2bfb40a954f1c538d909c49a..c50509bacc716898aa3d5cb6fa2e732b3454e1d8 100644 (file)
@@ -215,11 +215,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -592,7 +587,7 @@ SR_PRIV struct sr_dev_driver ols_driver_info = {
        .longname = "Openbench Logic Sniffer",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index c9a14931e2f69eeffa6d0a02f645ea95e81e7f51..86ad7f9f1817583df1fbc89f2640ce81fca841cd 100644 (file)
@@ -220,11 +220,6 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear(di, clear_helper);
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -722,7 +717,7 @@ SR_PRIV struct sr_dev_driver p_ols_driver_info = {
        .longname = "Pipistrello OLS",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 8c3282779abeae19cc9684494f43e13e07aeb637..d8ad1a06887c778c0822053f912881fa844aa25b 100644 (file)
@@ -459,11 +459,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int analog_frame_size(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc = sdi->priv;
@@ -1072,7 +1067,7 @@ SR_PRIV struct sr_dev_driver rigol_ds_driver_info = {
        .longname = "Rigol DS",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index dbd85fb3b2233862734d61722724b22c0128714c..4450a22cc1e08bcf894ed1526330ec51d05c0879 100644 (file)
@@ -402,21 +402,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       int ret;
-       struct drv_context *drvc;
-
-       if (!(drvc = di->context))
-               /* Can get called on an unused driver, doesn't matter. */
-               return SR_OK;
-
-       ret = std_dev_clear(di, NULL);
-       g_free(drvc);
-
-       return ret;
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -817,7 +802,7 @@ SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = {
        .longname = "Saleae Logic16",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 111d76b064b2ef8f5507191a1addfcb0601d1e3c..e2afad3bead0f9ce016e8910ebf4b27404c78314 100644 (file)
@@ -247,11 +247,6 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear(di, clear_helper);
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -642,7 +637,7 @@ SR_PRIV struct sr_dev_driver scpi_pps_driver_info = {
        .longname = "SCPI PPS",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index f505876402ff22549ab768c3a457083bd22b8044..6b32f6485ec60b43bcf90e98db69f2f140e402e8 100644 (file)
@@ -155,11 +155,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -253,7 +248,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        .longname = VENDOR " " MODEL, \
                        .api_version = 1, \
                        .init = init, \
-                       .cleanup = cleanup, \
+                       .cleanup = std_cleanup, \
                        .scan = scan, \
                        .dev_list = dev_list, \
                        .dev_clear = dev_clear, \
index 8ee85a62be0c08aa0ec214798fdce4757c52e71d..be7c9ee72bca13391fe4d79512e87dd1ef3c5dd8 100644 (file)
@@ -803,7 +803,7 @@ SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info = {
        .longname = "SysClk LWLA series",
        .api_version = 1,
        .init = init,
-       .cleanup = dev_clear,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 7af74b031dca42efaf4d349b3dcfb2b741c345bc..245f550119421921f2bad753b0ffdb093f77b2b0 100644 (file)
@@ -138,11 +138,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -232,7 +227,7 @@ SR_PRIV struct sr_dev_driver teleinfo_driver_info = {
        .longname = "Teleinfo",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index c43c3c7eb803fd43ddf2acada10f4976196be1d4..fb3f8b64ce6c56312d327d73337f4bf92d74ee11 100644 (file)
@@ -230,20 +230,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       int ret;
-       struct drv_context *drvc;
-
-       if (!(drvc = di->context))
-               return SR_OK;
-
-       ret = dev_clear(di);
-       g_free(drvc);
-
-       return ret;
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -518,7 +504,7 @@ SR_PRIV struct sr_dev_driver testo_driver_info = {
        .longname = "Testo",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index d6d6f1e7efba6e7be30fbd30700b100898f5577d..1d067e3989888d85cc0891182b39c2bd4415ce83 100644 (file)
@@ -111,11 +111,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
        return ((struct drv_context *)(di->context))->instances;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -189,7 +184,7 @@ SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = {
        .longname = "Tondaj SL-814",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index a77aebbae5cc320fc5de61e3bc201f1c3ef09f00..3eef3aa29494cfc8a2ad765f180da09fc45e6ba6 100644 (file)
@@ -139,11 +139,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return dev_clear(di);
-}
-
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -221,7 +216,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
                        .longname = VENDOR " " MODEL, \
                        .api_version = 1, \
                        .init = init, \
-                       .cleanup = cleanup, \
+                       .cleanup = std_cleanup, \
                        .scan = scan, \
                        .dev_list = dev_list, \
                        .dev_clear = dev_clear, \
index fe75241537aa13eb385e59a607dc10a8c60ba652..13c2a637303e9920a39c0cb40306fc47091f0fdc 100644 (file)
@@ -171,21 +171,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       int ret;
-       struct drv_context *drvc;
-
-       if (!(drvc = di->context))
-               /* Can get called on an unused driver, doesn't matter. */
-               return SR_OK;
-
-       ret = std_dev_clear(di, NULL);
-       g_free(drvc);
-
-       return ret;
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -349,7 +334,7 @@ SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info = {
        .longname = "UNI-T UT32x",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 1bc034424a1784e745f38917715d1c6a5cd87cb6..023388f4f345705eb1db72d9d71cd0c6ae04fdee 100644 (file)
@@ -183,21 +183,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       int ret;
-       struct drv_context *drvc;
-
-       if (!(drvc = di->context))
-               /* Can get called on an unused driver, doesn't matter. */
-               return SR_OK;
-
-       ret = std_dev_clear(di, NULL);
-       g_free(drvc);
-
-       return ret;
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -426,7 +411,7 @@ SR_PRIV struct sr_dev_driver victor_dmm_driver_info = {
        .longname = "Victor DMMs",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index 34801afe02461cfc04a85807bfde0444997f1de2..25a292ad5f9691256e1b1132ebd64df4e69fd343 100644 (file)
@@ -176,13 +176,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       dev_clear(di);
-
-       return SR_OK;
-}
-
 /**
  * Check which category a given channel group belongs to.
  *
@@ -696,7 +689,7 @@ SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info = {
        .longname = "Yokogawa DL/DLM",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
index 22e949c98ad98d90ec51c4174cbf5750daae6d4f..f9f2ba795d6bd4185e834a226d7f98f0c156b8bc 100644 (file)
@@ -373,11 +373,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int cleanup(const struct sr_dev_driver *di)
-{
-       return std_dev_clear(di, NULL);
-}
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -706,7 +701,7 @@ SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = {
        .longname = "ZEROPLUS Logic Cube LAP-C series",
        .api_version = 1,
        .init = init,
-       .cleanup = cleanup,
+       .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = NULL,
index af08f2ab6172a0a38500898577498965ef82c0db..d859e934f7c37d57883996c818fb0155eadaf805 100644 (file)
@@ -849,6 +849,7 @@ typedef void (*std_dev_clear_callback)(void *priv);
 
 SR_PRIV int std_init(struct sr_context *sr_ctx, struct sr_dev_driver *di,
                const char *prefix);
+SR_PRIV int std_cleanup(const struct sr_dev_driver *di);
 #ifdef HAVE_LIBSERIALPORT
 SR_PRIV int std_serial_dev_open(struct sr_dev_inst *sdi);
 SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi,
index d741c80928a62f0a549d5efbe9305f7a69a33454..b66ed8f0b4884c603d4e235a972775c1a1ab40c6 100644 (file)
--- a/src/std.c
+++ b/src/std.c
@@ -63,6 +63,28 @@ SR_PRIV int std_init(struct sr_context *sr_ctx, struct sr_dev_driver *di,
        return SR_OK;
 }
 
+/**
+ * Standard driver cleanup() callback API helper
+ *
+ * @param di The driver instance to use.
+ *
+ * Frees all device instances by calling sr_dev_clear() and then releases any
+ * resources allocated by std_init().
+ *
+ * @retval SR_OK Success
+ * @retval SR_ERR_ARG Invalid driver
+ *
+*/
+SR_PRIV int std_cleanup(const struct sr_dev_driver *di)
+{
+       int ret;
+
+       ret = sr_dev_clear(di);
+       g_free(di->context);
+
+       return ret;
+}
+
 /**
  * Standard API helper for sending an SR_DF_HEADER packet.
  *