summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/i386/isa/pms.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/arch/i386/isa/pms.c b/sys/arch/i386/isa/pms.c
index eccfe6671c1..44d4abbfebe 100644
--- a/sys/arch/i386/isa/pms.c
+++ b/sys/arch/i386/isa/pms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pms.c,v 1.11 1996/10/13 00:55:49 downsj Exp $ */
+/* $OpenBSD: pms.c,v 1.12 1996/10/13 04:25:12 downsj Exp $ */
/* $NetBSD: pms.c,v 1.29 1996/05/12 23:12:42 mycroft Exp $ */
/*-
@@ -121,6 +121,11 @@ struct cfdriver pms_cd = {
#define PMSUNIT(dev) (minor(dev) / 2)
#define PMSTYPE(dev) (minor(dev) % 2)
+#define FLUSHQ(q) { \
+ if ((q)->c_cc) \
+ ndflush(q, (q)->c_cc); \
+}
+
static __inline void pms_flush __P((void));
static __inline void pms_dev_cmd __P((u_char));
static __inline void pms_pit_cmd __P((u_char));
@@ -351,6 +356,7 @@ pmsioctl(dev, cmd, addr, flag, p)
int s;
int error;
+ error = 0;
switch (cmd) {
case MOUSEIOCREAD:
s = spltty();
@@ -383,10 +389,16 @@ pmsioctl(dev, cmd, addr, flag, p)
error = copyout(&info, addr, sizeof(struct mouseinfo));
break;
case MOUSEIOCSRAW:
- sc->sc_flags |= PMS_RAW;
+ if (!(sc->sc_flags & PMS_RAW)) {
+ FLUSHQ(&sc->sc_q);
+ sc->sc_flags |= PMS_RAW;
+ }
break;
case MOUSEIOCSCOOKED:
- sc->sc_flags &= ~PMS_RAW;
+ if (sc->sc_flags & PMS_RAW) {
+ FLUSHQ(&sc->sc_q);
+ sc->sc_flags &= ~PMS_RAW;
+ }
break;
default:
error = EINVAL;