]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/gianfar.c
USB: use IRQF_DISABLED for HCD interrupt handlers
[linux-2.6-omap-h63xx.git] / drivers / net / gianfar.c
index bd2de325bbdd0aa09793d91cafce5f74228672b3..0431e9ed0fac56681615a495f9f2c1a5f2d30040 100644 (file)
@@ -116,7 +116,6 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static void gfar_timeout(struct net_device *dev);
 static int gfar_close(struct net_device *dev);
 struct sk_buff *gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp);
-static struct net_device_stats *gfar_get_stats(struct net_device *dev);
 static int gfar_set_mac_address(struct net_device *dev);
 static int gfar_change_mtu(struct net_device *dev, int new_mtu);
 static irqreturn_t gfar_error(int irq, void *dev_id);
@@ -169,8 +168,8 @@ static int gfar_probe(struct platform_device *pdev)
        struct gfar_private *priv = NULL;
        struct gianfar_platform_data *einfo;
        struct resource *r;
-       int idx;
        int err = 0;
+       DECLARE_MAC_BUF(mac);
 
        einfo = (struct gianfar_platform_data *) pdev->dev.platform_data;
 
@@ -254,7 +253,6 @@ static int gfar_probe(struct platform_device *pdev)
        /* Set the dev->base_addr to the gfar reg region */
        dev->base_addr = (unsigned long) (priv->regs);
 
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        /* Fill in the dev structure */
@@ -262,12 +260,13 @@ static int gfar_probe(struct platform_device *pdev)
        dev->hard_start_xmit = gfar_start_xmit;
        dev->tx_timeout = gfar_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
+#ifdef CONFIG_GFAR_NAPI
        netif_napi_add(dev, &priv->napi, gfar_poll, GFAR_DEV_WEIGHT);
+#endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
        dev->poll_controller = gfar_netpoll;
 #endif
        dev->stop = gfar_close;
-       dev->get_stats = gfar_get_stats;
        dev->change_mtu = gfar_change_mtu;
        dev->mtu = 1500;
        dev->set_multicast_list = gfar_set_multi;
@@ -359,10 +358,8 @@ static int gfar_probe(struct platform_device *pdev)
        gfar_init_sysfs(dev);
 
        /* Print out the device info */
-       printk(KERN_INFO DEVICE_NAME, dev->name);
-       for (idx = 0; idx < 6; idx++)
-               printk("%2.2x%c", dev->dev_addr[idx], idx == 5 ? ' ' : ':');
-       printk("\n");
+       printk(KERN_INFO DEVICE_NAME "%s\n",
+              dev->name, print_mac(mac, dev->dev_addr));
 
        /* Even more device info helps when determining which kernel */
        /* provided which set of benchmarks. */
@@ -699,7 +696,7 @@ int startup_gfar(struct net_device *dev)
 {
        struct txbd8 *txbdp;
        struct rxbd8 *rxbdp;
-       dma_addr_t addr;
+       dma_addr_t addr = 0;
        unsigned long vaddr;
        int i;
        struct gfar_private *priv = netdev_priv(dev);
@@ -935,9 +932,14 @@ tx_skb_fail:
 /* Returns 0 for success. */
 static int gfar_enet_open(struct net_device *dev)
 {
+#ifdef CONFIG_GFAR_NAPI
+       struct gfar_private *priv = netdev_priv(dev);
+#endif
        int err;
 
+#ifdef CONFIG_GFAR_NAPI
        napi_enable(&priv->napi);
+#endif
 
        /* Initialize a bunch of registers */
        init_registers(dev);
@@ -947,13 +949,19 @@ static int gfar_enet_open(struct net_device *dev)
        err = init_phy(dev);
 
        if(err) {
+#ifdef CONFIG_GFAR_NAPI
                napi_disable(&priv->napi);
+#endif
                return err;
        }
 
        err = startup_gfar(dev);
-       if (err)
+       if (err) {
+#ifdef CONFIG_GFAR_NAPI
                napi_disable(&priv->napi);
+#endif
+               return err;
+       }
 
        netif_start_queue(dev);
 
@@ -1014,7 +1022,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
        unsigned long flags;
 
        /* Update transmit stats */
-       priv->stats.tx_bytes += skb->len;
+       dev->stats.tx_bytes += skb->len;
 
        /* Lock priv now */
        spin_lock_irqsave(&priv->txlock, flags);
@@ -1087,7 +1095,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (txbdp == priv->dirty_tx) {
                netif_stop_queue(dev);
 
-               priv->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
        }
 
        /* Update the current txbd to the next one */
@@ -1107,7 +1115,9 @@ static int gfar_close(struct net_device *dev)
 {
        struct gfar_private *priv = netdev_priv(dev);
 
+#ifdef CONFIG_GFAR_NAPI
        napi_disable(&priv->napi);
+#endif
 
        stop_gfar(dev);
 
@@ -1120,14 +1130,6 @@ static int gfar_close(struct net_device *dev)
        return 0;
 }
 
-/* returns a net_device_stats structure pointer */
-static struct net_device_stats * gfar_get_stats(struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-
-       return &(priv->stats);
-}
-
 /* Changes the mac address if the controller is not running. */
 int gfar_set_mac_address(struct net_device *dev)
 {
@@ -1237,9 +1239,7 @@ static int gfar_change_mtu(struct net_device *dev, int new_mtu)
  * starting over will fix the problem. */
 static void gfar_timeout(struct net_device *dev)
 {
-       struct gfar_private *priv = netdev_priv(dev);
-
-       priv->stats.tx_errors++;
+       dev->stats.tx_errors++;
 
        if (dev->flags & IFF_UP) {
                stop_gfar(dev);
@@ -1269,12 +1269,12 @@ static irqreturn_t gfar_transmit(int irq, void *dev_id)
                if ((bdp == priv->cur_tx) && (netif_queue_stopped(dev) == 0))
                        break;
 
-               priv->stats.tx_packets++;
+               dev->stats.tx_packets++;
 
                /* Deferred means some collisions occurred during transmit, */
                /* but we eventually sent the packet. */
                if (bdp->status & TXBD_DEF)
-                       priv->stats.collisions++;
+                       dev->stats.collisions++;
 
                /* Free the sk buffer associated with this TxBD */
                dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]);
@@ -1344,9 +1344,10 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
        return skb;
 }
 
-static inline void count_errors(unsigned short status, struct gfar_private *priv)
+static inline void count_errors(unsigned short status, struct net_device *dev)
 {
-       struct net_device_stats *stats = &priv->stats;
+       struct gfar_private *priv = netdev_priv(dev);
+       struct net_device_stats *stats = &dev->stats;
        struct gfar_extra_stats *estats = &priv->extra_stats;
 
        /* If the packet was truncated, none of the other errors
@@ -1471,7 +1472,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
        if (NULL == skb) {
                if (netif_msg_rx_err(priv))
                        printk(KERN_WARNING "%s: Missing skb!!.\n", dev->name);
-               priv->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                priv->extra_stats.rx_skbmissing++;
        } else {
                int ret;
@@ -1529,7 +1530,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
                      (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET
                       | RXBD_CRCERR | RXBD_OVERRUN | RXBD_TRUNCATED))) {
                        /* Increment the number of packets */
-                       priv->stats.rx_packets++;
+                       dev->stats.rx_packets++;
                        howmany++;
 
                        /* Remove the FCS from the packet length */
@@ -1537,9 +1538,9 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
 
                        gfar_process_frame(dev, skb, pkt_len);
 
-                       priv->stats.rx_bytes += pkt_len;
+                       dev->stats.rx_bytes += pkt_len;
                } else {
-                       count_errors(bdp->status, priv);
+                       count_errors(bdp->status, dev);
 
                        if (skb)
                                dev_kfree_skb_any(skb);
@@ -1917,17 +1918,17 @@ static irqreturn_t gfar_error(int irq, void *dev_id)
 
        /* Update the error counters */
        if (events & IEVENT_TXE) {
-               priv->stats.tx_errors++;
+               dev->stats.tx_errors++;
 
                if (events & IEVENT_LC)
-                       priv->stats.tx_window_errors++;
+                       dev->stats.tx_window_errors++;
                if (events & IEVENT_CRL)
-                       priv->stats.tx_aborted_errors++;
+                       dev->stats.tx_aborted_errors++;
                if (events & IEVENT_XFUN) {
                        if (netif_msg_tx_err(priv))
                                printk(KERN_DEBUG "%s: TX FIFO underrun, "
                                       "packet dropped.\n", dev->name);
-                       priv->stats.tx_dropped++;
+                       dev->stats.tx_dropped++;
                        priv->extra_stats.tx_underrun++;
 
                        /* Reactivate the Tx Queues */
@@ -1937,7 +1938,7 @@ static irqreturn_t gfar_error(int irq, void *dev_id)
                        printk(KERN_DEBUG "%s: Transmit Error\n", dev->name);
        }
        if (events & IEVENT_BSY) {
-               priv->stats.rx_errors++;
+               dev->stats.rx_errors++;
                priv->extra_stats.rx_bsy++;
 
                gfar_receive(irq, dev_id);
@@ -1952,7 +1953,7 @@ static irqreturn_t gfar_error(int irq, void *dev_id)
                               dev->name, gfar_read(&priv->regs->rstat));
        }
        if (events & IEVENT_BABR) {
-               priv->stats.rx_errors++;
+               dev->stats.rx_errors++;
                priv->extra_stats.rx_babr++;
 
                if (netif_msg_rx_err(priv))