commit 894019d14afc7461c6e6b06e9e4899db954d57f6
Author: Paul Kocialkowski <contact@paulk.fr>
Date:   Sun Apr 10 15:15:33 2016 +0200

    Revert "fastboot: OUT transaction length must be aligned to wMaxPacketSize"
    
    This reverts commit 9e4b510d40310bf46e09f4edd0a0b6356213df47.

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 2e87fee..dac9712 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -57,7 +57,6 @@ static struct f_fastboot *fastboot_func;
 static unsigned int fastboot_flash_session_id;
 static unsigned int download_size;
 static unsigned int download_bytes;
-static bool is_high_speed;
 
 static struct usb_endpoint_descriptor fs_ep_in = {
 	.bLength            = USB_DT_ENDPOINT_SIZE,
@@ -241,13 +240,10 @@ static int fastboot_set_alt(struct usb_function *f,
 	      __func__, f->name, interface, alt);
 
 	/* make sure we don't enable the ep twice */
-	if (gadget->speed == USB_SPEED_HIGH) {
+	if (gadget->speed == USB_SPEED_HIGH)
 		ret = usb_ep_enable(f_fb->out_ep, &hs_ep_out);
-		is_high_speed = true;
-	} else {
+	else
 		ret = usb_ep_enable(f_fb->out_ep, &fs_ep_out);
-		is_high_speed = false;
-	}
 	if (ret) {
 		puts("failed to enable out ep\n");
 		return ret;
@@ -427,20 +423,13 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
 	fastboot_tx_write_str(response);
 }
 
-static unsigned int rx_bytes_expected(unsigned int maxpacket)
+static unsigned int rx_bytes_expected(void)
 {
 	int rx_remain = download_size - download_bytes;
-	int rem = 0;
 	if (rx_remain < 0)
 		return 0;
 	if (rx_remain > EP_BUFFER_SIZE)
 		return EP_BUFFER_SIZE;
-	if (rx_remain < maxpacket) {
-		rx_remain = maxpacket;
-	} else if (rx_remain % maxpacket != 0) {
-		rem = rx_remain % maxpacket;
-		rx_remain = rx_remain + (maxpacket - rem);
-	}
 	return rx_remain;
 }
 
@@ -452,7 +441,6 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
 	const unsigned char *buffer = req->buf;
 	unsigned int buffer_size = req->actual;
 	unsigned int pre_dot_num, now_dot_num;
-	unsigned int max;
 
 	if (req->status != 0) {
 		printf("Bad status: %d\n", req->status);
@@ -490,9 +478,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
 
 		printf("\ndownloading of %d bytes finished\n", download_bytes);
 	} else {
-		max = is_high_speed ? hs_ep_out.wMaxPacketSize :
-				fs_ep_out.wMaxPacketSize;
-		req->length = rx_bytes_expected(max);
+		req->length = rx_bytes_expected();
 		if (req->length < ep->maxpacket)
 			req->length = ep->maxpacket;
 	}
@@ -521,9 +507,7 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req)
 	} else {
 		sprintf(response, "DATA%08x", download_size);
 		req->complete = rx_handler_dl_image;
-		max = is_high_speed ? hs_ep_out.wMaxPacketSize :
-			fs_ep_out.wMaxPacketSize;
-		req->length = rx_bytes_expected(max);
+		req->length = rx_bytes_expected();
 		if (req->length < ep->maxpacket)
 			req->length = ep->maxpacket;
 	}
