Skip to content

Commit b1e9512

Browse files
n-p-softchristosmarg
authored andcommitted
sound: Fix revents in midi_poll()
Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: christos Pull Request: #1887 (cherry picked from commit 8f8b8e4)
1 parent 47bb49b commit b1e9512

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

sys/dev/sound/midi/midi.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -658,21 +658,19 @@ midi_poll(struct cdev *i_dev, int events, struct thread *td)
658658
mtx_lock(&m->lock);
659659
mtx_lock(&m->qlock);
660660

661-
if (events & (POLLIN | POLLRDNORM))
661+
if (events & (POLLIN | POLLRDNORM)) {
662662
if (!MIDIQ_EMPTY(m->inq))
663-
events |= events & (POLLIN | POLLRDNORM);
664-
665-
if (events & (POLLOUT | POLLWRNORM))
666-
if (MIDIQ_AVAIL(m->outq) < m->hiwat)
667-
events |= events & (POLLOUT | POLLWRNORM);
668-
669-
if (revents == 0) {
670-
if (events & (POLLIN | POLLRDNORM))
663+
revents |= events & (POLLIN | POLLRDNORM);
664+
else
671665
selrecord(td, &m->rsel);
672-
673-
if (events & (POLLOUT | POLLWRNORM))
666+
}
667+
if (events & (POLLOUT | POLLWRNORM)) {
668+
if (MIDIQ_AVAIL(m->outq) < m->hiwat)
669+
revents |= events & (POLLOUT | POLLWRNORM);
670+
else
674671
selrecord(td, &m->wsel);
675672
}
673+
676674
mtx_unlock(&m->lock);
677675
mtx_unlock(&m->qlock);
678676

0 commit comments

Comments
 (0)