uint8_t sample_delay_l;
};
-struct dslogic_fpga_config {
+struct fpga_config {
uint32_t sync;
uint16_t mode_header;
* Get the session trigger and configure the FPGA structure
* accordingly.
*/
-static void set_trigger(const struct sr_dev_inst *sdi,
- struct dslogic_fpga_config *cfg)
+static void set_trigger(const struct sr_dev_inst *sdi, struct fpga_config *cfg)
{
struct sr_trigger *trigger;
struct sr_trigger_stage *stage;
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
uint8_t c[3];
- struct dslogic_fpga_config cfg;
+ struct fpga_config cfg;
uint16_t v16;
uint32_t v32;
int transferred, len, ret;
WL32(&cfg.end_sync, DS_CFG_END);
/* Pass in the length of a fixed-size struct. Really. */
- len = sizeof(struct dslogic_fpga_config) / 2;
+ len = sizeof(struct fpga_config) / 2;
c[0] = len & 0xff;
c[1] = (len >> 8) & 0xff;
c[2] = (len >> 16) & 0xff;
set_trigger(sdi, &cfg);
- len = sizeof(struct dslogic_fpga_config);
+ len = sizeof(struct fpga_config);
ret = libusb_bulk_transfer(usb->devhdl, 2 | LIBUSB_ENDPOINT_OUT,
(unsigned char *)&cfg, len, &transferred, USB_TIMEOUT);
if (ret < 0 || transferred != len) {
struct dev_context *devc;
struct drv_context *drvc;
struct version_info vi;
- int ret, i, device_count;
+ int ret = SR_ERR, i, device_count;
uint8_t revid;
char connection_id[64];
if ((sdi->status == SR_ST_INITIALIZING) ||
(sdi->status == SR_ST_INACTIVE)) {
- /*
- * Check device by its physical USB bus/port address.
- */
+ /* Check device by its physical USB bus/port address. */
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (strcmp(sdi->connection_id, connection_id))
/* This is not the one. */
} else {
sr_err("Failed to open device: %s.",
libusb_error_name(ret));
+ ret = SR_ERR;
break;
}
if ((ret = libusb_detach_kernel_driver(usb->devhdl, USB_INTERFACE)) < 0) {
sr_err("Failed to detach kernel driver: %s.",
libusb_error_name(ret));
- return SR_ERR;
+ ret = SR_ERR;
+ break;
}
}
}
sr_err("Expected firmware version %d.x, "
"got %d.%d.", DSLOGIC_REQUIRED_VERSION_MAJOR,
vi.major, vi.minor);
+ ret = SR_ERR;
break;
}
- sdi->status = SR_ST_ACTIVE;
sr_info("Opened device on %d.%d (logical) / %s (physical), "
"interface %d, firmware %d.%d.",
usb->bus, usb->address, connection_id,
sr_info("Detected REVID=%d, it's a Cypress CY7C68013%s.",
revid, (revid != 1) ? " (FX2)" : "A (FX2LP)");
+ ret = SR_OK;
+
break;
}
- libusb_free_device_list(devlist, 1);
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR;
+ libusb_free_device_list(devlist, 1);
- return SR_OK;
+ return ret;
}
SR_PRIV struct dev_context *dslogic_dev_new(void)