*/
#include <libusb.h>
-#include "fx2lafw.h"
-#include "command.h"
#include "libsigrok.h"
#include "libsigrok-internal.h"
+#include "fx2lafw.h"
+#include "command.h"
SR_PRIV int command_get_fw_version(libusb_device_handle *devhdl,
struct version_info *vi)
(unsigned char *)vi, sizeof(struct version_info), 100);
if (ret < 0) {
- sr_err("fx2lafw: Unable to get version info: %s.",
+ sr_err("Unable to get version info: %s.",
libusb_error_name(ret));
return SR_ERR;
}
revid, 1, 100);
if (ret < 0) {
- sr_err("fx2lafw: Unable to get REVID: %s.",
+ sr_err("Unable to get REVID: %s.",
libusb_error_name(ret));
return SR_ERR;
}
/* Compute the sample rate. */
if (samplewide && samplerate > MAX_16BIT_SAMPLE_RATE) {
- sr_err("fx2lafw: Unable to sample at %" PRIu64 "Hz "
+ sr_err("Unable to sample at %" PRIu64 "Hz "
"when collecting 16-bit samples.", samplerate);
return SR_ERR;
}
delay = SR_MHZ(30) / samplerate - 1;
}
- sr_info("fx2lafw: GPIF delay = %d, clocksource = %sMHz", delay,
+ sr_info("GPIF delay = %d, clocksource = %sMHz", delay,
(cmd.flags & CMD_START_FLAGS_CLK_48MHZ) ? "48" : "30");
if (delay <= 0 || delay > MAX_SAMPLE_DELAY) {
- sr_err("fx2lafw: Unable to sample at %" PRIu64 "Hz.",
+ sr_err("Unable to sample at %" PRIu64 "Hz.",
samplerate);
return SR_ERR;
}
LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 100);
if (ret < 0) {
- sr_err("fx2lafw: Unable to send start command: %s.",
+ sr_err("Unable to send start command: %s.",
libusb_error_name(ret));
return SR_ERR;
}
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: %s.",
+ 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: %s.",
+ 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;
}
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;
}
if ((ret = libusb_get_device_descriptor(
devlist[i], &des)) != 0) {
- sr_warn("fx2lafw: Failed to get device descriptor: %s.",
+ sr_warn("Failed to get device descriptor: %s.",
libusb_error_name(ret));
continue;
}
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);
*/
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);
}
} else {
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;
} else {
- sr_info("fx2lafw: Device came back after %d ms.",
+ sr_info("Device came back after %d ms.",
timediff_ms);
}
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: %s.",
+ 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);
free_transfer(transfer);
/* TODO: Stop session? */
- sr_err("fx2lafw: %s: %s", __func__, libusb_error_name(ret));
+ 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. */
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);
2 | LIBUSB_ENDPOINT_IN, buf, size,
receive_transfer, devc, timeout);
if ((ret = libusb_submit_transfer(transfer)) != 0) {
- sr_err("fx2lafw: %s: libusb_submit_transfer: %s.",
+ sr_err("%s: libusb_submit_transfer: %s.",
__func__, libusb_error_name(ret));
libusb_free_transfer(transfer);
g_free(buf);