Pass driver struct pointer to driver callbacks.

This lays the groundwork for subdrivers to share callbacks without
needing a separate wrapper function for each subdriver.
This commit is contained in:
Martin Ling 2015-03-21 00:47:31 +00:00 committed by Uwe Hermann
parent 9e60a31fb9
commit 4f840ce965
56 changed files with 361 additions and 384 deletions

View File

@ -998,24 +998,24 @@ struct sr_dev_driver {
/** API version (currently 1). */ /** API version (currently 1). */
int api_version; int api_version;
/** Called when driver is loaded, e.g. program startup. */ /** Called when driver is loaded, e.g. program startup. */
int (*init) (struct sr_context *sr_ctx); int (*init) (struct sr_dev_driver *driver, struct sr_context *sr_ctx);
/** Called before driver is unloaded. /** Called before driver is unloaded.
* Driver must free all resources held by it. */ * Driver must free all resources held by it. */
int (*cleanup) (void); int (*cleanup) (const struct sr_dev_driver *driver);
/** Scan for devices. Driver should do all initialisation required. /** Scan for devices. Driver should do all initialisation required.
* Can be called several times, e.g. with different port options. * Can be called several times, e.g. with different port options.
* \retval NULL Error or no devices found. * \retval NULL Error or no devices found.
* \retval other GSList of a struct sr_dev_inst for each device. * \retval other GSList of a struct sr_dev_inst for each device.
* Must be freed by caller! * Must be freed by caller!
*/ */
GSList *(*scan) (GSList *options); GSList *(*scan) (struct sr_dev_driver *driver, GSList *options);
/** Get list of device instances the driver knows about. /** Get list of device instances the driver knows about.
* \returns NULL or GSList of a struct sr_dev_inst for each device. * \returns NULL or GSList of a struct sr_dev_inst for each device.
* Must not be freed by caller! * Must not be freed by caller!
*/ */
GSList *(*dev_list) (void); GSList *(*dev_list) (const struct sr_dev_driver *driver);
/** Clear list of devices the driver knows about. */ /** Clear list of devices the driver knows about. */
int (*dev_clear) (void); int (*dev_clear) (const struct sr_dev_driver *driver);
/** Query value of a configuration key in driver or given device instance. /** Query value of a configuration key in driver or given device instance.
* @see sr_config_get(). * @see sr_config_get().
*/ */

View File

@ -360,7 +360,7 @@ SR_PRIV void sr_usbtmc_dev_inst_free(struct sr_usbtmc_dev_inst *usbtmc)
SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver) SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver)
{ {
if (driver && driver->dev_list) if (driver && driver->dev_list)
return driver->dev_list(); return driver->dev_list(driver);
else else
return NULL; return NULL;
} }
@ -386,7 +386,7 @@ SR_API int sr_dev_clear(const struct sr_dev_driver *driver)
} }
if (driver->dev_clear) if (driver->dev_clear)
ret = driver->dev_clear(); ret = driver->dev_clear(driver);
else else
ret = std_dev_clear(driver, NULL); ret = std_dev_clear(driver, NULL);

View File

@ -71,14 +71,13 @@ static const struct agdmm_profile supported_agdmm[] = {
}; };
SR_PRIV struct sr_dev_driver agdmm_driver_info; SR_PRIV struct sr_dev_driver agdmm_driver_info;
static struct sr_dev_driver *di = &agdmm_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -165,12 +164,12 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -42,14 +42,13 @@ static const char *data_sources[] = {
}; };
SR_PRIV struct sr_dev_driver appa_55ii_driver_info; SR_PRIV struct sr_dev_driver appa_55ii_driver_info;
static struct sr_dev_driver *di = &appa_55ii_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -121,12 +120,12 @@ scan_cleanup:
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -39,7 +39,6 @@
#define USB_MODEL_NAME "SIGMA" #define USB_MODEL_NAME "SIGMA"
SR_PRIV struct sr_dev_driver asix_sigma_driver_info; SR_PRIV struct sr_dev_driver asix_sigma_driver_info;
static struct sr_dev_driver *di = &asix_sigma_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
/* /*
@ -312,17 +311,17 @@ static void clear_helper(void *priv)
ftdi_deinit(&devc->ftdic); ftdi_deinit(&devc->ftdic);
} }
static int dev_clear(void) 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 init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -401,7 +400,7 @@ free:
return NULL; return NULL;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -803,9 +802,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); 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,

View File

@ -77,14 +77,13 @@ static struct pps_model models[] = {
SR_PRIV struct sr_dev_driver atten_pps3203_driver_info; SR_PRIV struct sr_dev_driver atten_pps3203_driver_info;
static struct sr_dev_driver *di = &atten_pps3203_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options, int modelid) static GSList *scan(struct sr_dev_driver *di, GSList *options, int modelid)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -196,17 +195,17 @@ static GSList *scan(GSList *options, int modelid)
return devices; return devices;
} }
static GSList *scan_3203(GSList *options) static GSList *scan_3203(struct sr_dev_driver *di, GSList *options)
{ {
return scan(options, PPS_3203T_3S); return scan(di, options, PPS_3203T_3S);
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -20,7 +20,6 @@
#include "protocol.h" #include "protocol.h"
SR_PRIV struct sr_dev_driver baylibre_acme_driver_info; SR_PRIV struct sr_dev_driver baylibre_acme_driver_info;
static struct sr_dev_driver *di = &baylibre_acme_driver_info;
static const uint32_t devopts[] = { static const uint32_t devopts[] = {
SR_CONF_CONTINUOUS | SR_CONF_SET, SR_CONF_CONTINUOUS | SR_CONF_SET,
@ -42,12 +41,12 @@ static const uint64_t samplerates[] = {
SR_HZ(1), SR_HZ(1),
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -131,12 +130,12 @@ err_out:
return NULL; return NULL;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }
@ -161,9 +160,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
dev_clear(); dev_clear(di);
return SR_OK; return SR_OK;
} }

View File

@ -21,7 +21,6 @@
#include "beaglelogic.h" #include "beaglelogic.h"
SR_PRIV struct sr_dev_driver beaglelogic_driver_info; SR_PRIV struct sr_dev_driver beaglelogic_driver_info;
static struct sr_dev_driver *di = &beaglelogic_driver_info;
/* Scan options */ /* Scan options */
static const uint32_t scanopts[] = { static const uint32_t scanopts[] = {
@ -61,7 +60,7 @@ static const uint64_t samplerates[] = {
SR_HZ(1), SR_HZ(1),
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -79,7 +78,7 @@ static struct dev_context *beaglelogic_devc_alloc(void)
return devc; return devc;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
GSList *devices, *l; GSList *devices, *l;
@ -146,12 +145,12 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }
@ -200,7 +199,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
@ -220,8 +219,6 @@ static int cleanup(void)
g_slist_free(drvc->instances); g_slist_free(drvc->instances);
drvc->instances = NULL; drvc->instances = NULL;
di->priv = NULL;
return SR_OK; return SR_OK;
} }

View File

@ -33,14 +33,13 @@ static const uint32_t devopts[] = {
}; };
SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info; SR_PRIV struct sr_dev_driver brymen_bm86x_driver_info;
static struct sr_dev_driver *di = &brymen_bm86x_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
GSList *usb_devices, *devices, *l; GSList *usb_devices, *devices, *l;
struct drv_context *drvc; struct drv_context *drvc;
@ -92,13 +91,14 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->priv; struct drv_context *drvc = di->priv;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
struct dev_context *devc; struct dev_context *devc;
@ -166,7 +166,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return ret; return ret;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -34,7 +34,7 @@ static const uint32_t devopts[] = {
SR_PRIV struct sr_dev_driver brymen_bm857_driver_info; SR_PRIV struct sr_dev_driver brymen_bm857_driver_info;
static struct sr_dev_driver *di = &brymen_bm857_driver_info; static struct sr_dev_driver *di = &brymen_bm857_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -93,7 +93,7 @@ scan_cleanup:
return devices; return devices;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct sr_config *src; struct sr_config *src;
@ -130,12 +130,12 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -67,15 +67,14 @@ static const char *data_sources[] = {
"Memory", "Memory",
}; };
SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info; SR_PRIV struct sr_dev_driver cem_dt_885x_driver_info;
static struct sr_dev_driver *di = &cem_dt_885x_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -135,7 +134,7 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -153,7 +152,7 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -239,15 +239,21 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
/* Driver-specific API function wrappers */ /* Driver-specific API function wrappers */
#define HW_INIT(X) \ #define HW_INIT(X) \
static int init_##X(struct sr_context *sr_ctx) { return init(sr_ctx, X); } static int init_##X(struct sr_dev_driver *d, \
struct sr_context *sr_ctx) { \
(void) d; return init(sr_ctx, X); }
#define HW_CLEANUP(X) \ #define HW_CLEANUP(X) \
static int cleanup_##X(void) { return 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(GSList *options) { return scan(options, X); } static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \
(void) d; return scan(options, X); }
#define HW_DEV_LIST(X) \ #define HW_DEV_LIST(X) \
static GSList *dev_list_##X(void) { return dev_list(X); } static GSList *dev_list_##X(const struct sr_dev_driver *d) { \
(void) d; return dev_list(X); }
#define HW_DEV_CLEAR(X) \ #define HW_DEV_CLEAR(X) \
static int dev_clear_##X(void) { return dev_clear(X); } static int dev_clear_##X(const struct sr_dev_driver *d) { \
(void) d; return dev_clear(X); }
#define HW_DEV_ACQUISITION_START(X) \ #define HW_DEV_ACQUISITION_START(X) \
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }

View File

@ -63,12 +63,12 @@ static void clear_helper(void *priv)
g_free(devc->final_buf); g_free(devc->final_buf);
} }
static int dev_clear(void) 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 init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -142,13 +142,14 @@ err_free_devc:
return ret; return ret;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
int ret; int ret;
unsigned int i; unsigned int i;
GSList *devices; GSList *devices;
struct ftdi_context *ftdic; struct ftdi_context *ftdic;
(void)di;
(void)options; (void)options;
devices = NULL; devices = NULL;
@ -188,7 +189,7 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -267,9 +268,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); 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,

View File

@ -43,14 +43,13 @@ static const uint32_t devopts[] = {
}; };
SR_PRIV struct sr_dev_driver colead_slm_driver_info; SR_PRIV struct sr_dev_driver colead_slm_driver_info;
static struct sr_dev_driver *di = &colead_slm_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -97,7 +96,7 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -115,7 +114,7 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -39,14 +39,13 @@ static const uint32_t devopts[] = {
}; };
SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info; SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info;
static struct sr_dev_driver *di = &conrad_digi_35_cpu_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -106,12 +105,12 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -180,12 +180,11 @@ static uint8_t pattern_sigrok[] = {
}; };
SR_PRIV struct sr_dev_driver demo_driver_info; SR_PRIV struct sr_dev_driver demo_driver_info;
static struct sr_dev_driver *di = &demo_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -266,7 +265,7 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
} }
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -369,7 +368,7 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -404,7 +403,7 @@ static void clear_helper(void *priv)
g_free(devc); g_free(devc);
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, clear_helper); return std_dev_clear(di, clear_helper);
} }

View File

@ -34,7 +34,7 @@ static void std_dev_attach(struct sr_dev_driver *di, struct sr_dev_inst *sdi)
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
} }
static GSList *std_dev_list(struct sr_dev_driver *di) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)di->priv)->instances; return ((struct drv_context *)di->priv)->instances;
} }
@ -43,33 +43,28 @@ static GSList *std_dev_list(struct sr_dev_driver *di)
SR_PRIV struct sr_dev_driver deree_de5000_driver_info; SR_PRIV struct sr_dev_driver deree_de5000_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, &deree_de5000_driver_info, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(&deree_de5000_driver_info, es51919_serial_clean); return std_dev_clear(di, es51919_serial_clean);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
if (!(sdi = es51919_serial_scan(options, "DER EE", "DE-5000"))) if (!(sdi = es51919_serial_scan(options, "DER EE", "DE-5000")))
return NULL; return NULL;
std_dev_attach(&deree_de5000_driver_info, sdi); std_dev_attach(di, sdi);
return g_slist_append(NULL, sdi); return g_slist_append(NULL, sdi);
} }
static GSList *dev_list(void)
{
return std_dev_list(&deree_de5000_driver_info);
}
SR_PRIV struct sr_dev_driver deree_de5000_driver_info = { SR_PRIV struct sr_dev_driver deree_de5000_driver_info = {
.name = "deree-de5000", .name = "deree-de5000",
.longname = "DER EE DE-5000", .longname = "DER EE DE-5000",

View File

@ -40,7 +40,6 @@ static const uint32_t devopts[] = {
}; };
SR_PRIV struct sr_dev_driver flukedmm_driver_info; SR_PRIV struct sr_dev_driver flukedmm_driver_info;
static struct sr_dev_driver *di = &flukedmm_driver_info;
static char *scan_conn[] = { static char *scan_conn[] = {
/* 287/289 */ /* 287/289 */
@ -59,12 +58,13 @@ static const struct flukedmm_profile supported_flukedmm[] = {
{ FLUKE_190, "199B", 1000, 3500 }, { FLUKE_190, "199B", 1000, 3500 },
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *fluke_scan(const char *conn, const char *serialcomm) static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
const char *serialcomm)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -149,7 +149,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
return devices; return devices;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_config *src; struct sr_config *src;
GSList *l, *devices; GSList *l, *devices;
@ -174,10 +174,10 @@ static GSList *scan(GSList *options)
devices = NULL; devices = NULL;
if (serialcomm) { if (serialcomm) {
/* Use the provided comm specs. */ /* Use the provided comm specs. */
devices = fluke_scan(conn, serialcomm); devices = fluke_scan(di, conn, serialcomm);
} else { } else {
for (i = 0; scan_conn[i]; i++) { for (i = 0; scan_conn[i]; i++) {
if ((devices = fluke_scan(conn, scan_conn[i]))) if ((devices = fluke_scan(di, conn, scan_conn[i])))
break; break;
/* The Scopemeter 199B, at least, requires this /* The Scopemeter 199B, at least, requires this
* after all the 115k/9.6k confusion. */ * after all the 115k/9.6k confusion. */
@ -188,12 +188,12 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -158,14 +158,13 @@ static const uint64_t dslogic_samplerates[] = {
}; };
SR_PRIV struct sr_dev_driver fx2lafw_driver_info; SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
static struct sr_dev_driver *di = &fx2lafw_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -340,13 +339,14 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
struct dev_context *devc; struct dev_context *devc;
int ret; int ret;
@ -440,7 +440,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
int ret; int ret;
struct drv_context *drvc; struct drv_context *drvc;
@ -451,7 +451,6 @@ static int cleanup(void)
ret = std_dev_clear(di, NULL); ret = std_dev_clear(di, NULL);
g_free(drvc); g_free(drvc);
di->priv = NULL;
return ret; return ret;
} }
@ -601,7 +600,7 @@ static int receive_data(int fd, int revents, void *cb_data)
(void)revents; (void)revents;
(void)cb_data; (void)cb_data;
drvc = di->priv; drvc = (struct drv_context *) cb_data;
tv.tv_sec = tv.tv_usec = 0; tv.tv_sec = tv.tv_usec = 0;
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv); libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
@ -735,6 +734,7 @@ static int dslogic_trigger_request(const struct sr_dev_inst *sdi)
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
int timeout, ret; int timeout, ret;
@ -742,6 +742,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
if (sdi->status != SR_ST_ACTIVE) if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
di = sdi->driver;
drvc = di->priv; drvc = di->priv;
devc = sdi->priv; devc = sdi->priv;
@ -752,7 +753,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
devc->acq_aborted = FALSE; devc->acq_aborted = FALSE;
timeout = fx2lafw_get_timeout(devc); timeout = fx2lafw_get_timeout(devc);
usb_source_add(sdi->session, devc->ctx, timeout, receive_data, NULL); usb_source_add(sdi->session, devc->ctx, timeout, receive_data, drvc);
if (devc->dslogic) { if (devc->dslogic) {
dslogic_trigger_request(sdi); dslogic_trigger_request(sdi);

View File

@ -66,16 +66,10 @@ static const uint32_t devopts_bd[] = {
* Need to implement device-specific lists. * Need to implement device-specific lists.
*/ */
/** Init driver gmc_mh_1x_2x_rs232. */ /** Init driver. */
static int init_1x_2x_rs232(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, &gmc_mh_1x_2x_rs232_driver_info, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
}
/** Init driver gmc_mh_2x_bd232. */
static int init_2x_bd232(struct sr_context *sr_ctx)
{
return std_init(sr_ctx, &gmc_mh_2x_bd232_driver_info, LOG_PREFIX);
} }
/** /**
@ -156,7 +150,7 @@ static enum model scan_model_sm(struct sr_serial_dev_inst *serial)
* on configuration and measurement mode the intervals can be much larger and * on configuration and measurement mode the intervals can be much larger and
* then the detection might not work. * then the detection might not work.
*/ */
static GSList *scan_1x_2x_rs232(GSList *options) static GSList *scan_1x_2x_rs232(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -169,7 +163,7 @@ static GSList *scan_1x_2x_rs232(GSList *options)
gboolean serialcomm_given; gboolean serialcomm_given;
devices = NULL; devices = NULL;
drvc = (&gmc_mh_1x_2x_rs232_driver_info)->priv; drvc = di->priv;
drvc->instances = NULL; drvc->instances = NULL;
conn = serialcomm = NULL; conn = serialcomm = NULL;
model = METRAHIT_NONE; model = METRAHIT_NONE;
@ -234,7 +228,7 @@ static GSList *scan_1x_2x_rs232(GSList *options)
devc->settings_ok = FALSE; devc->settings_ok = FALSE;
sdi->conn = serial; sdi->conn = serial;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = &gmc_mh_1x_2x_rs232_driver_info; sdi->driver = di;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1"); sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
@ -246,7 +240,7 @@ static GSList *scan_1x_2x_rs232(GSList *options)
/** Scan for Metrahit 2x in a bidirectional mode using Gossen Metrawatt 'BD 232' interface. /** Scan for Metrahit 2x in a bidirectional mode using Gossen Metrawatt 'BD 232' interface.
* *
*/ */
static GSList *scan_2x_bd232(GSList *options) static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -263,7 +257,7 @@ static GSList *scan_2x_bd232(GSList *options)
conn = serialcomm = NULL; conn = serialcomm = NULL;
devices = NULL; devices = NULL;
drvc = (&gmc_mh_2x_bd232_driver_info)->priv; drvc = di->priv;
drvc->instances = NULL; drvc->instances = NULL;
sr_spew("scan_2x_bd232() called!"); sr_spew("scan_2x_bd232() called!");
@ -328,7 +322,7 @@ static GSList *scan_2x_bd232(GSList *options)
sdi->version = g_strdup_printf("Firmware %d.%d", devc->fw_ver_maj, devc->fw_ver_min); sdi->version = g_strdup_printf("Firmware %d.%d", devc->fw_ver_maj, devc->fw_ver_min);
sdi->conn = serial; sdi->conn = serial;
sdi->priv = devc; sdi->priv = devc;
sdi->driver = &gmc_mh_2x_bd232_driver_info; sdi->driver = di;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1"); sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
@ -361,16 +355,9 @@ exit_err:
} }
/** Driver device list function */ /** Driver device list function */
static GSList *dev_list_1x_2x_rs232(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(gmc_mh_1x_2x_rs232_driver_info.priv))->instances; return ((struct drv_context *)(di->priv))->instances;
}
/** Driver device list function */
static GSList *dev_list_2x_bd232(void)
{
return ((struct drv_context *)(gmc_mh_2x_bd232_driver_info.priv))
->instances;
} }
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
@ -391,14 +378,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup_sm_rs232(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(&gmc_mh_1x_2x_rs232_driver_info, NULL); return std_dev_clear(di, NULL);
}
static int cleanup_2x_bd232(void)
{
return std_dev_clear(&gmc_mh_2x_bd232_driver_info, NULL);
} }
/** Get value of configuration item */ /** Get value of configuration item */
@ -563,10 +545,10 @@ SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = {
.name = "gmc-mh-1x-2x-rs232", .name = "gmc-mh-1x-2x-rs232",
.longname = "Gossen Metrawatt Metrahit 1x/2x, RS232 interface", .longname = "Gossen Metrawatt Metrahit 1x/2x, RS232 interface",
.api_version = 1, .api_version = 1,
.init = init_1x_2x_rs232, .init = init,
.cleanup = cleanup_sm_rs232, .cleanup = cleanup,
.scan = scan_1x_2x_rs232, .scan = scan_1x_2x_rs232,
.dev_list = dev_list_1x_2x_rs232, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,
.config_get = config_get, .config_get = config_get,
.config_set = config_set, .config_set = config_set,
@ -582,10 +564,10 @@ SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info = {
.name = "gmc-mh-2x-bd232", .name = "gmc-mh-2x-bd232",
.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_2x_bd232, .init = init,
.cleanup = cleanup_2x_bd232, .cleanup = cleanup,
.scan = scan_2x_bd232, .scan = scan_2x_bd232,
.dev_list = dev_list_2x_bd232, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,
.config_get = config_get, .config_get = config_get,
.config_set = config_set, .config_set = config_set,

View File

@ -23,7 +23,6 @@
#define SERIALCOMM "115200/8n1/flow=1" #define SERIALCOMM "115200/8n1/flow=1"
SR_PRIV struct sr_dev_driver hameg_hmo_driver_info; SR_PRIV struct sr_dev_driver hameg_hmo_driver_info;
static struct sr_dev_driver *di = &hameg_hmo_driver_info;
static const char *manufacturers[] = { static const char *manufacturers[] = {
"HAMEG", "HAMEG",
@ -45,7 +44,7 @@ enum {
CG_DIGITAL, CG_DIGITAL,
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -85,7 +84,7 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi
sdi->model = g_strdup(hw_info->model); sdi->model = g_strdup(hw_info->model);
sdi->version = g_strdup(hw_info->firmware_version); sdi->version = g_strdup(hw_info->firmware_version);
sdi->serial_num = g_strdup(hw_info->serial_number); sdi->serial_num = g_strdup(hw_info->serial_number);
sdi->driver = di; sdi->driver = &hameg_hmo_driver_info;
sdi->inst_type = SR_INST_SCPI; sdi->inst_type = SR_INST_SCPI;
sdi->conn = scpi; sdi->conn = scpi;
@ -116,12 +115,12 @@ fail:
return NULL; return NULL;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
return sr_scpi_scan(di->priv, options, hmo_probe_serial_device); return sr_scpi_scan(di->priv, options, hmo_probe_serial_device);
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -140,7 +139,7 @@ static void clear_helper(void *priv)
g_free(devc); g_free(devc);
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, clear_helper); return std_dev_clear(di, clear_helper);
} }
@ -170,9 +169,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
dev_clear(); dev_clear(di);
return SR_OK; return SR_OK;
} }

View File

@ -159,7 +159,6 @@ static const char *coupling[] = {
}; };
SR_PRIV struct sr_dev_driver hantek_dso_driver_info; SR_PRIV struct sr_dev_driver hantek_dso_driver_info;
static struct sr_dev_driver *di = &hantek_dso_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
@ -176,7 +175,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
sdi->status = SR_ST_INITIALIZING; sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(prof->vendor); sdi->vendor = g_strdup(prof->vendor);
sdi->model = g_strdup(prof->model); sdi->model = g_strdup(prof->model);
sdi->driver = di; sdi->driver = &hantek_dso_driver_info;
/* /*
* Add only the real channels -- EXT isn't a source of data, only * Add only the real channels -- EXT isn't a source of data, only
@ -208,7 +207,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
devc->triggersource = g_strdup(DEFAULT_TRIGGER_SOURCE); devc->triggersource = g_strdup(DEFAULT_TRIGGER_SOURCE);
devc->triggerposition = DEFAULT_HORIZ_TRIGGERPOS; devc->triggerposition = DEFAULT_HORIZ_TRIGGERPOS;
sdi->priv = devc; sdi->priv = devc;
drvc = di->priv; drvc = hantek_dso_driver_info.priv;
drvc->instances = g_slist_append(drvc->instances, sdi); drvc->instances = g_slist_append(drvc->instances, sdi);
return sdi; return sdi;
@ -248,17 +247,17 @@ static void clear_dev_context(void *priv)
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, clear_dev_context); return std_dev_clear(di, clear_dev_context);
} }
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -361,7 +360,7 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -421,9 +420,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); 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,
@ -867,8 +866,9 @@ static int handle_event(int fd, int revents, void *cb_data)
const struct sr_dev_inst *sdi; const struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct timeval tv; struct timeval tv;
struct sr_dev_driver *di;
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc = di->priv; struct drv_context *drvc;
int num_channels; int num_channels;
uint32_t trigger_offset; uint32_t trigger_offset;
uint8_t capturestate; uint8_t capturestate;
@ -877,6 +877,8 @@ static int handle_event(int fd, int revents, void *cb_data)
(void)revents; (void)revents;
sdi = cb_data; sdi = cb_data;
di = sdi->driver;
drvc = di->priv;
devc = sdi->priv; devc = sdi->priv;
if (devc->dev_state == STOPPING) { if (devc->dev_state == STOPPING) {
/* We've been told to wind up the acquisition. */ /* We've been told to wind up the acquisition. */
@ -976,6 +978,7 @@ static int handle_event(int fd, int revents, void *cb_data)
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->priv; struct drv_context *drvc = di->priv;
if (sdi->status != SR_ST_ACTIVE) if (sdi->status != SR_ST_ACTIVE)

View File

@ -53,14 +53,13 @@ static const char *channel_names[NUM_CHANNELS + 1] = {
}; };
SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info; SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info;
static struct sr_dev_driver *di = &ikalogic_scanalogic2_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
GSList *usb_devices, *devices, *l; GSList *usb_devices, *devices, *l;
struct drv_context *drvc; struct drv_context *drvc;
@ -162,7 +161,7 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -180,13 +179,14 @@ static void clear_dev_context(void *priv)
g_free(devc); g_free(devc);
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, &clear_dev_context); return std_dev_clear(di, &clear_dev_context);
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
@ -258,6 +258,7 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
if (!di->priv) { if (!di->priv) {
@ -279,9 +280,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); 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,
@ -386,6 +387,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
uint16_t trigger_bytes, tmp; uint16_t trigger_bytes, tmp;

View File

@ -20,7 +20,6 @@
#include "protocol.h" #include "protocol.h"
extern struct sr_dev_driver ikalogic_scanalogic2_driver_info; extern struct sr_dev_driver ikalogic_scanalogic2_driver_info;
static struct sr_dev_driver *di = &ikalogic_scanalogic2_driver_info;
extern uint64_t sl2_samplerates[NUM_SAMPLERATES]; extern uint64_t sl2_samplerates[NUM_SAMPLERATES];
@ -199,6 +198,7 @@ static void process_sample_data(const struct sr_dev_inst *sdi)
SR_PRIV int ikalogic_scanalogic2_receive_data(int fd, int revents, void *cb_data) SR_PRIV int ikalogic_scanalogic2_receive_data(int fd, int revents, void *cb_data)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_dev_driver *di;
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc; struct drv_context *drvc;
struct timeval tv; struct timeval tv;
@ -214,6 +214,7 @@ SR_PRIV int ikalogic_scanalogic2_receive_data(int fd, int revents, void *cb_data
if (!(devc = sdi->priv)) if (!(devc = sdi->priv))
return TRUE; return TRUE;
di = sdi->driver;
drvc = di->priv; drvc = di->priv;
current_time = g_get_monotonic_time(); current_time = g_get_monotonic_time();
@ -642,7 +643,7 @@ SR_PRIV int sl2_get_device_info(struct sr_usb_dev_inst usb,
uint8_t buffer[PACKET_LENGTH]; uint8_t buffer[PACKET_LENGTH];
int ret; int ret;
drvc = di->priv; drvc = ikalogic_scanalogic2_driver_info.priv;
if (!dev_info) if (!dev_info)
return SR_ERR_ARG; return SR_ERR_ARG;

View File

@ -45,7 +45,6 @@ static const char *channel_names[] = {
static uint64_t samplerates[1] = { SR_MHZ(100) }; static uint64_t samplerates[1] = { SR_MHZ(100) };
SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info; SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info;
static struct sr_dev_driver *di = &ikalogic_scanaplus_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
@ -61,17 +60,17 @@ static void clear_helper(void *priv)
g_free(devc); g_free(devc);
} }
static int dev_clear(void) 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 init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -151,7 +150,7 @@ err_free_devc:
return NULL; return NULL;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -263,9 +262,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return ret; return ret;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); 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,

View File

@ -61,15 +61,15 @@ static const char *data_sources[] = {
}; };
SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info; SR_PRIV struct sr_dev_driver kecheng_kc_330b_driver_info;
static struct sr_dev_driver *di = &kecheng_kc_330b_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static int scan_kecheng(struct sr_usb_dev_inst *usb, char **model) static int scan_kecheng(struct sr_dev_driver *di,
struct sr_usb_dev_inst *usb, char **model)
{ {
struct drv_context *drvc; struct drv_context *drvc;
int len, ret; int len, ret;
@ -108,7 +108,7 @@ static int scan_kecheng(struct sr_usb_dev_inst *usb, char **model)
return SR_OK; return SR_OK;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -126,7 +126,7 @@ static GSList *scan(GSList *options)
/* We have a list of sr_usb_dev_inst matching the connection /* We have a list of sr_usb_dev_inst matching the connection
* string. Wrap them in sr_dev_inst and we're done. */ * string. Wrap them in sr_dev_inst and we're done. */
for (l = usb_devices; l; l = l->next) { for (l = usb_devices; l; l = l->next) {
if (scan_kecheng(l->data, &model) != SR_OK) if (scan_kecheng(di, l->data, &model) != SR_OK)
continue; continue;
sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE; sdi->status = SR_ST_INACTIVE;
@ -160,13 +160,14 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc; struct drv_context *drvc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
int ret; int ret;
@ -197,6 +198,7 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
@ -225,7 +227,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
int ret; int ret;
struct drv_context *drvc; struct drv_context *drvc;
@ -237,7 +239,6 @@ static int cleanup(void)
ret = std_dev_clear(di, NULL); ret = std_dev_clear(di, NULL);
g_free(drvc); g_free(drvc);
di->priv = NULL;
return ret; return ret;
} }
@ -294,6 +295,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
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)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
uint64_t p, q; uint64_t p, q;
unsigned int i; unsigned int i;
@ -415,6 +417,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
static int dev_acquisition_start(const struct sr_dev_inst *sdi, static int dev_acquisition_start(const struct sr_dev_inst *sdi,
void *cb_data) void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;

View File

@ -21,11 +21,11 @@
#include "protocol.h" #include "protocol.h"
extern struct sr_dev_driver kecheng_kc_330b_driver_info; extern struct sr_dev_driver kecheng_kc_330b_driver_info;
static struct sr_dev_driver *di = &kecheng_kc_330b_driver_info;
extern const uint64_t kecheng_kc_330b_sample_intervals[][2]; extern const uint64_t kecheng_kc_330b_sample_intervals[][2];
SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data) SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
{ {
struct sr_dev_driver *di;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
@ -40,10 +40,11 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
(void)fd; (void)fd;
(void)revents; (void)revents;
drvc = di->priv;
sdi = cb_data; sdi = cb_data;
devc = sdi->priv; devc = sdi->priv;
usb = sdi->conn; usb = sdi->conn;
di = sdi->driver;
drvc = di->priv;
memset(&tv, 0, sizeof(struct timeval)); memset(&tv, 0, sizeof(struct timeval));
libusb_handle_events_timeout_completed(drvc->sr_ctx->libusb_ctx, &tv, libusb_handle_events_timeout_completed(drvc->sr_ctx->libusb_ctx, &tv,

View File

@ -24,7 +24,6 @@
#include "protocol.h" #include "protocol.h"
SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info; SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info;
static struct sr_dev_driver *di = &lascar_el_usb_driver_info;
static const uint32_t scanopts[] = { static const uint32_t scanopts[] = {
SR_CONF_CONN, SR_CONF_CONN,
@ -38,12 +37,12 @@ static const uint32_t devopts[] = {
SR_CONF_DATALOG | SR_CONF_GET | SR_CONF_SET, SR_CONF_DATALOG | SR_CONF_GET | SR_CONF_SET,
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
@ -89,13 +88,14 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc; struct drv_context *drvc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
int ret; int ret;
@ -121,6 +121,7 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
if (!di->priv) { if (!di->priv) {
@ -142,7 +143,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
int ret; int ret;
struct drv_context *drvc; struct drv_context *drvc;
@ -154,7 +155,6 @@ static int cleanup(void)
ret = std_dev_clear(di, NULL); ret = std_dev_clear(di, NULL);
g_free(drvc); g_free(drvc);
di->priv = NULL;
return ret; return ret;
} }
@ -198,6 +198,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
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)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
int ret; int ret;
@ -329,6 +330,7 @@ static int lascar_proc_config(const struct sr_dev_inst *sdi)
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_meta meta; struct sr_datafeed_meta meta;
struct sr_config *src; struct sr_config *src;
@ -453,6 +455,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
(void)cb_data; (void)cb_data;
if (!di->priv) { if (!di->priv) {

View File

@ -27,7 +27,7 @@
#include "protocol.h" #include "protocol.h"
extern struct sr_dev_driver lascar_el_usb_driver_info; extern struct sr_dev_driver lascar_el_usb_driver_info;
static struct sr_dev_driver *di = &lascar_el_usb_driver_info; struct sr_dev_driver *di = &lascar_el_usb_driver_info;
static const struct elusb_profile profiles[] = { static const struct elusb_profile profiles[] = {
{ 1, "EL-USB-1", LOG_UNSUPPORTED }, { 1, "EL-USB-1", LOG_UNSUPPORTED },

View File

@ -50,10 +50,9 @@ static const uint64_t samplerates[] = {
}; };
SR_PRIV struct sr_dev_driver link_mso19_driver_info; SR_PRIV struct sr_dev_driver link_mso19_driver_info;
static struct sr_dev_driver *di = &link_mso19_driver_info;
/* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */ /* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
GSList *l; GSList *l;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
@ -88,12 +87,12 @@ static int dev_clear(void)
return ret; return ret;
} }
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
int i; int i;
GSList *devices = NULL; GSList *devices = NULL;
@ -229,7 +228,7 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -265,7 +264,7 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); return dev_clear();
} }

View File

@ -30,7 +30,6 @@ static const char mso_head[] = { 0x40, 0x4c, 0x44, 0x53, 0x7e };
static const char mso_foot[] = { 0x7e }; static const char mso_foot[] = { 0x7e };
extern SR_PRIV struct sr_dev_driver link_mso19_driver_info; extern SR_PRIV struct sr_dev_driver link_mso19_driver_info;
static struct sr_dev_driver *di = &link_mso19_driver_info;
SR_PRIV int mso_send_control_message(struct sr_serial_dev_inst *serial, SR_PRIV int mso_send_control_message(struct sr_serial_dev_inst *serial,
uint16_t payload[], int n) uint16_t payload[], int n)

View File

@ -73,19 +73,18 @@ static struct hcs_model models[] = {
}; };
SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info; SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info;
static struct sr_dev_driver *di = &manson_hcs_3xxx_driver_info;
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
int i, model_id; int i, model_id;
struct drv_context *drvc; struct drv_context *drvc;
@ -203,14 +202,14 @@ exit_err:
return NULL; return NULL;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); 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,

View File

@ -248,15 +248,20 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
/* Driver-specific API function wrappers */ /* Driver-specific API function wrappers */
#define HW_INIT(X) \ #define HW_INIT(X) \
static int init_##X(struct sr_context *sr_ctx) { return init(sr_ctx, X); } static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \
(void) di; return init(sr_ctx, X); }
#define HW_CLEANUP(X) \ #define HW_CLEANUP(X) \
static int cleanup_##X(void) { return 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(GSList *options) { return scan(options, X); } static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \
(void) di; return scan(options, X); }
#define HW_DEV_LIST(X) \ #define HW_DEV_LIST(X) \
static GSList *dev_list_##X(void) { return dev_list(X); } static GSList *dev_list_##X(const struct sr_dev_driver *di) { \
(void) di; return dev_list(X); }
#define HW_DEV_CLEAR(X) \ #define HW_DEV_CLEAR(X) \
static int dev_clear_##X(void) { return dev_clear(X); } static int dev_clear_##X(const struct sr_dev_driver *di) { \
(void) di; return dev_clear(X); }
#define HW_CONFIG_LIST(X) \ #define HW_CONFIG_LIST(X) \
static int config_list_##X(uint32_t key, GVariant **data, \ static int config_list_##X(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) { \

View File

@ -134,9 +134,9 @@ static struct lps_modelspec models[] = {
}, },
}; };
static int init_lps301(struct sr_context *sr_ctx) static int init_lps301(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, &motech_lps_301_driver_info, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
/** Send command to device with va_list. /** Send command to device with va_list.
@ -512,19 +512,14 @@ exit_err:
} }
/** Scan for LPS-301 device. */ /** Scan for LPS-301 device. */
static GSList *scan_lps301(GSList *options) static GSList *scan_lps301(struct sr_dev_driver *di, GSList *options)
{ {
return do_scan(LPS_301, &motech_lps_301_driver_info, options); return do_scan(LPS_301, di, options);
} }
static GSList *doDevList(struct sr_dev_driver *drv) static GSList *dev_list_lps301(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(drv->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
}
static GSList *dev_list_lps301(void)
{
return doDevList(&motech_lps_301_driver_info);
} }
static void dev_clear_private(struct dev_context* devc) static void dev_clear_private(struct dev_context* devc)
@ -538,14 +533,14 @@ static void dev_clear_private(struct dev_context* devc)
g_timer_destroy(devc->elapsed_msec); g_timer_destroy(devc->elapsed_msec);
} }
static int dev_clear_lps301(void) static int dev_clear_lps301(const struct sr_dev_driver *di)
{ {
return std_dev_clear(&motech_lps_301_driver_info, (std_dev_clear_callback)dev_clear_private); return std_dev_clear(di, (std_dev_clear_callback)dev_clear_private);
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear_lps301(); 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,

View File

@ -66,17 +66,12 @@ static const char* get_typestr(int type, struct sr_dev_driver* drv)
return nameref[type-1][(drv == &siemens_b102x_driver_info)]; return nameref[type-1][(drv == &siemens_b102x_driver_info)];
} }
static int init_norma_dmm(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, &norma_dmm_driver_info, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static int init_siemens_b102x(struct sr_context *sr_ctx) static GSList *scan(struct sr_dev_driver* drv, GSList *options)
{
return std_init(sr_ctx, &siemens_b102x_driver_info, LOG_PREFIX);
}
static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -181,24 +176,9 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
return devices; return devices;
} }
static GSList *scan_norma_dmm(GSList *options) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return do_scan(&norma_dmm_driver_info, options); return ((struct drv_context *)(di->priv))->instances;
}
static GSList *scan_siemens_b102x(GSList *options)
{
return do_scan(&siemens_b102x_driver_info, options);
}
static GSList *dev_list_norma_dmm(void)
{
return ((struct drv_context *)(norma_dmm_driver_info.priv))->instances;
}
static GSList *dev_list_siemens_b102x(void)
{
return ((struct drv_context *)(siemens_b102x_driver_info.priv))->instances;
} }
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
@ -217,14 +197,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup_norma_dmm(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(&norma_dmm_driver_info, NULL); return std_dev_clear(di, NULL);
}
static int cleanup_siemens_b102x(void)
{
return std_dev_clear(&siemens_b102x_driver_info, 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,
@ -331,10 +306,10 @@ SR_PRIV struct sr_dev_driver norma_dmm_driver_info = {
.name = "norma-dmm", .name = "norma-dmm",
.longname = "Norma DM9x0 DMMs", .longname = "Norma DM9x0 DMMs",
.api_version = 1, .api_version = 1,
.init = init_norma_dmm, .init = init,
.cleanup = cleanup_norma_dmm, .cleanup = cleanup,
.scan = scan_norma_dmm, .scan = scan,
.dev_list = dev_list_norma_dmm, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,
.config_get = NULL, .config_get = NULL,
.config_set = config_set, .config_set = config_set,
@ -351,10 +326,10 @@ SR_PRIV struct sr_dev_driver siemens_b102x_driver_info = {
.name = "siemens-b102x", .name = "siemens-b102x",
.longname = "Siemens B102x DMMs", .longname = "Siemens B102x DMMs",
.api_version = 1, .api_version = 1,
.init = init_siemens_b102x, .init = init,
.cleanup = cleanup_siemens_b102x, .cleanup = cleanup,
.scan = scan_siemens_b102x, .scan = scan,
.dev_list = dev_list_siemens_b102x, .dev_list = dev_list,
.dev_clear = NULL, .dev_clear = NULL,
.config_get = NULL, .config_get = NULL,
.config_set = config_set, .config_set = config_set,

View File

@ -85,14 +85,13 @@ static const uint64_t samplerates[] = {
}; };
SR_PRIV struct sr_dev_driver ols_driver_info; SR_PRIV struct sr_dev_driver ols_driver_info;
static struct sr_dev_driver *di = &ols_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_config *src; struct sr_config *src;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
@ -214,12 +213,12 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -21,7 +21,6 @@
#include <libserialport.h> #include <libserialport.h>
extern SR_PRIV struct sr_dev_driver ols_driver_info; extern SR_PRIV struct sr_dev_driver ols_driver_info;
static struct sr_dev_driver *di = &ols_driver_info;
SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial, SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial,
uint8_t command) uint8_t command)
@ -150,7 +149,7 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE; sdi->status = SR_ST_INACTIVE;
sdi->driver = di; sdi->driver = &ols_driver_info;
devc = ols_dev_new(); devc = ols_dev_new();
sdi->priv = devc; sdi->priv = devc;

View File

@ -76,14 +76,13 @@ static const uint64_t samplerates[] = {
}; };
SR_PRIV struct sr_dev_driver p_ols_driver_info; SR_PRIV struct sr_dev_driver p_ols_driver_info;
static struct sr_dev_driver *di = &p_ols_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -205,7 +204,7 @@ err_free_devc:
return NULL; return NULL;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -220,14 +219,14 @@ static void clear_helper(void *priv)
g_free(devc->ftdi_buf); g_free(devc->ftdi_buf);
} }
static int dev_clear(void) 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(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); return dev_clear(di);
} }

View File

@ -20,7 +20,6 @@
#include "protocol.h" #include "protocol.h"
extern SR_PRIV struct sr_dev_driver p_ols_driver_info; extern SR_PRIV struct sr_dev_driver p_ols_driver_info;
static struct sr_dev_driver *di = &p_ols_driver_info;
SR_PRIV int write_shortcommand(struct dev_context *devc, uint8_t command) SR_PRIV int write_shortcommand(struct dev_context *devc, uint8_t command)
{ {
@ -227,7 +226,7 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE; sdi->status = SR_ST_INACTIVE;
sdi->driver = di; sdi->driver = &p_ols_driver_info;
sdi->priv = devc; sdi->priv = devc;
devname = g_string_new(""); devname = g_string_new("");

View File

@ -247,7 +247,6 @@ static const struct rigol_ds_model supported_models[] = {
}; };
SR_PRIV struct sr_dev_driver rigol_ds_driver_info; SR_PRIV struct sr_dev_driver rigol_ds_driver_info;
static struct sr_dev_driver *di = &rigol_ds_driver_info;
static void clear_helper(void *priv) static void clear_helper(void *priv)
{ {
@ -265,12 +264,12 @@ static void clear_helper(void *priv)
g_free(devc); g_free(devc);
} }
static int dev_clear(void) 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 init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -316,7 +315,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
sdi->model = g_strdup(model->name); sdi->model = g_strdup(model->name);
sdi->version = g_strdup(hw_info->firmware_version); sdi->version = g_strdup(hw_info->firmware_version);
sdi->conn = scpi; sdi->conn = scpi;
sdi->driver = di; sdi->driver = &rigol_ds_driver_info;
sdi->inst_type = SR_INST_SCPI; sdi->inst_type = SR_INST_SCPI;
sdi->serial_num = g_strdup(hw_info->serial_number); sdi->serial_num = g_strdup(hw_info->serial_number);
devc = g_malloc0(sizeof(struct dev_context)); devc = g_malloc0(sizeof(struct dev_context));
@ -407,12 +406,12 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
return sdi; return sdi;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
return sr_scpi_scan(di->priv, options, probe_device); return sr_scpi_scan(di->priv, options, probe_device);
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -460,9 +459,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); 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)

View File

@ -39,7 +39,6 @@
#define NUM_SIMUL_TRANSFERS 32 #define NUM_SIMUL_TRANSFERS 32
SR_PRIV struct sr_dev_driver saleae_logic16_driver_info; SR_PRIV struct sr_dev_driver saleae_logic16_driver_info;
static struct sr_dev_driver *di = &saleae_logic16_driver_info;
static const uint32_t scanopts[] = { static const uint32_t scanopts[] = {
SR_CONF_CONN, SR_CONF_CONN,
@ -96,7 +95,7 @@ static const uint64_t samplerates[] = {
SR_MHZ(100), SR_MHZ(100),
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -139,7 +138,7 @@ static gboolean check_conf_profile(libusb_device *dev)
return ret; return ret;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -241,13 +240,14 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int logic16_dev_open(struct sr_dev_inst *sdi) static int logic16_dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di;
libusb_device **devlist; libusb_device **devlist;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
struct libusb_device_descriptor des; struct libusb_device_descriptor des;
@ -255,6 +255,7 @@ static int logic16_dev_open(struct sr_dev_inst *sdi)
int ret, i, device_count; int ret, i, device_count;
char connection_id[64]; char connection_id[64];
di = sdi->driver;
drvc = di->priv; drvc = di->priv;
usb = sdi->conn; usb = sdi->conn;
@ -410,7 +411,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
int ret; int ret;
struct drv_context *drvc; struct drv_context *drvc;
@ -421,7 +422,6 @@ static int cleanup(void)
ret = std_dev_clear(di, NULL); ret = std_dev_clear(di, NULL);
g_free(drvc); g_free(drvc);
di->priv = NULL;
return ret; return ret;
} }
@ -680,11 +680,13 @@ static int receive_data(int fd, int revents, void *cb_data)
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc; struct drv_context *drvc;
const struct sr_dev_inst *sdi; const struct sr_dev_inst *sdi;
struct sr_dev_driver *di;
(void)fd; (void)fd;
(void)revents; (void)revents;
sdi = cb_data; sdi = cb_data;
di = sdi->driver;
drvc = di->priv; drvc = di->priv;
devc = sdi->priv; devc = sdi->priv;
@ -701,6 +703,7 @@ static int receive_data(int fd, int revents, void *cb_data)
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc; struct drv_context *drvc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;

View File

@ -21,7 +21,6 @@
#include "protocol.h" #include "protocol.h"
SR_PRIV struct sr_dev_driver scpi_pps_driver_info; SR_PRIV struct sr_dev_driver scpi_pps_driver_info;
static struct sr_dev_driver *di = &scpi_pps_driver_info;
extern unsigned int num_pps_profiles; extern unsigned int num_pps_profiles;
extern const struct scpi_pps pps_profiles[]; extern const struct scpi_pps pps_profiles[];
@ -40,7 +39,7 @@ static struct pps_channel_instance pci[] = {
{ SR_MQ_POWER, SCPI_CMD_GET_MEAS_POWER, "P" }, { SR_MQ_POWER, SCPI_CMD_GET_MEAS_POWER, "P" },
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -95,7 +94,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
sdi->model = g_strdup(hw_info->model); sdi->model = g_strdup(hw_info->model);
sdi->version = g_strdup(hw_info->firmware_version); sdi->version = g_strdup(hw_info->firmware_version);
sdi->conn = scpi; sdi->conn = scpi;
sdi->driver = di; sdi->driver = &scpi_pps_driver_info;
sdi->inst_type = SR_INST_SCPI; sdi->inst_type = SR_INST_SCPI;
sdi->serial_num = g_strdup(hw_info->serial_number); sdi->serial_num = g_strdup(hw_info->serial_number);
@ -172,17 +171,17 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
return sdi; return sdi;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
return sr_scpi_scan(di->priv, options, probe_device); return sr_scpi_scan(di->priv, options, probe_device);
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }
@ -247,7 +246,7 @@ static void clear_helper(void *priv)
g_free(devc); g_free(devc);
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, clear_helper); return std_dev_clear(di, clear_helper);
} }

View File

@ -629,15 +629,20 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
/* Driver-specific API function wrappers */ /* Driver-specific API function wrappers */
#define HW_INIT(X) \ #define HW_INIT(X) \
static int init_##X(struct sr_context *sr_ctx) { return init(sr_ctx, X); } static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \
(void) di; return init(sr_ctx, X); }
#define HW_CLEANUP(X) \ #define HW_CLEANUP(X) \
static int cleanup_##X(void) { return 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(GSList *options) { return scan(options, X); } static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \
(void) di; return scan(options, X); }
#define HW_DEV_LIST(X) \ #define HW_DEV_LIST(X) \
static GSList *dev_list_##X(void) { return dev_list(X); } static GSList *dev_list_##X(const struct sr_dev_driver *di) { \
(void) di; return dev_list(X); }
#define HW_DEV_CLEAR(X) \ #define HW_DEV_CLEAR(X) \
static int dev_clear_##X(void) { return dev_clear(X); } static int dev_clear_##X(const struct sr_dev_driver *di) { \
(void) di; return dev_clear(X); }
#define HW_DEV_ACQUISITION_START(X) \ #define HW_DEV_ACQUISITION_START(X) \
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }

View File

@ -74,7 +74,7 @@ static const char *const signal_edge_names[] = { "r", "f" };
SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info; SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info;
static struct sr_dev_driver *const di = &sysclk_lwla_driver_info; static struct sr_dev_driver *const di = &sysclk_lwla_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -109,7 +109,7 @@ static struct sr_dev_inst *dev_inst_new(void)
return sdi; return sdi;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
GSList *usb_devices, *devices, *node; GSList *usb_devices, *devices, *node;
struct drv_context *drvc; struct drv_context *drvc;
@ -154,7 +154,7 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
struct drv_context *drvc; struct drv_context *drvc;
@ -175,7 +175,7 @@ static void clear_dev_context(void *priv)
g_free(devc); g_free(devc);
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, &clear_dev_context); return std_dev_clear(di, &clear_dev_context);
} }
@ -243,9 +243,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return dev_clear(); 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,

View File

@ -36,14 +36,13 @@ static const uint32_t devopts[] = {
}; };
SR_PRIV struct sr_dev_driver teleinfo_driver_info; SR_PRIV struct sr_dev_driver teleinfo_driver_info;
static struct sr_dev_driver *di = &teleinfo_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -133,12 +132,12 @@ scan_cleanup:
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -23,7 +23,6 @@
#define SERIALCOMM "115200/8n1" #define SERIALCOMM "115200/8n1"
SR_PRIV struct sr_dev_driver testo_driver_info; SR_PRIV struct sr_dev_driver testo_driver_info;
static struct sr_dev_driver *di = &testo_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static const uint32_t scanopts[] = { static const uint32_t scanopts[] = {
@ -42,12 +41,12 @@ struct testo_model models[] = {
{ "435", 9, TESTO_x35_REQUEST }, { "435", 9, TESTO_x35_REQUEST },
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -149,18 +148,19 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->priv; struct drv_context *drvc = di->priv;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
libusb_device **devlist; libusb_device **devlist;
@ -211,6 +211,7 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
if (!di->priv) { if (!di->priv) {
@ -231,7 +232,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
int ret; int ret;
struct drv_context *drvc; struct drv_context *drvc;
@ -239,9 +240,8 @@ static int cleanup(void)
if (!(drvc = di->priv)) if (!(drvc = di->priv))
return SR_OK; return SR_OK;
ret = dev_clear(); ret = dev_clear(di);
g_free(drvc); g_free(drvc);
di->priv = NULL;
return ret; return ret;
} }
@ -272,6 +272,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
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)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
gint64 now; gint64 now;
int ret; int ret;
@ -415,8 +416,9 @@ SR_PRIV void receive_transfer(struct libusb_transfer *transfer)
static int handle_events(int fd, int revents, void *cb_data) static int handle_events(int fd, int revents, void *cb_data)
{ {
struct sr_dev_driver *di;
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc = di->priv; struct drv_context *drvc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct timeval tv; struct timeval tv;
@ -427,6 +429,8 @@ static int handle_events(int fd, int revents, void *cb_data)
sdi = cb_data; sdi = cb_data;
devc = sdi->priv; devc = sdi->priv;
di = sdi->driver;
drvc = di->priv;
if (devc->limit_msec) { if (devc->limit_msec) {
now = g_get_monotonic_time() / 1000; now = g_get_monotonic_time() / 1000;
@ -452,6 +456,7 @@ static int handle_events(int fd, int revents, void *cb_data)
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
@ -505,6 +510,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
(void)cb_data; (void)cb_data;
if (!di->priv) { if (!di->priv) {

View File

@ -38,14 +38,13 @@ static const uint32_t devopts[] = {
}; };
SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info; SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info;
static struct sr_dev_driver *di = &tondaj_sl_814_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -106,12 +105,12 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -414,15 +414,20 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
/* Driver-specific API function wrappers */ /* Driver-specific API function wrappers */
#define HW_INIT(X) \ #define HW_INIT(X) \
static int init_##X(struct sr_context *sr_ctx) { return init(sr_ctx, X); } static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \
(void) di; return init(sr_ctx, X); }
#define HW_CLEANUP(X) \ #define HW_CLEANUP(X) \
static int cleanup_##X(void) { return 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(GSList *options) { return scan(options, X); } static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \
(void) di; return scan(options, X); }
#define HW_DEV_LIST(X) \ #define HW_DEV_LIST(X) \
static GSList *dev_list_##X(void) { return dev_list(X); } static GSList *dev_list_##X(const struct sr_dev_driver *di) { \
(void) di; return dev_list(X); }
#define HW_DEV_CLEAR(X) \ #define HW_DEV_CLEAR(X) \
static int dev_clear_##X(void) { return dev_clear(X); } static int dev_clear_##X(const struct sr_dev_driver *di) { \
(void) di; return dev_clear(X); }
#define HW_DEV_ACQUISITION_START(X) \ #define HW_DEV_ACQUISITION_START(X) \
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }

View File

@ -40,15 +40,14 @@ static const char *data_sources[] = {
}; };
SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info; SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info;
static struct sr_dev_driver *di = &uni_t_ut32x_driver_info;
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -101,13 +100,14 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc; struct drv_context *drvc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
int ret; int ret;
@ -152,6 +152,7 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
if (!di->priv) { if (!di->priv) {
@ -172,7 +173,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
int ret; int ret;
struct drv_context *drvc; struct drv_context *drvc;
@ -184,7 +185,6 @@ static int cleanup(void)
ret = std_dev_clear(di, NULL); ret = std_dev_clear(di, NULL);
g_free(drvc); g_free(drvc);
di->priv = NULL;
return ret; return ret;
} }
@ -217,6 +217,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
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)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
int ret; int ret;
const char *tmp_str; const char *tmp_str;
@ -280,6 +281,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
static int dev_acquisition_start(const struct sr_dev_inst *sdi, static int dev_acquisition_start(const struct sr_dev_inst *sdi,
void *cb_data) void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;

View File

@ -23,7 +23,6 @@
#include <math.h> #include <math.h>
extern struct sr_dev_driver uni_t_ut32x_driver_info; extern struct sr_dev_driver uni_t_ut32x_driver_info;
static struct sr_dev_driver *di = &uni_t_ut32x_driver_info;
static float parse_temperature(unsigned char *buf) static float parse_temperature(unsigned char *buf)
{ {
@ -194,6 +193,7 @@ SR_PRIV int uni_t_ut32x_handle_events(int fd, int revents, void *cb_data)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
struct sr_dev_driver *di;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
@ -204,11 +204,12 @@ SR_PRIV int uni_t_ut32x_handle_events(int fd, int revents, void *cb_data)
(void)fd; (void)fd;
(void)revents; (void)revents;
drvc = di->priv;
if (!(sdi = cb_data)) if (!(sdi = cb_data))
return TRUE; return TRUE;
di = sdi->driver;
drvc = di->priv;
if (!(devc = sdi->priv)) if (!(devc = sdi->priv))
return TRUE; return TRUE;

View File

@ -32,7 +32,6 @@
#define VICTOR_ENDPOINT LIBUSB_ENDPOINT_IN | 1 #define VICTOR_ENDPOINT LIBUSB_ENDPOINT_IN | 1
SR_PRIV struct sr_dev_driver victor_dmm_driver_info; SR_PRIV struct sr_dev_driver victor_dmm_driver_info;
static struct sr_dev_driver *di = &victor_dmm_driver_info;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
static const uint32_t drvopts[] = { static const uint32_t drvopts[] = {
@ -49,12 +48,12 @@ static const uint32_t devopts[] = {
SR_CONF_CONN | SR_CONF_GET, SR_CONF_CONN | SR_CONF_GET,
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct drv_context *drvc; struct drv_context *drvc;
struct dev_context *devc; struct dev_context *devc;
@ -105,13 +104,14 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->priv; struct drv_context *drvc = di->priv;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
libusb_device **devlist; libusb_device **devlist;
@ -164,6 +164,7 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
if (!di->priv) { if (!di->priv) {
@ -185,7 +186,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
int ret; int ret;
struct drv_context *drvc; struct drv_context *drvc;
@ -197,7 +198,6 @@ static int cleanup(void)
ret = std_dev_clear(di, NULL); ret = std_dev_clear(di, NULL);
g_free(drvc); g_free(drvc);
di->priv = NULL;
return ret; return ret;
} }
@ -228,6 +228,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
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)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
gint64 now; gint64 now;
int ret; int ret;
@ -334,9 +335,10 @@ static void receive_transfer(struct libusb_transfer *transfer)
static int handle_events(int fd, int revents, void *cb_data) static int handle_events(int fd, int revents, void *cb_data)
{ {
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc = di->priv; struct drv_context *drvc;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct sr_dev_driver *di;
struct timeval tv; struct timeval tv;
gint64 now; gint64 now;
@ -345,6 +347,8 @@ static int handle_events(int fd, int revents, void *cb_data)
sdi = cb_data; sdi = cb_data;
devc = sdi->priv; devc = sdi->priv;
di = sdi->driver;
drvc = di->priv;
if (devc->limit_msec) { if (devc->limit_msec) {
now = g_get_monotonic_time() / 1000; now = g_get_monotonic_time() / 1000;
@ -370,6 +374,7 @@ static int handle_events(int fd, int revents, void *cb_data)
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc = di->priv; struct drv_context *drvc = di->priv;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
@ -416,6 +421,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{ {
struct sr_dev_driver *di = sdi->driver;
(void)cb_data; (void)cb_data;
if (!di->priv) { if (!di->priv) {

View File

@ -22,7 +22,6 @@
#include "protocol.h" #include "protocol.h"
SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info; SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info;
static struct sr_dev_driver *di = &yokogawa_dlm_driver_info;
static char *MANUFACTURER_ID = "YOKOGAWA"; static char *MANUFACTURER_ID = "YOKOGAWA";
static char *MANUFACTURER_NAME = "Yokogawa"; static char *MANUFACTURER_NAME = "Yokogawa";
@ -39,7 +38,7 @@ enum {
CG_DIGITAL, CG_DIGITAL,
}; };
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
@ -80,7 +79,7 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
devc = g_malloc0(sizeof(struct dev_context)); devc = g_malloc0(sizeof(struct dev_context));
sdi->driver = di; sdi->driver = &yokogawa_dlm_driver_info;
sdi->priv = devc; sdi->priv = devc;
sdi->inst_type = SR_INST_SCPI; sdi->inst_type = SR_INST_SCPI;
sdi->conn = scpi; sdi->conn = scpi;
@ -104,12 +103,12 @@ fail:
return NULL; return NULL;
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
return sr_scpi_scan(di->priv, options, probe_usbtmc_device); return sr_scpi_scan(di->priv, options, probe_usbtmc_device);
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
@ -127,7 +126,7 @@ static void clear_helper(void *priv)
g_free(devc); g_free(devc);
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, clear_helper); return std_dev_clear(di, clear_helper);
} }
@ -157,9 +156,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
dev_clear(); dev_clear(di);
return SR_OK; return SR_OK;
} }

View File

@ -80,7 +80,6 @@ static const char *channel_names[] = {
}; };
SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info; SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info;
static struct sr_dev_driver *di = &zeroplus_logic_cube_driver_info;
/* /*
* The hardware supports more samplerates than these, but these are the * The hardware supports more samplerates than these, but these are the
@ -156,12 +155,12 @@ SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
return SR_OK; return SR_OK;
} }
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static GSList *scan(GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
struct drv_context *drvc; struct drv_context *drvc;
@ -262,13 +261,14 @@ static GSList *scan(GSList *options)
return devices; return devices;
} }
static GSList *dev_list(void) static GSList *dev_list(const struct sr_dev_driver *di)
{ {
return ((struct drv_context *)(di->priv))->instances; return ((struct drv_context *)(di->priv))->instances;
} }
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc; struct dev_context *devc;
struct drv_context *drvc; struct drv_context *drvc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
@ -382,7 +382,7 @@ static int dev_close(struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
static int cleanup(void) static int cleanup(const struct sr_dev_driver *di)
{ {
return std_dev_clear(di, NULL); return std_dev_clear(di, NULL);
} }

View File

@ -315,7 +315,7 @@ SR_API int sr_driver_init(struct sr_context *ctx, struct sr_dev_driver *driver)
} }
sr_spew("Initializing driver '%s'.", driver->name); sr_spew("Initializing driver '%s'.", driver->name);
if ((ret = driver->init(ctx)) < 0) if ((ret = driver->init(driver, ctx)) < 0)
sr_err("Failed to initialize the driver: %d.", ret); sr_err("Failed to initialize the driver: %d.", ret);
return ret; return ret;
@ -409,7 +409,7 @@ SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options)
return NULL; return NULL;
} }
l = driver->scan(options); l = driver->scan(driver, options);
sr_spew("Scan of '%s' found %d devices.", driver->name, sr_spew("Scan of '%s' found %d devices.", driver->name,
g_slist_length(l)); g_slist_length(l));
@ -427,7 +427,8 @@ SR_PRIV void sr_hw_cleanup_all(void)
drivers = sr_driver_list(); drivers = sr_driver_list();
for (i = 0; drivers[i]; i++) { for (i = 0; drivers[i]; i++) {
if (drivers[i]->cleanup) if (drivers[i]->cleanup)
drivers[i]->cleanup(); drivers[i]->cleanup(drivers[i]);
drivers[i]->priv = NULL;
} }
} }

View File

@ -34,7 +34,6 @@
/** @endcond */ /** @endcond */
SR_PRIV struct sr_dev_driver session_driver_info; SR_PRIV struct sr_dev_driver session_driver_info;
static struct sr_dev_driver *di = &session_driver_info;
struct session_vdev { struct session_vdev {
char *sessionfile; char *sessionfile;
@ -165,12 +164,12 @@ static int receive_data(int fd, int revents, void *cb_data)
/* driver callbacks */ /* driver callbacks */
static int init(struct sr_context *sr_ctx) static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{ {
return std_init(sr_ctx, di, LOG_PREFIX); return std_init(sr_ctx, di, LOG_PREFIX);
} }
static int dev_clear(void) static int dev_clear(const struct sr_dev_driver *di)
{ {
struct drv_context *drvc; struct drv_context *drvc;
GSList *l; GSList *l;
@ -186,9 +185,11 @@ static int dev_clear(void)
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
struct sr_dev_driver *di;
struct drv_context *drvc; struct drv_context *drvc;
struct session_vdev *vdev; struct session_vdev *vdev;
di = sdi->driver;
drvc = di->priv; drvc = di->priv;
vdev = g_malloc0(sizeof(struct session_vdev)); vdev = g_malloc0(sizeof(struct session_vdev));
sdi->priv = vdev; sdi->priv = vdev;

View File

@ -175,7 +175,7 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
if (!session_driver_initialized) { if (!session_driver_initialized) {
/* first device, init the driver */ /* first device, init the driver */
session_driver_initialized = 1; session_driver_initialized = 1;
sdi->driver->init(NULL); sdi->driver->init(sdi->driver, NULL);
} }
sr_dev_open(sdi); sr_dev_open(sdi);
sr_session_dev_add(*session, sdi); sr_session_dev_add(*session, sdi);