]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/atmel.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / atmel.c
index 51a7db53afa5f5c02229891dfcf49d77d4260024..f978a9d5190b504eb34113cb879c4d7250a3126b 100644 (file)
@@ -66,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"
 
@@ -432,7 +433,6 @@ struct atmel_private {
        struct net_device *dev;
        struct device *sys_dev;
        struct iw_statistics wstats;
-       struct net_device_stats stats;  // device stats
        spinlock_t irqlock, timerlock;  // spinlocks
        enum { BUS_TYPE_PCCARD, BUS_TYPE_PCI } bus_type;
        enum {
@@ -516,7 +516,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;
@@ -693,9 +693,9 @@ static void tx_done_irq(struct atmel_private *priv)
 
                if (type == TX_PACKET_TYPE_DATA) {
                        if (status == TX_STATUS_SUCCESS)
-                               priv->stats.tx_packets++;
+                               priv->dev->stats.tx_packets++;
                        else
-                               priv->stats.tx_errors++;
+                               priv->dev->stats.tx_errors++;
                        netif_wake_queue(priv->dev);
                }
        }
@@ -791,13 +791,13 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
 
        if (priv->card && priv->present_callback &&
            !(*priv->present_callback)(priv->card)) {
-               priv->stats.tx_errors++;
+               dev->stats.tx_errors++;
                dev_kfree_skb(skb);
                return 0;
        }
 
        if (priv->station_state != STATION_STATE_READY) {
-               priv->stats.tx_errors++;
+               dev->stats.tx_errors++;
                dev_kfree_skb(skb);
                return 0;
        }
@@ -814,7 +814,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
           initial + 18 (+30-12) */
 
        if (!(buff = find_tx_buff(priv, len + 18))) {
-               priv->stats.tx_dropped++;
+               dev->stats.tx_dropped++;
                spin_unlock_irqrestore(&priv->irqlock, flags);
                spin_unlock_bh(&priv->timerlock);
                netif_stop_queue(dev);
@@ -850,7 +850,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
        /* low bit of first byte of destination tells us if broadcast */
        tx_update_descriptor(priv, *(skb->data) & 0x01, len + 18, buff, TX_PACKET_TYPE_DATA);
        dev->trans_start = jiffies;
-       priv->stats.tx_bytes += len;
+       dev->stats.tx_bytes += len;
 
        spin_unlock_irqrestore(&priv->irqlock, flags);
        spin_unlock_bh(&priv->timerlock);
@@ -894,7 +894,7 @@ static void fast_rx_path(struct atmel_private *priv,
        }
 
        if (!(skb = dev_alloc_skb(msdu_size + 14))) {
-               priv->stats.rx_dropped++;
+               priv->dev->stats.rx_dropped++;
                return;
        }
 
@@ -907,7 +907,7 @@ static void fast_rx_path(struct atmel_private *priv,
                crc = crc32_le(crc, skbp + 12, msdu_size);
                atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + 30 + msdu_size, 4);
                if ((crc ^ 0xffffffff) != netcrc) {
-                       priv->stats.rx_crc_errors++;
+                       priv->dev->stats.rx_crc_errors++;
                        dev_kfree_skb(skb);
                        return;
                }
@@ -923,8 +923,8 @@ static void fast_rx_path(struct atmel_private *priv,
        skb->protocol = eth_type_trans(skb, priv->dev);
        skb->ip_summed = CHECKSUM_NONE;
        netif_rx(skb);
-       priv->stats.rx_bytes += 12 + msdu_size;
-       priv->stats.rx_packets++;
+       priv->dev->stats.rx_bytes += 12 + msdu_size;
+       priv->dev->stats.rx_packets++;
 }
 
 /* Test to see if the packet in card memory at packet_loc has a valid CRC
@@ -990,7 +990,7 @@ static void frag_rx_path(struct atmel_private *priv,
                        crc = crc32_le(crc, &priv->rx_buf[12], msdu_size);
                        atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4);
                        if ((crc ^ 0xffffffff) != netcrc) {
-                               priv->stats.rx_crc_errors++;
+                               priv->dev->stats.rx_crc_errors++;
                                memset(priv->frag_source, 0xff, 6);
                        }
                }
@@ -1008,7 +1008,7 @@ static void frag_rx_path(struct atmel_private *priv,
                                       msdu_size);
                        atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4);
                        if ((crc ^ 0xffffffff) != netcrc) {
-                               priv->stats.rx_crc_errors++;
+                               priv->dev->stats.rx_crc_errors++;
                                memset(priv->frag_source, 0xff, 6);
                                more_frags = 1; /* don't send broken assembly */
                        }
@@ -1020,7 +1020,7 @@ static void frag_rx_path(struct atmel_private *priv,
                if (!more_frags) { /* last one */
                        memset(priv->frag_source, 0xff, 6);
                        if (!(skb = dev_alloc_skb(priv->frag_len + 14))) {
-                               priv->stats.rx_dropped++;
+                               priv->dev->stats.rx_dropped++;
                        } else {
                                skb_reserve(skb, 2);
                                memcpy(skb_put(skb, priv->frag_len + 12),
@@ -1030,8 +1030,8 @@ static void frag_rx_path(struct atmel_private *priv,
                                skb->protocol = eth_type_trans(skb, priv->dev);
                                skb->ip_summed = CHECKSUM_NONE;
                                netif_rx(skb);
-                               priv->stats.rx_bytes += priv->frag_len + 12;
-                               priv->stats.rx_packets++;
+                               priv->dev->stats.rx_bytes += priv->frag_len + 12;
+                               priv->dev->stats.rx_packets++;
                        }
                }
        } else
@@ -1056,7 +1056,7 @@ static void rx_done_irq(struct atmel_private *priv)
                        if (status == 0xc1) /* determined by experiment */
                                priv->wstats.discard.nwid++;
                        else
-                               priv->stats.rx_errors++;
+                               priv->dev->stats.rx_errors++;
                        goto next;
                }
 
@@ -1064,7 +1064,7 @@ static void rx_done_irq(struct atmel_private *priv)
                rx_packet_loc = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_POS_OFFSET, priv->rx_desc_head));
 
                if (msdu_size < 30) {
-                       priv->stats.rx_errors++;
+                       priv->dev->stats.rx_errors++;
                        goto next;
                }
 
@@ -1122,7 +1122,7 @@ static void rx_done_irq(struct atmel_private *priv)
                                msdu_size -= 4;
                                crc = crc32_le(crc, (unsigned char *)&priv->rx_buf, msdu_size);
                                if ((crc ^ 0xffffffff) != (*((u32 *)&priv->rx_buf[msdu_size]))) {
-                                       priv->stats.rx_crc_errors++;
+                                       priv->dev->stats.rx_crc_errors++;
                                        goto next;
                                }
                        }
@@ -1249,12 +1249,6 @@ static irqreturn_t service_interrupt(int irq, void *dev_id)
        }
 }
 
-static struct net_device_stats *atmel_get_stats(struct net_device *dev)
-{
-       struct atmel_private *priv = netdev_priv(dev);
-       return &priv->stats;
-}
-
 static struct iw_statistics *atmel_get_wireless_stats(struct net_device *dev)
 {
        struct atmel_private *priv = netdev_priv(dev);
@@ -1484,6 +1478,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));
@@ -1516,8 +1511,6 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
                priv->crc_ok_cnt = priv->crc_ko_cnt = 0;
        } else
                priv->probe_crc = 0;
-       memset(&priv->stats, 0, sizeof(priv->stats));
-       memset(&priv->wstats, 0, sizeof(priv->wstats));
        priv->last_qual = jiffies;
        priv->last_beacon_timestamp = 0;
        memset(priv->frag_source, 0xff, sizeof(priv->frag_source));
@@ -1566,7 +1559,6 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
        dev->change_mtu = atmel_change_mtu;
        dev->set_mac_address = atmel_set_mac_address;
        dev->hard_start_xmit = start_tx;
-       dev->get_stats = atmel_get_stats;
        dev->wireless_handlers = (struct iw_handler_def *)&atmel_handler_def;
        dev->do_ioctl = atmel_ioctl;
        dev->irq = irq;
@@ -1598,12 +1590,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:
@@ -1761,9 +1750,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) {
@@ -2286,7 +2274,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;
 
@@ -2678,9 +2666,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];
@@ -2715,9 +2703,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;
@@ -2760,7 +2748,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;
@@ -2865,8 +2853,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;
@@ -3087,9 +3075,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];
@@ -3296,9 +3284,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 */