X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fikalogic-scanalogic2%2Fapi.c;h=130addc74ea3894e25fa6f51683eba4cc997bfe3;hb=e57057aee778e723da572a6b5e2bd01526cc7beb;hp=97a733a18e194d105838e9486a4fc4f18b52c04b;hpb=4f840ce965b1c30c5ab75afecc56193cbaf5c1b3;p=libsigrok.git
diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c
index 97a733a1..130addc7 100644
--- a/src/hardware/ikalogic-scanalogic2/api.c
+++ b/src/hardware/ikalogic-scanalogic2/api.c
@@ -17,6 +17,7 @@
* along with this program. If not, see .
*/
+#include
#include "protocol.h"
static const uint32_t devopts[] = {
@@ -47,9 +48,8 @@ SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = {
SR_MHZ(20),
};
-static const char *channel_names[NUM_CHANNELS + 1] = {
+static const char *channel_names[] = {
"0", "1", "2", "3",
- NULL,
};
SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info;
@@ -67,17 +67,18 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
struct device_info dev_info;
- int ret, i;
+ unsigned int i;
+ int ret;
(void)options;
devices = NULL;
- drvc = di->priv;
+ drvc = di->context;
drvc->instances = NULL;
usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_VID_PID);
- if (usb_devices == NULL)
+ if (!usb_devices)
return NULL;
for (l = usb_devices; l; l = l->next) {
@@ -117,9 +118,9 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sdi->inst_type = SR_INST_USB;
sdi->conn = usb;
- for (i = 0; channel_names[i]; i++)
- devc->channels[i] = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC,
- TRUE, channel_names[i]);
+ for (i = 0; i < ARRAY_SIZE(channel_names); i++)
+ devc->channels[i] = sr_channel_new(sdi, i,
+ SR_CHANNEL_LOGIC, TRUE, channel_names[i]);
devc->state = STATE_IDLE;
devc->next_state = STATE_IDLE;
@@ -163,7 +164,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 void clear_dev_context(void *priv)
@@ -193,7 +194,7 @@ static int dev_open(struct sr_dev_inst *sdi)
uint8_t buffer[PACKET_LENGTH];
int ret;
- if (!(drvc = di->priv)) {
+ if (!(drvc = di->context)) {
sr_err("Driver was not initialized.");
return SR_ERR;
}
@@ -225,11 +226,11 @@ static int dev_open(struct sr_dev_inst *sdi)
libusb_fill_control_transfer(devc->xfer_in, usb->devhdl,
devc->xfer_buf_in, sl2_receive_transfer_in,
- sdi, USB_TIMEOUT);
+ sdi, USB_TIMEOUT_MS);
libusb_fill_control_transfer(devc->xfer_out, usb->devhdl,
devc->xfer_buf_out, sl2_receive_transfer_out,
- sdi, USB_TIMEOUT);
+ sdi, USB_TIMEOUT_MS);
memset(buffer, 0, sizeof(buffer));
@@ -261,7 +262,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;
}
@@ -321,8 +322,6 @@ 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;
- ret = SR_OK;
-
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
limit_samples = g_variant_get_uint64(data);
@@ -354,7 +353,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
(void)cg;
ret = SR_OK;
-
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -398,7 +396,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- drvc = di->priv;
+ drvc = di->context;
devc->cb_data = cb_data;
devc->wait_data_ready_locked = TRUE;
@@ -506,5 +504,5 @@ SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info = {
.dev_close = dev_close,
.dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop,
- .priv = NULL,
+ .context = NULL,
};