linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / net / hp100.c
index ff5a67d..55c7ed6 100644 (file)
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/types.h>
+#include <linux/config.h>      /* for CONFIG_PCI */
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
-#include <linux/jiffies.h>
 
 #include <asm/io.h>
 
@@ -1078,7 +1078,7 @@ static int hp100_open(struct net_device *dev)
        /* New: if bus is PCI or EISA, interrupts might be shared interrupts */
        if (request_irq(dev->irq, hp100_interrupt,
                        lp->bus == HP100_BUS_PCI || lp->bus ==
-                       HP100_BUS_EISA ? IRQF_SHARED : IRQF_DISABLED,
+                       HP100_BUS_EISA ? SA_SHIRQ : SA_INTERRUPT,
                        "hp100", dev)) {
                printk("hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq);
                return -EAGAIN;
@@ -1486,8 +1486,11 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
        if (skb->len <= 0)
                return 0;
                
-       if (lp->chip == HP100_CHIPID_SHASTA && skb_padto(skb, ETH_ZLEN))
-               return 0;
+       if (skb->len < ETH_ZLEN && lp->chip == HP100_CHIPID_SHASTA) {
+               skb = skb_padto(skb, ETH_ZLEN);
+               if (skb == NULL)
+                       return 0;
+       }
 
        /* Get Tx ring tail pointer */
        if (lp->txrtail->next == lp->txrhead) {
@@ -1496,7 +1499,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
                printk("hp100: %s: start_xmit_bm: No TX PDL available.\n", dev->name);
 #endif
                /* not waited long enough since last tx? */
-               if (time_before(jiffies, dev->trans_start + HZ))
+               if (jiffies - dev->trans_start < HZ)
                        return -EAGAIN;
 
                if (hp100_check_lan(dev))
@@ -1649,7 +1652,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
                printk("hp100: %s: start_xmit: tx free mem = 0x%x\n", dev->name, i);
 #endif
                /* not waited long enough since last failed tx try? */
-               if (time_before(jiffies, dev->trans_start + HZ)) {
+               if (jiffies - dev->trans_start < HZ) {
 #ifdef HP100_DEBUG
                        printk("hp100: %s: trans_start timing problem\n",
                               dev->name);
@@ -1715,10 +1718,17 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
        hp100_outw(i, FRAGMENT_LEN);    /* and first/only fragment length    */
 
        if (lp->mode == 2) {    /* memory mapped */
-               /* Note: The J2585B needs alignment to 32bits here!  */
-               memcpy_toio(lp->mem_ptr_virt, skb->data, (skb->len + 3) & ~3);
-               if (!ok_flag)
-                       memset_io(lp->mem_ptr_virt, 0, HP100_MIN_PACKET_SIZE - skb->len);
+               if (lp->mem_ptr_virt) { /* high pci memory was remapped */
+                       /* Note: The J2585B needs alignment to 32bits here!  */
+                       memcpy_toio(lp->mem_ptr_virt, skb->data, (skb->len + 3) & ~3);
+                       if (!ok_flag)
+                               memset_io(lp->mem_ptr_virt, 0, HP100_MIN_PACKET_SIZE - skb->len);
+               } else {
+                       /* Note: The J2585B needs alignment to 32bits here!  */
+                       isa_memcpy_toio(lp->mem_ptr_phys, skb->data, (skb->len + 3) & ~3);
+                       if (!ok_flag)
+                               isa_memset_io(lp->mem_ptr_phys, 0, HP100_MIN_PACKET_SIZE - skb->len);
+               }
        } else {                /* programmed i/o */
                outsl(ioaddr + HP100_REG_DATA32, skb->data,
                      (skb->len + 3) >> 2);
@@ -1788,7 +1798,10 @@ static void hp100_rx(struct net_device *dev)
                /* First we get the header, which contains information about the */
                /* actual length of the received packet. */
                if (lp->mode == 2) {    /* memory mapped mode */
-                       header = readl(lp->mem_ptr_virt);
+                       if (lp->mem_ptr_virt)   /* if memory was remapped */
+                               header = readl(lp->mem_ptr_virt);
+                       else
+                               header = isa_readl(lp->mem_ptr_phys);
                } else          /* programmed i/o */
                        header = hp100_inl(DATA32);
 
@@ -1820,9 +1833,13 @@ static void hp100_rx(struct net_device *dev)
                        ptr = skb->data;
 
                        /* Now transfer the data from the card into that area */
-                       if (lp->mode == 2)
-                               memcpy_fromio(ptr, lp->mem_ptr_virt,pkt_len);
-                       else    /* io mapped */
+                       if (lp->mode == 2) {
+                               if (lp->mem_ptr_virt)
+                                       memcpy_fromio(ptr, lp->mem_ptr_virt,pkt_len);
+                               /* Note alignment to 32bit transfers */
+                               else
+                                       isa_memcpy_fromio(ptr, lp->mem_ptr_phys, pkt_len);
+                       } else  /* io mapped */
                                insl(ioaddr + HP100_REG_DATA32, ptr, pkt_len >> 2);
 
                        skb->protocol = eth_type_trans(skb, dev);