X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ftesto%2Fapi.c;h=0c37886e30c9d995e17c1a9c95eeee59c24e3679;hb=2a8f2d41adcd0aa9e498c4eea2a5f82263039e5c;hp=64d292dd3488b2a0d928a834bfb65976b1c80130;hpb=dcd438ee3523098201c7937e75e55775da3b506f;p=libsigrok.git
diff --git a/src/hardware/testo/api.c b/src/hardware/testo/api.c
index 64d292dd..0c37886e 100644
--- a/src/hardware/testo/api.c
+++ b/src/hardware/testo/api.c
@@ -17,6 +17,7 @@
* along with this program. If not, see .
*/
+#include
#include
#include "protocol.h"
@@ -63,7 +64,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
char manufacturer[64], product[64], connection_id[64];
devices = NULL;
- drvc = di->priv;
+ drvc = di->context;
drvc->instances = NULL;
conn_devices = NULL;
@@ -91,11 +92,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
continue;
}
- if ((ret = libusb_get_device_descriptor( devlist[i], &des)) != 0) {
- sr_warn("Failed to get device descriptor: %s.",
- libusb_error_name(ret));
- continue;
- }
+ libusb_get_device_descriptor(devlist[i], &des);
if ((ret = libusb_open(devlist[i], &hdl)) < 0)
continue;
@@ -151,7 +148,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
static GSList *dev_list(const struct sr_dev_driver *di)
{
- return ((struct drv_context *)(di->priv))->instances;
+ return ((struct drv_context *)(di->context))->instances;
}
static int dev_clear(const struct sr_dev_driver *di)
@@ -162,13 +159,13 @@ static int dev_clear(const struct sr_dev_driver *di)
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->context;
struct sr_usb_dev_inst *usb;
libusb_device **devlist;
int ret, i;
char connection_id[64];
- if (!di->priv) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
@@ -215,7 +212,7 @@ 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) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
@@ -238,7 +235,7 @@ static int cleanup(const struct sr_dev_driver *di)
int ret;
struct drv_context *drvc;
- if (!(drvc = di->priv))
+ if (!(drvc = di->context))
return SR_OK;
ret = dev_clear(di);
@@ -283,7 +280,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->priv) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
@@ -372,7 +369,7 @@ static void receive_data(struct sr_dev_inst *sdi, unsigned char *data, int len)
}
-SR_PRIV void receive_transfer(struct libusb_transfer *transfer)
+SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
{
struct dev_context *devc;
struct sr_dev_inst *sdi;
@@ -427,7 +424,7 @@ static int handle_events(int fd, int revents, void *cb_data)
sdi = cb_data;
devc = sdi->priv;
di = sdi->driver;
- drvc = di->priv;
+ drvc = di->context;
if (devc->limit_msec) {
now = g_get_monotonic_time() / 1000;
@@ -461,11 +458,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
int ret;
unsigned char *buf;
- drvc = di->priv;
+ drvc = di->context;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!di->priv) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
@@ -490,7 +487,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
if (testo_request_packet(sdi) != SR_OK)
return SR_ERR;
- buf = g_try_malloc(MAX_REPLY_SIZE);
+ buf = g_malloc(MAX_REPLY_SIZE);
transfer = libusb_alloc_transfer(0);
libusb_fill_bulk_transfer(transfer, usb->devhdl, EP_IN, buf,
MAX_REPLY_SIZE, receive_transfer, (void *)sdi, 100);
@@ -510,7 +507,7 @@ 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) {
+ if (!di->context) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
@@ -539,5 +536,5 @@ SR_PRIV struct sr_dev_driver testo_driver_info = {
.dev_close = dev_close,
.dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop,
- .priv = NULL,
+ .context = NULL,
};