adb: Remove usages of ENDPOINT_ALLOC
All devices that previously used ENDPOINT_ALLOC
are on the new async io routines. None of the devices
using aio_compat have ENDPOINT_ALLOC so remove the
code to stop logging failures.
Fixes: 74213465
Test: adb works
Change-Id: I0c903eb76b006b6bcce48cec24f5353fa47cc128
(cherry picked from commit ff3c088706cd397ac533224d9a511b5845a1387c)
diff --git a/daemon/usb.cpp b/daemon/usb.cpp
index 20fb6a3..c58c67a 100644
--- a/daemon/usb.cpp
+++ b/daemon/usb.cpp
@@ -58,10 +58,6 @@
#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 @@
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));
@@ -326,30 +321,6 @@
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:
@@ -403,7 +374,7 @@
const char* buf = static_cast<const char*>(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));
@@ -422,7 +393,7 @@
char* buf = static_cast<char*>(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/daemon/usb.h b/daemon/usb.h
index db1a6d6..15a7f65 100644
--- a/daemon/usb.h
+++ b/daemon/usb.h
@@ -54,7 +54,5 @@
// read and write threads.
struct aio_block read_aiob;
struct aio_block write_aiob;
-
- int max_rw;
};