Module Name:    src
Committed By:   thorpej
Date:           Sun Sep 26 15:07:17 UTC 2021

Modified Files:
        src/sys/dev/usb: uhid.c

Log Message:
Use seltrue_filtops rather than rolling our own with filt_seltrue.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/uhid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uhid.c
diff -u src/sys/dev/usb/uhid.c:1.118 src/sys/dev/usb/uhid.c:1.119
--- src/sys/dev/usb/uhid.c:1.118	Sun Sep 26 01:16:09 2021
+++ src/sys/dev/usb/uhid.c	Sun Sep 26 15:07:17 2021
@@ -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 @@ static const struct filterops uhidread_f
 	.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 @@ uhidkqfilter(dev_t dev, struct knote *kn
 	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;
 }

Reply via email to