X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fvictor-dmm%2Fapi.c;h=3970a838bdea51915410ae597cf7fd5c40e8b07d;hb=c1aae90038456a61d0f9313d34e6107c3440d3e7;hp=9aa0019e951e2a580b200a07f68e807b2ccf4659;hpb=1beccaed464a4d92a070988a0331fe399f9f7a7a;p=libsigrok.git diff --git a/src/hardware/victor-dmm/api.c b/src/hardware/victor-dmm/api.c index 9aa0019e..3970a838 100644 --- a/src/hardware/victor-dmm/api.c +++ b/src/hardware/victor-dmm/api.c @@ -21,7 +21,7 @@ #include #include #include -#include "libsigrok.h" +#include #include "libsigrok-internal.h" #include "protocol.h" @@ -29,7 +29,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 +67,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); @@ -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; @@ -231,38 +231,33 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd struct sr_dev_driver *di = sdi->driver; struct dev_context *devc; gint64 now; - int ret; (void)cg; 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; } devc = sdi->priv; - ret = SR_OK; + switch (key) { case SR_CONF_LIMIT_MSEC: devc->limit_msec = g_variant_get_uint64(data); now = g_get_monotonic_time() / 1000; devc->end_time = now + devc->limit_msec; - sr_dbg("Setting time limit to %" PRIu64 "ms.", - devc->limit_msec); break; case SR_CONF_LIMIT_SAMPLES: devc->limit_samples = g_variant_get_uint64(data); - sr_dbg("Setting sample limit to %" PRIu64 ".", - devc->limit_samples); break; default: - ret = SR_ERR_NA; + return SR_ERR_NA; } - return ret; + return SR_OK; } static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, @@ -291,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; @@ -348,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; @@ -376,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; @@ -385,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; } @@ -400,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 @@ -424,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; } @@ -455,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, };