Commit ba4d6513 authored by Lee Jones's avatar Lee Jones Committed by Kalle Valo

airo: Fix a myriad of coding style issues

- Ensure spaces appear after {for, if, while, etc}
 - Ensure spaces to not appear after '('
 - Ensure spaces to not appear before ')'
 - Ensure spaces appear between ')' and '{'
 - Ensure spaces appear after ','
 - Ensure spaces do not appear before ','
 - Ensure spaces appear either side of '='
 - Ensure '{'s which open functions are on a new line
 - Remove trailing whitespace

There are still a whole host of issues with this file, but this
patch certainly breaks the back of them.

Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Benjamin Reed <breed@users.sourceforge.net>
Cc: Javier Achirica <achirica@users.sourceforge.net>
Cc: Jean Tourrilhes <jt@hpl.hp.com>
Cc: Fabrice Bellet <fabrice@bellet.info>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200814113933.1903438-13-lee.jones@linaro.org
parent 0b6a4247
...@@ -433,7 +433,7 @@ static int do8bitIO /* = 0 */; ...@@ -433,7 +433,7 @@ static int do8bitIO /* = 0 */;
#define STATUS_INTS (EV_AWAKE|EV_LINK|EV_TXEXC|EV_TX|EV_TXCPY|EV_RX|EV_MIC) #define STATUS_INTS (EV_AWAKE|EV_LINK|EV_TXEXC|EV_TX|EV_TXCPY|EV_RX|EV_MIC)
#ifdef CHECK_UNKNOWN_INTS #ifdef CHECK_UNKNOWN_INTS
#define IGNORE_INTS ( EV_CMD | EV_UNKNOWN) #define IGNORE_INTS (EV_CMD | EV_UNKNOWN)
#else #else
#define IGNORE_INTS (~STATUS_INTS) #define IGNORE_INTS (~STATUS_INTS)
#endif #endif
...@@ -1107,9 +1107,9 @@ static const char version[] = "airo.c 0.6 (Ben Reed & Javier Achirica)"; ...@@ -1107,9 +1107,9 @@ static const char version[] = "airo.c 0.6 (Ben Reed & Javier Achirica)";
struct airo_info; struct airo_info;
static int get_dec_u16( char *buffer, int *start, int limit ); static int get_dec_u16(char *buffer, int *start, int limit);
static void OUT4500( struct airo_info *, u16 reg, u16 value ); static void OUT4500(struct airo_info *, u16 reg, u16 value);
static unsigned short IN4500( struct airo_info *, u16 reg ); static unsigned short IN4500(struct airo_info *, u16 reg);
static u16 setup_card(struct airo_info*, u8 *mac, int lock); static u16 setup_card(struct airo_info*, u8 *mac, int lock);
static int enable_MAC(struct airo_info *ai, int lock); static int enable_MAC(struct airo_info *ai, int lock);
static void disable_MAC(struct airo_info *ai, int lock); static void disable_MAC(struct airo_info *ai, int lock);
...@@ -1127,24 +1127,24 @@ static int PC4500_accessrid(struct airo_info*, u16 rid, u16 accmd); ...@@ -1127,24 +1127,24 @@ static int PC4500_accessrid(struct airo_info*, u16 rid, u16 accmd);
static int PC4500_readrid(struct airo_info*, u16 rid, void *pBuf, int len, int lock); static int PC4500_readrid(struct airo_info*, u16 rid, void *pBuf, int len, int lock);
static int PC4500_writerid(struct airo_info*, u16 rid, const void static int PC4500_writerid(struct airo_info*, u16 rid, const void
*pBuf, int len, int lock); *pBuf, int len, int lock);
static int do_writerid( struct airo_info*, u16 rid, const void *rid_data, static int do_writerid(struct airo_info*, u16 rid, const void *rid_data,
int len, int dummy ); int len, int dummy);
static u16 transmit_allocate(struct airo_info*, int lenPayload, int raw); static u16 transmit_allocate(struct airo_info*, int lenPayload, int raw);
static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket); static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket);
static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket); static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket);
static int mpi_send_packet (struct net_device *dev); static int mpi_send_packet(struct net_device *dev);
static void mpi_unmap_card(struct pci_dev *pci); static void mpi_unmap_card(struct pci_dev *pci);
static void mpi_receive_802_3(struct airo_info *ai); static void mpi_receive_802_3(struct airo_info *ai);
static void mpi_receive_802_11(struct airo_info *ai); static void mpi_receive_802_11(struct airo_info *ai);
static int waitbusy (struct airo_info *ai); static int waitbusy(struct airo_info *ai);
static irqreturn_t airo_interrupt( int irq, void* dev_id); static irqreturn_t airo_interrupt(int irq, void* dev_id);
static int airo_thread(void *data); static int airo_thread(void *data);
static void timer_func( struct net_device *dev ); static void timer_func(struct net_device *dev);
static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static struct iw_statistics *airo_get_wireless_stats (struct net_device *dev); static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev);
static void airo_read_wireless_stats (struct airo_info *local); static void airo_read_wireless_stats(struct airo_info *local);
#ifdef CISCO_EXT #ifdef CISCO_EXT
static int readrids(struct net_device *dev, aironet_ioctl *comp); static int readrids(struct net_device *dev, aironet_ioctl *comp);
static int writerids(struct net_device *dev, aironet_ioctl *comp); static int writerids(struct net_device *dev, aironet_ioctl *comp);
...@@ -1155,8 +1155,8 @@ static int micsetup(struct airo_info *ai); ...@@ -1155,8 +1155,8 @@ static int micsetup(struct airo_info *ai);
static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len); static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len);
static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen); static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen);
static u8 airo_rssi_to_dbm (tdsRssiEntry *rssi_rid, u8 rssi); static u8 airo_rssi_to_dbm(tdsRssiEntry *rssi_rid, u8 rssi);
static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm); static u8 airo_dbm_to_pct(tdsRssiEntry *rssi_rid, u8 dbm);
static void airo_networks_free(struct airo_info *ai); static void airo_networks_free(struct airo_info *ai);
...@@ -1261,16 +1261,16 @@ static inline int bap_read(struct airo_info *ai, __le16 *pu16Dst, int bytelen, ...@@ -1261,16 +1261,16 @@ static inline int bap_read(struct airo_info *ai, __le16 *pu16Dst, int bytelen,
return ai->bap_read(ai, pu16Dst, bytelen, whichbap); return ai->bap_read(ai, pu16Dst, bytelen, whichbap);
} }
static int setup_proc_entry( struct net_device *dev, static int setup_proc_entry(struct net_device *dev,
struct airo_info *apriv ); struct airo_info *apriv);
static int takedown_proc_entry( struct net_device *dev, static int takedown_proc_entry(struct net_device *dev,
struct airo_info *apriv ); struct airo_info *apriv);
static int cmdreset(struct airo_info *ai); static int cmdreset(struct airo_info *ai);
static int setflashmode (struct airo_info *ai); static int setflashmode(struct airo_info *ai);
static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime); static int flashgchar(struct airo_info *ai, int matchbyte, int dwelltime);
static int flashputbuf(struct airo_info *ai); static int flashputbuf(struct airo_info *ai);
static int flashrestart(struct airo_info *ai,struct net_device *dev); static int flashrestart(struct airo_info *ai, struct net_device *dev);
#define airo_print(type, name, fmt, args...) \ #define airo_print(type, name, fmt, args...) \
printk(type DRV_NAME "(%s): " fmt "\n", name, ##args) printk(type DRV_NAME "(%s): " fmt "\n", name, ##args)
...@@ -1294,14 +1294,14 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev); ...@@ -1294,14 +1294,14 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev);
*********************************************************************** ***********************************************************************
*/ */
static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq); static int RxSeqValid(struct airo_info *ai, miccntx *context, int mcast, u32 micSeq);
static void MoveWindow(miccntx *context, u32 micSeq); static void MoveWindow(miccntx *context, u32 micSeq);
static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
struct crypto_sync_skcipher *tfm); struct crypto_sync_skcipher *tfm);
static void emmh32_init(emmh32_context *context); static void emmh32_init(emmh32_context *context);
static void emmh32_update(emmh32_context *context, u8 *pOctets, int len); static void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
static void emmh32_final(emmh32_context *context, u8 digest[4]); static void emmh32_final(emmh32_context *context, u8 digest[4]);
static int flashpchar(struct airo_info *ai,int byte,int dwelltime); static int flashpchar(struct airo_info *ai, int byte, int dwelltime);
static void age_mic_context(miccntx *cur, miccntx *old, u8 *key, int key_len, static void age_mic_context(miccntx *cur, miccntx *old, u8 *key, int key_len,
struct crypto_sync_skcipher *tfm) struct crypto_sync_skcipher *tfm)
...@@ -1361,7 +1361,8 @@ static void micinit(struct airo_info *ai) ...@@ -1361,7 +1361,8 @@ static void micinit(struct airo_info *ai)
/* micsetup - Get ready for business */ /* micsetup - Get ready for business */
static int micsetup(struct airo_info *ai) { static int micsetup(struct airo_info *ai)
{
int i; int i;
if (ai->tfm == NULL) if (ai->tfm == NULL)
...@@ -1373,14 +1374,14 @@ static int micsetup(struct airo_info *ai) { ...@@ -1373,14 +1374,14 @@ static int micsetup(struct airo_info *ai) {
return ERROR; return ERROR;
} }
for (i=0; i < NUM_MODULES; i++) { for (i = 0; i < NUM_MODULES; i++) {
memset(&ai->mod[i].mCtx,0,sizeof(miccntx)); memset(&ai->mod[i].mCtx, 0, sizeof(miccntx));
memset(&ai->mod[i].uCtx,0,sizeof(miccntx)); memset(&ai->mod[i].uCtx, 0, sizeof(miccntx));
} }
return SUCCESS; return SUCCESS;
} }
static const u8 micsnap[] = {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02}; static const u8 micsnap[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x02};
/*=========================================================================== /*===========================================================================
* Description: Mic a packet * Description: Mic a packet
...@@ -1398,7 +1399,7 @@ static const u8 micsnap[] = {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02}; ...@@ -1398,7 +1399,7 @@ static const u8 micsnap[] = {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02};
* Merciless hacks by rwilcher (1/14/02) * Merciless hacks by rwilcher (1/14/02)
*/ */
static int encapsulate(struct airo_info *ai ,etherHead *frame, MICBuffer *mic, int payLen) static int encapsulate(struct airo_info *ai, etherHead *frame, MICBuffer *mic, int payLen)
{ {
miccntx *context; miccntx *context;
...@@ -1422,10 +1423,10 @@ static int encapsulate(struct airo_info *ai ,etherHead *frame, MICBuffer *mic, i ...@@ -1422,10 +1423,10 @@ static int encapsulate(struct airo_info *ai ,etherHead *frame, MICBuffer *mic, i
context->tx += 2; context->tx += 2;
emmh32_init(&context->seed); // Mic the packet emmh32_init(&context->seed); // Mic the packet
emmh32_update(&context->seed,frame->da,ETH_ALEN * 2); // DA,SA emmh32_update(&context->seed, frame->da, ETH_ALEN * 2); // DA, SA
emmh32_update(&context->seed,(u8*)&mic->typelen,10); // Type/Length and Snap emmh32_update(&context->seed, (u8*)&mic->typelen, 10); // Type/Length and Snap
emmh32_update(&context->seed,(u8*)&mic->seq,sizeof(mic->seq)); //SEQ emmh32_update(&context->seed, (u8*)&mic->seq, sizeof(mic->seq)); //SEQ
emmh32_update(&context->seed,(u8*)(frame + 1),payLen); //payload emmh32_update(&context->seed, (u8*)(frame + 1), payLen); //payload
emmh32_final(&context->seed, (u8*)&mic->mic); emmh32_final(&context->seed, (u8*)&mic->mic);
/* New Type/length ?????????? */ /* New Type/length ?????????? */
...@@ -1488,7 +1489,7 @@ static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16 ...@@ -1488,7 +1489,7 @@ static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16
//Now do the mic error checking. //Now do the mic error checking.
//Receive seq must be odd //Receive seq must be odd
if ( (micSEQ & 1) == 0 ) { if ((micSEQ & 1) == 0) {
ai->micstats.rxWrongSequence++; ai->micstats.rxWrongSequence++;
return ERROR; return ERROR;
} }
...@@ -1512,8 +1513,8 @@ static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16 ...@@ -1512,8 +1513,8 @@ static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16
emmh32_init(&context->seed); emmh32_init(&context->seed);
emmh32_update(&context->seed, eth->da, ETH_ALEN*2); emmh32_update(&context->seed, eth->da, ETH_ALEN*2);
emmh32_update(&context->seed, (u8 *)&mic->typelen, sizeof(mic->typelen)+sizeof(mic->u.snap)); emmh32_update(&context->seed, (u8 *)&mic->typelen, sizeof(mic->typelen)+sizeof(mic->u.snap));
emmh32_update(&context->seed, (u8 *)&mic->seq,sizeof(mic->seq)); emmh32_update(&context->seed, (u8 *)&mic->seq, sizeof(mic->seq));
emmh32_update(&context->seed, (u8 *)(eth + 1),payLen); emmh32_update(&context->seed, (u8 *)(eth + 1), payLen);
//Calculate MIC //Calculate MIC
emmh32_final(&context->seed, digest); emmh32_final(&context->seed, digest);
...@@ -1558,9 +1559,9 @@ static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16 ...@@ -1558,9 +1559,9 @@ static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16
*--------------------------------------------------------------------------- *---------------------------------------------------------------------------
*/ */
static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq) static int RxSeqValid(struct airo_info *ai, miccntx *context, int mcast, u32 micSeq)
{ {
u32 seq,index; u32 seq, index;
//Allow for the ap being rebooted - if it is then use the next //Allow for the ap being rebooted - if it is then use the next
//sequence number of the current sequence number - might go backwards //sequence number of the current sequence number - might go backwards
...@@ -1584,9 +1585,9 @@ static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSe ...@@ -1584,9 +1585,9 @@ static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSe
if ((s32)seq < 0) if ((s32)seq < 0)
return ERROR; return ERROR;
if ( seq > 64 ) { if (seq > 64) {
//Window is infinite forward //Window is infinite forward
MoveWindow(context,micSeq); MoveWindow(context, micSeq);
return SUCCESS; return SUCCESS;
} }
...@@ -1599,7 +1600,7 @@ static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSe ...@@ -1599,7 +1600,7 @@ static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSe
//Add seqence number to the list of received numbers. //Add seqence number to the list of received numbers.
context->rx |= index; context->rx |= index;
MoveWindow(context,micSeq); MoveWindow(context, micSeq);
return SUCCESS; return SUCCESS;
} }
...@@ -1750,7 +1751,7 @@ static int readBSSListRid(struct airo_info *ai, int first, ...@@ -1750,7 +1751,7 @@ static int readBSSListRid(struct airo_info *ai, int first,
if (first == 1) { if (first == 1) {
if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN;
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.cmd=CMD_LISTBSS; cmd.cmd = CMD_LISTBSS;
if (down_interruptible(&ai->sem)) if (down_interruptible(&ai->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
ai->list_bss_task = current; ai->list_bss_task = current;
...@@ -1815,7 +1816,7 @@ static inline void checkThrottle(struct airo_info *ai) ...@@ -1815,7 +1816,7 @@ static inline void checkThrottle(struct airo_info *ai)
int i; int i;
/* Old hardware had a limit on encryption speed */ /* Old hardware had a limit on encryption speed */
if (ai->config.authType != AUTH_OPEN && maxencrypt) { if (ai->config.authType != AUTH_OPEN && maxencrypt) {
for(i=0; i<8; i++) { for (i = 0; i<8; i++) {
if (ai->config.rates[i] > maxencrypt) { if (ai->config.rates[i] > maxencrypt) {
ai->config.rates[i] = 0; ai->config.rates[i] = 0;
} }
...@@ -1840,7 +1841,7 @@ static int writeConfigRid(struct airo_info *ai, int lock) ...@@ -1840,7 +1841,7 @@ static int writeConfigRid(struct airo_info *ai, int lock)
else else
clear_bit(FLAG_ADHOC, &ai->flags); clear_bit(FLAG_ADHOC, &ai->flags);
return PC4500_writerid( ai, RID_CONFIG, &cfgr, sizeof(cfgr), lock); return PC4500_writerid(ai, RID_CONFIG, &cfgr, sizeof(cfgr), lock);
} }
static int readStatusRid(struct airo_info *ai, StatusRid *statr, int lock) static int readStatusRid(struct airo_info *ai, StatusRid *statr, int lock)
...@@ -1871,7 +1872,8 @@ static void try_auto_wep(struct airo_info *ai) ...@@ -1871,7 +1872,8 @@ static void try_auto_wep(struct airo_info *ai)
} }
} }
static int airo_open(struct net_device *dev) { static int airo_open(struct net_device *dev)
{
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
int rc = 0; int rc = 0;
...@@ -1947,7 +1949,7 @@ static netdev_tx_t mpi_start_xmit(struct sk_buff *skb, ...@@ -1947,7 +1949,7 @@ static netdev_tx_t mpi_start_xmit(struct sk_buff *skb,
spin_lock_irqsave(&ai->aux_lock, flags); spin_lock_irqsave(&ai->aux_lock, flags);
skb_queue_tail (&ai->txq, skb); skb_queue_tail (&ai->txq, skb);
pending = test_bit(FLAG_PENDING_XMIT, &ai->flags); pending = test_bit(FLAG_PENDING_XMIT, &ai->flags);
spin_unlock_irqrestore(&ai->aux_lock,flags); spin_unlock_irqrestore(&ai->aux_lock, flags);
netif_wake_queue (dev); netif_wake_queue (dev);
if (pending == 0) { if (pending == 0) {
...@@ -2096,7 +2098,8 @@ static void get_tx_error(struct airo_info *ai, s32 fid) ...@@ -2096,7 +2098,8 @@ static void get_tx_error(struct airo_info *ai, s32 fid)
} }
} }
static void airo_end_xmit(struct net_device *dev) { static void airo_end_xmit(struct net_device *dev)
{
u16 status; u16 status;
int i; int i;
struct airo_info *priv = dev->ml_priv; struct airo_info *priv = dev->ml_priv;
...@@ -2110,7 +2113,7 @@ static void airo_end_xmit(struct net_device *dev) { ...@@ -2110,7 +2113,7 @@ static void airo_end_xmit(struct net_device *dev) {
up(&priv->sem); up(&priv->sem);
i = 0; i = 0;
if ( status == SUCCESS ) { if (status == SUCCESS) {
netif_trans_update(dev); netif_trans_update(dev);
for (; i < MAX_FIDS / 2 && (priv->fids[i] & 0xffff0000); i++); for (; i < MAX_FIDS / 2 && (priv->fids[i] & 0xffff0000); i++);
} else { } else {
...@@ -2130,7 +2133,7 @@ static netdev_tx_t airo_start_xmit(struct sk_buff *skb, ...@@ -2130,7 +2133,7 @@ static netdev_tx_t airo_start_xmit(struct sk_buff *skb,
struct airo_info *priv = dev->ml_priv; struct airo_info *priv = dev->ml_priv;
u32 *fids = priv->fids; u32 *fids = priv->fids;
if ( skb == NULL ) { if (skb == NULL) {
airo_print_err(dev->name, "%s: skb == NULL!", __func__); airo_print_err(dev->name, "%s: skb == NULL!", __func__);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -2140,10 +2143,10 @@ static netdev_tx_t airo_start_xmit(struct sk_buff *skb, ...@@ -2140,10 +2143,10 @@ static netdev_tx_t airo_start_xmit(struct sk_buff *skb,
} }
/* Find a vacant FID */ /* Find a vacant FID */
for( i = 0; i < MAX_FIDS / 2 && (fids[i] & 0xffff0000); i++ ); for (i = 0; i < MAX_FIDS / 2 && (fids[i] & 0xffff0000); i++);
for( j = i + 1; j < MAX_FIDS / 2 && (fids[j] & 0xffff0000); j++ ); for (j = i + 1; j < MAX_FIDS / 2 && (fids[j] & 0xffff0000); j++);
if ( j >= MAX_FIDS / 2 ) { if (j >= MAX_FIDS / 2) {
netif_stop_queue(dev); netif_stop_queue(dev);
if (i == MAX_FIDS / 2) { if (i == MAX_FIDS / 2) {
...@@ -2167,7 +2170,8 @@ static netdev_tx_t airo_start_xmit(struct sk_buff *skb, ...@@ -2167,7 +2170,8 @@ static netdev_tx_t airo_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
static void airo_end_xmit11(struct net_device *dev) { static void airo_end_xmit11(struct net_device *dev)
{
u16 status; u16 status;
int i; int i;
struct airo_info *priv = dev->ml_priv; struct airo_info *priv = dev->ml_priv;
...@@ -2181,7 +2185,7 @@ static void airo_end_xmit11(struct net_device *dev) { ...@@ -2181,7 +2185,7 @@ static void airo_end_xmit11(struct net_device *dev) {
up(&priv->sem); up(&priv->sem);
i = MAX_FIDS / 2; i = MAX_FIDS / 2;
if ( status == SUCCESS ) { if (status == SUCCESS) {
netif_trans_update(dev); netif_trans_update(dev);
for (; i < MAX_FIDS && (priv->fids[i] & 0xffff0000); i++); for (; i < MAX_FIDS && (priv->fids[i] & 0xffff0000); i++);
} else { } else {
...@@ -2208,7 +2212,7 @@ static netdev_tx_t airo_start_xmit11(struct sk_buff *skb, ...@@ -2208,7 +2212,7 @@ static netdev_tx_t airo_start_xmit11(struct sk_buff *skb,
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
if ( skb == NULL ) { if (skb == NULL) {
airo_print_err(dev->name, "%s: skb == NULL!", __func__); airo_print_err(dev->name, "%s: skb == NULL!", __func__);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -2218,10 +2222,10 @@ static netdev_tx_t airo_start_xmit11(struct sk_buff *skb, ...@@ -2218,10 +2222,10 @@ static netdev_tx_t airo_start_xmit11(struct sk_buff *skb,
} }
/* Find a vacant FID */ /* Find a vacant FID */
for( i = MAX_FIDS / 2; i < MAX_FIDS && (fids[i] & 0xffff0000); i++ ); for (i = MAX_FIDS / 2; i < MAX_FIDS && (fids[i] & 0xffff0000); i++);
for( j = i + 1; j < MAX_FIDS && (fids[j] & 0xffff0000); j++ ); for (j = i + 1; j < MAX_FIDS && (fids[j] & 0xffff0000); j++);
if ( j >= MAX_FIDS ) { if (j >= MAX_FIDS) {
netif_stop_queue(dev); netif_stop_queue(dev);
if (i == MAX_FIDS) { if (i == MAX_FIDS) {
...@@ -2295,19 +2299,21 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev) ...@@ -2295,19 +2299,21 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev)
return &dev->stats; return &dev->stats;
} }
static void airo_set_promisc(struct airo_info *ai) { static void airo_set_promisc(struct airo_info *ai)
{
Cmd cmd; Cmd cmd;
Resp rsp; Resp rsp;
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.cmd=CMD_SETMODE; cmd.cmd = CMD_SETMODE;
clear_bit(JOB_PROMISC, &ai->jobs); clear_bit(JOB_PROMISC, &ai->jobs);
cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC;
issuecommand(ai, &cmd, &rsp); issuecommand(ai, &cmd, &rsp);
up(&ai->sem); up(&ai->sem);
} }
static void airo_set_multicast_list(struct net_device *dev) { static void airo_set_multicast_list(struct net_device *dev)
{
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
if ((dev->flags ^ ai->flags) & IFF_PROMISC) { if ((dev->flags ^ ai->flags) & IFF_PROMISC) {
...@@ -2357,7 +2363,8 @@ static void del_airo_dev(struct airo_info *ai) ...@@ -2357,7 +2363,8 @@ static void del_airo_dev(struct airo_info *ai)
list_del(&ai->dev_list); list_del(&ai->dev_list);
} }
static int airo_close(struct net_device *dev) { static int airo_close(struct net_device *dev)
{
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
netif_stop_queue(dev); netif_stop_queue(dev);
...@@ -2372,7 +2379,7 @@ static int airo_close(struct net_device *dev) { ...@@ -2372,7 +2379,7 @@ static int airo_close(struct net_device *dev) {
set_bit(FLAG_RADIO_DOWN, &ai->flags); set_bit(FLAG_RADIO_DOWN, &ai->flags);
disable_MAC(ai, 1); disable_MAC(ai, 1);
#endif #endif
disable_interrupts( ai ); disable_interrupts(ai);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
...@@ -2382,16 +2389,16 @@ static int airo_close(struct net_device *dev) { ...@@ -2382,16 +2389,16 @@ static int airo_close(struct net_device *dev) {
return 0; return 0;
} }
void stop_airo_card( struct net_device *dev, int freeres ) void stop_airo_card(struct net_device *dev, int freeres)
{ {
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
set_bit(FLAG_RADIO_DOWN, &ai->flags); set_bit(FLAG_RADIO_DOWN, &ai->flags);
disable_MAC(ai, 1); disable_MAC(ai, 1);
disable_interrupts(ai); disable_interrupts(ai);
takedown_proc_entry( dev, ai ); takedown_proc_entry(dev, ai);
if (test_bit(FLAG_REGISTERED, &ai->flags)) { if (test_bit(FLAG_REGISTERED, &ai->flags)) {
unregister_netdev( dev ); unregister_netdev(dev);
if (ai->wifidev) { if (ai->wifidev) {
unregister_netdev(ai->wifidev); unregister_netdev(ai->wifidev);
free_netdev(ai->wifidev); free_netdev(ai->wifidev);
...@@ -2415,7 +2422,7 @@ void stop_airo_card( struct net_device *dev, int freeres ) ...@@ -2415,7 +2422,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
kfree(ai->SSID); kfree(ai->SSID);
if (freeres) { if (freeres) {
/* PCMCIA frees this stuff, so only for PCI and ISA */ /* PCMCIA frees this stuff, so only for PCI and ISA */
release_region( dev->base_addr, 64 ); release_region(dev->base_addr, 64);
if (test_bit(FLAG_MPI, &ai->flags)) { if (test_bit(FLAG_MPI, &ai->flags)) {
if (ai->pci) if (ai->pci)
mpi_unmap_card(ai->pci); mpi_unmap_card(ai->pci);
...@@ -2429,7 +2436,7 @@ void stop_airo_card( struct net_device *dev, int freeres ) ...@@ -2429,7 +2436,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
} }
crypto_free_sync_skcipher(ai->tfm); crypto_free_sync_skcipher(ai->tfm);
del_airo_dev(ai); del_airo_dev(ai);
free_netdev( dev ); free_netdev(dev);
} }
EXPORT_SYMBOL(stop_airo_card); EXPORT_SYMBOL(stop_airo_card);
...@@ -2468,56 +2475,56 @@ static int mpi_init_descriptors (struct airo_info *ai) ...@@ -2468,56 +2475,56 @@ static int mpi_init_descriptors (struct airo_info *ai)
/* Alloc card RX descriptors */ /* Alloc card RX descriptors */
netif_stop_queue(ai->dev); netif_stop_queue(ai->dev);
memset(&rsp,0,sizeof(rsp)); memset(&rsp, 0, sizeof(rsp));
memset(&cmd,0,sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.cmd = CMD_ALLOCATEAUX; cmd.cmd = CMD_ALLOCATEAUX;
cmd.parm0 = FID_RX; cmd.parm0 = FID_RX;
cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux); cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux);
cmd.parm2 = MPI_MAX_FIDS; cmd.parm2 = MPI_MAX_FIDS;
rc=issuecommand(ai, &cmd, &rsp); rc = issuecommand(ai, &cmd, &rsp);
if (rc != SUCCESS) { if (rc != SUCCESS) {
airo_print_err(ai->dev->name, "Couldn't allocate RX FID"); airo_print_err(ai->dev->name, "Couldn't allocate RX FID");
return rc; return rc;
} }
for (i=0; i<MPI_MAX_FIDS; i++) { for (i = 0; i<MPI_MAX_FIDS; i++) {
memcpy_toio(ai->rxfids[i].card_ram_off, memcpy_toio(ai->rxfids[i].card_ram_off,
&ai->rxfids[i].rx_desc, sizeof(RxFid)); &ai->rxfids[i].rx_desc, sizeof(RxFid));
} }
/* Alloc card TX descriptors */ /* Alloc card TX descriptors */
memset(&rsp,0,sizeof(rsp)); memset(&rsp, 0, sizeof(rsp));
memset(&cmd,0,sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.cmd = CMD_ALLOCATEAUX; cmd.cmd = CMD_ALLOCATEAUX;
cmd.parm0 = FID_TX; cmd.parm0 = FID_TX;
cmd.parm1 = (ai->txfids[0].card_ram_off - ai->pciaux); cmd.parm1 = (ai->txfids[0].card_ram_off - ai->pciaux);
cmd.parm2 = MPI_MAX_FIDS; cmd.parm2 = MPI_MAX_FIDS;
for (i=0; i<MPI_MAX_FIDS; i++) { for (i = 0; i<MPI_MAX_FIDS; i++) {
ai->txfids[i].tx_desc.valid = 1; ai->txfids[i].tx_desc.valid = 1;
memcpy_toio(ai->txfids[i].card_ram_off, memcpy_toio(ai->txfids[i].card_ram_off,
&ai->txfids[i].tx_desc, sizeof(TxFid)); &ai->txfids[i].tx_desc, sizeof(TxFid));
} }
ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */
rc=issuecommand(ai, &cmd, &rsp); rc = issuecommand(ai, &cmd, &rsp);
if (rc != SUCCESS) { if (rc != SUCCESS) {
airo_print_err(ai->dev->name, "Couldn't allocate TX FID"); airo_print_err(ai->dev->name, "Couldn't allocate TX FID");
return rc; return rc;
} }
/* Alloc card Rid descriptor */ /* Alloc card Rid descriptor */
memset(&rsp,0,sizeof(rsp)); memset(&rsp, 0, sizeof(rsp));
memset(&cmd,0,sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.cmd = CMD_ALLOCATEAUX; cmd.cmd = CMD_ALLOCATEAUX;
cmd.parm0 = RID_RW; cmd.parm0 = RID_RW;
cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux); cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux);
cmd.parm2 = 1; /* Magic number... */ cmd.parm2 = 1; /* Magic number... */
rc=issuecommand(ai, &cmd, &rsp); rc = issuecommand(ai, &cmd, &rsp);
if (rc != SUCCESS) { if (rc != SUCCESS) {
airo_print_err(ai->dev->name, "Couldn't allocate RID"); airo_print_err(ai->dev->name, "Couldn't allocate RID");
return rc; return rc;
...@@ -2589,7 +2596,7 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) ...@@ -2589,7 +2596,7 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci)
vpackoff = ai->shared; vpackoff = ai->shared;
/* RX descriptor setup */ /* RX descriptor setup */
for(i = 0; i < MPI_MAX_FIDS; i++) { for (i = 0; i < MPI_MAX_FIDS; i++) {
ai->rxfids[i].pending = 0; ai->rxfids[i].pending = 0;
ai->rxfids[i].card_ram_off = pciaddroff; ai->rxfids[i].card_ram_off = pciaddroff;
ai->rxfids[i].virtual_host_addr = vpackoff; ai->rxfids[i].virtual_host_addr = vpackoff;
...@@ -2604,7 +2611,7 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) ...@@ -2604,7 +2611,7 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci)
} }
/* TX descriptor setup */ /* TX descriptor setup */
for(i = 0; i < MPI_MAX_FIDS; i++) { for (i = 0; i < MPI_MAX_FIDS; i++) {
ai->txfids[i].card_ram_off = pciaddroff; ai->txfids[i].card_ram_off = pciaddroff;
ai->txfids[i].virtual_host_addr = vpackoff; ai->txfids[i].virtual_host_addr = vpackoff;
ai->txfids[i].tx_desc.valid = 1; ai->txfids[i].tx_desc.valid = 1;
...@@ -2703,13 +2710,14 @@ static struct net_device *init_wifidev(struct airo_info *ai, ...@@ -2703,13 +2710,14 @@ static struct net_device *init_wifidev(struct airo_info *ai,
return dev; return dev;
} }
static int reset_card( struct net_device *dev , int lock) { static int reset_card(struct net_device *dev, int lock)
{
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
if (lock && down_interruptible(&ai->sem)) if (lock && down_interruptible(&ai->sem))
return -1; return -1;
waitbusy (ai); waitbusy (ai);
OUT4500(ai,COMMAND,CMD_SOFTRESET); OUT4500(ai, COMMAND, CMD_SOFTRESET);
msleep(200); msleep(200);
waitbusy (ai); waitbusy (ai);
msleep(200); msleep(200);
...@@ -2774,9 +2782,9 @@ static const struct net_device_ops mpi_netdev_ops = { ...@@ -2774,9 +2782,9 @@ static const struct net_device_ops mpi_netdev_ops = {
}; };
static struct net_device *_init_airo_card( unsigned short irq, int port, static struct net_device *_init_airo_card(unsigned short irq, int port,
int is_pcmcia, struct pci_dev *pci, int is_pcmcia, struct pci_dev *pci,
struct device *dmdev ) struct device *dmdev)
{ {
struct net_device *dev; struct net_device *dev;
struct airo_info *ai; struct airo_info *ai;
...@@ -2849,7 +2857,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, ...@@ -2849,7 +2857,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
if (probe) { if (probe) {
if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) { if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) {
airo_print_err(dev->name, "MAC could not be enabled" ); airo_print_err(dev->name, "MAC could not be enabled");
rc = -EIO; rc = -EIO;
goto err_out_map; goto err_out_map;
} }
...@@ -2907,8 +2915,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, ...@@ -2907,8 +2915,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
/* Allocate the transmit buffers */ /* Allocate the transmit buffers */
if (probe && !test_bit(FLAG_MPI,&ai->flags)) if (probe && !test_bit(FLAG_MPI,&ai->flags))
for( i = 0; i < MAX_FIDS; i++ ) for (i = 0; i < MAX_FIDS; i++)
ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2); ai->fids[i] = transmit_allocate(ai, AIRO_DEF_MTU, i>=MAX_FIDS/2);
if (setup_proc_entry(dev, dev->ml_priv) < 0) if (setup_proc_entry(dev, dev->ml_priv) < 0)
goto err_out_wifi; goto err_out_wifi;
...@@ -2929,7 +2937,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, ...@@ -2929,7 +2937,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
} }
err_out_res: err_out_res:
if (!is_pcmcia) if (!is_pcmcia)
release_region( dev->base_addr, 64 ); release_region(dev->base_addr, 64);
err_out_nets: err_out_nets:
airo_networks_free(ai); airo_networks_free(ai);
err_out_free: err_out_free:
...@@ -2938,15 +2946,16 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, ...@@ -2938,15 +2946,16 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
return NULL; return NULL;
} }
struct net_device *init_airo_card( unsigned short irq, int port, int is_pcmcia, struct net_device *init_airo_card(unsigned short irq, int port, int is_pcmcia,
struct device *dmdev) struct device *dmdev)
{ {
return _init_airo_card ( irq, port, is_pcmcia, NULL, dmdev); return _init_airo_card (irq, port, is_pcmcia, NULL, dmdev);
} }
EXPORT_SYMBOL(init_airo_card); EXPORT_SYMBOL(init_airo_card);
static int waitbusy (struct airo_info *ai) { static int waitbusy (struct airo_info *ai)
{
int delay = 0; int delay = 0;
while ((IN4500(ai, COMMAND) & COMMAND_BUSY) && (delay < 10000)) { while ((IN4500(ai, COMMAND) & COMMAND_BUSY) && (delay < 10000)) {
udelay (10); udelay (10);
...@@ -2956,7 +2965,7 @@ static int waitbusy (struct airo_info *ai) { ...@@ -2956,7 +2965,7 @@ static int waitbusy (struct airo_info *ai) {
return delay < 10000; return delay < 10000;
} }
int reset_airo_card( struct net_device *dev ) int reset_airo_card(struct net_device *dev)
{ {
int i; int i;
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
...@@ -2964,24 +2973,25 @@ int reset_airo_card( struct net_device *dev ) ...@@ -2964,24 +2973,25 @@ int reset_airo_card( struct net_device *dev )
if (reset_card (dev, 1)) if (reset_card (dev, 1))
return -1; return -1;
if ( setup_card(ai, dev->dev_addr, 1 ) != SUCCESS ) { if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) {
airo_print_err(dev->name, "MAC could not be enabled"); airo_print_err(dev->name, "MAC could not be enabled");
return -1; return -1;
} }
airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr); airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr);
/* Allocate the transmit buffers if needed */ /* Allocate the transmit buffers if needed */
if (!test_bit(FLAG_MPI,&ai->flags)) if (!test_bit(FLAG_MPI,&ai->flags))
for( i = 0; i < MAX_FIDS; i++ ) for (i = 0; i < MAX_FIDS; i++)
ai->fids[i] = transmit_allocate (ai,AIRO_DEF_MTU,i>=MAX_FIDS/2); ai->fids[i] = transmit_allocate (ai, AIRO_DEF_MTU, i>=MAX_FIDS/2);
enable_interrupts( ai ); enable_interrupts(ai);
netif_wake_queue(dev); netif_wake_queue(dev);
return 0; return 0;
} }
EXPORT_SYMBOL(reset_airo_card); EXPORT_SYMBOL(reset_airo_card);
static void airo_send_event(struct net_device *dev) { static void airo_send_event(struct net_device *dev)
{
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
union iwreq_data wrqu; union iwreq_data wrqu;
StatusRid status_rid; StatusRid status_rid;
...@@ -2998,7 +3008,8 @@ static void airo_send_event(struct net_device *dev) { ...@@ -2998,7 +3008,8 @@ static void airo_send_event(struct net_device *dev) {
wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
} }
static void airo_process_scan_results (struct airo_info *ai) { static void airo_process_scan_results (struct airo_info *ai)
{
union iwreq_data wrqu; union iwreq_data wrqu;
BSSListRid bss; BSSListRid bss;
int rc; int rc;
...@@ -3014,14 +3025,14 @@ static void airo_process_scan_results (struct airo_info *ai) { ...@@ -3014,14 +3025,14 @@ static void airo_process_scan_results (struct airo_info *ai) {
/* Try to read the first entry of the scan result */ /* Try to read the first entry of the scan result */
rc = PC4500_readrid(ai, ai->bssListFirst, &bss, ai->bssListRidLen, 0); rc = PC4500_readrid(ai, ai->bssListFirst, &bss, ai->bssListRidLen, 0);
if((rc) || (bss.index == cpu_to_le16(0xffff))) { if ((rc) || (bss.index == cpu_to_le16(0xffff))) {
/* No scan results */ /* No scan results */
goto out; goto out;
} }
/* Read and parse all entries */ /* Read and parse all entries */
tmp_net = NULL; tmp_net = NULL;
while((!rc) && (bss.index != cpu_to_le16(0xffff))) { while ((!rc) && (bss.index != cpu_to_le16(0xffff))) {
/* Grab a network off the free list */ /* Grab a network off the free list */
if (!list_empty(&ai->network_free_list)) { if (!list_empty(&ai->network_free_list)) {
tmp_net = list_entry(ai->network_free_list.next, tmp_net = list_entry(ai->network_free_list.next,
...@@ -3062,13 +3073,14 @@ static void airo_process_scan_results (struct airo_info *ai) { ...@@ -3062,13 +3073,14 @@ static void airo_process_scan_results (struct airo_info *ai) {
wireless_send_event(ai->dev, SIOCGIWSCAN, &wrqu, NULL); wireless_send_event(ai->dev, SIOCGIWSCAN, &wrqu, NULL);
} }
static int airo_thread(void *data) { static int airo_thread(void *data)
{
struct net_device *dev = data; struct net_device *dev = data;
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
int locked; int locked;
set_freezable(); set_freezable();
while(1) { while (1) {
/* make swsusp happy with our thread */ /* make swsusp happy with our thread */
try_to_freeze(); try_to_freeze();
...@@ -3088,11 +3100,11 @@ static int airo_thread(void *data) { ...@@ -3088,11 +3100,11 @@ static int airo_thread(void *data) {
break; break;
if (ai->expires || ai->scan_timeout) { if (ai->expires || ai->scan_timeout) {
if (ai->scan_timeout && if (ai->scan_timeout &&
time_after_eq(jiffies,ai->scan_timeout)){ time_after_eq(jiffies, ai->scan_timeout)) {
set_bit(JOB_SCAN_RESULTS, &ai->jobs); set_bit(JOB_SCAN_RESULTS, &ai->jobs);
break; break;
} else if (ai->expires && } else if (ai->expires &&
time_after_eq(jiffies,ai->expires)){ time_after_eq(jiffies, ai->expires)) {
set_bit(JOB_AUTOWEP, &ai->jobs); set_bit(JOB_AUTOWEP, &ai->jobs);
break; break;
} }
...@@ -3442,11 +3454,11 @@ static void airo_handle_tx(struct airo_info *ai, u16 status) ...@@ -3442,11 +3454,11 @@ static void airo_handle_tx(struct airo_info *ai, u16 status)
spin_lock_irqsave(&ai->aux_lock, flags); spin_lock_irqsave(&ai->aux_lock, flags);
if (!skb_queue_empty(&ai->txq)) { if (!skb_queue_empty(&ai->txq)) {
spin_unlock_irqrestore(&ai->aux_lock,flags); spin_unlock_irqrestore(&ai->aux_lock, flags);
mpi_send_packet(ai->dev); mpi_send_packet(ai->dev);
} else { } else {
clear_bit(FLAG_PENDING_XMIT, &ai->flags); clear_bit(FLAG_PENDING_XMIT, &ai->flags);
spin_unlock_irqrestore(&ai->aux_lock,flags); spin_unlock_irqrestore(&ai->aux_lock, flags);
netif_wake_queue(ai->dev); netif_wake_queue(ai->dev);
} }
OUT4500(ai, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC)); OUT4500(ai, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC));
...@@ -3526,9 +3538,9 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id) ...@@ -3526,9 +3538,9 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
if (status & (EV_TX | EV_TXCPY | EV_TXEXC)) if (status & (EV_TX | EV_TXCPY | EV_TXEXC))
airo_handle_tx(ai, status); airo_handle_tx(ai, status);
if ( status & ~STATUS_INTS & ~IGNORE_INTS ) { if (status & ~STATUS_INTS & ~IGNORE_INTS) {
airo_print_warn(ai->dev->name, "Got weird status %x", airo_print_warn(ai->dev->name, "Got weird status %x",
status & ~STATUS_INTS & ~IGNORE_INTS ); status & ~STATUS_INTS & ~IGNORE_INTS);
} }
} }
...@@ -3547,27 +3559,29 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id) ...@@ -3547,27 +3559,29 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
* NOTE: If use with 8bit mode and SMP bad things will happen! * NOTE: If use with 8bit mode and SMP bad things will happen!
* Why would some one do 8 bit IO in an SMP machine?!? * Why would some one do 8 bit IO in an SMP machine?!?
*/ */
static void OUT4500( struct airo_info *ai, u16 reg, u16 val ) { static void OUT4500(struct airo_info *ai, u16 reg, u16 val)
{
if (test_bit(FLAG_MPI,&ai->flags)) if (test_bit(FLAG_MPI,&ai->flags))
reg <<= 1; reg <<= 1;
if ( !do8bitIO ) if (!do8bitIO)
outw( val, ai->dev->base_addr + reg ); outw(val, ai->dev->base_addr + reg);
else { else {
outb( val & 0xff, ai->dev->base_addr + reg ); outb(val & 0xff, ai->dev->base_addr + reg);
outb( val >> 8, ai->dev->base_addr + reg + 1 ); outb(val >> 8, ai->dev->base_addr + reg + 1);
} }
} }
static u16 IN4500( struct airo_info *ai, u16 reg ) { static u16 IN4500(struct airo_info *ai, u16 reg)
{
unsigned short rc; unsigned short rc;
if (test_bit(FLAG_MPI,&ai->flags)) if (test_bit(FLAG_MPI,&ai->flags))
reg <<= 1; reg <<= 1;
if ( !do8bitIO ) if (!do8bitIO)
rc = inw( ai->dev->base_addr + reg ); rc = inw(ai->dev->base_addr + reg);
else { else {
rc = inb( ai->dev->base_addr + reg ); rc = inb(ai->dev->base_addr + reg);
rc += ((int)inb( ai->dev->base_addr + reg + 1 )) << 8; rc += ((int)inb(ai->dev->base_addr + reg + 1)) << 8;
} }
return rc; return rc;
} }
...@@ -3611,7 +3625,8 @@ static int enable_MAC(struct airo_info *ai, int lock) ...@@ -3611,7 +3625,8 @@ static int enable_MAC(struct airo_info *ai, int lock)
return rc; return rc;
} }
static void disable_MAC( struct airo_info *ai, int lock ) { static void disable_MAC(struct airo_info *ai, int lock)
{
Cmd cmd; Cmd cmd;
Resp rsp; Resp rsp;
...@@ -3630,13 +3645,15 @@ static void disable_MAC( struct airo_info *ai, int lock ) { ...@@ -3630,13 +3645,15 @@ static void disable_MAC( struct airo_info *ai, int lock ) {
up(&ai->sem); up(&ai->sem);
} }
static void enable_interrupts( struct airo_info *ai ) { static void enable_interrupts(struct airo_info *ai)
{
/* Enable the interrupts */ /* Enable the interrupts */
OUT4500( ai, EVINTEN, STATUS_INTS ); OUT4500(ai, EVINTEN, STATUS_INTS);
} }
static void disable_interrupts( struct airo_info *ai ) { static void disable_interrupts(struct airo_info *ai)
OUT4500( ai, EVINTEN, 0 ); {
OUT4500(ai, EVINTEN, 0);
} }
static void mpi_receive_802_3(struct airo_info *ai) static void mpi_receive_802_3(struct airo_info *ai)
...@@ -3660,7 +3677,7 @@ static void mpi_receive_802_3(struct airo_info *ai) ...@@ -3660,7 +3677,7 @@ static void mpi_receive_802_3(struct airo_info *ai)
ai->dev->stats.rx_dropped++; ai->dev->stats.rx_dropped++;
goto badrx; goto badrx;
} }
buffer = skb_put(skb,len); buffer = skb_put(skb, len);
memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2); memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2);
if (ai->micstats.enabled) { if (ai->micstats.enabled) {
memcpy(&micbuf, memcpy(&micbuf,
...@@ -3739,8 +3756,8 @@ static void mpi_receive_802_11(struct airo_info *ai) ...@@ -3739,8 +3756,8 @@ static void mpi_receive_802_11(struct airo_info *ai)
fc = get_unaligned((__le16 *)ptr); fc = get_unaligned((__le16 *)ptr);
hdrlen = header_len(fc); hdrlen = header_len(fc);
skb = dev_alloc_skb( len + hdrlen + 2 ); skb = dev_alloc_skb(len + hdrlen + 2);
if ( !skb ) { if (!skb) {
ai->dev->stats.rx_dropped++; ai->dev->stats.rx_dropped++;
goto badrx; goto badrx;
} }
...@@ -3784,7 +3801,7 @@ static void mpi_receive_802_11(struct airo_info *ai) ...@@ -3784,7 +3801,7 @@ static void mpi_receive_802_11(struct airo_info *ai)
skb->dev = ai->wifidev; skb->dev = ai->wifidev;
skb->protocol = htons(ETH_P_802_2); skb->protocol = htons(ETH_P_802_2);
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
netif_rx( skb ); netif_rx(skb);
badrx: badrx:
if (rxd.valid == 0) { if (rxd.valid == 0) {
...@@ -3815,7 +3832,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3815,7 +3832,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
WepKeyRid wkr; WepKeyRid wkr;
int rc; int rc;
memset( &mySsid, 0, sizeof( mySsid ) ); memset(&mySsid, 0, sizeof(mySsid));
kfree (ai->flash); kfree (ai->flash);
ai->flash = NULL; ai->flash = NULL;
...@@ -3824,12 +3841,12 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3824,12 +3841,12 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
cmd.parm0 = cmd.parm1 = cmd.parm2 = 0; cmd.parm0 = cmd.parm1 = cmd.parm2 = 0;
if (lock && down_interruptible(&ai->sem)) if (lock && down_interruptible(&ai->sem))
return ERROR; return ERROR;
if ( issuecommand( ai, &cmd, &rsp ) != SUCCESS ) { if (issuecommand(ai, &cmd, &rsp) != SUCCESS) {
if (lock) if (lock)
up(&ai->sem); up(&ai->sem);
return ERROR; return ERROR;
} }
disable_MAC( ai, 0); disable_MAC(ai, 0);
// Let's figure out if we need to use the AUX port // Let's figure out if we need to use the AUX port
if (!test_bit(FLAG_MPI,&ai->flags)) { if (!test_bit(FLAG_MPI,&ai->flags)) {
...@@ -3859,13 +3876,13 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3859,13 +3876,13 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
ai->SSID = NULL; ai->SSID = NULL;
// general configuration (read/modify/write) // general configuration (read/modify/write)
status = readConfigRid(ai, lock); status = readConfigRid(ai, lock);
if ( status != SUCCESS ) return ERROR; if (status != SUCCESS) return ERROR;
status = readCapabilityRid(ai, &cap_rid, lock); status = readCapabilityRid(ai, &cap_rid, lock);
if ( status != SUCCESS ) return ERROR; if (status != SUCCESS) return ERROR;
status = PC4500_readrid(ai,RID_RSSI,&rssi_rid,sizeof(rssi_rid),lock); status = PC4500_readrid(ai, RID_RSSI,&rssi_rid, sizeof(rssi_rid), lock);
if ( status == SUCCESS ) { if (status == SUCCESS) {
if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL) if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL)
memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */ memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */
} }
...@@ -3890,15 +3907,15 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3890,15 +3907,15 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
} }
/* Save off the MAC */ /* Save off the MAC */
for( i = 0; i < ETH_ALEN; i++ ) { for (i = 0; i < ETH_ALEN; i++) {
mac[i] = ai->config.macAddr[i]; mac[i] = ai->config.macAddr[i];
} }
/* Check to see if there are any insmod configured /* Check to see if there are any insmod configured
rates to add */ rates to add */
if ( rates[0] ) { if (rates[0]) {
memset(ai->config.rates,0,sizeof(ai->config.rates)); memset(ai->config.rates, 0, sizeof(ai->config.rates));
for( i = 0; i < 8 && rates[i]; i++ ) { for (i = 0; i < 8 && rates[i]; i++) {
ai->config.rates[i] = rates[i]; ai->config.rates[i] = rates[i];
} }
} }
...@@ -3906,9 +3923,9 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3906,9 +3923,9 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
} }
/* Setup the SSIDs if present */ /* Setup the SSIDs if present */
if ( ssids[0] ) { if (ssids[0]) {
int i; int i;
for( i = 0; i < 3 && ssids[i]; i++ ) { for (i = 0; i < 3 && ssids[i]; i++) {
size_t len = strlen(ssids[i]); size_t len = strlen(ssids[i]);
if (len > 32) if (len > 32)
len = 32; len = 32;
...@@ -3919,12 +3936,12 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3919,12 +3936,12 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
} }
status = writeConfigRid(ai, lock); status = writeConfigRid(ai, lock);
if ( status != SUCCESS ) return ERROR; if (status != SUCCESS) return ERROR;
/* Set up the SSID list */ /* Set up the SSID list */
if ( ssids[0] ) { if (ssids[0]) {
status = writeSsidRid(ai, &mySsid, lock); status = writeSsidRid(ai, &mySsid, lock);
if ( status != SUCCESS ) return ERROR; if (status != SUCCESS) return ERROR;
} }
status = enable_MAC(ai, lock); status = enable_MAC(ai, lock);
...@@ -3939,14 +3956,15 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3939,14 +3956,15 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
ai->defindex = wkr.mac[0]; ai->defindex = wkr.mac[0];
} }
rc = readWepKeyRid(ai, &wkr, 0, lock); rc = readWepKeyRid(ai, &wkr, 0, lock);
} while(lastindex != wkr.kindex); } while (lastindex != wkr.kindex);
try_auto_wep(ai); try_auto_wep(ai);
return SUCCESS; return SUCCESS;
} }
static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) { static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp)
{
// Im really paranoid about letting it run forever! // Im really paranoid about letting it run forever!
int max_tries = 600000; int max_tries = 600000;
...@@ -3966,7 +3984,7 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) { ...@@ -3966,7 +3984,7 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) {
schedule(); schedule();
} }
if ( max_tries == -1 ) { if (max_tries == -1) {
airo_print_err(ai->dev->name, airo_print_err(ai->dev->name,
"Max tries exceeded when issuing command"); "Max tries exceeded when issuing command");
if (IN4500(ai, COMMAND) & COMMAND_BUSY) if (IN4500(ai, COMMAND) & COMMAND_BUSY)
...@@ -3998,7 +4016,7 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) { ...@@ -3998,7 +4016,7 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) {
/* Sets up the bap to start exchange data. whichbap should /* Sets up the bap to start exchange data. whichbap should
* be one of the BAP0 or BAP1 defines. Locks should be held before * be one of the BAP0 or BAP1 defines. Locks should be held before
* calling! */ * calling! */
static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap ) static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap)
{ {
int timeout = 50; int timeout = 50;
int max_tries = 3; int max_tries = 3;
...@@ -4013,15 +4031,15 @@ static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap ) ...@@ -4013,15 +4031,15 @@ static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap )
if (timeout--) { if (timeout--) {
continue; continue;
} }
} else if ( status & BAP_ERR ) { } else if (status & BAP_ERR) {
/* invalid rid or offset */ /* invalid rid or offset */
airo_print_err(ai->dev->name, "BAP error %x %d", airo_print_err(ai->dev->name, "BAP error %x %d",
status, whichbap ); status, whichbap);
return ERROR; return ERROR;
} else if (status & BAP_DONE) { // success } else if (status & BAP_DONE) { // success
return SUCCESS; return SUCCESS;
} }
if ( !(max_tries--) ) { if (!(max_tries--)) {
airo_print_err(ai->dev->name, airo_print_err(ai->dev->name,
"BAP setup error too many retries\n"); "BAP setup error too many retries\n");
return ERROR; return ERROR;
...@@ -4067,15 +4085,15 @@ static int aux_bap_read(struct airo_info *ai, __le16 *pu16Dst, ...@@ -4067,15 +4085,15 @@ static int aux_bap_read(struct airo_info *ai, __le16 *pu16Dst,
next = aux_setup(ai, page, offset, &len); next = aux_setup(ai, page, offset, &len);
words = (bytelen+1)>>1; words = (bytelen+1)>>1;
for (i=0; i<words;) { for (i = 0; i<words;) {
int count; int count;
count = (len>>1) < (words-i) ? (len>>1) : (words-i); count = (len>>1) < (words-i) ? (len>>1) : (words-i);
if ( !do8bitIO ) if (!do8bitIO)
insw( ai->dev->base_addr+DATA0+whichbap, insw(ai->dev->base_addr+DATA0+whichbap,
pu16Dst+i,count ); pu16Dst+i, count);
else else
insb( ai->dev->base_addr+DATA0+whichbap, insb(ai->dev->base_addr+DATA0+whichbap,
pu16Dst+i, count << 1 ); pu16Dst+i, count << 1);
i += count; i += count;
if (i<words) { if (i<words) {
next = aux_setup(ai, next, 4, &len); next = aux_setup(ai, next, 4, &len);
...@@ -4091,10 +4109,10 @@ static int fast_bap_read(struct airo_info *ai, __le16 *pu16Dst, ...@@ -4091,10 +4109,10 @@ static int fast_bap_read(struct airo_info *ai, __le16 *pu16Dst,
int bytelen, int whichbap) int bytelen, int whichbap)
{ {
bytelen = (bytelen + 1) & (~1); // round up to even value bytelen = (bytelen + 1) & (~1); // round up to even value
if ( !do8bitIO ) if (!do8bitIO)
insw( ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen>>1 ); insw(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen>>1);
else else
insb( ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen ); insb(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen);
return SUCCESS; return SUCCESS;
} }
...@@ -4103,11 +4121,11 @@ static int bap_write(struct airo_info *ai, const __le16 *pu16Src, ...@@ -4103,11 +4121,11 @@ static int bap_write(struct airo_info *ai, const __le16 *pu16Src,
int bytelen, int whichbap) int bytelen, int whichbap)
{ {
bytelen = (bytelen + 1) & (~1); // round up to even value bytelen = (bytelen + 1) & (~1); // round up to even value
if ( !do8bitIO ) if (!do8bitIO)
outsw( ai->dev->base_addr+DATA0+whichbap, outsw(ai->dev->base_addr+DATA0+whichbap,
pu16Src, bytelen>>1 ); pu16Src, bytelen>>1);
else else
outsb( ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen ); outsb(ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen);
return SUCCESS; return SUCCESS;
} }
...@@ -4122,7 +4140,7 @@ static int PC4500_accessrid(struct airo_info *ai, u16 rid, u16 accmd) ...@@ -4122,7 +4140,7 @@ static int PC4500_accessrid(struct airo_info *ai, u16 rid, u16 accmd)
cmd.parm0 = rid; cmd.parm0 = rid;
status = issuecommand(ai, &cmd, &rsp); status = issuecommand(ai, &cmd, &rsp);
if (status != 0) return status; if (status != 0) return status;
if ( (rsp.status & 0x7F00) != 0) { if ((rsp.status & 0x7F00) != 0) {
return (accmd << 8) + (rsp.rsp0 & 0xFF); return (accmd << 8) + (rsp.rsp0 & 0xFF);
} }
return 0; return 0;
...@@ -4177,10 +4195,10 @@ static int PC4500_readrid(struct airo_info *ai, u16 rid, void *pBuf, int len, in ...@@ -4177,10 +4195,10 @@ static int PC4500_readrid(struct airo_info *ai, u16 rid, void *pBuf, int len, in
// length for remaining part of rid // length for remaining part of rid
len = min(len, (int)le16_to_cpu(*(__le16*)pBuf)) - 2; len = min(len, (int)le16_to_cpu(*(__le16*)pBuf)) - 2;
if ( len <= 2 ) { if (len <= 2) {
airo_print_err(ai->dev->name, airo_print_err(ai->dev->name,
"Rid %x has a length of %d which is too short", "Rid %x has a length of %d which is too short",
(int)rid, (int)len ); (int)rid, (int)len);
rc = ERROR; rc = ERROR;
goto done; goto done;
} }
...@@ -4248,7 +4266,7 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid, ...@@ -4248,7 +4266,7 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid,
} }
} else { } else {
// --- first access so that we can write the rid data // --- first access so that we can write the rid data
if ( (status = PC4500_accessrid(ai, rid, CMD_ACCESS)) != 0) { if ((status = PC4500_accessrid(ai, rid, CMD_ACCESS)) != 0) {
rc = status; rc = status;
goto done; goto done;
} }
...@@ -4285,7 +4303,7 @@ static u16 transmit_allocate(struct airo_info *ai, int lenPayload, int raw) ...@@ -4285,7 +4303,7 @@ static u16 transmit_allocate(struct airo_info *ai, int lenPayload, int raw)
txFid = ERROR; txFid = ERROR;
goto done; goto done;
} }
if ( (rsp.status & 0xFF00) != 0) { if ((rsp.status & 0xFF00) != 0) {
txFid = ERROR; txFid = ERROR;
goto done; goto done;
} }
...@@ -4346,7 +4364,7 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket) ...@@ -4346,7 +4364,7 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket)
if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled &&
(ntohs(((__be16 *)pPacket)[6]) != 0x888E)) { (ntohs(((__be16 *)pPacket)[6]) != 0x888E)) {
if (encapsulate(ai,(etherHead *)pPacket,&pMic,len) != SUCCESS) if (encapsulate(ai, (etherHead *)pPacket,&pMic, len) != SUCCESS)
return ERROR; return ERROR;
miclen = sizeof(pMic); miclen = sizeof(pMic);
} }
...@@ -4356,17 +4374,17 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket) ...@@ -4356,17 +4374,17 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket)
/* The hardware addresses aren't counted as part of the payload, so /* The hardware addresses aren't counted as part of the payload, so
* we have to subtract the 12 bytes for the addresses off */ * we have to subtract the 12 bytes for the addresses off */
payloadLen = cpu_to_le16(len + miclen); payloadLen = cpu_to_le16(len + miclen);
bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1); bap_write(ai, &payloadLen, sizeof(payloadLen), BAP1);
bap_write(ai, (__le16*)pPacket, sizeof(etherHead), BAP1); bap_write(ai, (__le16*)pPacket, sizeof(etherHead), BAP1);
if (miclen) if (miclen)
bap_write(ai, (__le16*)&pMic, miclen, BAP1); bap_write(ai, (__le16*)&pMic, miclen, BAP1);
bap_write(ai, (__le16*)(pPacket + sizeof(etherHead)), len, BAP1); bap_write(ai, (__le16*)(pPacket + sizeof(etherHead)), len, BAP1);
// issue the transmit command // issue the transmit command
memset( &cmd, 0, sizeof( cmd ) ); memset(&cmd, 0, sizeof(cmd));
cmd.cmd = CMD_TRANSMIT; cmd.cmd = CMD_TRANSMIT;
cmd.parm0 = txFid; cmd.parm0 = txFid;
if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR; if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR;
if ( (rsp.status & 0xFF00) != 0) return ERROR; if ((rsp.status & 0xFF00) != 0) return ERROR;
return SUCCESS; return SUCCESS;
} }
...@@ -4395,18 +4413,18 @@ static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket) ...@@ -4395,18 +4413,18 @@ static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket)
/* The 802.11 header aren't counted as part of the payload, so /* The 802.11 header aren't counted as part of the payload, so
* we have to subtract the header bytes off */ * we have to subtract the header bytes off */
payloadLen = cpu_to_le16(len-hdrlen); payloadLen = cpu_to_le16(len-hdrlen);
bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1); bap_write(ai, &payloadLen, sizeof(payloadLen), BAP1);
if (bap_setup(ai, txFid, 0x0014, BAP1) != SUCCESS) return ERROR; if (bap_setup(ai, txFid, 0x0014, BAP1) != SUCCESS) return ERROR;
bap_write(ai, (__le16 *)pPacket, hdrlen, BAP1); bap_write(ai, (__le16 *)pPacket, hdrlen, BAP1);
bap_write(ai, (__le16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1); bap_write(ai, (__le16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1);
bap_write(ai, (__le16 *)(pPacket + hdrlen), len - hdrlen, BAP1); bap_write(ai, (__le16 *)(pPacket + hdrlen), len - hdrlen, BAP1);
// issue the transmit command // issue the transmit command
memset( &cmd, 0, sizeof( cmd ) ); memset(&cmd, 0, sizeof(cmd));
cmd.cmd = CMD_TRANSMIT; cmd.cmd = CMD_TRANSMIT;
cmd.parm0 = txFid; cmd.parm0 = txFid;
if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR; if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR;
if ( (rsp.status & 0xFF00) != 0) return ERROR; if ((rsp.status & 0xFF00) != 0) return ERROR;
return SUCCESS; return SUCCESS;
} }
...@@ -4415,25 +4433,25 @@ static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket) ...@@ -4415,25 +4433,25 @@ static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket)
* like! Feel free to clean it up! * like! Feel free to clean it up!
*/ */
static ssize_t proc_read( struct file *file, static ssize_t proc_read(struct file *file,
char __user *buffer, char __user *buffer,
size_t len, size_t len,
loff_t *offset); loff_t *offset);
static ssize_t proc_write( struct file *file, static ssize_t proc_write(struct file *file,
const char __user *buffer, const char __user *buffer,
size_t len, size_t len,
loff_t *offset ); loff_t *offset);
static int proc_close( struct inode *inode, struct file *file ); static int proc_close(struct inode *inode, struct file *file);
static int proc_stats_open( struct inode *inode, struct file *file ); static int proc_stats_open(struct inode *inode, struct file *file);
static int proc_statsdelta_open( struct inode *inode, struct file *file ); static int proc_statsdelta_open(struct inode *inode, struct file *file);
static int proc_status_open( struct inode *inode, struct file *file ); static int proc_status_open(struct inode *inode, struct file *file);
static int proc_SSID_open( struct inode *inode, struct file *file ); static int proc_SSID_open(struct inode *inode, struct file *file);
static int proc_APList_open( struct inode *inode, struct file *file ); static int proc_APList_open(struct inode *inode, struct file *file);
static int proc_BSSList_open( struct inode *inode, struct file *file ); static int proc_BSSList_open(struct inode *inode, struct file *file);
static int proc_config_open( struct inode *inode, struct file *file ); static int proc_config_open(struct inode *inode, struct file *file);
static int proc_wepkey_open( struct inode *inode, struct file *file ); static int proc_wepkey_open(struct inode *inode, struct file *file);
static const struct proc_ops proc_statsdelta_ops = { static const struct proc_ops proc_statsdelta_ops = {
.proc_read = proc_read, .proc_read = proc_read,
...@@ -4508,12 +4526,13 @@ struct proc_data { ...@@ -4508,12 +4526,13 @@ struct proc_data {
void (*on_close) (struct inode *, struct file *); void (*on_close) (struct inode *, struct file *);
}; };
static int setup_proc_entry( struct net_device *dev, static int setup_proc_entry(struct net_device *dev,
struct airo_info *apriv ) { struct airo_info *apriv)
{
struct proc_dir_entry *entry; struct proc_dir_entry *entry;
/* First setup the device directory */ /* First setup the device directory */
strcpy(apriv->proc_name,dev->name); strcpy(apriv->proc_name, dev->name);
apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm, apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm,
airo_entry); airo_entry);
if (!apriv->proc_entry) if (!apriv->proc_entry)
...@@ -4582,8 +4601,8 @@ static int setup_proc_entry( struct net_device *dev, ...@@ -4582,8 +4601,8 @@ static int setup_proc_entry( struct net_device *dev,
return -ENOMEM; return -ENOMEM;
} }
static int takedown_proc_entry( struct net_device *dev, static int takedown_proc_entry(struct net_device *dev,
struct airo_info *apriv ) struct airo_info *apriv)
{ {
remove_proc_subtree(apriv->proc_name, airo_entry); remove_proc_subtree(apriv->proc_name, airo_entry);
return 0; return 0;
...@@ -4601,10 +4620,10 @@ static int takedown_proc_entry( struct net_device *dev, ...@@ -4601,10 +4620,10 @@ static int takedown_proc_entry( struct net_device *dev,
* The read routine is generic, it relies on the preallocated rbuffer * The read routine is generic, it relies on the preallocated rbuffer
* to supply the data. * to supply the data.
*/ */
static ssize_t proc_read( struct file *file, static ssize_t proc_read(struct file *file,
char __user *buffer, char __user *buffer,
size_t len, size_t len,
loff_t *offset ) loff_t *offset)
{ {
struct proc_data *priv = file->private_data; struct proc_data *priv = file->private_data;
...@@ -4619,10 +4638,10 @@ static ssize_t proc_read( struct file *file, ...@@ -4619,10 +4638,10 @@ static ssize_t proc_read( struct file *file,
* The write routine is generic, it fills in a preallocated rbuffer * The write routine is generic, it fills in a preallocated rbuffer
* to supply the data. * to supply the data.
*/ */
static ssize_t proc_write( struct file *file, static ssize_t proc_write(struct file *file,
const char __user *buffer, const char __user *buffer,
size_t len, size_t len,
loff_t *offset ) loff_t *offset)
{ {
ssize_t ret; ssize_t ret;
struct proc_data *priv = file->private_data; struct proc_data *priv = file->private_data;
...@@ -4648,10 +4667,10 @@ static int proc_status_open(struct inode *inode, struct file *file) ...@@ -4648,10 +4667,10 @@ static int proc_status_open(struct inode *inode, struct file *file)
u16 mode; u16 mode;
int i; int i;
if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
data = file->private_data; data = file->private_data;
if ((data->rbuffer = kmalloc( 2048, GFP_KERNEL )) == NULL) { if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) {
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
} }
...@@ -4671,7 +4690,7 @@ static int proc_status_open(struct inode *inode, struct file *file) ...@@ -4671,7 +4690,7 @@ static int proc_status_open(struct inode *inode, struct file *file)
mode & 0x100 ? "KEY ": "", mode & 0x100 ? "KEY ": "",
mode & 0x200 ? "WEP ": "", mode & 0x200 ? "WEP ": "",
mode & 0x8000 ? "ERR ": ""); mode & 0x8000 ? "ERR ": "");
sprintf( data->rbuffer+i, "Mode: %x\n" sprintf(data->rbuffer+i, "Mode: %x\n"
"Signal Strength: %d\n" "Signal Strength: %d\n"
"Signal Quality: %d\n" "Signal Quality: %d\n"
"SSID: %-.*s\n" "SSID: %-.*s\n"
...@@ -4701,26 +4720,28 @@ static int proc_status_open(struct inode *inode, struct file *file) ...@@ -4701,26 +4720,28 @@ static int proc_status_open(struct inode *inode, struct file *file)
le16_to_cpu(cap_rid.softVer), le16_to_cpu(cap_rid.softVer),
le16_to_cpu(cap_rid.softSubVer), le16_to_cpu(cap_rid.softSubVer),
le16_to_cpu(cap_rid.bootBlockVer)); le16_to_cpu(cap_rid.bootBlockVer));
data->readlen = strlen( data->rbuffer ); data->readlen = strlen(data->rbuffer);
return 0; return 0;
} }
static int proc_stats_rid_open(struct inode*, struct file*, u16); static int proc_stats_rid_open(struct inode*, struct file*, u16);
static int proc_statsdelta_open( struct inode *inode, static int proc_statsdelta_open(struct inode *inode,
struct file *file ) { struct file *file)
{
if (file->f_mode&FMODE_WRITE) { if (file->f_mode&FMODE_WRITE) {
return proc_stats_rid_open(inode, file, RID_STATSDELTACLEAR); return proc_stats_rid_open(inode, file, RID_STATSDELTACLEAR);
} }
return proc_stats_rid_open(inode, file, RID_STATSDELTA); return proc_stats_rid_open(inode, file, RID_STATSDELTA);
} }
static int proc_stats_open( struct inode *inode, struct file *file ) { static int proc_stats_open(struct inode *inode, struct file *file)
{
return proc_stats_rid_open(inode, file, RID_STATS); return proc_stats_rid_open(inode, file, RID_STATS);
} }
static int proc_stats_rid_open( struct inode *inode, static int proc_stats_rid_open(struct inode *inode,
struct file *file, struct file *file,
u16 rid ) u16 rid)
{ {
struct proc_data *data; struct proc_data *data;
struct net_device *dev = PDE_DATA(inode); struct net_device *dev = PDE_DATA(inode);
...@@ -4730,10 +4751,10 @@ static int proc_stats_rid_open( struct inode *inode, ...@@ -4730,10 +4751,10 @@ static int proc_stats_rid_open( struct inode *inode,
__le32 *vals = stats.vals; __le32 *vals = stats.vals;
int len; int len;
if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
data = file->private_data; data = file->private_data;
if ((data->rbuffer = kmalloc( 4096, GFP_KERNEL )) == NULL) { if ((data->rbuffer = kmalloc(4096, GFP_KERNEL)) == NULL) {
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
} }
...@@ -4742,7 +4763,7 @@ static int proc_stats_rid_open( struct inode *inode, ...@@ -4742,7 +4763,7 @@ static int proc_stats_rid_open( struct inode *inode,
len = le16_to_cpu(stats.len); len = le16_to_cpu(stats.len);
j = 0; j = 0;
for(i=0; statsLabels[i]!=(char *)-1 && i*4<len; i++) { for (i = 0; statsLabels[i]!=(char *)-1 && i*4<len; i++) {
if (!statsLabels[i]) continue; if (!statsLabels[i]) continue;
if (j+strlen(statsLabels[i])+16>4096) { if (j+strlen(statsLabels[i])+16>4096) {
airo_print_warn(apriv->dev->name, airo_print_warn(apriv->dev->name,
...@@ -4759,7 +4780,8 @@ static int proc_stats_rid_open( struct inode *inode, ...@@ -4759,7 +4780,8 @@ static int proc_stats_rid_open( struct inode *inode,
return 0; return 0;
} }
static int get_dec_u16( char *buffer, int *start, int limit ) { static int get_dec_u16(char *buffer, int *start, int limit)
{
u16 value; u16 value;
int valid = 0; int valid = 0;
for (value = 0; *start < limit && buffer[*start] >= '0' && for (value = 0; *start < limit && buffer[*start] >= '0' &&
...@@ -4768,7 +4790,7 @@ static int get_dec_u16( char *buffer, int *start, int limit ) { ...@@ -4768,7 +4790,7 @@ static int get_dec_u16( char *buffer, int *start, int limit ) {
value *= 10; value *= 10;
value += buffer[*start] - '0'; value += buffer[*start] - '0';
} }
if ( !valid ) return -1; if (!valid) return -1;
return value; return value;
} }
...@@ -4789,15 +4811,15 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4789,15 +4811,15 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
char *line; char *line;
if ( !data->writelen ) return; if (!data->writelen) return;
readConfigRid(ai, 1); readConfigRid(ai, 1);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
line = data->wbuffer; line = data->wbuffer;
while( line[0] ) { while (line[0]) {
/*** Mode processing */ /*** Mode processing */
if ( !strncmp( line, "Mode: ", 6 ) ) { if (!strncmp(line, "Mode: ", 6)) {
line += 6; line += 6;
if (sniffing_mode(ai)) if (sniffing_mode(ai))
set_bit (FLAG_RESET, &ai->flags); set_bit (FLAG_RESET, &ai->flags);
...@@ -4805,19 +4827,19 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4805,19 +4827,19 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
clear_bit (FLAG_802_11, &ai->flags); clear_bit (FLAG_802_11, &ai->flags);
ai->config.opmode &= ~MODE_CFG_MASK; ai->config.opmode &= ~MODE_CFG_MASK;
ai->config.scanMode = SCANMODE_ACTIVE; ai->config.scanMode = SCANMODE_ACTIVE;
if ( line[0] == 'a' ) { if (line[0] == 'a') {
ai->config.opmode |= MODE_STA_IBSS; ai->config.opmode |= MODE_STA_IBSS;
} else { } else {
ai->config.opmode |= MODE_STA_ESS; ai->config.opmode |= MODE_STA_ESS;
if ( line[0] == 'r' ) { if (line[0] == 'r') {
ai->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER; ai->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER;
ai->config.scanMode = SCANMODE_PASSIVE; ai->config.scanMode = SCANMODE_PASSIVE;
set_bit (FLAG_802_11, &ai->flags); set_bit (FLAG_802_11, &ai->flags);
} else if ( line[0] == 'y' ) { } else if (line[0] == 'y') {
ai->config.rmode |= RXMODE_RFMON_ANYBSS | RXMODE_DISABLE_802_3_HEADER; ai->config.rmode |= RXMODE_RFMON_ANYBSS | RXMODE_DISABLE_802_3_HEADER;
ai->config.scanMode = SCANMODE_PASSIVE; ai->config.scanMode = SCANMODE_PASSIVE;
set_bit (FLAG_802_11, &ai->flags); set_bit (FLAG_802_11, &ai->flags);
} else if ( line[0] == 'l' ) } else if (line[0] == 'l')
ai->config.rmode |= RXMODE_LANMON; ai->config.rmode |= RXMODE_LANMON;
} }
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
...@@ -4826,68 +4848,68 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4826,68 +4848,68 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
/*** Radio status */ /*** Radio status */
else if (!strncmp(line,"Radio: ", 7)) { else if (!strncmp(line,"Radio: ", 7)) {
line += 7; line += 7;
if (!strncmp(line,"off",3)) { if (!strncmp(line,"off", 3)) {
set_bit (FLAG_RADIO_OFF, &ai->flags); set_bit (FLAG_RADIO_OFF, &ai->flags);
} else { } else {
clear_bit (FLAG_RADIO_OFF, &ai->flags); clear_bit (FLAG_RADIO_OFF, &ai->flags);
} }
} }
/*** NodeName processing */ /*** NodeName processing */
else if ( !strncmp( line, "NodeName: ", 10 ) ) { else if (!strncmp(line, "NodeName: ", 10)) {
int j; int j;
line += 10; line += 10;
memset( ai->config.nodeName, 0, 16 ); memset(ai->config.nodeName, 0, 16);
/* Do the name, assume a space between the mode and node name */ /* Do the name, assume a space between the mode and node name */
for( j = 0; j < 16 && line[j] != '\n'; j++ ) { for (j = 0; j < 16 && line[j] != '\n'; j++) {
ai->config.nodeName[j] = line[j]; ai->config.nodeName[j] = line[j];
} }
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} }
/*** PowerMode processing */ /*** PowerMode processing */
else if ( !strncmp( line, "PowerMode: ", 11 ) ) { else if (!strncmp(line, "PowerMode: ", 11)) {
line += 11; line += 11;
if ( !strncmp( line, "PSPCAM", 6 ) ) { if (!strncmp(line, "PSPCAM", 6)) {
ai->config.powerSaveMode = POWERSAVE_PSPCAM; ai->config.powerSaveMode = POWERSAVE_PSPCAM;
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "PSP", 3 ) ) { } else if (!strncmp(line, "PSP", 3)) {
ai->config.powerSaveMode = POWERSAVE_PSP; ai->config.powerSaveMode = POWERSAVE_PSP;
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else { } else {
ai->config.powerSaveMode = POWERSAVE_CAM; ai->config.powerSaveMode = POWERSAVE_CAM;
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} }
} else if ( !strncmp( line, "DataRates: ", 11 ) ) { } else if (!strncmp(line, "DataRates: ", 11)) {
int v, i = 0, k = 0; /* i is index into line, int v, i = 0, k = 0; /* i is index into line,
k is index to rates */ k is index to rates */
line += 11; line += 11;
while((v = get_dec_u16(line, &i, 3))!=-1) { while ((v = get_dec_u16(line, &i, 3))!=-1) {
ai->config.rates[k++] = (u8)v; ai->config.rates[k++] = (u8)v;
line += i + 1; line += i + 1;
i = 0; i = 0;
} }
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "Channel: ", 9 ) ) { } else if (!strncmp(line, "Channel: ", 9)) {
int v, i = 0; int v, i = 0;
line += 9; line += 9;
v = get_dec_u16(line, &i, i+3); v = get_dec_u16(line, &i, i+3);
if ( v != -1 ) { if (v != -1) {
ai->config.channelSet = cpu_to_le16(v); ai->config.channelSet = cpu_to_le16(v);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} }
} else if ( !strncmp( line, "XmitPower: ", 11 ) ) { } else if (!strncmp(line, "XmitPower: ", 11)) {
int v, i = 0; int v, i = 0;
line += 11; line += 11;
v = get_dec_u16(line, &i, i+3); v = get_dec_u16(line, &i, i+3);
if ( v != -1 ) { if (v != -1) {
ai->config.txPower = cpu_to_le16(v); ai->config.txPower = cpu_to_le16(v);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} }
} else if ( !strncmp( line, "WEP: ", 5 ) ) { } else if (!strncmp(line, "WEP: ", 5)) {
line += 5; line += 5;
switch( line[0] ) { switch(line[0]) {
case 's': case 's':
set_auth_type(ai, AUTH_SHAREDKEY); set_auth_type(ai, AUTH_SHAREDKEY);
break; break;
...@@ -4899,7 +4921,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4899,7 +4921,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
break; break;
} }
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "LongRetryLimit: ", 16 ) ) { } else if (!strncmp(line, "LongRetryLimit: ", 16)) {
int v, i = 0; int v, i = 0;
line += 16; line += 16;
...@@ -4907,7 +4929,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4907,7 +4929,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
v = (v<0) ? 0 : ((v>255) ? 255 : v); v = (v<0) ? 0 : ((v>255) ? 255 : v);
ai->config.longRetryLimit = cpu_to_le16(v); ai->config.longRetryLimit = cpu_to_le16(v);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "ShortRetryLimit: ", 17 ) ) { } else if (!strncmp(line, "ShortRetryLimit: ", 17)) {
int v, i = 0; int v, i = 0;
line += 17; line += 17;
...@@ -4915,7 +4937,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4915,7 +4937,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
v = (v<0) ? 0 : ((v>255) ? 255 : v); v = (v<0) ? 0 : ((v>255) ? 255 : v);
ai->config.shortRetryLimit = cpu_to_le16(v); ai->config.shortRetryLimit = cpu_to_le16(v);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "RTSThreshold: ", 14 ) ) { } else if (!strncmp(line, "RTSThreshold: ", 14)) {
int v, i = 0; int v, i = 0;
line += 14; line += 14;
...@@ -4923,7 +4945,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4923,7 +4945,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
v = (v<0) ? 0 : ((v>AIRO_DEF_MTU) ? AIRO_DEF_MTU : v); v = (v<0) ? 0 : ((v>AIRO_DEF_MTU) ? AIRO_DEF_MTU : v);
ai->config.rtsThres = cpu_to_le16(v); ai->config.rtsThres = cpu_to_le16(v);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "TXMSDULifetime: ", 16 ) ) { } else if (!strncmp(line, "TXMSDULifetime: ", 16)) {
int v, i = 0; int v, i = 0;
line += 16; line += 16;
...@@ -4931,7 +4953,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4931,7 +4953,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
v = (v<0) ? 0 : v; v = (v<0) ? 0 : v;
ai->config.txLifetime = cpu_to_le16(v); ai->config.txLifetime = cpu_to_le16(v);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "RXMSDULifetime: ", 16 ) ) { } else if (!strncmp(line, "RXMSDULifetime: ", 16)) {
int v, i = 0; int v, i = 0;
line += 16; line += 16;
...@@ -4939,17 +4961,17 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4939,17 +4961,17 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
v = (v<0) ? 0 : v; v = (v<0) ? 0 : v;
ai->config.rxLifetime = cpu_to_le16(v); ai->config.rxLifetime = cpu_to_le16(v);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "TXDiversity: ", 13 ) ) { } else if (!strncmp(line, "TXDiversity: ", 13)) {
ai->config.txDiversity = ai->config.txDiversity =
(line[13]=='l') ? 1 : (line[13]=='l') ? 1 :
((line[13]=='r')? 2: 3); ((line[13]=='r')? 2: 3);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "RXDiversity: ", 13 ) ) { } else if (!strncmp(line, "RXDiversity: ", 13)) {
ai->config.rxDiversity = ai->config.rxDiversity =
(line[13]=='l') ? 1 : (line[13]=='l') ? 1 :
((line[13]=='r')? 2: 3); ((line[13]=='r')? 2: 3);
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "FragThreshold: ", 15 ) ) { } else if (!strncmp(line, "FragThreshold: ", 15)) {
int v, i = 0; int v, i = 0;
line += 15; line += 15;
...@@ -4961,24 +4983,24 @@ static void proc_config_on_close(struct inode *inode, struct file *file) ...@@ -4961,24 +4983,24 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
} else if (!strncmp(line, "Modulation: ", 12)) { } else if (!strncmp(line, "Modulation: ", 12)) {
line += 12; line += 12;
switch(*line) { switch(*line) {
case 'd': ai->config.modulation=MOD_DEFAULT; set_bit(FLAG_COMMIT, &ai->flags); break; case 'd': ai->config.modulation = MOD_DEFAULT; set_bit(FLAG_COMMIT, &ai->flags); break;
case 'c': ai->config.modulation=MOD_CCK; set_bit(FLAG_COMMIT, &ai->flags); break; case 'c': ai->config.modulation = MOD_CCK; set_bit(FLAG_COMMIT, &ai->flags); break;
case 'm': ai->config.modulation=MOD_MOK; set_bit(FLAG_COMMIT, &ai->flags); break; case 'm': ai->config.modulation = MOD_MOK; set_bit(FLAG_COMMIT, &ai->flags); break;
default: airo_print_warn(ai->dev->name, "Unknown modulation"); default: airo_print_warn(ai->dev->name, "Unknown modulation");
} }
} else if (!strncmp(line, "Preamble: ", 10)) { } else if (!strncmp(line, "Preamble: ", 10)) {
line += 10; line += 10;
switch(*line) { switch(*line) {
case 'a': ai->config.preamble=PREAMBLE_AUTO; set_bit(FLAG_COMMIT, &ai->flags); break; case 'a': ai->config.preamble = PREAMBLE_AUTO; set_bit(FLAG_COMMIT, &ai->flags); break;
case 'l': ai->config.preamble=PREAMBLE_LONG; set_bit(FLAG_COMMIT, &ai->flags); break; case 'l': ai->config.preamble = PREAMBLE_LONG; set_bit(FLAG_COMMIT, &ai->flags); break;
case 's': ai->config.preamble=PREAMBLE_SHORT; set_bit(FLAG_COMMIT, &ai->flags); break; case 's': ai->config.preamble = PREAMBLE_SHORT; set_bit(FLAG_COMMIT, &ai->flags); break;
default: airo_print_warn(ai->dev->name, "Unknown preamble"); default: airo_print_warn(ai->dev->name, "Unknown preamble");
} }
} else { } else {
airo_print_warn(ai->dev->name, "Couldn't figure out %s", line); airo_print_warn(ai->dev->name, "Couldn't figure out %s", line);
} }
while( line[0] && line[0] != '\n' ) line++; while (line[0] && line[0] != '\n') line++;
if ( line[0] ) line++; if (line[0]) line++;
} }
airo_config_commit(dev, NULL, NULL, NULL); airo_config_commit(dev, NULL, NULL, NULL);
} }
...@@ -5001,14 +5023,14 @@ static int proc_config_open(struct inode *inode, struct file *file) ...@@ -5001,14 +5023,14 @@ static int proc_config_open(struct inode *inode, struct file *file)
int i; int i;
__le16 mode; __le16 mode;
if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
data = file->private_data; data = file->private_data;
if ((data->rbuffer = kmalloc( 2048, GFP_KERNEL )) == NULL) { if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) {
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
} }
if ((data->wbuffer = kzalloc( 2048, GFP_KERNEL )) == NULL) { if ((data->wbuffer = kzalloc(2048, GFP_KERNEL)) == NULL) {
kfree (data->rbuffer); kfree (data->rbuffer);
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
...@@ -5019,7 +5041,7 @@ static int proc_config_open(struct inode *inode, struct file *file) ...@@ -5019,7 +5041,7 @@ static int proc_config_open(struct inode *inode, struct file *file)
readConfigRid(ai, 1); readConfigRid(ai, 1);
mode = ai->config.opmode & MODE_CFG_MASK; mode = ai->config.opmode & MODE_CFG_MASK;
i = sprintf( data->rbuffer, i = sprintf(data->rbuffer,
"Mode: %s\n" "Mode: %s\n"
"Radio: %s\n" "Radio: %s\n"
"NodeName: %-16s\n" "NodeName: %-16s\n"
...@@ -5048,7 +5070,7 @@ static int proc_config_open(struct inode *inode, struct file *file) ...@@ -5048,7 +5070,7 @@ static int proc_config_open(struct inode *inode, struct file *file)
le16_to_cpu(ai->config.channelSet), le16_to_cpu(ai->config.channelSet),
le16_to_cpu(ai->config.txPower) le16_to_cpu(ai->config.txPower)
); );
sprintf( data->rbuffer + i, sprintf(data->rbuffer + i,
"LongRetryLimit: %d\n" "LongRetryLimit: %d\n"
"ShortRetryLimit: %d\n" "ShortRetryLimit: %d\n"
"RTSThreshold: %d\n" "RTSThreshold: %d\n"
...@@ -5079,7 +5101,7 @@ static int proc_config_open(struct inode *inode, struct file *file) ...@@ -5079,7 +5101,7 @@ static int proc_config_open(struct inode *inode, struct file *file)
ai->config.preamble == PREAMBLE_LONG ? "long" : ai->config.preamble == PREAMBLE_LONG ? "long" :
ai->config.preamble == PREAMBLE_SHORT ? "short" : "error" ai->config.preamble == PREAMBLE_SHORT ? "short" : "error"
); );
data->readlen = strlen( data->rbuffer ); data->readlen = strlen(data->rbuffer);
return 0; return 0;
} }
...@@ -5119,14 +5141,15 @@ static void proc_SSID_on_close(struct inode *inode, struct file *file) ...@@ -5119,14 +5141,15 @@ static void proc_SSID_on_close(struct inode *inode, struct file *file)
enable_MAC(ai, 1); enable_MAC(ai, 1);
} }
static void proc_APList_on_close( struct inode *inode, struct file *file ) { static void proc_APList_on_close(struct inode *inode, struct file *file)
{
struct proc_data *data = file->private_data; struct proc_data *data = file->private_data;
struct net_device *dev = PDE_DATA(inode); struct net_device *dev = PDE_DATA(inode);
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
APListRid *APList_rid = &ai->APList; APListRid *APList_rid = &ai->APList;
int i; int i;
if ( !data->writelen ) return; if (!data->writelen) return;
memset(APList_rid, 0, sizeof(*APList_rid)); memset(APList_rid, 0, sizeof(*APList_rid));
APList_rid->len = cpu_to_le16(sizeof(*APList_rid)); APList_rid->len = cpu_to_le16(sizeof(*APList_rid));
...@@ -5140,8 +5163,9 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) { ...@@ -5140,8 +5163,9 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) {
} }
/* This function wraps PC4500_writerid with a MAC disable */ /* This function wraps PC4500_writerid with a MAC disable */
static int do_writerid( struct airo_info *ai, u16 rid, const void *rid_data, static int do_writerid(struct airo_info *ai, u16 rid, const void *rid_data,
int len, int dummy ) { int len, int dummy)
{
int rc; int rc;
disable_MAC(ai, 1); disable_MAC(ai, 1);
...@@ -5241,7 +5265,8 @@ static int set_wep_tx_idx(struct airo_info *ai, u16 index, int perm, int lock) ...@@ -5241,7 +5265,8 @@ static int set_wep_tx_idx(struct airo_info *ai, u16 index, int perm, int lock)
return rc; return rc;
} }
static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { static void proc_wepkey_on_close(struct inode *inode, struct file *file)
{
struct proc_data *data; struct proc_data *data;
struct net_device *dev = PDE_DATA(inode); struct net_device *dev = PDE_DATA(inode);
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
...@@ -5253,7 +5278,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { ...@@ -5253,7 +5278,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
memset(key, 0, sizeof(key)); memset(key, 0, sizeof(key));
data = file->private_data; data = file->private_data;
if ( !data->writelen ) return; if (!data->writelen) return;
if (data->wbuffer[0] >= '0' && data->wbuffer[0] <= '3' && if (data->wbuffer[0] >= '0' && data->wbuffer[0] <= '3' &&
(data->wbuffer[1] == ' ' || data->wbuffer[1] == '\n')) { (data->wbuffer[1] == ' ' || data->wbuffer[1] == '\n')) {
...@@ -5273,7 +5298,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { ...@@ -5273,7 +5298,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
return; return;
} }
for( i = 0; i < 16*3 && data->wbuffer[i+j]; i++ ) { for (i = 0; i < 16*3 && data->wbuffer[i+j]; i++) {
switch(i%3) { switch(i%3) {
case 0: case 0:
key[i/3] = hex_to_bin(data->wbuffer[i+j])<<4; key[i/3] = hex_to_bin(data->wbuffer[i+j])<<4;
...@@ -5291,7 +5316,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { ...@@ -5291,7 +5316,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
} }
} }
static int proc_wepkey_open( struct inode *inode, struct file *file ) static int proc_wepkey_open(struct inode *inode, struct file *file)
{ {
struct proc_data *data; struct proc_data *data;
struct net_device *dev = PDE_DATA(inode); struct net_device *dev = PDE_DATA(inode);
...@@ -5299,20 +5324,20 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) ...@@ -5299,20 +5324,20 @@ static int proc_wepkey_open( struct inode *inode, struct file *file )
char *ptr; char *ptr;
WepKeyRid wkr; WepKeyRid wkr;
__le16 lastindex; __le16 lastindex;
int j=0; int j = 0;
int rc; int rc;
if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(&wkr, 0, sizeof(wkr)); memset(&wkr, 0, sizeof(wkr));
data = file->private_data; data = file->private_data;
if ((data->rbuffer = kzalloc( 180, GFP_KERNEL )) == NULL) { if ((data->rbuffer = kzalloc(180, GFP_KERNEL)) == NULL) {
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
} }
data->writelen = 0; data->writelen = 0;
data->maxwritelen = 80; data->maxwritelen = 80;
if ((data->wbuffer = kzalloc( 80, GFP_KERNEL )) == NULL) { if ((data->wbuffer = kzalloc(80, GFP_KERNEL)) == NULL) {
kfree (data->rbuffer); kfree (data->rbuffer);
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
...@@ -5333,9 +5358,9 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) ...@@ -5333,9 +5358,9 @@ static int proc_wepkey_open( struct inode *inode, struct file *file )
le16_to_cpu(wkr.klen)); le16_to_cpu(wkr.klen));
} }
readWepKeyRid(ai, &wkr, 0, 1); readWepKeyRid(ai, &wkr, 0, 1);
} while((lastindex != wkr.kindex) && (j < 180-30)); } while ((lastindex != wkr.kindex) && (j < 180-30));
data->readlen = strlen( data->rbuffer ); data->readlen = strlen(data->rbuffer);
return 0; return 0;
} }
...@@ -5348,10 +5373,10 @@ static int proc_SSID_open(struct inode *inode, struct file *file) ...@@ -5348,10 +5373,10 @@ static int proc_SSID_open(struct inode *inode, struct file *file)
char *ptr; char *ptr;
SsidRid SSID_rid; SsidRid SSID_rid;
if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
data = file->private_data; data = file->private_data;
if ((data->rbuffer = kmalloc( 104, GFP_KERNEL )) == NULL) { if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) {
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
} }
...@@ -5379,11 +5404,12 @@ static int proc_SSID_open(struct inode *inode, struct file *file) ...@@ -5379,11 +5404,12 @@ static int proc_SSID_open(struct inode *inode, struct file *file)
*ptr++ = '\n'; *ptr++ = '\n';
} }
*ptr = '\0'; *ptr = '\0';
data->readlen = strlen( data->rbuffer ); data->readlen = strlen(data->rbuffer);
return 0; return 0;
} }
static int proc_APList_open( struct inode *inode, struct file *file ) { static int proc_APList_open(struct inode *inode, struct file *file)
{
struct proc_data *data; struct proc_data *data;
struct net_device *dev = PDE_DATA(inode); struct net_device *dev = PDE_DATA(inode);
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
...@@ -5391,16 +5417,16 @@ static int proc_APList_open( struct inode *inode, struct file *file ) { ...@@ -5391,16 +5417,16 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
char *ptr; char *ptr;
APListRid *APList_rid = &ai->APList; APListRid *APList_rid = &ai->APList;
if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
data = file->private_data; data = file->private_data;
if ((data->rbuffer = kmalloc( 104, GFP_KERNEL )) == NULL) { if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) {
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
} }
data->writelen = 0; data->writelen = 0;
data->maxwritelen = 4*6*3; data->maxwritelen = 4*6*3;
if ((data->wbuffer = kzalloc( data->maxwritelen, GFP_KERNEL )) == NULL) { if ((data->wbuffer = kzalloc(data->maxwritelen, GFP_KERNEL)) == NULL) {
kfree (data->rbuffer); kfree (data->rbuffer);
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
...@@ -5408,20 +5434,21 @@ static int proc_APList_open( struct inode *inode, struct file *file ) { ...@@ -5408,20 +5434,21 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
data->on_close = proc_APList_on_close; data->on_close = proc_APList_on_close;
ptr = data->rbuffer; ptr = data->rbuffer;
for( i = 0; i < 4; i++ ) { for (i = 0; i < 4; i++) {
// We end when we find a zero MAC // We end when we find a zero MAC
if ( !*(int*)APList_rid->ap[i] && if (!*(int*)APList_rid->ap[i] &&
!*(int*)&APList_rid->ap[i][2]) break; !*(int*)&APList_rid->ap[i][2]) break;
ptr += sprintf(ptr, "%pM\n", APList_rid->ap[i]); ptr += sprintf(ptr, "%pM\n", APList_rid->ap[i]);
} }
if (i==0) ptr += sprintf(ptr, "Not using specific APs\n"); if (i==0) ptr += sprintf(ptr, "Not using specific APs\n");
*ptr = '\0'; *ptr = '\0';
data->readlen = strlen( data->rbuffer ); data->readlen = strlen(data->rbuffer);
return 0; return 0;
} }
static int proc_BSSList_open( struct inode *inode, struct file *file ) { static int proc_BSSList_open(struct inode *inode, struct file *file)
{
struct proc_data *data; struct proc_data *data;
struct net_device *dev = PDE_DATA(inode); struct net_device *dev = PDE_DATA(inode);
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
...@@ -5431,10 +5458,10 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) { ...@@ -5431,10 +5458,10 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
/* If doLoseSync is not 1, we won't do a Lose Sync */ /* If doLoseSync is not 1, we won't do a Lose Sync */
int doLoseSync = -1; int doLoseSync = -1;
if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
data = file->private_data; data = file->private_data;
if ((data->rbuffer = kmalloc( 1024, GFP_KERNEL )) == NULL) { if ((data->rbuffer = kmalloc(1024, GFP_KERNEL)) == NULL) {
kfree (file->private_data); kfree (file->private_data);
return -ENOMEM; return -ENOMEM;
} }
...@@ -5454,7 +5481,7 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) { ...@@ -5454,7 +5481,7 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
return -ENETDOWN; return -ENETDOWN;
} }
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.cmd=CMD_LISTBSS; cmd.cmd = CMD_LISTBSS;
if (down_interruptible(&ai->sem)) { if (down_interruptible(&ai->sem)) {
kfree(data->rbuffer); kfree(data->rbuffer);
kfree(file->private_data); kfree(file->private_data);
...@@ -5472,7 +5499,7 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) { ...@@ -5472,7 +5499,7 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
Since it is a rare condition, we'll just live with it, otherwise Since it is a rare condition, we'll just live with it, otherwise
we have to add a spin lock... */ we have to add a spin lock... */
rc = readBSSListRid(ai, doLoseSync, &BSSList_rid); rc = readBSSListRid(ai, doLoseSync, &BSSList_rid);
while(rc == 0 && BSSList_rid.index != cpu_to_le16(0xffff)) { while (rc == 0 && BSSList_rid.index != cpu_to_le16(0xffff)) {
ptr += sprintf(ptr, "%pM %.*s rssi = %d", ptr += sprintf(ptr, "%pM %.*s rssi = %d",
BSSList_rid.bssid, BSSList_rid.bssid,
(int)BSSList_rid.ssidLen, (int)BSSList_rid.ssidLen,
...@@ -5487,11 +5514,11 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) { ...@@ -5487,11 +5514,11 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
rc = readBSSListRid(ai, 0, &BSSList_rid); rc = readBSSListRid(ai, 0, &BSSList_rid);
} }
*ptr = '\0'; *ptr = '\0';
data->readlen = strlen( data->rbuffer ); data->readlen = strlen(data->rbuffer);
return 0; return 0;
} }
static int proc_close( struct inode *inode, struct file *file ) static int proc_close(struct inode *inode, struct file *file)
{ {
struct proc_data *data = file->private_data; struct proc_data *data = file->private_data;
...@@ -5508,7 +5535,8 @@ static int proc_close( struct inode *inode, struct file *file ) ...@@ -5508,7 +5535,8 @@ static int proc_close( struct inode *inode, struct file *file )
will switch WEP modes to see if that will help. If the card is will switch WEP modes to see if that will help. If the card is
associated we will check every minute to see if anything has associated we will check every minute to see if anything has
changed. */ changed. */
static void timer_func( struct net_device *dev ) { static void timer_func(struct net_device *dev)
{
struct airo_info *apriv = dev->ml_priv; struct airo_info *apriv = dev->ml_priv;
/* We don't have a link so try changing the authtype */ /* We don't have a link so try changing the authtype */
...@@ -5642,7 +5670,7 @@ static int __maybe_unused airo_pci_resume(struct device *dev_d) ...@@ -5642,7 +5670,7 @@ static int __maybe_unused airo_pci_resume(struct device *dev_d)
} }
#endif #endif
static int __init airo_init_module( void ) static int __init airo_init_module(void)
{ {
int i; int i;
...@@ -5658,8 +5686,8 @@ static int __init airo_init_module( void ) ...@@ -5658,8 +5686,8 @@ static int __init airo_init_module( void )
for (i = 0; i < 4 && io[i] && irq[i]; i++) { for (i = 0; i < 4 && io[i] && irq[i]; i++) {
airo_print_info("", "Trying to configure ISA adapter at irq=%d " airo_print_info("", "Trying to configure ISA adapter at irq=%d "
"io=0x%x", irq[i], io[i] ); "io = 0x%x", irq[i], io[i]);
if (init_airo_card( irq[i], io[i], 0, NULL )) { if (init_airo_card(irq[i], io[i], 0, NULL)) {
/* do nothing */ ; /* do nothing */ ;
} }
} }
...@@ -5681,10 +5709,10 @@ static int __init airo_init_module( void ) ...@@ -5681,10 +5709,10 @@ static int __init airo_init_module( void )
return 0; return 0;
} }
static void __exit airo_cleanup_module( void ) static void __exit airo_cleanup_module(void)
{ {
struct airo_info *ai; struct airo_info *ai;
while(!list_empty(&airo_devices)) { while (!list_empty(&airo_devices)) {
ai = list_entry(airo_devices.next, struct airo_info, dev_list); ai = list_entry(airo_devices.next, struct airo_info, dev_list);
airo_print_info(ai->dev->name, "Unregistering..."); airo_print_info(ai->dev->name, "Unregistering...");
stop_airo_card(ai->dev, 1); stop_airo_card(ai->dev, 1);
...@@ -5784,7 +5812,7 @@ static int airo_set_freq(struct net_device *dev, ...@@ -5784,7 +5812,7 @@ static int airo_set_freq(struct net_device *dev,
int rc = -EINPROGRESS; /* Call commit handler */ int rc = -EINPROGRESS; /* Call commit handler */
/* If setting by frequency, convert to a channel */ /* If setting by frequency, convert to a channel */
if(fwrq->e == 1) { if (fwrq->e == 1) {
int f = fwrq->m / 100000; int f = fwrq->m / 100000;
/* Hack to fall through... */ /* Hack to fall through... */
...@@ -5798,7 +5826,7 @@ static int airo_set_freq(struct net_device *dev, ...@@ -5798,7 +5826,7 @@ static int airo_set_freq(struct net_device *dev,
int channel = fwrq->m; int channel = fwrq->m;
/* We should do a better check than that, /* We should do a better check than that,
* based on the card capability !!! */ * based on the card capability !!! */
if((channel < 1) || (channel > 14)) { if ((channel < 1) || (channel > 14)) {
airo_print_dbg(dev->name, "New channel value of %d is invalid!", airo_print_dbg(dev->name, "New channel value of %d is invalid!",
fwrq->m); fwrq->m);
rc = -EINVAL; rc = -EINVAL;
...@@ -5832,7 +5860,7 @@ static int airo_get_freq(struct net_device *dev, ...@@ -5832,7 +5860,7 @@ static int airo_get_freq(struct net_device *dev,
readStatusRid(local, &status_rid, 1); readStatusRid(local, &status_rid, 1);
ch = le16_to_cpu(status_rid.channel); ch = le16_to_cpu(status_rid.channel);
if((ch > 0) && (ch < 15)) { if ((ch > 0) && (ch < 15)) {
fwrq->m = 100000 * fwrq->m = 100000 *
ieee80211_channel_to_frequency(ch, NL80211_BAND_2GHZ); ieee80211_channel_to_frequency(ch, NL80211_BAND_2GHZ);
fwrq->e = 1; fwrq->e = 1;
...@@ -5936,7 +5964,7 @@ static int airo_set_wap(struct net_device *dev, ...@@ -5936,7 +5964,7 @@ static int airo_set_wap(struct net_device *dev,
else if (is_broadcast_ether_addr(awrq->sa_data) || else if (is_broadcast_ether_addr(awrq->sa_data) ||
is_zero_ether_addr(awrq->sa_data)) { is_zero_ether_addr(awrq->sa_data)) {
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.cmd=CMD_LOSE_SYNC; cmd.cmd = CMD_LOSE_SYNC;
if (down_interruptible(&local->sem)) if (down_interruptible(&local->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
issuecommand(local, &cmd, &rsp); issuecommand(local, &cmd, &rsp);
...@@ -5985,7 +6013,7 @@ static int airo_set_nick(struct net_device *dev, ...@@ -5985,7 +6013,7 @@ static int airo_set_nick(struct net_device *dev,
struct airo_info *local = dev->ml_priv; struct airo_info *local = dev->ml_priv;
/* Check the size of the string */ /* Check the size of the string */
if(dwrq->length > 16) { if (dwrq->length > 16) {
return -E2BIG; return -E2BIG;
} }
readConfigRid(local, 1); readConfigRid(local, 1);
...@@ -6033,7 +6061,7 @@ static int airo_set_rate(struct net_device *dev, ...@@ -6033,7 +6061,7 @@ static int airo_set_rate(struct net_device *dev,
readCapabilityRid(local, &cap_rid, 1); readCapabilityRid(local, &cap_rid, 1);
/* Which type of value ? */ /* Which type of value ? */
if((vwrq->value < 8) && (vwrq->value >= 0)) { if ((vwrq->value < 8) && (vwrq->value >= 0)) {
/* Setting by rate index */ /* Setting by rate index */
/* Find value in the magic rate table */ /* Find value in the magic rate table */
brate = cap_rid.supportedRates[vwrq->value]; brate = cap_rid.supportedRates[vwrq->value];
...@@ -6042,36 +6070,36 @@ static int airo_set_rate(struct net_device *dev, ...@@ -6042,36 +6070,36 @@ static int airo_set_rate(struct net_device *dev,
u8 normvalue = (u8) (vwrq->value/500000); u8 normvalue = (u8) (vwrq->value/500000);
/* Check if rate is valid */ /* Check if rate is valid */
for(i = 0 ; i < 8 ; i++) { for (i = 0 ; i < 8 ; i++) {
if(normvalue == cap_rid.supportedRates[i]) { if (normvalue == cap_rid.supportedRates[i]) {
brate = normvalue; brate = normvalue;
break; break;
} }
} }
} }
/* -1 designed the max rate (mostly auto mode) */ /* -1 designed the max rate (mostly auto mode) */
if(vwrq->value == -1) { if (vwrq->value == -1) {
/* Get the highest available rate */ /* Get the highest available rate */
for(i = 0 ; i < 8 ; i++) { for (i = 0 ; i < 8 ; i++) {
if(cap_rid.supportedRates[i] == 0) if (cap_rid.supportedRates[i] == 0)
break; break;
} }
if(i != 0) if (i != 0)
brate = cap_rid.supportedRates[i - 1]; brate = cap_rid.supportedRates[i - 1];
} }
/* Check that it is valid */ /* Check that it is valid */
if(brate == 0) { if (brate == 0) {
return -EINVAL; return -EINVAL;
} }
readConfigRid(local, 1); readConfigRid(local, 1);
/* Now, check if we want a fixed or auto value */ /* Now, check if we want a fixed or auto value */
if(vwrq->fixed == 0) { if (vwrq->fixed == 0) {
/* Fill all the rates up to this max rate */ /* Fill all the rates up to this max rate */
memset(local->config.rates, 0, 8); memset(local->config.rates, 0, 8);
for(i = 0 ; i < 8 ; i++) { for (i = 0 ; i < 8 ; i++) {
local->config.rates[i] = cap_rid.supportedRates[i]; local->config.rates[i] = cap_rid.supportedRates[i];
if(local->config.rates[i] == brate) if (local->config.rates[i] == brate)
break; break;
} }
} else { } else {
...@@ -6119,9 +6147,9 @@ static int airo_set_rts(struct net_device *dev, ...@@ -6119,9 +6147,9 @@ static int airo_set_rts(struct net_device *dev,
struct airo_info *local = dev->ml_priv; struct airo_info *local = dev->ml_priv;
int rthr = vwrq->value; int rthr = vwrq->value;
if(vwrq->disabled) if (vwrq->disabled)
rthr = AIRO_DEF_MTU; rthr = AIRO_DEF_MTU;
if((rthr < 0) || (rthr > AIRO_DEF_MTU)) { if ((rthr < 0) || (rthr > AIRO_DEF_MTU)) {
return -EINVAL; return -EINVAL;
} }
readConfigRid(local, 1); readConfigRid(local, 1);
...@@ -6162,9 +6190,9 @@ static int airo_set_frag(struct net_device *dev, ...@@ -6162,9 +6190,9 @@ static int airo_set_frag(struct net_device *dev,
struct airo_info *local = dev->ml_priv; struct airo_info *local = dev->ml_priv;
int fthr = vwrq->value; int fthr = vwrq->value;
if(vwrq->disabled) if (vwrq->disabled)
fthr = AIRO_DEF_MTU; fthr = AIRO_DEF_MTU;
if((fthr < 256) || (fthr > AIRO_DEF_MTU)) { if ((fthr < 256) || (fthr > AIRO_DEF_MTU)) {
return -EINVAL; return -EINVAL;
} }
fthr &= ~0x1; /* Get an even value - is it really needed ??? */ fthr &= ~0x1; /* Get an even value - is it really needed ??? */
...@@ -6341,7 +6369,7 @@ static int airo_set_encode(struct net_device *dev, ...@@ -6341,7 +6369,7 @@ static int airo_set_encode(struct net_device *dev,
else else
key.len = MIN_KEY_SIZE; key.len = MIN_KEY_SIZE;
/* Check if the key is not marked as invalid */ /* Check if the key is not marked as invalid */
if(!(dwrq->flags & IW_ENCODE_NOKEY)) { if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
/* Cleanup */ /* Cleanup */
memset(key.key, 0, MAX_KEY_SIZE); memset(key.key, 0, MAX_KEY_SIZE);
/* Copy the key in the driver */ /* Copy the key in the driver */
...@@ -6358,7 +6386,7 @@ static int airo_set_encode(struct net_device *dev, ...@@ -6358,7 +6386,7 @@ static int airo_set_encode(struct net_device *dev,
/* WE specify that if a valid key is set, encryption /* WE specify that if a valid key is set, encryption
* should be enabled (user may turn it off later) * should be enabled (user may turn it off later)
* This is also how "iwconfig ethX key on" works */ * This is also how "iwconfig ethX key on" works */
if((index == current_index) && (key.len > 0) && if ((index == current_index) && (key.len > 0) &&
(local->config.authType == AUTH_OPEN)) (local->config.authType == AUTH_OPEN))
set_auth_type(local, AUTH_ENCRYPT); set_auth_type(local, AUTH_ENCRYPT);
} else { } else {
...@@ -6381,7 +6409,7 @@ static int airo_set_encode(struct net_device *dev, ...@@ -6381,7 +6409,7 @@ static int airo_set_encode(struct net_device *dev,
/* Read the flags */ /* Read the flags */
if (dwrq->flags & IW_ENCODE_DISABLED) if (dwrq->flags & IW_ENCODE_DISABLED)
set_auth_type(local, AUTH_OPEN); /* disable encryption */ set_auth_type(local, AUTH_OPEN); /* disable encryption */
if(dwrq->flags & IW_ENCODE_RESTRICTED) if (dwrq->flags & IW_ENCODE_RESTRICTED)
set_auth_type(local, AUTH_SHAREDKEY); /* Only Both */ set_auth_type(local, AUTH_SHAREDKEY); /* Only Both */
if (dwrq->flags & IW_ENCODE_OPEN) if (dwrq->flags & IW_ENCODE_OPEN)
set_auth_type(local, AUTH_ENCRYPT); /* Only Wep */ set_auth_type(local, AUTH_ENCRYPT); /* Only Wep */
...@@ -6459,7 +6487,7 @@ static int airo_set_encodeext(struct net_device *dev, ...@@ -6459,7 +6487,7 @@ static int airo_set_encodeext(struct net_device *dev,
struct airo_info *local = dev->ml_priv; struct airo_info *local = dev->ml_priv;
struct iw_point *encoding = &wrqu->encoding; struct iw_point *encoding = &wrqu->encoding;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
int perm = ( encoding->flags & IW_ENCODE_TEMP ? 0 : 1 ); int perm = (encoding->flags & IW_ENCODE_TEMP ? 0 : 1);
__le16 currentAuthType = local->config.authType; __le16 currentAuthType = local->config.authType;
int idx, key_len, alg = ext->alg, set_key = 1, rc; int idx, key_len, alg = ext->alg, set_key = 1, rc;
wep_key_t key; wep_key_t key;
...@@ -6541,7 +6569,7 @@ static int airo_set_encodeext(struct net_device *dev, ...@@ -6541,7 +6569,7 @@ static int airo_set_encodeext(struct net_device *dev,
/* Read the flags */ /* Read the flags */
if (encoding->flags & IW_ENCODE_DISABLED) if (encoding->flags & IW_ENCODE_DISABLED)
set_auth_type(local, AUTH_OPEN); /* disable encryption */ set_auth_type(local, AUTH_OPEN); /* disable encryption */
if(encoding->flags & IW_ENCODE_RESTRICTED) if (encoding->flags & IW_ENCODE_RESTRICTED)
set_auth_type(local, AUTH_SHAREDKEY); /* Only Both */ set_auth_type(local, AUTH_SHAREDKEY); /* Only Both */
if (encoding->flags & IW_ENCODE_OPEN) if (encoding->flags & IW_ENCODE_OPEN)
set_auth_type(local, AUTH_ENCRYPT); set_auth_type(local, AUTH_ENCRYPT);
...@@ -6807,13 +6835,13 @@ static int airo_set_retry(struct net_device *dev, ...@@ -6807,13 +6835,13 @@ static int airo_set_retry(struct net_device *dev,
struct airo_info *local = dev->ml_priv; struct airo_info *local = dev->ml_priv;
int rc = -EINVAL; int rc = -EINVAL;
if(vwrq->disabled) { if (vwrq->disabled) {
return -EINVAL; return -EINVAL;
} }
readConfigRid(local, 1); readConfigRid(local, 1);
if(vwrq->flags & IW_RETRY_LIMIT) { if (vwrq->flags & IW_RETRY_LIMIT) {
__le16 v = cpu_to_le16(vwrq->value); __le16 v = cpu_to_le16(vwrq->value);
if(vwrq->flags & IW_RETRY_LONG) if (vwrq->flags & IW_RETRY_LONG)
local->config.longRetryLimit = v; local->config.longRetryLimit = v;
else if (vwrq->flags & IW_RETRY_SHORT) else if (vwrq->flags & IW_RETRY_SHORT)
local->config.shortRetryLimit = v; local->config.shortRetryLimit = v;
...@@ -6825,7 +6853,7 @@ static int airo_set_retry(struct net_device *dev, ...@@ -6825,7 +6853,7 @@ static int airo_set_retry(struct net_device *dev,
set_bit (FLAG_COMMIT, &local->flags); set_bit (FLAG_COMMIT, &local->flags);
rc = -EINPROGRESS; /* Call commit handler */ rc = -EINPROGRESS; /* Call commit handler */
} }
if(vwrq->flags & IW_RETRY_LIFETIME) { if (vwrq->flags & IW_RETRY_LIFETIME) {
local->config.txLifetime = cpu_to_le16(vwrq->value / 1024); local->config.txLifetime = cpu_to_le16(vwrq->value / 1024);
set_bit (FLAG_COMMIT, &local->flags); set_bit (FLAG_COMMIT, &local->flags);
rc = -EINPROGRESS; /* Call commit handler */ rc = -EINPROGRESS; /* Call commit handler */
...@@ -6848,16 +6876,16 @@ static int airo_get_retry(struct net_device *dev, ...@@ -6848,16 +6876,16 @@ static int airo_get_retry(struct net_device *dev,
readConfigRid(local, 1); readConfigRid(local, 1);
/* Note : by default, display the min retry number */ /* Note : by default, display the min retry number */
if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
vwrq->flags = IW_RETRY_LIFETIME; vwrq->flags = IW_RETRY_LIFETIME;
vwrq->value = le16_to_cpu(local->config.txLifetime) * 1024; vwrq->value = le16_to_cpu(local->config.txLifetime) * 1024;
} else if((vwrq->flags & IW_RETRY_LONG)) { } else if ((vwrq->flags & IW_RETRY_LONG)) {
vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
vwrq->value = le16_to_cpu(local->config.longRetryLimit); vwrq->value = le16_to_cpu(local->config.longRetryLimit);
} else { } else {
vwrq->flags = IW_RETRY_LIMIT; vwrq->flags = IW_RETRY_LIMIT;
vwrq->value = le16_to_cpu(local->config.shortRetryLimit); vwrq->value = le16_to_cpu(local->config.shortRetryLimit);
if(local->config.shortRetryLimit != local->config.longRetryLimit) if (local->config.shortRetryLimit != local->config.longRetryLimit)
vwrq->flags |= IW_RETRY_SHORT; vwrq->flags |= IW_RETRY_SHORT;
} }
...@@ -6889,7 +6917,7 @@ static int airo_get_range(struct net_device *dev, ...@@ -6889,7 +6917,7 @@ static int airo_get_range(struct net_device *dev,
/* Should be based on cap_rid.country to give only /* Should be based on cap_rid.country to give only
* what the current card support */ * what the current card support */
k = 0; k = 0;
for(i = 0; i < 14; i++) { for (i = 0; i < 14; i++) {
range->freq[k].i = i + 1; /* List index */ range->freq[k].i = i + 1; /* List index */
range->freq[k].m = 100000 * range->freq[k].m = 100000 *
ieee80211_channel_to_frequency(i + 1, NL80211_BAND_2GHZ); ieee80211_channel_to_frequency(i + 1, NL80211_BAND_2GHZ);
...@@ -6919,9 +6947,9 @@ static int airo_get_range(struct net_device *dev, ...@@ -6919,9 +6947,9 @@ static int airo_get_range(struct net_device *dev,
} }
range->avg_qual.noise = 0x100 - 85; /* -85 dBm */ range->avg_qual.noise = 0x100 - 85; /* -85 dBm */
for(i = 0 ; i < 8 ; i++) { for (i = 0 ; i < 8 ; i++) {
range->bitrate[i] = cap_rid.supportedRates[i] * 500000; range->bitrate[i] = cap_rid.supportedRates[i] * 500000;
if(range->bitrate[i] == 0) if (range->bitrate[i] == 0)
break; break;
} }
range->num_bitrates = i; range->num_bitrates = i;
...@@ -6929,7 +6957,7 @@ static int airo_get_range(struct net_device *dev, ...@@ -6929,7 +6957,7 @@ static int airo_get_range(struct net_device *dev,
/* Set an indication of the max TCP throughput /* Set an indication of the max TCP throughput
* in bit/s that we can expect using this interface. * in bit/s that we can expect using this interface.
* May be use for QoS stuff... Jean II */ * May be use for QoS stuff... Jean II */
if(i > 2) if (i > 2)
range->throughput = 5000 * 1000; range->throughput = 5000 * 1000;
else else
range->throughput = 1500 * 1000; range->throughput = 1500 * 1000;
...@@ -6939,7 +6967,7 @@ static int airo_get_range(struct net_device *dev, ...@@ -6939,7 +6967,7 @@ static int airo_get_range(struct net_device *dev,
range->min_frag = 256; range->min_frag = 256;
range->max_frag = AIRO_DEF_MTU; range->max_frag = AIRO_DEF_MTU;
if(cap_rid.softCap & cpu_to_le16(2)) { if (cap_rid.softCap & cpu_to_le16(2)) {
// WEP: RC4 40 bits // WEP: RC4 40 bits
range->encoding_size[0] = 5; range->encoding_size[0] = 5;
// RC4 ~128 bits // RC4 ~128 bits
...@@ -6963,9 +6991,9 @@ static int airo_get_range(struct net_device *dev, ...@@ -6963,9 +6991,9 @@ static int airo_get_range(struct net_device *dev,
range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
/* Transmit Power - values are in mW */ /* Transmit Power - values are in mW */
for(i = 0 ; i < 8 ; i++) { for (i = 0 ; i < 8 ; i++) {
range->txpower[i] = le16_to_cpu(cap_rid.txPowerLevels[i]); range->txpower[i] = le16_to_cpu(cap_rid.txPowerLevels[i]);
if(range->txpower[i] == 0) if (range->txpower[i] == 0)
break; break;
} }
range->num_txpower = i; range->num_txpower = i;
...@@ -7236,7 +7264,7 @@ static int airo_set_scan(struct net_device *dev, ...@@ -7236,7 +7264,7 @@ static int airo_set_scan(struct net_device *dev,
/* Initiate a scan command */ /* Initiate a scan command */
ai->scan_timeout = RUN_AT(3*HZ); ai->scan_timeout = RUN_AT(3*HZ);
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.cmd=CMD_LISTBSS; cmd.cmd = CMD_LISTBSS;
issuecommand(ai, &cmd, &rsp); issuecommand(ai, &cmd, &rsp);
wake = 1; wake = 1;
...@@ -7277,7 +7305,7 @@ static inline char *airo_translate_scan(struct net_device *dev, ...@@ -7277,7 +7305,7 @@ static inline char *airo_translate_scan(struct net_device *dev,
/* Add the ESSID */ /* Add the ESSID */
iwe.u.data.length = bss->ssidLen; iwe.u.data.length = bss->ssidLen;
if(iwe.u.data.length > 32) if (iwe.u.data.length > 32)
iwe.u.data.length = 32; iwe.u.data.length = 32;
iwe.cmd = SIOCGIWESSID; iwe.cmd = SIOCGIWESSID;
iwe.u.data.flags = 1; iwe.u.data.flags = 1;
...@@ -7287,8 +7315,8 @@ static inline char *airo_translate_scan(struct net_device *dev, ...@@ -7287,8 +7315,8 @@ static inline char *airo_translate_scan(struct net_device *dev,
/* Add mode */ /* Add mode */
iwe.cmd = SIOCGIWMODE; iwe.cmd = SIOCGIWMODE;
capabilities = bss->cap; capabilities = bss->cap;
if(capabilities & (CAP_ESS | CAP_IBSS)) { if (capabilities & (CAP_ESS | CAP_IBSS)) {
if(capabilities & CAP_ESS) if (capabilities & CAP_ESS)
iwe.u.mode = IW_MODE_MASTER; iwe.u.mode = IW_MODE_MASTER;
else else
iwe.u.mode = IW_MODE_ADHOC; iwe.u.mode = IW_MODE_ADHOC;
...@@ -7328,7 +7356,7 @@ static inline char *airo_translate_scan(struct net_device *dev, ...@@ -7328,7 +7356,7 @@ static inline char *airo_translate_scan(struct net_device *dev,
/* Add encryption capability */ /* Add encryption capability */
iwe.cmd = SIOCGIWENCODE; iwe.cmd = SIOCGIWENCODE;
if(capabilities & CAP_PRIVACY) if (capabilities & CAP_PRIVACY)
iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
else else
iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.flags = IW_ENCODE_DISABLED;
...@@ -7344,9 +7372,9 @@ static inline char *airo_translate_scan(struct net_device *dev, ...@@ -7344,9 +7372,9 @@ static inline char *airo_translate_scan(struct net_device *dev,
/* Those two flags are ignored... */ /* Those two flags are ignored... */
iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
/* Max 8 values */ /* Max 8 values */
for(i = 0 ; i < 8 ; i++) { for (i = 0 ; i < 8 ; i++) {
/* NULL terminated */ /* NULL terminated */
if(bss->rates[i] == 0) if (bss->rates[i] == 0)
break; break;
/* Bit rate given in 500 kb/s units (+ 0x80) */ /* Bit rate given in 500 kb/s units (+ 0x80) */
iwe.u.bitrate.value = ((bss->rates[i] & 0x7f) * 500000); iwe.u.bitrate.value = ((bss->rates[i] & 0x7f) * 500000);
...@@ -7454,7 +7482,7 @@ static int airo_get_scan(struct net_device *dev, ...@@ -7454,7 +7482,7 @@ static int airo_get_scan(struct net_device *dev,
&net->bss); &net->bss);
/* Check if there is space for one more entry */ /* Check if there is space for one more entry */
if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) { if ((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
/* Ask user space to try again with a bigger buffer */ /* Ask user space to try again with a bigger buffer */
err = -E2BIG; err = -E2BIG;
goto out; goto out;
...@@ -7492,7 +7520,7 @@ static int airo_config_commit(struct net_device *dev, ...@@ -7492,7 +7520,7 @@ static int airo_config_commit(struct net_device *dev,
readSsidRid(local, &SSID_rid); readSsidRid(local, &SSID_rid);
if (test_bit(FLAG_MPI,&local->flags)) if (test_bit(FLAG_MPI,&local->flags))
setup_card(local, dev->dev_addr, 1 ); setup_card(local, dev->dev_addr, 1);
else else
reset_airo_card(dev); reset_airo_card(dev);
disable_MAC(local, 1); disable_MAC(local, 1);
...@@ -7636,9 +7664,9 @@ static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -7636,9 +7664,9 @@ static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
int val = AIROMAGIC; int val = AIROMAGIC;
aironet_ioctl com; aironet_ioctl com;
if (copy_from_user(&com,rq->ifr_data,sizeof(com))) if (copy_from_user(&com, rq->ifr_data, sizeof(com)))
rc = -EFAULT; rc = -EFAULT;
else if (copy_to_user(com.data,(char *)&val,sizeof(val))) else if (copy_to_user(com.data, (char *)&val, sizeof(val)))
rc = -EFAULT; rc = -EFAULT;
} }
break; break;
...@@ -7652,24 +7680,24 @@ static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -7652,24 +7680,24 @@ static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
*/ */
{ {
aironet_ioctl com; aironet_ioctl com;
if (copy_from_user(&com,rq->ifr_data,sizeof(com))) { if (copy_from_user(&com, rq->ifr_data, sizeof(com))) {
rc = -EFAULT; rc = -EFAULT;
break; break;
} }
/* Separate R/W functions bracket legality here /* Separate R/W functions bracket legality here
*/ */
if ( com.command == AIRORSWVERSION ) { if (com.command == AIRORSWVERSION) {
if (copy_to_user(com.data, swversion, sizeof(swversion))) if (copy_to_user(com.data, swversion, sizeof(swversion)))
rc = -EFAULT; rc = -EFAULT;
else else
rc = 0; rc = 0;
} }
else if ( com.command <= AIRORRID) else if (com.command <= AIRORRID)
rc = readrids(dev,&com); rc = readrids(dev,&com);
else if ( com.command >= AIROPCAP && com.command <= (AIROPLEAPUSR+2) ) else if (com.command >= AIROPCAP && com.command <= (AIROPLEAPUSR+2))
rc = writerids(dev,&com); rc = writerids(dev,&com);
else if ( com.command >= AIROFLSHRST && com.command <= AIRORESTART ) else if (com.command >= AIROFLSHRST && com.command <= AIRORESTART)
rc = flashcard(dev,&com); rc = flashcard(dev,&com);
else else
rc = -EINVAL; /* Bad command in ioctl */ rc = -EINVAL; /* Bad command in ioctl */
...@@ -7771,7 +7799,8 @@ static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev) ...@@ -7771,7 +7799,8 @@ static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
* as needed. This represents the READ side of control I/O to * as needed. This represents the READ side of control I/O to
* the card * the card
*/ */
static int readrids(struct net_device *dev, aironet_ioctl *comp) { static int readrids(struct net_device *dev, aironet_ioctl *comp)
{
unsigned short ridcode; unsigned short ridcode;
unsigned char *iobuf; unsigned char *iobuf;
int len; int len;
...@@ -7801,7 +7830,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -7801,7 +7830,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
case AIROGSTATSC32: ridcode = RID_STATS; break; case AIROGSTATSC32: ridcode = RID_STATS; break;
case AIROGMICSTATS: case AIROGMICSTATS:
if (copy_to_user(comp->data, &ai->micstats, if (copy_to_user(comp->data, &ai->micstats,
min((int)comp->len,(int)sizeof(ai->micstats)))) min((int)comp->len, (int)sizeof(ai->micstats))))
return -EFAULT; return -EFAULT;
return 0; return 0;
case AIRORRID: ridcode = comp->ridnum; break; case AIRORRID: ridcode = comp->ridnum; break;
...@@ -7818,7 +7847,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -7818,7 +7847,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
if ((iobuf = kzalloc(RIDSIZE, GFP_KERNEL)) == NULL) if ((iobuf = kzalloc(RIDSIZE, GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
PC4500_readrid(ai,ridcode,iobuf,RIDSIZE, 1); PC4500_readrid(ai, ridcode, iobuf, RIDSIZE, 1);
/* get the count of bytes in the rid docs say 1st 2 bytes is it. /* get the count of bytes in the rid docs say 1st 2 bytes is it.
* then return it to the user * then return it to the user
* 9/22/2000 Honor user given length * 9/22/2000 Honor user given length
...@@ -7837,7 +7866,8 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -7837,7 +7866,8 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
* Danger Will Robinson write the rids here * Danger Will Robinson write the rids here
*/ */
static int writerids(struct net_device *dev, aironet_ioctl *comp) { static int writerids(struct net_device *dev, aironet_ioctl *comp)
{
struct airo_info *ai = dev->ml_priv; struct airo_info *ai = dev->ml_priv;
int ridcode; int ridcode;
int enabled; int enabled;
...@@ -7894,10 +7924,10 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -7894,10 +7924,10 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL) if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDSIZE, 1); PC4500_readrid(ai, RID_STATSDELTACLEAR, iobuf, RIDSIZE, 1);
enabled = ai->micstats.enabled; enabled = ai->micstats.enabled;
memset(&ai->micstats,0,sizeof(ai->micstats)); memset(&ai->micstats, 0, sizeof(ai->micstats));
ai->micstats.enabled = enabled; ai->micstats.enabled = enabled;
if (copy_to_user(comp->data, iobuf, if (copy_to_user(comp->data, iobuf,
...@@ -7911,13 +7941,13 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -7911,13 +7941,13 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
default: default:
return -EOPNOTSUPP; /* Blarg! */ return -EOPNOTSUPP; /* Blarg! */
} }
if(comp->len > RIDSIZE) if (comp->len > RIDSIZE)
return -EINVAL; return -EINVAL;
if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL) if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(iobuf,comp->data,comp->len)) { if (copy_from_user(iobuf, comp->data, comp->len)) {
kfree (iobuf); kfree (iobuf);
return -EFAULT; return -EFAULT;
} }
...@@ -7934,7 +7964,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -7934,7 +7964,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
clear_bit (FLAG_ADHOC, &ai->flags); clear_bit (FLAG_ADHOC, &ai->flags);
} }
if((*writer)(ai, ridcode, iobuf,comp->len,1)) { if ((*writer)(ai, ridcode, iobuf, comp->len, 1)) {
kfree (iobuf); kfree (iobuf);
return -EIO; return -EIO;
} }
...@@ -7951,7 +7981,8 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -7951,7 +7981,8 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
* Flash command switch table * Flash command switch table
*/ */
static int flashcard(struct net_device *dev, aironet_ioctl *comp) { static int flashcard(struct net_device *dev, aironet_ioctl *comp)
{
int z; int z;
/* Only super-user can modify flash */ /* Only super-user can modify flash */
...@@ -7970,23 +8001,23 @@ static int flashcard(struct net_device *dev, aironet_ioctl *comp) { ...@@ -7970,23 +8001,23 @@ static int flashcard(struct net_device *dev, aironet_ioctl *comp) {
return setflashmode((struct airo_info *)dev->ml_priv); return setflashmode((struct airo_info *)dev->ml_priv);
case AIROFLSHGCHR: /* Get char from aux */ case AIROFLSHGCHR: /* Get char from aux */
if(comp->len != sizeof(int)) if (comp->len != sizeof(int))
return -EINVAL; return -EINVAL;
if (copy_from_user(&z,comp->data,comp->len)) if (copy_from_user(&z, comp->data, comp->len))
return -EFAULT; return -EFAULT;
return flashgchar((struct airo_info *)dev->ml_priv, z, 8000); return flashgchar((struct airo_info *)dev->ml_priv, z, 8000);
case AIROFLSHPCHR: /* Send char to card. */ case AIROFLSHPCHR: /* Send char to card. */
if(comp->len != sizeof(int)) if (comp->len != sizeof(int))
return -EINVAL; return -EINVAL;
if (copy_from_user(&z,comp->data,comp->len)) if (copy_from_user(&z, comp->data, comp->len))
return -EFAULT; return -EFAULT;
return flashpchar((struct airo_info *)dev->ml_priv, z, 8000); return flashpchar((struct airo_info *)dev->ml_priv, z, 8000);
case AIROFLPUTBUF: /* Send 32k to card */ case AIROFLPUTBUF: /* Send 32k to card */
if (!AIRO_FLASH(dev)) if (!AIRO_FLASH(dev))
return -ENOMEM; return -ENOMEM;
if(comp->len > FLASHSIZE) if (comp->len > FLASHSIZE)
return -EINVAL; return -EINVAL;
if (copy_from_user(AIRO_FLASH(dev), comp->data, comp->len)) if (copy_from_user(AIRO_FLASH(dev), comp->data, comp->len))
return -EFAULT; return -EFAULT;
...@@ -8010,19 +8041,20 @@ static int flashcard(struct net_device *dev, aironet_ioctl *comp) { ...@@ -8010,19 +8041,20 @@ static int flashcard(struct net_device *dev, aironet_ioctl *comp) {
* card. * card.
*/ */
static int cmdreset(struct airo_info *ai) { static int cmdreset(struct airo_info *ai)
{
disable_MAC(ai, 1); disable_MAC(ai, 1);
if(!waitbusy (ai)){ if (!waitbusy (ai)) {
airo_print_info(ai->dev->name, "Waitbusy hang before RESET"); airo_print_info(ai->dev->name, "Waitbusy hang before RESET");
return -EBUSY; return -EBUSY;
} }
OUT4500(ai,COMMAND,CMD_SOFTRESET); OUT4500(ai, COMMAND, CMD_SOFTRESET);
ssleep(1); /* WAS 600 12/7/00 */ ssleep(1); /* WAS 600 12/7/00 */
if(!waitbusy (ai)){ if (!waitbusy (ai)) {
airo_print_info(ai->dev->name, "Waitbusy hang AFTER RESET"); airo_print_info(ai->dev->name, "Waitbusy hang AFTER RESET");
return -EBUSY; return -EBUSY;
} }
...@@ -8034,22 +8066,23 @@ static int cmdreset(struct airo_info *ai) { ...@@ -8034,22 +8066,23 @@ static int cmdreset(struct airo_info *ai) {
* mode * mode
*/ */
static int setflashmode (struct airo_info *ai) { static int setflashmode (struct airo_info *ai)
{
set_bit (FLAG_FLASHING, &ai->flags); set_bit (FLAG_FLASHING, &ai->flags);
OUT4500(ai, SWS0, FLASH_COMMAND); OUT4500(ai, SWS0, FLASH_COMMAND);
OUT4500(ai, SWS1, FLASH_COMMAND); OUT4500(ai, SWS1, FLASH_COMMAND);
if (probe) { if (probe) {
OUT4500(ai, SWS0, FLASH_COMMAND); OUT4500(ai, SWS0, FLASH_COMMAND);
OUT4500(ai, COMMAND,0x10); OUT4500(ai, COMMAND, 0x10);
} else { } else {
OUT4500(ai, SWS2, FLASH_COMMAND); OUT4500(ai, SWS2, FLASH_COMMAND);
OUT4500(ai, SWS3, FLASH_COMMAND); OUT4500(ai, SWS3, FLASH_COMMAND);
OUT4500(ai, COMMAND,0); OUT4500(ai, COMMAND, 0);
} }
msleep(500); /* 500ms delay */ msleep(500); /* 500ms delay */
if(!waitbusy(ai)) { if (!waitbusy(ai)) {
clear_bit (FLAG_FLASHING, &ai->flags); clear_bit (FLAG_FLASHING, &ai->flags);
airo_print_info(ai->dev->name, "Waitbusy hang after setflash mode"); airo_print_info(ai->dev->name, "Waitbusy hang after setflash mode");
return -EIO; return -EIO;
...@@ -8061,16 +8094,17 @@ static int setflashmode (struct airo_info *ai) { ...@@ -8061,16 +8094,17 @@ static int setflashmode (struct airo_info *ai) {
* x 50us for echo . * x 50us for echo .
*/ */
static int flashpchar(struct airo_info *ai,int byte,int dwelltime) { static int flashpchar(struct airo_info *ai, int byte, int dwelltime)
{
int echo; int echo;
int waittime; int waittime;
byte |= 0x8000; byte |= 0x8000;
if(dwelltime == 0 ) if (dwelltime == 0)
dwelltime = 200; dwelltime = 200;
waittime=dwelltime; waittime = dwelltime;
/* Wait for busy bit d15 to go false indicating buffer empty */ /* Wait for busy bit d15 to go false indicating buffer empty */
while ((IN4500 (ai, SWS0) & 0x8000) && waittime > 0) { while ((IN4500 (ai, SWS0) & 0x8000) && waittime > 0) {
...@@ -8079,20 +8113,20 @@ static int flashpchar(struct airo_info *ai,int byte,int dwelltime) { ...@@ -8079,20 +8113,20 @@ static int flashpchar(struct airo_info *ai,int byte,int dwelltime) {
} }
/* timeout for busy clear wait */ /* timeout for busy clear wait */
if(waittime <= 0 ){ if (waittime <= 0) {
airo_print_info(ai->dev->name, "flash putchar busywait timeout!"); airo_print_info(ai->dev->name, "flash putchar busywait timeout!");
return -EBUSY; return -EBUSY;
} }
/* Port is clear now write byte and wait for it to echo back */ /* Port is clear now write byte and wait for it to echo back */
do { do {
OUT4500(ai,SWS0,byte); OUT4500(ai, SWS0, byte);
udelay(50); udelay(50);
dwelltime -= 50; dwelltime -= 50;
echo = IN4500(ai,SWS1); echo = IN4500(ai, SWS1);
} while (dwelltime >= 0 && echo != byte); } while (dwelltime >= 0 && echo != byte);
OUT4500(ai,SWS1,0); OUT4500(ai, SWS1, 0);
return (echo == byte) ? 0 : -EIO; return (echo == byte) ? 0 : -EIO;
} }
...@@ -8101,29 +8135,30 @@ static int flashpchar(struct airo_info *ai,int byte,int dwelltime) { ...@@ -8101,29 +8135,30 @@ static int flashpchar(struct airo_info *ai,int byte,int dwelltime) {
* Get a character from the card matching matchbyte * Get a character from the card matching matchbyte
* Step 3) * Step 3)
*/ */
static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime){ static int flashgchar(struct airo_info *ai, int matchbyte, int dwelltime)
{
int rchar; int rchar;
unsigned char rbyte=0; unsigned char rbyte = 0;
do { do {
rchar = IN4500(ai,SWS1); rchar = IN4500(ai, SWS1);
if(dwelltime && !(0x8000 & rchar)){ if (dwelltime && !(0x8000 & rchar)) {
dwelltime -= 10; dwelltime -= 10;
mdelay(10); mdelay(10);
continue; continue;
} }
rbyte = 0xff & rchar; rbyte = 0xff & rchar;
if( (rbyte == matchbyte) && (0x8000 & rchar) ){ if ((rbyte == matchbyte) && (0x8000 & rchar)) {
OUT4500(ai,SWS1,0); OUT4500(ai, SWS1, 0);
return 0; return 0;
} }
if( rbyte == 0x81 || rbyte == 0x82 || rbyte == 0x83 || rbyte == 0x1a || 0xffff == rchar) if (rbyte == 0x81 || rbyte == 0x82 || rbyte == 0x83 || rbyte == 0x1a || 0xffff == rchar)
break; break;
OUT4500(ai,SWS1,0); OUT4500(ai, SWS1, 0);
}while(dwelltime > 0); } while (dwelltime > 0);
return -EIO; return -EIO;
} }
...@@ -8132,21 +8167,22 @@ static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime){ ...@@ -8132,21 +8167,22 @@ static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime){
* send to the card * send to the card
*/ */
static int flashputbuf(struct airo_info *ai){ static int flashputbuf(struct airo_info *ai)
{
int nwords; int nwords;
/* Write stuff */ /* Write stuff */
if (test_bit(FLAG_MPI,&ai->flags)) if (test_bit(FLAG_MPI,&ai->flags))
memcpy_toio(ai->pciaux + 0x8000, ai->flash, FLASHSIZE); memcpy_toio(ai->pciaux + 0x8000, ai->flash, FLASHSIZE);
else { else {
OUT4500(ai,AUXPAGE,0x100); OUT4500(ai, AUXPAGE, 0x100);
OUT4500(ai,AUXOFF,0); OUT4500(ai, AUXOFF, 0);
for(nwords=0;nwords != FLASHSIZE / 2;nwords++){ for (nwords = 0; nwords != FLASHSIZE / 2; nwords++) {
OUT4500(ai,AUXDATA,ai->flash[nwords] & 0xffff); OUT4500(ai, AUXDATA, ai->flash[nwords] & 0xffff);
} }
} }
OUT4500(ai,SWS0,0x8000); OUT4500(ai, SWS0, 0x8000);
return 0; return 0;
} }
...@@ -8154,8 +8190,9 @@ static int flashputbuf(struct airo_info *ai){ ...@@ -8154,8 +8190,9 @@ static int flashputbuf(struct airo_info *ai){
/* /*
* *
*/ */
static int flashrestart(struct airo_info *ai,struct net_device *dev){ static int flashrestart(struct airo_info *ai, struct net_device *dev)
int i,status; {
int i, status;
ssleep(1); /* Added 12/7/00 */ ssleep(1); /* Added 12/7/00 */
clear_bit (FLAG_FLASHING, &ai->flags); clear_bit (FLAG_FLASHING, &ai->flags);
...@@ -8167,9 +8204,9 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev){ ...@@ -8167,9 +8204,9 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev){
status = setup_card(ai, dev->dev_addr, 1); status = setup_card(ai, dev->dev_addr, 1);
if (!test_bit(FLAG_MPI,&ai->flags)) if (!test_bit(FLAG_MPI,&ai->flags))
for( i = 0; i < MAX_FIDS; i++ ) { for (i = 0; i < MAX_FIDS; i++) {
ai->fids[i] = transmit_allocate ai->fids[i] = transmit_allocate
( ai, AIRO_DEF_MTU, i >= MAX_FIDS / 2 ); (ai, AIRO_DEF_MTU, i >= MAX_FIDS / 2);
} }
ssleep(1); /* Added 12/7/00 */ ssleep(1); /* Added 12/7/00 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment