Stefan Reinauer has uploaded this change for review. ( https://review.coreboot.org/c/em100/+/47731 )
Change subject: Handle errors of libusb_bulk_transfer() ......................................................................
Handle errors of libusb_bulk_transfer()
Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org Change-Id: Iad1308e3bc2656506b0f485aecff8328034dc319 --- M usb.c 1 file changed, 6 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/31/47731/1
diff --git a/usb.c b/usb.c index c7d52d8..4fd3df5 100644 --- a/usb.c +++ b/usb.c @@ -20,16 +20,20 @@ { int actual; int length = 16; /* haven't seen any other length yet */ - libusb_bulk_transfer(dev, 1 | LIBUSB_ENDPOINT_OUT, + int ret = libusb_bulk_transfer(dev, 1 | LIBUSB_ENDPOINT_OUT, data, length, &actual, BULK_SEND_TIMEOUT); + if (LIBUSB_SUCCESS != ret) + printf("ERROR: USB: %s: %s\n", __func__, libusb_strerror(ret)); return (actual == length); }
int get_response(libusb_device_handle *dev, void *data, int length) { int actual; - libusb_bulk_transfer(dev, 2 | LIBUSB_ENDPOINT_IN, + int ret = libusb_bulk_transfer(dev, 2 | LIBUSB_ENDPOINT_IN, data, length, &actual, BULK_SEND_TIMEOUT); + if (LIBUSB_SUCCESS != ret) + printf("ERROR: USB: %s: %s\n", __func__, libusb_strerror(ret)); return actual; }
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/em100/+/47731 )
Change subject: Handle errors of libusb_bulk_transfer() ......................................................................
Patch Set 1: Code-Review+2
I'd like to differentiate both kinds of errors, but I guess it doesn't really matter.
Stefan Reinauer has posted comments on this change. ( https://review.coreboot.org/c/em100/+/47731 )
Change subject: Handle errors of libusb_bulk_transfer() ......................................................................
Patch Set 1:
Patch Set 1: Code-Review+2
I'd like to differentiate both kinds of errors, but I guess it doesn't really matter.
It will print the function name in each of them, so you can see where it goes wrong.
Stefan Reinauer has submitted this change. ( https://review.coreboot.org/c/em100/+/47731 )
Change subject: Handle errors of libusb_bulk_transfer() ......................................................................
Handle errors of libusb_bulk_transfer()
Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org Change-Id: Iad1308e3bc2656506b0f485aecff8328034dc319 Reviewed-on: https://review.coreboot.org/c/em100/+/47731 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M usb.c 1 file changed, 6 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/usb.c b/usb.c index c7d52d8..4fd3df5 100644 --- a/usb.c +++ b/usb.c @@ -20,16 +20,20 @@ { int actual; int length = 16; /* haven't seen any other length yet */ - libusb_bulk_transfer(dev, 1 | LIBUSB_ENDPOINT_OUT, + int ret = libusb_bulk_transfer(dev, 1 | LIBUSB_ENDPOINT_OUT, data, length, &actual, BULK_SEND_TIMEOUT); + if (LIBUSB_SUCCESS != ret) + printf("ERROR: USB: %s: %s\n", __func__, libusb_strerror(ret)); return (actual == length); }
int get_response(libusb_device_handle *dev, void *data, int length) { int actual; - libusb_bulk_transfer(dev, 2 | LIBUSB_ENDPOINT_IN, + int ret = libusb_bulk_transfer(dev, 2 | LIBUSB_ENDPOINT_IN, data, length, &actual, BULK_SEND_TIMEOUT); + if (LIBUSB_SUCCESS != ret) + printf("ERROR: USB: %s: %s\n", __func__, libusb_strerror(ret)); return actual; }