]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/arm/at91_ether.c
[PATCH] AT91RM9200 Ethernet: Use dev_alloc_skb()
[linux-2.6-omap-h63xx.git] / drivers / net / arm / at91_ether.c
index 58da5b77335063deb6329c93e21e044b00604e18..fada15d959dec6fd6a7e8f72c8c32ed50afdb3df 100644 (file)
@@ -41,7 +41,6 @@
 #define DRV_NAME       "at91_ether"
 #define DRV_VERSION    "1.0"
 
-static struct timer_list check_timer;
 #define LINK_POLL_INTERVAL     (HZ)
 
 /* ..................................................................... */
@@ -250,8 +249,7 @@ static void enable_phyirq(struct net_device *dev)
                 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
                 * or board does not have it connected.
                 */
-               check_timer.expires = jiffies + LINK_POLL_INTERVAL;
-               add_timer(&check_timer);
+               mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
                return;
        }
 
@@ -298,7 +296,7 @@ static void disable_phyirq(struct net_device *dev)
 
        irq_number = lp->board_data.phy_irq_pin;
        if (!irq_number) {
-               del_timer_sync(&check_timer);
+               del_timer_sync(&lp->check_timer);
                return;
        }
 
@@ -360,13 +358,13 @@ static void reset_phy(struct net_device *dev)
 static void at91ether_check_link(unsigned long dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
+       struct at91_private *lp = netdev_priv(dev);
 
        enable_mdi();
        update_linkspeed(dev, 1);
        disable_mdi();
 
-       check_timer.expires = jiffies + LINK_POLL_INTERVAL;
-       add_timer(&check_timer);
+       mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
 }
 
 /* ......................... ADDRESS MANAGEMENT ........................ */
@@ -855,14 +853,13 @@ static void at91ether_rx(struct net_device *dev)
        while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
                p_recv = dlist->recv_buf[lp->rxBuffIndex];
                pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff;      /* Length of frame including FCS */
-               skb = alloc_skb(pktlen + 2, GFP_ATOMIC);
+               skb = dev_alloc_skb(pktlen + 2);
                if (skb != NULL) {
                        skb_reserve(skb, 2);
                        memcpy(skb_put(skb, pktlen), p_recv, pktlen);
 
                        skb->dev = dev;
                        skb->protocol = eth_type_trans(skb, dev);
-                       skb->len = pktlen;
                        dev->last_rx = jiffies;
                        lp->stats.rx_bytes += pktlen;
                        netif_rx(skb);
@@ -925,6 +922,17 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void at91ether_poll_controller(struct net_device *dev)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       at91ether_interrupt(dev->irq, dev);
+       local_irq_restore(flags);
+}
+#endif
+
 /*
  * Initialize the ethernet interface
  */
@@ -974,6 +982,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
        dev->set_mac_address = set_mac_address;
        dev->ethtool_ops = &at91ether_ethtool_ops;
        dev->do_ioctl = at91ether_ioctl;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       dev->poll_controller = at91ether_poll_controller;
+#endif
 
        SET_NETDEV_DEV(dev, &pdev->dev);
 
@@ -1030,9 +1041,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
 
        /* If board has no PHY IRQ, use a timer to poll the PHY */
        if (!lp->board_data.phy_irq_pin) {
-               init_timer(&check_timer);
-               check_timer.data = (unsigned long)dev;
-               check_timer.function = at91ether_check_link;
+               init_timer(&lp->check_timer);
+               lp->check_timer.data = (unsigned long)dev;
+               lp->check_timer.function = at91ether_check_link;
        }
 
        /* Display ethernet banner */