Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb ukbd_cngetc: poll once for data in the buffer, o...



details:   https://anonhg.NetBSD.org/src/rev/bdd0ef0f8db6
branches:  trunk
changeset: 828538:bdd0ef0f8db6
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Dec 18 18:58:00 2017 +0000

description:
ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)

diffstat:

 sys/dev/usb/ukbd.c |  23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diffs (46 lines):

diff -r 24200df9cd62 -r bdd0ef0f8db6 sys/dev/usb/ukbd.c
--- a/sys/dev/usb/ukbd.c        Mon Dec 18 18:57:21 2017 +0000
+++ b/sys/dev/usb/ukbd.c        Mon Dec 18 18:58:00 2017 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ukbd.c,v 1.139 2017/12/10 17:03:07 bouyer Exp $        */
+/*      $NetBSD: ukbd.c,v 1.140 2017/12/18 18:58:00 jmcneill Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.139 2017/12/10 17:03:07 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.140 2017/12/18 18:58:00 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -964,15 +964,20 @@
 
        DPRINTFN(0,("ukbd_cngetc: enter\n"));
        sc->sc_flags |= FLAG_POLLING;
-       while (sc->sc_npollchar <= 0)
+       if (sc->sc_npollchar <= 0)
                usbd_dopoll(sc->sc_hdev.sc_parent->sc_iface);
        sc->sc_flags &= ~FLAG_POLLING;
-       c = sc->sc_pollchars[0];
-       sc->sc_npollchar--;
-       memmove(sc->sc_pollchars, sc->sc_pollchars+1,
-              sc->sc_npollchar * sizeof(uint16_t));
-       *type = c & RELEASE ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
-       *data = c & CODEMASK;
+       if (sc->sc_npollchar > 0) {
+               c = sc->sc_pollchars[0];
+               sc->sc_npollchar--;
+               memmove(sc->sc_pollchars, sc->sc_pollchars+1,
+                      sc->sc_npollchar * sizeof(uint16_t));
+               *type = c & RELEASE ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
+               *data = c & CODEMASK;
+       } else {
+               *type = 0;
+               *data = 0;
+       }
        DPRINTFN(0,("ukbd_cngetc: return 0x%02x\n", c));
        if (broken)
                ukbd_cnpollc(v, 0);



Home | Main Index | Thread Index | Old Index