keyboard: fix poll

This commit is contained in:
Matheus
2024-05-03 15:14:49 -03:00
parent bff2e26274
commit 2930506e59
+5 -4
View File
@@ -190,12 +190,10 @@ static int poll(int minor, polldata_t *data, int events) {
if (kb == NULL)
return POLLERR;
long ipl = interrupt_raiseipl(IPL_KEYBOARD);
spinlock_acquire(&kb->lock);
if (events & POLLIN) {
long ipl = interrupt_raiseipl(IPL_KEYBOARD);
spinlock_acquire(&kb->lock);
size_t dataleft = RINGBUFFER_DATACOUNT(&kb->packetbuffer);
spinlock_release(&kb->lock);
interrupt_loweripl(ipl);
if (dataleft)
revents |= POLLIN;
}
@@ -203,6 +201,9 @@ static int poll(int minor, polldata_t *data, int events) {
if (revents == 0 && data)
poll_add(&kb->pollheader, data, events);
spinlock_release(&kb->lock);
interrupt_loweripl(ipl);
return revents;
}