Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Use sel{record,remove}_knote().



details:   https://anonhg.NetBSD.org/src/rev/eb8ba38ed1cd
branches:  trunk
changeset: 947589:eb8ba38ed1cd
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Dec 19 01:18:58 2020 +0000

description:
Use sel{record,remove}_knote().

diffstat:

 sys/dev/apm/apm.c        |  10 ++++------
 sys/dev/audio/audio.c    |  21 +++++++++------------
 sys/dev/hpc/apm/apmdev.c |  10 ++++------
 sys/dev/ir/irframe_tty.c |  16 ++++++++--------
 sys/dev/midi.c           |  27 ++++++++++++++-------------
 sys/dev/sequencer.c      |  16 ++++++++--------
 6 files changed, 47 insertions(+), 53 deletions(-)

diffs (truncated from 399 to 300 lines):

diff -r b22333ea45db -r eb8ba38ed1cd sys/dev/apm/apm.c
--- a/sys/dev/apm/apm.c Sat Dec 19 01:12:21 2020 +0000
+++ b/sys/dev/apm/apm.c Sat Dec 19 01:18:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apm.c,v 1.33 2017/10/28 04:53:54 riastradh Exp $ */
+/*     $NetBSD: apm.c,v 1.34 2020/12/19 01:18:58 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.33 2017/10/28 04:53:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.34 2020/12/19 01:18:58 thorpej Exp $");
 
 #include "opt_apm.h"
 
@@ -870,7 +870,7 @@
        struct apm_softc *sc = kn->kn_hook;
 
        APM_LOCK(sc);
-       SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&sc->sc_rsel, kn);
        APM_UNLOCK(sc);
 }
 
@@ -894,11 +894,9 @@
 apmkqfilter(dev_t dev, struct knote *kn)
 {
        struct apm_softc *sc = device_lookup_private(&apm_cd, APMUNIT(dev));
-       struct klist *klist;
 
        switch (kn->kn_filter) {
        case EVFILT_READ:
-               klist = &sc->sc_rsel.sel_klist;
                kn->kn_fop = &apmread_filtops;
                break;
 
@@ -909,7 +907,7 @@
        kn->kn_hook = sc;
 
        APM_LOCK(sc);
-       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       selrecord_knote(&sc->sc_rsel, kn);
        APM_UNLOCK(sc);
 
        return (0);
diff -r b22333ea45db -r eb8ba38ed1cd sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Sat Dec 19 01:12:21 2020 +0000
+++ b/sys/dev/audio/audio.c     Sat Dec 19 01:18:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.85 2020/12/13 05:47:08 isaki Exp $ */
+/*     $NetBSD: audio.c,v 1.86 2020/12/19 01:18:58 thorpej Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.85 2020/12/13 05:47:08 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.86 2020/12/19 01:18:58 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3143,7 +3143,7 @@
        TRACEF(3, file, "");
 
        mutex_enter(sc->sc_lock);
-       SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&sc->sc_rsel, kn);
        mutex_exit(sc->sc_lock);
 }
 
@@ -3190,7 +3190,7 @@
        TRACEF(3, file, "");
 
        mutex_enter(sc->sc_lock);
-       SLIST_REMOVE(&sc->sc_wsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&sc->sc_wsel, kn);
        mutex_exit(sc->sc_lock);
 }
 
@@ -3225,30 +3225,29 @@
 int
 audio_kqfilter(struct audio_softc *sc, audio_file_t *file, struct knote *kn)
 {
-       struct klist *klist;
+       struct selinfo *sip;
 
        TRACEF(3, file, "kn=%p kn_filter=%x", kn, (int)kn->kn_filter);
 
-       mutex_enter(sc->sc_lock);
        switch (kn->kn_filter) {
        case EVFILT_READ:
-               klist = &sc->sc_rsel.sel_klist;
+               sip = &sc->sc_rsel;
                kn->kn_fop = &audioread_filtops;
                break;
 
        case EVFILT_WRITE:
-               klist = &sc->sc_wsel.sel_klist;
+               sip = &sc->sc_wsel;
                kn->kn_fop = &audiowrite_filtops;
                break;
 
        default:
-               mutex_exit(sc->sc_lock);
                return EINVAL;
        }
 
        kn->kn_hook = file;
 
-       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       mutex_enter(sc->sc_lock);
+       selrecord_knote(sip, kn);
        mutex_exit(sc->sc_lock);
 
        return 0;
@@ -6078,7 +6077,6 @@
 
        /* Notify that data has arrived. */
        selnotify(&sc->sc_rsel, 0, NOTE_SUBMIT);
-       KNOTE(&sc->sc_rsel.sel_klist, 0);
        cv_broadcast(&sc->sc_rmixer->outcv);
 
        mutex_exit(sc->sc_lock);
@@ -6143,7 +6141,6 @@
        if (found) {
                TRACE(4, "selnotify");
                selnotify(&sc->sc_wsel, 0, NOTE_SUBMIT);
-               KNOTE(&sc->sc_wsel.sel_klist, 0);
        }
 
        /* Notify to audio_write() that outbuf available. */
diff -r b22333ea45db -r eb8ba38ed1cd sys/dev/hpc/apm/apmdev.c
--- a/sys/dev/hpc/apm/apmdev.c  Sat Dec 19 01:12:21 2020 +0000
+++ b/sys/dev/hpc/apm/apmdev.c  Sat Dec 19 01:18:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apmdev.c,v 1.32 2018/07/21 18:11:09 maya Exp $ */
+/*     $NetBSD: apmdev.c,v 1.33 2020/12/19 01:18:59 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apmdev.c,v 1.32 2018/07/21 18:11:09 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apmdev.c,v 1.33 2020/12/19 01:18:59 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_apm.h"
@@ -911,7 +911,7 @@
        struct apm_softc *sc = kn->kn_hook;
 
        APM_LOCK(sc);
-       SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&sc->sc_rsel, kn);
        APM_UNLOCK(sc);
 }
 
@@ -935,11 +935,9 @@
 apmdevkqfilter(dev_t dev, struct knote *kn)
 {
        struct apm_softc *sc = device_lookup_private(&apmdev_cd, APMUNIT(dev));
-       struct klist *klist;
 
        switch (kn->kn_filter) {
        case EVFILT_READ:
-               klist = &sc->sc_rsel.sel_klist;
                kn->kn_fop = &apmread_filtops;
                break;
 
@@ -950,7 +948,7 @@
        kn->kn_hook = sc;
 
        APM_LOCK(sc);
-       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       selrecord_knote(&sc->sc_rsel, kn);
        APM_UNLOCK(sc);
 
        return (0);
diff -r b22333ea45db -r eb8ba38ed1cd sys/dev/ir/irframe_tty.c
--- a/sys/dev/ir/irframe_tty.c  Sat Dec 19 01:12:21 2020 +0000
+++ b/sys/dev/ir/irframe_tty.c  Sat Dec 19 01:18:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irframe_tty.c,v 1.63 2019/01/24 09:33:03 knakahara Exp $       */
+/*     $NetBSD: irframe_tty.c,v 1.64 2020/12/19 01:18:59 thorpej Exp $ */
 
 /*
  * TODO
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.63 2019/01/24 09:33:03 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.64 2020/12/19 01:18:59 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -787,7 +787,7 @@
        int s;
 
        s = splir();
-       SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&sc->sc_rsel, kn);
        splx(s);
 }
 
@@ -809,7 +809,7 @@
        int s;
 
        s = splir();
-       SLIST_REMOVE(&sc->sc_wsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&sc->sc_wsel, kn);
        splx(s);
 }
 
@@ -848,16 +848,16 @@
 {
        struct tty *tp = h;
        struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
-       struct klist *klist;
+       struct selinfo *sip;
        int s;
 
        switch (kn->kn_filter) {
        case EVFILT_READ:
-               klist = &sc->sc_rsel.sel_klist;
+               sip = &sc->sc_rsel;
                kn->kn_fop = &irframetread_filtops;
                break;
        case EVFILT_WRITE:
-               klist = &sc->sc_wsel.sel_klist;
+               sip = &sc->sc_wsel;
                kn->kn_fop = &irframetwrite_filtops;
                break;
        default:
@@ -867,7 +867,7 @@
        kn->kn_hook = tp;
 
        s = splir();
-       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       selrecord_knote(sip, kn);
        splx(s);
 
        return (0);
diff -r b22333ea45db -r eb8ba38ed1cd sys/dev/midi.c
--- a/sys/dev/midi.c    Sat Dec 19 01:12:21 2020 +0000
+++ b/sys/dev/midi.c    Sat Dec 19 01:18:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: midi.c,v 1.90 2020/05/23 23:42:42 ad Exp $     */
+/*     $NetBSD: midi.c,v 1.91 2020/12/19 01:18:58 thorpej Exp $        */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.90 2020/05/23 23:42:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.91 2020/12/19 01:18:58 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "midi.h"
@@ -1743,7 +1743,7 @@
        struct midi_softc *sc = kn->kn_hook;
 
        mutex_enter(sc->lock);
-       SLIST_REMOVE(&sc->rsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&sc->rsel, kn);
        mutex_exit(sc->lock);
 }
 
@@ -1776,7 +1776,7 @@
        struct midi_softc *sc = kn->kn_hook;
 
        mutex_enter(sc->lock);
-       SLIST_REMOVE(&sc->wsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&sc->wsel, kn);
        mutex_exit(sc->lock);
 }
 
@@ -1823,36 +1823,37 @@
 {
        struct midi_softc *sc =
            device_lookup_private(&midi_cd, MIDIUNIT(dev));
-       struct klist *klist;
+       struct selinfo *sip;
+       int error = 0;
 
-       mutex_exit(sc->lock);
+       mutex_enter(sc->lock);
        sc->refcnt++;
-       mutex_enter(sc->lock);
 
        switch (kn->kn_filter) {
        case EVFILT_READ:



Home | Main Index | Thread Index | Old Index