airo: use simple_read_from_buffer()
[safe/jmp/linux-2.6] / drivers / net / wireless / airo.c
index 8eac7fb..e30f8b7 100644 (file)
@@ -520,121 +520,124 @@ typedef struct {
 } SsidRid;
 
 typedef struct {
-        u16 len;
-        u16 modulation;
-#define MOD_DEFAULT 0
-#define MOD_CCK 1
-#define MOD_MOK 2
+        __le16 len;
+        __le16 modulation;
+#define MOD_DEFAULT cpu_to_le16(0)
+#define MOD_CCK cpu_to_le16(1)
+#define MOD_MOK cpu_to_le16(2)
 } ModulationRid;
 
 typedef struct {
-       u16 len; /* sizeof(ConfigRid) */
-       u16 opmode; /* operating mode */
-#define MODE_STA_IBSS 0
-#define MODE_STA_ESS 1
-#define MODE_AP 2
-#define MODE_AP_RPTR 3
-#define MODE_ETHERNET_HOST (0<<8) /* rx payloads converted */
-#define MODE_LLC_HOST (1<<8) /* rx payloads left as is */
-#define MODE_AIRONET_EXTEND (1<<9) /* enable Aironet extenstions */
-#define MODE_AP_INTERFACE (1<<10) /* enable ap interface extensions */
-#define MODE_ANTENNA_ALIGN (1<<11) /* enable antenna alignment */
-#define MODE_ETHER_LLC (1<<12) /* enable ethernet LLC */
-#define MODE_LEAF_NODE (1<<13) /* enable leaf node bridge */
-#define MODE_CF_POLLABLE (1<<14) /* enable CF pollable */
-#define MODE_MIC (1<<15) /* enable MIC */
-       u16 rmode; /* receive mode */
-#define RXMODE_BC_MC_ADDR 0
-#define RXMODE_BC_ADDR 1 /* ignore multicasts */
-#define RXMODE_ADDR 2 /* ignore multicast and broadcast */
-#define RXMODE_RFMON 3 /* wireless monitor mode */
-#define RXMODE_RFMON_ANYBSS 4
-#define RXMODE_LANMON 5 /* lan style monitor -- data packets only */
-#define RXMODE_DISABLE_802_3_HEADER (1<<8) /* disables 802.3 header on rx */
-#define RXMODE_NORMALIZED_RSSI (1<<9) /* return normalized RSSI */
-       u16 fragThresh;
-       u16 rtsThres;
+       __le16 len; /* sizeof(ConfigRid) */
+       __le16 opmode; /* operating mode */
+#define MODE_STA_IBSS cpu_to_le16(0)
+#define MODE_STA_ESS cpu_to_le16(1)
+#define MODE_AP cpu_to_le16(2)
+#define MODE_AP_RPTR cpu_to_le16(3)
+#define MODE_CFG_MASK cpu_to_le16(0xff)
+#define MODE_ETHERNET_HOST cpu_to_le16(0<<8) /* rx payloads converted */
+#define MODE_LLC_HOST cpu_to_le16(1<<8) /* rx payloads left as is */
+#define MODE_AIRONET_EXTEND cpu_to_le16(1<<9) /* enable Aironet extenstions */
+#define MODE_AP_INTERFACE cpu_to_le16(1<<10) /* enable ap interface extensions */
+#define MODE_ANTENNA_ALIGN cpu_to_le16(1<<11) /* enable antenna alignment */
+#define MODE_ETHER_LLC cpu_to_le16(1<<12) /* enable ethernet LLC */
+#define MODE_LEAF_NODE cpu_to_le16(1<<13) /* enable leaf node bridge */
+#define MODE_CF_POLLABLE cpu_to_le16(1<<14) /* enable CF pollable */
+#define MODE_MIC cpu_to_le16(1<<15) /* enable MIC */
+       __le16 rmode; /* receive mode */
+#define RXMODE_BC_MC_ADDR cpu_to_le16(0)
+#define RXMODE_BC_ADDR cpu_to_le16(1) /* ignore multicasts */
+#define RXMODE_ADDR cpu_to_le16(2) /* ignore multicast and broadcast */
+#define RXMODE_RFMON cpu_to_le16(3) /* wireless monitor mode */
+#define RXMODE_RFMON_ANYBSS cpu_to_le16(4)
+#define RXMODE_LANMON cpu_to_le16(5) /* lan style monitor -- data packets only */
+#define RXMODE_MASK cpu_to_le16(255)
+#define RXMODE_DISABLE_802_3_HEADER cpu_to_le16(1<<8) /* disables 802.3 header on rx */
+#define RXMODE_FULL_MASK (RXMODE_MASK | RXMODE_DISABLE_802_3_HEADER)
+#define RXMODE_NORMALIZED_RSSI cpu_to_le16(1<<9) /* return normalized RSSI */
+       __le16 fragThresh;
+       __le16 rtsThres;
        u8 macAddr[ETH_ALEN];
        u8 rates[8];
-       u16 shortRetryLimit;
-       u16 longRetryLimit;
-       u16 txLifetime; /* in kusec */
-       u16 rxLifetime; /* in kusec */
-       u16 stationary;
-       u16 ordering;
-       u16 u16deviceType; /* for overriding device type */
-       u16 cfpRate;
-       u16 cfpDuration;
-       u16 _reserved1[3];
+       __le16 shortRetryLimit;
+       __le16 longRetryLimit;
+       __le16 txLifetime; /* in kusec */
+       __le16 rxLifetime; /* in kusec */
+       __le16 stationary;
+       __le16 ordering;
+       __le16 u16deviceType; /* for overriding device type */
+       __le16 cfpRate;
+       __le16 cfpDuration;
+       __le16 _reserved1[3];
        /*---------- Scanning/Associating ----------*/
-       u16 scanMode;
-#define SCANMODE_ACTIVE 0
-#define SCANMODE_PASSIVE 1
-#define SCANMODE_AIROSCAN 2
-       u16 probeDelay; /* in kusec */
-       u16 probeEnergyTimeout; /* in kusec */
-        u16 probeResponseTimeout;
-       u16 beaconListenTimeout;
-       u16 joinNetTimeout;
-       u16 authTimeout;
-       u16 authType;
-#define AUTH_OPEN 0x1
-#define AUTH_ENCRYPT 0x101
-#define AUTH_SHAREDKEY 0x102
-#define AUTH_ALLOW_UNENCRYPTED 0x200
-       u16 associationTimeout;
-       u16 specifiedApTimeout;
-       u16 offlineScanInterval;
-       u16 offlineScanDuration;
-       u16 linkLossDelay;
-       u16 maxBeaconLostTime;
-       u16 refreshInterval;
-#define DISABLE_REFRESH 0xFFFF
-       u16 _reserved1a[1];
+       __le16 scanMode;
+#define SCANMODE_ACTIVE cpu_to_le16(0)
+#define SCANMODE_PASSIVE cpu_to_le16(1)
+#define SCANMODE_AIROSCAN cpu_to_le16(2)
+       __le16 probeDelay; /* in kusec */
+       __le16 probeEnergyTimeout; /* in kusec */
+        __le16 probeResponseTimeout;
+       __le16 beaconListenTimeout;
+       __le16 joinNetTimeout;
+       __le16 authTimeout;
+       __le16 authType;
+#define AUTH_OPEN cpu_to_le16(0x1)
+#define AUTH_ENCRYPT cpu_to_le16(0x101)
+#define AUTH_SHAREDKEY cpu_to_le16(0x102)
+#define AUTH_ALLOW_UNENCRYPTED cpu_to_le16(0x200)
+       __le16 associationTimeout;
+       __le16 specifiedApTimeout;
+       __le16 offlineScanInterval;
+       __le16 offlineScanDuration;
+       __le16 linkLossDelay;
+       __le16 maxBeaconLostTime;
+       __le16 refreshInterval;
+#define DISABLE_REFRESH cpu_to_le16(0xFFFF)
+       __le16 _reserved1a[1];
        /*---------- Power save operation ----------*/
-       u16 powerSaveMode;
-#define POWERSAVE_CAM 0
-#define POWERSAVE_PSP 1
-#define POWERSAVE_PSPCAM 2
-       u16 sleepForDtims;
-       u16 listenInterval;
-       u16 fastListenInterval;
-       u16 listenDecay;
-       u16 fastListenDelay;
-       u16 _reserved2[2];
+       __le16 powerSaveMode;
+#define POWERSAVE_CAM cpu_to_le16(0)
+#define POWERSAVE_PSP cpu_to_le16(1)
+#define POWERSAVE_PSPCAM cpu_to_le16(2)
+       __le16 sleepForDtims;
+       __le16 listenInterval;
+       __le16 fastListenInterval;
+       __le16 listenDecay;
+       __le16 fastListenDelay;
+       __le16 _reserved2[2];
        /*---------- Ap/Ibss config items ----------*/
-       u16 beaconPeriod;
-       u16 atimDuration;
-       u16 hopPeriod;
-       u16 channelSet;
-       u16 channel;
-       u16 dtimPeriod;
-       u16 bridgeDistance;
-       u16 radioID;
+       __le16 beaconPeriod;
+       __le16 atimDuration;
+       __le16 hopPeriod;
+       __le16 channelSet;
+       __le16 channel;
+       __le16 dtimPeriod;
+       __le16 bridgeDistance;
+       __le16 radioID;
        /*---------- Radio configuration ----------*/
-       u16 radioType;
-#define RADIOTYPE_DEFAULT 0
-#define RADIOTYPE_802_11 1
-#define RADIOTYPE_LEGACY 2
+       __le16 radioType;
+#define RADIOTYPE_DEFAULT cpu_to_le16(0)
+#define RADIOTYPE_802_11 cpu_to_le16(1)
+#define RADIOTYPE_LEGACY cpu_to_le16(2)
        u8 rxDiversity;
        u8 txDiversity;
-       u16 txPower;
+       __le16 txPower;
 #define TXPOWER_DEFAULT 0
-       u16 rssiThreshold;
+       __le16 rssiThreshold;
 #define RSSI_DEFAULT 0
-        u16 modulation;
-#define PREAMBLE_AUTO 0
-#define PREAMBLE_LONG 1
-#define PREAMBLE_SHORT 2
-       u16 preamble;
-       u16 homeProduct;
-       u16 radioSpecific;
+        __le16 modulation;
+#define PREAMBLE_AUTO cpu_to_le16(0)
+#define PREAMBLE_LONG cpu_to_le16(1)
+#define PREAMBLE_SHORT cpu_to_le16(2)
+       __le16 preamble;
+       __le16 homeProduct;
+       __le16 radioSpecific;
        /*---------- Aironet Extensions ----------*/
        u8 nodeName[16];
-       u16 arlThreshold;
-       u16 arlDecay;
-       u16 arlDelay;
-       u16 _reserved4[1];
+       __le16 arlThreshold;
+       __le16 arlDecay;
+       __le16 arlDelay;
+       __le16 _reserved4[1];
        /*---------- Aironet Extensions ----------*/
        u8 magicAction;
 #define MAGIC_ACTION_STSCHG 1
@@ -644,34 +647,34 @@ typedef struct {
 #define MAGIC_SWITCH_TO_PSP (0<<10)
 #define MAGIC_STAY_IN_CAM (1<<10)
        u8 magicControl;
-       u16 autoWake;
+       __le16 autoWake;
 } ConfigRid;
 
 typedef struct {
-       u16 len;
+       __le16 len;
        u8 mac[ETH_ALEN];
-       u16 mode;
-       u16 errorCode;
-       u16 sigQuality;
-       u16 SSIDlen;
+       __le16 mode;
+       __le16 errorCode;
+       __le16 sigQuality;
+       __le16 SSIDlen;
        char SSID[32];
        char apName[16];
        u8 bssid[4][ETH_ALEN];
-       u16 beaconPeriod;
-       u16 dimPeriod;
-       u16 atimDuration;
-       u16 hopPeriod;
-       u16 channelSet;
-       u16 channel;
-       u16 hopsToBackbone;
-       u16 apTotalLoad;
-       u16 generatedLoad;
-       u16 accumulatedArl;
-       u16 signalQuality;
-       u16 currentXmitRate;
-       u16 apDevExtensions;
-       u16 normalizedSignalStrength;
-       u16 shortPreamble;
+       __le16 beaconPeriod;
+       __le16 dimPeriod;
+       __le16 atimDuration;
+       __le16 hopPeriod;
+       __le16 channelSet;
+       __le16 channel;
+       __le16 hopsToBackbone;
+       __le16 apTotalLoad;
+       __le16 generatedLoad;
+       __le16 accumulatedArl;
+       __le16 signalQuality;
+       __le16 currentXmitRate;
+       __le16 apDevExtensions;
+       __le16 normalizedSignalStrength;
+       __le16 shortPreamble;
        u8 apIP[4];
        u8 noisePercent; /* Noise percent in last second */
        u8 noisedBm; /* Noise dBm in last second */
@@ -679,9 +682,9 @@ typedef struct {
        u8 noiseAvedBm; /* Noise dBm in last minute */
        u8 noiseMaxPercent; /* Highest noise percent in last minute */
        u8 noiseMaxdBm; /* Highest noise dbm in last minute */
-       u16 load;
+       __le16 load;
        u8 carrier[4];
-       u16 assocStatus;
+       __le16 assocStatus;
 #define STAT_NOPACKETS 0
 #define STAT_NOCARRIERSET 10
 #define STAT_GOTCARRIERSET 11
@@ -706,44 +709,44 @@ typedef struct {
 } StatusRid;
 
 typedef struct {
-       u16 len;
-       u16 spacer;
-       u32 vals[100];
+       __le16 len;
+       __le16 spacer;
+       __le32 vals[100];
 } StatsRid;
 
 
 typedef struct {
-       u16 len;
+       __le16 len;
        u8 ap[4][ETH_ALEN];
 } APListRid;
 
 typedef struct {
-       u16 len;
+       __le16 len;
        char oui[3];
        char zero;
-       u16 prodNum;
+       __le16 prodNum;
        char manName[32];
        char prodName[16];
        char prodVer[8];
        char factoryAddr[ETH_ALEN];
        char aironetAddr[ETH_ALEN];
-       u16 radioType;
-       u16 country;
+       __le16 radioType;
+       __le16 country;
        char callid[ETH_ALEN];
        char supportedRates[8];
        char rxDiversity;
        char txDiversity;
-       u16 txPowerLevels[8];
-       u16 hardVer;
-       u16 hardCap;
-       u16 tempRange;
-       u16 softVer;
-       u16 softSubVer;
-       u16 interfaceVer;
-       u16 softCap;
-       u16 bootBlockVer;
-       u16 requiredHard;
-       u16 extSoftCap;
+       __le16 txPowerLevels[8];
+       __le16 hardVer;
+       __le16 hardCap;
+       __le16 tempRange;
+       __le16 softVer;
+       __le16 softSubVer;
+       __le16 interfaceVer;
+       __le16 softCap;
+       __le16 bootBlockVer;
+       __le16 requiredHard;
+       __le16 extSoftCap;
 } CapabilityRid;
 
 
@@ -1145,7 +1148,6 @@ static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm);
 static void airo_networks_free(struct airo_info *ai);
 
 struct airo_info {
-       struct net_device_stats stats;
        struct net_device             *dev;
        struct list_head              dev_list;
        /* Note, we can have MAX_FIDS outstanding.  FIDs are 16-bits, so we
@@ -1780,9 +1782,9 @@ static int writeSsidRid(struct airo_info*ai, SsidRid *pssidr, int lock)
        return PC4500_writerid(ai, RID_SSID, pssidr, sizeof(*pssidr), lock);
 }
 
-static int readConfigRid(struct airo_info*ai, int lock) {
+static int readConfigRid(struct airo_info *ai, int lock)
+{
        int rc;
-       u16 *s;
        ConfigRid cfg;
 
        if (ai->config.len)
@@ -1792,24 +1794,12 @@ static int readConfigRid(struct airo_info*ai, int lock) {
        if (rc != SUCCESS)
                return rc;
 
-       for(s = &cfg.len; s <= &cfg.rtsThres; s++) *s = le16_to_cpu(*s);
-
-       for(s = &cfg.shortRetryLimit; s <= &cfg.radioType; s++)
-               *s = le16_to_cpu(*s);
-
-       for(s = &cfg.txPower; s <= &cfg.radioSpecific; s++)
-               *s = le16_to_cpu(*s);
-
-       for(s = &cfg.arlThreshold; s <= &cfg._reserved4[0]; s++)
-               *s = cpu_to_le16(*s);
-
-       for(s = &cfg.autoWake; s <= &cfg.autoWake; s++)
-               *s = cpu_to_le16(*s);
-
        ai->config = cfg;
        return SUCCESS;
 }
-static inline void checkThrottle(struct airo_info *ai) {
+
+static inline void checkThrottle(struct airo_info *ai)
+{
        int i;
 /* Old hardware had a limit on encryption speed */
        if (ai->config.authType != AUTH_OPEN && maxencrypt) {
@@ -1820,8 +1810,9 @@ static inline void checkThrottle(struct airo_info *ai) {
                }
        }
 }
-static int writeConfigRid(struct airo_info*ai, int lock) {
-       u16 *s;
+
+static int writeConfigRid(struct airo_info *ai, int lock)
+{
        ConfigRid cfgr;
 
        if (!test_bit (FLAG_COMMIT, &ai->flags))
@@ -1832,70 +1823,37 @@ static int writeConfigRid(struct airo_info*ai, int lock) {
        checkThrottle(ai);
        cfgr = ai->config;
 
-       if ((cfgr.opmode & 0xFF) == MODE_STA_IBSS)
+       if ((cfgr.opmode & MODE_CFG_MASK) == MODE_STA_IBSS)
                set_bit(FLAG_ADHOC, &ai->flags);
        else
                clear_bit(FLAG_ADHOC, &ai->flags);
 
-       for(s = &cfgr.len; s <= &cfgr.rtsThres; s++) *s = cpu_to_le16(*s);
-
-       for(s = &cfgr.shortRetryLimit; s <= &cfgr.radioType; s++)
-               *s = cpu_to_le16(*s);
-
-       for(s = &cfgr.txPower; s <= &cfgr.radioSpecific; s++)
-               *s = cpu_to_le16(*s);
-
-       for(s = &cfgr.arlThreshold; s <= &cfgr._reserved4[0]; s++)
-               *s = cpu_to_le16(*s);
-
-       for(s = &cfgr.autoWake; s <= &cfgr.autoWake; s++)
-               *s = cpu_to_le16(*s);
-
        return PC4500_writerid( ai, RID_CONFIG, &cfgr, sizeof(cfgr), lock);
 }
-static int readStatusRid(struct airo_info*ai, StatusRid *statr, int lock) {
-       int rc = PC4500_readrid(ai, RID_STATUS, statr, sizeof(*statr), lock);
-       u16 *s;
 
-       statr->len = le16_to_cpu(statr->len);
-       for(s = &statr->mode; s <= &statr->SSIDlen; s++) *s = le16_to_cpu(*s);
-
-       for(s = &statr->beaconPeriod; s <= &statr->shortPreamble; s++)
-               *s = le16_to_cpu(*s);
-       statr->load = le16_to_cpu(statr->load);
-       statr->assocStatus = le16_to_cpu(statr->assocStatus);
-       return rc;
+static int readStatusRid(struct airo_info *ai, StatusRid *statr, int lock)
+{
+       return PC4500_readrid(ai, RID_STATUS, statr, sizeof(*statr), lock);
 }
-static int readAPListRid(struct airo_info*ai, APListRid *aplr) {
-       int rc =  PC4500_readrid(ai, RID_APLIST, aplr, sizeof(*aplr), 1);
-       aplr->len = le16_to_cpu(aplr->len);
-       return rc;
+
+static int readAPListRid(struct airo_info *ai, APListRid *aplr)
+{
+       return PC4500_readrid(ai, RID_APLIST, aplr, sizeof(*aplr), 1);
 }
-static int writeAPListRid(struct airo_info*ai, APListRid *aplr, int lock) {
-       int rc;
-       aplr->len = cpu_to_le16(aplr->len);
-       rc = PC4500_writerid(ai, RID_APLIST, aplr, sizeof(*aplr), lock);
-       return rc;
+
+static int writeAPListRid(struct airo_info *ai, APListRid *aplr, int lock)
+{
+       return PC4500_writerid(ai, RID_APLIST, aplr, sizeof(*aplr), lock);
 }
-static int readCapabilityRid(struct airo_info*ai, CapabilityRid *capr, int lock) {
-       int rc = PC4500_readrid(ai, RID_CAPABILITIES, capr, sizeof(*capr), lock);
-       u16 *s;
 
-       capr->len = le16_to_cpu(capr->len);
-       capr->prodNum = le16_to_cpu(capr->prodNum);
-       capr->radioType = le16_to_cpu(capr->radioType);
-       capr->country = le16_to_cpu(capr->country);
-       for(s = &capr->txPowerLevels[0]; s <= &capr->requiredHard; s++)
-               *s = le16_to_cpu(*s);
-       return rc;
+static int readCapabilityRid(struct airo_info *ai, CapabilityRid *capr, int lock)
+{
+       return PC4500_readrid(ai, RID_CAPABILITIES, capr, sizeof(*capr), lock);
 }
-static int readStatsRid(struct airo_info*ai, StatsRid *sr, int rid, int lock) {
-       int rc = PC4500_readrid(ai, rid, sr, sizeof(*sr), lock);
-       u32 *i;
 
-       sr->len = le16_to_cpu(sr->len);
-       for(i = &sr->vals[0]; i <= &sr->vals[99]; i++) *i = le32_to_cpu(*i);
-       return rc;
+static int readStatsRid(struct airo_info*ai, StatsRid *sr, int rid, int lock)
+{
+       return PC4500_readrid(ai, rid, sr, sizeof(*sr), lock);
 }
 
 static void try_auto_wep(struct airo_info *ai)
@@ -1965,7 +1923,7 @@ static int mpi_start_xmit(struct sk_buff *skb, struct net_device *dev) {
        if (npacks >= MAXTXQ - 1) {
                netif_stop_queue (dev);
                if (npacks > MAXTXQ) {
-                       ai->stats.tx_fifo_errors++;
+                       dev->stats.tx_fifo_errors++;
                        return 1;
                }
                skb_queue_tail (&ai->txq, skb);
@@ -2085,13 +2043,13 @@ static void get_tx_error(struct airo_info *ai, s32 fid)
                bap_read(ai, &status, 2, BAP0);
        }
        if (le16_to_cpu(status) & 2) /* Too many retries */
-               ai->stats.tx_aborted_errors++;
+               ai->dev->stats.tx_aborted_errors++;
        if (le16_to_cpu(status) & 4) /* Transmit lifetime exceeded */
-               ai->stats.tx_heartbeat_errors++;
+               ai->dev->stats.tx_heartbeat_errors++;
        if (le16_to_cpu(status) & 8) /* Aid fail */
                { }
        if (le16_to_cpu(status) & 0x10) /* MAC disabled */
-               ai->stats.tx_carrier_errors++;
+               ai->dev->stats.tx_carrier_errors++;
        if (le16_to_cpu(status) & 0x20) /* Association lost */
                { }
        /* We produce a TXDROP event only for retry or lifetime
@@ -2143,7 +2101,7 @@ static void airo_end_xmit(struct net_device *dev) {
                for (; i < MAX_FIDS / 2 && (priv->fids[i] & 0xffff0000); i++);
        } else {
                priv->fids[fid] &= 0xffff;
-               priv->stats.tx_window_errors++;
+               dev->stats.tx_window_errors++;
        }
        if (i < MAX_FIDS / 2)
                netif_wake_queue(dev);
@@ -2169,7 +2127,7 @@ static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) {
                netif_stop_queue(dev);
 
                if (i == MAX_FIDS / 2) {
-                       priv->stats.tx_fifo_errors++;
+                       dev->stats.tx_fifo_errors++;
                        return 1;
                }
        }
@@ -2208,7 +2166,7 @@ static void airo_end_xmit11(struct net_device *dev) {
                for (; i < MAX_FIDS && (priv->fids[i] & 0xffff0000); i++);
        } else {
                priv->fids[fid] &= 0xffff;
-               priv->stats.tx_window_errors++;
+               dev->stats.tx_window_errors++;
        }
        if (i < MAX_FIDS)
                netif_wake_queue(dev);
@@ -2240,7 +2198,7 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) {
                netif_stop_queue(dev);
 
                if (i == MAX_FIDS) {
-                       priv->stats.tx_fifo_errors++;
+                       dev->stats.tx_fifo_errors++;
                        return 1;
                }
        }
@@ -2260,9 +2218,11 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) {
        return 0;
 }
 
-static void airo_read_stats(struct airo_info *ai) {
+static void airo_read_stats(struct net_device *dev)
+{
+       struct airo_info *ai = dev->priv;
        StatsRid stats_rid;
-       u32 *vals = stats_rid.vals;
+       __le32 *vals = stats_rid.vals;
 
        clear_bit(JOB_STATS, &ai->jobs);
        if (ai->power.event) {
@@ -2272,20 +2232,24 @@ static void airo_read_stats(struct airo_info *ai) {
        readStatsRid(ai, &stats_rid, RID_STATS, 0);
        up(&ai->sem);
 
-       ai->stats.rx_packets = vals[43] + vals[44] + vals[45];
-       ai->stats.tx_packets = vals[39] + vals[40] + vals[41];
-       ai->stats.rx_bytes = vals[92];
-       ai->stats.tx_bytes = vals[91];
-       ai->stats.rx_errors = vals[0] + vals[2] + vals[3] + vals[4];
-       ai->stats.tx_errors = vals[42] + ai->stats.tx_fifo_errors;
-       ai->stats.multicast = vals[43];
-       ai->stats.collisions = vals[89];
+       dev->stats.rx_packets = le32_to_cpu(vals[43]) + le32_to_cpu(vals[44]) +
+                              le32_to_cpu(vals[45]);
+       dev->stats.tx_packets = le32_to_cpu(vals[39]) + le32_to_cpu(vals[40]) +
+                              le32_to_cpu(vals[41]);
+       dev->stats.rx_bytes = le32_to_cpu(vals[92]);
+       dev->stats.tx_bytes = le32_to_cpu(vals[91]);
+       dev->stats.rx_errors = le32_to_cpu(vals[0]) + le32_to_cpu(vals[2]) +
+                             le32_to_cpu(vals[3]) + le32_to_cpu(vals[4]);
+       dev->stats.tx_errors = le32_to_cpu(vals[42]) +
+                             dev->stats.tx_fifo_errors;
+       dev->stats.multicast = le32_to_cpu(vals[43]);
+       dev->stats.collisions = le32_to_cpu(vals[89]);
 
        /* detailed rx_errors: */
-       ai->stats.rx_length_errors = vals[3];
-       ai->stats.rx_crc_errors = vals[4];
-       ai->stats.rx_frame_errors = vals[2];
-       ai->stats.rx_fifo_errors = vals[0];
+       dev->stats.rx_length_errors = le32_to_cpu(vals[3]);
+       dev->stats.rx_crc_errors = le32_to_cpu(vals[4]);
+       dev->stats.rx_frame_errors = le32_to_cpu(vals[2]);
+       dev->stats.rx_fifo_errors = le32_to_cpu(vals[0]);
 }
 
 static struct net_device_stats *airo_get_stats(struct net_device *dev)
@@ -2298,10 +2262,10 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev)
                        set_bit(JOB_STATS, &local->jobs);
                        wake_up_interruptible(&local->thr_wait);
                } else
-                       airo_read_stats(local);
+                       airo_read_stats(dev);
        }
 
-       return &local->stats;
+       return &dev->stats;
 }
 
 static void airo_set_promisc(struct airo_info *ai) {
@@ -2705,6 +2669,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
        dev->irq = ethdev->irq;
        dev->base_addr = ethdev->base_addr;
        dev->wireless_data = ethdev->wireless_data;
+       SET_NETDEV_DEV(dev, ethdev->dev.parent);
        memcpy(dev->dev_addr, ethdev->dev_addr, dev->addr_len);
        err = register_netdev(dev);
        if (err<0) {
@@ -2772,8 +2737,9 @@ static int airo_test_wpa_capable(struct airo_info *ai)
        if (status != SUCCESS) return 0;
 
        /* Only firmware versions 5.30.17 or better can do WPA */
-       if ((cap_rid.softVer > 0x530)
-         || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 17))) {
+       if (le16_to_cpu(cap_rid.softVer) > 0x530
+         || (le16_to_cpu(cap_rid.softVer) == 0x530
+             && le16_to_cpu(cap_rid.softSubVer) >= 17)) {
                airo_print_info("", "WPA is supported.");
                return 1;
        }
@@ -2940,7 +2906,7 @@ EXPORT_SYMBOL(init_airo_card);
 
 static int waitbusy (struct airo_info *ai) {
        int delay = 0;
-       while ((IN4500 (ai, COMMAND) & COMMAND_BUSY) & (delay < 10000)) {
+       while ((IN4500(ai, COMMAND) & COMMAND_BUSY) && (delay < 10000)) {
                udelay (10);
                if ((++delay % 20) == 0)
                        OUT4500(ai, EVACK, EV_CLEARCOMMANDBUSY);
@@ -3128,7 +3094,7 @@ static int airo_thread(void *data) {
                else if (test_bit(JOB_XMIT11, &ai->jobs))
                        airo_end_xmit11(dev);
                else if (test_bit(JOB_STATS, &ai->jobs))
-                       airo_read_stats(ai);
+                       airo_read_stats(dev);
                else if (test_bit(JOB_WSTATS, &ai->jobs))
                        airo_read_wireless_stats(ai);
                else if (test_bit(JOB_PROMISC, &ai->jobs))
@@ -3324,7 +3290,7 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
 
                        skb = dev_alloc_skb( len + hdrlen + 2 + 2 );
                        if ( !skb ) {
-                               apriv->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                goto badrx;
                        }
                        skb_reserve(skb, 2); /* This way the IP header is aligned */
@@ -3592,7 +3558,7 @@ static void mpi_receive_802_3(struct airo_info *ai)
 
                skb = dev_alloc_skb(len);
                if (!skb) {
-                       ai->stats.rx_dropped++;
+                       ai->dev->stats.rx_dropped++;
                        goto badrx;
                }
                buffer = skb_put(skb,len);
@@ -3685,7 +3651,7 @@ void mpi_receive_802_11 (struct airo_info *ai)
 
        skb = dev_alloc_skb( len + hdrlen + 2 );
        if ( !skb ) {
-               ai->stats.rx_dropped++;
+               ai->dev->stats.rx_dropped++;
                goto badrx;
        }
        buffer = (u16*)skb_put (skb, len + hdrlen);
@@ -3693,7 +3659,7 @@ void mpi_receive_802_11 (struct airo_info *ai)
        ptr += hdrlen;
        if (hdrlen == 24)
                ptr += 6;
-       gap = le16_to_cpu(get_unaligned((__le16 *)ptr));
+       gap = get_unaligned_le16(ptr);
        ptr += sizeof(__le16);
        if (gap) {
                if (gap <= 8)
@@ -3808,7 +3774,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
                else {
                        kfree(ai->rssi);
                        ai->rssi = NULL;
-                       if (cap_rid.softCap & 8)
+                       if (cap_rid.softCap & cpu_to_le16(8))
                                ai->config.rmode |= RXMODE_NORMALIZED_RSSI;
                        else
                                airo_print_warn(ai->dev->name, "unknown received signal "
@@ -3818,9 +3784,9 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
                ai->config.authType = AUTH_OPEN;
                ai->config.modulation = MOD_CCK;
 
-               if ((cap_rid.len>=sizeof(cap_rid)) &&
+               if (le16_to_cpu(cap_rid.len) >= sizeof(cap_rid) &&
                    (cap_rid.extSoftCap & cpu_to_le16(1)) &&
-                   (micsetup(ai) == SUCCESS)) {
+                   micsetup(ai) == SUCCESS) {
                        ai->config.opmode |= MODE_MIC;
                        set_bit(FLAG_MIC_CAPABLE, &ai->flags);
                }
@@ -4383,24 +4349,28 @@ static int proc_config_open( struct inode *inode, struct file *file );
 static int proc_wepkey_open( struct inode *inode, struct file *file );
 
 static const struct file_operations proc_statsdelta_ops = {
+       .owner          = THIS_MODULE,
        .read           = proc_read,
        .open           = proc_statsdelta_open,
        .release        = proc_close
 };
 
 static const struct file_operations proc_stats_ops = {
+       .owner          = THIS_MODULE,
        .read           = proc_read,
        .open           = proc_stats_open,
        .release        = proc_close
 };
 
 static const struct file_operations proc_status_ops = {
+       .owner          = THIS_MODULE,
        .read           = proc_read,
        .open           = proc_status_open,
        .release        = proc_close
 };
 
 static const struct file_operations proc_SSID_ops = {
+       .owner          = THIS_MODULE,
        .read           = proc_read,
        .write          = proc_write,
        .open           = proc_SSID_open,
@@ -4408,6 +4378,7 @@ static const struct file_operations proc_SSID_ops = {
 };
 
 static const struct file_operations proc_BSSList_ops = {
+       .owner          = THIS_MODULE,
        .read           = proc_read,
        .write          = proc_write,
        .open           = proc_BSSList_open,
@@ -4415,6 +4386,7 @@ static const struct file_operations proc_BSSList_ops = {
 };
 
 static const struct file_operations proc_APList_ops = {
+       .owner          = THIS_MODULE,
        .read           = proc_read,
        .write          = proc_write,
        .open           = proc_APList_open,
@@ -4422,6 +4394,7 @@ static const struct file_operations proc_APList_ops = {
 };
 
 static const struct file_operations proc_config_ops = {
+       .owner          = THIS_MODULE,
        .read           = proc_read,
        .write          = proc_write,
        .open           = proc_config_open,
@@ -4429,6 +4402,7 @@ static const struct file_operations proc_config_ops = {
 };
 
 static const struct file_operations proc_wepkey_ops = {
+       .owner          = THIS_MODULE,
        .read           = proc_read,
        .write          = proc_write,
        .open           = proc_wepkey_open,
@@ -4447,10 +4421,6 @@ struct proc_data {
        void (*on_close) (struct inode *, struct file *);
 };
 
-#ifndef SETPROC_OPS
-#define SETPROC_OPS(entry, ops) (entry)->proc_fops = &(ops)
-#endif
-
 static int setup_proc_entry( struct net_device *dev,
                             struct airo_info *apriv ) {
        struct proc_dir_entry *entry;
@@ -4466,100 +4436,76 @@ static int setup_proc_entry( struct net_device *dev,
        apriv->proc_entry->owner = THIS_MODULE;
 
        /* Setup the StatsDelta */
-       entry = create_proc_entry("StatsDelta",
-                                 S_IFREG | (S_IRUGO&proc_perm),
-                                 apriv->proc_entry);
+       entry = proc_create_data("StatsDelta",
+                                S_IFREG | (S_IRUGO&proc_perm),
+                                apriv->proc_entry, &proc_statsdelta_ops, dev);
        if (!entry)
                goto fail_stats_delta;
        entry->uid = proc_uid;
        entry->gid = proc_gid;
-       entry->data = dev;
-       entry->owner = THIS_MODULE;
-       SETPROC_OPS(entry, proc_statsdelta_ops);
 
        /* Setup the Stats */
-       entry = create_proc_entry("Stats",
-                                 S_IFREG | (S_IRUGO&proc_perm),
-                                 apriv->proc_entry);
+       entry = proc_create_data("Stats",
+                                S_IFREG | (S_IRUGO&proc_perm),
+                                apriv->proc_entry, &proc_stats_ops, dev);
        if (!entry)
                goto fail_stats;
        entry->uid = proc_uid;
        entry->gid = proc_gid;
-       entry->data = dev;
-       entry->owner = THIS_MODULE;
-       SETPROC_OPS(entry, proc_stats_ops);
 
        /* Setup the Status */
-       entry = create_proc_entry("Status",
-                                 S_IFREG | (S_IRUGO&proc_perm),
-                                 apriv->proc_entry);
+       entry = proc_create_data("Status",
+                                S_IFREG | (S_IRUGO&proc_perm),
+                                apriv->proc_entry, &proc_status_ops, dev);
        if (!entry)
                goto fail_status;
        entry->uid = proc_uid;
        entry->gid = proc_gid;
-       entry->data = dev;
-       entry->owner = THIS_MODULE;
-       SETPROC_OPS(entry, proc_status_ops);
 
        /* Setup the Config */
-       entry = create_proc_entry("Config",
-                                 S_IFREG | proc_perm,
-                                 apriv->proc_entry);
+       entry = proc_create_data("Config",
+                                S_IFREG | proc_perm,
+                                apriv->proc_entry, &proc_config_ops, dev);
        if (!entry)
                goto fail_config;
        entry->uid = proc_uid;
        entry->gid = proc_gid;
-       entry->data = dev;
-       entry->owner = THIS_MODULE;
-       SETPROC_OPS(entry, proc_config_ops);
 
        /* Setup the SSID */
-       entry = create_proc_entry("SSID",
-                                 S_IFREG | proc_perm,
-                                 apriv->proc_entry);
+       entry = proc_create_data("SSID",
+                                S_IFREG | proc_perm,
+                                apriv->proc_entry, &proc_SSID_ops, dev);
        if (!entry)
                goto fail_ssid;
        entry->uid = proc_uid;
        entry->gid = proc_gid;
-       entry->data = dev;
-       entry->owner = THIS_MODULE;
-       SETPROC_OPS(entry, proc_SSID_ops);
 
        /* Setup the APList */
-       entry = create_proc_entry("APList",
-                                 S_IFREG | proc_perm,
-                                 apriv->proc_entry);
+       entry = proc_create_data("APList",
+                                S_IFREG | proc_perm,
+                                apriv->proc_entry, &proc_APList_ops, dev);
        if (!entry)
                goto fail_aplist;
        entry->uid = proc_uid;
        entry->gid = proc_gid;
-       entry->data = dev;
-       entry->owner = THIS_MODULE;
-       SETPROC_OPS(entry, proc_APList_ops);
 
        /* Setup the BSSList */
-       entry = create_proc_entry("BSSList",
-                                 S_IFREG | proc_perm,
-                                 apriv->proc_entry);
+       entry = proc_create_data("BSSList",
+                                S_IFREG | proc_perm,
+                                apriv->proc_entry, &proc_BSSList_ops, dev);
        if (!entry)
                goto fail_bsslist;
        entry->uid = proc_uid;
        entry->gid = proc_gid;
-       entry->data = dev;
-       entry->owner = THIS_MODULE;
-       SETPROC_OPS(entry, proc_BSSList_ops);
 
        /* Setup the WepKey */
-       entry = create_proc_entry("WepKey",
-                                 S_IFREG | proc_perm,
-                                 apriv->proc_entry);
+       entry = proc_create_data("WepKey",
+                                S_IFREG | proc_perm,
+                                apriv->proc_entry, &proc_wepkey_ops, dev);
        if (!entry)
                goto fail_wepkey;
        entry->uid = proc_uid;
        entry->gid = proc_gid;
-       entry->data = dev;
-       entry->owner = THIS_MODULE;
-       SETPROC_OPS(entry, proc_wepkey_ops);
 
        return 0;
 
@@ -4615,22 +4561,13 @@ static ssize_t proc_read( struct file *file,
                          size_t len,
                          loff_t *offset )
 {
-       loff_t pos = *offset;
-       struct proc_data *priv = (struct proc_data*)file->private_data;
+       struct proc_data *priv = file->private_data;
 
        if (!priv->rbuffer)
                return -EINVAL;
 
-       if (pos < 0)
-               return -EINVAL;
-       if (pos >= priv->readlen)
-               return 0;
-       if (len > priv->readlen - pos)
-               len = priv->readlen - pos;
-       if (copy_to_user(buffer, priv->rbuffer + pos, len))
-               return -EFAULT;
-       *offset = pos + len;
-       return len;
+       return simple_read_from_buffer(buffer, len, offset, priv->rbuffer,
+                                       priv->readlen);
 }
 
 /*
@@ -4662,13 +4599,15 @@ static ssize_t proc_write( struct file *file,
        return len;
 }
 
-static int proc_status_open( struct inode *inode, struct file *file ) {
+static int proc_status_open(struct inode *inode, struct file *file)
+{
        struct proc_data *data;
        struct proc_dir_entry *dp = PDE(inode);
        struct net_device *dev = dp->data;
        struct airo_info *apriv = dev->priv;
        CapabilityRid cap_rid;
        StatusRid status_rid;
+       u16 mode;
        int i;
 
        if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
@@ -4682,16 +4621,18 @@ static int proc_status_open( struct inode *inode, struct file *file ) {
        readStatusRid(apriv, &status_rid, 1);
        readCapabilityRid(apriv, &cap_rid, 1);
 
+       mode = le16_to_cpu(status_rid.mode);
+
         i = sprintf(data->rbuffer, "Status: %s%s%s%s%s%s%s%s%s\n",
-                    status_rid.mode & 1 ? "CFG ": "",
-                    status_rid.mode & 2 ? "ACT ": "",
-                    status_rid.mode & 0x10 ? "SYN ": "",
-                    status_rid.mode & 0x20 ? "LNK ": "",
-                    status_rid.mode & 0x40 ? "LEAP ": "",
-                    status_rid.mode & 0x80 ? "PRIV ": "",
-                    status_rid.mode & 0x100 ? "KEY ": "",
-                    status_rid.mode & 0x200 ? "WEP ": "",
-                    status_rid.mode & 0x8000 ? "ERR ": "");
+                    mode & 1 ? "CFG ": "",
+                    mode & 2 ? "ACT ": "",
+                    mode & 0x10 ? "SYN ": "",
+                    mode & 0x20 ? "LNK ": "",
+                    mode & 0x40 ? "LEAP ": "",
+                    mode & 0x80 ? "PRIV ": "",
+                    mode & 0x100 ? "KEY ": "",
+                    mode & 0x200 ? "WEP ": "",
+                    mode & 0x8000 ? "ERR ": "");
        sprintf( data->rbuffer+i, "Mode: %x\n"
                 "Signal Strength: %d\n"
                 "Signal Quality: %d\n"
@@ -4704,24 +4645,24 @@ static int proc_status_open( struct inode *inode, struct file *file ) {
                 "Radio type: %x\nCountry: %x\nHardware Version: %x\n"
                 "Software Version: %x\nSoftware Subversion: %x\n"
                 "Boot block version: %x\n",
-                (int)status_rid.mode,
-                (int)status_rid.normalizedSignalStrength,
-                (int)status_rid.signalQuality,
-                (int)status_rid.SSIDlen,
+                le16_to_cpu(status_rid.mode),
+                le16_to_cpu(status_rid.normalizedSignalStrength),
+                le16_to_cpu(status_rid.signalQuality),
+                le16_to_cpu(status_rid.SSIDlen),
                 status_rid.SSID,
                 status_rid.apName,
-                (int)status_rid.channel,
-                (int)status_rid.currentXmitRate/2,
+                le16_to_cpu(status_rid.channel),
+                le16_to_cpu(status_rid.currentXmitRate) / 2,
                 version,
                 cap_rid.prodName,
                 cap_rid.manName,
                 cap_rid.prodVer,
-                cap_rid.radioType,
-                cap_rid.country,
-                cap_rid.hardVer,
-                (int)cap_rid.softVer,
-                (int)cap_rid.softSubVer,
-                (int)cap_rid.bootBlockVer );
+                le16_to_cpu(cap_rid.radioType),
+                le16_to_cpu(cap_rid.country),
+                le16_to_cpu(cap_rid.hardVer),
+                le16_to_cpu(cap_rid.softVer),
+                le16_to_cpu(cap_rid.softSubVer),
+                le16_to_cpu(cap_rid.bootBlockVer));
        data->readlen = strlen( data->rbuffer );
        return 0;
 }
@@ -4741,14 +4682,16 @@ static int proc_stats_open( struct inode *inode, struct file *file ) {
 
 static int proc_stats_rid_open( struct inode *inode,
                                struct file *file,
-                               u16 rid ) {
+                               u16 rid )
+{
        struct proc_data *data;
        struct proc_dir_entry *dp = PDE(inode);
        struct net_device *dev = dp->data;
        struct airo_info *apriv = dev->priv;
        StatsRid stats;
        int i, j;
-       u32 *vals = stats.vals;
+       __le32 *vals = stats.vals;
+       int len = le16_to_cpu(stats.len);
 
        if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
                return -ENOMEM;
@@ -4761,17 +4704,17 @@ static int proc_stats_rid_open( struct inode *inode,
        readStatsRid(apriv, &stats, rid, 1);
 
         j = 0;
-       for(i=0; statsLabels[i]!=(char *)-1 &&
-                   i*4<stats.len; i++){
+       for(i=0; statsLabels[i]!=(char *)-1 && i*4<len; i++) {
                if (!statsLabels[i]) continue;
                if (j+strlen(statsLabels[i])+16>4096) {
                        airo_print_warn(apriv->dev->name,
                               "Potentially disasterous buffer overflow averted!");
                        break;
                }
-               j+=sprintf(data->rbuffer+j, "%s: %u\n", statsLabels[i], vals[i]);
+               j+=sprintf(data->rbuffer+j, "%s: %u\n", statsLabels[i],
+                               le32_to_cpu(vals[i]));
        }
-       if (i*4>=stats.len){
+       if (i*4 >= len) {
                airo_print_warn(apriv->dev->name, "Got a short rid");
        }
        data->readlen = j;
@@ -4796,7 +4739,14 @@ static int airo_config_commit(struct net_device *dev,
                              struct iw_request_info *info, void *zwrq,
                              char *extra);
 
-static void proc_config_on_close( struct inode *inode, struct file *file ) {
+static inline int sniffing_mode(struct airo_info *ai)
+{
+       return le16_to_cpu(ai->config.rmode & RXMODE_MASK) >=
+               le16_to_cpu(RXMODE_RFMON);
+}
+
+static void proc_config_on_close(struct inode *inode, struct file *file)
+{
        struct proc_data *data = file->private_data;
        struct proc_dir_entry *dp = PDE(inode);
        struct net_device *dev = dp->data;
@@ -4813,16 +4763,16 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
 /*** Mode processing */
                if ( !strncmp( line, "Mode: ", 6 ) ) {
                        line += 6;
-                       if ((ai->config.rmode & 0xff) >= RXMODE_RFMON)
-                                       set_bit (FLAG_RESET, &ai->flags);
-                       ai->config.rmode &= 0xfe00;
+                       if (sniffing_mode(ai))
+                               set_bit (FLAG_RESET, &ai->flags);
+                       ai->config.rmode &= ~RXMODE_FULL_MASK;
                        clear_bit (FLAG_802_11, &ai->flags);
-                       ai->config.opmode &= 0xFF00;
+                       ai->config.opmode &= ~MODE_CFG_MASK;
                        ai->config.scanMode = SCANMODE_ACTIVE;
                        if ( line[0] == 'a' ) {
-                               ai->config.opmode |= 0;
+                               ai->config.opmode |= MODE_STA_IBSS;
                        } else {
-                               ai->config.opmode |= 1;
+                               ai->config.opmode |= MODE_STA_ESS;
                                if ( line[0] == 'r' ) {
                                        ai->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER;
                                        ai->config.scanMode = SCANMODE_PASSIVE;
@@ -4888,7 +4838,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
                        line += 9;
                        v = get_dec_u16(line, &i, i+3);
                        if ( v != -1 ) {
-                               ai->config.channelSet = (u16)v;
+                               ai->config.channelSet = cpu_to_le16(v);
                                set_bit (FLAG_COMMIT, &ai->flags);
                        }
                } else if ( !strncmp( line, "XmitPower: ", 11 ) ) {
@@ -4896,20 +4846,20 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
                        line += 11;
                        v = get_dec_u16(line, &i, i+3);
                        if ( v != -1 ) {
-                               ai->config.txPower = (u16)v;
+                               ai->config.txPower = cpu_to_le16(v);
                                set_bit (FLAG_COMMIT, &ai->flags);
                        }
                } else if ( !strncmp( line, "WEP: ", 5 ) ) {
                        line += 5;
                        switch( line[0] ) {
                        case 's':
-                               ai->config.authType = (u16)AUTH_SHAREDKEY;
+                               ai->config.authType = AUTH_SHAREDKEY;
                                break;
                        case 'e':
-                               ai->config.authType = (u16)AUTH_ENCRYPT;
+                               ai->config.authType = AUTH_ENCRYPT;
                                break;
                        default:
-                               ai->config.authType = (u16)AUTH_OPEN;
+                               ai->config.authType = AUTH_OPEN;
                                break;
                        }
                        set_bit (FLAG_COMMIT, &ai->flags);
@@ -4919,7 +4869,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
                        line += 16;
                        v = get_dec_u16(line, &i, 3);
                        v = (v<0) ? 0 : ((v>255) ? 255 : v);
-                       ai->config.longRetryLimit = (u16)v;
+                       ai->config.longRetryLimit = cpu_to_le16(v);
                        set_bit (FLAG_COMMIT, &ai->flags);
                } else if ( !strncmp( line, "ShortRetryLimit: ", 17 ) ) {
                        int v, i = 0;
@@ -4927,7 +4877,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
                        line += 17;
                        v = get_dec_u16(line, &i, 3);
                        v = (v<0) ? 0 : ((v>255) ? 255 : v);
-                       ai->config.shortRetryLimit = (u16)v;
+                       ai->config.shortRetryLimit = cpu_to_le16(v);
                        set_bit (FLAG_COMMIT, &ai->flags);
                } else if ( !strncmp( line, "RTSThreshold: ", 14 ) ) {
                        int v, i = 0;
@@ -4935,7 +4885,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
                        line += 14;
                        v = get_dec_u16(line, &i, 4);
                        v = (v<0) ? 0 : ((v>AIRO_DEF_MTU) ? AIRO_DEF_MTU : v);
-                       ai->config.rtsThres = (u16)v;
+                       ai->config.rtsThres = cpu_to_le16(v);
                        set_bit (FLAG_COMMIT, &ai->flags);
                } else if ( !strncmp( line, "TXMSDULifetime: ", 16 ) ) {
                        int v, i = 0;
@@ -4943,7 +4893,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
                        line += 16;
                        v = get_dec_u16(line, &i, 5);
                        v = (v<0) ? 0 : v;
-                       ai->config.txLifetime = (u16)v;
+                       ai->config.txLifetime = cpu_to_le16(v);
                        set_bit (FLAG_COMMIT, &ai->flags);
                } else if ( !strncmp( line, "RXMSDULifetime: ", 16 ) ) {
                        int v, i = 0;
@@ -4951,7 +4901,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
                        line += 16;
                        v = get_dec_u16(line, &i, 5);
                        v = (v<0) ? 0 : v;
-                       ai->config.rxLifetime = (u16)v;
+                       ai->config.rxLifetime = cpu_to_le16(v);
                        set_bit (FLAG_COMMIT, &ai->flags);
                } else if ( !strncmp( line, "TXDiversity: ", 13 ) ) {
                        ai->config.txDiversity =
@@ -4970,7 +4920,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
                        v = get_dec_u16(line, &i, 4);
                        v = (v<256) ? 256 : ((v>AIRO_DEF_MTU) ? AIRO_DEF_MTU : v);
                        v = v & 0xfffe; /* Make sure its even */
-                       ai->config.fragThresh = (u16)v;
+                       ai->config.fragThresh = cpu_to_le16(v);
                        set_bit (FLAG_COMMIT, &ai->flags);
                } else if (!strncmp(line, "Modulation: ", 12)) {
                        line += 12;
@@ -4997,8 +4947,9 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
        airo_config_commit(dev, NULL, NULL, NULL);
 }
 
-static char *get_rmode(u16 mode) {
-        switch(mode&0xff) {
+static char *get_rmode(__le16 mode)
+{
+        switch(mode & RXMODE_MASK) {
         case RXMODE_RFMON:  return "rfmon";
         case RXMODE_RFMON_ANYBSS:  return "yna (any) bss rfmon";
         case RXMODE_LANMON:  return "lanmon";
@@ -5006,12 +4957,14 @@ static char *get_rmode(u16 mode) {
         return "ESS";
 }
 
-static int proc_config_open( struct inode *inode, struct file *file ) {
+static int proc_config_open(struct inode *inode, struct file *file)
+{
        struct proc_data *data;
        struct proc_dir_entry *dp = PDE(inode);
        struct net_device *dev = dp->data;
        struct airo_info *ai = dev->priv;
        int i;
+       __le16 mode;
 
        if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
                return -ENOMEM;
@@ -5030,6 +4983,7 @@ static int proc_config_open( struct inode *inode, struct file *file ) {
 
        readConfigRid(ai, 1);
 
+       mode = ai->config.opmode & MODE_CFG_MASK;
        i = sprintf( data->rbuffer,
                     "Mode: %s\n"
                     "Radio: %s\n"
@@ -5038,15 +4992,16 @@ static int proc_config_open( struct inode *inode, struct file *file ) {
                     "DataRates: %d %d %d %d %d %d %d %d\n"
                     "Channel: %d\n"
                     "XmitPower: %d\n",
-                    (ai->config.opmode & 0xFF) == 0 ? "adhoc" :
-                    (ai->config.opmode & 0xFF) == 1 ? get_rmode(ai->config.rmode):
-                    (ai->config.opmode & 0xFF) == 2 ? "AP" :
-                    (ai->config.opmode & 0xFF) == 3 ? "AP RPTR" : "Error",
+                    mode == MODE_STA_IBSS ? "adhoc" :
+                    mode == MODE_STA_ESS ? get_rmode(ai->config.rmode):
+                    mode == MODE_AP ? "AP" :
+                    mode == MODE_AP_RPTR ? "AP RPTR" : "Error",
                     test_bit(FLAG_RADIO_OFF, &ai->flags) ? "off" : "on",
                     ai->config.nodeName,
-                    ai->config.powerSaveMode == 0 ? "CAM" :
-                    ai->config.powerSaveMode == 1 ? "PSP" :
-                    ai->config.powerSaveMode == 2 ? "PSPCAM" : "Error",
+                    ai->config.powerSaveMode == POWERSAVE_CAM ? "CAM" :
+                    ai->config.powerSaveMode == POWERSAVE_PSP ? "PSP" :
+                    ai->config.powerSaveMode == POWERSAVE_PSPCAM ? "PSPCAM" :
+                    "Error",
                     (int)ai->config.rates[0],
                     (int)ai->config.rates[1],
                     (int)ai->config.rates[2],
@@ -5055,8 +5010,8 @@ static int proc_config_open( struct inode *inode, struct file *file ) {
                     (int)ai->config.rates[5],
                     (int)ai->config.rates[6],
                     (int)ai->config.rates[7],
-                    (int)ai->config.channelSet,
-                    (int)ai->config.txPower
+                    le16_to_cpu(ai->config.channelSet),
+                    le16_to_cpu(ai->config.txPower)
                );
        sprintf( data->rbuffer + i,
                 "LongRetryLimit: %d\n"
@@ -5070,19 +5025,19 @@ static int proc_config_open( struct inode *inode, struct file *file ) {
                 "WEP: %s\n"
                 "Modulation: %s\n"
                 "Preamble: %s\n",
-                (int)ai->config.longRetryLimit,
-                (int)ai->config.shortRetryLimit,
-                (int)ai->config.rtsThres,
-                (int)ai->config.txLifetime,
-                (int)ai->config.rxLifetime,
+                le16_to_cpu(ai->config.longRetryLimit),
+                le16_to_cpu(ai->config.shortRetryLimit),
+                le16_to_cpu(ai->config.rtsThres),
+                le16_to_cpu(ai->config.txLifetime),
+                le16_to_cpu(ai->config.rxLifetime),
                 ai->config.txDiversity == 1 ? "left" :
                 ai->config.txDiversity == 2 ? "right" : "both",
                 ai->config.rxDiversity == 1 ? "left" :
                 ai->config.rxDiversity == 2 ? "right" : "both",
-                (int)ai->config.fragThresh,
+                le16_to_cpu(ai->config.fragThresh),
                 ai->config.authType == AUTH_ENCRYPT ? "encrypt" :
                 ai->config.authType == AUTH_SHAREDKEY ? "shared" : "open",
-                ai->config.modulation == 0 ? "default" :
+                ai->config.modulation == MOD_DEFAULT ? "default" :
                 ai->config.modulation == MOD_CCK ? "cck" :
                 ai->config.modulation == MOD_MOK ? "mok" : "error",
                 ai->config.preamble == PREAMBLE_AUTO ? "auto" :
@@ -5148,7 +5103,7 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) {
        if ( !data->writelen ) return;
 
        memset( &APList_rid, 0, sizeof(APList_rid) );
-       APList_rid.len = sizeof(APList_rid);
+       APList_rid.len = cpu_to_le16(sizeof(APList_rid));
 
        for( i = 0; i < 4 && data->writelen >= (i+1)*6*3; i++ ) {
                int j;
@@ -5643,9 +5598,9 @@ static int __init airo_init_module( void )
        int have_isa_dev = 0;
 #endif
 
-       airo_entry = create_proc_entry("aironet",
+       airo_entry = create_proc_entry("driver/aironet",
                                       S_IFDIR | airo_perm,
-                                      proc_root_driver);
+                                      NULL);
 
        if (airo_entry) {
                airo_entry->uid = proc_uid;
@@ -5669,7 +5624,7 @@ static int __init airo_init_module( void )
        airo_print_info("", "Finished probing for PCI adapters");
 
        if (i) {
-               remove_proc_entry("aironet", proc_root_driver);
+               remove_proc_entry("driver/aironet", NULL);
                return i;
        }
 #endif
@@ -5691,7 +5646,7 @@ static void __exit airo_cleanup_module( void )
 #ifdef CONFIG_PCI
        pci_unregister_driver(&airo_driver);
 #endif
-       remove_proc_entry("aironet", proc_root_driver);
+       remove_proc_entry("driver/aironet", NULL);
 }
 
 /*
@@ -5730,21 +5685,27 @@ static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm)
 static int airo_get_quality (StatusRid *status_rid, CapabilityRid *cap_rid)
 {
        int quality = 0;
+       u16 sq;
 
-       if ((status_rid->mode & 0x3f) == 0x3f && (cap_rid->hardCap & 8)) {
-               if (memcmp(cap_rid->prodName, "350", 3))
-                       if (status_rid->signalQuality > 0x20)
-                               quality = 0;
-                       else
-                               quality = 0x20 - status_rid->signalQuality;
+       if ((status_rid->mode & cpu_to_le16(0x3f)) != cpu_to_le16(0x3f))
+               return 0;
+
+       if (!(cap_rid->hardCap & cpu_to_le16(8)))
+               return 0;
+
+       sq = le16_to_cpu(status_rid->signalQuality);
+       if (memcmp(cap_rid->prodName, "350", 3))
+               if (sq > 0x20)
+                       quality = 0;
                else
-                       if (status_rid->signalQuality > 0xb0)
-                               quality = 0;
-                       else if (status_rid->signalQuality < 0x10)
-                               quality = 0xa0;
-                       else
-                               quality = 0xb0 - status_rid->signalQuality;
-       }
+                       quality = 0x20 - sq;
+       else
+               if (sq > 0xb0)
+                       quality = 0;
+               else if (sq < 0x10)
+                       quality = 0xa0;
+               else
+                       quality = 0xb0 - sq;
        return quality;
 }
 
@@ -5802,7 +5763,7 @@ static int airo_set_freq(struct net_device *dev,
                } else {
                        readConfigRid(local, 1);
                        /* Yes ! We can set it !!! */
-                       local->config.channelSet = (u16) channel;
+                       local->config.channelSet = cpu_to_le16(channel);
                        set_bit (FLAG_COMMIT, &local->flags);
                }
        }
@@ -5823,12 +5784,12 @@ static int airo_get_freq(struct net_device *dev,
        int ch;
 
        readConfigRid(local, 1);
-       if ((local->config.opmode & 0xFF) == MODE_STA_ESS)
+       if ((local->config.opmode & MODE_CFG_MASK) == MODE_STA_ESS)
                status_rid.channel = local->config.channelSet;
        else
                readStatusRid(local, &status_rid, 1);
 
-       ch = (int)status_rid.channel;
+       ch = le16_to_cpu(status_rid.channel);
        if((ch > 0) && (ch < 15)) {
                fwrq->m = frequency_list[ch - 1] * 100000;
                fwrq->e = 1;
@@ -5904,11 +5865,11 @@ static int airo_get_essid(struct net_device *dev,
         * get the relevant SSID from the SSID list... */
 
        /* Get the current SSID */
-       memcpy(extra, status_rid.SSID, status_rid.SSIDlen);
+       memcpy(extra, status_rid.SSID, le16_to_cpu(status_rid.SSIDlen));
        /* If none, we may want to get the one that was set */
 
        /* Push it out ! */
-       dwrq->length = status_rid.SSIDlen;
+       dwrq->length = le16_to_cpu(status_rid.SSIDlen);
        dwrq->flags = 1; /* active */
 
        return 0;
@@ -5942,7 +5903,7 @@ static int airo_set_wap(struct net_device *dev,
                up(&local->sem);
        } else {
                memset(&APList_rid, 0, sizeof(APList_rid));
-               APList_rid.len = sizeof(APList_rid);
+               APList_rid.len = cpu_to_le16(sizeof(APList_rid));
                memcpy(APList_rid.ap[0], awrq->sa_data, ETH_ALEN);
                disable_MAC(local, 1);
                writeAPListRid(local, &APList_rid, 1);
@@ -6098,7 +6059,7 @@ static int airo_get_rate(struct net_device *dev,
 
        readStatusRid(local, &status_rid, 1);
 
-       vwrq->value = status_rid.currentXmitRate * 500000;
+       vwrq->value = le16_to_cpu(status_rid.currentXmitRate) * 500000;
        /* If more than one rate, set auto */
        readConfigRid(local, 1);
        vwrq->fixed = (local->config.rates[1] == 0);
@@ -6124,7 +6085,7 @@ static int airo_set_rts(struct net_device *dev,
                return -EINVAL;
        }
        readConfigRid(local, 1);
-       local->config.rtsThres = rthr;
+       local->config.rtsThres = cpu_to_le16(rthr);
        set_bit (FLAG_COMMIT, &local->flags);
 
        return -EINPROGRESS;            /* Call commit handler */
@@ -6142,7 +6103,7 @@ static int airo_get_rts(struct net_device *dev,
        struct airo_info *local = dev->priv;
 
        readConfigRid(local, 1);
-       vwrq->value = local->config.rtsThres;
+       vwrq->value = le16_to_cpu(local->config.rtsThres);
        vwrq->disabled = (vwrq->value >= AIRO_DEF_MTU);
        vwrq->fixed = 1;
 
@@ -6168,7 +6129,7 @@ static int airo_set_frag(struct net_device *dev,
        }
        fthr &= ~0x1;   /* Get an even value - is it really needed ??? */
        readConfigRid(local, 1);
-       local->config.fragThresh = (u16)fthr;
+       local->config.fragThresh = cpu_to_le16(fthr);
        set_bit (FLAG_COMMIT, &local->flags);
 
        return -EINPROGRESS;            /* Call commit handler */
@@ -6186,7 +6147,7 @@ static int airo_get_frag(struct net_device *dev,
        struct airo_info *local = dev->priv;
 
        readConfigRid(local, 1);
-       vwrq->value = local->config.fragThresh;
+       vwrq->value = le16_to_cpu(local->config.fragThresh);
        vwrq->disabled = (vwrq->value >= AIRO_DEF_MTU);
        vwrq->fixed = 1;
 
@@ -6206,42 +6167,42 @@ static int airo_set_mode(struct net_device *dev,
        int reset = 0;
 
        readConfigRid(local, 1);
-       if ((local->config.rmode & 0xff) >= RXMODE_RFMON)
+       if (sniffing_mode(local))
                reset = 1;
 
        switch(*uwrq) {
                case IW_MODE_ADHOC:
-                       local->config.opmode &= 0xFF00;
+                       local->config.opmode &= ~MODE_CFG_MASK;
                        local->config.opmode |= MODE_STA_IBSS;
-                       local->config.rmode &= 0xfe00;
+                       local->config.rmode &= ~RXMODE_FULL_MASK;
                        local->config.scanMode = SCANMODE_ACTIVE;
                        clear_bit (FLAG_802_11, &local->flags);
                        break;
                case IW_MODE_INFRA:
-                       local->config.opmode &= 0xFF00;
+                       local->config.opmode &= ~MODE_CFG_MASK;
                        local->config.opmode |= MODE_STA_ESS;
-                       local->config.rmode &= 0xfe00;
+                       local->config.rmode &= ~RXMODE_FULL_MASK;
                        local->config.scanMode = SCANMODE_ACTIVE;
                        clear_bit (FLAG_802_11, &local->flags);
                        break;
                case IW_MODE_MASTER:
-                       local->config.opmode &= 0xFF00;
+                       local->config.opmode &= ~MODE_CFG_MASK;
                        local->config.opmode |= MODE_AP;
-                       local->config.rmode &= 0xfe00;
+                       local->config.rmode &= ~RXMODE_FULL_MASK;
                        local->config.scanMode = SCANMODE_ACTIVE;
                        clear_bit (FLAG_802_11, &local->flags);
                        break;
                case IW_MODE_REPEAT:
-                       local->config.opmode &= 0xFF00;
+                       local->config.opmode &= ~MODE_CFG_MASK;
                        local->config.opmode |= MODE_AP_RPTR;
-                       local->config.rmode &= 0xfe00;
+                       local->config.rmode &= ~RXMODE_FULL_MASK;
                        local->config.scanMode = SCANMODE_ACTIVE;
                        clear_bit (FLAG_802_11, &local->flags);
                        break;
                case IW_MODE_MONITOR:
-                       local->config.opmode &= 0xFF00;
+                       local->config.opmode &= ~MODE_CFG_MASK;
                        local->config.opmode |= MODE_STA_ESS;
-                       local->config.rmode &= 0xfe00;
+                       local->config.rmode &= ~RXMODE_FULL_MASK;
                        local->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER;
                        local->config.scanMode = SCANMODE_PASSIVE;
                        set_bit (FLAG_802_11, &local->flags);
@@ -6269,7 +6230,7 @@ static int airo_get_mode(struct net_device *dev,
 
        readConfigRid(local, 1);
        /* If not managed, assume it's ad-hoc */
-       switch (local->config.opmode & 0xFF) {
+       switch (local->config.opmode & MODE_CFG_MASK) {
                case MODE_STA_ESS:
                        *uwrq = IW_MODE_INFRA;
                        break;
@@ -6286,6 +6247,13 @@ static int airo_get_mode(struct net_device *dev,
        return 0;
 }
 
+static inline int valid_index(CapabilityRid *p, int index)
+{
+       if (index < 0)
+               return 0;
+       return index < (p->softCap & cpu_to_le16(0x80) ? 4 : 1);
+}
+
 /*------------------------------------------------------------------*/
 /*
  * Wireless Handler : set Encryption Key
@@ -6298,12 +6266,12 @@ static int airo_set_encode(struct net_device *dev,
        struct airo_info *local = dev->priv;
        CapabilityRid cap_rid;          /* Card capability info */
        int perm = ( dwrq->flags & IW_ENCODE_TEMP ? 0 : 1 );
-       u16 currentAuthType = local->config.authType;
+       __le16 currentAuthType = local->config.authType;
 
        /* Is WEP supported ? */
        readCapabilityRid(local, &cap_rid, 1);
        /* Older firmware doesn't support this...
-       if(!(cap_rid.softCap & 2)) {
+       if(!(cap_rid.softCap & cpu_to_le16(2))) {
                return -EOPNOTSUPP;
        } */
        readConfigRid(local, 1);
@@ -6323,7 +6291,7 @@ static int airo_set_encode(struct net_device *dev,
                        return -EINVAL;
                }
                /* Check the index (none -> use current) */
-               if ((index < 0) || (index >= ((cap_rid.softCap & 0x80) ? 4:1)))
+               if (!valid_index(&cap_rid, index))
                        index = current_index;
                /* Set the length */
                if (dwrq->length > MIN_KEY_SIZE)
@@ -6353,7 +6321,7 @@ static int airo_set_encode(struct net_device *dev,
        } else {
                /* Do we want to just set the transmit key index ? */
                int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
-               if ((index >= 0) && (index < ((cap_rid.softCap & 0x80)?4:1))) {
+               if (valid_index(&cap_rid, index)) {
                        set_wep_key(local, index, NULL, 0, perm, 1);
                } else
                        /* Don't complain if only change the mode */
@@ -6388,7 +6356,7 @@ static int airo_get_encode(struct net_device *dev,
 
        /* Is it supported ? */
        readCapabilityRid(local, &cap_rid, 1);
-       if(!(cap_rid.softCap & 2)) {
+       if(!(cap_rid.softCap & cpu_to_le16(2))) {
                return -EOPNOTSUPP;
        }
        readConfigRid(local, 1);
@@ -6410,7 +6378,7 @@ static int airo_get_encode(struct net_device *dev,
        memset(extra, 0, 16);
 
        /* Which key do we want ? -1 -> tx index */
-       if ((index < 0) || (index >= ((cap_rid.softCap & 0x80) ? 4 : 1)))
+       if (!valid_index(&cap_rid, index))
                index = get_wep_key(local, 0xffff);
        dwrq->flags |= index + 1;
        /* Copy the key to the user buffer */
@@ -6435,14 +6403,14 @@ static int airo_set_encodeext(struct net_device *dev,
        struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
        CapabilityRid cap_rid;          /* Card capability info */
        int perm = ( encoding->flags & IW_ENCODE_TEMP ? 0 : 1 );
-       u16 currentAuthType = local->config.authType;
+       __le16 currentAuthType = local->config.authType;
        int idx, key_len, alg = ext->alg, set_key = 1;
        wep_key_t key;
 
        /* Is WEP supported ? */
        readCapabilityRid(local, &cap_rid, 1);
        /* Older firmware doesn't support this...
-       if(!(cap_rid.softCap & 2)) {
+       if(!(cap_rid.softCap & cpu_to_le16(2))) {
                return -EOPNOTSUPP;
        } */
        readConfigRid(local, 1);
@@ -6450,7 +6418,7 @@ static int airo_set_encodeext(struct net_device *dev,
        /* Determine and validate the key index */
        idx = encoding->flags & IW_ENCODE_INDEX;
        if (idx) {
-               if (idx < 1 || idx > ((cap_rid.softCap & 0x80) ? 4:1))
+               if (!valid_index(&cap_rid, idx - 1))
                        return -EINVAL;
                idx--;
        } else
@@ -6524,7 +6492,7 @@ static int airo_get_encodeext(struct net_device *dev,
 
        /* Is it supported ? */
        readCapabilityRid(local, &cap_rid, 1);
-       if(!(cap_rid.softCap & 2)) {
+       if(!(cap_rid.softCap & cpu_to_le16(2))) {
                return -EOPNOTSUPP;
        }
        readConfigRid(local, 1);
@@ -6535,7 +6503,7 @@ static int airo_get_encodeext(struct net_device *dev,
 
        idx = encoding->flags & IW_ENCODE_INDEX;
        if (idx) {
-               if (idx < 1 || idx > ((cap_rid.softCap & 0x80) ? 4:1))
+               if (!valid_index(&cap_rid, idx - 1))
                        return -EINVAL;
                idx--;
        } else
@@ -6581,7 +6549,7 @@ static int airo_set_auth(struct net_device *dev,
 {
        struct airo_info *local = dev->priv;
        struct iw_param *param = &wrqu->param;
-       u16 currentAuthType = local->config.authType;
+       __le16 currentAuthType = local->config.authType;
 
        switch (param->flags & IW_AUTH_INDEX) {
        case IW_AUTH_WPA_VERSION:
@@ -6649,7 +6617,7 @@ static int airo_get_auth(struct net_device *dev,
 {
        struct airo_info *local = dev->priv;
        struct iw_param *param = &wrqu->param;
-       u16 currentAuthType = local->config.authType;
+       __le16 currentAuthType = local->config.authType;
 
        switch (param->flags & IW_AUTH_INDEX) {
        case IW_AUTH_DROP_UNENCRYPTED:
@@ -6700,6 +6668,7 @@ static int airo_set_txpow(struct net_device *dev,
        CapabilityRid cap_rid;          /* Card capability info */
        int i;
        int rc = -EINVAL;
+       __le16 v = cpu_to_le16(vwrq->value);
 
        readCapabilityRid(local, &cap_rid, 1);
 
@@ -6713,9 +6682,9 @@ static int airo_set_txpow(struct net_device *dev,
        }
        clear_bit (FLAG_RADIO_OFF, &local->flags);
        for (i = 0; cap_rid.txPowerLevels[i] && (i < 8); i++)
-               if ((vwrq->value==cap_rid.txPowerLevels[i])) {
+               if (v == cap_rid.txPowerLevels[i]) {
                        readConfigRid(local, 1);
-                       local->config.txPower = vwrq->value;
+                       local->config.txPower = v;
                        set_bit (FLAG_COMMIT, &local->flags);
                        rc = -EINPROGRESS;      /* Call commit handler */
                        break;
@@ -6735,7 +6704,7 @@ static int airo_get_txpow(struct net_device *dev,
        struct airo_info *local = dev->priv;
 
        readConfigRid(local, 1);
-       vwrq->value = local->config.txPower;
+       vwrq->value = le16_to_cpu(local->config.txPower);
        vwrq->fixed = 1;        /* No power control */
        vwrq->disabled = test_bit(FLAG_RADIO_OFF, &local->flags);
        vwrq->flags = IW_TXPOW_MWATT;
@@ -6760,20 +6729,21 @@ static int airo_set_retry(struct net_device *dev,
        }
        readConfigRid(local, 1);
        if(vwrq->flags & IW_RETRY_LIMIT) {
+               __le16 v = cpu_to_le16(vwrq->value);
                if(vwrq->flags & IW_RETRY_LONG)
-                       local->config.longRetryLimit = vwrq->value;
+                       local->config.longRetryLimit = v;
                else if (vwrq->flags & IW_RETRY_SHORT)
-                       local->config.shortRetryLimit = vwrq->value;
+                       local->config.shortRetryLimit = v;
                else {
                        /* No modifier : set both */
-                       local->config.longRetryLimit = vwrq->value;
-                       local->config.shortRetryLimit = vwrq->value;
+                       local->config.longRetryLimit = v;
+                       local->config.shortRetryLimit = v;
                }
                set_bit (FLAG_COMMIT, &local->flags);
                rc = -EINPROGRESS;              /* Call commit handler */
        }
        if(vwrq->flags & IW_RETRY_LIFETIME) {
-               local->config.txLifetime = vwrq->value / 1024;
+               local->config.txLifetime = cpu_to_le16(vwrq->value / 1024);
                set_bit (FLAG_COMMIT, &local->flags);
                rc = -EINPROGRESS;              /* Call commit handler */
        }
@@ -6797,14 +6767,14 @@ static int airo_get_retry(struct net_device *dev,
        /* Note : by default, display the min retry number */
        if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
                vwrq->flags = IW_RETRY_LIFETIME;
-               vwrq->value = (int)local->config.txLifetime * 1024;
+               vwrq->value = le16_to_cpu(local->config.txLifetime) * 1024;
        } else if((vwrq->flags & IW_RETRY_LONG)) {
                vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
-               vwrq->value = (int)local->config.longRetryLimit;
+               vwrq->value = le16_to_cpu(local->config.longRetryLimit);
        } else {
                vwrq->flags = IW_RETRY_LIMIT;
-               vwrq->value = (int)local->config.shortRetryLimit;
-               if((int)local->config.shortRetryLimit != (int)local->config.longRetryLimit)
+               vwrq->value = le16_to_cpu(local->config.shortRetryLimit);
+               if(local->config.shortRetryLimit != local->config.longRetryLimit)
                        vwrq->flags |= IW_RETRY_SHORT;
        }
 
@@ -6885,16 +6855,17 @@ static int airo_get_range(struct net_device *dev,
        range->min_frag = 256;
        range->max_frag = AIRO_DEF_MTU;
 
-       if(cap_rid.softCap & 2) {
+       if(cap_rid.softCap & cpu_to_le16(2)) {
                // WEP: RC4 40 bits
                range->encoding_size[0] = 5;
                // RC4 ~128 bits
-               if (cap_rid.softCap & 0x100) {
+               if (cap_rid.softCap & cpu_to_le16(0x100)) {
                        range->encoding_size[1] = 13;
                        range->num_encoding_sizes = 2;
                } else
                        range->num_encoding_sizes = 1;
-               range->max_encoding_tokens = (cap_rid.softCap & 0x80) ? 4 : 1;
+               range->max_encoding_tokens =
+                       cap_rid.softCap & cpu_to_le16(0x80) ? 4 : 1;
        } else {
                range->num_encoding_sizes = 0;
                range->max_encoding_tokens = 0;
@@ -6909,7 +6880,7 @@ static int airo_get_range(struct net_device *dev,
 
        /* Transmit Power - values are in mW */
        for(i = 0 ; i < 8 ; i++) {
-               range->txpower[i] = cap_rid.txPowerLevels[i];
+               range->txpower[i] = le16_to_cpu(cap_rid.txPowerLevels[i]);
                if(range->txpower[i] == 0)
                        break;
        }
@@ -6948,38 +6919,37 @@ static int airo_set_power(struct net_device *dev,
 
        readConfigRid(local, 1);
        if (vwrq->disabled) {
-               if ((local->config.rmode & 0xFF) >= RXMODE_RFMON) {
+               if (sniffing_mode(local))
                        return -EINVAL;
-               }
                local->config.powerSaveMode = POWERSAVE_CAM;
-               local->config.rmode &= 0xFF00;
+               local->config.rmode &= ~RXMODE_MASK;
                local->config.rmode |= RXMODE_BC_MC_ADDR;
                set_bit (FLAG_COMMIT, &local->flags);
                return -EINPROGRESS;            /* Call commit handler */
        }
        if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
-               local->config.fastListenDelay = (vwrq->value + 500) / 1024;
+               local->config.fastListenDelay = cpu_to_le16((vwrq->value + 500) / 1024);
                local->config.powerSaveMode = POWERSAVE_PSPCAM;
                set_bit (FLAG_COMMIT, &local->flags);
        } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
-               local->config.fastListenInterval = local->config.listenInterval = (vwrq->value + 500) / 1024;
+               local->config.fastListenInterval =
+               local->config.listenInterval =
+                       cpu_to_le16((vwrq->value + 500) / 1024);
                local->config.powerSaveMode = POWERSAVE_PSPCAM;
                set_bit (FLAG_COMMIT, &local->flags);
        }
        switch (vwrq->flags & IW_POWER_MODE) {
                case IW_POWER_UNICAST_R:
-                       if ((local->config.rmode & 0xFF) >= RXMODE_RFMON) {
+                       if (sniffing_mode(local))
                                return -EINVAL;
-                       }
-                       local->config.rmode &= 0xFF00;
+                       local->config.rmode &= ~RXMODE_MASK;
                        local->config.rmode |= RXMODE_ADDR;
                        set_bit (FLAG_COMMIT, &local->flags);
                        break;
                case IW_POWER_ALL_R:
-                       if ((local->config.rmode & 0xFF) >= RXMODE_RFMON) {
+                       if (sniffing_mode(local))
                                return -EINVAL;
-                       }
-                       local->config.rmode &= 0xFF00;
+                       local->config.rmode &= ~RXMODE_MASK;
                        local->config.rmode |= RXMODE_BC_MC_ADDR;
                        set_bit (FLAG_COMMIT, &local->flags);
                case IW_POWER_ON:
@@ -7003,20 +6973,20 @@ static int airo_get_power(struct net_device *dev,
                          char *extra)
 {
        struct airo_info *local = dev->priv;
-       int mode;
+       __le16 mode;
 
        readConfigRid(local, 1);
        mode = local->config.powerSaveMode;
        if ((vwrq->disabled = (mode == POWERSAVE_CAM)))
                return 0;
        if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
-               vwrq->value = (int)local->config.fastListenDelay * 1024;
+               vwrq->value = le16_to_cpu(local->config.fastListenDelay) * 1024;
                vwrq->flags = IW_POWER_TIMEOUT;
        } else {
-               vwrq->value = (int)local->config.fastListenInterval * 1024;
+               vwrq->value = le16_to_cpu(local->config.fastListenInterval) * 1024;
                vwrq->flags = IW_POWER_PERIOD;
        }
-       if ((local->config.rmode & 0xFF) == RXMODE_ADDR)
+       if ((local->config.rmode & RXMODE_MASK) == RXMODE_ADDR)
                vwrq->flags |= IW_POWER_UNICAST_R;
        else
                vwrq->flags |= IW_POWER_ALL_R;
@@ -7036,7 +7006,8 @@ static int airo_set_sens(struct net_device *dev,
        struct airo_info *local = dev->priv;
 
        readConfigRid(local, 1);
-       local->config.rssiThreshold = vwrq->disabled ? RSSI_DEFAULT : vwrq->value;
+       local->config.rssiThreshold =
+               cpu_to_le16(vwrq->disabled ? RSSI_DEFAULT : vwrq->value);
        set_bit (FLAG_COMMIT, &local->flags);
 
        return -EINPROGRESS;            /* Call commit handler */
@@ -7054,7 +7025,7 @@ static int airo_get_sens(struct net_device *dev,
        struct airo_info *local = dev->priv;
 
        readConfigRid(local, 1);
-       vwrq->value = local->config.rssiThreshold;
+       vwrq->value = le16_to_cpu(local->config.rssiThreshold);
        vwrq->disabled = (vwrq->value == 0);
        vwrq->fixed = 1;
 
@@ -7624,7 +7595,7 @@ static void airo_read_wireless_stats(struct airo_info *local)
        StatusRid status_rid;
        StatsRid stats_rid;
        CapabilityRid cap_rid;
-       u32 *vals = stats_rid.vals;
+       __le32 *vals = stats_rid.vals;
 
        /* Get stats out of the card */
        clear_bit(JOB_WSTATS, &local->jobs);
@@ -7638,18 +7609,22 @@ static void airo_read_wireless_stats(struct airo_info *local)
        up(&local->sem);
 
        /* The status */
-       local->wstats.status = status_rid.mode;
+       local->wstats.status = le16_to_cpu(status_rid.mode);
 
        /* Signal quality and co */
        if (local->rssi) {
-               local->wstats.qual.level = airo_rssi_to_dbm( local->rssi, status_rid.sigQuality );
+               local->wstats.qual.level =
+                       airo_rssi_to_dbm(local->rssi,
+                                        le16_to_cpu(status_rid.sigQuality));
                /* normalizedSignalStrength appears to be a percentage */
-               local->wstats.qual.qual = status_rid.normalizedSignalStrength;
+               local->wstats.qual.qual =
+                       le16_to_cpu(status_rid.normalizedSignalStrength);
        } else {
-               local->wstats.qual.level = (status_rid.normalizedSignalStrength + 321) / 2;
+               local->wstats.qual.level =
+                       (le16_to_cpu(status_rid.normalizedSignalStrength) + 321) / 2;
                local->wstats.qual.qual = airo_get_quality(&status_rid, &cap_rid);
        }
-       if (status_rid.len >= 124) {
+       if (le16_to_cpu(status_rid.len) >= 124) {
                local->wstats.qual.noise = 0x100 - status_rid.noisedBm;
                local->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
        } else {
@@ -7659,12 +7634,15 @@ static void airo_read_wireless_stats(struct airo_info *local)
 
        /* Packets discarded in the wireless adapter due to wireless
         * specific problems */
-       local->wstats.discard.nwid = vals[56] + vals[57] + vals[58];/* SSID Mismatch */
-       local->wstats.discard.code = vals[6];/* RxWepErr */
-       local->wstats.discard.fragment = vals[30];
-       local->wstats.discard.retries = vals[10];
-       local->wstats.discard.misc = vals[1] + vals[32];
-       local->wstats.miss.beacon = vals[34];
+       local->wstats.discard.nwid = le32_to_cpu(vals[56]) +
+                                    le32_to_cpu(vals[57]) +
+                                    le32_to_cpu(vals[58]); /* SSID Mismatch */
+       local->wstats.discard.code = le32_to_cpu(vals[6]);/* RxWepErr */
+       local->wstats.discard.fragment = le32_to_cpu(vals[30]);
+       local->wstats.discard.retries = le32_to_cpu(vals[10]);
+       local->wstats.discard.misc = le32_to_cpu(vals[1]) +
+                                    le32_to_cpu(vals[32]);
+       local->wstats.miss.beacon = le32_to_cpu(vals[34]);
 }
 
 static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
@@ -7848,9 +7826,9 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
                ConfigRid *cfg = (ConfigRid *)iobuf;
 
                if (test_bit(FLAG_MIC_CAPABLE, &ai->flags))
-                       cfg->opmode |= cpu_to_le16(MODE_MIC);
+                       cfg->opmode |= MODE_MIC;
 
-               if ((le16_to_cpu(cfg->opmode) & 0xFF) == MODE_STA_IBSS)
+               if ((cfg->opmode & MODE_CFG_MASK) == MODE_STA_IBSS)
                        set_bit (FLAG_ADHOC, &ai->flags);
                else
                        clear_bit (FLAG_ADHOC, &ai->flags);