iwlwifi: add missing rcu_read_lock
[safe/jmp/linux-2.6] / drivers / net / wireless / zd1201.c
index b45c27d..390d77f 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/wireless.h>
@@ -112,6 +113,9 @@ exit:
        return err;
 }
 
+MODULE_FIRMWARE("zd1201-ap.fw");
+MODULE_FIRMWARE("zd1201.fw");
+
 static void zd1201_usbfree(struct urb *urb)
 {
        struct zd1201 *zd = urb->context;
@@ -130,7 +134,6 @@ static void zd1201_usbfree(struct urb *urb)
 
        kfree(urb->transfer_buffer);
        usb_free_urb(urb);
-       return;
 }
 
 /* cmdreq message: 
@@ -181,7 +184,6 @@ static void zd1201_usbtx(struct urb *urb)
 {
        struct zd1201 *zd = urb->context;
        netif_wake_queue(zd->dev);
-       return;
 }
 
 /* Incoming data */
@@ -328,8 +330,8 @@ static void zd1201_usbrx(struct urb *urb)
                        memcpy(skb_put(skb, 2), &data[datalen-24], 2);
                        memcpy(skb_put(skb, len), data, len);
                        skb->protocol = eth_type_trans(skb, zd->dev);
-                       zd->stats.rx_packets++;
-                       zd->stats.rx_bytes += skb->len;
+                       zd->dev->stats.rx_packets++;
+                       zd->dev->stats.rx_bytes += skb->len;
                        netif_rx(skb);
                        goto resubmit;
                }
@@ -384,8 +386,8 @@ static void zd1201_usbrx(struct urb *urb)
                        memcpy(skb_put(skb, len), data+8, len);
                }
                skb->protocol = eth_type_trans(skb, zd->dev);
-               zd->stats.rx_packets++;
-               zd->stats.rx_bytes += skb->len;
+               zd->dev->stats.rx_packets++;
+               zd->dev->stats.rx_bytes += skb->len;
                netif_rx(skb);
        }
 resubmit:
@@ -403,7 +405,6 @@ exit:
                wake_up(&zd->rxdataq);
                kfree(urb->transfer_buffer);
        }
-       return;
 }
 
 static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,
@@ -779,7 +780,8 @@ static int zd1201_net_stop(struct net_device *dev)
                                (llc+snap+type+payload)
                zd              1 null byte, zd1201 packet type
  */
-static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t zd1201_hard_start_xmit(struct sk_buff *skb,
+                                               struct net_device *dev)
 {
        struct zd1201 *zd = netdev_priv(dev);
        unsigned char *txbuf = zd->txdata;
@@ -787,9 +789,9 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
        struct urb *urb = zd->tx_urb;
 
        if (!zd->mac_enabled || zd->monitor) {
-               zd->stats.tx_dropped++;
+               dev->stats.tx_dropped++;
                kfree_skb(skb);
-               return 0;
+               return NETDEV_TX_OK;
        }
        netif_stop_queue(dev);
 
@@ -817,16 +819,15 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        err = usb_submit_urb(zd->tx_urb, GFP_ATOMIC);
        if (err) {
-               zd->stats.tx_errors++;
+               dev->stats.tx_errors++;
                netif_start_queue(dev);
-               return err;
+       } else {
+               dev->stats.tx_packets++;
+               dev->stats.tx_bytes += skb->len;
        }
-       zd->stats.tx_packets++;
-       zd->stats.tx_bytes += skb->len;
-       dev->trans_start = jiffies;
        kfree_skb(skb);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void zd1201_tx_timeout(struct net_device *dev)
@@ -838,9 +839,9 @@ static void zd1201_tx_timeout(struct net_device *dev)
        dev_warn(&zd->usb->dev, "%s: TX timeout, shooting down urb\n",
            dev->name);
        usb_unlink_urb(zd->tx_urb);
-       zd->stats.tx_errors++;
+       dev->stats.tx_errors++;
        /* Restart the timeout to quiet the watchdog: */
-       dev->trans_start = jiffies;
+       dev->trans_start = jiffies; /* prevent tx timeout */
 }
 
 static int zd1201_set_mac_address(struct net_device *dev, void *p)
@@ -861,13 +862,6 @@ static int zd1201_set_mac_address(struct net_device *dev, void *p)
        return zd1201_mac_reset(zd);
 }
 
-static struct net_device_stats *zd1201_get_stats(struct net_device *dev)
-{
-       struct zd1201 *zd = netdev_priv(dev);
-
-       return &zd->stats;
-}
-
 static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
 {
        struct zd1201 *zd = netdev_priv(dev);
@@ -878,20 +872,18 @@ static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
 static void zd1201_set_multicast(struct net_device *dev)
 {
        struct zd1201 *zd = netdev_priv(dev);
-       struct dev_mc_list *mc = dev->mc_list;
+       struct netdev_hw_addr *ha;
        unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI];
        int i;
 
-       if (dev->mc_count > ZD1201_MAXMULTI)
+       if (netdev_mc_count(dev) > ZD1201_MAXMULTI)
                return;
 
-       for (i=0; i<dev->mc_count; i++) {
-               memcpy(reqbuf+i*ETH_ALEN, mc->dmi_addr, ETH_ALEN);
-               mc = mc->next;
-       }
+       i = 0;
+       netdev_for_each_mc_addr(ha, dev)
+               memcpy(reqbuf + i++ * ETH_ALEN, ha->addr, ETH_ALEN);
        zd1201_setconfig(zd, ZD1201_RID_CNFGROUPADDRESS, reqbuf,
-           dev->mc_count*ETH_ALEN, 0);
-       
+                        netdev_mc_count(dev) * ETH_ALEN, 0);
 }
 
 static int zd1201_config_commit(struct net_device *dev, 
@@ -919,10 +911,9 @@ static int zd1201_set_freq(struct net_device *dev,
        if (freq->e == 0)
                channel = freq->m;
        else {
-               if (freq->m >= 2482)
-                       channel = 14;
-               if (freq->m >= 2407)
-                       channel = (freq->m-2407)/5;
+               channel = ieee80211_freq_to_dsss_chan(freq->m);
+               if (channel < 0)
+                       channel = 0;
        }
 
        err = zd1201_setconfig16(zd, ZD1201_RID_CNFOWNCHANNEL, channel);
@@ -1725,6 +1716,17 @@ static const struct iw_handler_def zd1201_iw_handlers = {
        .get_wireless_stats     = zd1201_get_wireless_stats,
 };
 
+static const struct net_device_ops zd1201_netdev_ops = {
+       .ndo_open               = zd1201_net_open,
+       .ndo_stop               = zd1201_net_stop,
+       .ndo_start_xmit         = zd1201_hard_start_xmit,
+       .ndo_tx_timeout         = zd1201_tx_timeout,
+       .ndo_set_multicast_list = zd1201_set_multicast,
+       .ndo_set_mac_address    = zd1201_set_mac_address,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static int zd1201_probe(struct usb_interface *interface,
                        const struct usb_device_id *id)
 {
@@ -1777,16 +1779,9 @@ static int zd1201_probe(struct usb_interface *interface,
        if (err)
                goto err_start;
 
-       dev->open = zd1201_net_open;
-       dev->stop = zd1201_net_stop;
-       dev->get_stats = zd1201_get_stats;
-       dev->wireless_handlers =
-           (struct iw_handler_def *)&zd1201_iw_handlers;
-       dev->hard_start_xmit = zd1201_hard_start_xmit;
+       dev->netdev_ops = &zd1201_netdev_ops;
+       dev->wireless_handlers = &zd1201_iw_handlers;
        dev->watchdog_timeo = ZD1201_TX_TIMEOUT;
-       dev->tx_timeout = zd1201_tx_timeout;
-       dev->set_multicast_list = zd1201_set_multicast;
-       dev->set_mac_address = zd1201_set_mac_address;
        strcpy(dev->name, "wlan%d");
 
        err = zd1201_getconfig(zd, ZD1201_RID_CNFOWNMACADDR,