Commit b2f3e0ea3e469a759fd74832ce551e3384bc07c0

Authored by Jim Lin
Committed by Tom Rini
1 parent 3fd1e85aaa

console: USB: KBD: Fix incorrect autoboot timeout

Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if
CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in
configuration file and when tstc() function for checking key pressed
takes longer time than 10 ms (e.g., 50 ms) to finish.

Signed-off-by: Jim Lin <jilin@nvidia.com>

Showing 1 changed file with 5 additions and 5 deletions Side-by-side Diff

... ... @@ -225,6 +225,7 @@
225 225 int abortboot(int bootdelay)
226 226 {
227 227 int abort = 0;
  228 + unsigned long ts;
228 229  
229 230 #ifdef CONFIG_MENUPROMPT
230 231 printf(CONFIG_MENUPROMPT);
231 232  
... ... @@ -248,11 +249,10 @@
248 249 #endif
249 250  
250 251 while ((bootdelay > 0) && (!abort)) {
251   - int i;
252   -
253 252 --bootdelay;
254   - /* delay 100 * 10ms */
255   - for (i=0; !abort && i<100; ++i) {
  253 + /* delay 1000 ms */
  254 + ts = get_timer(0);
  255 + do {
256 256 if (tstc()) { /* we got a key press */
257 257 abort = 1; /* don't auto boot */
258 258 bootdelay = 0; /* no more delay */
... ... @@ -264,7 +264,7 @@
264 264 break;
265 265 }
266 266 udelay(10000);
267   - }
  267 + } while (!abort && get_timer(ts) < 1000);
268 268  
269 269 printf("\b\b\b%2d ", bootdelay);
270 270 }