From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Fri, 19 Sep 2014 06:24:32 +0200 Subject: [U-Boot] FW: [PATCH] usb: gadget: fastboot: improve download progress bar In-Reply-To: <541BA289.1080507@atmel.com> References: <201409181159.53234.marex@denx.de> <541BA289.1080507@atmel.com> Message-ID: <201409190624.32446.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Friday, September 19, 2014 at 05:27:05 AM, Bo Shen wrote: > Hi Marek, [...] > >> Transfer I mean here is a usb request, which trying to transfer > >> EP_BUFFER_SIZE at one time. > >> In my test case, sometime it transfer less than EP_BUFFER_SIZE in a usb > >> request. So, it cause dot won't print the dot, and seems stuck. However, > >> it will finish transfer after some time. > > > > I see now. This code is really weird. > > > > What would happen if the following condition is met in the code for k>0 ? > > (download_bytes == download_size) AND (download_bytes = k * > > BYTES_PER_DOT) > > I am not fully understand what you plan to present here. > > > I think the original code would happily print a dot after printing this > > output: printf("\ndownloading of %d bytes finished\n", download_bytes); > > > > Do you agree ? If yes, then I believe this code should go into the else > > branch only. > > Yes, I agree. This may happen, if the (download_bytes % BTYES_PER_DOT) > equals to 0. > > > Also, you can probably avoid the counting variable if you do something > > like: > > > > if (download_bytes / CONST != (download_bytes + transfer_size) / CONST) { > > > > print(dot); > > if (download_bytes / (74 * CONST) != ((download_bytes + transfer_size) / > > > > (74 * CONST)) > > > > print(\n); > > > > } > > > > Surely, the code can be simplified . You would also need to be careful > > about this assignment at the top of the function : download_bytes += > > transfer_size; > > > > What do you think ? > > I think this piece of code is better, which won't introduce new variable. > > If no other comments, I will modify the code like this and send the v2 > patch. Well OK then. Thanks!