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 ow...



details:   https://anonhg.NetBSD.org/src/rev/f92955b486a7
branches:  trunk
changeset: 1023798:f92955b486a7
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Sep 26 15:08:29 2021 +0000

description:
- Use seltrue_filtops rather than rolling our own with filt_seltrue.
- Remove sc_wr_sel completely; nothing actually uses it.

diffstat:

 sys/dev/usb/uirda.c    |  41 +++++++++--------------------------------
 sys/dev/usb/uirdavar.h |   3 +--
 2 files changed, 10 insertions(+), 34 deletions(-)

diffs (116 lines):

diff -r e89ca7217aec -r f92955b486a7 sys/dev/usb/uirda.c
--- a/sys/dev/usb/uirda.c       Sun Sep 26 15:07:17 2021 +0000
+++ b/sys/dev/usb/uirda.c       Sun Sep 26 15:08:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uirda.c,v 1.51 2021/09/26 01:16:09 thorpej Exp $       */
+/*     $NetBSD: uirda.c,v 1.52 2021/09/26 15:08:29 thorpej Exp $       */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uirda.c,v 1.51 2021/09/26 01:16:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uirda.c,v 1.52 2021/09/26 15:08:29 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -283,7 +283,6 @@
        mutex_init(&sc->sc_wr_buf_lk, MUTEX_DEFAULT, IPL_NONE);
        mutex_init(&sc->sc_rd_buf_lk, MUTEX_DEFAULT, IPL_NONE);
        selinit(&sc->sc_rd_sel);
-       selinit(&sc->sc_wr_sel);
 
        ia.ia_type = IR_TYPE_IRFRAME;
        ia.ia_methods = sc->sc_irm ? sc->sc_irm : &uirda_methods;
@@ -346,7 +345,6 @@
        mutex_destroy(&sc->sc_wr_buf_lk);
        mutex_destroy(&sc->sc_rd_buf_lk);
        seldestroy(&sc->sc_rd_sel);
-       seldestroy(&sc->sc_wr_sel);
 
        return rv;
 }
@@ -629,17 +627,6 @@
        return kn->kn_data > 0;
 }
 
-static void
-filt_uirdawdetach(struct knote *kn)
-{
-       struct uirda_softc *sc = kn->kn_hook;
-       int s;
-
-       s = splusb();
-       selremove_knote(&sc->sc_wr_sel, kn);
-       splx(s);
-}
-
 static const struct filterops uirdaread_filtops = {
        .f_flags = FILTEROP_ISFD,
        .f_attach = NULL,
@@ -647,39 +634,29 @@
        .f_event = filt_uirdaread,
 };
 
-static const struct filterops uirdawrite_filtops = {
-       .f_flags = FILTEROP_ISFD,
-       .f_attach = NULL,
-       .f_detach = filt_uirdawdetach,
-       .f_event = filt_seltrue,
-};
-
 int
 uirda_kqfilter(void *h, struct knote *kn)
 {
        struct uirda_softc *sc = kn->kn_hook;
-       struct selinfo *sip;
        int s;
 
        switch (kn->kn_filter) {
        case EVFILT_READ:
-               sip = &sc->sc_rd_sel;
                kn->kn_fop = &uirdaread_filtops;
+               kn->kn_hook = sc;
+               s = splusb();
+               selrecord_knote(&sc->sc_rd_sel, kn);
+               splx(s);
                break;
+
        case EVFILT_WRITE:
-               sip = &sc->sc_wr_sel;
-               kn->kn_fop = &uirdawrite_filtops;
+               kn->kn_fop = &seltrue_filtops;
                break;
+
        default:
                return EINVAL;
        }
 
-       kn->kn_hook = sc;
-
-       s = splusb();
-       selrecord_knote(sip, kn);
-       splx(s);
-
        return 0;
 }
 
diff -r e89ca7217aec -r f92955b486a7 sys/dev/usb/uirdavar.h
--- a/sys/dev/usb/uirdavar.h    Sun Sep 26 15:07:17 2021 +0000
+++ b/sys/dev/usb/uirdavar.h    Sun Sep 26 15:08:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uirdavar.h,v 1.7 2016/12/04 10:12:35 skrll Exp $       */
+/*     $NetBSD: uirdavar.h,v 1.8 2021/09/26 15:08:29 thorpej Exp $     */
 
 /*
  * Copyright (c) 2001,2007 The NetBSD Foundation, Inc.
@@ -136,7 +136,6 @@
        struct usbd_xfer        *sc_wr_xfer;
        struct usbd_pipe        *sc_wr_pipe;
        int                     sc_wr_hdr;
-       struct selinfo          sc_wr_sel;
 
        device_t                sc_child;
        struct irda_params      sc_params;



Home | Main Index | Thread Index | Old Index