/** API version (currently 1). */
int api_version;
/** 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.
* 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.
* Can be called several times, e.g. with different port options.
* \retval NULL Error or no devices found.
* \retval other GSList of a struct sr_dev_inst for each device.
* 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.
* \returns NULL or GSList of a struct sr_dev_inst for each device.
* 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. */
- 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.
* @see sr_config_get().
*/
SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver)
{
if (driver && driver->dev_list)
- return driver->dev_list();
+ return driver->dev_list(driver);
else
return NULL;
}
}
if (driver->dev_clear)
- ret = driver->dev_clear();
+ ret = driver->dev_clear(driver);
else
ret = std_dev_clear(driver, NULL);
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;
struct drv_context *drvc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
#define USB_MODEL_NAME "SIGMA"
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);
/*
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);
}
-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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;
struct drv_context *drvc;
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 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,
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);
}
-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 drv_context *drvc;
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;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return std_dev_clear(di, NULL);
}
#include "protocol.h"
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[] = {
SR_CONF_CONTINUOUS | SR_CONF_SET,
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return NULL;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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 SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
- dev_clear();
+ dev_clear(di);
return SR_OK;
}
#include "beaglelogic.h"
SR_PRIV struct sr_dev_driver beaglelogic_driver_info;
-static struct sr_dev_driver *di = &beaglelogic_driver_info;
/* Scan options */
static const uint32_t scanopts[] = {
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 devc;
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
GSList *devices, *l;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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 SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
struct drv_context *drvc;
struct sr_dev_inst *sdi;
g_slist_free(drvc->instances);
drvc->instances = NULL;
- di->priv = NULL;
-
return SR_OK;
}
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
GSList *usb_devices, *devices, *l;
struct drv_context *drvc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->priv;
struct sr_usb_dev_inst *usb;
struct dev_context *devc;
return ret;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return std_dev_clear(di, NULL);
}
SR_PRIV struct sr_dev_driver 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 devices;
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct sr_config *src;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
"Memory",
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
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 SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return std_dev_clear(di, NULL);
}
/* Driver-specific API function wrappers */
#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) \
-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) \
-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) \
-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) \
-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) \
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
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);
}
-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 ret;
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
int ret;
unsigned int i;
GSList *devices;
struct ftdi_context *ftdic;
+ (void)di;
(void)options;
devices = NULL;
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 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,
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
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 SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return std_dev_clear(di, NULL);
}
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;
struct drv_context *drvc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
};
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 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);
}
}
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
g_free(devc);
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return std_dev_clear(di, clear_helper);
}
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;
}
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;
if (!(sdi = es51919_serial_scan(options, "DER EE", "DE-5000")))
return NULL;
- std_dev_attach(&deree_de5000_driver_info, sdi);
+ std_dev_attach(di, 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 = {
.name = "deree-de5000",
.longname = "DER EE DE-5000",
};
SR_PRIV struct sr_dev_driver flukedmm_driver_info;
-static struct sr_dev_driver *di = &flukedmm_driver_info;
static char *scan_conn[] = {
/* 287/289 */
{ 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);
}
-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 drv_context *drvc;
return devices;
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_config *src;
GSList *l, *devices;
devices = NULL;
if (serialcomm) {
/* Use the provided comm specs. */
- devices = fluke_scan(conn, serialcomm);
+ devices = fluke_scan(di, conn, serialcomm);
} else {
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;
/* The Scopemeter 199B, at least, requires this
* after all the 115k/9.6k confusion. */
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
struct dev_context *devc;
int ret;
return SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
int ret;
struct drv_context *drvc;
ret = std_dev_clear(di, NULL);
g_free(drvc);
- di->priv = NULL;
return ret;
}
(void)revents;
(void)cb_data;
- drvc = di->priv;
+ drvc = (struct drv_context *) cb_data;
tv.tv_sec = tv.tv_usec = 0;
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{
+ struct sr_dev_driver *di;
struct drv_context *drvc;
struct dev_context *devc;
int timeout, ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
+ di = sdi->driver;
drvc = di->priv;
devc = sdi->priv;
devc->acq_aborted = FALSE;
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) {
dslogic_trigger_request(sdi);
* Need to implement device-specific lists.
*/
-/** Init driver gmc_mh_1x_2x_rs232. */
-static int init_1x_2x_rs232(struct sr_context *sr_ctx)
+/** Init driver. */
+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);
-}
-
-/** 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);
+ return std_init(sr_ctx, di, LOG_PREFIX);
}
/**
* on configuration and measurement mode the intervals can be much larger and
* 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 drv_context *drvc;
gboolean serialcomm_given;
devices = NULL;
- drvc = (&gmc_mh_1x_2x_rs232_driver_info)->priv;
+ drvc = di->priv;
drvc->instances = NULL;
conn = serialcomm = NULL;
model = METRAHIT_NONE;
devc->settings_ok = FALSE;
sdi->conn = serial;
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");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
/** 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 drv_context *drvc;
conn = serialcomm = NULL;
devices = NULL;
- drvc = (&gmc_mh_2x_bd232_driver_info)->priv;
+ drvc = di->priv;
drvc->instances = NULL;
sr_spew("scan_2x_bd232() called!");
sdi->version = g_strdup_printf("Firmware %d.%d", devc->fw_ver_maj, devc->fw_ver_min);
sdi->conn = serial;
sdi->priv = devc;
- sdi->driver = &gmc_mh_2x_bd232_driver_info;
+ sdi->driver = di;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
}
/** Driver device list function */
-static GSList *dev_list_1x_2x_rs232(void)
-{
- return ((struct drv_context *)(gmc_mh_1x_2x_rs232_driver_info.priv))->instances;
-}
-
-/** Driver device list function */
-static GSList *dev_list_2x_bd232(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
- return ((struct drv_context *)(gmc_mh_2x_bd232_driver_info.priv))
- ->instances;
+ return ((struct drv_context *)(di->priv))->instances;
}
static int dev_close(struct sr_dev_inst *sdi)
return SR_OK;
}
-static int cleanup_sm_rs232(void)
-{
- return std_dev_clear(&gmc_mh_1x_2x_rs232_driver_info, NULL);
-}
-
-static int cleanup_2x_bd232(void)
+static int cleanup(const struct sr_dev_driver *di)
{
- return std_dev_clear(&gmc_mh_2x_bd232_driver_info, NULL);
+ return std_dev_clear(di, NULL);
}
/** Get value of configuration item */
.name = "gmc-mh-1x-2x-rs232",
.longname = "Gossen Metrawatt Metrahit 1x/2x, RS232 interface",
.api_version = 1,
- .init = init_1x_2x_rs232,
- .cleanup = cleanup_sm_rs232,
+ .init = init,
+ .cleanup = cleanup,
.scan = scan_1x_2x_rs232,
- .dev_list = dev_list_1x_2x_rs232,
+ .dev_list = dev_list,
.dev_clear = NULL,
.config_get = config_get,
.config_set = config_set,
.name = "gmc-mh-2x-bd232",
.longname = "Gossen Metrawatt Metrahit 2x, BD232/SI232-II interface",
.api_version = 1,
- .init = init_2x_bd232,
- .cleanup = cleanup_2x_bd232,
+ .init = init,
+ .cleanup = cleanup,
.scan = scan_2x_bd232,
- .dev_list = dev_list_2x_bd232,
+ .dev_list = dev_list,
.dev_clear = NULL,
.config_get = config_get,
.config_set = config_set,
#define SERIALCOMM "115200/8n1/flow=1"
SR_PRIV struct sr_dev_driver hameg_hmo_driver_info;
-static struct sr_dev_driver *di = &hameg_hmo_driver_info;
static const char *manufacturers[] = {
"HAMEG",
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);
}
sdi->model = g_strdup(hw_info->model);
sdi->version = g_strdup(hw_info->firmware_version);
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->conn = scpi;
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);
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
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 SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
- dev_clear();
+ dev_clear(di);
return SR_OK;
}
};
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);
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(prof->vendor);
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
devc->triggersource = g_strdup(DEFAULT_TRIGGER_SOURCE);
devc->triggerposition = DEFAULT_HORIZ_TRIGGERPOS;
sdi->priv = devc;
- drvc = di->priv;
+ drvc = hantek_dso_driver_info.priv;
drvc->instances = g_slist_append(drvc->instances, sdi);
return sdi;
}
-static int dev_clear(void)
+static int dev_clear(const struct sr_dev_driver *di)
{
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
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 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,
const struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet;
struct timeval tv;
+ struct sr_dev_driver *di;
struct dev_context *devc;
- struct drv_context *drvc = di->priv;
+ struct drv_context *drvc;
int num_channels;
uint32_t trigger_offset;
uint8_t capturestate;
(void)revents;
sdi = cb_data;
+ di = sdi->driver;
+ drvc = di->priv;
devc = sdi->priv;
if (devc->dev_state == STOPPING) {
/* We've been told to wind up the acquisition. */
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{
struct dev_context *devc;
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->priv;
if (sdi->status != SR_ST_ACTIVE)
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
GSList *usb_devices, *devices, *l;
struct drv_context *drvc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
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);
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
static int dev_close(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
if (!di->priv) {
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 dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
struct dev_context *devc;
uint16_t trigger_bytes, tmp;
#include "protocol.h"
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];
SR_PRIV int ikalogic_scanalogic2_receive_data(int fd, int revents, void *cb_data)
{
struct sr_dev_inst *sdi;
+ struct sr_dev_driver *di;
struct dev_context *devc;
struct drv_context *drvc;
struct timeval tv;
if (!(devc = sdi->priv))
return TRUE;
+ di = sdi->driver;
drvc = di->priv;
current_time = g_get_monotonic_time();
uint8_t buffer[PACKET_LENGTH];
int ret;
- drvc = di->priv;
+ drvc = ikalogic_scanalogic2_driver_info.priv;
if (!dev_info)
return SR_ERR_ARG;
static uint64_t samplerates[1] = { SR_MHZ(100) };
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);
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);
}
-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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;
struct drv_context *drvc;
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 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,
};
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);
}
-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;
int len, ret;
return SR_OK;
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
/* We have a list of sr_usb_dev_inst matching the connection
* string. Wrap them in sr_dev_inst and we're done. */
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;
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
struct sr_usb_dev_inst *usb;
int ret;
static int dev_close(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
return SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
int ret;
struct drv_context *drvc;
ret = std_dev_clear(di, NULL);
g_free(drvc);
- di->priv = NULL;
return ret;
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
+ struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc;
uint64_t p, q;
unsigned int i;
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 dev_context *devc;
struct sr_datafeed_packet packet;
#include "protocol.h"
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];
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 dev_context *devc;
struct sr_datafeed_packet packet;
(void)fd;
(void)revents;
- drvc = di->priv;
sdi = cb_data;
devc = sdi->priv;
usb = sdi->conn;
+ di = sdi->driver;
+ drvc = di->priv;
memset(&tv, 0, sizeof(struct timeval));
libusb_handle_events_timeout_completed(drvc->sr_ctx->libusb_ctx, &tv,
#include "protocol.h"
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[] = {
SR_CONF_CONN,
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct sr_dev_inst *sdi;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
struct sr_usb_dev_inst *usb;
int ret;
static int dev_close(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
if (!di->priv) {
return SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
int ret;
struct drv_context *drvc;
ret = std_dev_clear(di, NULL);
g_free(drvc);
- di->priv = NULL;
return ret;
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
+ struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc;
int ret;
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_meta meta;
struct sr_config *src;
SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
+ struct sr_dev_driver *di = sdi->driver;
(void)cb_data;
if (!di->priv) {
#include "protocol.h"
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[] = {
{ 1, "EL-USB-1", LOG_UNSUPPORTED },
};
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(). */
-static int dev_clear(void)
+static int dev_clear(const struct sr_dev_driver *di)
{
GSList *l;
struct sr_dev_inst *sdi;
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
int i;
GSList *devices = NULL;
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 SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return dev_clear();
}
static const char mso_foot[] = { 0x7e };
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,
uint16_t payload[], int n)
};
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);
}
-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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
int i, model_id;
struct drv_context *drvc;
return NULL;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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,
/* Driver-specific API function wrappers */
#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) \
-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) \
-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) \
-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) \
-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) \
static int config_list_##X(uint32_t key, GVariant **data, \
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { \
},
};
-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.
}
/** 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;
-}
-
-static GSList *dev_list_lps301(void)
-{
- return doDevList(&motech_lps_301_driver_info);
+ return ((struct drv_context *)(di->priv))->instances;
}
static void dev_clear_private(struct dev_context* devc)
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,
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)
-{
- return std_init(sr_ctx, &siemens_b102x_driver_info, LOG_PREFIX);
-}
-
-static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
+static GSList *scan(struct sr_dev_driver* drv, GSList *options)
{
struct sr_dev_inst *sdi;
struct drv_context *drvc;
return devices;
}
-static GSList *scan_norma_dmm(GSList *options)
-{
- return do_scan(&norma_dmm_driver_info, options);
-}
-
-static GSList *scan_siemens_b102x(GSList *options)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
- 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;
+ return ((struct drv_context *)(di->priv))->instances;
}
static int dev_close(struct sr_dev_inst *sdi)
return SR_OK;
}
-static int cleanup_norma_dmm(void)
-{
- return std_dev_clear(&norma_dmm_driver_info, NULL);
-}
-
-static int cleanup_siemens_b102x(void)
+static int cleanup(const struct sr_dev_driver *di)
{
- return std_dev_clear(&siemens_b102x_driver_info, NULL);
+ return std_dev_clear(di, NULL);
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
.name = "norma-dmm",
.longname = "Norma DM9x0 DMMs",
.api_version = 1,
- .init = init_norma_dmm,
- .cleanup = cleanup_norma_dmm,
- .scan = scan_norma_dmm,
- .dev_list = dev_list_norma_dmm,
+ .init = init,
+ .cleanup = cleanup,
+ .scan = scan,
+ .dev_list = dev_list,
.dev_clear = NULL,
.config_get = NULL,
.config_set = config_set,
.name = "siemens-b102x",
.longname = "Siemens B102x DMMs",
.api_version = 1,
- .init = init_siemens_b102x,
- .cleanup = cleanup_siemens_b102x,
- .scan = scan_siemens_b102x,
- .dev_list = dev_list_siemens_b102x,
+ .init = init,
+ .cleanup = cleanup,
+ .scan = scan,
+ .dev_list = dev_list,
.dev_clear = NULL,
.config_get = NULL,
.config_set = config_set,
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_config *src;
struct sr_dev_inst *sdi;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
#include <libserialport.h>
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,
uint8_t command)
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
- sdi->driver = di;
+ sdi->driver = &ols_driver_info;
devc = ols_dev_new();
sdi->priv = devc;
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;
struct drv_context *drvc;
return NULL;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
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);
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
- return dev_clear();
+ return dev_clear(di);
}
#include "protocol.h"
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)
{
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
- sdi->driver = di;
+ sdi->driver = &p_ols_driver_info;
sdi->priv = devc;
devname = g_string_new("");
};
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)
{
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);
}
-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);
}
sdi->model = g_strdup(model->name);
sdi->version = g_strdup(hw_info->firmware_version);
sdi->conn = scpi;
- sdi->driver = di;
+ sdi->driver = &rigol_ds_driver_info;
sdi->inst_type = SR_INST_SCPI;
sdi->serial_num = g_strdup(hw_info->serial_number);
devc = g_malloc0(sizeof(struct dev_context));
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);
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
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)
#define NUM_SIMUL_TRANSFERS 32
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[] = {
SR_CONF_CONN,
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 ret;
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
static int logic16_dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di;
libusb_device **devlist;
struct sr_usb_dev_inst *usb;
struct libusb_device_descriptor des;
int ret, i, device_count;
char connection_id[64];
+ di = sdi->driver;
drvc = di->priv;
usb = sdi->conn;
return SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
int ret;
struct drv_context *drvc;
ret = std_dev_clear(di, NULL);
g_free(drvc);
- di->priv = NULL;
return ret;
}
struct dev_context *devc;
struct drv_context *drvc;
const struct sr_dev_inst *sdi;
+ struct sr_dev_driver *di;
(void)fd;
(void)revents;
sdi = cb_data;
+ di = sdi->driver;
drvc = di->priv;
devc = sdi->priv;
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 drv_context *drvc;
struct sr_usb_dev_inst *usb;
#include "protocol.h"
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 const struct scpi_pps pps_profiles[];
{ 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);
}
sdi->model = g_strdup(hw_info->model);
sdi->version = g_strdup(hw_info->firmware_version);
sdi->conn = scpi;
- sdi->driver = di;
+ sdi->driver = &scpi_pps_driver_info;
sdi->inst_type = SR_INST_SCPI;
sdi->serial_num = g_strdup(hw_info->serial_number);
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);
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
g_free(devc);
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return std_dev_clear(di, clear_helper);
}
/* Driver-specific API function wrappers */
#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) \
-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) \
-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) \
-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) \
-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) \
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
SR_PRIV struct sr_dev_driver 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 sdi;
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
GSList *usb_devices, *devices, *node;
struct drv_context *drvc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
struct drv_context *drvc;
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 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,
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
#define SERIALCOMM "115200/8n1"
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 const uint32_t scanopts[] = {
{ "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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->priv;
struct sr_usb_dev_inst *usb;
libusb_device **devlist;
static int dev_close(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
if (!di->priv) {
return SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
int ret;
struct drv_context *drvc;
if (!(drvc = di->priv))
return SR_OK;
- ret = dev_clear();
+ ret = dev_clear(di);
g_free(drvc);
- di->priv = NULL;
return ret;
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
+ struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc;
gint64 now;
int ret;
static int handle_events(int fd, int revents, void *cb_data)
{
+ struct sr_dev_driver *di;
struct dev_context *devc;
- struct drv_context *drvc = di->priv;
+ struct drv_context *drvc;
struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
struct timeval tv;
sdi = cb_data;
devc = sdi->priv;
+ di = sdi->driver;
+ drvc = di->priv;
if (devc->limit_msec) {
now = g_get_monotonic_time() / 1000;
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 dev_context *devc;
struct sr_usb_dev_inst *usb;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
+ struct sr_dev_driver *di = sdi->driver;
(void)cb_data;
if (!di->priv) {
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
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);
}
/* Driver-specific API function wrappers */
#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) \
-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) \
-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) \
-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) \
-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) \
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
};
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
struct sr_usb_dev_inst *usb;
int ret;
static int dev_close(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
if (!di->priv) {
return SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
int ret;
struct drv_context *drvc;
ret = std_dev_clear(di, NULL);
g_free(drvc);
- di->priv = NULL;
return ret;
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
+ struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc;
int ret;
const char *tmp_str;
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 dev_context *devc;
struct sr_usb_dev_inst *usb;
#include <math.h>
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)
{
{
struct drv_context *drvc;
struct dev_context *devc;
+ struct sr_dev_driver *di;
struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet;
struct sr_usb_dev_inst *usb;
(void)fd;
(void)revents;
- drvc = di->priv;
-
if (!(sdi = cb_data))
return TRUE;
+ di = sdi->driver;
+ drvc = di->priv;
+
if (!(devc = sdi->priv))
return TRUE;
#define VICTOR_ENDPOINT LIBUSB_ENDPOINT_IN | 1
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 const uint32_t drvopts[] = {
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct dev_context *devc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->priv;
struct sr_usb_dev_inst *usb;
libusb_device **devlist;
static int dev_close(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
if (!di->priv) {
return SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
int ret;
struct drv_context *drvc;
ret = std_dev_clear(di, NULL);
g_free(drvc);
- di->priv = NULL;
return ret;
}
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
+ struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc;
gint64 now;
int ret;
static int handle_events(int fd, int revents, void *cb_data)
{
struct dev_context *devc;
- struct drv_context *drvc = di->priv;
+ struct drv_context *drvc;
struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
+ struct sr_dev_driver *di;
struct timeval tv;
gint64 now;
sdi = cb_data;
devc = sdi->priv;
+ di = sdi->driver;
+ drvc = di->priv;
if (devc->limit_msec) {
now = g_get_monotonic_time() / 1000;
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 drv_context *drvc = di->priv;
struct sr_usb_dev_inst *usb;
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
+ struct sr_dev_driver *di = sdi->driver;
(void)cb_data;
if (!di->priv) {
#include "protocol.h"
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_NAME = "Yokogawa";
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);
}
devc = g_malloc0(sizeof(struct dev_context));
- sdi->driver = di;
+ sdi->driver = &yokogawa_dlm_driver_info;
sdi->priv = devc;
sdi->inst_type = SR_INST_SCPI;
sdi->conn = scpi;
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);
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
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 SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
- dev_clear();
+ dev_clear(di);
return SR_OK;
}
};
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
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);
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct sr_dev_inst *sdi;
struct drv_context *drvc;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc;
struct drv_context *drvc;
struct sr_usb_dev_inst *usb;
return SR_OK;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return std_dev_clear(di, NULL);
}
}
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);
return ret;
return NULL;
}
- l = driver->scan(options);
+ l = driver->scan(driver, options);
sr_spew("Scan of '%s' found %d devices.", driver->name,
g_slist_length(l));
drivers = sr_driver_list();
for (i = 0; drivers[i]; i++) {
if (drivers[i]->cleanup)
- drivers[i]->cleanup();
+ drivers[i]->cleanup(drivers[i]);
+ drivers[i]->priv = NULL;
}
}
/** @endcond */
SR_PRIV struct sr_dev_driver session_driver_info;
-static struct sr_dev_driver *di = &session_driver_info;
struct session_vdev {
char *sessionfile;
/* 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);
}
-static int dev_clear(void)
+static int dev_clear(const struct sr_dev_driver *di)
{
struct drv_context *drvc;
GSList *l;
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di;
struct drv_context *drvc;
struct session_vdev *vdev;
+ di = sdi->driver;
drvc = di->priv;
vdev = g_malloc0(sizeof(struct session_vdev));
sdi->priv = vdev;
if (!session_driver_initialized) {
/* first device, init the driver */
session_driver_initialized = 1;
- sdi->driver->init(NULL);
+ sdi->driver->init(sdi->driver, NULL);
}
sr_dev_open(sdi);
sr_session_dev_add(*session, sdi);