diff options
author | Tobias Thierer <tobiast@google.com> | 2018-07-25 10:41:24 +0000 |
---|---|---|
committer | Tobias Thierer <tobiast@google.com> | 2018-07-25 10:41:24 +0000 |
commit | ec1542f22dba42f66453133eb03c5dfc3685902f (patch) | |
tree | c166c42f1151cb9e2336d857792762b1f7a31570 /fastboot/usb_linux.cpp | |
parent | ceb7cbf5fde0ff26a35d442135d01e52b0ef0771 (diff) |
Revert "Add derived UsbTransport class with USB reset method"
This reverts commit ceb7cbf5fde0ff26a35d442135d01e52b0ef0771.
Reason for revert: Broke mac builds:
system/core/fastboot/usb_osx.cpp:513:35: error: use of undeclared identifier 'USB_TRANSACTION_TIMEOUT'
USB_TRANSACTION_TIMEOUT, USB_TRANSACTION_TIMEOUT);
^
Change-Id: Ibe2f9ff2d5c63f9d33f4bd6d9ba962604cf8caeb
Diffstat (limited to 'fastboot/usb_linux.cpp')
-rw-r--r-- | fastboot/usb_linux.cpp | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/fastboot/usb_linux.cpp b/fastboot/usb_linux.cpp index 9b779ddea..386dd300c 100644 --- a/fastboot/usb_linux.cpp +++ b/fastboot/usb_linux.cpp @@ -52,7 +52,7 @@ using namespace std::chrono_literals; -#define MAX_RETRIES 2 +#define MAX_RETRIES 5 /* Timeout in seconds for usb_wait_for_disconnect. * It doesn't usually take long for a device to disconnect (almost always @@ -91,21 +91,18 @@ struct usb_handle unsigned char ep_out; }; -class LinuxUsbTransport : public UsbTransport { +class LinuxUsbTransport : public Transport { public: - explicit LinuxUsbTransport(std::unique_ptr<usb_handle> handle, uint32_t ms_timeout = 0) - : handle_(std::move(handle)), ms_timeout_(ms_timeout) {} + explicit LinuxUsbTransport(std::unique_ptr<usb_handle> handle) : handle_(std::move(handle)) {} ~LinuxUsbTransport() override = default; ssize_t Read(void* data, size_t len) override; ssize_t Write(const void* data, size_t len) override; int Close() override; - int Reset() override; int WaitForDisconnect() override; private: std::unique_ptr<usb_handle> handle_; - const uint32_t ms_timeout_; DISALLOW_COPY_AND_ASSIGN(LinuxUsbTransport); }; @@ -405,7 +402,7 @@ ssize_t LinuxUsbTransport::Write(const void* _data, size_t len) bulk.ep = handle_->ep_out; bulk.len = xfer; bulk.data = data; - bulk.timeout = ms_timeout_; + bulk.timeout = 0; n = ioctl(handle_->desc, USBDEVFS_BULK, &bulk); if(n != xfer) { @@ -439,7 +436,7 @@ ssize_t LinuxUsbTransport::Read(void* _data, size_t len) bulk.ep = handle_->ep_in; bulk.len = xfer; bulk.data = data; - bulk.timeout = ms_timeout_; + bulk.timeout = 0; retry = 0; do { @@ -450,7 +447,7 @@ ssize_t LinuxUsbTransport::Read(void* _data, size_t len) if (n < 0) { DBG1("ERROR: n = %d, errno = %d (%s)\n",n, errno, strerror(errno)); if (++retry > MAX_RETRIES) return -1; - std::this_thread::sleep_for(100ms); + std::this_thread::sleep_for(1s); } } while (n < 0); @@ -480,19 +477,10 @@ int LinuxUsbTransport::Close() return 0; } -int LinuxUsbTransport::Reset() { - int ret = 0; - // We reset the USB connection - if ((ret = ioctl(handle_->desc, USBDEVFS_RESET, 0))) { - return ret; - } - - return 0; -} - -UsbTransport* usb_open(ifc_match_func callback, uint32_t timeout_ms) { +Transport* usb_open(ifc_match_func callback) +{ std::unique_ptr<usb_handle> handle = find_usb_device("/sys/bus/usb/devices", callback); - return handle ? new LinuxUsbTransport(std::move(handle), timeout_ms) : nullptr; + return handle ? new LinuxUsbTransport(std::move(handle)) : nullptr; } /* Wait for the system to notice the device is gone, so that a subsequent |