Mon Jan 4 15:29:34 2021 UTC ()
Use sel{record,remove}_knote().


(thorpej)
diff -r1.62 -r1.63 src/sys/arch/sparc/dev/tctrl.c

cvs diff -r1.62 -r1.63 src/sys/arch/sparc/dev/tctrl.c (expand / switch to unified diff)

--- src/sys/arch/sparc/dev/tctrl.c 2020/06/13 05:31:28 1.62
+++ src/sys/arch/sparc/dev/tctrl.c 2021/01/04 15:29:34 1.63
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $ */ 1/* $NetBSD: tctrl.c,v 1.63 2021/01/04 15:29:34 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas. 8 * by Matt Thomas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.63 2021/01/04 15:29:34 thorpej Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/ioctl.h> 37#include <sys/ioctl.h>
38#include <sys/select.h> 38#include <sys/select.h>
39#include <sys/tty.h> 39#include <sys/tty.h>
40#include <sys/proc.h> 40#include <sys/proc.h>
41#include <sys/conf.h> 41#include <sys/conf.h>
42#include <sys/file.h> 42#include <sys/file.h>
43#include <sys/uio.h> 43#include <sys/uio.h>
44#include <sys/kernel.h> 44#include <sys/kernel.h>
45#include <sys/kthread.h> 45#include <sys/kthread.h>
46#include <sys/syslog.h> 46#include <sys/syslog.h>
@@ -1208,68 +1208,66 @@ tctrlpoll(dev_t dev, int events, struct  @@ -1208,68 +1208,66 @@ tctrlpoll(dev_t dev, int events, struct
1208 selrecord(l, &sc->sc_rsel); 1208 selrecord(l, &sc->sc_rsel);
1209 } 1209 }
1210 1210
1211 return (revents); 1211 return (revents);
1212} 1212}
1213 1213
1214static void 1214static void
1215filt_tctrlrdetach(struct knote *kn) 1215filt_tctrlrdetach(struct knote *kn)
1216{ 1216{
1217 struct tctrl_softc *sc = kn->kn_hook; 1217 struct tctrl_softc *sc = kn->kn_hook;
1218 int s; 1218 int s;
1219 1219
1220 s = splts102(); 1220 s = splts102();
1221 SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext); 1221 selremove_knote(&sc->sc_rsel, kn);
1222 splx(s); 1222 splx(s);
1223} 1223}
1224 1224
1225static int 1225static int
1226filt_tctrlread(struct knote *kn, long hint) 1226filt_tctrlread(struct knote *kn, long hint)
1227{ 1227{
1228 struct tctrl_softc *sc = kn->kn_hook; 1228 struct tctrl_softc *sc = kn->kn_hook;
1229 1229
1230 kn->kn_data = sc->sc_event_count; 1230 kn->kn_data = sc->sc_event_count;
1231 return (kn->kn_data > 0); 1231 return (kn->kn_data > 0);
1232} 1232}
1233 1233
1234static const struct filterops tctrlread_filtops = { 1234static const struct filterops tctrlread_filtops = {
1235 .f_isfd = 1, 1235 .f_isfd = 1,
1236 .f_attach = NULL, 1236 .f_attach = NULL,
1237 .f_detach = filt_tctrlrdetach, 1237 .f_detach = filt_tctrlrdetach,
1238 .f_event = filt_tctrlread, 1238 .f_event = filt_tctrlread,
1239}; 1239};
1240 1240
1241int 1241int
1242tctrlkqfilter(dev_t dev, struct knote *kn) 1242tctrlkqfilter(dev_t dev, struct knote *kn)
1243{ 1243{
1244 struct tctrl_softc *sc = device_lookup_private(&tctrl_cd, 1244 struct tctrl_softc *sc = device_lookup_private(&tctrl_cd,
1245 TCTRL_STD_DEV); 1245 TCTRL_STD_DEV);
1246 struct klist *klist; 
1247 int s; 1246 int s;
1248 1247
1249 switch (kn->kn_filter) { 1248 switch (kn->kn_filter) {
1250 case EVFILT_READ: 1249 case EVFILT_READ:
1251 klist = &sc->sc_rsel.sel_klist; 
1252 kn->kn_fop = &tctrlread_filtops; 1250 kn->kn_fop = &tctrlread_filtops;
1253 break; 1251 break;
1254 1252
1255 default: 1253 default:
1256 return (1); 1254 return (1);
1257 } 1255 }
1258 1256
1259 kn->kn_hook = sc; 1257 kn->kn_hook = sc;
1260 1258
1261 s = splts102(); 1259 s = splts102();
1262 SLIST_INSERT_HEAD(klist, kn, kn_selnext); 1260 selrecord_knote(&sc->sc_rsel, kn);
1263 splx(s); 1261 splx(s);
1264 1262
1265 return (0); 1263 return (0);
1266} 1264}
1267 1265
1268static void 1266static void
1269tctrl_sensor_setup(struct tctrl_softc *sc) 1267tctrl_sensor_setup(struct tctrl_softc *sc)
1270{ 1268{
1271 int i, error; 1269 int i, error;
1272 1270
1273 sc->sc_sme = sysmon_envsys_create(); 1271 sc->sc_sme = sysmon_envsys_create();
1274 1272
1275 /* case temperature */ 1273 /* case temperature */