static int dev_open(struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
- struct drv_context *drvc;
+ struct drv_context *drvc = di->context;
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
uint8_t buffer[PACKET_LENGTH];
int ret;
- if (!(drvc = di->context)) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
devc = sdi->priv;
static int dev_close(struct sr_dev_inst *sdi)
{
- struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (!usb->devhdl)
static int dev_open(struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
- struct drv_context *drvc;
+ struct drv_context *drvc = di->context;
struct sr_usb_dev_inst *usb;
int ret;
- if (!(drvc = di->context)) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK)
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;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (!usb->devhdl)
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;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
devc = sdi->priv;
ret = SR_OK;
switch (key) {
static int dev_open(struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
- struct drv_context *drvc;
+ struct drv_context *drvc = di->context;;
struct sr_usb_dev_inst *usb;
int ret;
- if (!(drvc = di->context)) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK)
static int dev_close(struct sr_dev_inst *sdi)
{
- struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (!usb->devhdl)
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;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
devc = sdi->priv;
ret = SR_OK;
switch (key) {
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
drvc = di->context;
devc = sdi->priv;
usb = sdi->conn;
SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- struct sr_dev_driver *di = sdi->driver;
-
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
if (sdi->status != SR_ST_ACTIVE) {
sr_err("Device inactive, can't stop acquisition.");
return SR_ERR;
static int dev_open(struct sr_dev_inst *sdi)
{
- struct drv_context *drvc;
struct dev_context *devc;
int64_t timediff_us, timediff_ms;
int ret;
- drvc = sdi->driver->context;
devc = sdi->priv;
- if (!drvc) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
/*
* If we didn't need to upload FX2 firmware in scan(), open the device
* right away. Otherwise, wait up to MAX_RENUM_DELAY_MS ms for the
/* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */
static int dev_clear(const struct sr_dev_driver *di)
{
+ struct drv_context *drvc = di->context;
GSList *l;
struct sr_dev_inst *sdi;
- struct drv_context *drvc;
struct dev_context *devc;
int ret = SR_OK;
- if (!(drvc = di->context))
- return SR_OK;
-
/* Properly close and free all devices. */
for (l = drvc->instances; l; l = l->next) {
if (!(sdi = l->data)) {
devc = sdi->priv;
usb = sdi->conn;
- if (!drvc) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
if (sdi->status != SR_ST_INACTIVE) {
sr_err("Device already open.");
return SR_ERR;
*/
static int dev_close(struct sr_dev_inst *sdi)
{
- struct drv_context *drvc;
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
int ret;
- drvc = sdi->driver->context;
devc = sdi->priv;
usb = sdi->conn;
- if (!drvc) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
if (sdi->status == SR_ST_INACTIVE) {
sr_dbg("Device already closed.");
return SR_OK;
int ret, i;
char connection_id[64];
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
for (i = 0; devlist[i]; i++) {
static int dev_close(struct sr_dev_inst *sdi)
{
- struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (!usb->devhdl)
/* Nothing to do. */
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
devc = sdi->priv;
ret = SR_OK;
switch (key) {
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
devc = sdi->priv;
usb = sdi->conn;
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- struct sr_dev_driver *di = sdi->driver;
-
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
static int dev_open(struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
- struct drv_context *drvc;
+ struct drv_context *drvc = di->context;
struct sr_usb_dev_inst *usb;
int ret;
- if (!(drvc = di->context)) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK)
static int dev_close(struct sr_dev_inst *sdi)
{
- struct sr_dev_driver *di = sdi->driver;
struct sr_usb_dev_inst *usb;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (!usb->devhdl)
/* Nothing to do. */
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;
const char *tmp_str;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
devc = sdi->priv;
switch (key) {
int ret, i;
char connection_id[64];
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &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->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
if (!usb->devhdl)
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;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
devc = sdi->priv;
switch (key) {
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
usb = sdi->conn;
std_session_send_df_header(sdi, LOG_PREFIX);
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- struct sr_dev_driver *di = sdi->driver;
-
- if (!di->context) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
- }
-
if (sdi->status != SR_ST_ACTIVE) {
sr_err("Device not active, can't stop acquisition.");
return SR_ERR;