summaryrefslogtreecommitdiffstats
path: root/sys/dev/midi.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2003-09-23 16:51:11 +0000
committermillert <millert@openbsd.org>2003-09-23 16:51:11 +0000
commit154dfaaa7e8e47825c6990a73b3eba25e82ebbb9 (patch)
treebae4f380ce55fc233a68444dffc895a9dabf0b91 /sys/dev/midi.c
parentregen (Prepare for conversion of select backend -> poll) (diff)
downloadwireguard-openbsd-154dfaaa7e8e47825c6990a73b3eba25e82ebbb9.tar.xz
wireguard-openbsd-154dfaaa7e8e47825c6990a73b3eba25e82ebbb9.zip
Replace select backends with poll backends. selscan() and pollscan()
now call the poll backend. With this change we implement greater poll(2) functionality instead of emulating it via the select backend. Adapted from NetBSD and including some changes from FreeBSD. Tested by many, deraadt@ OK
Diffstat (limited to 'sys/dev/midi.c')
-rw-r--r--sys/dev/midi.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/sys/dev/midi.c b/sys/dev/midi.c
index 0f66c382e8b..710f59d1456 100644
--- a/sys/dev/midi.c
+++ b/sys/dev/midi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midi.c,v 1.8 2002/03/14 01:26:52 millert Exp $ */
+/* $OpenBSD: midi.c,v 1.9 2003/09/23 16:51:12 millert Exp $ */
/* $NetBSD: midi.c,v 1.10 1998/12/20 14:26:44 drochner Exp $ */
/*
@@ -695,37 +695,34 @@ midiioctl(dev, cmd, addr, flag, p)
}
int
-midiselect(dev, rw, p)
+midipoll(dev, events, p)
dev_t dev;
- int rw;
+ int events;
struct proc *p;
{
int unit = MIDIUNIT(dev);
struct midi_softc *sc = midi_cd.cd_devs[unit];
- int s = splaudio();
+ int revents = 0, s = splaudio();
- DPRINTF(("midiselect: %p rw=0x%x\n", sc, rw));
+ DPRINTF(("midipoll: %p events=0x%x\n", sc, events));
- switch (rw) {
- case FREAD:
- if (sc->inbuf.used > 0) {
- splx(s);
- return (1);
- }
- selrecord(p, &sc->rsel);
- break;
-
- case FWRITE:
- if (sc->outbuf.used < sc->outbuf.usedhigh) {
- splx(s);
- return (1);
- }
- selrecord(p, &sc->wsel);
- break;
+ if (events & (POLLIN | POLLRDNORM)) {
+ if (sc->inbuf.used > 0)
+ revents |= events & (POLLIN | POLLRDNORM);
+ }
+ if (events & (POLLOUT | POLLWRNORM)) {
+ if (sc->outbuf.used < sc->outbuf.usedhigh)
+ revents |= events & (POLLOUT | POLLWRNORM);
+ }
+ if (revents == 0) {
+ if (events & (POLLIN | POLLRDNORM))
+ selrecord(p, &sc->rsel);
+ if (events & (POLLOUT | POLLWRNORM))
+ selrecord(p, &sc->wsel);
}
splx(s);
- return (0);
+ return (revents);
}
void