Pull asus into release branch
[pandora-kernel.git] / drivers / net / sis900.c
index 28606e2..b2a3b19 100644 (file)
@@ -218,7 +218,7 @@ static void sis900_init_rx_ring(struct net_device *net_dev);
 static int sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev);
 static int sis900_rx(struct net_device *net_dev);
 static void sis900_finish_xmit (struct net_device *net_dev);
-static irqreturn_t sis900_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t sis900_interrupt(int irq, void *dev_instance);
 static int sis900_close(struct net_device *net_dev);
 static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd);
 static struct net_device_stats *sis900_get_stats(struct net_device *net_dev);
@@ -968,10 +968,10 @@ static void mdio_write(struct net_device *net_dev, int phy_id, int location,
 
 static u16 sis900_reset_phy(struct net_device *net_dev, int phy_addr)
 {
-       int i = 0;
+       int i;
        u16 status;
 
-       while (i++ < 2)
+       for (i = 0; i < 2; i++)
                status = mdio_read(net_dev, phy_addr, MII_STATUS);
 
        mdio_write( net_dev, phy_addr, MII_CONTROL, MII_CNTL_RESET );
@@ -988,7 +988,7 @@ static u16 sis900_reset_phy(struct net_device *net_dev, int phy_addr)
 static void sis900_poll(struct net_device *dev)
 {
        disable_irq(dev->irq);
-       sis900_interrupt(dev->irq, dev, NULL);
+       sis900_interrupt(dev->irq, dev);
        enable_irq(dev->irq);
 }
 #endif
@@ -1430,7 +1430,7 @@ static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr)
        int i = 0;
        u32 status;
 
-       while (i++ < 2)
+       for (i = 0; i < 2; i++)
                status = mdio_read(net_dev, phy_addr, MII_STATUS);
 
        if (!(status & MII_STAT_LINK)){
@@ -1466,9 +1466,9 @@ static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex
        int phy_addr = sis_priv->cur_phy;
        u32 status;
        u16 autoadv, autorec;
-       int i = 0;
+       int i;
 
-       while (i++ < 2)
+       for (i = 0; i < 2; i++)
                status = mdio_read(net_dev, phy_addr, MII_STATUS);
 
        if (!(status & MII_STAT_LINK))
@@ -1642,7 +1642,7 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
  *     and cleans up after the Tx thread
  */
 
-static irqreturn_t sis900_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t sis900_interrupt(int irq, void *dev_instance)
 {
        struct net_device *net_dev = dev_instance;
        struct sis900_private *sis_priv = net_dev->priv;
@@ -1755,6 +1755,24 @@ static int sis900_rx(struct net_device *net_dev)
                } else {
                        struct sk_buff * skb;
 
+                       pci_unmap_single(sis_priv->pci_dev,
+                               sis_priv->rx_ring[entry].bufptr, RX_BUF_SIZE,
+                               PCI_DMA_FROMDEVICE);
+
+                       /* refill the Rx buffer, what if there is not enought
+                        * memory for new socket buffer ?? */
+                       if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
+                               /*
+                                * Not enough memory to refill the buffer
+                                * so we need to recycle the old one so
+                                * as to avoid creating a memory hole
+                                * in the rx ring
+                                */
+                               skb = sis_priv->rx_skbuff[entry];
+                               sis_priv->stats.rx_dropped++;
+                               goto refill_rx_ring;
+                       }       
+
                        /* This situation should never happen, but due to
                           some unknow bugs, it is possible that
                           we are working on NULL sk_buff :-( */
@@ -1768,9 +1786,6 @@ static int sis900_rx(struct net_device *net_dev)
                                break;
                        }
 
-                       pci_unmap_single(sis_priv->pci_dev,
-                               sis_priv->rx_ring[entry].bufptr, RX_BUF_SIZE,
-                               PCI_DMA_FROMDEVICE);
                        /* give the socket buffer to upper layers */
                        skb = sis_priv->rx_skbuff[entry];
                        skb_put(skb, rx_size);
@@ -1783,33 +1798,14 @@ static int sis900_rx(struct net_device *net_dev)
                        net_dev->last_rx = jiffies;
                        sis_priv->stats.rx_bytes += rx_size;
                        sis_priv->stats.rx_packets++;
-
-                       /* refill the Rx buffer, what if there is not enought
-                        * memory for new socket buffer ?? */
-                       if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
-                               /* not enough memory for skbuff, this makes a
-                                * "hole" on the buffer ring, it is not clear
-                                * how the hardware will react to this kind
-                                * of degenerated buffer */
-                               if (netif_msg_rx_status(sis_priv))
-                                       printk(KERN_INFO "%s: Memory squeeze,"
-                                               "deferring packet.\n",
-                                               net_dev->name);
-                               sis_priv->rx_skbuff[entry] = NULL;
-                               /* reset buffer descriptor state */
-                               sis_priv->rx_ring[entry].cmdsts = 0;
-                               sis_priv->rx_ring[entry].bufptr = 0;
-                               sis_priv->stats.rx_dropped++;
-                               sis_priv->cur_rx++;
-                               break;
-                       }
+                       sis_priv->dirty_rx++;
+refill_rx_ring:
                        skb->dev = net_dev;
                        sis_priv->rx_skbuff[entry] = skb;
                        sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE;
                        sis_priv->rx_ring[entry].bufptr =
                                pci_map_single(sis_priv->pci_dev, skb->data,
                                        RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
-                       sis_priv->dirty_rx++;
                }
                sis_priv->cur_rx++;
                entry = sis_priv->cur_rx % NUM_RX_DESC;