]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86, olpc: Don't retry EC commands forever
authorPaul Fox <pgf@laptop.org>
Fri, 1 Oct 2010 17:17:19 +0000 (18:17 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 21 Mar 2011 19:43:31 +0000 (12:43 -0700)
commit 286e5b97eb22baab9d9a41ca76c6b933a484252c upstream.

Avoids a potential infinite loop.

It was observed once, during an EC hacking/debugging
session - not in regular operation.

Signed-off-by: Daniel Drake <dsd@laptop.org>
Cc: dilinger@queued.net
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kernel/olpc.c

index 9d1d263f786fdd694513ba8383b635bcdcea319e..434dfd58fc423ed92648d6cf9d30f6f01ab121ab 100644 (file)
@@ -115,6 +115,7 @@ int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
        unsigned long flags;
        int ret = -EIO;
        int i;
+       int restarts = 0;
 
        spin_lock_irqsave(&ec_lock, flags);
 
@@ -171,7 +172,9 @@ restart:
                        if (wait_on_obf(0x6c, 1)) {
                                printk(KERN_ERR "olpc-ec:  timeout waiting for"
                                                " EC to provide data!\n");
-                               goto restart;
+                               if (restarts++ < 10)
+                                       goto restart;
+                               goto err;
                        }
                        outbuf[i] = inb(0x68);
                        printk(KERN_DEBUG "olpc-ec:  received 0x%x\n",