return SR_ERR;
}
- if (libusb_init(&drvc->usb_context) != 0) {
+ if (libusb_init(NULL) != 0) {
g_free(drvc);
sr_err("hantek-dso: Failed to initialize USB.");
return SR_ERR;
clear_instances();
/* Find all Hantek DSO devices and upload firmware to all of them. */
- libusb_get_device_list(drvc->usb_context, &devlist);
+ libusb_get_device_list(NULL, &devlist);
for (i = 0; devlist[i]; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
sr_err("hantek-dso: failed to get device descriptor: %d", ret);
clear_instances();
- if (drvc->usb_context)
- libusb_exit(drvc->usb_context);
- drvc->usb_context = NULL;
+ libusb_exit(NULL);
return SR_OK;
}
const struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet;
struct timeval tv;
- struct drv_context *drvc;
struct dev_context *devc;
const struct libusb_pollfd **lupfd;
int num_probes, i;
(void)fd;
(void)revents;
- drvc = hdi->priv;
sdi = cb_data;
devc = sdi->priv;
if (devc->dev_state == STOPPING) {
sr_dbg("hantek-dso: stopping acquisition");
/* TODO: doesn't really cancel pending transfers so they might
* come in after SR_DF_END is sent. */
- lupfd = libusb_get_pollfds(drvc->usb_context);
+ lupfd = libusb_get_pollfds(NULL);
for (i = 0; lupfd[i]; i++)
sr_source_remove(lupfd[i]->fd);
free(lupfd);
/* Always handle pending libusb events. */
tv.tv_sec = tv.tv_usec = 0;
- libusb_handle_events_timeout(drvc->usb_context, &tv);
+ libusb_handle_events_timeout(NULL, &tv);
/* TODO: ugh */
if (devc->dev_state == NEW_CAPTURE) {
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
- struct drv_context *drvc;
struct dev_context *devc;
int i;
- drvc = hdi->priv;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
return SR_ERR;
devc->dev_state = CAPTURE;
- lupfd = libusb_get_pollfds(drvc->usb_context);
+ lupfd = libusb_get_pollfds(NULL);
for (i = 0; lupfd[i]; i++)
sr_source_add(lupfd[i]->fd, lupfd[i]->events, TICK, handle_event,
(void *)sdi);
#include <libusb.h>
extern struct sr_dev_driver hantek_dso_driver_info;
-static struct sr_dev_driver *hdi = &hantek_dso_driver_info;
static int send_begin(struct dev_context *devc)
{
libusb_device **devlist;
struct libusb_device_descriptor des;
- struct drv_context *drvc;
struct dev_context *devc;
int err, skip, i;
- drvc = hdi->priv;
devc = sdi->priv;
if (sdi->status == SR_ST_ACTIVE)
return SR_ERR;
skip = 0;
- libusb_get_device_list(drvc->usb_context, &devlist);
+ libusb_get_device_list(NULL, &devlist);
for (i = 0; devlist[i]; i++) {
if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
sr_err("hantek-dso: failed to get device descriptor: %d", err);