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/5ec04a9fb749
branches: kqueue
changeset: 512395:5ec04a9fb749
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Sep 08 05:18:32 2001 +0000
description:
Add kqueue support.
diffstat:
sys/dev/usb/usb.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 53 insertions(+), 2 deletions(-)
diffs (76 lines):
diff -r 1b45946cf5d9 -r 5ec04a9fb749 sys/dev/usb/usb.c
--- a/sys/dev/usb/usb.c Sat Sep 08 04:55:31 2001 +0000
+++ b/sys/dev/usb/usb.c Sat Sep 08 05:18:32 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usb.c,v 1.53 2001/01/23 17:04:30 augustss Exp $ */
+/* $NetBSD: usb.c,v 1.53.4.1 2001/09/08 05:18:32 thorpej Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -524,6 +524,57 @@
}
}
+static void
+filt_usbrdetach(struct knote *kn)
+{
+ int s;
+
+ s = splusb();
+ SLIST_REMOVE(&usb_selevent.si_klist, kn, knote, kn_selnext);
+ splx(s);
+}
+
+static int
+filt_usbread(struct knote *kn, long hint)
+{
+
+ if (usb_nevents == 0)
+ return (0);
+
+ kn->kn_data = sizeof(struct usb_event);
+ return (1);
+}
+
+static const struct filterops usbread_filtops =
+ { 1, NULL, filt_usbrdetach, filt_usbread };
+
+int
+usbkqfilter(dev_t dev, struct knote *kn)
+{
+ struct klist *klist;
+ int s;
+
+ switch (kn->kn_filter) {
+ case EVFILT_READ:
+ if (minor(dev) != USB_DEV_MINOR)
+ return (1);
+ klist = &usb_selevent.si_klist;
+ kn->kn_fop = &usbread_filtops;
+ break;
+
+ default:
+ return (1);
+ }
+
+ kn->kn_hook = NULL;
+
+ s = splusb();
+ SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+ splx(s);
+
+ return (0);
+}
+
/* Explore device tree from the root. */
Static void
usb_discover(void *v)
@@ -613,7 +664,7 @@
}
SIMPLEQ_INSERT_TAIL(&usb_events, ueq, next);
wakeup(&usb_events);
- selwakeup(&usb_selevent);
+ selnotify(&usb_selevent, 0);
if (usb_async_proc != NULL)
psignal(usb_async_proc, SIGIO);
splx(s);
Home |
Main Index |
Thread Index |
Old Index