Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/wscons fix wsdisplay/wskbd and cngetc() return value...



details:   https://anonhg.NetBSD.org/src/rev/3652deab5b90
branches:  trunk
changeset: 433516:3652deab5b90
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Sep 18 06:19:28 2018 +0000

description:
fix wsdisplay/wskbd and cngetc() return value issues:
- return -1 for error / no character
- allow 0 as a character

cngetc() itself considers any value >= 0 valid, and this matches
the usage in other drivers that return -1 for "not data", vs
polling until something arrives.

removes ^G from spewing out the askname/etc prompts when no key
has been pressed (these come from cngetsn(), ignoring unknown
non printable characters.)

from @skrll with help from @mlelstv.

diffstat:

 sys/dev/wscons/wsdisplay.c |  11 +++++------
 sys/dev/wscons/wskbd.c     |  10 +++++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

diffs (82 lines):

diff -r d1667a706848 -r 3652deab5b90 sys/dev/wscons/wsdisplay.c
--- a/sys/dev/wscons/wsdisplay.c        Tue Sep 18 05:37:54 2018 +0000
+++ b/sys/dev/wscons/wsdisplay.c        Tue Sep 18 06:19:28 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay.c,v 1.145 2017/12/18 22:44:30 christos Exp $ */
+/* $NetBSD: wsdisplay.c,v 1.146 2018/09/18 06:19:28 mrg Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.145 2017/12/18 22:44:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.146 2018/09/18 06:19:28 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_wsdisplay_compat.h"
@@ -2303,19 +2303,18 @@
 
        if (wsdisplay_cons_kbd_getc) {
                c = wsdisplay_cons_kbd_getc(wsdisplay_cons.cn_dev);
-               if (c > 0)
+               if (c >= 0)
                        return c;
        }
 
 #ifdef WSDISPLAY_MULTICONS
        if (wsdisplay_ocn && wsdisplay_ocn->cn_getc) {
                c = wsdisplay_ocn->cn_getc(wsdisplay_ocn->cn_dev);
-               if (c > 0)
+               if (c >= 0)
                        return c;
        }
 #endif
-       /* panic? */
-       return (0);
+       return -1;
 }
 
 static void
diff -r d1667a706848 -r 3652deab5b90 sys/dev/wscons/wskbd.c
--- a/sys/dev/wscons/wskbd.c    Tue Sep 18 05:37:54 2018 +0000
+++ b/sys/dev/wscons/wskbd.c    Tue Sep 18 06:19:28 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wskbd.c,v 1.141 2017/12/18 18:57:21 jmcneill Exp $ */
+/* $NetBSD: wskbd.c,v 1.142 2018/09/18 06:19:28 mrg Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -105,7 +105,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.141 2017/12/18 18:57:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.142 2018/09/18 06:19:28 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1385,11 +1385,11 @@
        keysym_t ks;
 
        if (!wskbd_console_initted)
-               return 0;
+               return -1;
 
        if (wskbd_console_device != NULL &&
            !wskbd_console_device->sc_translating)
-               return 0;
+               return -1;
 
        for(;;) {
                if (num-- > 0) {
@@ -1402,7 +1402,7 @@
                                 &type, &data);
                        if (type == 0) {
                                /* No data returned */
-                               return 0;
+                               return -1;
                        }
                        if (type == WSCONS_EVENT_ASCII) {
                                /*



Home | Main Index | Thread Index | Old Index