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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2016-04-29 15:47:04 +02:00
parent 88a0265ebc
commit c01bf34ca2
56 changed files with 76 additions and 336 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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, \

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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, \

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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, \

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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, \

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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, \

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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 ------------------------------------------------------------*/

View File

@ -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;
}