diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index 87ed3db67..c2e933782 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp @@ -58,10 +58,6 @@ using namespace std::chrono_literals; #define cpu_to_le16(x) htole16(x) #define cpu_to_le32(x) htole32(x) -#define FUNCTIONFS_ENDPOINT_ALLOC _IOR('g', 231, __u32) - -static constexpr size_t ENDPOINT_ALLOC_RETRIES = 10; - static int dummy_fd = -1; struct func_desc { @@ -256,7 +252,6 @@ bool init_functionfs(struct usb_handle* h) { ssize_t ret; struct desc_v1 v1_descriptor; struct desc_v2 v2_descriptor; - size_t retries = 0; v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2); v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor)); @@ -324,30 +319,6 @@ bool init_functionfs(struct usb_handle* h) { h->read_aiob.fd = h->bulk_out; h->write_aiob.fd = h->bulk_in; - - h->max_rw = MAX_PAYLOAD; - while (h->max_rw >= USB_FFS_BULK_SIZE && retries < ENDPOINT_ALLOC_RETRIES) { - int ret_in = ioctl(h->bulk_in, FUNCTIONFS_ENDPOINT_ALLOC, static_cast<__u32>(h->max_rw)); - int errno_in = errno; - int ret_out = ioctl(h->bulk_out, FUNCTIONFS_ENDPOINT_ALLOC, static_cast<__u32>(h->max_rw)); - int errno_out = errno; - - if (ret_in || ret_out) { - if (errno_in == ENODEV || errno_out == ENODEV) { - std::this_thread::sleep_for(100ms); - retries += 1; - continue; - } - h->max_rw /= 2; - } else { - return true; - } - } - - D("[ adb: cannot call endpoint alloc: errno=%d ]", errno); - // Kernel pre-allocation could have failed for recoverable reasons. - // Continue running with a safe max rw size. - h->max_rw = USB_FFS_BULK_SIZE; return true; err: @@ -401,7 +372,7 @@ static int usb_ffs_write(usb_handle* h, const void* data, int len) { const char* buf = static_cast(data); while (len > 0) { - int write_len = std::min(h->max_rw, len); + int write_len = std::min(USB_FFS_BULK_SIZE, len); int n = adb_write(h->bulk_in, buf, write_len); if (n < 0) { D("ERROR: fd = %d, n = %d: %s", h->bulk_in, n, strerror(errno)); @@ -420,7 +391,7 @@ static int usb_ffs_read(usb_handle* h, void* data, int len) { char* buf = static_cast(data); while (len > 0) { - int read_len = std::min(h->max_rw, len); + int read_len = std::min(USB_FFS_BULK_SIZE, len); int n = adb_read(h->bulk_out, buf, read_len); if (n < 0) { D("ERROR: fd = %d, n = %d: %s", h->bulk_out, n, strerror(errno)); diff --git a/adb/daemon/usb.h b/adb/daemon/usb.h index db1a6d6db..15a7f6539 100644 --- a/adb/daemon/usb.h +++ b/adb/daemon/usb.h @@ -54,7 +54,5 @@ struct usb_handle { // read and write threads. struct aio_block read_aiob; struct aio_block write_aiob; - - int max_rw; };