Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pckbport Deal with Foxconn NanoPC nT-i1250 returning...



details:   https://anonhg.NetBSD.org/src/rev/153270c63063
branches:  trunk
changeset: 785248:153270c63063
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 06 03:26:17 2013 +0000

description:
Deal with Foxconn NanoPC nT-i1250 returning BAT_FAIL and don't infinite loop
>From OpenBSD.

diffstat:

 sys/dev/pckbport/pckbdreg.h |   4 +-
 sys/dev/pckbport/pckbport.c |  71 +++++++++++++++++++-------------------------
 2 files changed, 33 insertions(+), 42 deletions(-)

diffs (169 lines):

diff -r bffd64b29613 -r 153270c63063 sys/dev/pckbport/pckbdreg.h
--- a/sys/dev/pckbport/pckbdreg.h       Tue Mar 05 23:01:06 2013 +0000
+++ b/sys/dev/pckbport/pckbdreg.h       Wed Mar 06 03:26:17 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbdreg.h,v 1.2 2005/12/11 12:23:22 christos Exp $ */
+/* $NetBSD: pckbdreg.h,v 1.3 2013/03/06 03:26:17 christos Exp $ */
 
 /*
  * Keyboard definitions
@@ -19,7 +19,9 @@
 #define        KBR_EXTENDED0   0xE0    /* extended key sequence */
 #define        KBR_EXTENDED1   0xE1    /* extended key sequence */
 #define        KBR_RESEND      0xFE    /* needs resend of command */
+#define        KBR_BAT_DONE    0xAA
 #define        KBR_ACK         0xFA    /* received a valid command */
+#define        KBR_BAT_FAIL    0xFC
 #define        KBR_OVERRUN     0x00    /* flooded */
 #define        KBR_FAILURE     0xFD    /* diagnostic failure */
 #define        KBR_BREAK       0xF0    /* break code prefix - sent on key release */
diff -r bffd64b29613 -r 153270c63063 sys/dev/pckbport/pckbport.c
--- a/sys/dev/pckbport/pckbport.c       Tue Mar 05 23:01:06 2013 +0000
+++ b/sys/dev/pckbport/pckbport.c       Wed Mar 06 03:26:17 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbport.c,v 1.14 2011/09/09 14:00:01 jakllsch Exp $ */
+/* $NetBSD: pckbport.c,v 1.15 2013/03/06 03:26:17 christos Exp $ */
 
 /*
  * Copyright (c) 2004 Ben Harris
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pckbport.c,v 1.14 2011/09/09 14:00:01 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbport.c,v 1.15 2013/03/06 03:26:17 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -93,10 +93,13 @@
 
 static struct pckbport_tag pckbport_cntag;
 
-#define KBC_DEVCMD_ACK 0xfa
-#define KBC_DEVCMD_RESEND 0xfe
+#define        KBD_DELAY       DELAY(8)
 
-#define        KBD_DELAY       DELAY(8)
+#ifdef PCKBPORTDEBUG
+#define DPRINTF(a)     printf a
+#else
+#define DPRINTF(a)
+#endif
 
 static int
 pckbport_poll_data1(pckbport_tag_t t, pckbport_slot_t slot)
@@ -261,35 +264,29 @@
                        if (c != -1)
                                break;
                }
-
-               if (c == KBC_DEVCMD_ACK) {
+               switch (c) {
+               case KBR_ACK:
                        cmd->cmdidx++;
                        continue;
-               }
-               if (c == KBC_DEVCMD_RESEND) {
-#ifdef PCKBPORTDEBUG
-                       printf("pckbport_cmd: RESEND\n");
-#endif
+               case KBR_BAT_DONE:
+               case KBR_BAT_FAIL:
+               case KBR_RESEND:
+                       DPRINTF(("%s: %s\n", __func__, c == KBR_RESEND ?
+                           "RESEND" : (c == KBR_BAT_DONE ? "BAT_DONE" :
+                           "BAT_FAIL")));
                        if (cmd->retries++ < 5)
                                continue;
                        else {
-#ifdef PCKBPORTDEBUG
-                               printf("pckbport: cmd failed\n");
-#endif
+                               DPRINTF(("%s: cmd failed\n", __func__));
                                cmd->status = EIO;
                                return;
                        }
-               }
-               if (c == -1) {
-#ifdef PCKBPORTDEBUG
-                       printf("pckbport_cmd: timeout\n");
-#endif
+               case -1:
+                       DPRINTF(("%s: timeout\n", __func__));
                        cmd->status = EIO;
                        return;
                }
-#ifdef PCKBPORTDEBUG
-               printf("pckbport_cmd: lost 0x%x\n", c);
-#endif
+               DPRINTF(("%s: lost 0x%x\n", __func__, c));
        }
 
        while (cmd->responseidx < cmd->responselen) {
@@ -303,9 +300,7 @@
                                break;
                }
                if (c == -1) {
-#ifdef PCKBPORTDEBUG
-                       printf("pckbport_cmd: no data\n");
-#endif
+                       DPRINTF(("%s: no data\n", __func__));
                        cmd->status = ETIMEDOUT;
                        return;
                } else
@@ -344,15 +339,12 @@
 pckbport_cleanqueue(struct pckbport_slotdata *q)
 {
        struct pckbport_devcmd *cmd;
-#ifdef PCKBPORTDEBUG
-       int i;
-#endif
 
        while ((cmd = TAILQ_FIRST(&q->cmdqueue))) {
                TAILQ_REMOVE(&q->cmdqueue, cmd, next);
 #ifdef PCKBPORTDEBUG
-               printf("pckbport_cleanqueue: removing");
-               for (i = 0; i < cmd->cmdlen; i++)
+               printf("%s: removing", __func__);
+               for (int i = 0; i < cmd->cmdlen; i++)
                        printf(" %02x", cmd->cmd[i]);
                printf("\n");
 #endif
@@ -445,17 +437,15 @@
                panic("pckbport_cmdresponse: no active command");
 #endif
        if (cmd->cmdidx < cmd->cmdlen) {
-               if (data != KBC_DEVCMD_ACK && data != KBC_DEVCMD_RESEND)
+               if (data != KBR_ACK && data != KBR_RESEND)
                        return 0;
 
-               if (data == KBC_DEVCMD_RESEND) {
+               if (data == KBR_RESEND) {
                        if (cmd->retries++ < 5)
                                /* try again last command */
                                goto restart;
                        else {
-#ifdef PCKBPORTDEBUG
-                               printf("pckbport: cmd failed\n");
-#endif
+                               DPRINTF(("%s: cmd failed\n", __func__));
                                cmd->status = EIO;
                                /* dequeue */
                        }
@@ -584,12 +574,11 @@
        if (CMD_IN_QUEUE(q) && pckbport_cmdresponse(t, slot, data))
                return;
 
-       if (t->t_inputhandler[slot])
+       if (t->t_inputhandler[slot]) {
                (*t->t_inputhandler[slot])(t->t_inputarg[slot], data);
-#ifdef PCKBPORTDEBUG
-       else
-               printf("pckbportintr: slot %d lost %d\n", slot, data);
-#endif
+               return;
+       }
+       DPRINTF(("%s: slot %d lost %d\n", slot, data, __func__));
 }
 
 int



Home | Main Index | Thread Index | Old Index