Merge "fastboot: fix USB_TRACE, make it better."

This commit is contained in:
Treehugger Robot 2018-07-20 20:01:05 +00:00 committed by Gerrit Code Review
commit a570644b7d

View file

@ -106,6 +106,7 @@ std::unique_ptr<usb_handle> do_usb_open(const wchar_t* interface_name) {
if (nullptr == ret->adb_interface) {
errno = GetLastError();
DBG("failed to open interface %S\n", interface_name);
return nullptr;
}
@ -157,7 +158,7 @@ ssize_t WindowsUsbTransport::Write(const void* data, size_t len) {
unsigned count = 0;
int ret;
DBG("usb_write %d\n", len);
DBG("usb_write %zu\n", len);
if (nullptr != handle_) {
// Perform write
while(len > 0) {
@ -195,7 +196,7 @@ ssize_t WindowsUsbTransport::Read(void* data, size_t len) {
unsigned long read = 0;
int ret;
DBG("usb_read %d\n", len);
DBG("usb_read %zu\n", len);
if (nullptr != handle_) {
while (1) {
int xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len;
@ -269,19 +270,22 @@ int recognized_device(usb_handle* handle, ifc_match_func callback) {
return 0;
// Check vendor and product id first
if (!AdbGetUsbDeviceDescriptor(handle->adb_interface,
&device_desc)) {
if (!AdbGetUsbDeviceDescriptor(handle->adb_interface, &device_desc)) {
DBG("skipping device %x:%x\n", device_desc.idVendor, device_desc.idProduct);
return 0;
}
// Then check interface properties
if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface,
&interf_desc)) {
if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface, &interf_desc)) {
DBG("skipping device %x:%x, failed to find interface\n", device_desc.idVendor,
device_desc.idProduct);
return 0;
}
// Must have two endpoints
if (2 != interf_desc.bNumEndpoints) {
DBG("skipping device %x:%x, incorrect number of endpoints\n", device_desc.idVendor,
device_desc.idProduct);
return 0;
}
@ -305,9 +309,13 @@ int recognized_device(usb_handle* handle, ifc_match_func callback) {
info.device_path[0] = 0;
if (callback(&info) == 0) {
DBG("skipping device %x:%x, not selected by callback\n", device_desc.idVendor,
device_desc.idProduct);
return 1;
}
DBG("found device %x:%x (%s)\n", device_desc.idVendor, device_desc.idProduct,
info.serial_number);
return 0;
}
@ -338,6 +346,7 @@ static std::unique_ptr<usb_handle> find_usb_device(ifc_match_func callback) {
}
*copy_name = '\0';
DBG("attempting to open interface %S\n", next_interface->device_name);
handle = do_usb_open(next_interface->device_name);
if (NULL != handle) {
// Lets see if this interface (device) belongs to us