openocd/src/jtag
Oleksij Rempel d612baacaa jtag_libusb_bulk_read|write: return error code instead of size
A USB bulk write/read operation may fail with different errors:
 LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates transferred)
 LIBUSB_ERROR_PIPE if the endpoint halted
 LIBUSB_ERROR_OVERFLOW if the device offered more data, see Packets and overflows
 LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
 another LIBUSB_ERROR code on other failures

Current OpenOCD code is using the transfer size based error detection.
Which may not always work. For example for LIBUSB_ERROR_OVERFLOW as libusb
documentation says:
"Problems may occur if the device attempts to send more data than can fit in
the buffer. libusb reports LIBUSB_TRANSFER_OVERFLOW for this condition but
other behaviour is largely undefined: actual_length may or may not be accurate,
the chunk of data that can fit in the buffer (before overflow) may or may not
have been transferred."

This patch is refactoring code to use actual error return value for
error detection instead of size.

Change-Id: Iec0798438ca7b5c76e2e2912af21d9aa76ee0217
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-on: http://openocd.zylin.com/4590
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2020-01-22 05:33:31 +00:00
..
aice jtag_libusb_bulk_read|write: return error code instead of size 2020-01-22 05:33:31 +00:00
drivers jtag_libusb_bulk_read|write: return error code instead of size 2020-01-22 05:33:31 +00:00
hla adapter: switch from struct jtag_interface to adapter_driver 2020-01-14 11:39:37 +00:00
minidriver Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
minidummy adapter: switch from struct jtag_interface to adapter_driver 2020-01-14 11:39:37 +00:00
zy1000 adapter: switch from struct jtag_interface to adapter_driver 2020-01-14 11:39:37 +00:00
adapter.c adapter: switch from struct jtag_interface to adapter_driver 2020-01-14 11:39:37 +00:00
commands.c jtag: print an errmsg on using jtag API for non jtag transport 2020-01-14 11:38:23 +00:00
commands.h jtag: make cmd_queue_scan_field_clone public 2018-10-16 11:58:17 +01:00
core.c adi_v5_dapdirect: add support for adapter drivers that provide DAP API 2020-01-14 11:40:25 +00:00
driver.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
interface.c Convert DEBUG_JTAG_IO to LOG_DEBUG_IO 2019-06-04 21:48:39 +01:00
interface.h adi_v5_dapdirect: add support for adapter drivers that provide DAP API 2020-01-14 11:40:25 +00:00
interfaces.c jtag: drivers: xlnx-pcie-xvc: Add support for Xilinx XVC/PCIe 2020-01-17 05:21:29 +00:00
interfaces.h adapter: switch from struct jtag_interface to adapter_driver 2020-01-14 11:39:37 +00:00
jtag.h adapter: add command "adapter [de]assert srst|trst [[de]assert srst|trst]" 2020-01-02 21:24:30 +00:00
Makefile.am jtag: make cmd_queue_scan_field_clone public 2018-10-16 11:58:17 +01:00
minidriver.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
startup.tcl jtag: replace command "jtag_reset" with "adapter [de]assert" 2020-01-02 21:24:38 +00:00
swd.h swd: get rid of jtag queue to assert/deassert srst 2020-01-14 11:15:12 +00:00
tcl.c jtag: replace command "jtag_reset" with "adapter [de]assert" 2020-01-02 21:24:38 +00:00
tcl.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00