X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fvictor-dmm%2Fapi.c;h=6f7416ce72e390349e2b9dbc1c35084e11b3e2bf;hb=6ec6c43b4738dbc7091f4a49a4ec80ea6102cb52;hp=3b77407fc3236eee56cbec35cb9723fd70a49807;hpb=dcd438ee3523098201c7937e75e55775da3b506f;p=libsigrok.git diff --git a/src/hardware/victor-dmm/api.c b/src/hardware/victor-dmm/api.c index 3b77407f..6f7416ce 100644 --- a/src/hardware/victor-dmm/api.c +++ b/src/hardware/victor-dmm/api.c @@ -17,11 +17,12 @@ * along with this program. If not, see . */ +#include #include #include #include #include -#include "libsigrok.h" +#include #include "libsigrok-internal.h" #include "protocol.h" @@ -29,7 +30,7 @@ #define VICTOR_PID 0xd237 #define VICTOR_VENDOR "Victor" #define VICTOR_INTERFACE 0 -#define VICTOR_ENDPOINT LIBUSB_ENDPOINT_IN | 1 +#define VICTOR_ENDPOINT (LIBUSB_ENDPOINT_IN | 1) SR_PRIV struct sr_dev_driver victor_dmm_driver_info; static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); @@ -67,7 +68,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) (void)options; - drvc = di->priv; + drvc = di->context; devices = NULL; libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); @@ -92,7 +93,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->priv = devc; sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1"); - sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]), libusb_get_device_address(devlist[i]), NULL); sdi->inst_type = SR_INST_USB; @@ -107,19 +107,19 @@ 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_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; } @@ -168,7 +168,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; } @@ -192,7 +192,7 @@ static int cleanup(const struct sr_dev_driver *di) int ret; struct drv_context *drvc; - if (!(drvc = di->priv)) + if (!(drvc = di->context)) /* Can get called on an unused driver, doesn't matter. */ return SR_OK; @@ -237,7 +237,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; } @@ -286,7 +286,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static void receive_transfer(struct libusb_transfer *transfer) +static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) { struct dev_context *devc; struct sr_dev_inst *sdi; @@ -343,7 +343,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; @@ -371,7 +371,7 @@ 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 drv_context *drvc = di->context; struct sr_usb_dev_inst *usb; struct libusb_transfer *transfer; int ret; @@ -380,7 +380,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) 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; } @@ -395,7 +395,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) usb_source_add(sdi->session, drvc->sr_ctx, 100, handle_events, (void *)sdi); - buf = g_try_malloc(DMM_DATA_SIZE); + buf = g_malloc(DMM_DATA_SIZE); transfer = libusb_alloc_transfer(0); /* Each transfer request gets 100ms to arrive before it's restarted. * The device only sends 1 transfer/second no matter how many @@ -419,7 +419,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; } @@ -450,5 +450,5 @@ SR_PRIV struct sr_dev_driver victor_dmm_driver_info = { .dev_close = dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, - .priv = NULL, + .context = NULL, };