aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Provost <dev@nicolas-provost.fr>2025-11-24 13:35:08 +0000
committerChristos Margiolis <christos@FreeBSD.org>2025-11-24 13:35:08 +0000
commit8f8b8e4af91d4e158caf6ba4b728482311bfc7c3 (patch)
tree43abadd05f00d7cf0321aef7e30298bcb21cd6be
parent120f8a4c2ae8a011827d83b098ecf70c791f794b (diff)
sound: Fix revents in midi_poll()
Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: christos Pull Request: https://github.com/freebsd/freebsd-src/pull/1887
-rw-r--r--sys/dev/sound/midi/midi.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c
index e14a28557406..cca7b93abf5f 100644
--- a/sys/dev/sound/midi/midi.c
+++ b/sys/dev/sound/midi/midi.c
@@ -658,21 +658,19 @@ midi_poll(struct cdev *i_dev, int events, struct thread *td)
mtx_lock(&m->lock);
mtx_lock(&m->qlock);
- if (events & (POLLIN | POLLRDNORM))
+ if (events & (POLLIN | POLLRDNORM)) {
if (!MIDIQ_EMPTY(m->inq))
- events |= events & (POLLIN | POLLRDNORM);
-
- if (events & (POLLOUT | POLLWRNORM))
- if (MIDIQ_AVAIL(m->outq) < m->hiwat)
- events |= events & (POLLOUT | POLLWRNORM);
-
- if (revents == 0) {
- if (events & (POLLIN | POLLRDNORM))
+ revents |= events & (POLLIN | POLLRDNORM);
+ else
selrecord(td, &m->rsel);
-
- if (events & (POLLOUT | POLLWRNORM))
+ }
+ if (events & (POLLOUT | POLLWRNORM)) {
+ if (MIDIQ_AVAIL(m->outq) < m->hiwat)
+ revents |= events & (POLLOUT | POLLWRNORM);
+ else
selrecord(td, &m->wsel);
}
+
mtx_unlock(&m->lock);
mtx_unlock(&m->qlock);