Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Use seltrue_filtops rather than rolling our own ...



details:   https://anonhg.NetBSD.org/src/rev/e89ca7217aec
branches:  trunk
changeset: 1023797:e89ca7217aec
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Sep 26 15:07:17 2021 +0000

description:
Use seltrue_filtops rather than rolling our own with filt_seltrue.

diffstat:

 sys/dev/usb/uhid.c |  25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diffs (61 lines):

diff -r 176ca422cef9 -r e89ca7217aec sys/dev/usb/uhid.c
--- a/sys/dev/usb/uhid.c        Sun Sep 26 15:01:55 2021 +0000
+++ b/sys/dev/usb/uhid.c        Sun Sep 26 15:07:17 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhid.c,v 1.118 2021/09/26 01:16:09 thorpej Exp $       */
+/*     $NetBSD: uhid.c,v 1.119 2021/09/26 15:07:17 thorpej Exp $       */
 
 /*
  * Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.118 2021/09/26 01:16:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.119 2021/09/26 15:07:17 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -862,13 +862,6 @@
        .f_event = filt_uhidread,
 };
 
-static const struct filterops uhid_seltrue_filtops = {
-       .f_flags = FILTEROP_ISFD,
-       .f_attach = NULL,
-       .f_detach = filt_uhidrdetach,
-       .f_event = filt_seltrue,
-};
-
 static int
 uhidkqfilter(dev_t dev, struct knote *kn)
 {
@@ -882,21 +875,21 @@
        switch (kn->kn_filter) {
        case EVFILT_READ:
                kn->kn_fop = &uhidread_filtops;
+               kn->kn_hook = sc;
+               mutex_enter(&sc->sc_lock);
+               selrecord_knote(&sc->sc_rsel, kn);
+               mutex_exit(&sc->sc_lock);
                break;
+
        case EVFILT_WRITE:
-               kn->kn_fop = &uhid_seltrue_filtops;
+               kn->kn_fop = &seltrue_filtops;
                break;
+
        default:
                error = EINVAL;
                goto out;
        }
 
-       kn->kn_hook = sc;
-
-       mutex_enter(&sc->sc_lock);
-       selrecord_knote(&sc->sc_rsel, kn);
-       mutex_exit(&sc->sc_lock);
-
 out:   uhid_exit(sc);
        return error;
 }



Home | Main Index | Thread Index | Old Index