Merge branch 'e1000-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[pandora-kernel.git] / drivers / net / wireless / atmel.c
index 0fc267d..51a7db5 100644 (file)
@@ -42,7 +42,6 @@
 #include <linux/init.h>
 
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/ptrace.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -595,7 +594,7 @@ static void atmel_join_bss(struct atmel_private *priv, int bss_index);
 static void atmel_smooth_qual(struct atmel_private *priv);
 static void atmel_writeAR(struct net_device *dev, u16 data);
 static int probe_atmel_card(struct net_device *dev);
-static int reset_atmel_card(struct net_device *dev );
+static int reset_atmel_card(struct net_device *dev);
 static void atmel_enter_state(struct atmel_private *priv, int new_state);
 int atmel_open (struct net_device *dev);
 
@@ -784,11 +783,11 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast,
 
 static int start_tx(struct sk_buff *skb, struct net_device *dev)
 {
+       static const u8 SNAP_RFC1024[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
        struct atmel_private *priv = netdev_priv(dev);
        struct ieee80211_hdr_4addr header;
        unsigned long flags;
        u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
-       u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
 
        if (priv->card && priv->present_callback &&
            !(*priv->present_callback)(priv->card)) {
@@ -828,14 +827,14 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
        if (priv->wep_is_on)
                frame_ctl |= IEEE80211_FCTL_PROTECTED;
        if (priv->operating_mode == IW_MODE_ADHOC) {
-               memcpy(&header.addr1, skb->data, 6);
+               skb_copy_from_linear_data(skb, &header.addr1, 6);
                memcpy(&header.addr2, dev->dev_addr, 6);
                memcpy(&header.addr3, priv->BSSID, 6);
        } else {
                frame_ctl |= IEEE80211_FCTL_TODS;
                memcpy(&header.addr1, priv->CurrentBSSID, 6);
                memcpy(&header.addr2, dev->dev_addr, 6);
-               memcpy(&header.addr3, skb->data, 6);
+               skb_copy_from_linear_data(skb, &header.addr3, 6);
        }
 
        if (priv->use_wpa)
@@ -921,7 +920,6 @@ static void fast_rx_path(struct atmel_private *priv,
                memcpy(&skbp[6], header->addr2, 6); /* source address */
 
        priv->dev->last_rx = jiffies;
-       skb->dev = priv->dev;
        skb->protocol = eth_type_trans(skb, priv->dev);
        skb->ip_summed = CHECKSUM_NONE;
        netif_rx(skb);
@@ -1029,7 +1027,6 @@ static void frag_rx_path(struct atmel_private *priv,
                                       priv->rx_buf,
                                       priv->frag_len + 12);
                                priv->dev->last_rx = jiffies;
-                               skb->dev = priv->dev;
                                skb->protocol = eth_type_trans(skb, priv->dev);
                                skb->ip_summed = CHECKSUM_NONE;
                                netif_rx(skb);
@@ -1145,7 +1142,7 @@ next:
        }
 }
 
-static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t service_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
        struct atmel_private *priv = netdev_priv(dev);
@@ -1193,7 +1190,7 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs
 
                atmel_set_gcr(dev, GCR_ACKINT); /* acknowledge interrupt */
 
-               for (i = 0; i < sizeof(irq_order)/sizeof(u8); i++)
+               for (i = 0; i < ARRAY_SIZE(irq_order); i++)
                        if (isr & irq_order[i])
                                break;
 
@@ -1345,10 +1342,10 @@ int atmel_open(struct net_device *dev)
                atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS, priv->reg_domain);
        } else {
                priv->reg_domain = atmel_get_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS);
-               for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++)
+               for (i = 0; i < ARRAY_SIZE(channel_table); i++)
                        if (priv->reg_domain == channel_table[i].reg_domain)
                                break;
-               if (i == sizeof(channel_table)/sizeof(channel_table[0])) {
+               if (i == ARRAY_SIZE(channel_table)) {
                        priv->reg_domain = REG_DOMAIN_MKK1;
                        printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name);
                }
@@ -1393,7 +1390,7 @@ static int atmel_validate_channel(struct atmel_private *priv, int channel)
           else return suitable default channel */
        int i;
 
-       for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++)
+       for (i = 0; i < ARRAY_SIZE(channel_table); i++)
                if (priv->reg_domain == channel_table[i].reg_domain) {
                        if (channel >= channel_table[i].min &&
                            channel <= channel_table[i].max)
@@ -1437,7 +1434,7 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv)
                }
 
                r = "<unknown>";
-               for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++)
+               for (i = 0; i < ARRAY_SIZE(channel_table); i++)
                        if (priv->reg_domain == channel_table[i].reg_domain)
                                r = channel_table[i].name;
 
@@ -1678,11 +1675,9 @@ static int atmel_get_essid(struct net_device *dev,
        /* Get the current SSID */
        if (priv->new_SSID_size != 0) {
                memcpy(extra, priv->new_SSID, priv->new_SSID_size);
-               extra[priv->new_SSID_size] = '\0';
                dwrq->length = priv->new_SSID_size;
        } else {
                memcpy(extra, priv->SSID, priv->SSID_size);
-               extra[priv->SSID_size] = '\0';
                dwrq->length = priv->SSID_size;
        }
 
@@ -1738,7 +1733,7 @@ static int atmel_set_encode(struct net_device *dev,
                                /* Disable the key */
                                priv->wep_key_len[index] = 0;
                /* Check if the key is not marked as invalid */
-               if(!(dwrq->flags & IW_ENCODE_NOKEY)) {
+               if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
                        /* Cleanup */
                        memset(priv->wep_keys[index], 0, 13);
                        /* Copy the key in the driver */
@@ -1909,7 +1904,7 @@ static int atmel_get_encodeext(struct net_device *dev,
 
        encoding->flags = idx + 1;
        memset(ext, 0, sizeof(*ext));
-       
+
        if (!priv->wep_is_on) {
                ext->alg = IW_ENCODE_ALG_NONE;
                ext->key_len = 0;
@@ -2345,6 +2340,14 @@ static int atmel_get_scan(struct net_device *dev,
                iwe.u.freq.e = 0;
                current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN);
 
+               /* Add quality statistics */
+               iwe.cmd = IWEVQUAL;
+               iwe.u.qual.level = priv->BSSinfo[i].RSSI;
+               iwe.u.qual.qual  = iwe.u.qual.level;
+               /* iwe.u.qual.noise  = SOMETHING */
+               current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA , &iwe, IW_EV_QUAL_LEN);
+
+
                iwe.cmd = SIOCGIWENCODE;
                if (priv->BSSinfo[i].UsingWEP)
                        iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
@@ -2375,7 +2378,7 @@ static int atmel_get_range(struct net_device *dev,
        range->min_nwid = 0x0000;
        range->max_nwid = 0x0000;
        range->num_channels = 0;
-       for (j = 0; j < sizeof(channel_table)/sizeof(channel_table[0]); j++)
+       for (j = 0; j < ARRAY_SIZE(channel_table); j++)
                if (priv->reg_domain == channel_table[j].reg_domain) {
                        range->num_channels = channel_table[j].max - channel_table[j].min + 1;
                        break;
@@ -2581,9 +2584,9 @@ static const struct iw_priv_args atmel_private_args[] = {
 
 static const struct iw_handler_def atmel_handler_def =
 {
-       .num_standard   = sizeof(atmel_handler)/sizeof(iw_handler),
-       .num_private    = sizeof(atmel_private_handler)/sizeof(iw_handler),
-       .num_private_args = sizeof(atmel_private_args)/sizeof(struct iw_priv_args),
+       .num_standard   = ARRAY_SIZE(atmel_handler),
+       .num_private    = ARRAY_SIZE(atmel_private_handler),
+       .num_private_args = ARRAY_SIZE(atmel_private_args),
        .standard       = (iw_handler *) atmel_handler,
        .private        = (iw_handler *) atmel_private_handler,
        .private_args   = (struct iw_priv_args *) atmel_private_args,
@@ -2647,7 +2650,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
                domain[REGDOMAINSZ] = 0;
                rc = -EINVAL;
-               for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) {
+               for (i = 0; i < ARRAY_SIZE(channel_table); i++) {
                        /* strcasecmp doesn't exist in the library */
                        char *a = channel_table[i].name;
                        char *b = domain;