| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: opms.c,v 1.30 2020/07/22 01:24:40 msaitoh Exp $ */ | | 1 | /* $NetBSD: opms.c,v 1.31 2021/01/03 17:28:33 thorpej Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 1997 | | 4 | * Copyright 1997 |
5 | * Digital Equipment Corporation. All rights reserved. | | 5 | * Digital Equipment Corporation. All rights reserved. |
6 | * | | 6 | * |
7 | * This software is furnished under license and may be used and | | 7 | * This software is furnished under license and may be used and |
8 | * copied only in accordance with the following terms and conditions. | | 8 | * copied only in accordance with the following terms and conditions. |
9 | * Subject to these conditions, you may download, copy, install, | | 9 | * Subject to these conditions, you may download, copy, install, |
10 | * use, modify and distribute this software in source and/or binary | | 10 | * use, modify and distribute this software in source and/or binary |
11 | * form. No title or ownership is transferred hereby. | | 11 | * form. No title or ownership is transferred hereby. |
12 | * | | 12 | * |
13 | * 1) Any source code used, modified or distributed must reproduce | | 13 | * 1) Any source code used, modified or distributed must reproduce |
14 | * and retain this copyright notice and list of conditions as | | 14 | * and retain this copyright notice and list of conditions as |
| @@ -81,27 +81,27 @@ | | | @@ -81,27 +81,27 @@ |
81 | ** AUTHORS: | | 81 | ** AUTHORS: |
82 | ** | | 82 | ** |
83 | ** Unknown. Modified by Patrick Crilly, and John Court | | 83 | ** Unknown. Modified by Patrick Crilly, and John Court |
84 | ** Digital Equipment Corporation. | | 84 | ** Digital Equipment Corporation. |
85 | ** | | 85 | ** |
86 | ** CREATION DATE: | | 86 | ** CREATION DATE: |
87 | ** | | 87 | ** |
88 | ** Unknown | | 88 | ** Unknown |
89 | ** | | 89 | ** |
90 | **-- | | 90 | **-- |
91 | */ | | 91 | */ |
92 | | | 92 | |
93 | #include <sys/cdefs.h> | | 93 | #include <sys/cdefs.h> |
94 | __KERNEL_RCSID(0, "$NetBSD: opms.c,v 1.30 2020/07/22 01:24:40 msaitoh Exp $"); | | 94 | __KERNEL_RCSID(0, "$NetBSD: opms.c,v 1.31 2021/01/03 17:28:33 thorpej Exp $"); |
95 | | | 95 | |
96 | #include "opms.h" | | 96 | #include "opms.h" |
97 | #if NOPMS > 1 | | 97 | #if NOPMS > 1 |
98 | #error Only one PS/2 style mouse may be configured into your system. | | 98 | #error Only one PS/2 style mouse may be configured into your system. |
99 | #endif | | 99 | #endif |
100 | | | 100 | |
101 | #include "locators.h" | | 101 | #include "locators.h" |
102 | | | 102 | |
103 | #include <sys/param.h> | | 103 | #include <sys/param.h> |
104 | #include <sys/kernel.h> | | 104 | #include <sys/kernel.h> |
105 | #include <sys/systm.h> | | 105 | #include <sys/systm.h> |
106 | #include <sys/buf.h> | | 106 | #include <sys/buf.h> |
107 | #include <sys/malloc.h> | | 107 | #include <sys/malloc.h> |
| @@ -956,58 +956,56 @@ opmspoll(dev_t dev, int events, struct l | | | @@ -956,58 +956,56 @@ opmspoll(dev_t dev, int events, struct l |
956 | } | | 956 | } |
957 | } | | 957 | } |
958 | splx(oldIpl); | | 958 | splx(oldIpl); |
959 | return (revents); | | 959 | return (revents); |
960 | } /* End opmspoll */ | | 960 | } /* End opmspoll */ |
961 | | | 961 | |
962 | static void | | 962 | static void |
963 | filt_opmsrdetach(struct knote *kn) | | 963 | filt_opmsrdetach(struct knote *kn) |
964 | { | | 964 | { |
965 | struct opms_softc *sc = kn->kn_hook; | | 965 | struct opms_softc *sc = kn->kn_hook; |
966 | int s; | | 966 | int s; |
967 | | | 967 | |
968 | s = spltty(); | | 968 | s = spltty(); |
969 | SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext); | | 969 | selremove_knote(&sc->sc_rsel, kn); |
970 | splx(s); | | 970 | splx(s); |
971 | } | | 971 | } |
972 | | | 972 | |
973 | static int | | 973 | static int |
974 | filt_opmsread(struct knote *kn, long hint) | | 974 | filt_opmsread(struct knote *kn, long hint) |
975 | { | | 975 | { |
976 | struct opms_softc *sc = kn->kn_hook; | | 976 | struct opms_softc *sc = kn->kn_hook; |
977 | | | 977 | |
978 | kn->kn_data = sc->sc_q.c_cc; | | 978 | kn->kn_data = sc->sc_q.c_cc; |
979 | return (kn->kn_data > 0); | | 979 | return (kn->kn_data > 0); |
980 | } | | 980 | } |
981 | | | 981 | |
982 | static const struct filterops opmsread_filtops = { | | 982 | static const struct filterops opmsread_filtops = { |
983 | .f_isfd = 1, | | 983 | .f_isfd = 1, |
984 | .f_attach = NULL, | | 984 | .f_attach = NULL, |
985 | .f_detach = filt_opmsrdetach, | | 985 | .f_detach = filt_opmsrdetach, |
986 | .f_event = filt_opmsread, | | 986 | .f_event = filt_opmsread, |
987 | }; | | 987 | }; |
988 | | | 988 | |
989 | int | | 989 | int |
990 | opmskqfilter(dev_t dev, struct knote *kn) | | 990 | opmskqfilter(dev_t dev, struct knote *kn) |
991 | { | | 991 | { |
992 | struct opms_softc *sc = device_lookup_private(&opms_cd, PMSUNIT(dev)); | | 992 | struct opms_softc *sc = device_lookup_private(&opms_cd, PMSUNIT(dev)); |
993 | struct klist *klist; | | | |
994 | int s; | | 993 | int s; |
995 | | | 994 | |
996 | switch (kn->kn_filter) { | | 995 | switch (kn->kn_filter) { |
997 | case EVFILT_READ: | | 996 | case EVFILT_READ: |
998 | klist = &sc->sc_rsel.sel_klist; | | | |
999 | kn->kn_fop = &opmsread_filtops; | | 997 | kn->kn_fop = &opmsread_filtops; |
1000 | break; | | 998 | break; |
1001 | | | 999 | |
1002 | default: | | 1000 | default: |
1003 | return (1); | | 1001 | return (1); |
1004 | } | | 1002 | } |
1005 | | | 1003 | |
1006 | kn->kn_hook = sc; | | 1004 | kn->kn_hook = sc; |
1007 | | | 1005 | |
1008 | s = spltty(); | | 1006 | s = spltty(); |
1009 | SLIST_INSERT_HEAD(klist, kn, kn_selnext); | | 1007 | selrecord_knote(&sc->sc_rsel, kn); |
1010 | splx(s); | | 1008 | splx(s); |
1011 | | | 1009 | |
1012 | return (0); | | 1010 | return (0); |
1013 | } | | 1011 | } |