Introduce standard cleanup helper

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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2016-04-29 13:36:05 +02:00
parent 1e726f568d
commit 700d6b64d5
56 changed files with 79 additions and 427 deletions

View File

@ -166,11 +166,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -254,7 +249,7 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = {
.longname = "Agilent U12xx series DMMs", .longname = "Agilent U12xx series DMMs",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -126,11 +126,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -264,7 +259,7 @@ SR_PRIV struct sr_dev_driver appa_55ii_driver_info = {
.longname = "APPA 55II", .longname = "APPA 55II",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -174,11 +174,6 @@ static int dev_clear(const struct sr_dev_driver *di)
return std_dev_clear(di, NULL); 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, static int config_list(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) 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", .longname = "Arachnid Labs Re:load Pro",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -188,11 +188,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -425,7 +420,7 @@ SR_PRIV struct sr_dev_driver asix_sigma_driver_info = {
.longname = "ASIX SIGMA/SIGMA2", .longname = "ASIX SIGMA/SIGMA2",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -204,11 +204,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -507,7 +502,7 @@ SR_PRIV struct sr_dev_driver atten_pps3203_driver_info = {
.longname = "Atten PPS3203T-3S", .longname = "Atten PPS3203T-3S",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan_3203, .scan = scan_3203,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -170,13 +170,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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)", .longname = "BayLibre ACME (Another Cute Measurement Equipment)",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -200,11 +200,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -383,7 +378,7 @@ SR_PRIV struct sr_dev_driver beaglelogic_driver_info = {
.longname = "BeagleLogic", .longname = "BeagleLogic",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -172,11 +172,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return ret; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -284,7 +279,7 @@ SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info = {
.longname = "Brymen BM86X", .longname = "Brymen BM86X",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -136,11 +136,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -233,7 +228,7 @@ SR_PRIV struct sr_dev_driver brymen_bm857_driver_info = {
.longname = "Brymen BM857", .longname = "Brymen BM857",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -141,11 +141,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "CEM DT-885x",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -144,11 +144,6 @@ static GSList *dev_list(int idx)
return ((struct drv_context *)(center_devs[idx].di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -236,9 +231,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
#define HW_INIT(X) \ #define HW_INIT(X) \
static int init_##X(struct sr_dev_driver *d, \ static int init_##X(struct sr_dev_driver *d, \
struct sr_context *sr_ctx) { (void)d; return init(sr_ctx, X); } 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) \ #define HW_SCAN(X) \
static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \ static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \
(void)d; return scan(options, X); } (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 */ /* Driver structs and API function wrappers */
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \ #define DRV(ID, ID_UPPER, NAME, LONGNAME) \
HW_INIT(ID_UPPER) \ HW_INIT(ID_UPPER) \
HW_CLEANUP(ID_UPPER) \
HW_SCAN(ID_UPPER) \ HW_SCAN(ID_UPPER) \
HW_DEV_LIST(ID_UPPER) \ HW_DEV_LIST(ID_UPPER) \
HW_DEV_CLEAR(ID_UPPER) \ HW_DEV_CLEAR(ID_UPPER) \
@ -265,7 +256,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
.longname = LONGNAME, \ .longname = LONGNAME, \
.api_version = 1, \ .api_version = 1, \
.init = init_##ID_UPPER, \ .init = init_##ID_UPPER, \
.cleanup = cleanup_##ID_UPPER, \ .cleanup = std_cleanup, \
.scan = scan_##ID_UPPER, \ .scan = scan_##ID_UPPER, \
.dev_list = dev_list_##ID_UPPER, \ .dev_list = dev_list_##ID_UPPER, \
.dev_clear = dev_clear_##ID_UPPER, \ .dev_clear = dev_clear_##ID_UPPER, \

View File

@ -323,11 +323,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -588,7 +583,7 @@ SR_PRIV struct sr_dev_driver chronovu_la_driver_info = {
.longname = "ChronoVu LA8/LA16", .longname = "ChronoVu LA8/LA16",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -101,11 +101,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -186,7 +181,7 @@ SR_PRIV struct sr_dev_driver colead_slm_driver_info = {
.longname = "Colead SLM", .longname = "Colead SLM",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -111,11 +111,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Conrad DIGI 35 CPU",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -394,11 +394,6 @@ static int dev_clear(const struct sr_dev_driver *di)
return std_dev_clear(di, clear_helper); 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Demo driver and pattern generator",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -54,11 +54,6 @@ static int dev_clear(const struct sr_dev_driver *di)
return std_dev_clear(di, es51919_serial_clean); 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) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
@ -76,7 +71,7 @@ SR_PRIV struct sr_dev_driver deree_de5000_driver_info = {
.longname = "DER EE DE-5000", .longname = "DER EE DE-5000",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -194,11 +194,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Fluke 18x/28x series DMMs",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -348,15 +348,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) 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", .longname = "FTDI LA",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -509,21 +509,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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)", .longname = "fx2lafw (generic driver for FX2 based LAs)",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -374,11 +374,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Gossen Metrawatt Metrahit 1x/2x, RS232 interface",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan_1x_2x_rs232, .scan = scan_1x_2x_rs232,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .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", .longname = "Gossen Metrawatt Metrahit 2x, BD232/SI232-II interface",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan_2x_bd232, .scan = scan_2x_bd232,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -135,13 +135,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "GW Instek GDS-800 series",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -166,13 +166,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int check_channel_group(struct dev_context *devc,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -790,7 +783,7 @@ SR_PRIV struct sr_dev_driver hameg_hmo_driver_info = {
.longname = "Hameg HMO", .longname = "Hameg HMO",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -328,11 +328,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -824,7 +819,7 @@ SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info = {
.longname = "Hantek 6xxx", .longname = "Hantek 6xxx",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -418,11 +418,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -1015,7 +1010,7 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
.longname = "Hantek DSO", .longname = "Hantek DSO",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -244,11 +244,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) 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", .longname = "HP 3457A",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -311,18 +311,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int find_in_array(GVariant *data, const GVariantType *type,
const void *arr, int n) 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", .longname = "Hung-Chang DSO-2100",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -281,11 +281,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -489,7 +484,7 @@ SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info = {
.longname = "IKALOGIC Scanalogic-2", .longname = "IKALOGIC Scanalogic-2",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -261,11 +261,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return ret; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -398,7 +393,7 @@ SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info = {
.longname = "IKALOGIC ScanaPLUS", .longname = "IKALOGIC ScanaPLUS",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -227,21 +227,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Kecheng KC-330B",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -129,11 +129,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -225,7 +220,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
.longname = VENDOR " " MODEL, \ .longname = VENDOR " " MODEL, \
.api_version = 1, \ .api_version = 1, \
.init = init, \ .init = init, \
.cleanup = cleanup, \ .cleanup = std_cleanup, \
.scan = scan, \ .scan = scan, \
.dev_list = dev_list, \ .dev_list = dev_list, \
.dev_clear = dev_clear, \ .dev_clear = dev_clear, \

View File

@ -188,12 +188,6 @@ static int dev_clear(const struct sr_dev_driver *di)
return std_dev_clear(di, NULL); 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, static int config_get(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) 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", .longname = "Korad KAxxxxP",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -144,21 +144,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Lascar EL-USB",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -380,20 +380,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) 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", .longname = "LeCroy LogicStudio",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -264,11 +264,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Link Instruments MSO-19",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -210,11 +210,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Manson HCS-3xxx",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -253,11 +253,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "maynuo M97/M98 series",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -150,11 +150,6 @@ static GSList *dev_list(int idx)
return ((struct drv_context *)(mic_devs[idx].di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -244,9 +239,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
#define HW_INIT(X) \ #define HW_INIT(X) \
static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \ static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \
(void)di; return init(sr_ctx, X); } (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) \ #define HW_SCAN(X) \
static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \ static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \
(void)di; return scan(options, X); } (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 */ /* Driver structs and API function wrappers */
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \ #define DRV(ID, ID_UPPER, NAME, LONGNAME) \
HW_INIT(ID_UPPER) \ HW_INIT(ID_UPPER) \
HW_CLEANUP(ID_UPPER) \
HW_SCAN(ID_UPPER) \ HW_SCAN(ID_UPPER) \
HW_DEV_LIST(ID_UPPER) \ HW_DEV_LIST(ID_UPPER) \
HW_DEV_CLEAR(ID_UPPER) \ HW_DEV_CLEAR(ID_UPPER) \
@ -278,7 +269,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
.longname = LONGNAME, \ .longname = LONGNAME, \
.api_version = 1, \ .api_version = 1, \
.init = init_##ID_UPPER, \ .init = init_##ID_UPPER, \
.cleanup = cleanup_##ID_UPPER, \ .cleanup = std_cleanup, \
.scan = scan_##ID_UPPER, \ .scan = scan_##ID_UPPER, \
.dev_list = dev_list_##ID_UPPER, \ .dev_list = dev_list_##ID_UPPER, \
.dev_clear = dev_clear_##ID_UPPER, \ .dev_clear = dev_clear_##ID_UPPER, \

View 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); 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Motech LPS-301",
.api_version = 1, .api_version = 1,
.init = init_lps301, .init = init_lps301,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan_lps301, .scan = scan_lps301,
.dev_list = dev_list_lps301, .dev_list = dev_list_lps301,
.dev_clear = dev_clear_lps301, .dev_clear = dev_clear_lps301,

View File

@ -193,11 +193,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -290,7 +285,7 @@ SR_PRIV struct sr_dev_driver norma_dmm_driver_info = {
.longname = "Norma DM9x0 DMMs", .longname = "Norma DM9x0 DMMs",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,
@ -309,7 +304,7 @@ SR_PRIV struct sr_dev_driver siemens_b102x_driver_info = {
.longname = "Siemens B102x DMMs", .longname = "Siemens B102x DMMs",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -215,11 +215,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -592,7 +587,7 @@ SR_PRIV struct sr_dev_driver ols_driver_info = {
.longname = "Openbench Logic Sniffer", .longname = "Openbench Logic Sniffer",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -220,11 +220,6 @@ static int dev_clear(const struct sr_dev_driver *di)
return std_dev_clear(di, clear_helper); 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -722,7 +717,7 @@ SR_PRIV struct sr_dev_driver p_ols_driver_info = {
.longname = "Pipistrello OLS", .longname = "Pipistrello OLS",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -459,11 +459,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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) static int analog_frame_size(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc = sdi->priv; struct dev_context *devc = sdi->priv;
@ -1072,7 +1067,7 @@ SR_PRIV struct sr_dev_driver rigol_ds_driver_info = {
.longname = "Rigol DS", .longname = "Rigol DS",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -402,21 +402,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -817,7 +802,7 @@ SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = {
.longname = "Saleae Logic16", .longname = "Saleae Logic16",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -247,11 +247,6 @@ static int dev_clear(const struct sr_dev_driver *di)
return std_dev_clear(di, clear_helper); 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -642,7 +637,7 @@ SR_PRIV struct sr_dev_driver scpi_pps_driver_info = {
.longname = "SCPI PPS", .longname = "SCPI PPS",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -155,11 +155,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -253,7 +248,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
.longname = VENDOR " " MODEL, \ .longname = VENDOR " " MODEL, \
.api_version = 1, \ .api_version = 1, \
.init = init, \ .init = init, \
.cleanup = cleanup, \ .cleanup = std_cleanup, \
.scan = scan, \ .scan = scan, \
.dev_list = dev_list, \ .dev_list = dev_list, \
.dev_clear = dev_clear, \ .dev_clear = dev_clear, \

View File

@ -803,7 +803,7 @@ SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info = {
.longname = "SysClk LWLA series", .longname = "SysClk LWLA series",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = dev_clear, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -138,11 +138,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -232,7 +227,7 @@ SR_PRIV struct sr_dev_driver teleinfo_driver_info = {
.longname = "Teleinfo", .longname = "Teleinfo",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -230,20 +230,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -518,7 +504,7 @@ SR_PRIV struct sr_dev_driver testo_driver_info = {
.longname = "Testo", .longname = "Testo",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -111,11 +111,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
return ((struct drv_context *)(di->context))->instances; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "Tondaj SL-814",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -139,11 +139,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -221,7 +216,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
.longname = VENDOR " " MODEL, \ .longname = VENDOR " " MODEL, \
.api_version = 1, \ .api_version = 1, \
.init = init, \ .init = init, \
.cleanup = cleanup, \ .cleanup = std_cleanup, \
.scan = scan, \ .scan = scan, \
.dev_list = dev_list, \ .dev_list = dev_list, \
.dev_clear = dev_clear, \ .dev_clear = dev_clear, \

View File

@ -171,21 +171,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "UNI-T UT32x",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -183,21 +183,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) const struct sr_channel_group *cg)
{ {
@ -426,7 +411,7 @@ SR_PRIV struct sr_dev_driver victor_dmm_driver_info = {
.longname = "Victor DMMs", .longname = "Victor DMMs",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View File

@ -176,13 +176,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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. * 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", .longname = "Yokogawa DL/DLM",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = dev_clear, .dev_clear = dev_clear,

View File

@ -373,11 +373,6 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; 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, static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg) 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", .longname = "ZEROPLUS Logic Cube LAP-C series",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = cleanup, .cleanup = std_cleanup,
.scan = scan, .scan = scan,
.dev_list = dev_list, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,

View 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, SR_PRIV int std_init(struct sr_context *sr_ctx, struct sr_dev_driver *di,
const char *prefix); const char *prefix);
SR_PRIV int std_cleanup(const struct sr_dev_driver *di);
#ifdef HAVE_LIBSERIALPORT #ifdef HAVE_LIBSERIALPORT
SR_PRIV int std_serial_dev_open(struct sr_dev_inst *sdi); 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, SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi,

View File

@ -63,6 +63,28 @@ SR_PRIV int std_init(struct sr_context *sr_ctx, struct sr_dev_driver *di,
return SR_OK; 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. * Standard API helper for sending an SR_DF_HEADER packet.
* *