From patchwork Wed Sep 17 07:43:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bo Shen X-Patchwork-Id: 390303 X-Patchwork-Delegate: l.majewski@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4339F140119 for ; Wed, 17 Sep 2014 17:44:41 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8F87FA73F0; Wed, 17 Sep 2014 09:44:38 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id osYUpO2pRcCD; Wed, 17 Sep 2014 09:44:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C98D6A73FE; Wed, 17 Sep 2014 09:44:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A8F96A73FE for ; Wed, 17 Sep 2014 09:44:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wzznh5yE-T05 for ; Wed, 17 Sep 2014 09:44:25 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from DVREDG02.corp.atmel.com (nasmtp01.atmel.com [192.199.1.246]) by theia.denx.de (Postfix) with ESMTPS id 241D5A73F0 for ; Wed, 17 Sep 2014 09:44:21 +0200 (CEST) Received: from sjogate2.atmel.com (10.42.103.223) by DVREDG02.corp.atmel.com (10.42.103.31) with Microsoft SMTP Server id 14.2.347.0; Wed, 17 Sep 2014 01:44:14 -0600 Received: from localhost.localdomain ([10.217.12.46]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id s8H7i2wC014170; Wed, 17 Sep 2014 00:44:03 -0700 (PDT) From: Bo Shen To: Marek Vasut Date: Wed, 17 Sep 2014 15:43:56 +0800 Message-ID: <1410939836-8052-1-git-send-email-voice.shen@atmel.com> X-Mailer: git-send-email 2.1.0.24.g4109c28 MIME-Version: 1.0 Cc: u-boot@lists.denx.de, Jeroen Hofstee , Rob Herring Subject: [U-Boot] [PATCH] usb: gadget: fastboot: improve download progress bar X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- 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);