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
This commit is contained in:
Jerry Zhang 2018-03-14 14:57:31 -07:00
parent fec2e2c783
commit 9a1be3ad0e
2 changed files with 2 additions and 33 deletions

View file

@ -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<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));
@ -420,7 +391,7 @@ static int usb_ffs_read(usb_handle* h, void* data, int len) {
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));

View file

@ -54,7 +54,5 @@ struct usb_handle {
// read and write threads.
struct aio_block read_aiob;
struct aio_block write_aiob;
int max_rw;
};