From: Lars-Peter Clausen Date: Fri, 29 Apr 2016 13:47:04 +0000 (+0200) Subject: Introduce standard implementation of the dev_list() callback X-Git-Tag: libsigrok-0.5.0~464 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c01bf34ca264b268fee2e71ab918c71d28dc3018;p=libsigrok.git Introduce standard implementation of the dev_list() callback Every single hardware driver has the very same implementation of the dev_list() callback. Put this into a helper function in the standard helper library and use it throughout the drivers. This reduces boiler-plate code by quite a bit. Signed-off-by: Lars-Peter Clausen --- diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index d2a11cc7..4ce966d9 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -161,11 +161,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -251,7 +246,7 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index 27b4399a..cdf30af8 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -121,11 +121,6 @@ scan_cleanup: return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -261,7 +256,7 @@ SR_PRIV struct sr_dev_driver appa_55ii_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/arachnid-labs-re-load-pro/api.c b/src/hardware/arachnid-labs-re-load-pro/api.c index 323f7cf5..5a6ad007 100644 --- a/src/hardware/arachnid-labs-re-load-pro/api.c +++ b/src/hardware/arachnid-labs-re-load-pro/api.c @@ -164,11 +164,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -377,7 +372,7 @@ SR_PRIV struct sr_dev_driver arachnid_labs_re_load_pro_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/asix-sigma/api.c b/src/hardware/asix-sigma/api.c index 25b5cad3..77e989a9 100644 --- a/src/hardware/asix-sigma/api.c +++ b/src/hardware/asix-sigma/api.c @@ -146,11 +146,6 @@ free: return NULL; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -422,7 +417,7 @@ SR_PRIV struct sr_dev_driver asix_sigma_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/atten-pps3xxx/api.c b/src/hardware/atten-pps3xxx/api.c index ce0531c9..85a32a4a 100644 --- a/src/hardware/atten-pps3xxx/api.c +++ b/src/hardware/atten-pps3xxx/api.c @@ -199,11 +199,6 @@ static GSList *scan_3203(struct sr_dev_driver *di, GSList *options) return scan(di, options, PPS_3203T_3S); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -504,7 +499,7 @@ SR_PRIV struct sr_dev_driver atten_pps3203_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan_3203, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/baylibre-acme/api.c b/src/hardware/baylibre-acme/api.c index cdf9968b..b4a7f8c6 100644 --- a/src/hardware/baylibre-acme/api.c +++ b/src/hardware/baylibre-acme/api.c @@ -142,11 +142,6 @@ err_out: return NULL; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { (void)sdi; @@ -412,7 +407,7 @@ SR_PRIV struct sr_dev_driver baylibre_acme_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index cba429ca..8694d8fd 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -145,11 +145,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; @@ -375,7 +370,7 @@ SR_PRIV struct sr_dev_driver beaglelogic_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index 8b6f5ee3..87c328d9 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -92,11 +92,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; @@ -281,7 +276,7 @@ SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/brymen-dmm/api.c b/src/hardware/brymen-dmm/api.c index 9868cdf1..a4f96a44 100644 --- a/src/hardware/brymen-dmm/api.c +++ b/src/hardware/brymen-dmm/api.c @@ -131,11 +131,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -230,7 +225,7 @@ SR_PRIV struct sr_dev_driver brymen_bm857_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, diff --git a/src/hardware/cem-dt-885x/api.c b/src/hardware/cem-dt-885x/api.c index 59137d6d..9eb8bf06 100644 --- a/src/hardware/cem-dt-885x/api.c +++ b/src/hardware/cem-dt-885x/api.c @@ -136,11 +136,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -399,7 +394,7 @@ SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/center-3xx/api.c b/src/hardware/center-3xx/api.c index 7f08d9da..2e72cc96 100644 --- a/src/hardware/center-3xx/api.c +++ b/src/hardware/center-3xx/api.c @@ -134,11 +134,6 @@ static GSList *scan(GSList *options, int idx) return devices; } -static GSList *dev_list(int idx) -{ - return ((struct drv_context *)(center_devs[idx].di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -229,9 +224,6 @@ static int init_##X(struct sr_dev_driver *d, \ #define HW_SCAN(X) \ static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \ (void)d; return scan(options, X); } -#define HW_DEV_LIST(X) \ -static GSList *dev_list_##X(const struct sr_dev_driver *d) { \ - (void)d; return dev_list(X); } #define HW_DEV_ACQUISITION_START(X) \ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \ ) { return dev_acquisition_start(sdi, X); } @@ -240,7 +232,6 @@ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \ #define DRV(ID, ID_UPPER, NAME, LONGNAME) \ HW_INIT(ID_UPPER) \ HW_SCAN(ID_UPPER) \ -HW_DEV_LIST(ID_UPPER) \ HW_DEV_ACQUISITION_START(ID_UPPER) \ SR_PRIV struct sr_dev_driver ID##_driver_info = { \ .name = NAME, \ @@ -249,7 +240,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \ .init = init_##ID_UPPER, \ .cleanup = std_cleanup, \ .scan = scan_##ID_UPPER, \ - .dev_list = dev_list_##ID_UPPER, \ + .dev_list = std_dev_list, \ .config_get = NULL, \ .config_set = config_set, \ .config_list = config_list, \ diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index bd922d05..1e6f5f41 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -245,11 +245,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -585,7 +580,7 @@ SR_PRIV struct sr_dev_driver chronovu_la_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/colead-slm/api.c b/src/hardware/colead-slm/api.c index 4a0b61e5..880c6039 100644 --- a/src/hardware/colead-slm/api.c +++ b/src/hardware/colead-slm/api.c @@ -96,11 +96,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -183,7 +178,7 @@ SR_PRIV struct sr_dev_driver colead_slm_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, diff --git a/src/hardware/conrad-digi-35-cpu/api.c b/src/hardware/conrad-digi-35-cpu/api.c index 0195f480..92798e82 100644 --- a/src/hardware/conrad-digi-35-cpu/api.c +++ b/src/hardware/conrad-digi-35-cpu/api.c @@ -106,11 +106,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -200,7 +195,7 @@ SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, diff --git a/src/hardware/demo/demo.c b/src/hardware/demo/demo.c index 15a4c60d..10a3eb02 100644 --- a/src/hardware/demo/demo.c +++ b/src/hardware/demo/demo.c @@ -354,11 +354,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { sdi->status = SR_ST_ACTIVE; @@ -891,7 +886,7 @@ SR_PRIV struct sr_dev_driver demo_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/deree-de5000/api.c b/src/hardware/deree-de5000/api.c index 8c24eb18..2f1109b5 100644 --- a/src/hardware/deree-de5000/api.c +++ b/src/hardware/deree-de5000/api.c @@ -35,11 +35,6 @@ static void std_dev_attach(struct sr_dev_driver *di, struct sr_dev_inst *sdi) drvc->instances = g_slist_append(drvc->instances, sdi); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)di->context)->instances; -} - #define LOG_PREFIX "deree-de5000" SR_PRIV struct sr_dev_driver deree_de5000_driver_info; @@ -73,7 +68,7 @@ SR_PRIV struct sr_dev_driver deree_de5000_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = es51919_serial_config_get, .config_set = es51919_serial_config_set, diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c index dc55aa41..b352355c 100644 --- a/src/hardware/fluke-dmm/api.c +++ b/src/hardware/fluke-dmm/api.c @@ -189,11 +189,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -286,7 +281,7 @@ SR_PRIV struct sr_dev_driver flukedmm_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, diff --git a/src/hardware/ftdi-la/api.c b/src/hardware/ftdi-la/api.c index 547e25e4..a2cc4a75 100644 --- a/src/hardware/ftdi-la/api.c +++ b/src/hardware/ftdi-la/api.c @@ -263,11 +263,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return scan_all(di, options); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static void clear_helper(void *priv) { struct dev_context *devc; @@ -499,7 +494,7 @@ SR_PRIV struct sr_dev_driver ftdi_la_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index fcc98fa9..368873ab 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -399,11 +399,6 @@ static int dev_clear(const struct sr_dev_driver *di) return std_dev_clear(di, clear_dev_context); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; @@ -899,7 +894,7 @@ SR_PRIV struct sr_dev_driver fx2lafw_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index b8f71c2f..2f0f671c 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -351,11 +351,6 @@ exit_err: return NULL; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_close(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -526,7 +521,7 @@ SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan_1x_2x_rs232, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, @@ -545,7 +540,7 @@ SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan_2x_bd232, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/gwinstek-gds-800/api.c b/src/hardware/gwinstek-gds-800/api.c index c26ec261..0da6760a 100644 --- a/src/hardware/gwinstek-gds-800/api.c +++ b/src/hardware/gwinstek-gds-800/api.c @@ -93,11 +93,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, probe_device); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { int ret; @@ -252,7 +247,7 @@ SR_PRIV struct sr_dev_driver gwinstek_gds_800_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index 2ea5ca79..b810b9f1 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -117,11 +117,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, hmo_probe_serial_device); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static void clear_helper(void *priv) { struct dev_context *devc; @@ -785,7 +780,7 @@ SR_PRIV struct sr_dev_driver hameg_hmo_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/hantek-6xxx/api.c b/src/hardware/hantek-6xxx/api.c index 4d153834..1d600648 100644 --- a/src/hardware/hantek-6xxx/api.c +++ b/src/hardware/hantek-6xxx/api.c @@ -267,11 +267,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -821,7 +816,7 @@ SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index 10e51939..ddea8084 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -358,11 +358,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -1012,7 +1007,7 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/hp-3457a/api.c b/src/hardware/hp-3457a/api.c index 1a5e5d92..129e1e59 100644 --- a/src/hardware/hp-3457a/api.c +++ b/src/hardware/hp-3457a/api.c @@ -176,11 +176,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, probe_device); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - /* * We need to set the HP 3457A to a known state, and there are quite a number * of knobs to tweak. Here's a brief explanation of what's going on. For more @@ -454,7 +449,7 @@ SR_PRIV struct sr_dev_driver hp_3457a_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/hung-chang-dso-2100/api.c b/src/hardware/hung-chang-dso-2100/api.c index 55b9922b..791fd5d6 100644 --- a/src/hardware/hung-chang-dso-2100/api.c +++ b/src/hardware/hung-chang-dso-2100/api.c @@ -230,11 +230,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static void clear_private(void *priv) { struct dev_context *devc = priv; @@ -731,7 +726,7 @@ SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c index a9d3fcb7..dd2e4211 100644 --- a/src/hardware/ikalogic-scanalogic2/api.c +++ b/src/hardware/ikalogic-scanalogic2/api.c @@ -162,11 +162,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static void clear_dev_context(void *priv) { struct dev_context *devc; @@ -486,7 +481,7 @@ SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index 2bdf28d9..8c8ee13f 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -149,11 +149,6 @@ err_free_devc: return NULL; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -395,7 +390,7 @@ SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/kecheng-kc-330b/api.c b/src/hardware/kecheng-kc-330b/api.c index d30f1604..15c43b1b 100644 --- a/src/hardware/kecheng-kc-330b/api.c +++ b/src/hardware/kecheng-kc-330b/api.c @@ -160,11 +160,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; @@ -537,7 +532,7 @@ SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/kern-scale/api.c b/src/hardware/kern-scale/api.c index e16bf596..c38e515f 100644 --- a/src/hardware/kern-scale/api.c +++ b/src/hardware/kern-scale/api.c @@ -119,11 +119,6 @@ scan_cleanup: return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -217,7 +212,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) .init = init, \ .cleanup = std_cleanup, \ .scan = scan, \ - .dev_list = dev_list, \ + .dev_list = std_dev_list, \ .config_get = NULL, \ .config_set = config_set, \ .config_list = config_list, \ diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c index 26b1ee8e..f60d0d69 100644 --- a/src/hardware/korad-kaxxxxp/api.c +++ b/src/hardware/korad-kaxxxxp/api.c @@ -178,11 +178,6 @@ exit_err: return NULL; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -410,7 +405,7 @@ SR_PRIV struct sr_dev_driver korad_kaxxxxp_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/lascar-el-usb/api.c b/src/hardware/lascar-el-usb/api.c index 62441720..fb9d1930 100644 --- a/src/hardware/lascar-el-usb/api.c +++ b/src/hardware/lascar-el-usb/api.c @@ -89,11 +89,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; @@ -457,7 +452,7 @@ SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/lecroy-logicstudio/api.c b/src/hardware/lecroy-logicstudio/api.c index 458be366..9cf7018e 100644 --- a/src/hardware/lecroy-logicstudio/api.c +++ b/src/hardware/lecroy-logicstudio/api.c @@ -191,11 +191,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int open_device(struct sr_dev_inst *sdi) { struct drv_context *drvc; @@ -524,7 +519,7 @@ SR_PRIV struct sr_dev_driver lecroy_logicstudio_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index 5107d309..faee455c 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -228,11 +228,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { int ret; @@ -467,7 +462,7 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c index d3901954..f803c2b8 100644 --- a/src/hardware/manson-hcs-3xxx/api.c +++ b/src/hardware/manson-hcs-3xxx/api.c @@ -200,11 +200,6 @@ exit_err: return NULL; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -415,7 +410,7 @@ SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/maynuo-m97/api.c b/src/hardware/maynuo-m97/api.c index 5716d3bd..3878e6f9 100644 --- a/src/hardware/maynuo-m97/api.c +++ b/src/hardware/maynuo-m97/api.c @@ -199,11 +199,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_modbus_dev_inst *modbus = sdi->conn; @@ -488,7 +483,7 @@ SR_PRIV struct sr_dev_driver maynuo_m97_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/mic-985xx/api.c b/src/hardware/mic-985xx/api.c index 2bf20627..8e1bba8d 100644 --- a/src/hardware/mic-985xx/api.c +++ b/src/hardware/mic-985xx/api.c @@ -140,11 +140,6 @@ static GSList *scan(GSList *options, int idx) return devices; } -static GSList *dev_list(int idx) -{ - return ((struct drv_context *)(mic_devs[idx].di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -237,9 +232,6 @@ static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \ #define HW_SCAN(X) \ static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \ (void)di; return scan(options, X); } -#define HW_DEV_LIST(X) \ -static GSList *dev_list_##X(const struct sr_dev_driver *di) { \ - (void)di; return dev_list(X); } #define HW_CONFIG_LIST(X) \ static int config_list_##X(uint32_t key, GVariant **data, \ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { \ @@ -252,7 +244,6 @@ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \ #define DRV(ID, ID_UPPER, NAME, LONGNAME) \ HW_INIT(ID_UPPER) \ HW_SCAN(ID_UPPER) \ -HW_DEV_LIST(ID_UPPER) \ HW_CONFIG_LIST(ID_UPPER) \ HW_DEV_ACQUISITION_START(ID_UPPER) \ SR_PRIV struct sr_dev_driver ID##_driver_info = { \ @@ -262,7 +253,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \ .init = init_##ID_UPPER, \ .cleanup = std_cleanup, \ .scan = scan_##ID_UPPER, \ - .dev_list = dev_list_##ID_UPPER, \ + .dev_list = std_dev_list, \ .config_get = NULL, \ .config_set = config_set, \ .config_list = config_list_##ID_UPPER, \ diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c index 693f6e4a..4bda494a 100644 --- a/src/hardware/motech-lps-30x/api.c +++ b/src/hardware/motech-lps-30x/api.c @@ -517,11 +517,6 @@ static GSList *scan_lps301(struct sr_dev_driver *di, GSList *options) return do_scan(LPS_301, di, options); } -static GSList *dev_list_lps301(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static void dev_clear_private(struct dev_context *devc) { int ch_idx; @@ -837,7 +832,7 @@ SR_PRIV struct sr_dev_driver motech_lps_301_driver_info = { .init = init_lps301, .cleanup = std_cleanup, .scan = scan_lps301, - .dev_list = dev_list_lps301, + .dev_list = std_dev_list, .dev_clear = dev_clear_lps301, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/norma-dmm/api.c b/src/hardware/norma-dmm/api.c index 67735d49..a48ef6a2 100644 --- a/src/hardware/norma-dmm/api.c +++ b/src/hardware/norma-dmm/api.c @@ -172,11 +172,6 @@ static GSList *scan(struct sr_dev_driver *drv, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_close(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -287,7 +282,7 @@ SR_PRIV struct sr_dev_driver norma_dmm_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, @@ -306,7 +301,7 @@ SR_PRIV struct sr_dev_driver siemens_b102x_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, diff --git a/src/hardware/openbench-logic-sniffer/api.c b/src/hardware/openbench-logic-sniffer/api.c index c50509ba..9a96e234 100644 --- a/src/hardware/openbench-logic-sniffer/api.c +++ b/src/hardware/openbench-logic-sniffer/api.c @@ -210,11 +210,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -589,7 +584,7 @@ SR_PRIV struct sr_dev_driver ols_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index 86ad7f9f..a2b01dce 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -200,11 +200,6 @@ err_free_ftdi_buf: return NULL; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static void clear_helper(void *priv) { struct dev_context *devc; @@ -719,7 +714,7 @@ SR_PRIV struct sr_dev_driver p_ols_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index d8ad1a06..f38ad8db 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -411,11 +411,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, probe_device); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { int ret; @@ -1069,7 +1064,7 @@ SR_PRIV struct sr_dev_driver rigol_ds_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/saleae-logic16/api.c b/src/hardware/saleae-logic16/api.c index 4450a22c..4990ce82 100644 --- a/src/hardware/saleae-logic16/api.c +++ b/src/hardware/saleae-logic16/api.c @@ -235,11 +235,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int logic16_dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di; @@ -804,7 +799,7 @@ SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index e2afad3b..5fd83d4e 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -176,11 +176,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, probe_device); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -639,7 +634,7 @@ SR_PRIV struct sr_dev_driver scpi_pps_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index f29a0e0b..a9de0674 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -145,11 +145,6 @@ scan_cleanup: return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -245,7 +240,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) .init = init, \ .cleanup = std_cleanup, \ .scan = scan, \ - .dev_list = dev_list, \ + .dev_list = std_dev_list, \ .config_get = NULL, \ .config_set = config_set, \ .config_list = config_list, \ diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index be7c9ee7..59d12633 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -212,13 +212,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -/* Return the list of devices found during scan. - */ -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - /* Destroy the private device context. */ static void clear_dev_context(void *priv) @@ -805,7 +798,7 @@ SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/teleinfo/api.c b/src/hardware/teleinfo/api.c index 245f5501..302373d6 100644 --- a/src/hardware/teleinfo/api.c +++ b/src/hardware/teleinfo/api.c @@ -133,11 +133,6 @@ scan_cleanup: return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -229,7 +224,7 @@ SR_PRIV struct sr_dev_driver teleinfo_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, diff --git a/src/hardware/testo/api.c b/src/hardware/testo/api.c index 6e3511c0..d0e60237 100644 --- a/src/hardware/testo/api.c +++ b/src/hardware/testo/api.c @@ -146,11 +146,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; @@ -501,7 +496,7 @@ SR_PRIV struct sr_dev_driver testo_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, diff --git a/src/hardware/tondaj-sl-814/api.c b/src/hardware/tondaj-sl-814/api.c index 1d067e39..5b1a85f9 100644 --- a/src/hardware/tondaj-sl-814/api.c +++ b/src/hardware/tondaj-sl-814/api.c @@ -106,11 +106,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - 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 tondaj_sl_814_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = NULL, .config_set = config_set, diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index 7e55d857..b4e667c5 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -103,11 +103,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di; @@ -213,7 +208,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) .init = init, \ .cleanup = std_cleanup, \ .scan = scan, \ - .dev_list = dev_list, \ + .dev_list = std_dev_list, \ .config_get = NULL, \ .config_set = config_set, \ .config_list = config_list, \ diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index 13c2a637..f19dabef 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -98,11 +98,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; @@ -336,7 +331,7 @@ SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/victor-dmm/api.c b/src/hardware/victor-dmm/api.c index 023388f4..9323e700 100644 --- a/src/hardware/victor-dmm/api.c +++ b/src/hardware/victor-dmm/api.c @@ -101,11 +101,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; @@ -413,7 +408,7 @@ SR_PRIV struct sr_dev_driver victor_dmm_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index 25a292ad..082c0179 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -128,11 +128,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, probe_usbtmc_device); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static void clear_helper(void *priv) { struct dev_context *devc; @@ -691,7 +686,7 @@ SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index f9f2ba79..1081b81c 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -256,11 +256,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - static int dev_open(struct sr_dev_inst *sdi) { struct sr_dev_driver *di = sdi->driver; @@ -703,7 +698,7 @@ SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = { .init = init, .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, + .dev_list = std_dev_list, .dev_clear = NULL, .config_get = config_get, .config_set = config_set, diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index d859e934..0af77db6 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -862,6 +862,7 @@ SR_PRIV int std_session_send_df_end(const struct sr_dev_inst *sdi, const char *prefix); SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, std_dev_clear_callback clear_private); +SR_PRIV GSList *std_dev_list(const struct sr_dev_driver *di); SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi); /*--- resource.c ------------------------------------------------------------*/ diff --git a/src/std.c b/src/std.c index b66ed8f0..aadf8236 100644 --- a/src/std.c +++ b/src/std.c @@ -337,3 +337,22 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, return ret; } + +/** + * Standard implementation for the driver dev_list() callback + * + * This function can be used as the dev_list callback by most drivers that use + * the standard helper functions. It returns the devices contained in the driver + * context instances list. + * + * @param di The driver instance to use. + * + * @return The list of devices/instances of this driver, or NULL upon errors + * or if the list is empty. + */ +SR_PRIV GSList *std_dev_list(const struct sr_dev_driver *di) +{ + struct drv_context *drvc = di->context; + + return drvc->instances; +}