diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2018-06-26 16:00:16 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2018-06-26 16:00:16 +0000 |
commit | dfd30b26a923b331bc21fda3a26b94a082381623 (patch) | |
tree | 0711ce5a5c9e2c4e8e2537a5bd0ca2e7f7c78cf9 /lib/libusb | |
parent | 8518997526ad09863b6d1a38416e9d36aadb1377 (diff) | |
download | src-test2-dfd30b26a923b331bc21fda3a26b94a082381623.tar.gz src-test2-dfd30b26a923b331bc21fda3a26b94a082381623.zip |
Notes
Diffstat (limited to 'lib/libusb')
-rw-r--r-- | lib/libusb/libusb20.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c index a83e725248ea..05094443c10b 100644 --- a/lib/libusb/libusb20.c +++ b/lib/libusb/libusb20.c @@ -814,6 +814,7 @@ libusb20_dev_req_string_sync(struct libusb20_device *pdev, { struct LIBUSB20_CONTROL_SETUP_DECODED req; int error; + int flags; /* make sure memory is initialised */ memset(ptr, 0, len); @@ -840,22 +841,24 @@ libusb20_dev_req_string_sync(struct libusb20_device *pdev, error = libusb20_dev_request_sync(pdev, &req, ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK); if (error) { - return (error); + /* try to request full string */ + req.wLength = 255; + flags = 0; + } else { + /* extract length and request full string */ + req.wLength = *(uint8_t *)ptr; + flags = LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK; } - req.wLength = *(uint8_t *)ptr; /* bytes */ if (req.wLength > len) { /* partial string read */ req.wLength = len; } - error = libusb20_dev_request_sync(pdev, &req, - ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK); - - if (error) { + error = libusb20_dev_request_sync(pdev, &req, ptr, NULL, 1000, flags); + if (error) return (error); - } - if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING) { + + if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING) return (LIBUSB20_ERROR_OTHER); - } return (0); /* success */ } |