diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-10-13 04:25:13 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-10-13 04:25:13 +0000 |
commit | 87fb0845420b1428da17a4968a49fd4ecb44fa8b (patch) | |
tree | 83749f127e6156623de6a441be1249167a6f8b86 /sys | |
parent | fa40a92d8219289b93f23b415664da340cbc9b4c (diff) |
Clean up ioctl and flush the input buffer.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/isa/pms.c | 18 |
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; |