]> err.no Git - linux-2.6/blobdiff - drivers/net/wireless/atmel.c
Merge branch 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6
[linux-2.6] / drivers / net / wireless / atmel.c
index 0c07b8b7250d604b8ffd453b947020c9aec3ae46..ef2da4023d685e075426ade0e9c5cc3315c2ebea 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>
@@ -67,6 +66,7 @@
 #include <linux/device.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/jiffies.h>
 #include <net/ieee80211.h>
 #include "atmel.h"
 
@@ -517,7 +517,7 @@ struct atmel_private {
                SITE_SURVEY_IN_PROGRESS,
                SITE_SURVEY_COMPLETED
        } site_survey_state;
-       time_t last_survey;
+       unsigned long last_survey;
 
        int station_was_associated, station_is_associated;
        int fast_scan;
@@ -595,7 +595,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 +784,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 +828,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 +921,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 +1028,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);
@@ -1193,7 +1191,7 @@ static irqreturn_t service_interrupt(int irq, void *dev_id)
 
                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 +1343,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 +1391,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 +1435,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;
 
@@ -1487,6 +1485,7 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
        struct net_device *dev;
        struct atmel_private *priv;
        int rc;
+       DECLARE_MAC_BUF(mac);
 
        /* Create the network device object. */
         dev = alloc_etherdev(sizeof(*priv));
@@ -1601,12 +1600,9 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
        if (!ent)
                printk(KERN_WARNING "atmel: unable to create /proc entry.\n");
 
-       printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
-              dev->name, DRIVER_MAJOR, DRIVER_MINOR,
-              dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
-              dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] );
+       printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %s\n",
+              dev->name, DRIVER_MAJOR, DRIVER_MINOR, print_mac(mac, dev->dev_addr));
 
-       SET_MODULE_OWNER(dev);
        return dev;
 
 err_out_res:
@@ -1736,7 +1732,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 */
@@ -1764,9 +1760,8 @@ static int atmel_set_encode(struct net_device *dev,
                        priv->default_key = index;
                } else
                        /* Don't complain if only change the mode */
-                       if (!dwrq->flags & IW_ENCODE_MODE) {
+                       if (!(dwrq->flags & IW_ENCODE_MODE))
                                return -EINVAL;
-                       }
        }
        /* Read the flags */
        if (dwrq->flags & IW_ENCODE_DISABLED) {
@@ -1907,7 +1902,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;
@@ -2289,7 +2284,7 @@ static int atmel_set_scan(struct net_device *dev,
                return -EAGAIN;
 
        /* Timeout old surveys. */
-       if ((jiffies - priv->last_survey) > (20 * HZ))
+       if (time_after(jiffies, priv->last_survey + 20 * HZ))
                priv->site_survey_state = SITE_SURVEY_IDLE;
        priv->last_survey = jiffies;
 
@@ -2343,6 +2338,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;
@@ -2373,7 +2376,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;
@@ -2579,9 +2582,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,
@@ -2645,7 +2648,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;
@@ -2673,9 +2676,9 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 }
 
 struct auth_body {
-       u16 alg;
-       u16 trans_seq;
-       u16 status;
+       __le16 alg;
+       __le16 trans_seq;
+       __le16 status;
        u8 el_id;
        u8 chall_text_len;
        u8 chall_text[253];
@@ -2710,9 +2713,9 @@ static void atmel_scan(struct atmel_private *priv, int specific_ssid)
                u8 SSID[MAX_SSID_LENGTH];
                u8 scan_type;
                u8 channel;
-               u16 BSS_type;
-               u16 min_channel_time;
-               u16 max_channel_time;
+               __le16 BSS_type;
+               __le16 min_channel_time;
+               __le16 max_channel_time;
                u8 options;
                u8 SSID_size;
        } cmd;
@@ -2755,7 +2758,7 @@ static void join(struct atmel_private *priv, int type)
                u8 SSID[MAX_SSID_LENGTH];
                u8 BSS_type; /* this is a short in a scan command - weird */
                u8 channel;
-               u16 timeout;
+               __le16 timeout;
                u8 SSID_size;
                u8 reserved;
        } cmd;
@@ -2860,8 +2863,8 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
        int bodysize;
        struct ieee80211_hdr_4addr header;
        struct ass_req_format {
-               u16 capability;
-               u16 listen_interval;
+               __le16 capability;
+               __le16 listen_interval;
                u8 ap[6]; /* nothing after here directly accessible */
                u8 ssid_el_id;
                u8 ssid_len;
@@ -3082,9 +3085,9 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
 static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype)
 {
        struct ass_resp_format {
-               u16 capability;
-               u16 status;
-               u16 ass_id;
+               __le16 capability;
+               __le16 status;
+               __le16 ass_id;
                u8 el_id;
                u8 length;
                u8 rates[4];
@@ -3291,9 +3294,9 @@ static void atmel_management_frame(struct atmel_private *priv,
                   never let an engineer loose with a data structure design. */
                {
                        struct beacon_format {
-                               u64 timestamp;
-                               u16 interval;
-                               u16 capability;
+                               __le64 timestamp;
+                               __le16 interval;
+                               __le16 capability;
                                u8 ssid_el_id;
                                u8 ssid_length;
                                /* ssid here */