Source-Changes-HG archive

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

[src/kqueue]: src/sys/dev/usb Add kqueue support.



details:   https://anonhg.NetBSD.org/src/rev/6aa3ca7423d8
branches:  kqueue
changeset: 512396:6aa3ca7423d8
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 08 05:44:23 2001 +0000

description:
Add kqueue support.

diffstat:

 sys/dev/usb/uhid.c |  58 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 2 deletions(-)

diffs (79 lines):

diff -r 5ec04a9fb749 -r 6aa3ca7423d8 sys/dev/usb/uhid.c
--- a/sys/dev/usb/uhid.c        Sat Sep 08 05:18:32 2001 +0000
+++ b/sys/dev/usb/uhid.c        Sat Sep 08 05:44:23 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhid.c,v 1.42.4.1 2001/08/25 06:16:40 thorpej Exp $    */
+/*     $NetBSD: uhid.c,v 1.42.4.2 2001/09/08 05:44:23 thorpej Exp $    */
 /*     $FreeBSD: src/sys/dev/usb/uhid.c,v 1.22 1999/11/17 22:33:43 n_hibma Exp $       */
 
 /*
@@ -371,7 +371,7 @@
                DPRINTFN(5, ("uhid_intr: waking %p\n", sc));
                wakeup(&sc->sc_q);
        }
-       selwakeup(&sc->sc_rsel);
+       selnotify(&sc->sc_rsel, 0);
        if (sc->sc_async != NULL) {
                DPRINTFN(3, ("uhid_intr: sending SIGIO %p\n", sc->sc_async));
                psignal(sc->sc_async, SIGIO);
@@ -724,6 +724,60 @@
        return (revents);
 }
 
+static void
+filt_uhidrdetach(struct knote *kn)
+{
+       struct uhid_softc *sc = (void *) kn->kn_hook;
+       int s;
+
+       s = splusb();
+       SLIST_REMOVE(&sc->sc_rsel.si_klist, kn, knote, kn_selnext);
+       splx(s);
+}
+
+static int
+filt_uhidread(struct knote *kn, long hint)
+{
+       struct uhid_softc *sc = (void *) kn->kn_hook;
+
+       kn->kn_data = sc->sc_q.c_cc;
+       return (kn->kn_data > 0);
+}
+
+static const struct filterops uhidread_filtops =
+       { 1, NULL, filt_uhidrdetach, filt_uhidread };
+
+int
+uhidkqfilter(dev_t dev, struct knote *kn)
+{
+       struct uhid_softc *sc;
+       struct klist *klist;
+       int s;
+
+       USB_GET_SC(uhid, UHIDUNIT(dev), sc);
+
+       if (sc->sc_dying)
+               return (EIO);
+
+       switch (kn->kn_filter) {
+       case EVFILT_READ:
+               klist = &sc->sc_rsel.si_klist;
+               kn->kn_fop = &uhidread_filtops;
+               break;
+
+       default:
+               return (1);
+       }
+
+       kn->kn_hook = (void *) sc;
+
+       s = splusb();
+       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       splx(s);
+
+       return (0);
+}
+
 #if defined(__FreeBSD__)
 DRIVER_MODULE(uhid, uhub, uhid_driver, uhid_devclass, usbd_driver_load, 0);
 #endif



Home | Main Index | Thread Index | Old Index