};
SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
-static struct sr_dev_driver *fdi = &fx2lafw_driver_info;
+static struct sr_dev_driver *di = &fx2lafw_driver_info;
static int hw_dev_close(struct sr_dev_inst *sdi);
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value);
libusb_device **devlist;
struct libusb_device_descriptor des;
struct dev_context *devc;
- struct drv_context *drvc = fdi->priv;
+ struct drv_context *drvc = di->priv;
struct version_info vi;
int ret, skip, i;
uint8_t revid;
const int device_count = libusb_get_device_list(
drvc->sr_ctx->libusb_ctx, &devlist);
if (device_count < 0) {
- sr_err("fx2lafw: Failed to retrieve device list (%d)",
+ sr_err("Failed to retrieve device list (%d)",
device_count);
return SR_ERR;
}
for (i = 0; i < device_count; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("fx2lafw: Failed to get device descriptor: %d.",
- ret);
+ sr_err("Failed to get device descriptor: %s.",
+ libusb_error_name(ret));
continue;
}
*/
devc->usb->address = libusb_get_device_address(devlist[i]);
} else {
- sr_err("fx2lafw: Failed to open device: %d.", ret);
+ sr_err("Failed to open device: %s.",
+ libusb_error_name(ret));
break;
}
ret = command_get_fw_version(devc->usb->devhdl, &vi);
if (ret != SR_OK) {
- sr_err("fx2lafw: Failed to retrieve "
+ sr_err("Failed to retrieve "
"firmware version information.");
break;
}
ret = command_get_revid_version(devc->usb->devhdl, &revid);
if (ret != SR_OK) {
- sr_err("fx2lafw: Failed to retrieve REVID.");
+ sr_err("Failed to retrieve REVID.");
break;
}
* Different minor versions are OK, they should be compatible.
*/
if (vi.major != FX2LAFW_REQUIRED_VERSION_MAJOR) {
- sr_err("fx2lafw: Expected firmware version %d.x, "
+ sr_err("Expected firmware version %d.x, "
"got %d.%d.", FX2LAFW_REQUIRED_VERSION_MAJOR,
vi.major, vi.minor);
break;
}
sdi->status = SR_ST_ACTIVE;
- sr_info("fx2lafw: Opened device %d on %d.%d "
+ sr_info("Opened device %d on %d.%d "
"interface %d, firmware %d.%d, REVID %d.",
sdi->index, devc->usb->bus, devc->usb->address,
USB_INTERFACE, vi.major, vi.minor, revid);
struct dev_context *devc;
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("fx2lafw: %s: devc malloc failed.", __func__);
+ sr_err("%s: devc malloc failed.", __func__);
return NULL;
}
struct dev_context *devc;
int ret;
- drvc = fdi->priv;
+ drvc = di->priv;
ret = SR_OK;
for (l = drvc->instances; l; l = l->next) {
if (!(sdi = l->data)) {
/* Log error, but continue cleaning up the rest. */
- sr_err("fx2lafw: %s: sdi was NULL, continuing.",
+ sr_err("%s: sdi was NULL, continuing.",
__func__);
ret = SR_ERR_BUG;
continue;
}
if (!(devc = sdi->priv)) {
/* Log error, but continue cleaning up the rest. */
- sr_err("fx2lafw: %s: sdi->priv was NULL, continuing",
+ sr_err("%s: sdi->priv was NULL, continuing",
__func__);
ret = SR_ERR_BUG;
continue;
struct drv_context *drvc;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
- sr_err("fx2lafw: driver context malloc failed.");
+ sr_err("Driver context malloc failed.");
return SR_ERR_MALLOC;
}
drvc->sr_ctx = sr_ctx;
- fdi->priv = drvc;
+ di->priv = drvc;
return SR_OK;
}
(void)options;
- drvc = fdi->priv;
+ drvc = di->priv;
/* This scan always invalidates any previous scans. */
clear_instances();
if ((ret = libusb_get_device_descriptor(
devlist[i], &des)) != 0) {
- sr_warn("fx2lafw: Failed to get device descriptor: %d.", ret);
+ sr_warn("Failed to get device descriptor: %s.",
+ libusb_error_name(ret));
continue;
}
prof->vendor, prof->model, prof->model_version);
if (!sdi)
return NULL;
- sdi->driver = fdi;
+ sdi->driver = di;
/* Fill in probelist according to this device's profile. */
num_logic_probes = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
if (check_conf_profile(devlist[i])) {
/* Already has the firmware, so fix the new address. */
- sr_dbg("fx2lafw: Found an fx2lafw device.");
+ sr_dbg("Found an fx2lafw device.");
sdi->status = SR_ST_INACTIVE;
devc->usb = sr_usb_dev_inst_new
(libusb_get_bus_number(devlist[i]),
/* Remember when the firmware on this device was updated */
devc->fw_updated = g_get_monotonic_time();
else
- sr_err("fx2lafw: Firmware upload failed for "
+ sr_err("Firmware upload failed for "
"device %d.", devcnt);
devc->usb = sr_usb_dev_inst_new
(libusb_get_bus_number(devlist[i]), 0xff, NULL);
{
struct drv_context *drvc;
- drvc = fdi->priv;
+ drvc = di->priv;
return drvc->instances;
}
*/
ret = SR_ERR;
if (devc->fw_updated > 0) {
- sr_info("fx2lafw: Waiting for device to reset.");
+ sr_info("Waiting for device to reset.");
/* takes at least 300ms for the FX2 to be gone from the USB bus */
g_usleep(300 * 1000);
timediff_ms = 0;
timediff_us = g_get_monotonic_time() - devc->fw_updated;
timediff_ms = timediff_us / 1000;
- sr_spew("fx2lafw: waited %" PRIi64 " ms", timediff_ms);
+ sr_spew("Waited %" PRIi64 " ms", timediff_ms);
}
- sr_info("fx2lafw: Device came back after %d ms.", timediff_ms);
+ if (ret != SR_OK) {
+ sr_err("Device failed to renumerate.");
+ return SR_ERR;
+ }
+ sr_info("Device came back after %d ms.",
+ timediff_ms);
} else {
+ sr_info("Firmware upload was not needed.");
ret = fx2lafw_dev_open(sdi);
}
if (ret != SR_OK) {
- sr_err("fx2lafw: Unable to open device.");
+ sr_err("Unable to open device.");
return SR_ERR;
}
+
devc = sdi->priv;
ret = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE);
if (ret != 0) {
switch(ret) {
case LIBUSB_ERROR_BUSY:
- sr_err("fx2lafw: Unable to claim USB interface. Another "
+ sr_err("Unable to claim USB interface. Another "
"program or driver has already claimed it.");
break;
case LIBUSB_ERROR_NO_DEVICE:
- sr_err("fx2lafw: Device has been disconnected.");
+ sr_err("Device has been disconnected.");
break;
default:
- sr_err("fx2lafw: Unable to claim interface: %d.", ret);
+ sr_err("Unable to claim interface: %s.",
+ libusb_error_name(ret));
break;
}
if (devc->usb->devhdl == NULL)
return SR_ERR;
- sr_info("fx2lafw: Closing device %d on %d.%d interface %d.",
+ sr_info("Closing device %d on %d.%d interface %d.",
sdi->index, devc->usb->bus, devc->usb->address, USB_INTERFACE);
libusb_release_interface(devc->usb->devhdl, USB_INTERFACE);
libusb_close(devc->usb->devhdl);
struct drv_context *drvc;
int ret;
- if (!(drvc = fdi->priv))
+ if (!(drvc = di->priv))
return SR_OK;
ret = clear_instances();
g_free(drvc);
- fdi->priv = NULL;
+ di->priv = NULL;
return ret;
}
static int receive_data(int fd, int revents, void *cb_data)
{
struct timeval tv;
- struct drv_context *drvc = fdi->priv;
+ struct drv_context *drvc = di->priv;
(void)fd;
(void)revents;
static void finish_acquisition(struct dev_context *devc)
{
struct sr_datafeed_packet packet;
- struct drv_context *drvc = fdi->priv;
+ struct drv_context *drvc = di->priv;
int i;
static void resubmit_transfer(struct libusb_transfer *transfer)
{
- if (libusb_submit_transfer(transfer) != 0) {
- free_transfer(transfer);
- /* TODO: Stop session? */
- /* TODO: Better error message. */
- sr_err("fx2lafw: %s: libusb_submit_transfer error.", __func__);
- }
+ int ret = libusb_submit_transfer(transfer);
+
+ if (LIBUSB_SUCCESS == ret)
+ return;
+
+ free_transfer(transfer);
+ /* TODO: Stop session? */
+
+ sr_err("%s: %s", __func__, libusb_error_name(ret));
}
static void receive_transfer(struct libusb_transfer *transfer)
return;
}
- sr_info("fx2lafw: receive_transfer(): status %d received %d bytes.",
+ sr_info("receive_transfer(): status %d received %d bytes.",
transfer->status, transfer->actual_length);
/* Save incoming transfer before reusing the transfer struct. */
struct sr_datafeed_header header;
struct sr_datafeed_meta_logic meta;
struct dev_context *devc;
- struct drv_context *drvc = fdi->priv;
+ struct drv_context *drvc = di->priv;
struct libusb_transfer *transfer;
const struct libusb_pollfd **lupfd;
unsigned int i;
return SR_ERR;
if (configure_probes(sdi) != SR_OK) {
- sr_err("fx2lafw: failed to configured probes");
+ sr_err("Failed to configured probes");
return SR_ERR;
}
devc->transfers = g_try_malloc0(sizeof(*devc->transfers) * num_transfers);
if (!devc->transfers) {
- sr_err("fx2lafw: USB transfers malloc failed.");
+ sr_err("USB transfers malloc failed.");
return SR_ERR_MALLOC;
}
for (i = 0; i < num_transfers; i++) {
if (!(buf = g_try_malloc(size))) {
- sr_err("fx2lafw: %s: buf malloc failed.", __func__);
+ sr_err("%s: buf malloc failed.", __func__);
return SR_ERR_MALLOC;
}
transfer = libusb_alloc_transfer(0);
libusb_fill_bulk_transfer(transfer, devc->usb->devhdl,
2 | LIBUSB_ENDPOINT_IN, buf, size,
receive_transfer, devc, timeout);
- if (libusb_submit_transfer(transfer) != 0) {
+ if ((ret = libusb_submit_transfer(transfer)) != 0) {
+ sr_err("%s: libusb_submit_transfer: %s.",
+ __func__, libusb_error_name(ret));
libusb_free_transfer(transfer);
g_free(buf);
abort_acquisition(devc);