libertas: separate libertas' Kconfig in it's own file
[safe/jmp/linux-2.6] / drivers / net / wireless / netwave_cs.c
index a670f36..9498b46 100644 (file)
@@ -203,17 +203,14 @@ static int netwave_open(struct net_device *dev);  /* Open the device */
 static int netwave_close(struct net_device *dev); /* Close the device */
 
 /* Packet transmission and Packet reception */
-static int netwave_start_xmit( struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t netwave_start_xmit( struct sk_buff *skb,
+                                            struct net_device *dev);
 static int netwave_rx( struct net_device *dev);
 
 /* Interrupt routines */
 static irqreturn_t netwave_interrupt(int irq, void *dev_id);
 static void netwave_watchdog(struct net_device *);
 
-/* Statistics */
-static void update_stats(struct net_device *dev);
-static struct net_device_stats *netwave_get_stats(struct net_device *dev);
-
 /* Wireless extensions */
 static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev);
 
@@ -275,14 +272,9 @@ typedef struct netwave_private {
     int        lastExec;
     struct timer_list      watchdog;   /* To avoid blocking state */
     struct site_survey     nss;
-    struct net_device_stats stats;
     struct iw_statistics   iw_stats;    /* Wireless stats */
 } netwave_private;
 
-#ifdef NETWAVE_STATS
-static struct net_device_stats *netwave_get_stats(struct net_device *dev);
-#endif
-
 /*
  * The Netwave card is little-endian, so won't work for big endian
  * systems.
@@ -364,6 +356,17 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
     return &priv->iw_stats;
 }
 
+static const struct net_device_ops netwave_netdev_ops = {
+       .ndo_open               = netwave_open,
+       .ndo_stop               = netwave_close,
+       .ndo_start_xmit         = netwave_start_xmit,
+       .ndo_set_multicast_list = set_multicast_list,
+       .ndo_tx_timeout         = netwave_watchdog,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 /*
  * Function netwave_attach (void)
  *
@@ -412,17 +415,12 @@ static int netwave_probe(struct pcmcia_device *link)
     spin_lock_init(&priv->spinlock);
 
     /* Netwave specific entries in the device structure */
-    dev->hard_start_xmit = &netwave_start_xmit;
-    dev->get_stats  = &netwave_get_stats;
-    dev->set_multicast_list = &set_multicast_list;
+    dev->netdev_ops = &netwave_netdev_ops;
     /* wireless extensions */
-    dev->wireless_handlers = (struct iw_handler_def *)&netwave_handler_def;
+    dev->wireless_handlers = &netwave_handler_def;
 
-    dev->tx_timeout = &netwave_watchdog;
     dev->watchdog_timeo = TX_TIMEOUT;
 
-    dev->open = &netwave_open;
-    dev->stop = &netwave_close;
     link->irq.Instance = dev;
 
     return netwave_pcmcia_config( link);
@@ -737,7 +735,6 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
     win_req_t req;
     memreq_t mem;
     u_char __iomem *ramBase = NULL;
-    DECLARE_MAC_BUF(mac);
 
     DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link);
 
@@ -808,12 +805,12 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
        dev->dev_addr[i] = readb(ramBase + NETWAVE_EREG_PA + i);
 
     printk(KERN_INFO "%s: Netwave: port %#3lx, irq %d, mem %lx, "
-          "id %c%c, hw_addr %s\n",
+          "id %c%c, hw_addr %pM\n",
           dev->name, dev->base_addr, dev->irq,
           (u_long) ramBase,
           (int) readb(ramBase+NETWAVE_EREG_NI),
           (int) readb(ramBase+NETWAVE_EREG_NI+1),
-          print_mac(mac, dev->dev_addr));
+          dev->dev_addr);
 
     /* get revision words */
     printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", 
@@ -989,7 +986,7 @@ static int netwave_hw_xmit(unsigned char* data, int len,
        return 1;
     }
 
-    priv->stats.tx_bytes += len;
+    dev->stats.tx_bytes += len;
 
     DEBUG(3, "Transmitting with SPCQ %x SPU %x LIF %x ISPLQ %x\n",
          readb(ramBase + NETWAVE_EREG_SPCQ),
@@ -1030,7 +1027,8 @@ static int netwave_hw_xmit(unsigned char* data, int len,
     return 0;
 }
 
-static int netwave_start_xmit(struct sk_buff *skb, struct net_device *dev) {
+static netdev_tx_t netwave_start_xmit(struct sk_buff *skb,
+                                           struct net_device *dev) {
        /* This flag indicate that the hardware can't perform a transmission.
         * Theoritically, NET3 check it before sending a packet to the driver,
         * but in fact it never do that and pool continuously.
@@ -1051,7 +1049,7 @@ static int netwave_start_xmit(struct sk_buff *skb, struct net_device *dev) {
     }
     dev_kfree_skb(skb);
     
-    return 0;
+    return NETDEV_TX_OK;
 } /* netwave_start_xmit */
 
 /*
@@ -1108,11 +1106,11 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
            rser = readb(ramBase + NETWAVE_EREG_RSER);                  
            
            if (rser & 0x04) {
-               ++priv->stats.rx_dropped; 
-               ++priv->stats.rx_crc_errors;
+               ++dev->stats.rx_dropped;
+               ++dev->stats.rx_crc_errors;
            }
            if (rser & 0x02)
-               ++priv->stats.rx_frame_errors;
+               ++dev->stats.rx_frame_errors;
                        
            /* Clear the RxErr bit in RSER. RSER+4 is the
             * write part. Also clear the RxCRC (0x04) and 
@@ -1126,8 +1124,8 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
            wait_WOC(iobase);
            writeb(0x40, ramBase + NETWAVE_EREG_ASCC);
 
-           /* Remember to count up priv->stats on error packets */
-           ++priv->stats.rx_errors;
+           /* Remember to count up dev->stats on error packets */
+           ++dev->stats.rx_errors;
        }
        /* TxDN */
        if (status & 0x20) {
@@ -1141,17 +1139,17 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
                /* Transmitting was okay, clear bits */
                wait_WOC(iobase);
                writeb(0x2f, ramBase + NETWAVE_EREG_TSER + 4);
-               ++priv->stats.tx_packets;
+               ++dev->stats.tx_packets;
            }
                        
            if (txStatus & 0xd0) {
                if (txStatus & 0x80) {
-                   ++priv->stats.collisions; /* Because of /proc/net/dev*/
-                   /* ++priv->stats.tx_aborted_errors; */
+                   ++dev->stats.collisions; /* Because of /proc/net/dev*/
+                   /* ++dev->stats.tx_aborted_errors; */
                    /* printk("Collision. %ld\n", jiffies - dev->trans_start); */
                }
                if (txStatus & 0x40) 
-                   ++priv->stats.tx_carrier_errors;
+                   ++dev->stats.tx_carrier_errors;
                /* 0x80 TxGU Transmit giveup - nine times and no luck
                 * 0x40 TxNOAP No access point. Discarded packet.
                 * 0x10 TxErr Transmit error. Always set when 
@@ -1164,7 +1162,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
                /* Clear out TxGU, TxNOAP, TxErr and TxTrys */
                wait_WOC(iobase);
                writeb(0xdf & txStatus, ramBase+NETWAVE_EREG_TSER+4);
-               ++priv->stats.tx_errors;
+               ++dev->stats.tx_errors;
            }
            DEBUG(3, "New status is TSER %x ASR %x\n",
                  readb(ramBase + NETWAVE_EREG_TSER),
@@ -1198,40 +1196,6 @@ static void netwave_watchdog(struct net_device *dev) {
     netif_wake_queue(dev);
 } /* netwave_watchdog */
 
-static struct net_device_stats *netwave_get_stats(struct net_device *dev) {
-    netwave_private *priv = netdev_priv(dev);
-
-    update_stats(dev);
-
-    DEBUG(2, "netwave: SPCQ %x SPU %x LIF %x ISPLQ %x MHS %x rxtx %x"
-         " %x tx %x %x %x %x\n", 
-         readb(priv->ramBase + NETWAVE_EREG_SPCQ),
-         readb(priv->ramBase + NETWAVE_EREG_SPU),
-         readb(priv->ramBase + NETWAVE_EREG_LIF),
-         readb(priv->ramBase + NETWAVE_EREG_ISPLQ),
-         readb(priv->ramBase + NETWAVE_EREG_MHS),
-         readb(priv->ramBase + NETWAVE_EREG_EC + 0xe),
-         readb(priv->ramBase + NETWAVE_EREG_EC + 0xf),
-         readb(priv->ramBase + NETWAVE_EREG_EC + 0x18),
-         readb(priv->ramBase + NETWAVE_EREG_EC + 0x19),
-         readb(priv->ramBase + NETWAVE_EREG_EC + 0x1a),
-         readb(priv->ramBase + NETWAVE_EREG_EC + 0x1b));
-
-    return &priv->stats;
-}
-
-static void update_stats(struct net_device *dev) {
-    //unsigned long flags;
-/*     netwave_private *priv = netdev_priv(dev); */
-
-    //spin_lock_irqsave(&priv->spinlock, flags);
-
-/*    priv->stats.rx_packets = readb(priv->ramBase + 0x18e); 
-    priv->stats.tx_packets = readb(priv->ramBase + 0x18f); */
-
-    //spin_unlock_irqrestore(&priv->spinlock, flags);
-}
-
 static int netwave_rx(struct net_device *dev)
 {
     netwave_private *priv = netdev_priv(dev);
@@ -1275,7 +1239,7 @@ static int netwave_rx(struct net_device *dev)
        if (skb == NULL) {
            DEBUG(1, "netwave_rx: Could not allocate an sk_buff of "
                  "length %d\n", rcvLen);
-           ++priv->stats.rx_dropped; 
+           ++dev->stats.rx_dropped;
            /* Tell the adapter to skip the packet */
            wait_WOC(iobase);
            writeb(NETWAVE_CMD_SRP, ramBase + NETWAVE_EREG_CB + 0);
@@ -1308,9 +1272,8 @@ static int netwave_rx(struct net_device *dev)
        /* Queue packet for network layer */
        netif_rx(skb);
 
-       dev->last_rx = jiffies;
-       priv->stats.rx_packets++;
-       priv->stats.rx_bytes += rcvLen;
+       dev->stats.rx_packets++;
+       dev->stats.rx_bytes += rcvLen;
 
        /* Got the packet, tell the adapter to skip it */
        wait_WOC(iobase);