hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/net/wireless/cisco/airo.c
....@@ -49,6 +49,9 @@
4949 #include <linux/kthread.h>
5050 #include <linux/freezer.h>
5151
52
+#include <crypto/aes.h>
53
+#include <crypto/skcipher.h>
54
+
5255 #include <net/cfg80211.h>
5356 #include <net/iw_handler.h>
5457
....@@ -71,16 +74,19 @@
7174
7275 static int airo_pci_probe(struct pci_dev *, const struct pci_device_id *);
7376 static void airo_pci_remove(struct pci_dev *);
74
-static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state);
75
-static int airo_pci_resume(struct pci_dev *pdev);
77
+static int __maybe_unused airo_pci_suspend(struct device *dev);
78
+static int __maybe_unused airo_pci_resume(struct device *dev);
79
+
80
+static SIMPLE_DEV_PM_OPS(airo_pci_pm_ops,
81
+ airo_pci_suspend,
82
+ airo_pci_resume);
7683
7784 static struct pci_driver airo_driver = {
78
- .name = DRV_NAME,
79
- .id_table = card_ids,
80
- .probe = airo_pci_probe,
81
- .remove = airo_pci_remove,
82
- .suspend = airo_pci_suspend,
83
- .resume = airo_pci_resume,
85
+ .name = DRV_NAME,
86
+ .id_table = card_ids,
87
+ .probe = airo_pci_probe,
88
+ .remove = airo_pci_remove,
89
+ .driver.pm = &airo_pci_pm_ops,
8490 };
8591 #endif /* CONFIG_PCI */
8692
....@@ -315,8 +321,8 @@
315321 #define CMD_DELTLV 0x002b
316322 #define CMD_FINDNEXTTLV 0x002c
317323 #define CMD_PSPNODES 0x0030
318
-#define CMD_SETCW 0x0031
319
-#define CMD_SETPCF 0x0032
324
+#define CMD_SETCW 0x0031
325
+#define CMD_SETPCF 0x0032
320326 #define CMD_SETPHYREG 0x003e
321327 #define CMD_TXTEST 0x003f
322328 #define MAC_ENABLETX 0x0101
....@@ -427,7 +433,7 @@
427433 #define STATUS_INTS (EV_AWAKE|EV_LINK|EV_TXEXC|EV_TX|EV_TXCPY|EV_RX|EV_MIC)
428434
429435 #ifdef CHECK_UNKNOWN_INTS
430
-#define IGNORE_INTS ( EV_CMD | EV_UNKNOWN)
436
+#define IGNORE_INTS (EV_CMD | EV_UNKNOWN)
431437 #else
432438 #define IGNORE_INTS (~STATUS_INTS)
433439 #endif
....@@ -951,7 +957,7 @@
951957 } mic_statistics;
952958
953959 typedef struct {
954
- u32 coeff[((EMMH32_MSGLEN_MAX)+3)>>2];
960
+ __be32 coeff[((EMMH32_MSGLEN_MAX)+3)>>2];
955961 u64 accum; // accumulated mic, reduced to u32 in final()
956962 int position; // current position (byte offset) in message
957963 union {
....@@ -1101,9 +1107,9 @@
11011107
11021108 struct airo_info;
11031109
1104
-static int get_dec_u16( char *buffer, int *start, int limit );
1105
-static void OUT4500( struct airo_info *, u16 reg, u16 value );
1106
-static unsigned short IN4500( struct airo_info *, u16 reg );
1110
+static int get_dec_u16(char *buffer, int *start, int limit);
1111
+static void OUT4500(struct airo_info *, u16 reg, u16 value);
1112
+static unsigned short IN4500(struct airo_info *, u16 reg);
11071113 static u16 setup_card(struct airo_info*, u8 *mac, int lock);
11081114 static int enable_MAC(struct airo_info *ai, int lock);
11091115 static void disable_MAC(struct airo_info *ai, int lock);
....@@ -1121,24 +1127,24 @@
11211127 static int PC4500_readrid(struct airo_info*, u16 rid, void *pBuf, int len, int lock);
11221128 static int PC4500_writerid(struct airo_info*, u16 rid, const void
11231129 *pBuf, int len, int lock);
1124
-static int do_writerid( struct airo_info*, u16 rid, const void *rid_data,
1125
- int len, int dummy );
1130
+static int do_writerid(struct airo_info*, u16 rid, const void *rid_data,
1131
+ int len, int dummy);
11261132 static u16 transmit_allocate(struct airo_info*, int lenPayload, int raw);
11271133 static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket);
11281134 static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket);
11291135
1130
-static int mpi_send_packet (struct net_device *dev);
1136
+static int mpi_send_packet(struct net_device *dev);
11311137 static void mpi_unmap_card(struct pci_dev *pci);
11321138 static void mpi_receive_802_3(struct airo_info *ai);
11331139 static void mpi_receive_802_11(struct airo_info *ai);
1134
-static int waitbusy (struct airo_info *ai);
1140
+static int waitbusy(struct airo_info *ai);
11351141
1136
-static irqreturn_t airo_interrupt( int irq, void* dev_id);
1142
+static irqreturn_t airo_interrupt(int irq, void* dev_id);
11371143 static int airo_thread(void *data);
1138
-static void timer_func( struct net_device *dev );
1144
+static void timer_func(struct net_device *dev);
11391145 static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
1140
-static struct iw_statistics *airo_get_wireless_stats (struct net_device *dev);
1141
-static void airo_read_wireless_stats (struct airo_info *local);
1146
+static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev);
1147
+static void airo_read_wireless_stats(struct airo_info *local);
11421148 #ifdef CISCO_EXT
11431149 static int readrids(struct net_device *dev, aironet_ioctl *comp);
11441150 static int writerids(struct net_device *dev, aironet_ioctl *comp);
....@@ -1149,8 +1155,8 @@
11491155 static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len);
11501156 static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen);
11511157
1152
-static u8 airo_rssi_to_dbm (tdsRssiEntry *rssi_rid, u8 rssi);
1153
-static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm);
1158
+static u8 airo_rssi_to_dbm(tdsRssiEntry *rssi_rid, u8 rssi);
1159
+static u8 airo_dbm_to_pct(tdsRssiEntry *rssi_rid, u8 dbm);
11541160
11551161 static void airo_networks_free(struct airo_info *ai);
11561162
....@@ -1216,7 +1222,7 @@
12161222 struct iw_spy_data spy_data;
12171223 struct iw_public_data wireless_data;
12181224 /* MIC stuff */
1219
- struct crypto_cipher *tfm;
1225
+ struct crypto_sync_skcipher *tfm;
12201226 mic_module mod[2];
12211227 mic_statistics micstats;
12221228 HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors
....@@ -1255,16 +1261,16 @@
12551261 return ai->bap_read(ai, pu16Dst, bytelen, whichbap);
12561262 }
12571263
1258
-static int setup_proc_entry( struct net_device *dev,
1259
- struct airo_info *apriv );
1260
-static int takedown_proc_entry( struct net_device *dev,
1261
- struct airo_info *apriv );
1264
+static int setup_proc_entry(struct net_device *dev,
1265
+ struct airo_info *apriv);
1266
+static int takedown_proc_entry(struct net_device *dev,
1267
+ struct airo_info *apriv);
12621268
12631269 static int cmdreset(struct airo_info *ai);
1264
-static int setflashmode (struct airo_info *ai);
1265
-static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime);
1270
+static int setflashmode(struct airo_info *ai);
1271
+static int flashgchar(struct airo_info *ai, int matchbyte, int dwelltime);
12661272 static int flashputbuf(struct airo_info *ai);
1267
-static int flashrestart(struct airo_info *ai,struct net_device *dev);
1273
+static int flashrestart(struct airo_info *ai, struct net_device *dev);
12681274
12691275 #define airo_print(type, name, fmt, args...) \
12701276 printk(type DRV_NAME "(%s): " fmt "\n", name, ##args)
....@@ -1288,17 +1294,17 @@
12881294 ***********************************************************************
12891295 */
12901296
1291
-static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq);
1297
+static int RxSeqValid(struct airo_info *ai, miccntx *context, int mcast, u32 micSeq);
12921298 static void MoveWindow(miccntx *context, u32 micSeq);
12931299 static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
1294
- struct crypto_cipher *tfm);
1300
+ struct crypto_sync_skcipher *tfm);
12951301 static void emmh32_init(emmh32_context *context);
12961302 static void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
12971303 static void emmh32_final(emmh32_context *context, u8 digest[4]);
1298
-static int flashpchar(struct airo_info *ai,int byte,int dwelltime);
1304
+static int flashpchar(struct airo_info *ai, int byte, int dwelltime);
12991305
13001306 static void age_mic_context(miccntx *cur, miccntx *old, u8 *key, int key_len,
1301
- struct crypto_cipher *tfm)
1307
+ struct crypto_sync_skcipher *tfm)
13021308 {
13031309 /* If the current MIC context is valid and its key is the same as
13041310 * the MIC register, there's nothing to do.
....@@ -1355,11 +1361,12 @@
13551361
13561362 /* micsetup - Get ready for business */
13571363
1358
-static int micsetup(struct airo_info *ai) {
1364
+static int micsetup(struct airo_info *ai)
1365
+{
13591366 int i;
13601367
13611368 if (ai->tfm == NULL)
1362
- ai->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
1369
+ ai->tfm = crypto_alloc_sync_skcipher("ctr(aes)", 0, 0);
13631370
13641371 if (IS_ERR(ai->tfm)) {
13651372 airo_print_err(ai->dev->name, "failed to load transform for AES");
....@@ -1367,32 +1374,32 @@
13671374 return ERROR;
13681375 }
13691376
1370
- for (i=0; i < NUM_MODULES; i++) {
1371
- memset(&ai->mod[i].mCtx,0,sizeof(miccntx));
1372
- memset(&ai->mod[i].uCtx,0,sizeof(miccntx));
1377
+ for (i = 0; i < NUM_MODULES; i++) {
1378
+ memset(&ai->mod[i].mCtx, 0, sizeof(miccntx));
1379
+ memset(&ai->mod[i].uCtx, 0, sizeof(miccntx));
13731380 }
13741381 return SUCCESS;
13751382 }
13761383
1377
-static const u8 micsnap[] = {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02};
1384
+static const u8 micsnap[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x02};
13781385
13791386 /*===========================================================================
13801387 * Description: Mic a packet
1381
- *
1388
+ *
13821389 * Inputs: etherHead * pointer to an 802.3 frame
1383
- *
1390
+ *
13841391 * Returns: BOOLEAN if successful, otherwise false.
13851392 * PacketTxLen will be updated with the mic'd packets size.
13861393 *
13871394 * Caveats: It is assumed that the frame buffer will already
13881395 * be big enough to hold the largets mic message possible.
13891396 * (No memory allocation is done here).
1390
- *
1397
+ *
13911398 * Author: sbraneky (10/15/01)
13921399 * Merciless hacks by rwilcher (1/14/02)
13931400 */
13941401
1395
-static int encapsulate(struct airo_info *ai ,etherHead *frame, MICBuffer *mic, int payLen)
1402
+static int encapsulate(struct airo_info *ai, etherHead *frame, MICBuffer *mic, int payLen)
13961403 {
13971404 miccntx *context;
13981405
....@@ -1403,7 +1410,7 @@
14031410 context = &ai->mod[0].mCtx;
14041411 else
14051412 context = &ai->mod[0].uCtx;
1406
-
1413
+
14071414 if (!context->valid)
14081415 return ERROR;
14091416
....@@ -1416,10 +1423,10 @@
14161423 context->tx += 2;
14171424
14181425 emmh32_init(&context->seed); // Mic the packet
1419
- emmh32_update(&context->seed,frame->da,ETH_ALEN * 2); // DA,SA
1420
- emmh32_update(&context->seed,(u8*)&mic->typelen,10); // Type/Length and Snap
1421
- emmh32_update(&context->seed,(u8*)&mic->seq,sizeof(mic->seq)); //SEQ
1422
- emmh32_update(&context->seed,(u8*)(frame + 1),payLen); //payload
1426
+ emmh32_update(&context->seed, frame->da, ETH_ALEN * 2); // DA, SA
1427
+ emmh32_update(&context->seed, (u8*)&mic->typelen, 10); // Type/Length and Snap
1428
+ emmh32_update(&context->seed, (u8*)&mic->seq, sizeof(mic->seq)); //SEQ
1429
+ emmh32_update(&context->seed, (u8*)(frame + 1), payLen); //payload
14231430 emmh32_final(&context->seed, (u8*)&mic->mic);
14241431
14251432 /* New Type/length ?????????? */
....@@ -1438,11 +1445,11 @@
14381445 /*===========================================================================
14391446 * Description: Decapsulates a MIC'd packet and returns the 802.3 packet
14401447 * (removes the MIC stuff) if packet is a valid packet.
1441
- *
1442
- * Inputs: etherHead pointer to the 802.3 packet
1443
- *
1448
+ *
1449
+ * Inputs: etherHead pointer to the 802.3 packet
1450
+ *
14441451 * Returns: BOOLEAN - TRUE if packet should be dropped otherwise FALSE
1445
- *
1452
+ *
14461453 * Author: sbraneky (10/15/01)
14471454 * Merciless hacks by rwilcher (1/14/02)
14481455 *---------------------------------------------------------------------------
....@@ -1482,35 +1489,35 @@
14821489 //Now do the mic error checking.
14831490
14841491 //Receive seq must be odd
1485
- if ( (micSEQ & 1) == 0 ) {
1492
+ if ((micSEQ & 1) == 0) {
14861493 ai->micstats.rxWrongSequence++;
14871494 return ERROR;
14881495 }
14891496
14901497 for (i = 0; i < NUM_MODULES; i++) {
14911498 int mcast = eth->da[0] & 1;
1492
- //Determine proper context
1499
+ //Determine proper context
14931500 context = mcast ? &ai->mod[i].mCtx : &ai->mod[i].uCtx;
1494
-
1501
+
14951502 //Make sure context is valid
14961503 if (!context->valid) {
14971504 if (i == 0)
14981505 micError = NOMICPLUMMED;
1499
- continue;
1506
+ continue;
15001507 }
1501
- //DeMic it
1508
+ //DeMic it
15021509
15031510 if (!mic->typelen)
15041511 mic->typelen = htons(payLen + sizeof(MICBuffer) - 2);
1505
-
1512
+
15061513 emmh32_init(&context->seed);
1507
- emmh32_update(&context->seed, eth->da, ETH_ALEN*2);
1508
- emmh32_update(&context->seed, (u8 *)&mic->typelen, sizeof(mic->typelen)+sizeof(mic->u.snap));
1509
- emmh32_update(&context->seed, (u8 *)&mic->seq,sizeof(mic->seq));
1510
- emmh32_update(&context->seed, (u8 *)(eth + 1),payLen);
1514
+ emmh32_update(&context->seed, eth->da, ETH_ALEN*2);
1515
+ emmh32_update(&context->seed, (u8 *)&mic->typelen, sizeof(mic->typelen)+sizeof(mic->u.snap));
1516
+ emmh32_update(&context->seed, (u8 *)&mic->seq, sizeof(mic->seq));
1517
+ emmh32_update(&context->seed, (u8 *)(eth + 1), payLen);
15111518 //Calculate MIC
15121519 emmh32_final(&context->seed, digest);
1513
-
1520
+
15141521 if (memcmp(digest, &mic->mic, 4)) { //Make sure the mics match
15151522 //Invalid Mic
15161523 if (i == 0)
....@@ -1541,22 +1548,22 @@
15411548 /*===========================================================================
15421549 * Description: Checks the Rx Seq number to make sure it is valid
15431550 * and hasn't already been received
1544
- *
1551
+ *
15451552 * Inputs: miccntx - mic context to check seq against
15461553 * micSeq - the Mic seq number
1547
- *
1548
- * Returns: TRUE if valid otherwise FALSE.
1554
+ *
1555
+ * Returns: TRUE if valid otherwise FALSE.
15491556 *
15501557 * Author: sbraneky (10/15/01)
15511558 * Merciless hacks by rwilcher (1/14/02)
15521559 *---------------------------------------------------------------------------
15531560 */
15541561
1555
-static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq)
1562
+static int RxSeqValid(struct airo_info *ai, miccntx *context, int mcast, u32 micSeq)
15561563 {
1557
- u32 seq,index;
1564
+ u32 seq, index;
15581565
1559
- //Allow for the ap being rebooted - if it is then use the next
1566
+ //Allow for the ap being rebooted - if it is then use the next
15601567 //sequence number of the current sequence number - might go backwards
15611568
15621569 if (mcast) {
....@@ -1577,10 +1584,10 @@
15771584 //Too old of a SEQ number to check.
15781585 if ((s32)seq < 0)
15791586 return ERROR;
1580
-
1581
- if ( seq > 64 ) {
1587
+
1588
+ if (seq > 64) {
15821589 //Window is infinite forward
1583
- MoveWindow(context,micSeq);
1590
+ MoveWindow(context, micSeq);
15841591 return SUCCESS;
15851592 }
15861593
....@@ -1593,7 +1600,7 @@
15931600 //Add seqence number to the list of received numbers.
15941601 context->rx |= index;
15951602
1596
- MoveWindow(context,micSeq);
1603
+ MoveWindow(context, micSeq);
15971604
15981605 return SUCCESS;
15991606 }
....@@ -1607,7 +1614,7 @@
16071614 //Move window if seq greater than the middle of the window
16081615 if (micSeq > context->window) {
16091616 shift = (micSeq - context->window) >> 1;
1610
-
1617
+
16111618 //Shift out old
16121619 if (shift < 32)
16131620 context->rx >>= shift;
....@@ -1624,37 +1631,31 @@
16241631
16251632 /* mic accumulate */
16261633 #define MIC_ACCUM(val) \
1627
- context->accum += (u64)(val) * context->coeff[coeff_position++];
1628
-
1629
-static unsigned char aes_counter[16];
1634
+ context->accum += (u64)(val) * be32_to_cpu(context->coeff[coeff_position++]);
16301635
16311636 /* expand the key to fill the MMH coefficient array */
16321637 static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
1633
- struct crypto_cipher *tfm)
1638
+ struct crypto_sync_skcipher *tfm)
16341639 {
16351640 /* take the keying material, expand if necessary, truncate at 16-bytes */
16361641 /* run through AES counter mode to generate context->coeff[] */
1637
-
1638
- int i,j;
1639
- u32 counter;
1640
- u8 *cipher, plain[16];
16411642
1642
- crypto_cipher_setkey(tfm, pkey, 16);
1643
- counter = 0;
1644
- for (i = 0; i < ARRAY_SIZE(context->coeff); ) {
1645
- aes_counter[15] = (u8)(counter >> 0);
1646
- aes_counter[14] = (u8)(counter >> 8);
1647
- aes_counter[13] = (u8)(counter >> 16);
1648
- aes_counter[12] = (u8)(counter >> 24);
1649
- counter++;
1650
- memcpy (plain, aes_counter, 16);
1651
- crypto_cipher_encrypt_one(tfm, plain, plain);
1652
- cipher = plain;
1653
- for (j = 0; (j < 16) && (i < ARRAY_SIZE(context->coeff)); ) {
1654
- context->coeff[i++] = ntohl(*(__be32 *)&cipher[j]);
1655
- j += 4;
1656
- }
1657
- }
1643
+ SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm);
1644
+ struct scatterlist sg;
1645
+ u8 iv[AES_BLOCK_SIZE] = {};
1646
+ int ret;
1647
+
1648
+ crypto_sync_skcipher_setkey(tfm, pkey, 16);
1649
+
1650
+ memset(context->coeff, 0, sizeof(context->coeff));
1651
+ sg_init_one(&sg, context->coeff, sizeof(context->coeff));
1652
+
1653
+ skcipher_request_set_sync_tfm(req, tfm);
1654
+ skcipher_request_set_callback(req, 0, NULL, NULL);
1655
+ skcipher_request_set_crypt(req, &sg, &sg, sizeof(context->coeff), iv);
1656
+
1657
+ ret = crypto_skcipher_encrypt(req);
1658
+ WARN_ON_ONCE(ret);
16581659 }
16591660
16601661 /* prepare for calculation of a new mic */
....@@ -1669,11 +1670,11 @@
16691670 static void emmh32_update(emmh32_context *context, u8 *pOctets, int len)
16701671 {
16711672 int coeff_position, byte_position;
1672
-
1673
+
16731674 if (len == 0) return;
1674
-
1675
+
16751676 coeff_position = context->position >> 2;
1676
-
1677
+
16771678 /* deal with partial 32-bit word left over from last update */
16781679 byte_position = context->position & 3;
16791680 if (byte_position) {
....@@ -1712,12 +1713,12 @@
17121713 {
17131714 int coeff_position, byte_position;
17141715 u32 val;
1715
-
1716
+
17161717 u64 sum, utmp;
17171718 s64 stmp;
17181719
17191720 coeff_position = context->position >> 2;
1720
-
1721
+
17211722 /* deal with partial 32-bit word left over from last update */
17221723 byte_position = context->position & 3;
17231724 if (byte_position) {
....@@ -1750,7 +1751,7 @@
17501751 if (first == 1) {
17511752 if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN;
17521753 memset(&cmd, 0, sizeof(cmd));
1753
- cmd.cmd=CMD_LISTBSS;
1754
+ cmd.cmd = CMD_LISTBSS;
17541755 if (down_interruptible(&ai->sem))
17551756 return -ERESTARTSYS;
17561757 ai->list_bss_task = current;
....@@ -1815,7 +1816,7 @@
18151816 int i;
18161817 /* Old hardware had a limit on encryption speed */
18171818 if (ai->config.authType != AUTH_OPEN && maxencrypt) {
1818
- for(i=0; i<8; i++) {
1819
+ for (i = 0; i<8; i++) {
18191820 if (ai->config.rates[i] > maxencrypt) {
18201821 ai->config.rates[i] = 0;
18211822 }
....@@ -1840,7 +1841,7 @@
18401841 else
18411842 clear_bit(FLAG_ADHOC, &ai->flags);
18421843
1843
- return PC4500_writerid( ai, RID_CONFIG, &cfgr, sizeof(cfgr), lock);
1844
+ return PC4500_writerid(ai, RID_CONFIG, &cfgr, sizeof(cfgr), lock);
18441845 }
18451846
18461847 static int readStatusRid(struct airo_info *ai, StatusRid *statr, int lock)
....@@ -1871,7 +1872,8 @@
18711872 }
18721873 }
18731874
1874
-static int airo_open(struct net_device *dev) {
1875
+static int airo_open(struct net_device *dev)
1876
+{
18751877 struct airo_info *ai = dev->ml_priv;
18761878 int rc = 0;
18771879
....@@ -1947,7 +1949,7 @@
19471949 spin_lock_irqsave(&ai->aux_lock, flags);
19481950 skb_queue_tail (&ai->txq, skb);
19491951 pending = test_bit(FLAG_PENDING_XMIT, &ai->flags);
1950
- spin_unlock_irqrestore(&ai->aux_lock,flags);
1952
+ spin_unlock_irqrestore(&ai->aux_lock, flags);
19511953 netif_wake_queue (dev);
19521954
19531955 if (pending == 0) {
....@@ -2096,7 +2098,8 @@
20962098 }
20972099 }
20982100
2099
-static void airo_end_xmit(struct net_device *dev) {
2101
+static void airo_end_xmit(struct net_device *dev)
2102
+{
21002103 u16 status;
21012104 int i;
21022105 struct airo_info *priv = dev->ml_priv;
....@@ -2110,7 +2113,7 @@
21102113 up(&priv->sem);
21112114
21122115 i = 0;
2113
- if ( status == SUCCESS ) {
2116
+ if (status == SUCCESS) {
21142117 netif_trans_update(dev);
21152118 for (; i < MAX_FIDS / 2 && (priv->fids[i] & 0xffff0000); i++);
21162119 } else {
....@@ -2130,7 +2133,7 @@
21302133 struct airo_info *priv = dev->ml_priv;
21312134 u32 *fids = priv->fids;
21322135
2133
- if ( skb == NULL ) {
2136
+ if (skb == NULL) {
21342137 airo_print_err(dev->name, "%s: skb == NULL!", __func__);
21352138 return NETDEV_TX_OK;
21362139 }
....@@ -2140,10 +2143,10 @@
21402143 }
21412144
21422145 /* Find a vacant FID */
2143
- for( i = 0; i < MAX_FIDS / 2 && (fids[i] & 0xffff0000); i++ );
2144
- for( j = i + 1; j < MAX_FIDS / 2 && (fids[j] & 0xffff0000); j++ );
2146
+ for (i = 0; i < MAX_FIDS / 2 && (fids[i] & 0xffff0000); i++);
2147
+ for (j = i + 1; j < MAX_FIDS / 2 && (fids[j] & 0xffff0000); j++);
21452148
2146
- if ( j >= MAX_FIDS / 2 ) {
2149
+ if (j >= MAX_FIDS / 2) {
21472150 netif_stop_queue(dev);
21482151
21492152 if (i == MAX_FIDS / 2) {
....@@ -2167,7 +2170,8 @@
21672170 return NETDEV_TX_OK;
21682171 }
21692172
2170
-static void airo_end_xmit11(struct net_device *dev) {
2173
+static void airo_end_xmit11(struct net_device *dev)
2174
+{
21712175 u16 status;
21722176 int i;
21732177 struct airo_info *priv = dev->ml_priv;
....@@ -2181,7 +2185,7 @@
21812185 up(&priv->sem);
21822186
21832187 i = MAX_FIDS / 2;
2184
- if ( status == SUCCESS ) {
2188
+ if (status == SUCCESS) {
21852189 netif_trans_update(dev);
21862190 for (; i < MAX_FIDS && (priv->fids[i] & 0xffff0000); i++);
21872191 } else {
....@@ -2208,7 +2212,7 @@
22082212 return NETDEV_TX_OK;
22092213 }
22102214
2211
- if ( skb == NULL ) {
2215
+ if (skb == NULL) {
22122216 airo_print_err(dev->name, "%s: skb == NULL!", __func__);
22132217 return NETDEV_TX_OK;
22142218 }
....@@ -2218,10 +2222,10 @@
22182222 }
22192223
22202224 /* Find a vacant FID */
2221
- for( i = MAX_FIDS / 2; i < MAX_FIDS && (fids[i] & 0xffff0000); i++ );
2222
- for( j = i + 1; j < MAX_FIDS && (fids[j] & 0xffff0000); j++ );
2225
+ for (i = MAX_FIDS / 2; i < MAX_FIDS && (fids[i] & 0xffff0000); i++);
2226
+ for (j = i + 1; j < MAX_FIDS && (fids[j] & 0xffff0000); j++);
22232227
2224
- if ( j >= MAX_FIDS ) {
2228
+ if (j >= MAX_FIDS) {
22252229 netif_stop_queue(dev);
22262230
22272231 if (i == MAX_FIDS) {
....@@ -2295,19 +2299,21 @@
22952299 return &dev->stats;
22962300 }
22972301
2298
-static void airo_set_promisc(struct airo_info *ai) {
2302
+static void airo_set_promisc(struct airo_info *ai)
2303
+{
22992304 Cmd cmd;
23002305 Resp rsp;
23012306
23022307 memset(&cmd, 0, sizeof(cmd));
2303
- cmd.cmd=CMD_SETMODE;
2308
+ cmd.cmd = CMD_SETMODE;
23042309 clear_bit(JOB_PROMISC, &ai->jobs);
23052310 cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC;
23062311 issuecommand(ai, &cmd, &rsp);
23072312 up(&ai->sem);
23082313 }
23092314
2310
-static void airo_set_multicast_list(struct net_device *dev) {
2315
+static void airo_set_multicast_list(struct net_device *dev)
2316
+{
23112317 struct airo_info *ai = dev->ml_priv;
23122318
23132319 if ((dev->flags ^ ai->flags) & IFF_PROMISC) {
....@@ -2357,7 +2363,8 @@
23572363 list_del(&ai->dev_list);
23582364 }
23592365
2360
-static int airo_close(struct net_device *dev) {
2366
+static int airo_close(struct net_device *dev)
2367
+{
23612368 struct airo_info *ai = dev->ml_priv;
23622369
23632370 netif_stop_queue(dev);
....@@ -2372,7 +2379,7 @@
23722379 set_bit(FLAG_RADIO_DOWN, &ai->flags);
23732380 disable_MAC(ai, 1);
23742381 #endif
2375
- disable_interrupts( ai );
2382
+ disable_interrupts(ai);
23762383
23772384 free_irq(dev->irq, dev);
23782385
....@@ -2382,16 +2389,16 @@
23822389 return 0;
23832390 }
23842391
2385
-void stop_airo_card( struct net_device *dev, int freeres )
2392
+void stop_airo_card(struct net_device *dev, int freeres)
23862393 {
23872394 struct airo_info *ai = dev->ml_priv;
23882395
23892396 set_bit(FLAG_RADIO_DOWN, &ai->flags);
23902397 disable_MAC(ai, 1);
23912398 disable_interrupts(ai);
2392
- takedown_proc_entry( dev, ai );
2399
+ takedown_proc_entry(dev, ai);
23932400 if (test_bit(FLAG_REGISTERED, &ai->flags)) {
2394
- unregister_netdev( dev );
2401
+ unregister_netdev(dev);
23952402 if (ai->wifidev) {
23962403 unregister_netdev(ai->wifidev);
23972404 free_netdev(ai->wifidev);
....@@ -2415,7 +2422,7 @@
24152422 kfree(ai->SSID);
24162423 if (freeres) {
24172424 /* PCMCIA frees this stuff, so only for PCI and ISA */
2418
- release_region( dev->base_addr, 64 );
2425
+ release_region(dev->base_addr, 64);
24192426 if (test_bit(FLAG_MPI, &ai->flags)) {
24202427 if (ai->pci)
24212428 mpi_unmap_card(ai->pci);
....@@ -2423,13 +2430,13 @@
24232430 iounmap(ai->pcimem);
24242431 if (ai->pciaux)
24252432 iounmap(ai->pciaux);
2426
- pci_free_consistent(ai->pci, PCI_SHARED_LEN,
2427
- ai->shared, ai->shared_dma);
2433
+ dma_free_coherent(&ai->pci->dev, PCI_SHARED_LEN,
2434
+ ai->shared, ai->shared_dma);
24282435 }
24292436 }
2430
- crypto_free_cipher(ai->tfm);
2437
+ crypto_free_sync_skcipher(ai->tfm);
24312438 del_airo_dev(ai);
2432
- free_netdev( dev );
2439
+ free_netdev(dev);
24332440 }
24342441
24352442 EXPORT_SYMBOL(stop_airo_card);
....@@ -2453,7 +2460,7 @@
24532460
24542461 /*************************************************************
24552462 * This routine assumes that descriptors have been setup .
2456
- * Run at insmod time or after reset when the decriptors
2463
+ * Run at insmod time or after reset when the descriptors
24572464 * have been initialized . Returns 0 if all is well nz
24582465 * otherwise . Does not allocate memory but sets up card
24592466 * using previously allocated descriptors.
....@@ -2468,56 +2475,56 @@
24682475 /* Alloc card RX descriptors */
24692476 netif_stop_queue(ai->dev);
24702477
2471
- memset(&rsp,0,sizeof(rsp));
2472
- memset(&cmd,0,sizeof(cmd));
2478
+ memset(&rsp, 0, sizeof(rsp));
2479
+ memset(&cmd, 0, sizeof(cmd));
24732480
24742481 cmd.cmd = CMD_ALLOCATEAUX;
24752482 cmd.parm0 = FID_RX;
24762483 cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux);
24772484 cmd.parm2 = MPI_MAX_FIDS;
2478
- rc=issuecommand(ai, &cmd, &rsp);
2485
+ rc = issuecommand(ai, &cmd, &rsp);
24792486 if (rc != SUCCESS) {
24802487 airo_print_err(ai->dev->name, "Couldn't allocate RX FID");
24812488 return rc;
24822489 }
24832490
2484
- for (i=0; i<MPI_MAX_FIDS; i++) {
2491
+ for (i = 0; i<MPI_MAX_FIDS; i++) {
24852492 memcpy_toio(ai->rxfids[i].card_ram_off,
24862493 &ai->rxfids[i].rx_desc, sizeof(RxFid));
24872494 }
24882495
24892496 /* Alloc card TX descriptors */
24902497
2491
- memset(&rsp,0,sizeof(rsp));
2492
- memset(&cmd,0,sizeof(cmd));
2498
+ memset(&rsp, 0, sizeof(rsp));
2499
+ memset(&cmd, 0, sizeof(cmd));
24932500
24942501 cmd.cmd = CMD_ALLOCATEAUX;
24952502 cmd.parm0 = FID_TX;
24962503 cmd.parm1 = (ai->txfids[0].card_ram_off - ai->pciaux);
24972504 cmd.parm2 = MPI_MAX_FIDS;
24982505
2499
- for (i=0; i<MPI_MAX_FIDS; i++) {
2506
+ for (i = 0; i<MPI_MAX_FIDS; i++) {
25002507 ai->txfids[i].tx_desc.valid = 1;
25012508 memcpy_toio(ai->txfids[i].card_ram_off,
25022509 &ai->txfids[i].tx_desc, sizeof(TxFid));
25032510 }
25042511 ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */
25052512
2506
- rc=issuecommand(ai, &cmd, &rsp);
2513
+ rc = issuecommand(ai, &cmd, &rsp);
25072514 if (rc != SUCCESS) {
25082515 airo_print_err(ai->dev->name, "Couldn't allocate TX FID");
25092516 return rc;
25102517 }
25112518
25122519 /* Alloc card Rid descriptor */
2513
- memset(&rsp,0,sizeof(rsp));
2514
- memset(&cmd,0,sizeof(cmd));
2520
+ memset(&rsp, 0, sizeof(rsp));
2521
+ memset(&cmd, 0, sizeof(cmd));
25152522
25162523 cmd.cmd = CMD_ALLOCATEAUX;
25172524 cmd.parm0 = RID_RW;
25182525 cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux);
25192526 cmd.parm2 = 1; /* Magic number... */
2520
- rc=issuecommand(ai, &cmd, &rsp);
2527
+ rc = issuecommand(ai, &cmd, &rsp);
25212528 if (rc != SUCCESS) {
25222529 airo_print_err(ai->dev->name, "Couldn't allocate RID");
25232530 return rc;
....@@ -2574,9 +2581,10 @@
25742581 }
25752582
25762583 /* Reserve PKTSIZE for each fid and 2K for the Rids */
2577
- ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma);
2584
+ ai->shared = dma_alloc_coherent(&pci->dev, PCI_SHARED_LEN,
2585
+ &ai->shared_dma, GFP_KERNEL);
25782586 if (!ai->shared) {
2579
- airo_print_err("", "Couldn't alloc_consistent %d",
2587
+ airo_print_err("", "Couldn't alloc_coherent %d",
25802588 PCI_SHARED_LEN);
25812589 goto free_auxmap;
25822590 }
....@@ -2589,7 +2597,7 @@
25892597 vpackoff = ai->shared;
25902598
25912599 /* RX descriptor setup */
2592
- for(i = 0; i < MPI_MAX_FIDS; i++) {
2600
+ for (i = 0; i < MPI_MAX_FIDS; i++) {
25932601 ai->rxfids[i].pending = 0;
25942602 ai->rxfids[i].card_ram_off = pciaddroff;
25952603 ai->rxfids[i].virtual_host_addr = vpackoff;
....@@ -2604,7 +2612,7 @@
26042612 }
26052613
26062614 /* TX descriptor setup */
2607
- for(i = 0; i < MPI_MAX_FIDS; i++) {
2615
+ for (i = 0; i < MPI_MAX_FIDS; i++) {
26082616 ai->txfids[i].card_ram_off = pciaddroff;
26092617 ai->txfids[i].virtual_host_addr = vpackoff;
26102618 ai->txfids[i].tx_desc.valid = 1;
....@@ -2636,7 +2644,8 @@
26362644
26372645 return 0;
26382646 free_shared:
2639
- pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma);
2647
+ dma_free_coherent(&pci->dev, PCI_SHARED_LEN, ai->shared,
2648
+ ai->shared_dma);
26402649 free_auxmap:
26412650 iounmap(ai->pciaux);
26422651 free_memmap:
....@@ -2674,7 +2683,7 @@
26742683 dev->min_mtu = 68;
26752684 dev->max_mtu = MIC_MSGLEN_MAX;
26762685 dev->addr_len = ETH_ALEN;
2677
- dev->tx_queue_len = 100;
2686
+ dev->tx_queue_len = 100;
26782687
26792688 eth_broadcast_addr(dev->broadcast);
26802689
....@@ -2703,13 +2712,14 @@
27032712 return dev;
27042713 }
27052714
2706
-static int reset_card( struct net_device *dev , int lock) {
2715
+static int reset_card(struct net_device *dev, int lock)
2716
+{
27072717 struct airo_info *ai = dev->ml_priv;
27082718
27092719 if (lock && down_interruptible(&ai->sem))
27102720 return -1;
27112721 waitbusy (ai);
2712
- OUT4500(ai,COMMAND,CMD_SOFTRESET);
2722
+ OUT4500(ai, COMMAND, CMD_SOFTRESET);
27132723 msleep(200);
27142724 waitbusy (ai);
27152725 msleep(200);
....@@ -2774,9 +2784,9 @@
27742784 };
27752785
27762786
2777
-static struct net_device *_init_airo_card( unsigned short irq, int port,
2787
+static struct net_device *_init_airo_card(unsigned short irq, int port,
27782788 int is_pcmcia, struct pci_dev *pci,
2779
- struct device *dmdev )
2789
+ struct device *dmdev)
27802790 {
27812791 struct net_device *dev;
27822792 struct airo_info *ai;
....@@ -2849,7 +2859,7 @@
28492859
28502860 if (probe) {
28512861 if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) {
2852
- airo_print_err(dev->name, "MAC could not be enabled" );
2862
+ airo_print_err(dev->name, "MAC could not be enabled");
28532863 rc = -EIO;
28542864 goto err_out_map;
28552865 }
....@@ -2907,8 +2917,8 @@
29072917
29082918 /* Allocate the transmit buffers */
29092919 if (probe && !test_bit(FLAG_MPI,&ai->flags))
2910
- for( i = 0; i < MAX_FIDS; i++ )
2911
- ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
2920
+ for (i = 0; i < MAX_FIDS; i++)
2921
+ ai->fids[i] = transmit_allocate(ai, AIRO_DEF_MTU, i>=MAX_FIDS/2);
29122922
29132923 if (setup_proc_entry(dev, dev->ml_priv) < 0)
29142924 goto err_out_wifi;
....@@ -2922,14 +2932,15 @@
29222932 unregister_netdev(dev);
29232933 err_out_map:
29242934 if (test_bit(FLAG_MPI,&ai->flags) && pci) {
2925
- pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma);
2935
+ dma_free_coherent(&pci->dev, PCI_SHARED_LEN, ai->shared,
2936
+ ai->shared_dma);
29262937 iounmap(ai->pciaux);
29272938 iounmap(ai->pcimem);
29282939 mpi_unmap_card(ai->pci);
29292940 }
29302941 err_out_res:
29312942 if (!is_pcmcia)
2932
- release_region( dev->base_addr, 64 );
2943
+ release_region(dev->base_addr, 64);
29332944 err_out_nets:
29342945 airo_networks_free(ai);
29352946 err_out_free:
....@@ -2938,15 +2949,16 @@
29382949 return NULL;
29392950 }
29402951
2941
-struct net_device *init_airo_card( unsigned short irq, int port, int is_pcmcia,
2952
+struct net_device *init_airo_card(unsigned short irq, int port, int is_pcmcia,
29422953 struct device *dmdev)
29432954 {
2944
- return _init_airo_card ( irq, port, is_pcmcia, NULL, dmdev);
2955
+ return _init_airo_card (irq, port, is_pcmcia, NULL, dmdev);
29452956 }
29462957
29472958 EXPORT_SYMBOL(init_airo_card);
29482959
2949
-static int waitbusy (struct airo_info *ai) {
2960
+static int waitbusy (struct airo_info *ai)
2961
+{
29502962 int delay = 0;
29512963 while ((IN4500(ai, COMMAND) & COMMAND_BUSY) && (delay < 10000)) {
29522964 udelay (10);
....@@ -2956,7 +2968,7 @@
29562968 return delay < 10000;
29572969 }
29582970
2959
-int reset_airo_card( struct net_device *dev )
2971
+int reset_airo_card(struct net_device *dev)
29602972 {
29612973 int i;
29622974 struct airo_info *ai = dev->ml_priv;
....@@ -2964,24 +2976,25 @@
29642976 if (reset_card (dev, 1))
29652977 return -1;
29662978
2967
- if ( setup_card(ai, dev->dev_addr, 1 ) != SUCCESS ) {
2979
+ if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) {
29682980 airo_print_err(dev->name, "MAC could not be enabled");
29692981 return -1;
29702982 }
29712983 airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr);
29722984 /* Allocate the transmit buffers if needed */
29732985 if (!test_bit(FLAG_MPI,&ai->flags))
2974
- for( i = 0; i < MAX_FIDS; i++ )
2975
- ai->fids[i] = transmit_allocate (ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
2986
+ for (i = 0; i < MAX_FIDS; i++)
2987
+ ai->fids[i] = transmit_allocate (ai, AIRO_DEF_MTU, i>=MAX_FIDS/2);
29762988
2977
- enable_interrupts( ai );
2989
+ enable_interrupts(ai);
29782990 netif_wake_queue(dev);
29792991 return 0;
29802992 }
29812993
29822994 EXPORT_SYMBOL(reset_airo_card);
29832995
2984
-static void airo_send_event(struct net_device *dev) {
2996
+static void airo_send_event(struct net_device *dev)
2997
+{
29852998 struct airo_info *ai = dev->ml_priv;
29862999 union iwreq_data wrqu;
29873000 StatusRid status_rid;
....@@ -2998,7 +3011,8 @@
29983011 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
29993012 }
30003013
3001
-static void airo_process_scan_results (struct airo_info *ai) {
3014
+static void airo_process_scan_results (struct airo_info *ai)
3015
+{
30023016 union iwreq_data wrqu;
30033017 BSSListRid bss;
30043018 int rc;
....@@ -3014,14 +3028,14 @@
30143028
30153029 /* Try to read the first entry of the scan result */
30163030 rc = PC4500_readrid(ai, ai->bssListFirst, &bss, ai->bssListRidLen, 0);
3017
- if((rc) || (bss.index == cpu_to_le16(0xffff))) {
3031
+ if ((rc) || (bss.index == cpu_to_le16(0xffff))) {
30183032 /* No scan results */
30193033 goto out;
30203034 }
30213035
30223036 /* Read and parse all entries */
30233037 tmp_net = NULL;
3024
- while((!rc) && (bss.index != cpu_to_le16(0xffff))) {
3038
+ while ((!rc) && (bss.index != cpu_to_le16(0xffff))) {
30253039 /* Grab a network off the free list */
30263040 if (!list_empty(&ai->network_free_list)) {
30273041 tmp_net = list_entry(ai->network_free_list.next,
....@@ -3062,13 +3076,14 @@
30623076 wireless_send_event(ai->dev, SIOCGIWSCAN, &wrqu, NULL);
30633077 }
30643078
3065
-static int airo_thread(void *data) {
3079
+static int airo_thread(void *data)
3080
+{
30663081 struct net_device *dev = data;
30673082 struct airo_info *ai = dev->ml_priv;
30683083 int locked;
30693084
30703085 set_freezable();
3071
- while(1) {
3086
+ while (1) {
30723087 /* make swsusp happy with our thread */
30733088 try_to_freeze();
30743089
....@@ -3088,11 +3103,11 @@
30883103 break;
30893104 if (ai->expires || ai->scan_timeout) {
30903105 if (ai->scan_timeout &&
3091
- time_after_eq(jiffies,ai->scan_timeout)){
3106
+ time_after_eq(jiffies, ai->scan_timeout)) {
30923107 set_bit(JOB_SCAN_RESULTS, &ai->jobs);
30933108 break;
30943109 } else if (ai->expires &&
3095
- time_after_eq(jiffies,ai->expires)){
3110
+ time_after_eq(jiffies, ai->expires)) {
30963111 set_bit(JOB_AUTOWEP, &ai->jobs);
30973112 break;
30983113 }
....@@ -3116,7 +3131,7 @@
31163131 }
31173132 break;
31183133 }
3119
- current->state = TASK_RUNNING;
3134
+ __set_current_state(TASK_RUNNING);
31203135 remove_wait_queue(&ai->thr_wait, &wait);
31213136 locked = 1;
31223137 }
....@@ -3442,11 +3457,11 @@
34423457
34433458 spin_lock_irqsave(&ai->aux_lock, flags);
34443459 if (!skb_queue_empty(&ai->txq)) {
3445
- spin_unlock_irqrestore(&ai->aux_lock,flags);
3460
+ spin_unlock_irqrestore(&ai->aux_lock, flags);
34463461 mpi_send_packet(ai->dev);
34473462 } else {
34483463 clear_bit(FLAG_PENDING_XMIT, &ai->flags);
3449
- spin_unlock_irqrestore(&ai->aux_lock,flags);
3464
+ spin_unlock_irqrestore(&ai->aux_lock, flags);
34503465 netif_wake_queue(ai->dev);
34513466 }
34523467 OUT4500(ai, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC));
....@@ -3526,9 +3541,9 @@
35263541 if (status & (EV_TX | EV_TXCPY | EV_TXEXC))
35273542 airo_handle_tx(ai, status);
35283543
3529
- if ( status & ~STATUS_INTS & ~IGNORE_INTS ) {
3544
+ if (status & ~STATUS_INTS & ~IGNORE_INTS) {
35303545 airo_print_warn(ai->dev->name, "Got weird status %x",
3531
- status & ~STATUS_INTS & ~IGNORE_INTS );
3546
+ status & ~STATUS_INTS & ~IGNORE_INTS);
35323547 }
35333548 }
35343549
....@@ -3547,27 +3562,29 @@
35473562 * NOTE: If use with 8bit mode and SMP bad things will happen!
35483563 * Why would some one do 8 bit IO in an SMP machine?!?
35493564 */
3550
-static void OUT4500( struct airo_info *ai, u16 reg, u16 val ) {
3565
+static void OUT4500(struct airo_info *ai, u16 reg, u16 val)
3566
+{
35513567 if (test_bit(FLAG_MPI,&ai->flags))
35523568 reg <<= 1;
3553
- if ( !do8bitIO )
3554
- outw( val, ai->dev->base_addr + reg );
3569
+ if (!do8bitIO)
3570
+ outw(val, ai->dev->base_addr + reg);
35553571 else {
3556
- outb( val & 0xff, ai->dev->base_addr + reg );
3557
- outb( val >> 8, ai->dev->base_addr + reg + 1 );
3572
+ outb(val & 0xff, ai->dev->base_addr + reg);
3573
+ outb(val >> 8, ai->dev->base_addr + reg + 1);
35583574 }
35593575 }
35603576
3561
-static u16 IN4500( struct airo_info *ai, u16 reg ) {
3577
+static u16 IN4500(struct airo_info *ai, u16 reg)
3578
+{
35623579 unsigned short rc;
35633580
35643581 if (test_bit(FLAG_MPI,&ai->flags))
35653582 reg <<= 1;
3566
- if ( !do8bitIO )
3567
- rc = inw( ai->dev->base_addr + reg );
3583
+ if (!do8bitIO)
3584
+ rc = inw(ai->dev->base_addr + reg);
35683585 else {
3569
- rc = inb( ai->dev->base_addr + reg );
3570
- rc += ((int)inb( ai->dev->base_addr + reg + 1 )) << 8;
3586
+ rc = inb(ai->dev->base_addr + reg);
3587
+ rc += ((int)inb(ai->dev->base_addr + reg + 1)) << 8;
35713588 }
35723589 return rc;
35733590 }
....@@ -3611,7 +3628,8 @@
36113628 return rc;
36123629 }
36133630
3614
-static void disable_MAC( struct airo_info *ai, int lock ) {
3631
+static void disable_MAC(struct airo_info *ai, int lock)
3632
+{
36153633 Cmd cmd;
36163634 Resp rsp;
36173635
....@@ -3630,13 +3648,15 @@
36303648 up(&ai->sem);
36313649 }
36323650
3633
-static void enable_interrupts( struct airo_info *ai ) {
3651
+static void enable_interrupts(struct airo_info *ai)
3652
+{
36343653 /* Enable the interrupts */
3635
- OUT4500( ai, EVINTEN, STATUS_INTS );
3654
+ OUT4500(ai, EVINTEN, STATUS_INTS);
36363655 }
36373656
3638
-static void disable_interrupts( struct airo_info *ai ) {
3639
- OUT4500( ai, EVINTEN, 0 );
3657
+static void disable_interrupts(struct airo_info *ai)
3658
+{
3659
+ OUT4500(ai, EVINTEN, 0);
36403660 }
36413661
36423662 static void mpi_receive_802_3(struct airo_info *ai)
....@@ -3660,7 +3680,7 @@
36603680 ai->dev->stats.rx_dropped++;
36613681 goto badrx;
36623682 }
3663
- buffer = skb_put(skb,len);
3683
+ buffer = skb_put(skb, len);
36643684 memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2);
36653685 if (ai->micstats.enabled) {
36663686 memcpy(&micbuf,
....@@ -3739,8 +3759,8 @@
37393759 fc = get_unaligned((__le16 *)ptr);
37403760 hdrlen = header_len(fc);
37413761
3742
- skb = dev_alloc_skb( len + hdrlen + 2 );
3743
- if ( !skb ) {
3762
+ skb = dev_alloc_skb(len + hdrlen + 2);
3763
+ if (!skb) {
37443764 ai->dev->stats.rx_dropped++;
37453765 goto badrx;
37463766 }
....@@ -3784,7 +3804,7 @@
37843804 skb->dev = ai->wifidev;
37853805 skb->protocol = htons(ETH_P_802_2);
37863806 skb->ip_summed = CHECKSUM_NONE;
3787
- netif_rx( skb );
3807
+ netif_rx(skb);
37883808
37893809 badrx:
37903810 if (rxd.valid == 0) {
....@@ -3805,6 +3825,68 @@
38053825 local->last_auth = auth_type;
38063826 }
38073827
3828
+static int noinline_for_stack airo_readconfig(struct airo_info *ai, u8 *mac, int lock)
3829
+{
3830
+ int i, status;
3831
+ /* large variables, so don't inline this function,
3832
+ * maybe change to kmalloc
3833
+ */
3834
+ tdsRssiRid rssi_rid;
3835
+ CapabilityRid cap_rid;
3836
+
3837
+ kfree(ai->SSID);
3838
+ ai->SSID = NULL;
3839
+ // general configuration (read/modify/write)
3840
+ status = readConfigRid(ai, lock);
3841
+ if (status != SUCCESS) return ERROR;
3842
+
3843
+ status = readCapabilityRid(ai, &cap_rid, lock);
3844
+ if (status != SUCCESS) return ERROR;
3845
+
3846
+ status = PC4500_readrid(ai, RID_RSSI, &rssi_rid, sizeof(rssi_rid), lock);
3847
+ if (status == SUCCESS) {
3848
+ if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL)
3849
+ memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */
3850
+ }
3851
+ else {
3852
+ kfree(ai->rssi);
3853
+ ai->rssi = NULL;
3854
+ if (cap_rid.softCap & cpu_to_le16(8))
3855
+ ai->config.rmode |= RXMODE_NORMALIZED_RSSI;
3856
+ else
3857
+ airo_print_warn(ai->dev->name, "unknown received signal "
3858
+ "level scale");
3859
+ }
3860
+ ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS;
3861
+ set_auth_type(ai, AUTH_OPEN);
3862
+ ai->config.modulation = MOD_CCK;
3863
+
3864
+ if (le16_to_cpu(cap_rid.len) >= sizeof(cap_rid) &&
3865
+ (cap_rid.extSoftCap & cpu_to_le16(1)) &&
3866
+ micsetup(ai) == SUCCESS) {
3867
+ ai->config.opmode |= MODE_MIC;
3868
+ set_bit(FLAG_MIC_CAPABLE, &ai->flags);
3869
+ }
3870
+
3871
+ /* Save off the MAC */
3872
+ for (i = 0; i < ETH_ALEN; i++) {
3873
+ mac[i] = ai->config.macAddr[i];
3874
+ }
3875
+
3876
+ /* Check to see if there are any insmod configured
3877
+ rates to add */
3878
+ if (rates[0]) {
3879
+ memset(ai->config.rates, 0, sizeof(ai->config.rates));
3880
+ for (i = 0; i < 8 && rates[i]; i++) {
3881
+ ai->config.rates[i] = rates[i];
3882
+ }
3883
+ }
3884
+ set_bit (FLAG_COMMIT, &ai->flags);
3885
+
3886
+ return SUCCESS;
3887
+}
3888
+
3889
+
38083890 static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
38093891 {
38103892 Cmd cmd;
....@@ -3815,7 +3897,7 @@
38153897 WepKeyRid wkr;
38163898 int rc;
38173899
3818
- memset( &mySsid, 0, sizeof( mySsid ) );
3900
+ memset(&mySsid, 0, sizeof(mySsid));
38193901 kfree (ai->flash);
38203902 ai->flash = NULL;
38213903
....@@ -3824,12 +3906,12 @@
38243906 cmd.parm0 = cmd.parm1 = cmd.parm2 = 0;
38253907 if (lock && down_interruptible(&ai->sem))
38263908 return ERROR;
3827
- if ( issuecommand( ai, &cmd, &rsp ) != SUCCESS ) {
3909
+ if (issuecommand(ai, &cmd, &rsp) != SUCCESS) {
38283910 if (lock)
38293911 up(&ai->sem);
38303912 return ERROR;
38313913 }
3832
- disable_MAC( ai, 0);
3914
+ disable_MAC(ai, 0);
38333915
38343916 // Let's figure out if we need to use the AUX port
38353917 if (!test_bit(FLAG_MPI,&ai->flags)) {
....@@ -3851,64 +3933,15 @@
38513933 if (lock)
38523934 up(&ai->sem);
38533935 if (ai->config.len == 0) {
3854
- int i;
3855
- tdsRssiRid rssi_rid;
3856
- CapabilityRid cap_rid;
3857
-
3858
- kfree(ai->SSID);
3859
- ai->SSID = NULL;
3860
- // general configuration (read/modify/write)
3861
- status = readConfigRid(ai, lock);
3862
- if ( status != SUCCESS ) return ERROR;
3863
-
3864
- status = readCapabilityRid(ai, &cap_rid, lock);
3865
- if ( status != SUCCESS ) return ERROR;
3866
-
3867
- status = PC4500_readrid(ai,RID_RSSI,&rssi_rid,sizeof(rssi_rid),lock);
3868
- if ( status == SUCCESS ) {
3869
- if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL)
3870
- memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */
3871
- }
3872
- else {
3873
- kfree(ai->rssi);
3874
- ai->rssi = NULL;
3875
- if (cap_rid.softCap & cpu_to_le16(8))
3876
- ai->config.rmode |= RXMODE_NORMALIZED_RSSI;
3877
- else
3878
- airo_print_warn(ai->dev->name, "unknown received signal "
3879
- "level scale");
3880
- }
3881
- ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS;
3882
- set_auth_type(ai, AUTH_OPEN);
3883
- ai->config.modulation = MOD_CCK;
3884
-
3885
- if (le16_to_cpu(cap_rid.len) >= sizeof(cap_rid) &&
3886
- (cap_rid.extSoftCap & cpu_to_le16(1)) &&
3887
- micsetup(ai) == SUCCESS) {
3888
- ai->config.opmode |= MODE_MIC;
3889
- set_bit(FLAG_MIC_CAPABLE, &ai->flags);
3890
- }
3891
-
3892
- /* Save off the MAC */
3893
- for( i = 0; i < ETH_ALEN; i++ ) {
3894
- mac[i] = ai->config.macAddr[i];
3895
- }
3896
-
3897
- /* Check to see if there are any insmod configured
3898
- rates to add */
3899
- if ( rates[0] ) {
3900
- memset(ai->config.rates,0,sizeof(ai->config.rates));
3901
- for( i = 0; i < 8 && rates[i]; i++ ) {
3902
- ai->config.rates[i] = rates[i];
3903
- }
3904
- }
3905
- set_bit (FLAG_COMMIT, &ai->flags);
3936
+ status = airo_readconfig(ai, mac, lock);
3937
+ if (status != SUCCESS)
3938
+ return ERROR;
39063939 }
39073940
39083941 /* Setup the SSIDs if present */
3909
- if ( ssids[0] ) {
3942
+ if (ssids[0]) {
39103943 int i;
3911
- for( i = 0; i < 3 && ssids[i]; i++ ) {
3944
+ for (i = 0; i < 3 && ssids[i]; i++) {
39123945 size_t len = strlen(ssids[i]);
39133946 if (len > 32)
39143947 len = 32;
....@@ -3919,12 +3952,12 @@
39193952 }
39203953
39213954 status = writeConfigRid(ai, lock);
3922
- if ( status != SUCCESS ) return ERROR;
3955
+ if (status != SUCCESS) return ERROR;
39233956
39243957 /* Set up the SSID list */
3925
- if ( ssids[0] ) {
3958
+ if (ssids[0]) {
39263959 status = writeSsidRid(ai, &mySsid, lock);
3927
- if ( status != SUCCESS ) return ERROR;
3960
+ if (status != SUCCESS) return ERROR;
39283961 }
39293962
39303963 status = enable_MAC(ai, lock);
....@@ -3939,14 +3972,15 @@
39393972 ai->defindex = wkr.mac[0];
39403973 }
39413974 rc = readWepKeyRid(ai, &wkr, 0, lock);
3942
- } while(lastindex != wkr.kindex);
3975
+ } while (lastindex != wkr.kindex);
39433976
39443977 try_auto_wep(ai);
39453978
39463979 return SUCCESS;
39473980 }
39483981
3949
-static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) {
3982
+static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp)
3983
+{
39503984 // Im really paranoid about letting it run forever!
39513985 int max_tries = 600000;
39523986
....@@ -3966,7 +4000,7 @@
39664000 schedule();
39674001 }
39684002
3969
- if ( max_tries == -1 ) {
4003
+ if (max_tries == -1) {
39704004 airo_print_err(ai->dev->name,
39714005 "Max tries exceeded when issuing command");
39724006 if (IN4500(ai, COMMAND) & COMMAND_BUSY)
....@@ -3998,7 +4032,7 @@
39984032 /* Sets up the bap to start exchange data. whichbap should
39994033 * be one of the BAP0 or BAP1 defines. Locks should be held before
40004034 * calling! */
4001
-static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap )
4035
+static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap)
40024036 {
40034037 int timeout = 50;
40044038 int max_tries = 3;
....@@ -4013,15 +4047,15 @@
40134047 if (timeout--) {
40144048 continue;
40154049 }
4016
- } else if ( status & BAP_ERR ) {
4050
+ } else if (status & BAP_ERR) {
40174051 /* invalid rid or offset */
40184052 airo_print_err(ai->dev->name, "BAP error %x %d",
4019
- status, whichbap );
4053
+ status, whichbap);
40204054 return ERROR;
40214055 } else if (status & BAP_DONE) { // success
40224056 return SUCCESS;
40234057 }
4024
- if ( !(max_tries--) ) {
4058
+ if (!(max_tries--)) {
40254059 airo_print_err(ai->dev->name,
40264060 "BAP setup error too many retries\n");
40274061 return ERROR;
....@@ -4067,15 +4101,15 @@
40674101 next = aux_setup(ai, page, offset, &len);
40684102 words = (bytelen+1)>>1;
40694103
4070
- for (i=0; i<words;) {
4104
+ for (i = 0; i<words;) {
40714105 int count;
40724106 count = (len>>1) < (words-i) ? (len>>1) : (words-i);
4073
- if ( !do8bitIO )
4074
- insw( ai->dev->base_addr+DATA0+whichbap,
4075
- pu16Dst+i,count );
4107
+ if (!do8bitIO)
4108
+ insw(ai->dev->base_addr+DATA0+whichbap,
4109
+ pu16Dst+i, count);
40764110 else
4077
- insb( ai->dev->base_addr+DATA0+whichbap,
4078
- pu16Dst+i, count << 1 );
4111
+ insb(ai->dev->base_addr+DATA0+whichbap,
4112
+ pu16Dst+i, count << 1);
40794113 i += count;
40804114 if (i<words) {
40814115 next = aux_setup(ai, next, 4, &len);
....@@ -4091,10 +4125,10 @@
40914125 int bytelen, int whichbap)
40924126 {
40934127 bytelen = (bytelen + 1) & (~1); // round up to even value
4094
- if ( !do8bitIO )
4095
- insw( ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen>>1 );
4128
+ if (!do8bitIO)
4129
+ insw(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen>>1);
40964130 else
4097
- insb( ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen );
4131
+ insb(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen);
40984132 return SUCCESS;
40994133 }
41004134
....@@ -4103,11 +4137,11 @@
41034137 int bytelen, int whichbap)
41044138 {
41054139 bytelen = (bytelen + 1) & (~1); // round up to even value
4106
- if ( !do8bitIO )
4107
- outsw( ai->dev->base_addr+DATA0+whichbap,
4108
- pu16Src, bytelen>>1 );
4140
+ if (!do8bitIO)
4141
+ outsw(ai->dev->base_addr+DATA0+whichbap,
4142
+ pu16Src, bytelen>>1);
41094143 else
4110
- outsb( ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen );
4144
+ outsb(ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen);
41114145 return SUCCESS;
41124146 }
41134147
....@@ -4122,7 +4156,7 @@
41224156 cmd.parm0 = rid;
41234157 status = issuecommand(ai, &cmd, &rsp);
41244158 if (status != 0) return status;
4125
- if ( (rsp.status & 0x7F00) != 0) {
4159
+ if ((rsp.status & 0x7F00) != 0) {
41264160 return (accmd << 8) + (rsp.rsp0 & 0xFF);
41274161 }
41284162 return 0;
....@@ -4177,10 +4211,10 @@
41774211 // length for remaining part of rid
41784212 len = min(len, (int)le16_to_cpu(*(__le16*)pBuf)) - 2;
41794213
4180
- if ( len <= 2 ) {
4214
+ if (len <= 2) {
41814215 airo_print_err(ai->dev->name,
41824216 "Rid %x has a length of %d which is too short",
4183
- (int)rid, (int)len );
4217
+ (int)rid, (int)len);
41844218 rc = ERROR;
41854219 goto done;
41864220 }
....@@ -4248,7 +4282,7 @@
42484282 }
42494283 } else {
42504284 // --- first access so that we can write the rid data
4251
- if ( (status = PC4500_accessrid(ai, rid, CMD_ACCESS)) != 0) {
4285
+ if ((status = PC4500_accessrid(ai, rid, CMD_ACCESS)) != 0) {
42524286 rc = status;
42534287 goto done;
42544288 }
....@@ -4285,7 +4319,7 @@
42854319 txFid = ERROR;
42864320 goto done;
42874321 }
4288
- if ( (rsp.status & 0xFF00) != 0) {
4322
+ if ((rsp.status & 0xFF00) != 0) {
42894323 txFid = ERROR;
42904324 goto done;
42914325 }
....@@ -4344,9 +4378,9 @@
43444378 }
43454379 len -= ETH_ALEN * 2;
43464380
4347
- if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled &&
4381
+ if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled &&
43484382 (ntohs(((__be16 *)pPacket)[6]) != 0x888E)) {
4349
- if (encapsulate(ai,(etherHead *)pPacket,&pMic,len) != SUCCESS)
4383
+ if (encapsulate(ai, (etherHead *)pPacket,&pMic, len) != SUCCESS)
43504384 return ERROR;
43514385 miclen = sizeof(pMic);
43524386 }
....@@ -4356,17 +4390,17 @@
43564390 /* The hardware addresses aren't counted as part of the payload, so
43574391 * we have to subtract the 12 bytes for the addresses off */
43584392 payloadLen = cpu_to_le16(len + miclen);
4359
- bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1);
4393
+ bap_write(ai, &payloadLen, sizeof(payloadLen), BAP1);
43604394 bap_write(ai, (__le16*)pPacket, sizeof(etherHead), BAP1);
43614395 if (miclen)
43624396 bap_write(ai, (__le16*)&pMic, miclen, BAP1);
43634397 bap_write(ai, (__le16*)(pPacket + sizeof(etherHead)), len, BAP1);
43644398 // issue the transmit command
4365
- memset( &cmd, 0, sizeof( cmd ) );
4399
+ memset(&cmd, 0, sizeof(cmd));
43664400 cmd.cmd = CMD_TRANSMIT;
43674401 cmd.parm0 = txFid;
43684402 if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR;
4369
- if ( (rsp.status & 0xFF00) != 0) return ERROR;
4403
+ if ((rsp.status & 0xFF00) != 0) return ERROR;
43704404 return SUCCESS;
43714405 }
43724406
....@@ -4395,18 +4429,18 @@
43954429 /* The 802.11 header aren't counted as part of the payload, so
43964430 * we have to subtract the header bytes off */
43974431 payloadLen = cpu_to_le16(len-hdrlen);
4398
- bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1);
4432
+ bap_write(ai, &payloadLen, sizeof(payloadLen), BAP1);
43994433 if (bap_setup(ai, txFid, 0x0014, BAP1) != SUCCESS) return ERROR;
44004434 bap_write(ai, (__le16 *)pPacket, hdrlen, BAP1);
44014435 bap_write(ai, (__le16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1);
44024436
44034437 bap_write(ai, (__le16 *)(pPacket + hdrlen), len - hdrlen, BAP1);
44044438 // issue the transmit command
4405
- memset( &cmd, 0, sizeof( cmd ) );
4439
+ memset(&cmd, 0, sizeof(cmd));
44064440 cmd.cmd = CMD_TRANSMIT;
44074441 cmd.parm0 = txFid;
44084442 if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR;
4409
- if ( (rsp.status & 0xFF00) != 0) return ERROR;
4443
+ if ((rsp.status & 0xFF00) != 0) return ERROR;
44104444 return SUCCESS;
44114445 }
44124446
....@@ -4415,93 +4449,85 @@
44154449 * like! Feel free to clean it up!
44164450 */
44174451
4418
-static ssize_t proc_read( struct file *file,
4452
+static ssize_t proc_read(struct file *file,
44194453 char __user *buffer,
44204454 size_t len,
44214455 loff_t *offset);
44224456
4423
-static ssize_t proc_write( struct file *file,
4457
+static ssize_t proc_write(struct file *file,
44244458 const char __user *buffer,
44254459 size_t len,
4426
- loff_t *offset );
4427
-static int proc_close( struct inode *inode, struct file *file );
4460
+ loff_t *offset);
4461
+static int proc_close(struct inode *inode, struct file *file);
44284462
4429
-static int proc_stats_open( struct inode *inode, struct file *file );
4430
-static int proc_statsdelta_open( struct inode *inode, struct file *file );
4431
-static int proc_status_open( struct inode *inode, struct file *file );
4432
-static int proc_SSID_open( struct inode *inode, struct file *file );
4433
-static int proc_APList_open( struct inode *inode, struct file *file );
4434
-static int proc_BSSList_open( struct inode *inode, struct file *file );
4435
-static int proc_config_open( struct inode *inode, struct file *file );
4436
-static int proc_wepkey_open( struct inode *inode, struct file *file );
4463
+static int proc_stats_open(struct inode *inode, struct file *file);
4464
+static int proc_statsdelta_open(struct inode *inode, struct file *file);
4465
+static int proc_status_open(struct inode *inode, struct file *file);
4466
+static int proc_SSID_open(struct inode *inode, struct file *file);
4467
+static int proc_APList_open(struct inode *inode, struct file *file);
4468
+static int proc_BSSList_open(struct inode *inode, struct file *file);
4469
+static int proc_config_open(struct inode *inode, struct file *file);
4470
+static int proc_wepkey_open(struct inode *inode, struct file *file);
44374471
4438
-static const struct file_operations proc_statsdelta_ops = {
4439
- .owner = THIS_MODULE,
4440
- .read = proc_read,
4441
- .open = proc_statsdelta_open,
4442
- .release = proc_close,
4443
- .llseek = default_llseek,
4472
+static const struct proc_ops proc_statsdelta_ops = {
4473
+ .proc_read = proc_read,
4474
+ .proc_open = proc_statsdelta_open,
4475
+ .proc_release = proc_close,
4476
+ .proc_lseek = default_llseek,
44444477 };
44454478
4446
-static const struct file_operations proc_stats_ops = {
4447
- .owner = THIS_MODULE,
4448
- .read = proc_read,
4449
- .open = proc_stats_open,
4450
- .release = proc_close,
4451
- .llseek = default_llseek,
4479
+static const struct proc_ops proc_stats_ops = {
4480
+ .proc_read = proc_read,
4481
+ .proc_open = proc_stats_open,
4482
+ .proc_release = proc_close,
4483
+ .proc_lseek = default_llseek,
44524484 };
44534485
4454
-static const struct file_operations proc_status_ops = {
4455
- .owner = THIS_MODULE,
4456
- .read = proc_read,
4457
- .open = proc_status_open,
4458
- .release = proc_close,
4459
- .llseek = default_llseek,
4486
+static const struct proc_ops proc_status_ops = {
4487
+ .proc_read = proc_read,
4488
+ .proc_open = proc_status_open,
4489
+ .proc_release = proc_close,
4490
+ .proc_lseek = default_llseek,
44604491 };
44614492
4462
-static const struct file_operations proc_SSID_ops = {
4463
- .owner = THIS_MODULE,
4464
- .read = proc_read,
4465
- .write = proc_write,
4466
- .open = proc_SSID_open,
4467
- .release = proc_close,
4468
- .llseek = default_llseek,
4493
+static const struct proc_ops proc_SSID_ops = {
4494
+ .proc_read = proc_read,
4495
+ .proc_write = proc_write,
4496
+ .proc_open = proc_SSID_open,
4497
+ .proc_release = proc_close,
4498
+ .proc_lseek = default_llseek,
44694499 };
44704500
4471
-static const struct file_operations proc_BSSList_ops = {
4472
- .owner = THIS_MODULE,
4473
- .read = proc_read,
4474
- .write = proc_write,
4475
- .open = proc_BSSList_open,
4476
- .release = proc_close,
4477
- .llseek = default_llseek,
4501
+static const struct proc_ops proc_BSSList_ops = {
4502
+ .proc_read = proc_read,
4503
+ .proc_write = proc_write,
4504
+ .proc_open = proc_BSSList_open,
4505
+ .proc_release = proc_close,
4506
+ .proc_lseek = default_llseek,
44784507 };
44794508
4480
-static const struct file_operations proc_APList_ops = {
4481
- .owner = THIS_MODULE,
4482
- .read = proc_read,
4483
- .write = proc_write,
4484
- .open = proc_APList_open,
4485
- .release = proc_close,
4486
- .llseek = default_llseek,
4509
+static const struct proc_ops proc_APList_ops = {
4510
+ .proc_read = proc_read,
4511
+ .proc_write = proc_write,
4512
+ .proc_open = proc_APList_open,
4513
+ .proc_release = proc_close,
4514
+ .proc_lseek = default_llseek,
44874515 };
44884516
4489
-static const struct file_operations proc_config_ops = {
4490
- .owner = THIS_MODULE,
4491
- .read = proc_read,
4492
- .write = proc_write,
4493
- .open = proc_config_open,
4494
- .release = proc_close,
4495
- .llseek = default_llseek,
4517
+static const struct proc_ops proc_config_ops = {
4518
+ .proc_read = proc_read,
4519
+ .proc_write = proc_write,
4520
+ .proc_open = proc_config_open,
4521
+ .proc_release = proc_close,
4522
+ .proc_lseek = default_llseek,
44964523 };
44974524
4498
-static const struct file_operations proc_wepkey_ops = {
4499
- .owner = THIS_MODULE,
4500
- .read = proc_read,
4501
- .write = proc_write,
4502
- .open = proc_wepkey_open,
4503
- .release = proc_close,
4504
- .llseek = default_llseek,
4525
+static const struct proc_ops proc_wepkey_ops = {
4526
+ .proc_read = proc_read,
4527
+ .proc_write = proc_write,
4528
+ .proc_open = proc_wepkey_open,
4529
+ .proc_release = proc_close,
4530
+ .proc_lseek = default_llseek,
45054531 };
45064532
45074533 static struct proc_dir_entry *airo_entry;
....@@ -4516,12 +4542,13 @@
45164542 void (*on_close) (struct inode *, struct file *);
45174543 };
45184544
4519
-static int setup_proc_entry( struct net_device *dev,
4520
- struct airo_info *apriv ) {
4545
+static int setup_proc_entry(struct net_device *dev,
4546
+ struct airo_info *apriv)
4547
+{
45214548 struct proc_dir_entry *entry;
45224549
45234550 /* First setup the device directory */
4524
- strcpy(apriv->proc_name,dev->name);
4551
+ strcpy(apriv->proc_name, dev->name);
45254552 apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm,
45264553 airo_entry);
45274554 if (!apriv->proc_entry)
....@@ -4590,8 +4617,8 @@
45904617 return -ENOMEM;
45914618 }
45924619
4593
-static int takedown_proc_entry( struct net_device *dev,
4594
- struct airo_info *apriv )
4620
+static int takedown_proc_entry(struct net_device *dev,
4621
+ struct airo_info *apriv)
45954622 {
45964623 remove_proc_subtree(apriv->proc_name, airo_entry);
45974624 return 0;
....@@ -4609,10 +4636,10 @@
46094636 * The read routine is generic, it relies on the preallocated rbuffer
46104637 * to supply the data.
46114638 */
4612
-static ssize_t proc_read( struct file *file,
4639
+static ssize_t proc_read(struct file *file,
46134640 char __user *buffer,
46144641 size_t len,
4615
- loff_t *offset )
4642
+ loff_t *offset)
46164643 {
46174644 struct proc_data *priv = file->private_data;
46184645
....@@ -4627,10 +4654,10 @@
46274654 * The write routine is generic, it fills in a preallocated rbuffer
46284655 * to supply the data.
46294656 */
4630
-static ssize_t proc_write( struct file *file,
4657
+static ssize_t proc_write(struct file *file,
46314658 const char __user *buffer,
46324659 size_t len,
4633
- loff_t *offset )
4660
+ loff_t *offset)
46344661 {
46354662 ssize_t ret;
46364663 struct proc_data *priv = file->private_data;
....@@ -4656,10 +4683,10 @@
46564683 u16 mode;
46574684 int i;
46584685
4659
- if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
4686
+ if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
46604687 return -ENOMEM;
46614688 data = file->private_data;
4662
- if ((data->rbuffer = kmalloc( 2048, GFP_KERNEL )) == NULL) {
4689
+ if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) {
46634690 kfree (file->private_data);
46644691 return -ENOMEM;
46654692 }
....@@ -4679,7 +4706,7 @@
46794706 mode & 0x100 ? "KEY ": "",
46804707 mode & 0x200 ? "WEP ": "",
46814708 mode & 0x8000 ? "ERR ": "");
4682
- sprintf( data->rbuffer+i, "Mode: %x\n"
4709
+ sprintf(data->rbuffer+i, "Mode: %x\n"
46834710 "Signal Strength: %d\n"
46844711 "Signal Quality: %d\n"
46854712 "SSID: %-.*s\n"
....@@ -4709,26 +4736,28 @@
47094736 le16_to_cpu(cap_rid.softVer),
47104737 le16_to_cpu(cap_rid.softSubVer),
47114738 le16_to_cpu(cap_rid.bootBlockVer));
4712
- data->readlen = strlen( data->rbuffer );
4739
+ data->readlen = strlen(data->rbuffer);
47134740 return 0;
47144741 }
47154742
47164743 static int proc_stats_rid_open(struct inode*, struct file*, u16);
4717
-static int proc_statsdelta_open( struct inode *inode,
4718
- struct file *file ) {
4744
+static int proc_statsdelta_open(struct inode *inode,
4745
+ struct file *file)
4746
+{
47194747 if (file->f_mode&FMODE_WRITE) {
47204748 return proc_stats_rid_open(inode, file, RID_STATSDELTACLEAR);
47214749 }
47224750 return proc_stats_rid_open(inode, file, RID_STATSDELTA);
47234751 }
47244752
4725
-static int proc_stats_open( struct inode *inode, struct file *file ) {
4753
+static int proc_stats_open(struct inode *inode, struct file *file)
4754
+{
47264755 return proc_stats_rid_open(inode, file, RID_STATS);
47274756 }
47284757
4729
-static int proc_stats_rid_open( struct inode *inode,
4758
+static int proc_stats_rid_open(struct inode *inode,
47304759 struct file *file,
4731
- u16 rid )
4760
+ u16 rid)
47324761 {
47334762 struct proc_data *data;
47344763 struct net_device *dev = PDE_DATA(inode);
....@@ -4738,10 +4767,10 @@
47384767 __le32 *vals = stats.vals;
47394768 int len;
47404769
4741
- if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
4770
+ if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
47424771 return -ENOMEM;
47434772 data = file->private_data;
4744
- if ((data->rbuffer = kmalloc( 4096, GFP_KERNEL )) == NULL) {
4773
+ if ((data->rbuffer = kmalloc(4096, GFP_KERNEL)) == NULL) {
47454774 kfree (file->private_data);
47464775 return -ENOMEM;
47474776 }
....@@ -4750,7 +4779,7 @@
47504779 len = le16_to_cpu(stats.len);
47514780
47524781 j = 0;
4753
- for(i=0; statsLabels[i]!=(char *)-1 && i*4<len; i++) {
4782
+ for (i = 0; statsLabels[i]!=(char *)-1 && i*4<len; i++) {
47544783 if (!statsLabels[i]) continue;
47554784 if (j+strlen(statsLabels[i])+16>4096) {
47564785 airo_print_warn(apriv->dev->name,
....@@ -4767,7 +4796,8 @@
47674796 return 0;
47684797 }
47694798
4770
-static int get_dec_u16( char *buffer, int *start, int limit ) {
4799
+static int get_dec_u16(char *buffer, int *start, int limit)
4800
+{
47714801 u16 value;
47724802 int valid = 0;
47734803 for (value = 0; *start < limit && buffer[*start] >= '0' &&
....@@ -4776,7 +4806,7 @@
47764806 value *= 10;
47774807 value += buffer[*start] - '0';
47784808 }
4779
- if ( !valid ) return -1;
4809
+ if (!valid) return -1;
47804810 return value;
47814811 }
47824812
....@@ -4797,15 +4827,15 @@
47974827 struct airo_info *ai = dev->ml_priv;
47984828 char *line;
47994829
4800
- if ( !data->writelen ) return;
4830
+ if (!data->writelen) return;
48014831
48024832 readConfigRid(ai, 1);
48034833 set_bit (FLAG_COMMIT, &ai->flags);
48044834
48054835 line = data->wbuffer;
4806
- while( line[0] ) {
4836
+ while (line[0]) {
48074837 /*** Mode processing */
4808
- if ( !strncmp( line, "Mode: ", 6 ) ) {
4838
+ if (!strncmp(line, "Mode: ", 6)) {
48094839 line += 6;
48104840 if (sniffing_mode(ai))
48114841 set_bit (FLAG_RESET, &ai->flags);
....@@ -4813,19 +4843,19 @@
48134843 clear_bit (FLAG_802_11, &ai->flags);
48144844 ai->config.opmode &= ~MODE_CFG_MASK;
48154845 ai->config.scanMode = SCANMODE_ACTIVE;
4816
- if ( line[0] == 'a' ) {
4846
+ if (line[0] == 'a') {
48174847 ai->config.opmode |= MODE_STA_IBSS;
48184848 } else {
48194849 ai->config.opmode |= MODE_STA_ESS;
4820
- if ( line[0] == 'r' ) {
4850
+ if (line[0] == 'r') {
48214851 ai->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER;
48224852 ai->config.scanMode = SCANMODE_PASSIVE;
48234853 set_bit (FLAG_802_11, &ai->flags);
4824
- } else if ( line[0] == 'y' ) {
4854
+ } else if (line[0] == 'y') {
48254855 ai->config.rmode |= RXMODE_RFMON_ANYBSS | RXMODE_DISABLE_802_3_HEADER;
48264856 ai->config.scanMode = SCANMODE_PASSIVE;
48274857 set_bit (FLAG_802_11, &ai->flags);
4828
- } else if ( line[0] == 'l' )
4858
+ } else if (line[0] == 'l')
48294859 ai->config.rmode |= RXMODE_LANMON;
48304860 }
48314861 set_bit (FLAG_COMMIT, &ai->flags);
....@@ -4834,68 +4864,68 @@
48344864 /*** Radio status */
48354865 else if (!strncmp(line,"Radio: ", 7)) {
48364866 line += 7;
4837
- if (!strncmp(line,"off",3)) {
4867
+ if (!strncmp(line,"off", 3)) {
48384868 set_bit (FLAG_RADIO_OFF, &ai->flags);
48394869 } else {
48404870 clear_bit (FLAG_RADIO_OFF, &ai->flags);
48414871 }
48424872 }
48434873 /*** NodeName processing */
4844
- else if ( !strncmp( line, "NodeName: ", 10 ) ) {
4874
+ else if (!strncmp(line, "NodeName: ", 10)) {
48454875 int j;
48464876
48474877 line += 10;
4848
- memset( ai->config.nodeName, 0, 16 );
4878
+ memset(ai->config.nodeName, 0, 16);
48494879 /* Do the name, assume a space between the mode and node name */
4850
- for( j = 0; j < 16 && line[j] != '\n'; j++ ) {
4880
+ for (j = 0; j < 16 && line[j] != '\n'; j++) {
48514881 ai->config.nodeName[j] = line[j];
48524882 }
48534883 set_bit (FLAG_COMMIT, &ai->flags);
48544884 }
48554885
48564886 /*** PowerMode processing */
4857
- else if ( !strncmp( line, "PowerMode: ", 11 ) ) {
4887
+ else if (!strncmp(line, "PowerMode: ", 11)) {
48584888 line += 11;
4859
- if ( !strncmp( line, "PSPCAM", 6 ) ) {
4889
+ if (!strncmp(line, "PSPCAM", 6)) {
48604890 ai->config.powerSaveMode = POWERSAVE_PSPCAM;
48614891 set_bit (FLAG_COMMIT, &ai->flags);
4862
- } else if ( !strncmp( line, "PSP", 3 ) ) {
4892
+ } else if (!strncmp(line, "PSP", 3)) {
48634893 ai->config.powerSaveMode = POWERSAVE_PSP;
48644894 set_bit (FLAG_COMMIT, &ai->flags);
48654895 } else {
48664896 ai->config.powerSaveMode = POWERSAVE_CAM;
48674897 set_bit (FLAG_COMMIT, &ai->flags);
48684898 }
4869
- } else if ( !strncmp( line, "DataRates: ", 11 ) ) {
4899
+ } else if (!strncmp(line, "DataRates: ", 11)) {
48704900 int v, i = 0, k = 0; /* i is index into line,
48714901 k is index to rates */
48724902
48734903 line += 11;
4874
- while((v = get_dec_u16(line, &i, 3))!=-1) {
4904
+ while ((v = get_dec_u16(line, &i, 3))!=-1) {
48754905 ai->config.rates[k++] = (u8)v;
48764906 line += i + 1;
48774907 i = 0;
48784908 }
48794909 set_bit (FLAG_COMMIT, &ai->flags);
4880
- } else if ( !strncmp( line, "Channel: ", 9 ) ) {
4910
+ } else if (!strncmp(line, "Channel: ", 9)) {
48814911 int v, i = 0;
48824912 line += 9;
48834913 v = get_dec_u16(line, &i, i+3);
4884
- if ( v != -1 ) {
4914
+ if (v != -1) {
48854915 ai->config.channelSet = cpu_to_le16(v);
48864916 set_bit (FLAG_COMMIT, &ai->flags);
48874917 }
4888
- } else if ( !strncmp( line, "XmitPower: ", 11 ) ) {
4918
+ } else if (!strncmp(line, "XmitPower: ", 11)) {
48894919 int v, i = 0;
48904920 line += 11;
48914921 v = get_dec_u16(line, &i, i+3);
4892
- if ( v != -1 ) {
4922
+ if (v != -1) {
48934923 ai->config.txPower = cpu_to_le16(v);
48944924 set_bit (FLAG_COMMIT, &ai->flags);
48954925 }
4896
- } else if ( !strncmp( line, "WEP: ", 5 ) ) {
4926
+ } else if (!strncmp(line, "WEP: ", 5)) {
48974927 line += 5;
4898
- switch( line[0] ) {
4928
+ switch(line[0]) {
48994929 case 's':
49004930 set_auth_type(ai, AUTH_SHAREDKEY);
49014931 break;
....@@ -4907,7 +4937,7 @@
49074937 break;
49084938 }
49094939 set_bit (FLAG_COMMIT, &ai->flags);
4910
- } else if ( !strncmp( line, "LongRetryLimit: ", 16 ) ) {
4940
+ } else if (!strncmp(line, "LongRetryLimit: ", 16)) {
49114941 int v, i = 0;
49124942
49134943 line += 16;
....@@ -4915,7 +4945,7 @@
49154945 v = (v<0) ? 0 : ((v>255) ? 255 : v);
49164946 ai->config.longRetryLimit = cpu_to_le16(v);
49174947 set_bit (FLAG_COMMIT, &ai->flags);
4918
- } else if ( !strncmp( line, "ShortRetryLimit: ", 17 ) ) {
4948
+ } else if (!strncmp(line, "ShortRetryLimit: ", 17)) {
49194949 int v, i = 0;
49204950
49214951 line += 17;
....@@ -4923,7 +4953,7 @@
49234953 v = (v<0) ? 0 : ((v>255) ? 255 : v);
49244954 ai->config.shortRetryLimit = cpu_to_le16(v);
49254955 set_bit (FLAG_COMMIT, &ai->flags);
4926
- } else if ( !strncmp( line, "RTSThreshold: ", 14 ) ) {
4956
+ } else if (!strncmp(line, "RTSThreshold: ", 14)) {
49274957 int v, i = 0;
49284958
49294959 line += 14;
....@@ -4931,7 +4961,7 @@
49314961 v = (v<0) ? 0 : ((v>AIRO_DEF_MTU) ? AIRO_DEF_MTU : v);
49324962 ai->config.rtsThres = cpu_to_le16(v);
49334963 set_bit (FLAG_COMMIT, &ai->flags);
4934
- } else if ( !strncmp( line, "TXMSDULifetime: ", 16 ) ) {
4964
+ } else if (!strncmp(line, "TXMSDULifetime: ", 16)) {
49354965 int v, i = 0;
49364966
49374967 line += 16;
....@@ -4939,7 +4969,7 @@
49394969 v = (v<0) ? 0 : v;
49404970 ai->config.txLifetime = cpu_to_le16(v);
49414971 set_bit (FLAG_COMMIT, &ai->flags);
4942
- } else if ( !strncmp( line, "RXMSDULifetime: ", 16 ) ) {
4972
+ } else if (!strncmp(line, "RXMSDULifetime: ", 16)) {
49434973 int v, i = 0;
49444974
49454975 line += 16;
....@@ -4947,17 +4977,17 @@
49474977 v = (v<0) ? 0 : v;
49484978 ai->config.rxLifetime = cpu_to_le16(v);
49494979 set_bit (FLAG_COMMIT, &ai->flags);
4950
- } else if ( !strncmp( line, "TXDiversity: ", 13 ) ) {
4980
+ } else if (!strncmp(line, "TXDiversity: ", 13)) {
49514981 ai->config.txDiversity =
49524982 (line[13]=='l') ? 1 :
49534983 ((line[13]=='r')? 2: 3);
49544984 set_bit (FLAG_COMMIT, &ai->flags);
4955
- } else if ( !strncmp( line, "RXDiversity: ", 13 ) ) {
4985
+ } else if (!strncmp(line, "RXDiversity: ", 13)) {
49564986 ai->config.rxDiversity =
49574987 (line[13]=='l') ? 1 :
49584988 ((line[13]=='r')? 2: 3);
49594989 set_bit (FLAG_COMMIT, &ai->flags);
4960
- } else if ( !strncmp( line, "FragThreshold: ", 15 ) ) {
4990
+ } else if (!strncmp(line, "FragThreshold: ", 15)) {
49614991 int v, i = 0;
49624992
49634993 line += 15;
....@@ -4969,24 +4999,24 @@
49694999 } else if (!strncmp(line, "Modulation: ", 12)) {
49705000 line += 12;
49715001 switch(*line) {
4972
- case 'd': ai->config.modulation=MOD_DEFAULT; set_bit(FLAG_COMMIT, &ai->flags); break;
4973
- case 'c': ai->config.modulation=MOD_CCK; set_bit(FLAG_COMMIT, &ai->flags); break;
4974
- case 'm': ai->config.modulation=MOD_MOK; set_bit(FLAG_COMMIT, &ai->flags); break;
5002
+ case 'd': ai->config.modulation = MOD_DEFAULT; set_bit(FLAG_COMMIT, &ai->flags); break;
5003
+ case 'c': ai->config.modulation = MOD_CCK; set_bit(FLAG_COMMIT, &ai->flags); break;
5004
+ case 'm': ai->config.modulation = MOD_MOK; set_bit(FLAG_COMMIT, &ai->flags); break;
49755005 default: airo_print_warn(ai->dev->name, "Unknown modulation");
49765006 }
49775007 } else if (!strncmp(line, "Preamble: ", 10)) {
49785008 line += 10;
49795009 switch(*line) {
4980
- case 'a': ai->config.preamble=PREAMBLE_AUTO; set_bit(FLAG_COMMIT, &ai->flags); break;
4981
- case 'l': ai->config.preamble=PREAMBLE_LONG; set_bit(FLAG_COMMIT, &ai->flags); break;
4982
- case 's': ai->config.preamble=PREAMBLE_SHORT; set_bit(FLAG_COMMIT, &ai->flags); break;
5010
+ case 'a': ai->config.preamble = PREAMBLE_AUTO; set_bit(FLAG_COMMIT, &ai->flags); break;
5011
+ case 'l': ai->config.preamble = PREAMBLE_LONG; set_bit(FLAG_COMMIT, &ai->flags); break;
5012
+ case 's': ai->config.preamble = PREAMBLE_SHORT; set_bit(FLAG_COMMIT, &ai->flags); break;
49835013 default: airo_print_warn(ai->dev->name, "Unknown preamble");
49845014 }
49855015 } else {
49865016 airo_print_warn(ai->dev->name, "Couldn't figure out %s", line);
49875017 }
4988
- while( line[0] && line[0] != '\n' ) line++;
4989
- if ( line[0] ) line++;
5018
+ while (line[0] && line[0] != '\n') line++;
5019
+ if (line[0]) line++;
49905020 }
49915021 airo_config_commit(dev, NULL, NULL, NULL);
49925022 }
....@@ -5009,14 +5039,14 @@
50095039 int i;
50105040 __le16 mode;
50115041
5012
- if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
5042
+ if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
50135043 return -ENOMEM;
50145044 data = file->private_data;
5015
- if ((data->rbuffer = kmalloc( 2048, GFP_KERNEL )) == NULL) {
5045
+ if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) {
50165046 kfree (file->private_data);
50175047 return -ENOMEM;
50185048 }
5019
- if ((data->wbuffer = kzalloc( 2048, GFP_KERNEL )) == NULL) {
5049
+ if ((data->wbuffer = kzalloc(2048, GFP_KERNEL)) == NULL) {
50205050 kfree (data->rbuffer);
50215051 kfree (file->private_data);
50225052 return -ENOMEM;
....@@ -5027,7 +5057,7 @@
50275057 readConfigRid(ai, 1);
50285058
50295059 mode = ai->config.opmode & MODE_CFG_MASK;
5030
- i = sprintf( data->rbuffer,
5060
+ i = sprintf(data->rbuffer,
50315061 "Mode: %s\n"
50325062 "Radio: %s\n"
50335063 "NodeName: %-16s\n"
....@@ -5056,7 +5086,7 @@
50565086 le16_to_cpu(ai->config.channelSet),
50575087 le16_to_cpu(ai->config.txPower)
50585088 );
5059
- sprintf( data->rbuffer + i,
5089
+ sprintf(data->rbuffer + i,
50605090 "LongRetryLimit: %d\n"
50615091 "ShortRetryLimit: %d\n"
50625092 "RTSThreshold: %d\n"
....@@ -5087,7 +5117,7 @@
50875117 ai->config.preamble == PREAMBLE_LONG ? "long" :
50885118 ai->config.preamble == PREAMBLE_SHORT ? "short" : "error"
50895119 );
5090
- data->readlen = strlen( data->rbuffer );
5120
+ data->readlen = strlen(data->rbuffer);
50915121 return 0;
50925122 }
50935123
....@@ -5127,14 +5157,15 @@
51275157 enable_MAC(ai, 1);
51285158 }
51295159
5130
-static void proc_APList_on_close( struct inode *inode, struct file *file ) {
5160
+static void proc_APList_on_close(struct inode *inode, struct file *file)
5161
+{
51315162 struct proc_data *data = file->private_data;
51325163 struct net_device *dev = PDE_DATA(inode);
51335164 struct airo_info *ai = dev->ml_priv;
51345165 APListRid *APList_rid = &ai->APList;
51355166 int i;
51365167
5137
- if ( !data->writelen ) return;
5168
+ if (!data->writelen) return;
51385169
51395170 memset(APList_rid, 0, sizeof(*APList_rid));
51405171 APList_rid->len = cpu_to_le16(sizeof(*APList_rid));
....@@ -5148,8 +5179,9 @@
51485179 }
51495180
51505181 /* This function wraps PC4500_writerid with a MAC disable */
5151
-static int do_writerid( struct airo_info *ai, u16 rid, const void *rid_data,
5152
- int len, int dummy ) {
5182
+static int do_writerid(struct airo_info *ai, u16 rid, const void *rid_data,
5183
+ int len, int dummy)
5184
+{
51535185 int rc;
51545186
51555187 disable_MAC(ai, 1);
....@@ -5204,7 +5236,7 @@
52045236 return -1;
52055237 }
52065238
5207
-static int set_wep_key(struct airo_info *ai, u16 index, const char *key,
5239
+static int set_wep_key(struct airo_info *ai, u16 index, const u8 *key,
52085240 u16 keylen, int perm, int lock)
52095241 {
52105242 static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
....@@ -5249,19 +5281,20 @@
52495281 return rc;
52505282 }
52515283
5252
-static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
5284
+static void proc_wepkey_on_close(struct inode *inode, struct file *file)
5285
+{
52535286 struct proc_data *data;
52545287 struct net_device *dev = PDE_DATA(inode);
52555288 struct airo_info *ai = dev->ml_priv;
52565289 int i, rc;
5257
- char key[16];
5290
+ u8 key[16];
52585291 u16 index = 0;
52595292 int j = 0;
52605293
52615294 memset(key, 0, sizeof(key));
52625295
52635296 data = file->private_data;
5264
- if ( !data->writelen ) return;
5297
+ if (!data->writelen) return;
52655298
52665299 if (data->wbuffer[0] >= '0' && data->wbuffer[0] <= '3' &&
52675300 (data->wbuffer[1] == ' ' || data->wbuffer[1] == '\n')) {
....@@ -5281,13 +5314,23 @@
52815314 return;
52825315 }
52835316
5284
- for( i = 0; i < 16*3 && data->wbuffer[i+j]; i++ ) {
5317
+ for (i = 0; i < 16*3 && data->wbuffer[i+j]; i++) {
5318
+ int val;
5319
+
5320
+ if (i % 3 == 2)
5321
+ continue;
5322
+
5323
+ val = hex_to_bin(data->wbuffer[i+j]);
5324
+ if (val < 0) {
5325
+ airo_print_err(ai->dev->name, "WebKey passed invalid key hex");
5326
+ return;
5327
+ }
52855328 switch(i%3) {
52865329 case 0:
5287
- key[i/3] = hex_to_bin(data->wbuffer[i+j])<<4;
5330
+ key[i/3] = (u8)val << 4;
52885331 break;
52895332 case 1:
5290
- key[i/3] |= hex_to_bin(data->wbuffer[i+j]);
5333
+ key[i/3] |= (u8)val;
52915334 break;
52925335 }
52935336 }
....@@ -5299,7 +5342,7 @@
52995342 }
53005343 }
53015344
5302
-static int proc_wepkey_open( struct inode *inode, struct file *file )
5345
+static int proc_wepkey_open(struct inode *inode, struct file *file)
53035346 {
53045347 struct proc_data *data;
53055348 struct net_device *dev = PDE_DATA(inode);
....@@ -5307,20 +5350,20 @@
53075350 char *ptr;
53085351 WepKeyRid wkr;
53095352 __le16 lastindex;
5310
- int j=0;
5353
+ int j = 0;
53115354 int rc;
53125355
5313
- if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
5356
+ if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
53145357 return -ENOMEM;
53155358 memset(&wkr, 0, sizeof(wkr));
53165359 data = file->private_data;
5317
- if ((data->rbuffer = kzalloc( 180, GFP_KERNEL )) == NULL) {
5360
+ if ((data->rbuffer = kzalloc(180, GFP_KERNEL)) == NULL) {
53185361 kfree (file->private_data);
53195362 return -ENOMEM;
53205363 }
53215364 data->writelen = 0;
53225365 data->maxwritelen = 80;
5323
- if ((data->wbuffer = kzalloc( 80, GFP_KERNEL )) == NULL) {
5366
+ if ((data->wbuffer = kzalloc(80, GFP_KERNEL)) == NULL) {
53245367 kfree (data->rbuffer);
53255368 kfree (file->private_data);
53265369 return -ENOMEM;
....@@ -5341,9 +5384,9 @@
53415384 le16_to_cpu(wkr.klen));
53425385 }
53435386 readWepKeyRid(ai, &wkr, 0, 1);
5344
- } while((lastindex != wkr.kindex) && (j < 180-30));
5387
+ } while ((lastindex != wkr.kindex) && (j < 180-30));
53455388
5346
- data->readlen = strlen( data->rbuffer );
5389
+ data->readlen = strlen(data->rbuffer);
53475390 return 0;
53485391 }
53495392
....@@ -5356,10 +5399,10 @@
53565399 char *ptr;
53575400 SsidRid SSID_rid;
53585401
5359
- if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
5402
+ if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
53605403 return -ENOMEM;
53615404 data = file->private_data;
5362
- if ((data->rbuffer = kmalloc( 104, GFP_KERNEL )) == NULL) {
5405
+ if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) {
53635406 kfree (file->private_data);
53645407 return -ENOMEM;
53655408 }
....@@ -5387,11 +5430,12 @@
53875430 *ptr++ = '\n';
53885431 }
53895432 *ptr = '\0';
5390
- data->readlen = strlen( data->rbuffer );
5433
+ data->readlen = strlen(data->rbuffer);
53915434 return 0;
53925435 }
53935436
5394
-static int proc_APList_open( struct inode *inode, struct file *file ) {
5437
+static int proc_APList_open(struct inode *inode, struct file *file)
5438
+{
53955439 struct proc_data *data;
53965440 struct net_device *dev = PDE_DATA(inode);
53975441 struct airo_info *ai = dev->ml_priv;
....@@ -5399,16 +5443,16 @@
53995443 char *ptr;
54005444 APListRid *APList_rid = &ai->APList;
54015445
5402
- if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
5446
+ if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
54035447 return -ENOMEM;
54045448 data = file->private_data;
5405
- if ((data->rbuffer = kmalloc( 104, GFP_KERNEL )) == NULL) {
5449
+ if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) {
54065450 kfree (file->private_data);
54075451 return -ENOMEM;
54085452 }
54095453 data->writelen = 0;
54105454 data->maxwritelen = 4*6*3;
5411
- if ((data->wbuffer = kzalloc( data->maxwritelen, GFP_KERNEL )) == NULL) {
5455
+ if ((data->wbuffer = kzalloc(data->maxwritelen, GFP_KERNEL)) == NULL) {
54125456 kfree (data->rbuffer);
54135457 kfree (file->private_data);
54145458 return -ENOMEM;
....@@ -5416,20 +5460,21 @@
54165460 data->on_close = proc_APList_on_close;
54175461
54185462 ptr = data->rbuffer;
5419
- for( i = 0; i < 4; i++ ) {
5463
+ for (i = 0; i < 4; i++) {
54205464 // We end when we find a zero MAC
5421
- if ( !*(int*)APList_rid->ap[i] &&
5465
+ if (!*(int*)APList_rid->ap[i] &&
54225466 !*(int*)&APList_rid->ap[i][2]) break;
54235467 ptr += sprintf(ptr, "%pM\n", APList_rid->ap[i]);
54245468 }
54255469 if (i==0) ptr += sprintf(ptr, "Not using specific APs\n");
54265470
54275471 *ptr = '\0';
5428
- data->readlen = strlen( data->rbuffer );
5472
+ data->readlen = strlen(data->rbuffer);
54295473 return 0;
54305474 }
54315475
5432
-static int proc_BSSList_open( struct inode *inode, struct file *file ) {
5476
+static int proc_BSSList_open(struct inode *inode, struct file *file)
5477
+{
54335478 struct proc_data *data;
54345479 struct net_device *dev = PDE_DATA(inode);
54355480 struct airo_info *ai = dev->ml_priv;
....@@ -5439,10 +5484,10 @@
54395484 /* If doLoseSync is not 1, we won't do a Lose Sync */
54405485 int doLoseSync = -1;
54415486
5442
- if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
5487
+ if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL)
54435488 return -ENOMEM;
54445489 data = file->private_data;
5445
- if ((data->rbuffer = kmalloc( 1024, GFP_KERNEL )) == NULL) {
5490
+ if ((data->rbuffer = kmalloc(1024, GFP_KERNEL)) == NULL) {
54465491 kfree (file->private_data);
54475492 return -ENOMEM;
54485493 }
....@@ -5456,11 +5501,18 @@
54565501 Cmd cmd;
54575502 Resp rsp;
54585503
5459
- if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN;
5504
+ if (ai->flags & FLAG_RADIO_MASK) {
5505
+ kfree(data->rbuffer);
5506
+ kfree(file->private_data);
5507
+ return -ENETDOWN;
5508
+ }
54605509 memset(&cmd, 0, sizeof(cmd));
5461
- cmd.cmd=CMD_LISTBSS;
5462
- if (down_interruptible(&ai->sem))
5510
+ cmd.cmd = CMD_LISTBSS;
5511
+ if (down_interruptible(&ai->sem)) {
5512
+ kfree(data->rbuffer);
5513
+ kfree(file->private_data);
54635514 return -ERESTARTSYS;
5515
+ }
54645516 issuecommand(ai, &cmd, &rsp);
54655517 up(&ai->sem);
54665518 data->readlen = 0;
....@@ -5473,7 +5525,7 @@
54735525 Since it is a rare condition, we'll just live with it, otherwise
54745526 we have to add a spin lock... */
54755527 rc = readBSSListRid(ai, doLoseSync, &BSSList_rid);
5476
- while(rc == 0 && BSSList_rid.index != cpu_to_le16(0xffff)) {
5528
+ while (rc == 0 && BSSList_rid.index != cpu_to_le16(0xffff)) {
54775529 ptr += sprintf(ptr, "%pM %.*s rssi = %d",
54785530 BSSList_rid.bssid,
54795531 (int)BSSList_rid.ssidLen,
....@@ -5488,11 +5540,11 @@
54885540 rc = readBSSListRid(ai, 0, &BSSList_rid);
54895541 }
54905542 *ptr = '\0';
5491
- data->readlen = strlen( data->rbuffer );
5543
+ data->readlen = strlen(data->rbuffer);
54925544 return 0;
54935545 }
54945546
5495
-static int proc_close( struct inode *inode, struct file *file )
5547
+static int proc_close(struct inode *inode, struct file *file)
54965548 {
54975549 struct proc_data *data = file->private_data;
54985550
....@@ -5509,7 +5561,8 @@
55095561 will switch WEP modes to see if that will help. If the card is
55105562 associated we will check every minute to see if anything has
55115563 changed. */
5512
-static void timer_func( struct net_device *dev ) {
5564
+static void timer_func(struct net_device *dev)
5565
+{
55135566 struct airo_info *apriv = dev->ml_priv;
55145567
55155568 /* We don't have a link so try changing the authtype */
....@@ -5577,9 +5630,9 @@
55775630 pci_disable_device(pdev);
55785631 }
55795632
5580
-static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
5633
+static int __maybe_unused airo_pci_suspend(struct device *dev_d)
55815634 {
5582
- struct net_device *dev = pci_get_drvdata(pdev);
5635
+ struct net_device *dev = dev_get_drvdata(dev_d);
55835636 struct airo_info *ai = dev->ml_priv;
55845637 Cmd cmd;
55855638 Resp rsp;
....@@ -5595,25 +5648,21 @@
55955648 return -EAGAIN;
55965649 disable_MAC(ai, 0);
55975650 netif_device_detach(dev);
5598
- ai->power = state;
5651
+ ai->power = PMSG_SUSPEND;
55995652 cmd.cmd = HOSTSLEEP;
56005653 issuecommand(ai, &cmd, &rsp);
56015654
5602
- pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
5603
- pci_save_state(pdev);
5604
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
5655
+ device_wakeup_enable(dev_d);
56055656 return 0;
56065657 }
56075658
5608
-static int airo_pci_resume(struct pci_dev *pdev)
5659
+static int __maybe_unused airo_pci_resume(struct device *dev_d)
56095660 {
5610
- struct net_device *dev = pci_get_drvdata(pdev);
5661
+ struct net_device *dev = dev_get_drvdata(dev_d);
56115662 struct airo_info *ai = dev->ml_priv;
5612
- pci_power_t prev_state = pdev->current_state;
5663
+ pci_power_t prev_state = to_pci_dev(dev_d)->current_state;
56135664
5614
- pci_set_power_state(pdev, PCI_D0);
5615
- pci_restore_state(pdev);
5616
- pci_enable_wake(pdev, PCI_D0, 0);
5665
+ device_wakeup_disable(dev_d);
56175666
56185667 if (prev_state != PCI_D1) {
56195668 reset_card(dev, 0);
....@@ -5647,7 +5696,7 @@
56475696 }
56485697 #endif
56495698
5650
-static int __init airo_init_module( void )
5699
+static int __init airo_init_module(void)
56515700 {
56525701 int i;
56535702
....@@ -5663,9 +5712,10 @@
56635712
56645713 for (i = 0; i < 4 && io[i] && irq[i]; i++) {
56655714 airo_print_info("", "Trying to configure ISA adapter at irq=%d "
5666
- "io=0x%x", irq[i], io[i] );
5667
- if (init_airo_card( irq[i], io[i], 0, NULL ))
5715
+ "io = 0x%x", irq[i], io[i]);
5716
+ if (init_airo_card(irq[i], io[i], 0, NULL)) {
56685717 /* do nothing */ ;
5718
+ }
56695719 }
56705720
56715721 #ifdef CONFIG_PCI
....@@ -5685,10 +5735,10 @@
56855735 return 0;
56865736 }
56875737
5688
-static void __exit airo_cleanup_module( void )
5738
+static void __exit airo_cleanup_module(void)
56895739 {
56905740 struct airo_info *ai;
5691
- while(!list_empty(&airo_devices)) {
5741
+ while (!list_empty(&airo_devices)) {
56925742 ai = list_entry(airo_devices.next, struct airo_info, dev_list);
56935743 airo_print_info(ai->dev->name, "Unregistering...");
56945744 stop_airo_card(ai->dev, 1);
....@@ -5788,7 +5838,7 @@
57885838 int rc = -EINPROGRESS; /* Call commit handler */
57895839
57905840 /* If setting by frequency, convert to a channel */
5791
- if(fwrq->e == 1) {
5841
+ if (fwrq->e == 1) {
57925842 int f = fwrq->m / 100000;
57935843
57945844 /* Hack to fall through... */
....@@ -5802,7 +5852,7 @@
58025852 int channel = fwrq->m;
58035853 /* We should do a better check than that,
58045854 * based on the card capability !!! */
5805
- if((channel < 1) || (channel > 14)) {
5855
+ if ((channel < 1) || (channel > 14)) {
58065856 airo_print_dbg(dev->name, "New channel value of %d is invalid!",
58075857 fwrq->m);
58085858 rc = -EINVAL;
....@@ -5836,7 +5886,7 @@
58365886 readStatusRid(local, &status_rid, 1);
58375887
58385888 ch = le16_to_cpu(status_rid.channel);
5839
- if((ch > 0) && (ch < 15)) {
5889
+ if ((ch > 0) && (ch < 15)) {
58405890 fwrq->m = 100000 *
58415891 ieee80211_channel_to_frequency(ch, NL80211_BAND_2GHZ);
58425892 fwrq->e = 1;
....@@ -5940,7 +5990,7 @@
59405990 else if (is_broadcast_ether_addr(awrq->sa_data) ||
59415991 is_zero_ether_addr(awrq->sa_data)) {
59425992 memset(&cmd, 0, sizeof(cmd));
5943
- cmd.cmd=CMD_LOSE_SYNC;
5993
+ cmd.cmd = CMD_LOSE_SYNC;
59445994 if (down_interruptible(&local->sem))
59455995 return -ERESTARTSYS;
59465996 issuecommand(local, &cmd, &rsp);
....@@ -5989,7 +6039,7 @@
59896039 struct airo_info *local = dev->ml_priv;
59906040
59916041 /* Check the size of the string */
5992
- if(dwrq->length > 16) {
6042
+ if (dwrq->length > 16) {
59936043 return -E2BIG;
59946044 }
59956045 readConfigRid(local, 1);
....@@ -6037,7 +6087,7 @@
60376087 readCapabilityRid(local, &cap_rid, 1);
60386088
60396089 /* Which type of value ? */
6040
- if((vwrq->value < 8) && (vwrq->value >= 0)) {
6090
+ if ((vwrq->value < 8) && (vwrq->value >= 0)) {
60416091 /* Setting by rate index */
60426092 /* Find value in the magic rate table */
60436093 brate = cap_rid.supportedRates[vwrq->value];
....@@ -6046,36 +6096,36 @@
60466096 u8 normvalue = (u8) (vwrq->value/500000);
60476097
60486098 /* Check if rate is valid */
6049
- for(i = 0 ; i < 8 ; i++) {
6050
- if(normvalue == cap_rid.supportedRates[i]) {
6099
+ for (i = 0 ; i < 8 ; i++) {
6100
+ if (normvalue == cap_rid.supportedRates[i]) {
60516101 brate = normvalue;
60526102 break;
60536103 }
60546104 }
60556105 }
60566106 /* -1 designed the max rate (mostly auto mode) */
6057
- if(vwrq->value == -1) {
6107
+ if (vwrq->value == -1) {
60586108 /* Get the highest available rate */
6059
- for(i = 0 ; i < 8 ; i++) {
6060
- if(cap_rid.supportedRates[i] == 0)
6109
+ for (i = 0 ; i < 8 ; i++) {
6110
+ if (cap_rid.supportedRates[i] == 0)
60616111 break;
60626112 }
6063
- if(i != 0)
6113
+ if (i != 0)
60646114 brate = cap_rid.supportedRates[i - 1];
60656115 }
60666116 /* Check that it is valid */
6067
- if(brate == 0) {
6117
+ if (brate == 0) {
60686118 return -EINVAL;
60696119 }
60706120
60716121 readConfigRid(local, 1);
60726122 /* Now, check if we want a fixed or auto value */
6073
- if(vwrq->fixed == 0) {
6123
+ if (vwrq->fixed == 0) {
60746124 /* Fill all the rates up to this max rate */
60756125 memset(local->config.rates, 0, 8);
6076
- for(i = 0 ; i < 8 ; i++) {
6126
+ for (i = 0 ; i < 8 ; i++) {
60776127 local->config.rates[i] = cap_rid.supportedRates[i];
6078
- if(local->config.rates[i] == brate)
6128
+ if (local->config.rates[i] == brate)
60796129 break;
60806130 }
60816131 } else {
....@@ -6100,8 +6150,11 @@
61006150 {
61016151 struct airo_info *local = dev->ml_priv;
61026152 StatusRid status_rid; /* Card status info */
6153
+ int ret;
61036154
6104
- readStatusRid(local, &status_rid, 1);
6155
+ ret = readStatusRid(local, &status_rid, 1);
6156
+ if (ret)
6157
+ return -EBUSY;
61056158
61066159 vwrq->value = le16_to_cpu(status_rid.currentXmitRate) * 500000;
61076160 /* If more than one rate, set auto */
....@@ -6123,9 +6176,9 @@
61236176 struct airo_info *local = dev->ml_priv;
61246177 int rthr = vwrq->value;
61256178
6126
- if(vwrq->disabled)
6179
+ if (vwrq->disabled)
61276180 rthr = AIRO_DEF_MTU;
6128
- if((rthr < 0) || (rthr > AIRO_DEF_MTU)) {
6181
+ if ((rthr < 0) || (rthr > AIRO_DEF_MTU)) {
61296182 return -EINVAL;
61306183 }
61316184 readConfigRid(local, 1);
....@@ -6166,9 +6219,9 @@
61666219 struct airo_info *local = dev->ml_priv;
61676220 int fthr = vwrq->value;
61686221
6169
- if(vwrq->disabled)
6222
+ if (vwrq->disabled)
61706223 fthr = AIRO_DEF_MTU;
6171
- if((fthr < 256) || (fthr > AIRO_DEF_MTU)) {
6224
+ if ((fthr < 256) || (fthr > AIRO_DEF_MTU)) {
61726225 return -EINVAL;
61736226 }
61746227 fthr &= ~0x1; /* Get an even value - is it really needed ??? */
....@@ -6345,7 +6398,7 @@
63456398 else
63466399 key.len = MIN_KEY_SIZE;
63476400 /* Check if the key is not marked as invalid */
6348
- if(!(dwrq->flags & IW_ENCODE_NOKEY)) {
6401
+ if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
63496402 /* Cleanup */
63506403 memset(key.key, 0, MAX_KEY_SIZE);
63516404 /* Copy the key in the driver */
....@@ -6362,7 +6415,7 @@
63626415 /* WE specify that if a valid key is set, encryption
63636416 * should be enabled (user may turn it off later)
63646417 * This is also how "iwconfig ethX key on" works */
6365
- if((index == current_index) && (key.len > 0) &&
6418
+ if ((index == current_index) && (key.len > 0) &&
63666419 (local->config.authType == AUTH_OPEN))
63676420 set_auth_type(local, AUTH_ENCRYPT);
63686421 } else {
....@@ -6385,7 +6438,7 @@
63856438 /* Read the flags */
63866439 if (dwrq->flags & IW_ENCODE_DISABLED)
63876440 set_auth_type(local, AUTH_OPEN); /* disable encryption */
6388
- if(dwrq->flags & IW_ENCODE_RESTRICTED)
6441
+ if (dwrq->flags & IW_ENCODE_RESTRICTED)
63896442 set_auth_type(local, AUTH_SHAREDKEY); /* Only Both */
63906443 if (dwrq->flags & IW_ENCODE_OPEN)
63916444 set_auth_type(local, AUTH_ENCRYPT); /* Only Wep */
....@@ -6463,7 +6516,7 @@
64636516 struct airo_info *local = dev->ml_priv;
64646517 struct iw_point *encoding = &wrqu->encoding;
64656518 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6466
- int perm = ( encoding->flags & IW_ENCODE_TEMP ? 0 : 1 );
6519
+ int perm = (encoding->flags & IW_ENCODE_TEMP ? 0 : 1);
64676520 __le16 currentAuthType = local->config.authType;
64686521 int idx, key_len, alg = ext->alg, set_key = 1, rc;
64696522 wep_key_t key;
....@@ -6545,7 +6598,7 @@
65456598 /* Read the flags */
65466599 if (encoding->flags & IW_ENCODE_DISABLED)
65476600 set_auth_type(local, AUTH_OPEN); /* disable encryption */
6548
- if(encoding->flags & IW_ENCODE_RESTRICTED)
6601
+ if (encoding->flags & IW_ENCODE_RESTRICTED)
65496602 set_auth_type(local, AUTH_SHAREDKEY); /* Only Both */
65506603 if (encoding->flags & IW_ENCODE_OPEN)
65516604 set_auth_type(local, AUTH_ENCRYPT);
....@@ -6611,7 +6664,7 @@
66116664 /* We can't return the key, so set the proper flag and return zero */
66126665 encoding->flags |= IW_ENCODE_NOKEY;
66136666 memset(extra, 0, 16);
6614
-
6667
+
66156668 /* Copy the key to the user buffer */
66166669 wep_key_len = get_wep_key(local, idx, &buf[0], sizeof(buf));
66176670 if (wep_key_len < 0) {
....@@ -6811,13 +6864,13 @@
68116864 struct airo_info *local = dev->ml_priv;
68126865 int rc = -EINVAL;
68136866
6814
- if(vwrq->disabled) {
6867
+ if (vwrq->disabled) {
68156868 return -EINVAL;
68166869 }
68176870 readConfigRid(local, 1);
6818
- if(vwrq->flags & IW_RETRY_LIMIT) {
6871
+ if (vwrq->flags & IW_RETRY_LIMIT) {
68196872 __le16 v = cpu_to_le16(vwrq->value);
6820
- if(vwrq->flags & IW_RETRY_LONG)
6873
+ if (vwrq->flags & IW_RETRY_LONG)
68216874 local->config.longRetryLimit = v;
68226875 else if (vwrq->flags & IW_RETRY_SHORT)
68236876 local->config.shortRetryLimit = v;
....@@ -6829,7 +6882,7 @@
68296882 set_bit (FLAG_COMMIT, &local->flags);
68306883 rc = -EINPROGRESS; /* Call commit handler */
68316884 }
6832
- if(vwrq->flags & IW_RETRY_LIFETIME) {
6885
+ if (vwrq->flags & IW_RETRY_LIFETIME) {
68336886 local->config.txLifetime = cpu_to_le16(vwrq->value / 1024);
68346887 set_bit (FLAG_COMMIT, &local->flags);
68356888 rc = -EINPROGRESS; /* Call commit handler */
....@@ -6852,16 +6905,16 @@
68526905
68536906 readConfigRid(local, 1);
68546907 /* Note : by default, display the min retry number */
6855
- if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
6908
+ if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
68566909 vwrq->flags = IW_RETRY_LIFETIME;
68576910 vwrq->value = le16_to_cpu(local->config.txLifetime) * 1024;
6858
- } else if((vwrq->flags & IW_RETRY_LONG)) {
6911
+ } else if ((vwrq->flags & IW_RETRY_LONG)) {
68596912 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
68606913 vwrq->value = le16_to_cpu(local->config.longRetryLimit);
68616914 } else {
68626915 vwrq->flags = IW_RETRY_LIMIT;
68636916 vwrq->value = le16_to_cpu(local->config.shortRetryLimit);
6864
- if(local->config.shortRetryLimit != local->config.longRetryLimit)
6917
+ if (local->config.shortRetryLimit != local->config.longRetryLimit)
68656918 vwrq->flags |= IW_RETRY_SHORT;
68666919 }
68676920
....@@ -6893,7 +6946,7 @@
68936946 /* Should be based on cap_rid.country to give only
68946947 * what the current card support */
68956948 k = 0;
6896
- for(i = 0; i < 14; i++) {
6949
+ for (i = 0; i < 14; i++) {
68976950 range->freq[k].i = i + 1; /* List index */
68986951 range->freq[k].m = 100000 *
68996952 ieee80211_channel_to_frequency(i + 1, NL80211_BAND_2GHZ);
....@@ -6923,9 +6976,9 @@
69236976 }
69246977 range->avg_qual.noise = 0x100 - 85; /* -85 dBm */
69256978
6926
- for(i = 0 ; i < 8 ; i++) {
6979
+ for (i = 0 ; i < 8 ; i++) {
69276980 range->bitrate[i] = cap_rid.supportedRates[i] * 500000;
6928
- if(range->bitrate[i] == 0)
6981
+ if (range->bitrate[i] == 0)
69296982 break;
69306983 }
69316984 range->num_bitrates = i;
....@@ -6933,7 +6986,7 @@
69336986 /* Set an indication of the max TCP throughput
69346987 * in bit/s that we can expect using this interface.
69356988 * May be use for QoS stuff... Jean II */
6936
- if(i > 2)
6989
+ if (i > 2)
69376990 range->throughput = 5000 * 1000;
69386991 else
69396992 range->throughput = 1500 * 1000;
....@@ -6943,7 +6996,7 @@
69436996 range->min_frag = 256;
69446997 range->max_frag = AIRO_DEF_MTU;
69456998
6946
- if(cap_rid.softCap & cpu_to_le16(2)) {
6999
+ if (cap_rid.softCap & cpu_to_le16(2)) {
69477000 // WEP: RC4 40 bits
69487001 range->encoding_size[0] = 5;
69497002 // RC4 ~128 bits
....@@ -6967,9 +7020,9 @@
69677020 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
69687021
69697022 /* Transmit Power - values are in mW */
6970
- for(i = 0 ; i < 8 ; i++) {
7023
+ for (i = 0 ; i < 8 ; i++) {
69717024 range->txpower[i] = le16_to_cpu(cap_rid.txPowerLevels[i]);
6972
- if(range->txpower[i] == 0)
7025
+ if (range->txpower[i] == 0)
69737026 break;
69747027 }
69757028 range->num_txpower = i;
....@@ -7240,7 +7293,7 @@
72407293 /* Initiate a scan command */
72417294 ai->scan_timeout = RUN_AT(3*HZ);
72427295 memset(&cmd, 0, sizeof(cmd));
7243
- cmd.cmd=CMD_LISTBSS;
7296
+ cmd.cmd = CMD_LISTBSS;
72447297 issuecommand(ai, &cmd, &rsp);
72457298 wake = 1;
72467299
....@@ -7281,7 +7334,7 @@
72817334
72827335 /* Add the ESSID */
72837336 iwe.u.data.length = bss->ssidLen;
7284
- if(iwe.u.data.length > 32)
7337
+ if (iwe.u.data.length > 32)
72857338 iwe.u.data.length = 32;
72867339 iwe.cmd = SIOCGIWESSID;
72877340 iwe.u.data.flags = 1;
....@@ -7291,8 +7344,8 @@
72917344 /* Add mode */
72927345 iwe.cmd = SIOCGIWMODE;
72937346 capabilities = bss->cap;
7294
- if(capabilities & (CAP_ESS | CAP_IBSS)) {
7295
- if(capabilities & CAP_ESS)
7347
+ if (capabilities & (CAP_ESS | CAP_IBSS)) {
7348
+ if (capabilities & CAP_ESS)
72967349 iwe.u.mode = IW_MODE_MASTER;
72977350 else
72987351 iwe.u.mode = IW_MODE_ADHOC;
....@@ -7332,7 +7385,7 @@
73327385
73337386 /* Add encryption capability */
73347387 iwe.cmd = SIOCGIWENCODE;
7335
- if(capabilities & CAP_PRIVACY)
7388
+ if (capabilities & CAP_PRIVACY)
73367389 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
73377390 else
73387391 iwe.u.data.flags = IW_ENCODE_DISABLED;
....@@ -7348,9 +7401,9 @@
73487401 /* Those two flags are ignored... */
73497402 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
73507403 /* Max 8 values */
7351
- for(i = 0 ; i < 8 ; i++) {
7404
+ for (i = 0 ; i < 8 ; i++) {
73527405 /* NULL terminated */
7353
- if(bss->rates[i] == 0)
7406
+ if (bss->rates[i] == 0)
73547407 break;
73557408 /* Bit rate given in 500 kb/s units (+ 0x80) */
73567409 iwe.u.bitrate.value = ((bss->rates[i] & 0x7f) * 500000);
....@@ -7458,7 +7511,7 @@
74587511 &net->bss);
74597512
74607513 /* Check if there is space for one more entry */
7461
- if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
7514
+ if ((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
74627515 /* Ask user space to try again with a bigger buffer */
74637516 err = -E2BIG;
74647517 goto out;
....@@ -7496,7 +7549,7 @@
74967549
74977550 readSsidRid(local, &SSID_rid);
74987551 if (test_bit(FLAG_MPI,&local->flags))
7499
- setup_card(local, dev->dev_addr, 1 );
7552
+ setup_card(local, dev->dev_addr, 1);
75007553 else
75017554 reset_airo_card(dev);
75027555 disable_MAC(local, 1);
....@@ -7640,9 +7693,9 @@
76407693 {
76417694 int val = AIROMAGIC;
76427695 aironet_ioctl com;
7643
- if (copy_from_user(&com,rq->ifr_data,sizeof(com)))
7696
+ if (copy_from_user(&com, rq->ifr_data, sizeof(com)))
76447697 rc = -EFAULT;
7645
- else if (copy_to_user(com.data,(char *)&val,sizeof(val)))
7698
+ else if (copy_to_user(com.data, (char *)&val, sizeof(val)))
76467699 rc = -EFAULT;
76477700 }
76487701 break;
....@@ -7656,24 +7709,24 @@
76567709 */
76577710 {
76587711 aironet_ioctl com;
7659
- if (copy_from_user(&com,rq->ifr_data,sizeof(com))) {
7712
+ if (copy_from_user(&com, rq->ifr_data, sizeof(com))) {
76607713 rc = -EFAULT;
76617714 break;
76627715 }
76637716
76647717 /* Separate R/W functions bracket legality here
76657718 */
7666
- if ( com.command == AIRORSWVERSION ) {
7719
+ if (com.command == AIRORSWVERSION) {
76677720 if (copy_to_user(com.data, swversion, sizeof(swversion)))
76687721 rc = -EFAULT;
76697722 else
76707723 rc = 0;
76717724 }
7672
- else if ( com.command <= AIRORRID)
7725
+ else if (com.command <= AIRORRID)
76737726 rc = readrids(dev,&com);
7674
- else if ( com.command >= AIROPCAP && com.command <= (AIROPLEAPUSR+2) )
7727
+ else if (com.command >= AIROPCAP && com.command <= (AIROPLEAPUSR+2))
76757728 rc = writerids(dev,&com);
7676
- else if ( com.command >= AIROFLSHRST && com.command <= AIRORESTART )
7729
+ else if (com.command >= AIROFLSHRST && com.command <= AIRORESTART)
76777730 rc = flashcard(dev,&com);
76787731 else
76797732 rc = -EINVAL; /* Bad command in ioctl */
....@@ -7775,7 +7828,8 @@
77757828 * as needed. This represents the READ side of control I/O to
77767829 * the card
77777830 */
7778
-static int readrids(struct net_device *dev, aironet_ioctl *comp) {
7831
+static int readrids(struct net_device *dev, aironet_ioctl *comp)
7832
+{
77797833 unsigned short ridcode;
77807834 unsigned char *iobuf;
77817835 int len;
....@@ -7805,7 +7859,7 @@
78057859 case AIROGSTATSC32: ridcode = RID_STATS; break;
78067860 case AIROGMICSTATS:
78077861 if (copy_to_user(comp->data, &ai->micstats,
7808
- min((int)comp->len,(int)sizeof(ai->micstats))))
7862
+ min((int)comp->len, (int)sizeof(ai->micstats))))
78097863 return -EFAULT;
78107864 return 0;
78117865 case AIRORRID: ridcode = comp->ridnum; break;
....@@ -7822,7 +7876,7 @@
78227876 if ((iobuf = kzalloc(RIDSIZE, GFP_KERNEL)) == NULL)
78237877 return -ENOMEM;
78247878
7825
- PC4500_readrid(ai,ridcode,iobuf,RIDSIZE, 1);
7879
+ PC4500_readrid(ai, ridcode, iobuf, RIDSIZE, 1);
78267880 /* get the count of bytes in the rid docs say 1st 2 bytes is it.
78277881 * then return it to the user
78287882 * 9/22/2000 Honor user given length
....@@ -7841,7 +7895,8 @@
78417895 * Danger Will Robinson write the rids here
78427896 */
78437897
7844
-static int writerids(struct net_device *dev, aironet_ioctl *comp) {
7898
+static int writerids(struct net_device *dev, aironet_ioctl *comp)
7899
+{
78457900 struct airo_info *ai = dev->ml_priv;
78467901 int ridcode;
78477902 int enabled;
....@@ -7898,10 +7953,10 @@
78987953 if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL)
78997954 return -ENOMEM;
79007955
7901
- PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDSIZE, 1);
7956
+ PC4500_readrid(ai, RID_STATSDELTACLEAR, iobuf, RIDSIZE, 1);
79027957
79037958 enabled = ai->micstats.enabled;
7904
- memset(&ai->micstats,0,sizeof(ai->micstats));
7959
+ memset(&ai->micstats, 0, sizeof(ai->micstats));
79057960 ai->micstats.enabled = enabled;
79067961
79077962 if (copy_to_user(comp->data, iobuf,
....@@ -7915,13 +7970,13 @@
79157970 default:
79167971 return -EOPNOTSUPP; /* Blarg! */
79177972 }
7918
- if(comp->len > RIDSIZE)
7973
+ if (comp->len > RIDSIZE)
79197974 return -EINVAL;
79207975
79217976 if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL)
79227977 return -ENOMEM;
79237978
7924
- if (copy_from_user(iobuf,comp->data,comp->len)) {
7979
+ if (copy_from_user(iobuf, comp->data, comp->len)) {
79257980 kfree (iobuf);
79267981 return -EFAULT;
79277982 }
....@@ -7938,7 +7993,7 @@
79387993 clear_bit (FLAG_ADHOC, &ai->flags);
79397994 }
79407995
7941
- if((*writer)(ai, ridcode, iobuf,comp->len,1)) {
7996
+ if ((*writer)(ai, ridcode, iobuf, comp->len, 1)) {
79427997 kfree (iobuf);
79437998 return -EIO;
79447999 }
....@@ -7955,7 +8010,8 @@
79558010 * Flash command switch table
79568011 */
79578012
7958
-static int flashcard(struct net_device *dev, aironet_ioctl *comp) {
8013
+static int flashcard(struct net_device *dev, aironet_ioctl *comp)
8014
+{
79598015 int z;
79608016
79618017 /* Only super-user can modify flash */
....@@ -7974,23 +8030,23 @@
79748030 return setflashmode((struct airo_info *)dev->ml_priv);
79758031
79768032 case AIROFLSHGCHR: /* Get char from aux */
7977
- if(comp->len != sizeof(int))
8033
+ if (comp->len != sizeof(int))
79788034 return -EINVAL;
7979
- if (copy_from_user(&z,comp->data,comp->len))
8035
+ if (copy_from_user(&z, comp->data, comp->len))
79808036 return -EFAULT;
79818037 return flashgchar((struct airo_info *)dev->ml_priv, z, 8000);
79828038
79838039 case AIROFLSHPCHR: /* Send char to card. */
7984
- if(comp->len != sizeof(int))
8040
+ if (comp->len != sizeof(int))
79858041 return -EINVAL;
7986
- if (copy_from_user(&z,comp->data,comp->len))
8042
+ if (copy_from_user(&z, comp->data, comp->len))
79878043 return -EFAULT;
79888044 return flashpchar((struct airo_info *)dev->ml_priv, z, 8000);
79898045
79908046 case AIROFLPUTBUF: /* Send 32k to card */
79918047 if (!AIRO_FLASH(dev))
79928048 return -ENOMEM;
7993
- if(comp->len > FLASHSIZE)
8049
+ if (comp->len > FLASHSIZE)
79948050 return -EINVAL;
79958051 if (copy_from_user(AIRO_FLASH(dev), comp->data, comp->len))
79968052 return -EFAULT;
....@@ -8014,19 +8070,20 @@
80148070 * card.
80158071 */
80168072
8017
-static int cmdreset(struct airo_info *ai) {
8073
+static int cmdreset(struct airo_info *ai)
8074
+{
80188075 disable_MAC(ai, 1);
80198076
8020
- if(!waitbusy (ai)){
8077
+ if (!waitbusy (ai)) {
80218078 airo_print_info(ai->dev->name, "Waitbusy hang before RESET");
80228079 return -EBUSY;
80238080 }
80248081
8025
- OUT4500(ai,COMMAND,CMD_SOFTRESET);
8082
+ OUT4500(ai, COMMAND, CMD_SOFTRESET);
80268083
80278084 ssleep(1); /* WAS 600 12/7/00 */
80288085
8029
- if(!waitbusy (ai)){
8086
+ if (!waitbusy (ai)) {
80308087 airo_print_info(ai->dev->name, "Waitbusy hang AFTER RESET");
80318088 return -EBUSY;
80328089 }
....@@ -8038,22 +8095,23 @@
80388095 * mode
80398096 */
80408097
8041
-static int setflashmode (struct airo_info *ai) {
8098
+static int setflashmode (struct airo_info *ai)
8099
+{
80428100 set_bit (FLAG_FLASHING, &ai->flags);
80438101
80448102 OUT4500(ai, SWS0, FLASH_COMMAND);
80458103 OUT4500(ai, SWS1, FLASH_COMMAND);
80468104 if (probe) {
80478105 OUT4500(ai, SWS0, FLASH_COMMAND);
8048
- OUT4500(ai, COMMAND,0x10);
8106
+ OUT4500(ai, COMMAND, 0x10);
80498107 } else {
80508108 OUT4500(ai, SWS2, FLASH_COMMAND);
80518109 OUT4500(ai, SWS3, FLASH_COMMAND);
8052
- OUT4500(ai, COMMAND,0);
8110
+ OUT4500(ai, COMMAND, 0);
80538111 }
80548112 msleep(500); /* 500ms delay */
80558113
8056
- if(!waitbusy(ai)) {
8114
+ if (!waitbusy(ai)) {
80578115 clear_bit (FLAG_FLASHING, &ai->flags);
80588116 airo_print_info(ai->dev->name, "Waitbusy hang after setflash mode");
80598117 return -EIO;
....@@ -8065,16 +8123,17 @@
80658123 * x 50us for echo .
80668124 */
80678125
8068
-static int flashpchar(struct airo_info *ai,int byte,int dwelltime) {
8126
+static int flashpchar(struct airo_info *ai, int byte, int dwelltime)
8127
+{
80698128 int echo;
80708129 int waittime;
80718130
80728131 byte |= 0x8000;
80738132
8074
- if(dwelltime == 0 )
8133
+ if (dwelltime == 0)
80758134 dwelltime = 200;
80768135
8077
- waittime=dwelltime;
8136
+ waittime = dwelltime;
80788137
80798138 /* Wait for busy bit d15 to go false indicating buffer empty */
80808139 while ((IN4500 (ai, SWS0) & 0x8000) && waittime > 0) {
....@@ -8083,20 +8142,20 @@
80838142 }
80848143
80858144 /* timeout for busy clear wait */
8086
- if(waittime <= 0 ){
8145
+ if (waittime <= 0) {
80878146 airo_print_info(ai->dev->name, "flash putchar busywait timeout!");
80888147 return -EBUSY;
80898148 }
80908149
80918150 /* Port is clear now write byte and wait for it to echo back */
80928151 do {
8093
- OUT4500(ai,SWS0,byte);
8152
+ OUT4500(ai, SWS0, byte);
80948153 udelay(50);
80958154 dwelltime -= 50;
8096
- echo = IN4500(ai,SWS1);
8155
+ echo = IN4500(ai, SWS1);
80978156 } while (dwelltime >= 0 && echo != byte);
80988157
8099
- OUT4500(ai,SWS1,0);
8158
+ OUT4500(ai, SWS1, 0);
81008159
81018160 return (echo == byte) ? 0 : -EIO;
81028161 }
....@@ -8105,29 +8164,30 @@
81058164 * Get a character from the card matching matchbyte
81068165 * Step 3)
81078166 */
8108
-static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime){
8167
+static int flashgchar(struct airo_info *ai, int matchbyte, int dwelltime)
8168
+{
81098169 int rchar;
8110
- unsigned char rbyte=0;
8170
+ unsigned char rbyte = 0;
81118171
81128172 do {
8113
- rchar = IN4500(ai,SWS1);
8173
+ rchar = IN4500(ai, SWS1);
81148174
8115
- if(dwelltime && !(0x8000 & rchar)){
8175
+ if (dwelltime && !(0x8000 & rchar)) {
81168176 dwelltime -= 10;
81178177 mdelay(10);
81188178 continue;
81198179 }
81208180 rbyte = 0xff & rchar;
81218181
8122
- if( (rbyte == matchbyte) && (0x8000 & rchar) ){
8123
- OUT4500(ai,SWS1,0);
8182
+ if ((rbyte == matchbyte) && (0x8000 & rchar)) {
8183
+ OUT4500(ai, SWS1, 0);
81248184 return 0;
81258185 }
8126
- if( rbyte == 0x81 || rbyte == 0x82 || rbyte == 0x83 || rbyte == 0x1a || 0xffff == rchar)
8186
+ if (rbyte == 0x81 || rbyte == 0x82 || rbyte == 0x83 || rbyte == 0x1a || 0xffff == rchar)
81278187 break;
8128
- OUT4500(ai,SWS1,0);
8188
+ OUT4500(ai, SWS1, 0);
81298189
8130
- }while(dwelltime > 0);
8190
+ } while (dwelltime > 0);
81318191 return -EIO;
81328192 }
81338193
....@@ -8136,21 +8196,22 @@
81368196 * send to the card
81378197 */
81388198
8139
-static int flashputbuf(struct airo_info *ai){
8199
+static int flashputbuf(struct airo_info *ai)
8200
+{
81408201 int nwords;
81418202
81428203 /* Write stuff */
81438204 if (test_bit(FLAG_MPI,&ai->flags))
81448205 memcpy_toio(ai->pciaux + 0x8000, ai->flash, FLASHSIZE);
81458206 else {
8146
- OUT4500(ai,AUXPAGE,0x100);
8147
- OUT4500(ai,AUXOFF,0);
8207
+ OUT4500(ai, AUXPAGE, 0x100);
8208
+ OUT4500(ai, AUXOFF, 0);
81488209
8149
- for(nwords=0;nwords != FLASHSIZE / 2;nwords++){
8150
- OUT4500(ai,AUXDATA,ai->flash[nwords] & 0xffff);
8210
+ for (nwords = 0; nwords != FLASHSIZE / 2; nwords++) {
8211
+ OUT4500(ai, AUXDATA, ai->flash[nwords] & 0xffff);
81518212 }
81528213 }
8153
- OUT4500(ai,SWS0,0x8000);
8214
+ OUT4500(ai, SWS0, 0x8000);
81548215
81558216 return 0;
81568217 }
....@@ -8158,8 +8219,9 @@
81588219 /*
81598220 *
81608221 */
8161
-static int flashrestart(struct airo_info *ai,struct net_device *dev){
8162
- int i,status;
8222
+static int flashrestart(struct airo_info *ai, struct net_device *dev)
8223
+{
8224
+ int i, status;
81638225
81648226 ssleep(1); /* Added 12/7/00 */
81658227 clear_bit (FLAG_FLASHING, &ai->flags);
....@@ -8171,9 +8233,9 @@
81718233 status = setup_card(ai, dev->dev_addr, 1);
81728234
81738235 if (!test_bit(FLAG_MPI,&ai->flags))
8174
- for( i = 0; i < MAX_FIDS; i++ ) {
8236
+ for (i = 0; i < MAX_FIDS; i++) {
81758237 ai->fids[i] = transmit_allocate
8176
- ( ai, AIRO_DEF_MTU, i >= MAX_FIDS / 2 );
8238
+ (ai, AIRO_DEF_MTU, i >= MAX_FIDS / 2);
81778239 }
81788240
81798241 ssleep(1); /* Added 12/7/00 */