adb: Move io_setup to usb_handle init
Remove some redundancy by moving io_setup into aio_block_init. The io_contexts will now live till the end of the program, similar to the rest of usb_handle Test: adb works Bug: 78793464 Change-Id: I910a39d4395645f1ff231f265c285a72893a0ac6
This commit is contained in:
parent
3464bc4b43
commit
d8c1ae910f
1 changed files with 4 additions and 9 deletions
|
@ -234,6 +234,10 @@ static void aio_block_init(aio_block* aiob) {
|
|||
for (unsigned i = 0; i < USB_FFS_NUM_BUFS; i++) {
|
||||
aiob->iocbs[i] = &aiob->iocb[i];
|
||||
}
|
||||
memset(&aiob->ctx, 0, sizeof(aiob->ctx));
|
||||
if (io_setup(USB_FFS_NUM_BUFS, &aiob->ctx)) {
|
||||
D("[ aio: got error on io_setup (%d) ]", errno);
|
||||
}
|
||||
}
|
||||
|
||||
static int getMaxPacketSize(int ffs_fd) {
|
||||
|
@ -312,13 +316,6 @@ bool init_functionfs(struct usb_handle* h) {
|
|||
goto err;
|
||||
}
|
||||
|
||||
memset(&h->read_aiob.ctx, 0, sizeof(h->read_aiob.ctx));
|
||||
memset(&h->write_aiob.ctx, 0, sizeof(h->write_aiob.ctx));
|
||||
if (io_setup(USB_FFS_NUM_BUFS, &h->read_aiob.ctx) ||
|
||||
io_setup(USB_FFS_NUM_BUFS, &h->write_aiob.ctx)) {
|
||||
D("[ aio: got error on io_setup (%d) ]", errno);
|
||||
}
|
||||
|
||||
h->read_aiob.fd = h->bulk_out;
|
||||
h->write_aiob.fd = h->bulk_in;
|
||||
return true;
|
||||
|
@ -494,8 +491,6 @@ static void usb_ffs_close(usb_handle* h) {
|
|||
h->kicked = false;
|
||||
adb_close(h->bulk_out);
|
||||
adb_close(h->bulk_in);
|
||||
io_destroy(h->read_aiob.ctx);
|
||||
io_destroy(h->write_aiob.ctx);
|
||||
|
||||
// Notify usb_adb_open_thread to open a new connection.
|
||||
h->lock.lock();
|
||||
|
|
Loading…
Reference in a new issue