ANDROID: Fixup usb_gadget_handle_interrupts()
`fastboot devices` and `fastboot getvar all` works.
`fastboot reboot` doesn't:
$ fastboot reboot
Rebooting FAILED (remote: 'Command not found')
fastboot: error: Command failed
Fixes: ANDROID: [efi] Implement EFI_ANDROID_BOOT_PROTOCOL
Change-Id: I8d8fb8bcec2ad4f577ed441f6bbcb38d33eae054
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
diff --git a/lib/efi_loader/efi_android_boot.c b/lib/efi_loader/efi_android_boot.c
index 5ef7fb6..3f64ef6 100644
--- a/lib/efi_loader/efi_android_boot.c
+++ b/lib/efi_loader/efi_android_boot.c
@@ -19,6 +19,7 @@
static struct android_boot_protocol_instance {
efi_android_boot_protocol protocol;
+ struct udevice *udc;
struct efi_event *timer_event;
bool send_completion_already_signaled;
} android_boot;
@@ -52,6 +53,13 @@
return EFI_EXIT(EFI_DEVICE_ERROR);
}
+ ret = udc_device_get_by_index(0, &(android_boot.udc));
+ if (ret) {
+ printf("%s: USB init failed: %d\n", __func__, ret);
+ return EFI_EXIT(EFI_DEVICE_ERROR);
+ }
+
+ g_dnl_clear_detach();
ret = g_dnl_register("usb_dnl_fastboot");
if (ret) {
printf("usb_dnl_fastboot register failed: %d\n", ret);
@@ -77,6 +85,7 @@
}
g_dnl_unregister();
+ g_dnl_clear_detach();
run_command("usb reset", 0);
reset_fastboot_usb_completion_cb();
return EFI_EXIT(EFI_SUCCESS);
@@ -160,6 +169,7 @@
.fastboot_usb_send = fastboot_usb_send,
.wait_for_send_completion = NULL,
},
+ .udc = NULL,
.timer_event = NULL,
.send_completion_already_signaled = false,
};
@@ -176,12 +186,23 @@
return;
}
- usb_gadget_handle_interrupts();
- if (fastboot_func->in_req->status == 0 &&
- !android_boot.send_completion_already_signaled) {
+ dm_usb_gadget_handle_interrupts(android_boot.udc);
+
+ if (!fastboot_func->in_req) {
+ EFI_EXIT(EFI_NOT_READY);
+ return;
+ } else if (fastboot_func->in_req->status == -EINPROGRESS) {
+ EFI_EXIT(EFI_NOT_READY);
+ return;
+ } else if (fastboot_func->in_req->status != 0) {
+ EFI_EXIT(EFI_DEVICE_ERROR);
+ return;
+ } else if (fastboot_func->in_req->status == 0 &&
+ !android_boot.send_completion_already_signaled) {
android_boot.send_completion_already_signaled = true;
protocol->wait_for_send_completion->is_signaled = true;
}
+
EFI_EXIT(EFI_SUCCESS);
}