[U-Boot] [PATCH] usb: gadget: fastboot: improve download progress bar

Bo Shen voice.shen at atmel.com
Wed Sep 17 09:43:56 CEST 2014


When download is ongoing, if the actual size of one transfer
is not the same as BTYES_PER_DOT, which will cause the dot
won't print anymore. Then it will let the user thinking it
is stuck, actually it is transfering without dot printed.

So, improve the method to show the progress bar (print dot).

Signed-off-by: Bo Shen <voice.shen at atmel.com>
---

 drivers/usb/gadget/f_fastboot.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 7a1acb9..2f13bf0 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -51,6 +51,7 @@ static inline struct f_fastboot *func_to_fastboot(struct usb_function *f)
 static struct f_fastboot *fastboot_func;
 static unsigned int download_size;
 static unsigned int download_bytes;
+static unsigned int num_of_dot;
 
 static struct usb_endpoint_descriptor fs_ep_in = {
 	.bLength            = USB_DT_ENDPOINT_SIZE,
@@ -414,9 +415,10 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
 			req->length = ep->maxpacket;
 	}
 
-	if (download_bytes && !(download_bytes % BYTES_PER_DOT)) {
+	if (download_bytes && ((download_bytes / BYTES_PER_DOT) > num_of_dot)) {
+		num_of_dot = download_bytes / BYTES_PER_DOT;
 		putc('.');
-		if (!(download_bytes % (74 * BYTES_PER_DOT)))
+		if (!(num_of_dot % 74))
 			putc('\n');
 	}
 	req->actual = 0;
@@ -431,6 +433,7 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req)
 	strsep(&cmd, ":");
 	download_size = simple_strtoul(cmd, NULL, 16);
 	download_bytes = 0;
+	num_of_dot = 0;
 
 	printf("Starting download of %d bytes\n", download_size);
 
-- 
2.1.0.24.g4109c28



More information about the U-Boot mailing list