hardware: Call libusb_error_name() in all USB-related error messages

This commit is contained in:
Peter Stuge 2012-12-04 21:11:25 +01:00 committed by Bert Vermeulen
parent 851d5b2274
commit d4928d7102
10 changed files with 100 additions and 62 deletions

View File

@ -50,7 +50,8 @@ SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear)
ret = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR, 0xa0, ret = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR, 0xa0,
0xe600, 0x0000, buf, 1, 100); 0xe600, 0x0000, buf, 1, 100);
if (ret < 0) if (ret < 0)
sr_err("Unable to send control request: %d", ret); sr_err("Unable to send control request: %s",
libusb_error_name(ret));
return ret; return ret;
} }
@ -79,8 +80,8 @@ SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
LIBUSB_ENDPOINT_OUT, 0xa0, offset, LIBUSB_ENDPOINT_OUT, 0xa0, offset,
0x0000, buf, chunksize, 100); 0x0000, buf, chunksize, 100);
if (ret < 0) { if (ret < 0) {
sr_err("Unable to send firmware to device: %d", sr_err("Unable to send firmware to device: %s",
ret); libusb_error_name(ret));
result = SR_ERR; result = SR_ERR;
break; break;
} }
@ -103,7 +104,8 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
libusb_get_bus_number(dev), libusb_get_device_address(dev)); libusb_get_bus_number(dev), libusb_get_device_address(dev));
if ((ret = libusb_open(dev, &hdl)) < 0) { if ((ret = libusb_open(dev, &hdl)) < 0) {
sr_err("failed to open device: %d", ret); sr_err("ezusb: failed to open device: %s",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -111,14 +113,16 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
#if !defined(_WIN32) && !defined(__APPLE__) #if !defined(_WIN32) && !defined(__APPLE__)
if (libusb_kernel_driver_active(hdl, 0)) { if (libusb_kernel_driver_active(hdl, 0)) {
if ((ret = libusb_detach_kernel_driver(hdl, 0)) < 0) { if ((ret = libusb_detach_kernel_driver(hdl, 0)) < 0) {
sr_err("failed to detach kernel driver: %d", ret); sr_err("failed to detach kernel driver: %s",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
} }
#endif #endif
if ((ret = libusb_set_configuration(hdl, configuration)) < 0) { if ((ret = libusb_set_configuration(hdl, configuration)) < 0) {
sr_err("Unable to set configuration: %d", ret); sr_err("Unable to set configuration: %s",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }

View File

@ -123,7 +123,8 @@ SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn)
libusb_get_device_list(usb_ctx, &devlist); libusb_get_device_list(usb_ctx, &devlist);
for (i = 0; devlist[i]; i++) { for (i = 0; devlist[i]; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) { if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
sr_err("Failed to get device descriptor: %d.", ret); sr_err("Failed to get device descriptor: %s.",
libusb_error_name(ret));
continue; continue;
} }

View File

@ -33,7 +33,8 @@ SR_PRIV int command_get_fw_version(libusb_device_handle *devhdl,
(unsigned char *)vi, sizeof(struct version_info), 100); (unsigned char *)vi, sizeof(struct version_info), 100);
if (ret < 0) { if (ret < 0) {
sr_err("fx2lafw: Unable to get version info: %d.", ret); sr_err("fx2lafw: Unable to get version info: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -50,7 +51,8 @@ SR_PRIV int command_get_revid_version(libusb_device_handle *devhdl,
revid, 1, 100); revid, 1, 100);
if (ret < 0) { if (ret < 0) {
sr_err("fx2lafw: Unable to get REVID: %d.", ret); sr_err("fx2lafw: Unable to get REVID: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -103,7 +105,8 @@ SR_PRIV int command_start_acquisition(libusb_device_handle *devhdl,
LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000, LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 100); (unsigned char *)&cmd, sizeof(cmd), 100);
if (ret < 0) { if (ret < 0) {
sr_err("fx2lafw: Unable to send start command: %d.", ret); sr_err("fx2lafw: Unable to send start command: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }

View File

@ -216,8 +216,8 @@ static int fx2lafw_dev_open(struct sr_dev_inst *sdi)
for (i = 0; i < device_count; i++) { for (i = 0; i < device_count; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) { if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
sr_err("fx2lafw: Failed to get device descriptor: %d.", sr_err("fx2lafw: Failed to get device descriptor: %s.",
ret); libusb_error_name(ret));
continue; continue;
} }
@ -250,7 +250,8 @@ static int fx2lafw_dev_open(struct sr_dev_inst *sdi)
*/ */
devc->usb->address = libusb_get_device_address(devlist[i]); devc->usb->address = libusb_get_device_address(devlist[i]);
} else { } else {
sr_err("fx2lafw: Failed to open device: %d.", ret); sr_err("fx2lafw: Failed to open device: %s.",
libusb_error_name(ret));
break; break;
} }
@ -442,7 +443,8 @@ static GSList *hw_scan(GSList *options)
if ((ret = libusb_get_device_descriptor( if ((ret = libusb_get_device_descriptor(
devlist[i], &des)) != 0) { devlist[i], &des)) != 0) {
sr_warn("fx2lafw: Failed to get device descriptor: %d.", ret); sr_warn("fx2lafw: Failed to get device descriptor: %s.",
libusb_error_name(ret));
continue; continue;
} }
@ -564,7 +566,8 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
break; break;
default: default:
sr_err("fx2lafw: Unable to claim interface: %d.", ret); sr_err("fx2lafw: Unable to claim interface: %s.",
libusb_error_name(ret));
break; break;
} }
@ -750,12 +753,15 @@ static void free_transfer(struct libusb_transfer *transfer)
static void resubmit_transfer(struct libusb_transfer *transfer) static void resubmit_transfer(struct libusb_transfer *transfer)
{ {
if (libusb_submit_transfer(transfer) != 0) { int ret = libusb_submit_transfer(transfer);
if (LIBUSB_SUCCESS == ret)
return;
free_transfer(transfer); free_transfer(transfer);
/* TODO: Stop session? */ /* TODO: Stop session? */
/* TODO: Better error message. */
sr_err("fx2lafw: %s: libusb_submit_transfer error.", __func__); sr_err("fx2lafw: %s: %s", __func__, libusb_error_name(ret));
}
} }
static void receive_transfer(struct libusb_transfer *transfer) static void receive_transfer(struct libusb_transfer *transfer)
@ -984,7 +990,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
libusb_fill_bulk_transfer(transfer, devc->usb->devhdl, libusb_fill_bulk_transfer(transfer, devc->usb->devhdl,
2 | LIBUSB_ENDPOINT_IN, buf, size, 2 | LIBUSB_ENDPOINT_IN, buf, size,
receive_transfer, devc, timeout); receive_transfer, devc, timeout);
if (libusb_submit_transfer(transfer) != 0) { if ((ret = libusb_submit_transfer(transfer)) != 0) {
sr_err("fx2lafw: %s: libusb_submit_transfer: %s.",
__func__, libusb_error_name(ret));
libusb_free_transfer(transfer); libusb_free_transfer(transfer);
g_free(buf); g_free(buf);
abort_acquisition(devc); abort_acquisition(devc);

View File

@ -292,7 +292,8 @@ static GSList *hw_scan(GSList *options)
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
for (i = 0; devlist[i]; i++) { for (i = 0; devlist[i]; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) { if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
sr_err("Failed to get device descriptor: %d.", ret); sr_err("Failed to get device descriptor: %s.",
libusb_error_name(ret));
continue; continue;
} }
@ -390,7 +391,8 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
err = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE); err = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE);
if (err != 0) { if (err != 0) {
sr_err("Unable to claim interface: %d.", err); sr_err("Unable to claim interface: %s.",
libusb_error_name(err));
return SR_ERR; return SR_ERR;
} }

View File

@ -39,7 +39,8 @@ static int send_begin(struct dev_context *devc)
if ((ret = libusb_control_transfer(devc->usb->devhdl, if ((ret = libusb_control_transfer(devc->usb->devhdl,
LIBUSB_REQUEST_TYPE_VENDOR, CTRL_BEGINCOMMAND, LIBUSB_REQUEST_TYPE_VENDOR, CTRL_BEGINCOMMAND,
0, 0, buffer, sizeof(buffer), 200)) != sizeof(buffer)) { 0, 0, buffer, sizeof(buffer), 200)) != sizeof(buffer)) {
sr_err("Failed to send begincommand: %d.", ret); sr_err("Failed to send begincommand: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -119,7 +120,8 @@ SR_PRIV int dso_open(struct sr_dev_inst *sdi)
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
for (i = 0; devlist[i]; i++) { for (i = 0; devlist[i]; i++) {
if ((err = libusb_get_device_descriptor(devlist[i], &des))) { if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
sr_err("Failed to get device descriptor: %d.", err); sr_err("Failed to get device descriptor: %s.",
libusb_error_name(err));
continue; continue;
} }
@ -161,7 +163,8 @@ SR_PRIV int dso_open(struct sr_dev_inst *sdi)
devc->usb->address, USB_INTERFACE); devc->usb->address, USB_INTERFACE);
} }
} else { } else {
sr_err("Failed to open device: %d.", err); sr_err("Failed to open device: %s.",
libusb_error_name(err));
} }
/* If we made it here, we handled the device (somehow). */ /* If we made it here, we handled the device (somehow). */
@ -206,7 +209,8 @@ static int get_channel_offsets(struct dev_context *devc)
(unsigned char *)&devc->channel_levels, (unsigned char *)&devc->channel_levels,
sizeof(devc->channel_levels), 200); sizeof(devc->channel_levels), 200);
if (ret != sizeof(devc->channel_levels)) { if (ret != sizeof(devc->channel_levels)) {
sr_err("Failed to get channel offsets: %d.", ret); sr_err("Failed to get channel offsets: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -349,7 +353,8 @@ SR_PRIV int dso_set_trigger_samplerate(struct dev_context *devc)
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT, DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring), cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) { &tmp, 100)) != 0) {
sr_err("Failed to set trigger/samplerate: %d.", ret); sr_err("Failed to set trigger/samplerate: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
sr_dbg("Sent CMD_SET_TRIGGER_SAMPLERATE."); sr_dbg("Sent CMD_SET_TRIGGER_SAMPLERATE.");
@ -388,7 +393,8 @@ SR_PRIV int dso_set_filters(struct dev_context *devc)
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT, DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring), cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) { &tmp, 100)) != 0) {
sr_err("Failed to set filters: %d", ret); sr_err("Failed to set filters: %s",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
sr_dbg("Sent CMD_SET_FILTERS."); sr_dbg("Sent CMD_SET_FILTERS.");
@ -455,7 +461,8 @@ SR_PRIV int dso_set_voltage(struct dev_context *devc)
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT, DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring), cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) { &tmp, 100)) != 0) {
sr_err("Failed to set voltage: %d.", ret); sr_err("Failed to set voltage: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
sr_dbg("Sent CMD_SET_VOLTAGE."); sr_dbg("Sent CMD_SET_VOLTAGE.");
@ -507,7 +514,8 @@ SR_PRIV int dso_set_relays(struct dev_context *devc)
if ((ret = libusb_control_transfer(devc->usb->devhdl, if ((ret = libusb_control_transfer(devc->usb->devhdl,
LIBUSB_REQUEST_TYPE_VENDOR, CTRL_SETRELAYS, LIBUSB_REQUEST_TYPE_VENDOR, CTRL_SETRELAYS,
0, 0, relays, 17, 100)) != sizeof(relays)) { 0, 0, relays, 17, 100)) != sizeof(relays)) {
sr_err("Failed to set relays: %d.", ret); sr_err("Failed to set relays: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
sr_dbg("Sent CTRL_SETRELAYS."); sr_dbg("Sent CTRL_SETRELAYS.");
@ -550,7 +558,8 @@ SR_PRIV int dso_set_voffsets(struct dev_context *devc)
if ((ret = libusb_control_transfer(devc->usb->devhdl, if ((ret = libusb_control_transfer(devc->usb->devhdl,
LIBUSB_REQUEST_TYPE_VENDOR, CTRL_SETOFFSET, LIBUSB_REQUEST_TYPE_VENDOR, CTRL_SETOFFSET,
0, 0, offsets, sizeof(offsets), 100)) != sizeof(offsets)) { 0, 0, offsets, sizeof(offsets), 100)) != sizeof(offsets)) {
sr_err("Failed to set offsets: %d.", ret); sr_err("Failed to set offsets: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
sr_dbg("Sent CTRL_SETOFFSET."); sr_dbg("Sent CTRL_SETOFFSET.");
@ -576,7 +585,8 @@ SR_PRIV int dso_enable_trigger(struct dev_context *devc)
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT, DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring), cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) { &tmp, 100)) != 0) {
sr_err("Failed to enable trigger: %d.", ret); sr_err("Failed to enable trigger: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -601,7 +611,8 @@ SR_PRIV int dso_force_trigger(struct dev_context *devc)
DSO_EP_OUT | LIBUSB_ENDPOINT_OUT, DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
cmdstring, sizeof(cmdstring), cmdstring, sizeof(cmdstring),
&tmp, 100)) != 0) { &tmp, 100)) != 0) {
sr_err("Failed to force trigger: %d.", ret); sr_err("Failed to force trigger: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -651,14 +662,16 @@ SR_PRIV int dso_get_capturestate(struct dev_context *devc,
cmdstring[1] = 0; cmdstring[1] = 0;
if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) { if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
sr_dbg("Failed to send get_capturestate command: %d.", ret); sr_dbg("Failed to send get_capturestate command: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
if ((ret = libusb_bulk_transfer(devc->usb->devhdl, if ((ret = libusb_bulk_transfer(devc->usb->devhdl,
DSO_EP_IN | LIBUSB_ENDPOINT_IN, DSO_EP_IN | LIBUSB_ENDPOINT_IN,
inbuf, 512, &tmp, 100)) != 0) { inbuf, 512, &tmp, 100)) != 0) {
sr_dbg("Failed to get capturestate: %d.", ret); sr_dbg("Failed to get capturestate: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
*capturestate = inbuf[0]; *capturestate = inbuf[0];
@ -692,7 +705,8 @@ SR_PRIV int dso_capture_start(struct dev_context *devc)
cmdstring[1] = 0; cmdstring[1] = 0;
if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) { if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
sr_err("Failed to send capture_start command: %d.", ret); sr_err("Failed to send capture_start command: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -712,7 +726,8 @@ SR_PRIV int dso_get_channeldata(struct dev_context *devc, libusb_transfer_cb_fn
cmdstring[1] = 0; cmdstring[1] = 0;
if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) { if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
sr_err("Failed to get channel data: %d.", ret); sr_err("Failed to get channel data: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -730,7 +745,8 @@ SR_PRIV int dso_get_channeldata(struct dev_context *devc, libusb_transfer_cb_fn
DSO_EP_IN | LIBUSB_ENDPOINT_IN, buf, DSO_EP_IN | LIBUSB_ENDPOINT_IN, buf,
devc->epin_maxpacketsize, cb, devc, 40); devc->epin_maxpacketsize, cb, devc, 40);
if ((ret = libusb_submit_transfer(transfer)) != 0) { if ((ret = libusb_submit_transfer(transfer)) != 0) {
sr_err("Failed to submit transfer: %d.", ret); sr_err("Failed to submit transfer: %s.",
libusb_error_name(ret));
/* TODO: Free them all. */ /* TODO: Free them all. */
libusb_free_transfer(transfer); libusb_free_transfer(transfer);
g_free(buf); g_free(buf);

View File

@ -106,7 +106,8 @@ static int hid_chip_init(struct dev_context *devc, uint16_t baudrate)
if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) { if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) {
ret = libusb_detach_kernel_driver(devc->usb->devhdl, 0); ret = libusb_detach_kernel_driver(devc->usb->devhdl, 0);
if (ret < 0) { if (ret < 0) {
sr_err("Failed to detach kernel driver: %d.", ret); sr_err("Failed to detach kernel driver: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
sr_dbg("Successfully detached kernel driver."); sr_dbg("Successfully detached kernel driver.");
@ -116,7 +117,8 @@ static int hid_chip_init(struct dev_context *devc, uint16_t baudrate)
/* Claim interface 0. */ /* Claim interface 0. */
if ((ret = libusb_claim_interface(devc->usb->devhdl, 0)) < 0) { if ((ret = libusb_claim_interface(devc->usb->devhdl, 0)) < 0) {
sr_err("Failed to claim interface 0: %d.", ret); sr_err("Failed to claim interface 0: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
sr_dbg("Successfully claimed interface 0."); sr_dbg("Successfully claimed interface 0.");
@ -145,7 +147,7 @@ static int hid_chip_init(struct dev_context *devc, uint16_t baudrate)
1000 /* timeout (ms) */); 1000 /* timeout (ms) */);
if (ret < 0) { if (ret < 0) {
sr_err("HID feature report error: %d.", ret); sr_err("HID feature report error: %s.", libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
@ -216,7 +218,7 @@ static int uni_t_dmm_receive_data(int fd, int revents, int dmm, void *cb_data)
1000 /* timeout (ms) */); 1000 /* timeout (ms) */);
if (ret < 0) { if (ret < 0) {
sr_err("USB receive error: %d.", ret); sr_err("USB receive error: %s.", libusb_error_name(ret));
return FALSE; return FALSE;
} }

View File

@ -194,8 +194,9 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
/* The device reports as HID class, so the kernel would have /* The device reports as HID class, so the kernel would have
* claimed it. */ * claimed it. */
if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) { if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) {
if (libusb_detach_kernel_driver(devc->usb->devhdl, 0) < 0) { if ((ret = libusb_detach_kernel_driver(devc->usb->devhdl, 0)) < 0) {
sr_err("Failed to detach kernel driver."); sr_err("Failed to detach kernel driver: %s.",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
} }

View File

@ -58,8 +58,7 @@ static int gl_write_address(libusb_device_handle *devh, unsigned int address)
ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEADDR, ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEADDR,
0, packet, 1, TIMEOUT); 0, packet, 1, TIMEOUT);
if (ret != 1) if (ret != 1)
sr_err("zp: %s: libusb_control_transfer returned %d.", sr_err("zp: %s: %s.", __func__, libusb_error_name(ret));
__func__, ret);
return ret; return ret;
} }
@ -71,8 +70,7 @@ static int gl_write_data(libusb_device_handle *devh, unsigned int val)
ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEDATA, ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEDATA,
0, packet, 1, TIMEOUT); 0, packet, 1, TIMEOUT);
if (ret != 1) if (ret != 1)
sr_err("zp: %s: libusb_control_transfer returned %d.", sr_err("zp: %s: %s.", __func__, libusb_error_name(ret));
__func__, ret);
return ret; return ret;
} }
@ -84,8 +82,8 @@ static int gl_read_data(libusb_device_handle *devh)
ret = libusb_control_transfer(devh, CTRL_IN, 0xc, REQ_READDATA, ret = libusb_control_transfer(devh, CTRL_IN, 0xc, REQ_READDATA,
0, packet, 1, TIMEOUT); 0, packet, 1, TIMEOUT);
if (ret != 1) if (ret != 1)
sr_err("zp: %s: libusb_control_transfer returned %d, " sr_err("zp: %s: %s, val=%hhx.", __func__,
"val=%hhx.", __func__, ret, packet[0]); libusb_error_name(ret), packet[0]);
return (ret == 1) ? packet[0] : ret; return (ret == 1) ? packet[0] : ret;
} }
@ -100,13 +98,14 @@ SR_PRIV int gl_read_bulk(libusb_device_handle *devh, void *buffer,
ret = libusb_control_transfer(devh, CTRL_OUT, 0x4, REQ_READBULK, ret = libusb_control_transfer(devh, CTRL_OUT, 0x4, REQ_READBULK,
0, packet, 8, TIMEOUT); 0, packet, 8, TIMEOUT);
if (ret != 8) if (ret != 8)
sr_err("zp: %s: libusb_control_transfer returned %d.", sr_err("zp: %s: libusb_control_transfer: %s.", __func__,
__func__, ret); libusb_error_name(ret));
ret = libusb_bulk_transfer(devh, EP1_BULK_IN, buffer, size, ret = libusb_bulk_transfer(devh, EP1_BULK_IN, buffer, size,
&transferred, TIMEOUT); &transferred, TIMEOUT);
if (ret < 0) if (ret < 0)
sr_err("zp: Bulk read error %d.", ret); sr_err("zp: %s: libusb_bulk_transfer: %s.", __func__,
libusb_error_name(ret));
return transferred; return transferred;
} }

View File

@ -341,7 +341,8 @@ static GSList *hw_scan(GSList *options)
for (i = 0; devlist[i]; i++) { for (i = 0; devlist[i]; i++) {
ret = libusb_get_device_descriptor(devlist[i], &des); ret = libusb_get_device_descriptor(devlist[i], &des);
if (ret != 0) { if (ret != 0) {
sr_err("zp: failed to get device descriptor: %d", ret); sr_err("zp: failed to get device descriptor: %s",
libusb_error_name(ret));
continue; continue;
} }
@ -436,8 +437,8 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
dev = NULL; dev = NULL;
for (i = 0; i < device_count; i++) { for (i = 0; i < device_count; i++) {
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) { if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
sr_err("fx2lafw: Failed to get device descriptor: %d.", sr_err("zp: Failed to get device descriptor: %s.",
ret); libusb_error_name(ret));
continue; continue;
} }
if (libusb_get_bus_number(devlist[i]) == devc->usb->bus if (libusb_get_bus_number(devlist[i]) == devc->usb->bus
@ -458,20 +459,21 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
sdi->index, devc->usb->bus, sdi->index, devc->usb->bus,
devc->usb->address, USB_INTERFACE); devc->usb->address, USB_INTERFACE);
} else { } else {
sr_err("zp: failed to open device: %d", ret); sr_err("zp: failed to open device: %s", libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
ret = libusb_set_configuration(devc->usb->devhdl, USB_CONFIGURATION); ret = libusb_set_configuration(devc->usb->devhdl, USB_CONFIGURATION);
if (ret < 0) { if (ret < 0) {
sr_err("zp: Unable to set USB configuration %d: %d", sr_err("zp: Unable to set USB configuration %d: %s",
USB_CONFIGURATION, ret); USB_CONFIGURATION, libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }
ret = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE); ret = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE);
if (ret != 0) { if (ret != 0) {
sr_err("zp: Unable to claim interface: %d", ret); sr_err("zp: Unable to claim interface: %s",
libusb_error_name(ret));
return SR_ERR; return SR_ERR;
} }