iwlwifi: update copyright year to 2009
[safe/jmp/linux-2.6] / drivers / net / wireless / atmel.c
index f978a9d..91930a2 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/string.h>
 #include <linux/ctype.h>
 #include <linux/timer.h>
+#include <asm/byteorder.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <linux/delay.h>
 #include <linux/wireless.h>
 #include <net/iw_handler.h>
-#include <linux/byteorder/generic.h>
 #include <linux/crc32.h>
 #include <linux/proc_fs.h>
 #include <linux/device.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
 #include <linux/jiffies.h>
-#include <net/ieee80211.h>
+#include <linux/ieee80211.h>
 #include "atmel.h"
 
 #define DRIVER_MAJOR 0
@@ -559,7 +559,7 @@ static const struct {
 static void build_wpa_mib(struct atmel_private *priv);
 static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void atmel_copy_to_card(struct net_device *dev, u16 dest,
-                              unsigned char *src, u16 len);
+                              const unsigned char *src, u16 len);
 static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest,
                               u16 src, u16 len);
 static void atmel_set_gcr(struct net_device *dev, u16 mask);
@@ -569,7 +569,7 @@ static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data);
 static void atmel_command_irq(struct atmel_private *priv);
 static int atmel_validate_channel(struct atmel_private *priv, int channel);
 static void atmel_management_frame(struct atmel_private *priv,
-                                  struct ieee80211_hdr_4addr *header,
+                                  struct ieee80211_hdr *header,
                                   u16 frame_len, u8 rssi);
 static void atmel_management_timer(u_long a);
 static void atmel_send_command(struct atmel_private *priv, int command,
@@ -577,7 +577,7 @@ static void atmel_send_command(struct atmel_private *priv, int command,
 static int atmel_send_command_wait(struct atmel_private *priv, int command,
                                   void *cmd, int cmd_size);
 static void atmel_transmit_management_frame(struct atmel_private *priv,
-                                           struct ieee80211_hdr_4addr *header,
+                                           struct ieee80211_hdr *header,
                                            u8 *body, int body_len);
 
 static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index);
@@ -785,7 +785,7 @@ 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;
+       struct ieee80211_hdr header;
        unsigned long flags;
        u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
 
@@ -823,7 +823,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
 
        frame_ctl = IEEE80211_FTYPE_DATA;
        header.duration_id = 0;
-       header.seq_ctl = 0;
+       header.seq_ctrl = 0;
        if (priv->wep_is_on)
                frame_ctl |= IEEE80211_FCTL_PROTECTED;
        if (priv->operating_mode == IW_MODE_ADHOC) {
@@ -840,7 +840,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
        if (priv->use_wpa)
                memcpy(&header.addr4, SNAP_RFC1024, 6);
 
-       header.frame_ctl = cpu_to_le16(frame_ctl);
+       header.frame_control = cpu_to_le16(frame_ctl);
        /* Copy the wireless header into the card */
        atmel_copy_to_card(dev, buff, (unsigned char *)&header, DATA_FRAME_WS_HEADER_SIZE);
        /* Copy the packet sans its 802.3 header addresses which have been replaced */
@@ -860,7 +860,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
 }
 
 static void atmel_transmit_management_frame(struct atmel_private *priv,
-                                           struct ieee80211_hdr_4addr *header,
+                                           struct ieee80211_hdr *header,
                                            u8 *body, int body_len)
 {
        u16 buff;
@@ -876,7 +876,7 @@ static void atmel_transmit_management_frame(struct atmel_private *priv,
 }
 
 static void fast_rx_path(struct atmel_private *priv,
-                        struct ieee80211_hdr_4addr *header,
+                        struct ieee80211_hdr *header,
                         u16 msdu_size, u16 rx_packet_loc, u32 crc)
 {
        /* fast path: unfragmented packet copy directly into skbuf */
@@ -914,12 +914,11 @@ static void fast_rx_path(struct atmel_private *priv,
        }
 
        memcpy(skbp, header->addr1, 6); /* destination address */
-       if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
+       if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
                memcpy(&skbp[6], header->addr3, 6);
        else
                memcpy(&skbp[6], header->addr2, 6); /* source address */
 
-       priv->dev->last_rx = jiffies;
        skb->protocol = eth_type_trans(skb, priv->dev);
        skb->ip_summed = CHECKSUM_NONE;
        netif_rx(skb);
@@ -950,7 +949,7 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
 }
 
 static void frag_rx_path(struct atmel_private *priv,
-                        struct ieee80211_hdr_4addr *header,
+                        struct ieee80211_hdr *header,
                         u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no,
                         u8 frag_no, int more_frags)
 {
@@ -958,7 +957,7 @@ static void frag_rx_path(struct atmel_private *priv,
        u8 source[6];
        struct sk_buff *skb;
 
-       if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
+       if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
                memcpy(source, header->addr3, 6);
        else
                memcpy(source, header->addr2, 6);
@@ -1026,7 +1025,6 @@ static void frag_rx_path(struct atmel_private *priv,
                                memcpy(skb_put(skb, priv->frag_len + 12),
                                       priv->rx_buf,
                                       priv->frag_len + 12);
-                               priv->dev->last_rx = jiffies;
                                skb->protocol = eth_type_trans(skb, priv->dev);
                                skb->ip_summed = CHECKSUM_NONE;
                                netif_rx(skb);
@@ -1041,7 +1039,7 @@ static void frag_rx_path(struct atmel_private *priv,
 static void rx_done_irq(struct atmel_private *priv)
 {
        int i;
-       struct ieee80211_hdr_4addr header;
+       struct ieee80211_hdr header;
 
        for (i = 0;
             atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID &&
@@ -1068,10 +1066,10 @@ static void rx_done_irq(struct atmel_private *priv)
                        goto next;
                }
 
-               /* Get header as far as end of seq_ctl */
+               /* Get header as far as end of seq_ctrl */
                atmel_copy_to_host(priv->dev, (char *)&header, rx_packet_loc, 24);
-               frame_ctl = le16_to_cpu(header.frame_ctl);
-               seq_control = le16_to_cpu(header.seq_ctl);
+               frame_ctl = le16_to_cpu(header.frame_control);
+               seq_control = le16_to_cpu(header.seq_ctrl);
 
                /* probe for CRC use here if needed  once five packets have
                   arrived with the same crc status, we assume we know what's
@@ -1304,7 +1302,7 @@ EXPORT_SYMBOL(atmel_open);
 int atmel_open(struct net_device *dev)
 {
        struct atmel_private *priv = netdev_priv(dev);
-       int i, channel;
+       int i, channel, err;
 
        /* any scheduled timer is no longer needed and might screw things up.. */
        del_timer_sync(&priv->management_timer);
@@ -1328,8 +1326,9 @@ int atmel_open(struct net_device *dev)
        priv->site_survey_state = SITE_SURVEY_IDLE;
        priv->station_is_associated = 0;
 
-       if (!reset_atmel_card(dev))
-               return -EAGAIN;
+       err = reset_atmel_card(dev);
+       if (err)
+               return err;
 
        if (priv->config_reg_domain) {
                priv->reg_domain = priv->config_reg_domain;
@@ -1478,7 +1477,6 @@ 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));
@@ -1590,8 +1588,8 @@ 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 %s\n",
-              dev->name, DRIVER_MAJOR, DRIVER_MINOR, print_mac(mac, dev->dev_addr));
+       printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %pM\n",
+              dev->name, DRIVER_MAJOR, DRIVER_MINOR, dev->dev_addr);
 
        return dev;
 
@@ -1821,7 +1819,7 @@ static int atmel_set_encodeext(struct net_device *dev,
        /* Determine and validate the key index */
        idx = encoding->flags & IW_ENCODE_INDEX;
        if (idx) {
-               if (idx < 1 || idx > WEP_KEYS)
+               if (idx < 1 || idx > 4)
                        return -EINVAL;
                idx--;
        } else
@@ -1884,7 +1882,7 @@ static int atmel_get_encodeext(struct net_device *dev,
 
        idx = encoding->flags & IW_ENCODE_INDEX;
        if (idx) {
-               if (idx < 1 || idx > WEP_KEYS)
+               if (idx < 1 || idx > 4)
                        return -EINVAL;
                idx--;
        } else
@@ -2206,9 +2204,6 @@ static int atmel_get_frag(struct net_device *dev,
        return 0;
 }
 
-static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
-                               2447, 2452, 2457, 2462, 2467, 2472, 2484 };
-
 static int atmel_set_freq(struct net_device *dev,
                          struct iw_request_info *info,
                          struct iw_freq *fwrq,
@@ -2218,16 +2213,12 @@ static int atmel_set_freq(struct net_device *dev,
        int rc = -EINPROGRESS;          /* Call commit handler */
 
        /* If setting by frequency, convert to a channel */
-       if ((fwrq->e == 1) &&
-           (fwrq->m >= (int) 241200000) &&
-           (fwrq->m <= (int) 248700000)) {
+       if (fwrq->e == 1) {
                int f = fwrq->m / 100000;
-               int c = 0;
-               while ((c < 14) && (f != frequency_list[c]))
-                       c++;
+
                /* Hack to fall through... */
                fwrq->e = 0;
-               fwrq->m = c + 1;
+               fwrq->m = ieee80211_freq_to_dsss_chan(f);
        }
        /* Setting by channel number */
        if ((fwrq->m > 1000) || (fwrq->e > 0))
@@ -2257,7 +2248,7 @@ static int atmel_get_freq(struct net_device *dev,
 
 static int atmel_set_scan(struct net_device *dev,
                          struct iw_request_info *info,
-                         struct iw_param *vwrq,
+                         struct iw_point *dwrq,
                          char *extra)
 {
        struct atmel_private *priv = netdev_priv(dev);
@@ -2310,30 +2301,40 @@ static int atmel_get_scan(struct net_device *dev,
                iwe.cmd = SIOCGIWAP;
                iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
                memcpy(iwe.u.ap_addr.sa_data, priv->BSSinfo[i].BSSID, 6);
-               current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_ADDR_LEN);
+               current_ev = iwe_stream_add_event(info, current_ev,
+                                                 extra + IW_SCAN_MAX_DATA,
+                                                 &iwe, IW_EV_ADDR_LEN);
 
                iwe.u.data.length =  priv->BSSinfo[i].SSIDsize;
                if (iwe.u.data.length > 32)
                        iwe.u.data.length = 32;
                iwe.cmd = SIOCGIWESSID;
                iwe.u.data.flags = 1;
-               current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, priv->BSSinfo[i].SSID);
+               current_ev = iwe_stream_add_point(info, current_ev,
+                                                 extra + IW_SCAN_MAX_DATA,
+                                                 &iwe, priv->BSSinfo[i].SSID);
 
                iwe.cmd = SIOCGIWMODE;
                iwe.u.mode = priv->BSSinfo[i].BSStype;
-               current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_UINT_LEN);
+               current_ev = iwe_stream_add_event(info, current_ev,
+                                                 extra + IW_SCAN_MAX_DATA,
+                                                 &iwe, IW_EV_UINT_LEN);
 
                iwe.cmd = SIOCGIWFREQ;
                iwe.u.freq.m = priv->BSSinfo[i].channel;
                iwe.u.freq.e = 0;
-               current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN);
+               current_ev = iwe_stream_add_event(info, 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);
+               current_ev = iwe_stream_add_event(info, current_ev,
+                                                 extra + IW_SCAN_MAX_DATA,
+                                                 &iwe, IW_EV_QUAL_LEN);
 
 
                iwe.cmd = SIOCGIWENCODE;
@@ -2342,7 +2343,9 @@ static int atmel_get_scan(struct net_device *dev,
                else
                        iwe.u.data.flags = IW_ENCODE_DISABLED;
                iwe.u.data.length = 0;
-               current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, NULL);
+               current_ev = iwe_stream_add_point(info, current_ev,
+                                                 extra + IW_SCAN_MAX_DATA,
+                                                 &iwe, NULL);
        }
 
        /* Length of data */
@@ -2374,8 +2377,11 @@ static int atmel_get_range(struct net_device *dev,
        if (range->num_channels != 0) {
                for (k = 0, i = channel_table[j].min; i <= channel_table[j].max; i++) {
                        range->freq[k].i = i; /* List index */
-                       range->freq[k].m = frequency_list[i - 1] * 100000;
-                       range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */
+
+                       /* Values in MHz -> * 10^5 * 10 */
+                       range->freq[k].m = (ieee80211_dsss_chan_to_freq(i) *
+                                           100000);
+                       range->freq[k++].e = 1;
                }
                range->num_frequency = k;
        }
@@ -2787,7 +2793,7 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability,
                                u8 channel)
 {
        int rejoin = 0;
-       int new = capability & MFIE_TYPE_POWER_CONSTRAINT ?
+       int new = capability & WLAN_CAPABILITY_SHORT_PREAMBLE ?
                SHORT_PREAMBLE : LONG_PREAMBLE;
 
        if (priv->preamble != new) {
@@ -2816,19 +2822,19 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability,
 static void send_authentication_request(struct atmel_private *priv, u16 system,
                                        u8 *challenge, int challenge_len)
 {
-       struct ieee80211_hdr_4addr header;
+       struct ieee80211_hdr header;
        struct auth_body auth;
 
-       header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
+       header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
        header.duration_id = cpu_to_le16(0x8000);
-       header.seq_ctl = 0;
+       header.seq_ctrl = 0;
        memcpy(header.addr1, priv->CurrentBSSID, 6);
        memcpy(header.addr2, priv->dev->dev_addr, 6);
        memcpy(header.addr3, priv->CurrentBSSID, 6);
 
        if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1)
                /* no WEP for authentication frames with TrSeqNo 1 */
-                header.frame_ctl |=  cpu_to_le16(IEEE80211_FCTL_PROTECTED);
+                header.frame_control |=  cpu_to_le16(IEEE80211_FCTL_PROTECTED);
 
        auth.alg = cpu_to_le16(system);
 
@@ -2851,7 +2857,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
 {
        u8 *ssid_el_p;
        int bodysize;
-       struct ieee80211_hdr_4addr header;
+       struct ieee80211_hdr header;
        struct ass_req_format {
                __le16 capability;
                __le16 listen_interval;
@@ -2864,10 +2870,10 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
                u8 rates[4];
        } body;
 
-       header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
+       header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
                (is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ));
        header.duration_id = cpu_to_le16(0x8000);
-       header.seq_ctl = 0;
+       header.seq_ctrl = 0;
 
        memcpy(header.addr1, priv->CurrentBSSID, 6);
        memcpy(header.addr2, priv->dev->dev_addr, 6);
@@ -2877,7 +2883,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
        if (priv->wep_is_on)
                body.capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
        if (priv->preamble == SHORT_PREAMBLE)
-               body.capability |= cpu_to_le16(MFIE_TYPE_POWER_CONSTRAINT);
+               body.capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
 
        body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period);
 
@@ -2891,10 +2897,10 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
                bodysize = 12 + priv->SSID_size;
        }
 
-       ssid_el_p[0] = MFIE_TYPE_SSID;
+       ssid_el_p[0] = WLAN_EID_SSID;
        ssid_el_p[1] = priv->SSID_size;
        memcpy(ssid_el_p + 2, priv->SSID, priv->SSID_size);
-       ssid_el_p[2 + priv->SSID_size] = MFIE_TYPE_RATES;
+       ssid_el_p[2 + priv->SSID_size] = WLAN_EID_SUPP_RATES;
        ssid_el_p[3 + priv->SSID_size] = 4; /* len of suported rates */
        memcpy(ssid_el_p + 4 + priv->SSID_size, atmel_basic_rates, 4);
 
@@ -2902,9 +2908,9 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
 }
 
 static int is_frame_from_current_bss(struct atmel_private *priv,
-                                    struct ieee80211_hdr_4addr *header)
+                                    struct ieee80211_hdr *header)
 {
-       if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
+       if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
                return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0;
        else
                return memcmp(header->addr2, priv->CurrentBSSID, 6) == 0;
@@ -2952,7 +2958,7 @@ static int retrieve_bss(struct atmel_private *priv)
 }
 
 static void store_bss_info(struct atmel_private *priv,
-                          struct ieee80211_hdr_4addr *header, u16 capability,
+                          struct ieee80211_hdr *header, u16 capability,
                           u16 beacon_period, u8 channel, u8 rssi, u8 ssid_len,
                           u8 *ssid, int is_beacon)
 {
@@ -2991,7 +2997,7 @@ static void store_bss_info(struct atmel_private *priv,
        else if (capability & WLAN_CAPABILITY_ESS)
                priv->BSSinfo[index].BSStype =IW_MODE_INFRA;
 
-       priv->BSSinfo[index].preamble = capability & MFIE_TYPE_POWER_CONSTRAINT ?
+       priv->BSSinfo[index].preamble = capability & WLAN_CAPABILITY_SHORT_PREAMBLE ?
                SHORT_PREAMBLE : LONG_PREAMBLE;
 }
 
@@ -3027,7 +3033,7 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
                        }
                } else if (system == WLAN_AUTH_SHARED_KEY) {
                        if (trans_seq_no == 0x0002 &&
-                           auth->el_id == MFIE_TYPE_CHALLENGE) {
+                           auth->el_id == WLAN_EID_CHALLENGE) {
                                send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len);
                                return;
                        } else if (trans_seq_no == 0x0004) {
@@ -3049,12 +3055,20 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
        }
 
        if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) {
-               /* Do opensystem first, then try sharedkey */
+               /* Flip back and forth between WEP auth modes until the max
+                * authentication tries has been exceeded.
+                */
                if (system == WLAN_AUTH_OPEN) {
                        priv->CurrentAuthentTransactionSeqNum = 0x001;
                        priv->exclude_unencrypted = 1;
                        send_authentication_request(priv, WLAN_AUTH_SHARED_KEY, NULL, 0);
                        return;
+               } else if (   system == WLAN_AUTH_SHARED_KEY
+                          && priv->wep_is_on) {
+                       priv->CurrentAuthentTransactionSeqNum = 0x001;
+                       priv->exclude_unencrypted = 0;
+                       send_authentication_request(priv, WLAN_AUTH_OPEN, NULL, 0);
+                       return;
                } else if (priv->connect_to_any_BSS) {
                        int bss_index;
 
@@ -3162,7 +3176,7 @@ static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype)
        }
 }
 
-void atmel_join_bss(struct atmel_private *priv, int bss_index)
+static void atmel_join_bss(struct atmel_private *priv, int bss_index)
 {
        struct bss_info *bss =  &priv->BSSinfo[bss_index];
 
@@ -3270,12 +3284,12 @@ static void atmel_smooth_qual(struct atmel_private *priv)
 
 /* deals with incoming managment frames. */
 static void atmel_management_frame(struct atmel_private *priv,
-                                  struct ieee80211_hdr_4addr *header,
+                                  struct ieee80211_hdr *header,
                                   u16 frame_len, u8 rssi)
 {
        u16 subtype;
 
-       subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE;
+       subtype = le16_to_cpu(header->frame_control) & IEEE80211_FCTL_STYPE;
        switch (subtype) {
        case IEEE80211_STYPE_BEACON:
        case IEEE80211_STYPE_PROBE_RESP:
@@ -3568,12 +3582,12 @@ static int atmel_wakeup_firmware(struct atmel_private *priv)
 
        if (i == 0) {
                printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name);
-               return 0;
+               return -EIO;
        }
 
        if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) {
                printk(KERN_ALERT "%s: card missing.\n", priv->dev->name);
-               return 0;
+               return -ENODEV;
        }
 
        /* now check for completion of MAC initialization through
@@ -3597,19 +3611,19 @@ static int atmel_wakeup_firmware(struct atmel_private *priv)
        if (i == 0) {
                printk(KERN_ALERT "%s: MAC failed to initialise.\n",
                                priv->dev->name);
-               return 0;
+               return -EIO;
        }
 
        /* Check for MAC_INIT_OK only on the register that the MAC_INIT_OK was set */
        if ((mr3 & MAC_INIT_COMPLETE) &&
            !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) {
                printk(KERN_ALERT "%s: MAC failed MR3 self-test.\n", priv->dev->name);
-               return 0;
+               return -EIO;
        }
        if ((mr1 & MAC_INIT_COMPLETE) &&
            !(atmel_read16(priv->dev, MR1) & MAC_INIT_OK)) {
                printk(KERN_ALERT "%s: MAC failed MR1 self-test.\n", priv->dev->name);
-               return 0;
+               return -EIO;
        }
 
        atmel_copy_to_host(priv->dev, (unsigned char *)iface,
@@ -3630,7 +3644,7 @@ static int atmel_wakeup_firmware(struct atmel_private *priv)
        iface->func_ctrl = le16_to_cpu(iface->func_ctrl);
        iface->mac_status = le16_to_cpu(iface->mac_status);
 
-       return 1;
+       return 0;
 }
 
 /* determine type of memory and MAC address */
@@ -3681,7 +3695,7 @@ static int probe_atmel_card(struct net_device *dev)
                /* Standard firmware in flash, boot it up and ask
                   for the Mac Address */
                priv->card_type = CARD_TYPE_SPI_FLASH;
-               if (atmel_wakeup_firmware(priv)) {
+               if (atmel_wakeup_firmware(priv) == 0) {
                        atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6);
 
                        /* got address, now squash it again until the network
@@ -3818,11 +3832,12 @@ static int reset_atmel_card(struct net_device *dev)
           This routine is also responsible for initialising some
           hardware-specific fields in the atmel_private structure,
           including a copy of the firmware's hostinfo stucture
-          which is the route into the rest of the firmare datastructures. */
+          which is the route into the rest of the firmware datastructures. */
 
        struct atmel_private *priv = netdev_priv(dev);
        u8 configuration;
        int old_state = priv->station_state;
+       int err = 0;
 
        /* data to add to the firmware names, in priority order
           this implemenents firmware versioning */
@@ -3843,7 +3858,7 @@ static int reset_atmel_card(struct net_device *dev)
        if (priv->card_type == CARD_TYPE_EEPROM) {
                /* copy in firmware if needed */
                const struct firmware *fw_entry = NULL;
-               unsigned char *fw;
+               const unsigned char *fw;
                int len = priv->firmware_length;
                if (!(fw = priv->firmware)) {
                        if (priv->firmware_type == ATMEL_FW_TYPE_NONE) {
@@ -3856,11 +3871,12 @@ static int reset_atmel_card(struct net_device *dev)
                                               dev->name);
                                        strcpy(priv->firmware_id, "atmel_at76c502.bin");
                                }
-                               if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) != 0) {
+                               err = request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev);
+                               if (err != 0) {
                                        printk(KERN_ALERT
                                               "%s: firmware %s is missing, cannot continue.\n",
                                               dev->name, priv->firmware_id);
-                                       return 0;
+                                       return err;
                                }
                        } else {
                                int fw_index = 0;
@@ -3889,7 +3905,7 @@ static int reset_atmel_card(struct net_device *dev)
                                               "%s: firmware %s is missing, cannot start.\n",
                                               dev->name, priv->firmware_id);
                                        priv->firmware_id[0] = '\0';
-                                       return 0;
+                                       return -ENOENT;
                                }
                        }
 
@@ -3914,8 +3930,9 @@ static int reset_atmel_card(struct net_device *dev)
                        release_firmware(fw_entry);
        }
 
-       if (!atmel_wakeup_firmware(priv))
-               return 0;
+       err = atmel_wakeup_firmware(priv);
+       if (err != 0)
+               return err;
 
        /* Check the version and set the correct flag for wpa stuff,
           old and new firmware is incompatible.
@@ -3956,10 +3973,9 @@ static int reset_atmel_card(struct net_device *dev)
        if (!priv->radio_on_broken) {
                if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) ==
                    CMD_STATUS_REJECTED_RADIO_OFF) {
-                       printk(KERN_INFO
-                              "%s: cannot turn the radio on. (Hey radio, you're beautiful!)\n",
+                       printk(KERN_INFO "%s: cannot turn the radio on.\n",
                               dev->name);
-                        return 0;
+                        return -EIO;
                }
        }
 
@@ -3994,7 +4010,7 @@ static int reset_atmel_card(struct net_device *dev)
                wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
        }
 
-       return 1;
+       return 0;
 }
 
 static void atmel_send_command(struct atmel_private *priv, int command,
@@ -4110,7 +4126,7 @@ static void atmel_writeAR(struct net_device *dev, u16 data)
 }
 
 static void atmel_copy_to_card(struct net_device *dev, u16 dest,
-                              unsigned char *src, u16 len)
+                              const unsigned char *src, u16 len)
 {
        int i;
        atmel_writeAR(dev, dest);