summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/driver/rtl8139.c
diff options
context:
space:
mode:
authordzwdz2022-08-28 14:53:48 +0200
committerdzwdz2022-08-28 14:53:48 +0200
commit96a1be7e79704d3d60324547b689f8dcdc357524 (patch)
tree17728f878af64669b16423e21a48b6bec1dc4d8e /src/kernel/arch/amd64/driver/rtl8139.c
parent83567c386e4a50cc4303d2c3966d7518331e129f (diff)
kernel/driver: add postqueue_join / postqueue_pop
Diffstat (limited to 'src/kernel/arch/amd64/driver/rtl8139.c')
-rw-r--r--src/kernel/arch/amd64/driver/rtl8139.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/kernel/arch/amd64/driver/rtl8139.c b/src/kernel/arch/amd64/driver/rtl8139.c
index 05a0f70..eb07494 100644
--- a/src/kernel/arch/amd64/driver/rtl8139.c
+++ b/src/kernel/arch/amd64/driver/rtl8139.c
@@ -1,4 +1,5 @@
#include <kernel/arch/amd64/driver/rtl8139.h>
+#include <kernel/arch/amd64/driver/util.h>
#include <kernel/arch/amd64/pci.h>
#include <kernel/arch/amd64/port_io.h>
#include <kernel/mem/virt.h>
@@ -94,10 +95,7 @@ void rtl8139_irq(void) {
/* bit 0 of cmd - Rx Buffer Empty
* not a do while() because sometimes the bit is empty on IRQ. no clue why. */
while (!(port_in8(iobase + CMD) & 1)) {
- if (blocked_on) {
- accept(blocked_on);
- blocked_on = blocked_on->postqueue_next;
- } else {
+ if (!postqueue_pop(&blocked_on, accept)) {
rx_irq_enable(false);
break;
}
@@ -177,12 +175,7 @@ static void accept(struct vfs_request *req) {
case VFSOP_READ:
ret = try_rx(req->caller->pages, req->output.buf, req->output.len);
if (ret == WAIT) {
- // TODO this is a pretty common pattern in drivers, try to make it unneeded
- // TODO those asserts should actually be regular panic checks
- assert(!req->postqueue_next);
- struct vfs_request **slot = &blocked_on;
- while (*slot) slot = &(*slot)->postqueue_next;
- *slot = req;
+ postqueue_join(&blocked_on, req);
rx_irq_enable(true);
} else {
vfsreq_finish_short(req, ret);