Fixes unchecked results from parsecmd
[akaros.git] / kern / drivers / net / ether8139.c
index 5cc149a..a8ec807 100644 (file)
@@ -17,6 +17,7 @@
 #include <pmap.h>
 #include <smp.h>
 #include <ip.h>
+#include <arch/io.h>
 
 enum {                                                 /* registers */
        Idr0 = 0x0000,                          /* MAC address */
@@ -479,11 +480,11 @@ static void rtl8139receive(struct ether *edev)
                status = (*(p + 1) << 8) | *p;
                if (!(status & Rcok)) {
                        if (status & (Ise | Fae))
-                               edev->netif.frames++;
+                               edev->frames++;
                        if (status & Crc)
-                               edev->netif.crcs++;
+                               edev->crcs++;
                        if (status & (Runt | Long))
-                               edev->netif.buffs++;
+                               edev->buffs++;
 
                        /*
                         * Reset the receiver.
@@ -564,7 +565,7 @@ static void rtl8139interrupt(struct hw_trapframe *tf, void *arg)
                                                if (ctlr->etxth < ETHERMAXTU / 32)
                                                        ctlr->etxth++;
                                        }
-                                       edev->netif.oerrs++;
+                                       edev->oerrs++;
                                }
 
                                if (td->bp != NULL) {
@@ -586,11 +587,11 @@ static void rtl8139interrupt(struct hw_trapframe *tf, void *arg)
                         */
                        msr = csr8r(ctlr, Msr);
                        if (!(msr & Linkb)) {
-                               if (!(msr & Speed10) && edev->netif.mbps != 100) {
-                                       edev->netif.mbps = 100;
+                               if (!(msr & Speed10) && edev->mbps != 100) {
+                                       edev->mbps = 100;
                                        qsetlimit(edev->oq, 256 * 1024);
-                               } else if ((msr & Speed10) && edev->netif.mbps != 10) {
-                                       edev->netif.mbps = 10;
+                               } else if ((msr & Speed10) && edev->mbps != 10) {
+                                       edev->mbps = 10;
                                        qsetlimit(edev->oq, 65 * 1024);
                                }
                        }
@@ -749,20 +750,21 @@ static int rtl8139pnp(struct ether *edev)
                edev->ea[4] = i;
                edev->ea[5] = i >> 8;
        }
+       edev->tbdf = pci_to_tbdf(ctlr->pcidev);
        edev->attach = rtl8139attach;
        edev->transmit = rtl8139transmit;
-       edev->interrupt = rtl8139interrupt;
        edev->ifstat = rtl8139ifstat;
 
-       edev->netif.arg = edev;
-       edev->netif.promiscuous = rtl8139promiscuous;
+       edev->arg = edev;
+       edev->promiscuous = rtl8139promiscuous;
 
        /*
         * This should be much more dynamic but will do for now.
         */
        if ((csr8r(ctlr, Msr) & (Speed10 | Linkb)) == 0)
-               edev->netif.mbps = 100;
+               edev->mbps = 100;
 
+       register_irq(edev->irq, rtl8139interrupt, edev, edev->tbdf);
        return 0;
 }