Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46134b9c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Zero-length packet send bug resolution for fastboot."

parents 717ee912 dce13716
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -191,16 +191,30 @@ static int try_interfaces(IOUSBDeviceInterface500** dev, usb_handle* handle) {

        // Iterate over the endpoints for this interface and see if there
        // are any that do bulk in/out.
        for (UInt8 endpoint = 1; endpoint <= interfaceNumEndpoints; endpoint++) {
        for (UInt8 endpoint = 1; endpoint <= interfaceNumEndpoints; ++endpoint) {
            UInt8   transferType;
            UInt16  maxPacketSize;
            UInt16  endPointMaxPacketSize = 0;
            UInt8   interval;

            // Attempt to retrieve the 'true' packet-size from supported interface.
            kr = (*interface)
                 ->GetEndpointProperties(interface, 0, endpoint,
                                       kUSBOut,
                                       &transferType,
                                       &endPointMaxPacketSize, &interval);
            if (kr == kIOReturnSuccess && !endPointMaxPacketSize) {
                ERR("GetEndpointProperties() returned zero len packet-size");
            }

            UInt16  pipePropMaxPacketSize;
            UInt8   number;
            UInt8   direction;

            // Proceed with extracting the transfer direction, so we can fill in the
            // appropriate fields (bulkIn or bulkOut).
            kr = (*interface)->GetPipeProperties(interface, endpoint,
                    &direction,
                    &number, &transferType, &maxPacketSize, &interval);
                    &number, &transferType, &pipePropMaxPacketSize, &interval);

            if (kr == 0) {
                if (transferType != kUSBBulk) {
@@ -216,7 +230,8 @@ static int try_interfaces(IOUSBDeviceInterface500** dev, usb_handle* handle) {
                }

                if (handle->info.ifc_protocol == 0x01) {
                    handle->zero_mask = maxPacketSize - 1;
                    handle->zero_mask = (endPointMaxPacketSize == 0) ?
                        pipePropMaxPacketSize - 1 : endPointMaxPacketSize - 1;
                }
            } else {
                ERR("could not get pipe properties for endpoint %u (%08x)\n", endpoint, kr);