| .. | .. |
|---|
| 49 | 49 | #include <linux/kthread.h> |
|---|
| 50 | 50 | #include <linux/freezer.h> |
|---|
| 51 | 51 | |
|---|
| 52 | +#include <crypto/aes.h> |
|---|
| 53 | +#include <crypto/skcipher.h> |
|---|
| 54 | + |
|---|
| 52 | 55 | #include <net/cfg80211.h> |
|---|
| 53 | 56 | #include <net/iw_handler.h> |
|---|
| 54 | 57 | |
|---|
| .. | .. |
|---|
| 71 | 74 | |
|---|
| 72 | 75 | static int airo_pci_probe(struct pci_dev *, const struct pci_device_id *); |
|---|
| 73 | 76 | 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); |
|---|
| 76 | 83 | |
|---|
| 77 | 84 | 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, |
|---|
| 84 | 90 | }; |
|---|
| 85 | 91 | #endif /* CONFIG_PCI */ |
|---|
| 86 | 92 | |
|---|
| .. | .. |
|---|
| 315 | 321 | #define CMD_DELTLV 0x002b |
|---|
| 316 | 322 | #define CMD_FINDNEXTTLV 0x002c |
|---|
| 317 | 323 | #define CMD_PSPNODES 0x0030 |
|---|
| 318 | | -#define CMD_SETCW 0x0031 |
|---|
| 319 | | -#define CMD_SETPCF 0x0032 |
|---|
| 324 | +#define CMD_SETCW 0x0031 |
|---|
| 325 | +#define CMD_SETPCF 0x0032 |
|---|
| 320 | 326 | #define CMD_SETPHYREG 0x003e |
|---|
| 321 | 327 | #define CMD_TXTEST 0x003f |
|---|
| 322 | 328 | #define MAC_ENABLETX 0x0101 |
|---|
| .. | .. |
|---|
| 427 | 433 | #define STATUS_INTS (EV_AWAKE|EV_LINK|EV_TXEXC|EV_TX|EV_TXCPY|EV_RX|EV_MIC) |
|---|
| 428 | 434 | |
|---|
| 429 | 435 | #ifdef CHECK_UNKNOWN_INTS |
|---|
| 430 | | -#define IGNORE_INTS ( EV_CMD | EV_UNKNOWN) |
|---|
| 436 | +#define IGNORE_INTS (EV_CMD | EV_UNKNOWN) |
|---|
| 431 | 437 | #else |
|---|
| 432 | 438 | #define IGNORE_INTS (~STATUS_INTS) |
|---|
| 433 | 439 | #endif |
|---|
| .. | .. |
|---|
| 951 | 957 | } mic_statistics; |
|---|
| 952 | 958 | |
|---|
| 953 | 959 | typedef struct { |
|---|
| 954 | | - u32 coeff[((EMMH32_MSGLEN_MAX)+3)>>2]; |
|---|
| 960 | + __be32 coeff[((EMMH32_MSGLEN_MAX)+3)>>2]; |
|---|
| 955 | 961 | u64 accum; // accumulated mic, reduced to u32 in final() |
|---|
| 956 | 962 | int position; // current position (byte offset) in message |
|---|
| 957 | 963 | union { |
|---|
| .. | .. |
|---|
| 1101 | 1107 | |
|---|
| 1102 | 1108 | struct airo_info; |
|---|
| 1103 | 1109 | |
|---|
| 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); |
|---|
| 1107 | 1113 | static u16 setup_card(struct airo_info*, u8 *mac, int lock); |
|---|
| 1108 | 1114 | static int enable_MAC(struct airo_info *ai, int lock); |
|---|
| 1109 | 1115 | static void disable_MAC(struct airo_info *ai, int lock); |
|---|
| .. | .. |
|---|
| 1121 | 1127 | static int PC4500_readrid(struct airo_info*, u16 rid, void *pBuf, int len, int lock); |
|---|
| 1122 | 1128 | static int PC4500_writerid(struct airo_info*, u16 rid, const void |
|---|
| 1123 | 1129 | *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); |
|---|
| 1126 | 1132 | static u16 transmit_allocate(struct airo_info*, int lenPayload, int raw); |
|---|
| 1127 | 1133 | static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket); |
|---|
| 1128 | 1134 | static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket); |
|---|
| 1129 | 1135 | |
|---|
| 1130 | | -static int mpi_send_packet (struct net_device *dev); |
|---|
| 1136 | +static int mpi_send_packet(struct net_device *dev); |
|---|
| 1131 | 1137 | static void mpi_unmap_card(struct pci_dev *pci); |
|---|
| 1132 | 1138 | static void mpi_receive_802_3(struct airo_info *ai); |
|---|
| 1133 | 1139 | 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); |
|---|
| 1135 | 1141 | |
|---|
| 1136 | | -static irqreturn_t airo_interrupt( int irq, void* dev_id); |
|---|
| 1142 | +static irqreturn_t airo_interrupt(int irq, void* dev_id); |
|---|
| 1137 | 1143 | static int airo_thread(void *data); |
|---|
| 1138 | | -static void timer_func( struct net_device *dev ); |
|---|
| 1144 | +static void timer_func(struct net_device *dev); |
|---|
| 1139 | 1145 | 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); |
|---|
| 1142 | 1148 | #ifdef CISCO_EXT |
|---|
| 1143 | 1149 | static int readrids(struct net_device *dev, aironet_ioctl *comp); |
|---|
| 1144 | 1150 | static int writerids(struct net_device *dev, aironet_ioctl *comp); |
|---|
| .. | .. |
|---|
| 1149 | 1155 | static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len); |
|---|
| 1150 | 1156 | static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen); |
|---|
| 1151 | 1157 | |
|---|
| 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); |
|---|
| 1154 | 1160 | |
|---|
| 1155 | 1161 | static void airo_networks_free(struct airo_info *ai); |
|---|
| 1156 | 1162 | |
|---|
| .. | .. |
|---|
| 1216 | 1222 | struct iw_spy_data spy_data; |
|---|
| 1217 | 1223 | struct iw_public_data wireless_data; |
|---|
| 1218 | 1224 | /* MIC stuff */ |
|---|
| 1219 | | - struct crypto_cipher *tfm; |
|---|
| 1225 | + struct crypto_sync_skcipher *tfm; |
|---|
| 1220 | 1226 | mic_module mod[2]; |
|---|
| 1221 | 1227 | mic_statistics micstats; |
|---|
| 1222 | 1228 | HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors |
|---|
| .. | .. |
|---|
| 1255 | 1261 | return ai->bap_read(ai, pu16Dst, bytelen, whichbap); |
|---|
| 1256 | 1262 | } |
|---|
| 1257 | 1263 | |
|---|
| 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); |
|---|
| 1262 | 1268 | |
|---|
| 1263 | 1269 | 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); |
|---|
| 1266 | 1272 | 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); |
|---|
| 1268 | 1274 | |
|---|
| 1269 | 1275 | #define airo_print(type, name, fmt, args...) \ |
|---|
| 1270 | 1276 | printk(type DRV_NAME "(%s): " fmt "\n", name, ##args) |
|---|
| .. | .. |
|---|
| 1288 | 1294 | *********************************************************************** |
|---|
| 1289 | 1295 | */ |
|---|
| 1290 | 1296 | |
|---|
| 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); |
|---|
| 1292 | 1298 | static void MoveWindow(miccntx *context, u32 micSeq); |
|---|
| 1293 | 1299 | static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, |
|---|
| 1294 | | - struct crypto_cipher *tfm); |
|---|
| 1300 | + struct crypto_sync_skcipher *tfm); |
|---|
| 1295 | 1301 | static void emmh32_init(emmh32_context *context); |
|---|
| 1296 | 1302 | static void emmh32_update(emmh32_context *context, u8 *pOctets, int len); |
|---|
| 1297 | 1303 | 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); |
|---|
| 1299 | 1305 | |
|---|
| 1300 | 1306 | 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) |
|---|
| 1302 | 1308 | { |
|---|
| 1303 | 1309 | /* If the current MIC context is valid and its key is the same as |
|---|
| 1304 | 1310 | * the MIC register, there's nothing to do. |
|---|
| .. | .. |
|---|
| 1355 | 1361 | |
|---|
| 1356 | 1362 | /* micsetup - Get ready for business */ |
|---|
| 1357 | 1363 | |
|---|
| 1358 | | -static int micsetup(struct airo_info *ai) { |
|---|
| 1364 | +static int micsetup(struct airo_info *ai) |
|---|
| 1365 | +{ |
|---|
| 1359 | 1366 | int i; |
|---|
| 1360 | 1367 | |
|---|
| 1361 | 1368 | 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); |
|---|
| 1363 | 1370 | |
|---|
| 1364 | 1371 | if (IS_ERR(ai->tfm)) { |
|---|
| 1365 | 1372 | airo_print_err(ai->dev->name, "failed to load transform for AES"); |
|---|
| .. | .. |
|---|
| 1367 | 1374 | return ERROR; |
|---|
| 1368 | 1375 | } |
|---|
| 1369 | 1376 | |
|---|
| 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)); |
|---|
| 1373 | 1380 | } |
|---|
| 1374 | 1381 | return SUCCESS; |
|---|
| 1375 | 1382 | } |
|---|
| 1376 | 1383 | |
|---|
| 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}; |
|---|
| 1378 | 1385 | |
|---|
| 1379 | 1386 | /*=========================================================================== |
|---|
| 1380 | 1387 | * Description: Mic a packet |
|---|
| 1381 | | - * |
|---|
| 1388 | + * |
|---|
| 1382 | 1389 | * Inputs: etherHead * pointer to an 802.3 frame |
|---|
| 1383 | | - * |
|---|
| 1390 | + * |
|---|
| 1384 | 1391 | * Returns: BOOLEAN if successful, otherwise false. |
|---|
| 1385 | 1392 | * PacketTxLen will be updated with the mic'd packets size. |
|---|
| 1386 | 1393 | * |
|---|
| 1387 | 1394 | * Caveats: It is assumed that the frame buffer will already |
|---|
| 1388 | 1395 | * be big enough to hold the largets mic message possible. |
|---|
| 1389 | 1396 | * (No memory allocation is done here). |
|---|
| 1390 | | - * |
|---|
| 1397 | + * |
|---|
| 1391 | 1398 | * Author: sbraneky (10/15/01) |
|---|
| 1392 | 1399 | * Merciless hacks by rwilcher (1/14/02) |
|---|
| 1393 | 1400 | */ |
|---|
| 1394 | 1401 | |
|---|
| 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) |
|---|
| 1396 | 1403 | { |
|---|
| 1397 | 1404 | miccntx *context; |
|---|
| 1398 | 1405 | |
|---|
| .. | .. |
|---|
| 1403 | 1410 | context = &ai->mod[0].mCtx; |
|---|
| 1404 | 1411 | else |
|---|
| 1405 | 1412 | context = &ai->mod[0].uCtx; |
|---|
| 1406 | | - |
|---|
| 1413 | + |
|---|
| 1407 | 1414 | if (!context->valid) |
|---|
| 1408 | 1415 | return ERROR; |
|---|
| 1409 | 1416 | |
|---|
| .. | .. |
|---|
| 1416 | 1423 | context->tx += 2; |
|---|
| 1417 | 1424 | |
|---|
| 1418 | 1425 | 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 |
|---|
| 1423 | 1430 | emmh32_final(&context->seed, (u8*)&mic->mic); |
|---|
| 1424 | 1431 | |
|---|
| 1425 | 1432 | /* New Type/length ?????????? */ |
|---|
| .. | .. |
|---|
| 1438 | 1445 | /*=========================================================================== |
|---|
| 1439 | 1446 | * Description: Decapsulates a MIC'd packet and returns the 802.3 packet |
|---|
| 1440 | 1447 | * (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 | + * |
|---|
| 1444 | 1451 | * Returns: BOOLEAN - TRUE if packet should be dropped otherwise FALSE |
|---|
| 1445 | | - * |
|---|
| 1452 | + * |
|---|
| 1446 | 1453 | * Author: sbraneky (10/15/01) |
|---|
| 1447 | 1454 | * Merciless hacks by rwilcher (1/14/02) |
|---|
| 1448 | 1455 | *--------------------------------------------------------------------------- |
|---|
| .. | .. |
|---|
| 1482 | 1489 | //Now do the mic error checking. |
|---|
| 1483 | 1490 | |
|---|
| 1484 | 1491 | //Receive seq must be odd |
|---|
| 1485 | | - if ( (micSEQ & 1) == 0 ) { |
|---|
| 1492 | + if ((micSEQ & 1) == 0) { |
|---|
| 1486 | 1493 | ai->micstats.rxWrongSequence++; |
|---|
| 1487 | 1494 | return ERROR; |
|---|
| 1488 | 1495 | } |
|---|
| 1489 | 1496 | |
|---|
| 1490 | 1497 | for (i = 0; i < NUM_MODULES; i++) { |
|---|
| 1491 | 1498 | int mcast = eth->da[0] & 1; |
|---|
| 1492 | | - //Determine proper context |
|---|
| 1499 | + //Determine proper context |
|---|
| 1493 | 1500 | context = mcast ? &ai->mod[i].mCtx : &ai->mod[i].uCtx; |
|---|
| 1494 | | - |
|---|
| 1501 | + |
|---|
| 1495 | 1502 | //Make sure context is valid |
|---|
| 1496 | 1503 | if (!context->valid) { |
|---|
| 1497 | 1504 | if (i == 0) |
|---|
| 1498 | 1505 | micError = NOMICPLUMMED; |
|---|
| 1499 | | - continue; |
|---|
| 1506 | + continue; |
|---|
| 1500 | 1507 | } |
|---|
| 1501 | | - //DeMic it |
|---|
| 1508 | + //DeMic it |
|---|
| 1502 | 1509 | |
|---|
| 1503 | 1510 | if (!mic->typelen) |
|---|
| 1504 | 1511 | mic->typelen = htons(payLen + sizeof(MICBuffer) - 2); |
|---|
| 1505 | | - |
|---|
| 1512 | + |
|---|
| 1506 | 1513 | 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); |
|---|
| 1511 | 1518 | //Calculate MIC |
|---|
| 1512 | 1519 | emmh32_final(&context->seed, digest); |
|---|
| 1513 | | - |
|---|
| 1520 | + |
|---|
| 1514 | 1521 | if (memcmp(digest, &mic->mic, 4)) { //Make sure the mics match |
|---|
| 1515 | 1522 | //Invalid Mic |
|---|
| 1516 | 1523 | if (i == 0) |
|---|
| .. | .. |
|---|
| 1541 | 1548 | /*=========================================================================== |
|---|
| 1542 | 1549 | * Description: Checks the Rx Seq number to make sure it is valid |
|---|
| 1543 | 1550 | * and hasn't already been received |
|---|
| 1544 | | - * |
|---|
| 1551 | + * |
|---|
| 1545 | 1552 | * Inputs: miccntx - mic context to check seq against |
|---|
| 1546 | 1553 | * micSeq - the Mic seq number |
|---|
| 1547 | | - * |
|---|
| 1548 | | - * Returns: TRUE if valid otherwise FALSE. |
|---|
| 1554 | + * |
|---|
| 1555 | + * Returns: TRUE if valid otherwise FALSE. |
|---|
| 1549 | 1556 | * |
|---|
| 1550 | 1557 | * Author: sbraneky (10/15/01) |
|---|
| 1551 | 1558 | * Merciless hacks by rwilcher (1/14/02) |
|---|
| 1552 | 1559 | *--------------------------------------------------------------------------- |
|---|
| 1553 | 1560 | */ |
|---|
| 1554 | 1561 | |
|---|
| 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) |
|---|
| 1556 | 1563 | { |
|---|
| 1557 | | - u32 seq,index; |
|---|
| 1564 | + u32 seq, index; |
|---|
| 1558 | 1565 | |
|---|
| 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 |
|---|
| 1560 | 1567 | //sequence number of the current sequence number - might go backwards |
|---|
| 1561 | 1568 | |
|---|
| 1562 | 1569 | if (mcast) { |
|---|
| .. | .. |
|---|
| 1577 | 1584 | //Too old of a SEQ number to check. |
|---|
| 1578 | 1585 | if ((s32)seq < 0) |
|---|
| 1579 | 1586 | return ERROR; |
|---|
| 1580 | | - |
|---|
| 1581 | | - if ( seq > 64 ) { |
|---|
| 1587 | + |
|---|
| 1588 | + if (seq > 64) { |
|---|
| 1582 | 1589 | //Window is infinite forward |
|---|
| 1583 | | - MoveWindow(context,micSeq); |
|---|
| 1590 | + MoveWindow(context, micSeq); |
|---|
| 1584 | 1591 | return SUCCESS; |
|---|
| 1585 | 1592 | } |
|---|
| 1586 | 1593 | |
|---|
| .. | .. |
|---|
| 1593 | 1600 | //Add seqence number to the list of received numbers. |
|---|
| 1594 | 1601 | context->rx |= index; |
|---|
| 1595 | 1602 | |
|---|
| 1596 | | - MoveWindow(context,micSeq); |
|---|
| 1603 | + MoveWindow(context, micSeq); |
|---|
| 1597 | 1604 | |
|---|
| 1598 | 1605 | return SUCCESS; |
|---|
| 1599 | 1606 | } |
|---|
| .. | .. |
|---|
| 1607 | 1614 | //Move window if seq greater than the middle of the window |
|---|
| 1608 | 1615 | if (micSeq > context->window) { |
|---|
| 1609 | 1616 | shift = (micSeq - context->window) >> 1; |
|---|
| 1610 | | - |
|---|
| 1617 | + |
|---|
| 1611 | 1618 | //Shift out old |
|---|
| 1612 | 1619 | if (shift < 32) |
|---|
| 1613 | 1620 | context->rx >>= shift; |
|---|
| .. | .. |
|---|
| 1624 | 1631 | |
|---|
| 1625 | 1632 | /* mic accumulate */ |
|---|
| 1626 | 1633 | #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++]); |
|---|
| 1630 | 1635 | |
|---|
| 1631 | 1636 | /* expand the key to fill the MMH coefficient array */ |
|---|
| 1632 | 1637 | static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, |
|---|
| 1633 | | - struct crypto_cipher *tfm) |
|---|
| 1638 | + struct crypto_sync_skcipher *tfm) |
|---|
| 1634 | 1639 | { |
|---|
| 1635 | 1640 | /* take the keying material, expand if necessary, truncate at 16-bytes */ |
|---|
| 1636 | 1641 | /* run through AES counter mode to generate context->coeff[] */ |
|---|
| 1637 | | - |
|---|
| 1638 | | - int i,j; |
|---|
| 1639 | | - u32 counter; |
|---|
| 1640 | | - u8 *cipher, plain[16]; |
|---|
| 1641 | 1642 | |
|---|
| 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); |
|---|
| 1658 | 1659 | } |
|---|
| 1659 | 1660 | |
|---|
| 1660 | 1661 | /* prepare for calculation of a new mic */ |
|---|
| .. | .. |
|---|
| 1669 | 1670 | static void emmh32_update(emmh32_context *context, u8 *pOctets, int len) |
|---|
| 1670 | 1671 | { |
|---|
| 1671 | 1672 | int coeff_position, byte_position; |
|---|
| 1672 | | - |
|---|
| 1673 | + |
|---|
| 1673 | 1674 | if (len == 0) return; |
|---|
| 1674 | | - |
|---|
| 1675 | + |
|---|
| 1675 | 1676 | coeff_position = context->position >> 2; |
|---|
| 1676 | | - |
|---|
| 1677 | + |
|---|
| 1677 | 1678 | /* deal with partial 32-bit word left over from last update */ |
|---|
| 1678 | 1679 | byte_position = context->position & 3; |
|---|
| 1679 | 1680 | if (byte_position) { |
|---|
| .. | .. |
|---|
| 1712 | 1713 | { |
|---|
| 1713 | 1714 | int coeff_position, byte_position; |
|---|
| 1714 | 1715 | u32 val; |
|---|
| 1715 | | - |
|---|
| 1716 | + |
|---|
| 1716 | 1717 | u64 sum, utmp; |
|---|
| 1717 | 1718 | s64 stmp; |
|---|
| 1718 | 1719 | |
|---|
| 1719 | 1720 | coeff_position = context->position >> 2; |
|---|
| 1720 | | - |
|---|
| 1721 | + |
|---|
| 1721 | 1722 | /* deal with partial 32-bit word left over from last update */ |
|---|
| 1722 | 1723 | byte_position = context->position & 3; |
|---|
| 1723 | 1724 | if (byte_position) { |
|---|
| .. | .. |
|---|
| 1750 | 1751 | if (first == 1) { |
|---|
| 1751 | 1752 | if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; |
|---|
| 1752 | 1753 | memset(&cmd, 0, sizeof(cmd)); |
|---|
| 1753 | | - cmd.cmd=CMD_LISTBSS; |
|---|
| 1754 | + cmd.cmd = CMD_LISTBSS; |
|---|
| 1754 | 1755 | if (down_interruptible(&ai->sem)) |
|---|
| 1755 | 1756 | return -ERESTARTSYS; |
|---|
| 1756 | 1757 | ai->list_bss_task = current; |
|---|
| .. | .. |
|---|
| 1815 | 1816 | int i; |
|---|
| 1816 | 1817 | /* Old hardware had a limit on encryption speed */ |
|---|
| 1817 | 1818 | if (ai->config.authType != AUTH_OPEN && maxencrypt) { |
|---|
| 1818 | | - for(i=0; i<8; i++) { |
|---|
| 1819 | + for (i = 0; i<8; i++) { |
|---|
| 1819 | 1820 | if (ai->config.rates[i] > maxencrypt) { |
|---|
| 1820 | 1821 | ai->config.rates[i] = 0; |
|---|
| 1821 | 1822 | } |
|---|
| .. | .. |
|---|
| 1840 | 1841 | else |
|---|
| 1841 | 1842 | clear_bit(FLAG_ADHOC, &ai->flags); |
|---|
| 1842 | 1843 | |
|---|
| 1843 | | - return PC4500_writerid( ai, RID_CONFIG, &cfgr, sizeof(cfgr), lock); |
|---|
| 1844 | + return PC4500_writerid(ai, RID_CONFIG, &cfgr, sizeof(cfgr), lock); |
|---|
| 1844 | 1845 | } |
|---|
| 1845 | 1846 | |
|---|
| 1846 | 1847 | static int readStatusRid(struct airo_info *ai, StatusRid *statr, int lock) |
|---|
| .. | .. |
|---|
| 1871 | 1872 | } |
|---|
| 1872 | 1873 | } |
|---|
| 1873 | 1874 | |
|---|
| 1874 | | -static int airo_open(struct net_device *dev) { |
|---|
| 1875 | +static int airo_open(struct net_device *dev) |
|---|
| 1876 | +{ |
|---|
| 1875 | 1877 | struct airo_info *ai = dev->ml_priv; |
|---|
| 1876 | 1878 | int rc = 0; |
|---|
| 1877 | 1879 | |
|---|
| .. | .. |
|---|
| 1947 | 1949 | spin_lock_irqsave(&ai->aux_lock, flags); |
|---|
| 1948 | 1950 | skb_queue_tail (&ai->txq, skb); |
|---|
| 1949 | 1951 | pending = test_bit(FLAG_PENDING_XMIT, &ai->flags); |
|---|
| 1950 | | - spin_unlock_irqrestore(&ai->aux_lock,flags); |
|---|
| 1952 | + spin_unlock_irqrestore(&ai->aux_lock, flags); |
|---|
| 1951 | 1953 | netif_wake_queue (dev); |
|---|
| 1952 | 1954 | |
|---|
| 1953 | 1955 | if (pending == 0) { |
|---|
| .. | .. |
|---|
| 2096 | 2098 | } |
|---|
| 2097 | 2099 | } |
|---|
| 2098 | 2100 | |
|---|
| 2099 | | -static void airo_end_xmit(struct net_device *dev) { |
|---|
| 2101 | +static void airo_end_xmit(struct net_device *dev) |
|---|
| 2102 | +{ |
|---|
| 2100 | 2103 | u16 status; |
|---|
| 2101 | 2104 | int i; |
|---|
| 2102 | 2105 | struct airo_info *priv = dev->ml_priv; |
|---|
| .. | .. |
|---|
| 2110 | 2113 | up(&priv->sem); |
|---|
| 2111 | 2114 | |
|---|
| 2112 | 2115 | i = 0; |
|---|
| 2113 | | - if ( status == SUCCESS ) { |
|---|
| 2116 | + if (status == SUCCESS) { |
|---|
| 2114 | 2117 | netif_trans_update(dev); |
|---|
| 2115 | 2118 | for (; i < MAX_FIDS / 2 && (priv->fids[i] & 0xffff0000); i++); |
|---|
| 2116 | 2119 | } else { |
|---|
| .. | .. |
|---|
| 2130 | 2133 | struct airo_info *priv = dev->ml_priv; |
|---|
| 2131 | 2134 | u32 *fids = priv->fids; |
|---|
| 2132 | 2135 | |
|---|
| 2133 | | - if ( skb == NULL ) { |
|---|
| 2136 | + if (skb == NULL) { |
|---|
| 2134 | 2137 | airo_print_err(dev->name, "%s: skb == NULL!", __func__); |
|---|
| 2135 | 2138 | return NETDEV_TX_OK; |
|---|
| 2136 | 2139 | } |
|---|
| .. | .. |
|---|
| 2140 | 2143 | } |
|---|
| 2141 | 2144 | |
|---|
| 2142 | 2145 | /* 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++); |
|---|
| 2145 | 2148 | |
|---|
| 2146 | | - if ( j >= MAX_FIDS / 2 ) { |
|---|
| 2149 | + if (j >= MAX_FIDS / 2) { |
|---|
| 2147 | 2150 | netif_stop_queue(dev); |
|---|
| 2148 | 2151 | |
|---|
| 2149 | 2152 | if (i == MAX_FIDS / 2) { |
|---|
| .. | .. |
|---|
| 2167 | 2170 | return NETDEV_TX_OK; |
|---|
| 2168 | 2171 | } |
|---|
| 2169 | 2172 | |
|---|
| 2170 | | -static void airo_end_xmit11(struct net_device *dev) { |
|---|
| 2173 | +static void airo_end_xmit11(struct net_device *dev) |
|---|
| 2174 | +{ |
|---|
| 2171 | 2175 | u16 status; |
|---|
| 2172 | 2176 | int i; |
|---|
| 2173 | 2177 | struct airo_info *priv = dev->ml_priv; |
|---|
| .. | .. |
|---|
| 2181 | 2185 | up(&priv->sem); |
|---|
| 2182 | 2186 | |
|---|
| 2183 | 2187 | i = MAX_FIDS / 2; |
|---|
| 2184 | | - if ( status == SUCCESS ) { |
|---|
| 2188 | + if (status == SUCCESS) { |
|---|
| 2185 | 2189 | netif_trans_update(dev); |
|---|
| 2186 | 2190 | for (; i < MAX_FIDS && (priv->fids[i] & 0xffff0000); i++); |
|---|
| 2187 | 2191 | } else { |
|---|
| .. | .. |
|---|
| 2208 | 2212 | return NETDEV_TX_OK; |
|---|
| 2209 | 2213 | } |
|---|
| 2210 | 2214 | |
|---|
| 2211 | | - if ( skb == NULL ) { |
|---|
| 2215 | + if (skb == NULL) { |
|---|
| 2212 | 2216 | airo_print_err(dev->name, "%s: skb == NULL!", __func__); |
|---|
| 2213 | 2217 | return NETDEV_TX_OK; |
|---|
| 2214 | 2218 | } |
|---|
| .. | .. |
|---|
| 2218 | 2222 | } |
|---|
| 2219 | 2223 | |
|---|
| 2220 | 2224 | /* 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++); |
|---|
| 2223 | 2227 | |
|---|
| 2224 | | - if ( j >= MAX_FIDS ) { |
|---|
| 2228 | + if (j >= MAX_FIDS) { |
|---|
| 2225 | 2229 | netif_stop_queue(dev); |
|---|
| 2226 | 2230 | |
|---|
| 2227 | 2231 | if (i == MAX_FIDS) { |
|---|
| .. | .. |
|---|
| 2295 | 2299 | return &dev->stats; |
|---|
| 2296 | 2300 | } |
|---|
| 2297 | 2301 | |
|---|
| 2298 | | -static void airo_set_promisc(struct airo_info *ai) { |
|---|
| 2302 | +static void airo_set_promisc(struct airo_info *ai) |
|---|
| 2303 | +{ |
|---|
| 2299 | 2304 | Cmd cmd; |
|---|
| 2300 | 2305 | Resp rsp; |
|---|
| 2301 | 2306 | |
|---|
| 2302 | 2307 | memset(&cmd, 0, sizeof(cmd)); |
|---|
| 2303 | | - cmd.cmd=CMD_SETMODE; |
|---|
| 2308 | + cmd.cmd = CMD_SETMODE; |
|---|
| 2304 | 2309 | clear_bit(JOB_PROMISC, &ai->jobs); |
|---|
| 2305 | 2310 | cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; |
|---|
| 2306 | 2311 | issuecommand(ai, &cmd, &rsp); |
|---|
| 2307 | 2312 | up(&ai->sem); |
|---|
| 2308 | 2313 | } |
|---|
| 2309 | 2314 | |
|---|
| 2310 | | -static void airo_set_multicast_list(struct net_device *dev) { |
|---|
| 2315 | +static void airo_set_multicast_list(struct net_device *dev) |
|---|
| 2316 | +{ |
|---|
| 2311 | 2317 | struct airo_info *ai = dev->ml_priv; |
|---|
| 2312 | 2318 | |
|---|
| 2313 | 2319 | if ((dev->flags ^ ai->flags) & IFF_PROMISC) { |
|---|
| .. | .. |
|---|
| 2357 | 2363 | list_del(&ai->dev_list); |
|---|
| 2358 | 2364 | } |
|---|
| 2359 | 2365 | |
|---|
| 2360 | | -static int airo_close(struct net_device *dev) { |
|---|
| 2366 | +static int airo_close(struct net_device *dev) |
|---|
| 2367 | +{ |
|---|
| 2361 | 2368 | struct airo_info *ai = dev->ml_priv; |
|---|
| 2362 | 2369 | |
|---|
| 2363 | 2370 | netif_stop_queue(dev); |
|---|
| .. | .. |
|---|
| 2372 | 2379 | set_bit(FLAG_RADIO_DOWN, &ai->flags); |
|---|
| 2373 | 2380 | disable_MAC(ai, 1); |
|---|
| 2374 | 2381 | #endif |
|---|
| 2375 | | - disable_interrupts( ai ); |
|---|
| 2382 | + disable_interrupts(ai); |
|---|
| 2376 | 2383 | |
|---|
| 2377 | 2384 | free_irq(dev->irq, dev); |
|---|
| 2378 | 2385 | |
|---|
| .. | .. |
|---|
| 2382 | 2389 | return 0; |
|---|
| 2383 | 2390 | } |
|---|
| 2384 | 2391 | |
|---|
| 2385 | | -void stop_airo_card( struct net_device *dev, int freeres ) |
|---|
| 2392 | +void stop_airo_card(struct net_device *dev, int freeres) |
|---|
| 2386 | 2393 | { |
|---|
| 2387 | 2394 | struct airo_info *ai = dev->ml_priv; |
|---|
| 2388 | 2395 | |
|---|
| 2389 | 2396 | set_bit(FLAG_RADIO_DOWN, &ai->flags); |
|---|
| 2390 | 2397 | disable_MAC(ai, 1); |
|---|
| 2391 | 2398 | disable_interrupts(ai); |
|---|
| 2392 | | - takedown_proc_entry( dev, ai ); |
|---|
| 2399 | + takedown_proc_entry(dev, ai); |
|---|
| 2393 | 2400 | if (test_bit(FLAG_REGISTERED, &ai->flags)) { |
|---|
| 2394 | | - unregister_netdev( dev ); |
|---|
| 2401 | + unregister_netdev(dev); |
|---|
| 2395 | 2402 | if (ai->wifidev) { |
|---|
| 2396 | 2403 | unregister_netdev(ai->wifidev); |
|---|
| 2397 | 2404 | free_netdev(ai->wifidev); |
|---|
| .. | .. |
|---|
| 2415 | 2422 | kfree(ai->SSID); |
|---|
| 2416 | 2423 | if (freeres) { |
|---|
| 2417 | 2424 | /* PCMCIA frees this stuff, so only for PCI and ISA */ |
|---|
| 2418 | | - release_region( dev->base_addr, 64 ); |
|---|
| 2425 | + release_region(dev->base_addr, 64); |
|---|
| 2419 | 2426 | if (test_bit(FLAG_MPI, &ai->flags)) { |
|---|
| 2420 | 2427 | if (ai->pci) |
|---|
| 2421 | 2428 | mpi_unmap_card(ai->pci); |
|---|
| .. | .. |
|---|
| 2423 | 2430 | iounmap(ai->pcimem); |
|---|
| 2424 | 2431 | if (ai->pciaux) |
|---|
| 2425 | 2432 | 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); |
|---|
| 2428 | 2435 | } |
|---|
| 2429 | 2436 | } |
|---|
| 2430 | | - crypto_free_cipher(ai->tfm); |
|---|
| 2437 | + crypto_free_sync_skcipher(ai->tfm); |
|---|
| 2431 | 2438 | del_airo_dev(ai); |
|---|
| 2432 | | - free_netdev( dev ); |
|---|
| 2439 | + free_netdev(dev); |
|---|
| 2433 | 2440 | } |
|---|
| 2434 | 2441 | |
|---|
| 2435 | 2442 | EXPORT_SYMBOL(stop_airo_card); |
|---|
| .. | .. |
|---|
| 2453 | 2460 | |
|---|
| 2454 | 2461 | /************************************************************* |
|---|
| 2455 | 2462 | * 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 |
|---|
| 2457 | 2464 | * have been initialized . Returns 0 if all is well nz |
|---|
| 2458 | 2465 | * otherwise . Does not allocate memory but sets up card |
|---|
| 2459 | 2466 | * using previously allocated descriptors. |
|---|
| .. | .. |
|---|
| 2468 | 2475 | /* Alloc card RX descriptors */ |
|---|
| 2469 | 2476 | netif_stop_queue(ai->dev); |
|---|
| 2470 | 2477 | |
|---|
| 2471 | | - memset(&rsp,0,sizeof(rsp)); |
|---|
| 2472 | | - memset(&cmd,0,sizeof(cmd)); |
|---|
| 2478 | + memset(&rsp, 0, sizeof(rsp)); |
|---|
| 2479 | + memset(&cmd, 0, sizeof(cmd)); |
|---|
| 2473 | 2480 | |
|---|
| 2474 | 2481 | cmd.cmd = CMD_ALLOCATEAUX; |
|---|
| 2475 | 2482 | cmd.parm0 = FID_RX; |
|---|
| 2476 | 2483 | cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux); |
|---|
| 2477 | 2484 | cmd.parm2 = MPI_MAX_FIDS; |
|---|
| 2478 | | - rc=issuecommand(ai, &cmd, &rsp); |
|---|
| 2485 | + rc = issuecommand(ai, &cmd, &rsp); |
|---|
| 2479 | 2486 | if (rc != SUCCESS) { |
|---|
| 2480 | 2487 | airo_print_err(ai->dev->name, "Couldn't allocate RX FID"); |
|---|
| 2481 | 2488 | return rc; |
|---|
| 2482 | 2489 | } |
|---|
| 2483 | 2490 | |
|---|
| 2484 | | - for (i=0; i<MPI_MAX_FIDS; i++) { |
|---|
| 2491 | + for (i = 0; i<MPI_MAX_FIDS; i++) { |
|---|
| 2485 | 2492 | memcpy_toio(ai->rxfids[i].card_ram_off, |
|---|
| 2486 | 2493 | &ai->rxfids[i].rx_desc, sizeof(RxFid)); |
|---|
| 2487 | 2494 | } |
|---|
| 2488 | 2495 | |
|---|
| 2489 | 2496 | /* Alloc card TX descriptors */ |
|---|
| 2490 | 2497 | |
|---|
| 2491 | | - memset(&rsp,0,sizeof(rsp)); |
|---|
| 2492 | | - memset(&cmd,0,sizeof(cmd)); |
|---|
| 2498 | + memset(&rsp, 0, sizeof(rsp)); |
|---|
| 2499 | + memset(&cmd, 0, sizeof(cmd)); |
|---|
| 2493 | 2500 | |
|---|
| 2494 | 2501 | cmd.cmd = CMD_ALLOCATEAUX; |
|---|
| 2495 | 2502 | cmd.parm0 = FID_TX; |
|---|
| 2496 | 2503 | cmd.parm1 = (ai->txfids[0].card_ram_off - ai->pciaux); |
|---|
| 2497 | 2504 | cmd.parm2 = MPI_MAX_FIDS; |
|---|
| 2498 | 2505 | |
|---|
| 2499 | | - for (i=0; i<MPI_MAX_FIDS; i++) { |
|---|
| 2506 | + for (i = 0; i<MPI_MAX_FIDS; i++) { |
|---|
| 2500 | 2507 | ai->txfids[i].tx_desc.valid = 1; |
|---|
| 2501 | 2508 | memcpy_toio(ai->txfids[i].card_ram_off, |
|---|
| 2502 | 2509 | &ai->txfids[i].tx_desc, sizeof(TxFid)); |
|---|
| 2503 | 2510 | } |
|---|
| 2504 | 2511 | ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ |
|---|
| 2505 | 2512 | |
|---|
| 2506 | | - rc=issuecommand(ai, &cmd, &rsp); |
|---|
| 2513 | + rc = issuecommand(ai, &cmd, &rsp); |
|---|
| 2507 | 2514 | if (rc != SUCCESS) { |
|---|
| 2508 | 2515 | airo_print_err(ai->dev->name, "Couldn't allocate TX FID"); |
|---|
| 2509 | 2516 | return rc; |
|---|
| 2510 | 2517 | } |
|---|
| 2511 | 2518 | |
|---|
| 2512 | 2519 | /* 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)); |
|---|
| 2515 | 2522 | |
|---|
| 2516 | 2523 | cmd.cmd = CMD_ALLOCATEAUX; |
|---|
| 2517 | 2524 | cmd.parm0 = RID_RW; |
|---|
| 2518 | 2525 | cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux); |
|---|
| 2519 | 2526 | cmd.parm2 = 1; /* Magic number... */ |
|---|
| 2520 | | - rc=issuecommand(ai, &cmd, &rsp); |
|---|
| 2527 | + rc = issuecommand(ai, &cmd, &rsp); |
|---|
| 2521 | 2528 | if (rc != SUCCESS) { |
|---|
| 2522 | 2529 | airo_print_err(ai->dev->name, "Couldn't allocate RID"); |
|---|
| 2523 | 2530 | return rc; |
|---|
| .. | .. |
|---|
| 2574 | 2581 | } |
|---|
| 2575 | 2582 | |
|---|
| 2576 | 2583 | /* 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); |
|---|
| 2578 | 2586 | if (!ai->shared) { |
|---|
| 2579 | | - airo_print_err("", "Couldn't alloc_consistent %d", |
|---|
| 2587 | + airo_print_err("", "Couldn't alloc_coherent %d", |
|---|
| 2580 | 2588 | PCI_SHARED_LEN); |
|---|
| 2581 | 2589 | goto free_auxmap; |
|---|
| 2582 | 2590 | } |
|---|
| .. | .. |
|---|
| 2589 | 2597 | vpackoff = ai->shared; |
|---|
| 2590 | 2598 | |
|---|
| 2591 | 2599 | /* RX descriptor setup */ |
|---|
| 2592 | | - for(i = 0; i < MPI_MAX_FIDS; i++) { |
|---|
| 2600 | + for (i = 0; i < MPI_MAX_FIDS; i++) { |
|---|
| 2593 | 2601 | ai->rxfids[i].pending = 0; |
|---|
| 2594 | 2602 | ai->rxfids[i].card_ram_off = pciaddroff; |
|---|
| 2595 | 2603 | ai->rxfids[i].virtual_host_addr = vpackoff; |
|---|
| .. | .. |
|---|
| 2604 | 2612 | } |
|---|
| 2605 | 2613 | |
|---|
| 2606 | 2614 | /* TX descriptor setup */ |
|---|
| 2607 | | - for(i = 0; i < MPI_MAX_FIDS; i++) { |
|---|
| 2615 | + for (i = 0; i < MPI_MAX_FIDS; i++) { |
|---|
| 2608 | 2616 | ai->txfids[i].card_ram_off = pciaddroff; |
|---|
| 2609 | 2617 | ai->txfids[i].virtual_host_addr = vpackoff; |
|---|
| 2610 | 2618 | ai->txfids[i].tx_desc.valid = 1; |
|---|
| .. | .. |
|---|
| 2636 | 2644 | |
|---|
| 2637 | 2645 | return 0; |
|---|
| 2638 | 2646 | 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); |
|---|
| 2640 | 2649 | free_auxmap: |
|---|
| 2641 | 2650 | iounmap(ai->pciaux); |
|---|
| 2642 | 2651 | free_memmap: |
|---|
| .. | .. |
|---|
| 2674 | 2683 | dev->min_mtu = 68; |
|---|
| 2675 | 2684 | dev->max_mtu = MIC_MSGLEN_MAX; |
|---|
| 2676 | 2685 | dev->addr_len = ETH_ALEN; |
|---|
| 2677 | | - dev->tx_queue_len = 100; |
|---|
| 2686 | + dev->tx_queue_len = 100; |
|---|
| 2678 | 2687 | |
|---|
| 2679 | 2688 | eth_broadcast_addr(dev->broadcast); |
|---|
| 2680 | 2689 | |
|---|
| .. | .. |
|---|
| 2703 | 2712 | return dev; |
|---|
| 2704 | 2713 | } |
|---|
| 2705 | 2714 | |
|---|
| 2706 | | -static int reset_card( struct net_device *dev , int lock) { |
|---|
| 2715 | +static int reset_card(struct net_device *dev, int lock) |
|---|
| 2716 | +{ |
|---|
| 2707 | 2717 | struct airo_info *ai = dev->ml_priv; |
|---|
| 2708 | 2718 | |
|---|
| 2709 | 2719 | if (lock && down_interruptible(&ai->sem)) |
|---|
| 2710 | 2720 | return -1; |
|---|
| 2711 | 2721 | waitbusy (ai); |
|---|
| 2712 | | - OUT4500(ai,COMMAND,CMD_SOFTRESET); |
|---|
| 2722 | + OUT4500(ai, COMMAND, CMD_SOFTRESET); |
|---|
| 2713 | 2723 | msleep(200); |
|---|
| 2714 | 2724 | waitbusy (ai); |
|---|
| 2715 | 2725 | msleep(200); |
|---|
| .. | .. |
|---|
| 2774 | 2784 | }; |
|---|
| 2775 | 2785 | |
|---|
| 2776 | 2786 | |
|---|
| 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, |
|---|
| 2778 | 2788 | int is_pcmcia, struct pci_dev *pci, |
|---|
| 2779 | | - struct device *dmdev ) |
|---|
| 2789 | + struct device *dmdev) |
|---|
| 2780 | 2790 | { |
|---|
| 2781 | 2791 | struct net_device *dev; |
|---|
| 2782 | 2792 | struct airo_info *ai; |
|---|
| .. | .. |
|---|
| 2849 | 2859 | |
|---|
| 2850 | 2860 | if (probe) { |
|---|
| 2851 | 2861 | 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"); |
|---|
| 2853 | 2863 | rc = -EIO; |
|---|
| 2854 | 2864 | goto err_out_map; |
|---|
| 2855 | 2865 | } |
|---|
| .. | .. |
|---|
| 2907 | 2917 | |
|---|
| 2908 | 2918 | /* Allocate the transmit buffers */ |
|---|
| 2909 | 2919 | 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); |
|---|
| 2912 | 2922 | |
|---|
| 2913 | 2923 | if (setup_proc_entry(dev, dev->ml_priv) < 0) |
|---|
| 2914 | 2924 | goto err_out_wifi; |
|---|
| .. | .. |
|---|
| 2922 | 2932 | unregister_netdev(dev); |
|---|
| 2923 | 2933 | err_out_map: |
|---|
| 2924 | 2934 | 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); |
|---|
| 2926 | 2937 | iounmap(ai->pciaux); |
|---|
| 2927 | 2938 | iounmap(ai->pcimem); |
|---|
| 2928 | 2939 | mpi_unmap_card(ai->pci); |
|---|
| 2929 | 2940 | } |
|---|
| 2930 | 2941 | err_out_res: |
|---|
| 2931 | 2942 | if (!is_pcmcia) |
|---|
| 2932 | | - release_region( dev->base_addr, 64 ); |
|---|
| 2943 | + release_region(dev->base_addr, 64); |
|---|
| 2933 | 2944 | err_out_nets: |
|---|
| 2934 | 2945 | airo_networks_free(ai); |
|---|
| 2935 | 2946 | err_out_free: |
|---|
| .. | .. |
|---|
| 2938 | 2949 | return NULL; |
|---|
| 2939 | 2950 | } |
|---|
| 2940 | 2951 | |
|---|
| 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, |
|---|
| 2942 | 2953 | struct device *dmdev) |
|---|
| 2943 | 2954 | { |
|---|
| 2944 | | - return _init_airo_card ( irq, port, is_pcmcia, NULL, dmdev); |
|---|
| 2955 | + return _init_airo_card (irq, port, is_pcmcia, NULL, dmdev); |
|---|
| 2945 | 2956 | } |
|---|
| 2946 | 2957 | |
|---|
| 2947 | 2958 | EXPORT_SYMBOL(init_airo_card); |
|---|
| 2948 | 2959 | |
|---|
| 2949 | | -static int waitbusy (struct airo_info *ai) { |
|---|
| 2960 | +static int waitbusy (struct airo_info *ai) |
|---|
| 2961 | +{ |
|---|
| 2950 | 2962 | int delay = 0; |
|---|
| 2951 | 2963 | while ((IN4500(ai, COMMAND) & COMMAND_BUSY) && (delay < 10000)) { |
|---|
| 2952 | 2964 | udelay (10); |
|---|
| .. | .. |
|---|
| 2956 | 2968 | return delay < 10000; |
|---|
| 2957 | 2969 | } |
|---|
| 2958 | 2970 | |
|---|
| 2959 | | -int reset_airo_card( struct net_device *dev ) |
|---|
| 2971 | +int reset_airo_card(struct net_device *dev) |
|---|
| 2960 | 2972 | { |
|---|
| 2961 | 2973 | int i; |
|---|
| 2962 | 2974 | struct airo_info *ai = dev->ml_priv; |
|---|
| .. | .. |
|---|
| 2964 | 2976 | if (reset_card (dev, 1)) |
|---|
| 2965 | 2977 | return -1; |
|---|
| 2966 | 2978 | |
|---|
| 2967 | | - if ( setup_card(ai, dev->dev_addr, 1 ) != SUCCESS ) { |
|---|
| 2979 | + if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) { |
|---|
| 2968 | 2980 | airo_print_err(dev->name, "MAC could not be enabled"); |
|---|
| 2969 | 2981 | return -1; |
|---|
| 2970 | 2982 | } |
|---|
| 2971 | 2983 | airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr); |
|---|
| 2972 | 2984 | /* Allocate the transmit buffers if needed */ |
|---|
| 2973 | 2985 | 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); |
|---|
| 2976 | 2988 | |
|---|
| 2977 | | - enable_interrupts( ai ); |
|---|
| 2989 | + enable_interrupts(ai); |
|---|
| 2978 | 2990 | netif_wake_queue(dev); |
|---|
| 2979 | 2991 | return 0; |
|---|
| 2980 | 2992 | } |
|---|
| 2981 | 2993 | |
|---|
| 2982 | 2994 | EXPORT_SYMBOL(reset_airo_card); |
|---|
| 2983 | 2995 | |
|---|
| 2984 | | -static void airo_send_event(struct net_device *dev) { |
|---|
| 2996 | +static void airo_send_event(struct net_device *dev) |
|---|
| 2997 | +{ |
|---|
| 2985 | 2998 | struct airo_info *ai = dev->ml_priv; |
|---|
| 2986 | 2999 | union iwreq_data wrqu; |
|---|
| 2987 | 3000 | StatusRid status_rid; |
|---|
| .. | .. |
|---|
| 2998 | 3011 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); |
|---|
| 2999 | 3012 | } |
|---|
| 3000 | 3013 | |
|---|
| 3001 | | -static void airo_process_scan_results (struct airo_info *ai) { |
|---|
| 3014 | +static void airo_process_scan_results (struct airo_info *ai) |
|---|
| 3015 | +{ |
|---|
| 3002 | 3016 | union iwreq_data wrqu; |
|---|
| 3003 | 3017 | BSSListRid bss; |
|---|
| 3004 | 3018 | int rc; |
|---|
| .. | .. |
|---|
| 3014 | 3028 | |
|---|
| 3015 | 3029 | /* Try to read the first entry of the scan result */ |
|---|
| 3016 | 3030 | 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))) { |
|---|
| 3018 | 3032 | /* No scan results */ |
|---|
| 3019 | 3033 | goto out; |
|---|
| 3020 | 3034 | } |
|---|
| 3021 | 3035 | |
|---|
| 3022 | 3036 | /* Read and parse all entries */ |
|---|
| 3023 | 3037 | tmp_net = NULL; |
|---|
| 3024 | | - while((!rc) && (bss.index != cpu_to_le16(0xffff))) { |
|---|
| 3038 | + while ((!rc) && (bss.index != cpu_to_le16(0xffff))) { |
|---|
| 3025 | 3039 | /* Grab a network off the free list */ |
|---|
| 3026 | 3040 | if (!list_empty(&ai->network_free_list)) { |
|---|
| 3027 | 3041 | tmp_net = list_entry(ai->network_free_list.next, |
|---|
| .. | .. |
|---|
| 3062 | 3076 | wireless_send_event(ai->dev, SIOCGIWSCAN, &wrqu, NULL); |
|---|
| 3063 | 3077 | } |
|---|
| 3064 | 3078 | |
|---|
| 3065 | | -static int airo_thread(void *data) { |
|---|
| 3079 | +static int airo_thread(void *data) |
|---|
| 3080 | +{ |
|---|
| 3066 | 3081 | struct net_device *dev = data; |
|---|
| 3067 | 3082 | struct airo_info *ai = dev->ml_priv; |
|---|
| 3068 | 3083 | int locked; |
|---|
| 3069 | 3084 | |
|---|
| 3070 | 3085 | set_freezable(); |
|---|
| 3071 | | - while(1) { |
|---|
| 3086 | + while (1) { |
|---|
| 3072 | 3087 | /* make swsusp happy with our thread */ |
|---|
| 3073 | 3088 | try_to_freeze(); |
|---|
| 3074 | 3089 | |
|---|
| .. | .. |
|---|
| 3088 | 3103 | break; |
|---|
| 3089 | 3104 | if (ai->expires || ai->scan_timeout) { |
|---|
| 3090 | 3105 | if (ai->scan_timeout && |
|---|
| 3091 | | - time_after_eq(jiffies,ai->scan_timeout)){ |
|---|
| 3106 | + time_after_eq(jiffies, ai->scan_timeout)) { |
|---|
| 3092 | 3107 | set_bit(JOB_SCAN_RESULTS, &ai->jobs); |
|---|
| 3093 | 3108 | break; |
|---|
| 3094 | 3109 | } else if (ai->expires && |
|---|
| 3095 | | - time_after_eq(jiffies,ai->expires)){ |
|---|
| 3110 | + time_after_eq(jiffies, ai->expires)) { |
|---|
| 3096 | 3111 | set_bit(JOB_AUTOWEP, &ai->jobs); |
|---|
| 3097 | 3112 | break; |
|---|
| 3098 | 3113 | } |
|---|
| .. | .. |
|---|
| 3116 | 3131 | } |
|---|
| 3117 | 3132 | break; |
|---|
| 3118 | 3133 | } |
|---|
| 3119 | | - current->state = TASK_RUNNING; |
|---|
| 3134 | + __set_current_state(TASK_RUNNING); |
|---|
| 3120 | 3135 | remove_wait_queue(&ai->thr_wait, &wait); |
|---|
| 3121 | 3136 | locked = 1; |
|---|
| 3122 | 3137 | } |
|---|
| .. | .. |
|---|
| 3442 | 3457 | |
|---|
| 3443 | 3458 | spin_lock_irqsave(&ai->aux_lock, flags); |
|---|
| 3444 | 3459 | if (!skb_queue_empty(&ai->txq)) { |
|---|
| 3445 | | - spin_unlock_irqrestore(&ai->aux_lock,flags); |
|---|
| 3460 | + spin_unlock_irqrestore(&ai->aux_lock, flags); |
|---|
| 3446 | 3461 | mpi_send_packet(ai->dev); |
|---|
| 3447 | 3462 | } else { |
|---|
| 3448 | 3463 | clear_bit(FLAG_PENDING_XMIT, &ai->flags); |
|---|
| 3449 | | - spin_unlock_irqrestore(&ai->aux_lock,flags); |
|---|
| 3464 | + spin_unlock_irqrestore(&ai->aux_lock, flags); |
|---|
| 3450 | 3465 | netif_wake_queue(ai->dev); |
|---|
| 3451 | 3466 | } |
|---|
| 3452 | 3467 | OUT4500(ai, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC)); |
|---|
| .. | .. |
|---|
| 3526 | 3541 | if (status & (EV_TX | EV_TXCPY | EV_TXEXC)) |
|---|
| 3527 | 3542 | airo_handle_tx(ai, status); |
|---|
| 3528 | 3543 | |
|---|
| 3529 | | - if ( status & ~STATUS_INTS & ~IGNORE_INTS ) { |
|---|
| 3544 | + if (status & ~STATUS_INTS & ~IGNORE_INTS) { |
|---|
| 3530 | 3545 | airo_print_warn(ai->dev->name, "Got weird status %x", |
|---|
| 3531 | | - status & ~STATUS_INTS & ~IGNORE_INTS ); |
|---|
| 3546 | + status & ~STATUS_INTS & ~IGNORE_INTS); |
|---|
| 3532 | 3547 | } |
|---|
| 3533 | 3548 | } |
|---|
| 3534 | 3549 | |
|---|
| .. | .. |
|---|
| 3547 | 3562 | * NOTE: If use with 8bit mode and SMP bad things will happen! |
|---|
| 3548 | 3563 | * Why would some one do 8 bit IO in an SMP machine?!? |
|---|
| 3549 | 3564 | */ |
|---|
| 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 | +{ |
|---|
| 3551 | 3567 | if (test_bit(FLAG_MPI,&ai->flags)) |
|---|
| 3552 | 3568 | reg <<= 1; |
|---|
| 3553 | | - if ( !do8bitIO ) |
|---|
| 3554 | | - outw( val, ai->dev->base_addr + reg ); |
|---|
| 3569 | + if (!do8bitIO) |
|---|
| 3570 | + outw(val, ai->dev->base_addr + reg); |
|---|
| 3555 | 3571 | 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); |
|---|
| 3558 | 3574 | } |
|---|
| 3559 | 3575 | } |
|---|
| 3560 | 3576 | |
|---|
| 3561 | | -static u16 IN4500( struct airo_info *ai, u16 reg ) { |
|---|
| 3577 | +static u16 IN4500(struct airo_info *ai, u16 reg) |
|---|
| 3578 | +{ |
|---|
| 3562 | 3579 | unsigned short rc; |
|---|
| 3563 | 3580 | |
|---|
| 3564 | 3581 | if (test_bit(FLAG_MPI,&ai->flags)) |
|---|
| 3565 | 3582 | reg <<= 1; |
|---|
| 3566 | | - if ( !do8bitIO ) |
|---|
| 3567 | | - rc = inw( ai->dev->base_addr + reg ); |
|---|
| 3583 | + if (!do8bitIO) |
|---|
| 3584 | + rc = inw(ai->dev->base_addr + reg); |
|---|
| 3568 | 3585 | 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; |
|---|
| 3571 | 3588 | } |
|---|
| 3572 | 3589 | return rc; |
|---|
| 3573 | 3590 | } |
|---|
| .. | .. |
|---|
| 3611 | 3628 | return rc; |
|---|
| 3612 | 3629 | } |
|---|
| 3613 | 3630 | |
|---|
| 3614 | | -static void disable_MAC( struct airo_info *ai, int lock ) { |
|---|
| 3631 | +static void disable_MAC(struct airo_info *ai, int lock) |
|---|
| 3632 | +{ |
|---|
| 3615 | 3633 | Cmd cmd; |
|---|
| 3616 | 3634 | Resp rsp; |
|---|
| 3617 | 3635 | |
|---|
| .. | .. |
|---|
| 3630 | 3648 | up(&ai->sem); |
|---|
| 3631 | 3649 | } |
|---|
| 3632 | 3650 | |
|---|
| 3633 | | -static void enable_interrupts( struct airo_info *ai ) { |
|---|
| 3651 | +static void enable_interrupts(struct airo_info *ai) |
|---|
| 3652 | +{ |
|---|
| 3634 | 3653 | /* Enable the interrupts */ |
|---|
| 3635 | | - OUT4500( ai, EVINTEN, STATUS_INTS ); |
|---|
| 3654 | + OUT4500(ai, EVINTEN, STATUS_INTS); |
|---|
| 3636 | 3655 | } |
|---|
| 3637 | 3656 | |
|---|
| 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); |
|---|
| 3640 | 3660 | } |
|---|
| 3641 | 3661 | |
|---|
| 3642 | 3662 | static void mpi_receive_802_3(struct airo_info *ai) |
|---|
| .. | .. |
|---|
| 3660 | 3680 | ai->dev->stats.rx_dropped++; |
|---|
| 3661 | 3681 | goto badrx; |
|---|
| 3662 | 3682 | } |
|---|
| 3663 | | - buffer = skb_put(skb,len); |
|---|
| 3683 | + buffer = skb_put(skb, len); |
|---|
| 3664 | 3684 | memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2); |
|---|
| 3665 | 3685 | if (ai->micstats.enabled) { |
|---|
| 3666 | 3686 | memcpy(&micbuf, |
|---|
| .. | .. |
|---|
| 3739 | 3759 | fc = get_unaligned((__le16 *)ptr); |
|---|
| 3740 | 3760 | hdrlen = header_len(fc); |
|---|
| 3741 | 3761 | |
|---|
| 3742 | | - skb = dev_alloc_skb( len + hdrlen + 2 ); |
|---|
| 3743 | | - if ( !skb ) { |
|---|
| 3762 | + skb = dev_alloc_skb(len + hdrlen + 2); |
|---|
| 3763 | + if (!skb) { |
|---|
| 3744 | 3764 | ai->dev->stats.rx_dropped++; |
|---|
| 3745 | 3765 | goto badrx; |
|---|
| 3746 | 3766 | } |
|---|
| .. | .. |
|---|
| 3784 | 3804 | skb->dev = ai->wifidev; |
|---|
| 3785 | 3805 | skb->protocol = htons(ETH_P_802_2); |
|---|
| 3786 | 3806 | skb->ip_summed = CHECKSUM_NONE; |
|---|
| 3787 | | - netif_rx( skb ); |
|---|
| 3807 | + netif_rx(skb); |
|---|
| 3788 | 3808 | |
|---|
| 3789 | 3809 | badrx: |
|---|
| 3790 | 3810 | if (rxd.valid == 0) { |
|---|
| .. | .. |
|---|
| 3805 | 3825 | local->last_auth = auth_type; |
|---|
| 3806 | 3826 | } |
|---|
| 3807 | 3827 | |
|---|
| 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 | + |
|---|
| 3808 | 3890 | static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) |
|---|
| 3809 | 3891 | { |
|---|
| 3810 | 3892 | Cmd cmd; |
|---|
| .. | .. |
|---|
| 3815 | 3897 | WepKeyRid wkr; |
|---|
| 3816 | 3898 | int rc; |
|---|
| 3817 | 3899 | |
|---|
| 3818 | | - memset( &mySsid, 0, sizeof( mySsid ) ); |
|---|
| 3900 | + memset(&mySsid, 0, sizeof(mySsid)); |
|---|
| 3819 | 3901 | kfree (ai->flash); |
|---|
| 3820 | 3902 | ai->flash = NULL; |
|---|
| 3821 | 3903 | |
|---|
| .. | .. |
|---|
| 3824 | 3906 | cmd.parm0 = cmd.parm1 = cmd.parm2 = 0; |
|---|
| 3825 | 3907 | if (lock && down_interruptible(&ai->sem)) |
|---|
| 3826 | 3908 | return ERROR; |
|---|
| 3827 | | - if ( issuecommand( ai, &cmd, &rsp ) != SUCCESS ) { |
|---|
| 3909 | + if (issuecommand(ai, &cmd, &rsp) != SUCCESS) { |
|---|
| 3828 | 3910 | if (lock) |
|---|
| 3829 | 3911 | up(&ai->sem); |
|---|
| 3830 | 3912 | return ERROR; |
|---|
| 3831 | 3913 | } |
|---|
| 3832 | | - disable_MAC( ai, 0); |
|---|
| 3914 | + disable_MAC(ai, 0); |
|---|
| 3833 | 3915 | |
|---|
| 3834 | 3916 | // Let's figure out if we need to use the AUX port |
|---|
| 3835 | 3917 | if (!test_bit(FLAG_MPI,&ai->flags)) { |
|---|
| .. | .. |
|---|
| 3851 | 3933 | if (lock) |
|---|
| 3852 | 3934 | up(&ai->sem); |
|---|
| 3853 | 3935 | 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; |
|---|
| 3906 | 3939 | } |
|---|
| 3907 | 3940 | |
|---|
| 3908 | 3941 | /* Setup the SSIDs if present */ |
|---|
| 3909 | | - if ( ssids[0] ) { |
|---|
| 3942 | + if (ssids[0]) { |
|---|
| 3910 | 3943 | int i; |
|---|
| 3911 | | - for( i = 0; i < 3 && ssids[i]; i++ ) { |
|---|
| 3944 | + for (i = 0; i < 3 && ssids[i]; i++) { |
|---|
| 3912 | 3945 | size_t len = strlen(ssids[i]); |
|---|
| 3913 | 3946 | if (len > 32) |
|---|
| 3914 | 3947 | len = 32; |
|---|
| .. | .. |
|---|
| 3919 | 3952 | } |
|---|
| 3920 | 3953 | |
|---|
| 3921 | 3954 | status = writeConfigRid(ai, lock); |
|---|
| 3922 | | - if ( status != SUCCESS ) return ERROR; |
|---|
| 3955 | + if (status != SUCCESS) return ERROR; |
|---|
| 3923 | 3956 | |
|---|
| 3924 | 3957 | /* Set up the SSID list */ |
|---|
| 3925 | | - if ( ssids[0] ) { |
|---|
| 3958 | + if (ssids[0]) { |
|---|
| 3926 | 3959 | status = writeSsidRid(ai, &mySsid, lock); |
|---|
| 3927 | | - if ( status != SUCCESS ) return ERROR; |
|---|
| 3960 | + if (status != SUCCESS) return ERROR; |
|---|
| 3928 | 3961 | } |
|---|
| 3929 | 3962 | |
|---|
| 3930 | 3963 | status = enable_MAC(ai, lock); |
|---|
| .. | .. |
|---|
| 3939 | 3972 | ai->defindex = wkr.mac[0]; |
|---|
| 3940 | 3973 | } |
|---|
| 3941 | 3974 | rc = readWepKeyRid(ai, &wkr, 0, lock); |
|---|
| 3942 | | - } while(lastindex != wkr.kindex); |
|---|
| 3975 | + } while (lastindex != wkr.kindex); |
|---|
| 3943 | 3976 | |
|---|
| 3944 | 3977 | try_auto_wep(ai); |
|---|
| 3945 | 3978 | |
|---|
| 3946 | 3979 | return SUCCESS; |
|---|
| 3947 | 3980 | } |
|---|
| 3948 | 3981 | |
|---|
| 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 | +{ |
|---|
| 3950 | 3984 | // Im really paranoid about letting it run forever! |
|---|
| 3951 | 3985 | int max_tries = 600000; |
|---|
| 3952 | 3986 | |
|---|
| .. | .. |
|---|
| 3966 | 4000 | schedule(); |
|---|
| 3967 | 4001 | } |
|---|
| 3968 | 4002 | |
|---|
| 3969 | | - if ( max_tries == -1 ) { |
|---|
| 4003 | + if (max_tries == -1) { |
|---|
| 3970 | 4004 | airo_print_err(ai->dev->name, |
|---|
| 3971 | 4005 | "Max tries exceeded when issuing command"); |
|---|
| 3972 | 4006 | if (IN4500(ai, COMMAND) & COMMAND_BUSY) |
|---|
| .. | .. |
|---|
| 3998 | 4032 | /* Sets up the bap to start exchange data. whichbap should |
|---|
| 3999 | 4033 | * be one of the BAP0 or BAP1 defines. Locks should be held before |
|---|
| 4000 | 4034 | * 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) |
|---|
| 4002 | 4036 | { |
|---|
| 4003 | 4037 | int timeout = 50; |
|---|
| 4004 | 4038 | int max_tries = 3; |
|---|
| .. | .. |
|---|
| 4013 | 4047 | if (timeout--) { |
|---|
| 4014 | 4048 | continue; |
|---|
| 4015 | 4049 | } |
|---|
| 4016 | | - } else if ( status & BAP_ERR ) { |
|---|
| 4050 | + } else if (status & BAP_ERR) { |
|---|
| 4017 | 4051 | /* invalid rid or offset */ |
|---|
| 4018 | 4052 | airo_print_err(ai->dev->name, "BAP error %x %d", |
|---|
| 4019 | | - status, whichbap ); |
|---|
| 4053 | + status, whichbap); |
|---|
| 4020 | 4054 | return ERROR; |
|---|
| 4021 | 4055 | } else if (status & BAP_DONE) { // success |
|---|
| 4022 | 4056 | return SUCCESS; |
|---|
| 4023 | 4057 | } |
|---|
| 4024 | | - if ( !(max_tries--) ) { |
|---|
| 4058 | + if (!(max_tries--)) { |
|---|
| 4025 | 4059 | airo_print_err(ai->dev->name, |
|---|
| 4026 | 4060 | "BAP setup error too many retries\n"); |
|---|
| 4027 | 4061 | return ERROR; |
|---|
| .. | .. |
|---|
| 4067 | 4101 | next = aux_setup(ai, page, offset, &len); |
|---|
| 4068 | 4102 | words = (bytelen+1)>>1; |
|---|
| 4069 | 4103 | |
|---|
| 4070 | | - for (i=0; i<words;) { |
|---|
| 4104 | + for (i = 0; i<words;) { |
|---|
| 4071 | 4105 | int count; |
|---|
| 4072 | 4106 | 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); |
|---|
| 4076 | 4110 | 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); |
|---|
| 4079 | 4113 | i += count; |
|---|
| 4080 | 4114 | if (i<words) { |
|---|
| 4081 | 4115 | next = aux_setup(ai, next, 4, &len); |
|---|
| .. | .. |
|---|
| 4091 | 4125 | int bytelen, int whichbap) |
|---|
| 4092 | 4126 | { |
|---|
| 4093 | 4127 | 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); |
|---|
| 4096 | 4130 | else |
|---|
| 4097 | | - insb( ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen ); |
|---|
| 4131 | + insb(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen); |
|---|
| 4098 | 4132 | return SUCCESS; |
|---|
| 4099 | 4133 | } |
|---|
| 4100 | 4134 | |
|---|
| .. | .. |
|---|
| 4103 | 4137 | int bytelen, int whichbap) |
|---|
| 4104 | 4138 | { |
|---|
| 4105 | 4139 | 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); |
|---|
| 4109 | 4143 | else |
|---|
| 4110 | | - outsb( ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen ); |
|---|
| 4144 | + outsb(ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen); |
|---|
| 4111 | 4145 | return SUCCESS; |
|---|
| 4112 | 4146 | } |
|---|
| 4113 | 4147 | |
|---|
| .. | .. |
|---|
| 4122 | 4156 | cmd.parm0 = rid; |
|---|
| 4123 | 4157 | status = issuecommand(ai, &cmd, &rsp); |
|---|
| 4124 | 4158 | if (status != 0) return status; |
|---|
| 4125 | | - if ( (rsp.status & 0x7F00) != 0) { |
|---|
| 4159 | + if ((rsp.status & 0x7F00) != 0) { |
|---|
| 4126 | 4160 | return (accmd << 8) + (rsp.rsp0 & 0xFF); |
|---|
| 4127 | 4161 | } |
|---|
| 4128 | 4162 | return 0; |
|---|
| .. | .. |
|---|
| 4177 | 4211 | // length for remaining part of rid |
|---|
| 4178 | 4212 | len = min(len, (int)le16_to_cpu(*(__le16*)pBuf)) - 2; |
|---|
| 4179 | 4213 | |
|---|
| 4180 | | - if ( len <= 2 ) { |
|---|
| 4214 | + if (len <= 2) { |
|---|
| 4181 | 4215 | airo_print_err(ai->dev->name, |
|---|
| 4182 | 4216 | "Rid %x has a length of %d which is too short", |
|---|
| 4183 | | - (int)rid, (int)len ); |
|---|
| 4217 | + (int)rid, (int)len); |
|---|
| 4184 | 4218 | rc = ERROR; |
|---|
| 4185 | 4219 | goto done; |
|---|
| 4186 | 4220 | } |
|---|
| .. | .. |
|---|
| 4248 | 4282 | } |
|---|
| 4249 | 4283 | } else { |
|---|
| 4250 | 4284 | // --- 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) { |
|---|
| 4252 | 4286 | rc = status; |
|---|
| 4253 | 4287 | goto done; |
|---|
| 4254 | 4288 | } |
|---|
| .. | .. |
|---|
| 4285 | 4319 | txFid = ERROR; |
|---|
| 4286 | 4320 | goto done; |
|---|
| 4287 | 4321 | } |
|---|
| 4288 | | - if ( (rsp.status & 0xFF00) != 0) { |
|---|
| 4322 | + if ((rsp.status & 0xFF00) != 0) { |
|---|
| 4289 | 4323 | txFid = ERROR; |
|---|
| 4290 | 4324 | goto done; |
|---|
| 4291 | 4325 | } |
|---|
| .. | .. |
|---|
| 4344 | 4378 | } |
|---|
| 4345 | 4379 | len -= ETH_ALEN * 2; |
|---|
| 4346 | 4380 | |
|---|
| 4347 | | - if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && |
|---|
| 4381 | + if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && |
|---|
| 4348 | 4382 | (ntohs(((__be16 *)pPacket)[6]) != 0x888E)) { |
|---|
| 4349 | | - if (encapsulate(ai,(etherHead *)pPacket,&pMic,len) != SUCCESS) |
|---|
| 4383 | + if (encapsulate(ai, (etherHead *)pPacket,&pMic, len) != SUCCESS) |
|---|
| 4350 | 4384 | return ERROR; |
|---|
| 4351 | 4385 | miclen = sizeof(pMic); |
|---|
| 4352 | 4386 | } |
|---|
| .. | .. |
|---|
| 4356 | 4390 | /* The hardware addresses aren't counted as part of the payload, so |
|---|
| 4357 | 4391 | * we have to subtract the 12 bytes for the addresses off */ |
|---|
| 4358 | 4392 | payloadLen = cpu_to_le16(len + miclen); |
|---|
| 4359 | | - bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1); |
|---|
| 4393 | + bap_write(ai, &payloadLen, sizeof(payloadLen), BAP1); |
|---|
| 4360 | 4394 | bap_write(ai, (__le16*)pPacket, sizeof(etherHead), BAP1); |
|---|
| 4361 | 4395 | if (miclen) |
|---|
| 4362 | 4396 | bap_write(ai, (__le16*)&pMic, miclen, BAP1); |
|---|
| 4363 | 4397 | bap_write(ai, (__le16*)(pPacket + sizeof(etherHead)), len, BAP1); |
|---|
| 4364 | 4398 | // issue the transmit command |
|---|
| 4365 | | - memset( &cmd, 0, sizeof( cmd ) ); |
|---|
| 4399 | + memset(&cmd, 0, sizeof(cmd)); |
|---|
| 4366 | 4400 | cmd.cmd = CMD_TRANSMIT; |
|---|
| 4367 | 4401 | cmd.parm0 = txFid; |
|---|
| 4368 | 4402 | if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR; |
|---|
| 4369 | | - if ( (rsp.status & 0xFF00) != 0) return ERROR; |
|---|
| 4403 | + if ((rsp.status & 0xFF00) != 0) return ERROR; |
|---|
| 4370 | 4404 | return SUCCESS; |
|---|
| 4371 | 4405 | } |
|---|
| 4372 | 4406 | |
|---|
| .. | .. |
|---|
| 4395 | 4429 | /* The 802.11 header aren't counted as part of the payload, so |
|---|
| 4396 | 4430 | * we have to subtract the header bytes off */ |
|---|
| 4397 | 4431 | payloadLen = cpu_to_le16(len-hdrlen); |
|---|
| 4398 | | - bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1); |
|---|
| 4432 | + bap_write(ai, &payloadLen, sizeof(payloadLen), BAP1); |
|---|
| 4399 | 4433 | if (bap_setup(ai, txFid, 0x0014, BAP1) != SUCCESS) return ERROR; |
|---|
| 4400 | 4434 | bap_write(ai, (__le16 *)pPacket, hdrlen, BAP1); |
|---|
| 4401 | 4435 | bap_write(ai, (__le16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1); |
|---|
| 4402 | 4436 | |
|---|
| 4403 | 4437 | bap_write(ai, (__le16 *)(pPacket + hdrlen), len - hdrlen, BAP1); |
|---|
| 4404 | 4438 | // issue the transmit command |
|---|
| 4405 | | - memset( &cmd, 0, sizeof( cmd ) ); |
|---|
| 4439 | + memset(&cmd, 0, sizeof(cmd)); |
|---|
| 4406 | 4440 | cmd.cmd = CMD_TRANSMIT; |
|---|
| 4407 | 4441 | cmd.parm0 = txFid; |
|---|
| 4408 | 4442 | if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR; |
|---|
| 4409 | | - if ( (rsp.status & 0xFF00) != 0) return ERROR; |
|---|
| 4443 | + if ((rsp.status & 0xFF00) != 0) return ERROR; |
|---|
| 4410 | 4444 | return SUCCESS; |
|---|
| 4411 | 4445 | } |
|---|
| 4412 | 4446 | |
|---|
| .. | .. |
|---|
| 4415 | 4449 | * like! Feel free to clean it up! |
|---|
| 4416 | 4450 | */ |
|---|
| 4417 | 4451 | |
|---|
| 4418 | | -static ssize_t proc_read( struct file *file, |
|---|
| 4452 | +static ssize_t proc_read(struct file *file, |
|---|
| 4419 | 4453 | char __user *buffer, |
|---|
| 4420 | 4454 | size_t len, |
|---|
| 4421 | 4455 | loff_t *offset); |
|---|
| 4422 | 4456 | |
|---|
| 4423 | | -static ssize_t proc_write( struct file *file, |
|---|
| 4457 | +static ssize_t proc_write(struct file *file, |
|---|
| 4424 | 4458 | const char __user *buffer, |
|---|
| 4425 | 4459 | 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); |
|---|
| 4428 | 4462 | |
|---|
| 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); |
|---|
| 4437 | 4471 | |
|---|
| 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, |
|---|
| 4444 | 4477 | }; |
|---|
| 4445 | 4478 | |
|---|
| 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, |
|---|
| 4452 | 4484 | }; |
|---|
| 4453 | 4485 | |
|---|
| 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, |
|---|
| 4460 | 4491 | }; |
|---|
| 4461 | 4492 | |
|---|
| 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, |
|---|
| 4469 | 4499 | }; |
|---|
| 4470 | 4500 | |
|---|
| 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, |
|---|
| 4478 | 4507 | }; |
|---|
| 4479 | 4508 | |
|---|
| 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, |
|---|
| 4487 | 4515 | }; |
|---|
| 4488 | 4516 | |
|---|
| 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, |
|---|
| 4496 | 4523 | }; |
|---|
| 4497 | 4524 | |
|---|
| 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, |
|---|
| 4505 | 4531 | }; |
|---|
| 4506 | 4532 | |
|---|
| 4507 | 4533 | static struct proc_dir_entry *airo_entry; |
|---|
| .. | .. |
|---|
| 4516 | 4542 | void (*on_close) (struct inode *, struct file *); |
|---|
| 4517 | 4543 | }; |
|---|
| 4518 | 4544 | |
|---|
| 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 | +{ |
|---|
| 4521 | 4548 | struct proc_dir_entry *entry; |
|---|
| 4522 | 4549 | |
|---|
| 4523 | 4550 | /* First setup the device directory */ |
|---|
| 4524 | | - strcpy(apriv->proc_name,dev->name); |
|---|
| 4551 | + strcpy(apriv->proc_name, dev->name); |
|---|
| 4525 | 4552 | apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm, |
|---|
| 4526 | 4553 | airo_entry); |
|---|
| 4527 | 4554 | if (!apriv->proc_entry) |
|---|
| .. | .. |
|---|
| 4590 | 4617 | return -ENOMEM; |
|---|
| 4591 | 4618 | } |
|---|
| 4592 | 4619 | |
|---|
| 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) |
|---|
| 4595 | 4622 | { |
|---|
| 4596 | 4623 | remove_proc_subtree(apriv->proc_name, airo_entry); |
|---|
| 4597 | 4624 | return 0; |
|---|
| .. | .. |
|---|
| 4609 | 4636 | * The read routine is generic, it relies on the preallocated rbuffer |
|---|
| 4610 | 4637 | * to supply the data. |
|---|
| 4611 | 4638 | */ |
|---|
| 4612 | | -static ssize_t proc_read( struct file *file, |
|---|
| 4639 | +static ssize_t proc_read(struct file *file, |
|---|
| 4613 | 4640 | char __user *buffer, |
|---|
| 4614 | 4641 | size_t len, |
|---|
| 4615 | | - loff_t *offset ) |
|---|
| 4642 | + loff_t *offset) |
|---|
| 4616 | 4643 | { |
|---|
| 4617 | 4644 | struct proc_data *priv = file->private_data; |
|---|
| 4618 | 4645 | |
|---|
| .. | .. |
|---|
| 4627 | 4654 | * The write routine is generic, it fills in a preallocated rbuffer |
|---|
| 4628 | 4655 | * to supply the data. |
|---|
| 4629 | 4656 | */ |
|---|
| 4630 | | -static ssize_t proc_write( struct file *file, |
|---|
| 4657 | +static ssize_t proc_write(struct file *file, |
|---|
| 4631 | 4658 | const char __user *buffer, |
|---|
| 4632 | 4659 | size_t len, |
|---|
| 4633 | | - loff_t *offset ) |
|---|
| 4660 | + loff_t *offset) |
|---|
| 4634 | 4661 | { |
|---|
| 4635 | 4662 | ssize_t ret; |
|---|
| 4636 | 4663 | struct proc_data *priv = file->private_data; |
|---|
| .. | .. |
|---|
| 4656 | 4683 | u16 mode; |
|---|
| 4657 | 4684 | int i; |
|---|
| 4658 | 4685 | |
|---|
| 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) |
|---|
| 4660 | 4687 | return -ENOMEM; |
|---|
| 4661 | 4688 | data = file->private_data; |
|---|
| 4662 | | - if ((data->rbuffer = kmalloc( 2048, GFP_KERNEL )) == NULL) { |
|---|
| 4689 | + if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) { |
|---|
| 4663 | 4690 | kfree (file->private_data); |
|---|
| 4664 | 4691 | return -ENOMEM; |
|---|
| 4665 | 4692 | } |
|---|
| .. | .. |
|---|
| 4679 | 4706 | mode & 0x100 ? "KEY ": "", |
|---|
| 4680 | 4707 | mode & 0x200 ? "WEP ": "", |
|---|
| 4681 | 4708 | mode & 0x8000 ? "ERR ": ""); |
|---|
| 4682 | | - sprintf( data->rbuffer+i, "Mode: %x\n" |
|---|
| 4709 | + sprintf(data->rbuffer+i, "Mode: %x\n" |
|---|
| 4683 | 4710 | "Signal Strength: %d\n" |
|---|
| 4684 | 4711 | "Signal Quality: %d\n" |
|---|
| 4685 | 4712 | "SSID: %-.*s\n" |
|---|
| .. | .. |
|---|
| 4709 | 4736 | le16_to_cpu(cap_rid.softVer), |
|---|
| 4710 | 4737 | le16_to_cpu(cap_rid.softSubVer), |
|---|
| 4711 | 4738 | le16_to_cpu(cap_rid.bootBlockVer)); |
|---|
| 4712 | | - data->readlen = strlen( data->rbuffer ); |
|---|
| 4739 | + data->readlen = strlen(data->rbuffer); |
|---|
| 4713 | 4740 | return 0; |
|---|
| 4714 | 4741 | } |
|---|
| 4715 | 4742 | |
|---|
| 4716 | 4743 | 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 | +{ |
|---|
| 4719 | 4747 | if (file->f_mode&FMODE_WRITE) { |
|---|
| 4720 | 4748 | return proc_stats_rid_open(inode, file, RID_STATSDELTACLEAR); |
|---|
| 4721 | 4749 | } |
|---|
| 4722 | 4750 | return proc_stats_rid_open(inode, file, RID_STATSDELTA); |
|---|
| 4723 | 4751 | } |
|---|
| 4724 | 4752 | |
|---|
| 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 | +{ |
|---|
| 4726 | 4755 | return proc_stats_rid_open(inode, file, RID_STATS); |
|---|
| 4727 | 4756 | } |
|---|
| 4728 | 4757 | |
|---|
| 4729 | | -static int proc_stats_rid_open( struct inode *inode, |
|---|
| 4758 | +static int proc_stats_rid_open(struct inode *inode, |
|---|
| 4730 | 4759 | struct file *file, |
|---|
| 4731 | | - u16 rid ) |
|---|
| 4760 | + u16 rid) |
|---|
| 4732 | 4761 | { |
|---|
| 4733 | 4762 | struct proc_data *data; |
|---|
| 4734 | 4763 | struct net_device *dev = PDE_DATA(inode); |
|---|
| .. | .. |
|---|
| 4738 | 4767 | __le32 *vals = stats.vals; |
|---|
| 4739 | 4768 | int len; |
|---|
| 4740 | 4769 | |
|---|
| 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) |
|---|
| 4742 | 4771 | return -ENOMEM; |
|---|
| 4743 | 4772 | data = file->private_data; |
|---|
| 4744 | | - if ((data->rbuffer = kmalloc( 4096, GFP_KERNEL )) == NULL) { |
|---|
| 4773 | + if ((data->rbuffer = kmalloc(4096, GFP_KERNEL)) == NULL) { |
|---|
| 4745 | 4774 | kfree (file->private_data); |
|---|
| 4746 | 4775 | return -ENOMEM; |
|---|
| 4747 | 4776 | } |
|---|
| .. | .. |
|---|
| 4750 | 4779 | len = le16_to_cpu(stats.len); |
|---|
| 4751 | 4780 | |
|---|
| 4752 | 4781 | 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++) { |
|---|
| 4754 | 4783 | if (!statsLabels[i]) continue; |
|---|
| 4755 | 4784 | if (j+strlen(statsLabels[i])+16>4096) { |
|---|
| 4756 | 4785 | airo_print_warn(apriv->dev->name, |
|---|
| .. | .. |
|---|
| 4767 | 4796 | return 0; |
|---|
| 4768 | 4797 | } |
|---|
| 4769 | 4798 | |
|---|
| 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 | +{ |
|---|
| 4771 | 4801 | u16 value; |
|---|
| 4772 | 4802 | int valid = 0; |
|---|
| 4773 | 4803 | for (value = 0; *start < limit && buffer[*start] >= '0' && |
|---|
| .. | .. |
|---|
| 4776 | 4806 | value *= 10; |
|---|
| 4777 | 4807 | value += buffer[*start] - '0'; |
|---|
| 4778 | 4808 | } |
|---|
| 4779 | | - if ( !valid ) return -1; |
|---|
| 4809 | + if (!valid) return -1; |
|---|
| 4780 | 4810 | return value; |
|---|
| 4781 | 4811 | } |
|---|
| 4782 | 4812 | |
|---|
| .. | .. |
|---|
| 4797 | 4827 | struct airo_info *ai = dev->ml_priv; |
|---|
| 4798 | 4828 | char *line; |
|---|
| 4799 | 4829 | |
|---|
| 4800 | | - if ( !data->writelen ) return; |
|---|
| 4830 | + if (!data->writelen) return; |
|---|
| 4801 | 4831 | |
|---|
| 4802 | 4832 | readConfigRid(ai, 1); |
|---|
| 4803 | 4833 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4804 | 4834 | |
|---|
| 4805 | 4835 | line = data->wbuffer; |
|---|
| 4806 | | - while( line[0] ) { |
|---|
| 4836 | + while (line[0]) { |
|---|
| 4807 | 4837 | /*** Mode processing */ |
|---|
| 4808 | | - if ( !strncmp( line, "Mode: ", 6 ) ) { |
|---|
| 4838 | + if (!strncmp(line, "Mode: ", 6)) { |
|---|
| 4809 | 4839 | line += 6; |
|---|
| 4810 | 4840 | if (sniffing_mode(ai)) |
|---|
| 4811 | 4841 | set_bit (FLAG_RESET, &ai->flags); |
|---|
| .. | .. |
|---|
| 4813 | 4843 | clear_bit (FLAG_802_11, &ai->flags); |
|---|
| 4814 | 4844 | ai->config.opmode &= ~MODE_CFG_MASK; |
|---|
| 4815 | 4845 | ai->config.scanMode = SCANMODE_ACTIVE; |
|---|
| 4816 | | - if ( line[0] == 'a' ) { |
|---|
| 4846 | + if (line[0] == 'a') { |
|---|
| 4817 | 4847 | ai->config.opmode |= MODE_STA_IBSS; |
|---|
| 4818 | 4848 | } else { |
|---|
| 4819 | 4849 | ai->config.opmode |= MODE_STA_ESS; |
|---|
| 4820 | | - if ( line[0] == 'r' ) { |
|---|
| 4850 | + if (line[0] == 'r') { |
|---|
| 4821 | 4851 | ai->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER; |
|---|
| 4822 | 4852 | ai->config.scanMode = SCANMODE_PASSIVE; |
|---|
| 4823 | 4853 | set_bit (FLAG_802_11, &ai->flags); |
|---|
| 4824 | | - } else if ( line[0] == 'y' ) { |
|---|
| 4854 | + } else if (line[0] == 'y') { |
|---|
| 4825 | 4855 | ai->config.rmode |= RXMODE_RFMON_ANYBSS | RXMODE_DISABLE_802_3_HEADER; |
|---|
| 4826 | 4856 | ai->config.scanMode = SCANMODE_PASSIVE; |
|---|
| 4827 | 4857 | set_bit (FLAG_802_11, &ai->flags); |
|---|
| 4828 | | - } else if ( line[0] == 'l' ) |
|---|
| 4858 | + } else if (line[0] == 'l') |
|---|
| 4829 | 4859 | ai->config.rmode |= RXMODE_LANMON; |
|---|
| 4830 | 4860 | } |
|---|
| 4831 | 4861 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| .. | .. |
|---|
| 4834 | 4864 | /*** Radio status */ |
|---|
| 4835 | 4865 | else if (!strncmp(line,"Radio: ", 7)) { |
|---|
| 4836 | 4866 | line += 7; |
|---|
| 4837 | | - if (!strncmp(line,"off",3)) { |
|---|
| 4867 | + if (!strncmp(line,"off", 3)) { |
|---|
| 4838 | 4868 | set_bit (FLAG_RADIO_OFF, &ai->flags); |
|---|
| 4839 | 4869 | } else { |
|---|
| 4840 | 4870 | clear_bit (FLAG_RADIO_OFF, &ai->flags); |
|---|
| 4841 | 4871 | } |
|---|
| 4842 | 4872 | } |
|---|
| 4843 | 4873 | /*** NodeName processing */ |
|---|
| 4844 | | - else if ( !strncmp( line, "NodeName: ", 10 ) ) { |
|---|
| 4874 | + else if (!strncmp(line, "NodeName: ", 10)) { |
|---|
| 4845 | 4875 | int j; |
|---|
| 4846 | 4876 | |
|---|
| 4847 | 4877 | line += 10; |
|---|
| 4848 | | - memset( ai->config.nodeName, 0, 16 ); |
|---|
| 4878 | + memset(ai->config.nodeName, 0, 16); |
|---|
| 4849 | 4879 | /* 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++) { |
|---|
| 4851 | 4881 | ai->config.nodeName[j] = line[j]; |
|---|
| 4852 | 4882 | } |
|---|
| 4853 | 4883 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4854 | 4884 | } |
|---|
| 4855 | 4885 | |
|---|
| 4856 | 4886 | /*** PowerMode processing */ |
|---|
| 4857 | | - else if ( !strncmp( line, "PowerMode: ", 11 ) ) { |
|---|
| 4887 | + else if (!strncmp(line, "PowerMode: ", 11)) { |
|---|
| 4858 | 4888 | line += 11; |
|---|
| 4859 | | - if ( !strncmp( line, "PSPCAM", 6 ) ) { |
|---|
| 4889 | + if (!strncmp(line, "PSPCAM", 6)) { |
|---|
| 4860 | 4890 | ai->config.powerSaveMode = POWERSAVE_PSPCAM; |
|---|
| 4861 | 4891 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4862 | | - } else if ( !strncmp( line, "PSP", 3 ) ) { |
|---|
| 4892 | + } else if (!strncmp(line, "PSP", 3)) { |
|---|
| 4863 | 4893 | ai->config.powerSaveMode = POWERSAVE_PSP; |
|---|
| 4864 | 4894 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4865 | 4895 | } else { |
|---|
| 4866 | 4896 | ai->config.powerSaveMode = POWERSAVE_CAM; |
|---|
| 4867 | 4897 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4868 | 4898 | } |
|---|
| 4869 | | - } else if ( !strncmp( line, "DataRates: ", 11 ) ) { |
|---|
| 4899 | + } else if (!strncmp(line, "DataRates: ", 11)) { |
|---|
| 4870 | 4900 | int v, i = 0, k = 0; /* i is index into line, |
|---|
| 4871 | 4901 | k is index to rates */ |
|---|
| 4872 | 4902 | |
|---|
| 4873 | 4903 | line += 11; |
|---|
| 4874 | | - while((v = get_dec_u16(line, &i, 3))!=-1) { |
|---|
| 4904 | + while ((v = get_dec_u16(line, &i, 3))!=-1) { |
|---|
| 4875 | 4905 | ai->config.rates[k++] = (u8)v; |
|---|
| 4876 | 4906 | line += i + 1; |
|---|
| 4877 | 4907 | i = 0; |
|---|
| 4878 | 4908 | } |
|---|
| 4879 | 4909 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4880 | | - } else if ( !strncmp( line, "Channel: ", 9 ) ) { |
|---|
| 4910 | + } else if (!strncmp(line, "Channel: ", 9)) { |
|---|
| 4881 | 4911 | int v, i = 0; |
|---|
| 4882 | 4912 | line += 9; |
|---|
| 4883 | 4913 | v = get_dec_u16(line, &i, i+3); |
|---|
| 4884 | | - if ( v != -1 ) { |
|---|
| 4914 | + if (v != -1) { |
|---|
| 4885 | 4915 | ai->config.channelSet = cpu_to_le16(v); |
|---|
| 4886 | 4916 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4887 | 4917 | } |
|---|
| 4888 | | - } else if ( !strncmp( line, "XmitPower: ", 11 ) ) { |
|---|
| 4918 | + } else if (!strncmp(line, "XmitPower: ", 11)) { |
|---|
| 4889 | 4919 | int v, i = 0; |
|---|
| 4890 | 4920 | line += 11; |
|---|
| 4891 | 4921 | v = get_dec_u16(line, &i, i+3); |
|---|
| 4892 | | - if ( v != -1 ) { |
|---|
| 4922 | + if (v != -1) { |
|---|
| 4893 | 4923 | ai->config.txPower = cpu_to_le16(v); |
|---|
| 4894 | 4924 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4895 | 4925 | } |
|---|
| 4896 | | - } else if ( !strncmp( line, "WEP: ", 5 ) ) { |
|---|
| 4926 | + } else if (!strncmp(line, "WEP: ", 5)) { |
|---|
| 4897 | 4927 | line += 5; |
|---|
| 4898 | | - switch( line[0] ) { |
|---|
| 4928 | + switch(line[0]) { |
|---|
| 4899 | 4929 | case 's': |
|---|
| 4900 | 4930 | set_auth_type(ai, AUTH_SHAREDKEY); |
|---|
| 4901 | 4931 | break; |
|---|
| .. | .. |
|---|
| 4907 | 4937 | break; |
|---|
| 4908 | 4938 | } |
|---|
| 4909 | 4939 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4910 | | - } else if ( !strncmp( line, "LongRetryLimit: ", 16 ) ) { |
|---|
| 4940 | + } else if (!strncmp(line, "LongRetryLimit: ", 16)) { |
|---|
| 4911 | 4941 | int v, i = 0; |
|---|
| 4912 | 4942 | |
|---|
| 4913 | 4943 | line += 16; |
|---|
| .. | .. |
|---|
| 4915 | 4945 | v = (v<0) ? 0 : ((v>255) ? 255 : v); |
|---|
| 4916 | 4946 | ai->config.longRetryLimit = cpu_to_le16(v); |
|---|
| 4917 | 4947 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4918 | | - } else if ( !strncmp( line, "ShortRetryLimit: ", 17 ) ) { |
|---|
| 4948 | + } else if (!strncmp(line, "ShortRetryLimit: ", 17)) { |
|---|
| 4919 | 4949 | int v, i = 0; |
|---|
| 4920 | 4950 | |
|---|
| 4921 | 4951 | line += 17; |
|---|
| .. | .. |
|---|
| 4923 | 4953 | v = (v<0) ? 0 : ((v>255) ? 255 : v); |
|---|
| 4924 | 4954 | ai->config.shortRetryLimit = cpu_to_le16(v); |
|---|
| 4925 | 4955 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4926 | | - } else if ( !strncmp( line, "RTSThreshold: ", 14 ) ) { |
|---|
| 4956 | + } else if (!strncmp(line, "RTSThreshold: ", 14)) { |
|---|
| 4927 | 4957 | int v, i = 0; |
|---|
| 4928 | 4958 | |
|---|
| 4929 | 4959 | line += 14; |
|---|
| .. | .. |
|---|
| 4931 | 4961 | v = (v<0) ? 0 : ((v>AIRO_DEF_MTU) ? AIRO_DEF_MTU : v); |
|---|
| 4932 | 4962 | ai->config.rtsThres = cpu_to_le16(v); |
|---|
| 4933 | 4963 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4934 | | - } else if ( !strncmp( line, "TXMSDULifetime: ", 16 ) ) { |
|---|
| 4964 | + } else if (!strncmp(line, "TXMSDULifetime: ", 16)) { |
|---|
| 4935 | 4965 | int v, i = 0; |
|---|
| 4936 | 4966 | |
|---|
| 4937 | 4967 | line += 16; |
|---|
| .. | .. |
|---|
| 4939 | 4969 | v = (v<0) ? 0 : v; |
|---|
| 4940 | 4970 | ai->config.txLifetime = cpu_to_le16(v); |
|---|
| 4941 | 4971 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4942 | | - } else if ( !strncmp( line, "RXMSDULifetime: ", 16 ) ) { |
|---|
| 4972 | + } else if (!strncmp(line, "RXMSDULifetime: ", 16)) { |
|---|
| 4943 | 4973 | int v, i = 0; |
|---|
| 4944 | 4974 | |
|---|
| 4945 | 4975 | line += 16; |
|---|
| .. | .. |
|---|
| 4947 | 4977 | v = (v<0) ? 0 : v; |
|---|
| 4948 | 4978 | ai->config.rxLifetime = cpu_to_le16(v); |
|---|
| 4949 | 4979 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4950 | | - } else if ( !strncmp( line, "TXDiversity: ", 13 ) ) { |
|---|
| 4980 | + } else if (!strncmp(line, "TXDiversity: ", 13)) { |
|---|
| 4951 | 4981 | ai->config.txDiversity = |
|---|
| 4952 | 4982 | (line[13]=='l') ? 1 : |
|---|
| 4953 | 4983 | ((line[13]=='r')? 2: 3); |
|---|
| 4954 | 4984 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4955 | | - } else if ( !strncmp( line, "RXDiversity: ", 13 ) ) { |
|---|
| 4985 | + } else if (!strncmp(line, "RXDiversity: ", 13)) { |
|---|
| 4956 | 4986 | ai->config.rxDiversity = |
|---|
| 4957 | 4987 | (line[13]=='l') ? 1 : |
|---|
| 4958 | 4988 | ((line[13]=='r')? 2: 3); |
|---|
| 4959 | 4989 | set_bit (FLAG_COMMIT, &ai->flags); |
|---|
| 4960 | | - } else if ( !strncmp( line, "FragThreshold: ", 15 ) ) { |
|---|
| 4990 | + } else if (!strncmp(line, "FragThreshold: ", 15)) { |
|---|
| 4961 | 4991 | int v, i = 0; |
|---|
| 4962 | 4992 | |
|---|
| 4963 | 4993 | line += 15; |
|---|
| .. | .. |
|---|
| 4969 | 4999 | } else if (!strncmp(line, "Modulation: ", 12)) { |
|---|
| 4970 | 5000 | line += 12; |
|---|
| 4971 | 5001 | 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; |
|---|
| 4975 | 5005 | default: airo_print_warn(ai->dev->name, "Unknown modulation"); |
|---|
| 4976 | 5006 | } |
|---|
| 4977 | 5007 | } else if (!strncmp(line, "Preamble: ", 10)) { |
|---|
| 4978 | 5008 | line += 10; |
|---|
| 4979 | 5009 | 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; |
|---|
| 4983 | 5013 | default: airo_print_warn(ai->dev->name, "Unknown preamble"); |
|---|
| 4984 | 5014 | } |
|---|
| 4985 | 5015 | } else { |
|---|
| 4986 | 5016 | airo_print_warn(ai->dev->name, "Couldn't figure out %s", line); |
|---|
| 4987 | 5017 | } |
|---|
| 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++; |
|---|
| 4990 | 5020 | } |
|---|
| 4991 | 5021 | airo_config_commit(dev, NULL, NULL, NULL); |
|---|
| 4992 | 5022 | } |
|---|
| .. | .. |
|---|
| 5009 | 5039 | int i; |
|---|
| 5010 | 5040 | __le16 mode; |
|---|
| 5011 | 5041 | |
|---|
| 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) |
|---|
| 5013 | 5043 | return -ENOMEM; |
|---|
| 5014 | 5044 | data = file->private_data; |
|---|
| 5015 | | - if ((data->rbuffer = kmalloc( 2048, GFP_KERNEL )) == NULL) { |
|---|
| 5045 | + if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) { |
|---|
| 5016 | 5046 | kfree (file->private_data); |
|---|
| 5017 | 5047 | return -ENOMEM; |
|---|
| 5018 | 5048 | } |
|---|
| 5019 | | - if ((data->wbuffer = kzalloc( 2048, GFP_KERNEL )) == NULL) { |
|---|
| 5049 | + if ((data->wbuffer = kzalloc(2048, GFP_KERNEL)) == NULL) { |
|---|
| 5020 | 5050 | kfree (data->rbuffer); |
|---|
| 5021 | 5051 | kfree (file->private_data); |
|---|
| 5022 | 5052 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 5027 | 5057 | readConfigRid(ai, 1); |
|---|
| 5028 | 5058 | |
|---|
| 5029 | 5059 | mode = ai->config.opmode & MODE_CFG_MASK; |
|---|
| 5030 | | - i = sprintf( data->rbuffer, |
|---|
| 5060 | + i = sprintf(data->rbuffer, |
|---|
| 5031 | 5061 | "Mode: %s\n" |
|---|
| 5032 | 5062 | "Radio: %s\n" |
|---|
| 5033 | 5063 | "NodeName: %-16s\n" |
|---|
| .. | .. |
|---|
| 5056 | 5086 | le16_to_cpu(ai->config.channelSet), |
|---|
| 5057 | 5087 | le16_to_cpu(ai->config.txPower) |
|---|
| 5058 | 5088 | ); |
|---|
| 5059 | | - sprintf( data->rbuffer + i, |
|---|
| 5089 | + sprintf(data->rbuffer + i, |
|---|
| 5060 | 5090 | "LongRetryLimit: %d\n" |
|---|
| 5061 | 5091 | "ShortRetryLimit: %d\n" |
|---|
| 5062 | 5092 | "RTSThreshold: %d\n" |
|---|
| .. | .. |
|---|
| 5087 | 5117 | ai->config.preamble == PREAMBLE_LONG ? "long" : |
|---|
| 5088 | 5118 | ai->config.preamble == PREAMBLE_SHORT ? "short" : "error" |
|---|
| 5089 | 5119 | ); |
|---|
| 5090 | | - data->readlen = strlen( data->rbuffer ); |
|---|
| 5120 | + data->readlen = strlen(data->rbuffer); |
|---|
| 5091 | 5121 | return 0; |
|---|
| 5092 | 5122 | } |
|---|
| 5093 | 5123 | |
|---|
| .. | .. |
|---|
| 5127 | 5157 | enable_MAC(ai, 1); |
|---|
| 5128 | 5158 | } |
|---|
| 5129 | 5159 | |
|---|
| 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 | +{ |
|---|
| 5131 | 5162 | struct proc_data *data = file->private_data; |
|---|
| 5132 | 5163 | struct net_device *dev = PDE_DATA(inode); |
|---|
| 5133 | 5164 | struct airo_info *ai = dev->ml_priv; |
|---|
| 5134 | 5165 | APListRid *APList_rid = &ai->APList; |
|---|
| 5135 | 5166 | int i; |
|---|
| 5136 | 5167 | |
|---|
| 5137 | | - if ( !data->writelen ) return; |
|---|
| 5168 | + if (!data->writelen) return; |
|---|
| 5138 | 5169 | |
|---|
| 5139 | 5170 | memset(APList_rid, 0, sizeof(*APList_rid)); |
|---|
| 5140 | 5171 | APList_rid->len = cpu_to_le16(sizeof(*APList_rid)); |
|---|
| .. | .. |
|---|
| 5148 | 5179 | } |
|---|
| 5149 | 5180 | |
|---|
| 5150 | 5181 | /* 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 | +{ |
|---|
| 5153 | 5185 | int rc; |
|---|
| 5154 | 5186 | |
|---|
| 5155 | 5187 | disable_MAC(ai, 1); |
|---|
| .. | .. |
|---|
| 5204 | 5236 | return -1; |
|---|
| 5205 | 5237 | } |
|---|
| 5206 | 5238 | |
|---|
| 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, |
|---|
| 5208 | 5240 | u16 keylen, int perm, int lock) |
|---|
| 5209 | 5241 | { |
|---|
| 5210 | 5242 | static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; |
|---|
| .. | .. |
|---|
| 5249 | 5281 | return rc; |
|---|
| 5250 | 5282 | } |
|---|
| 5251 | 5283 | |
|---|
| 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 | +{ |
|---|
| 5253 | 5286 | struct proc_data *data; |
|---|
| 5254 | 5287 | struct net_device *dev = PDE_DATA(inode); |
|---|
| 5255 | 5288 | struct airo_info *ai = dev->ml_priv; |
|---|
| 5256 | 5289 | int i, rc; |
|---|
| 5257 | | - char key[16]; |
|---|
| 5290 | + u8 key[16]; |
|---|
| 5258 | 5291 | u16 index = 0; |
|---|
| 5259 | 5292 | int j = 0; |
|---|
| 5260 | 5293 | |
|---|
| 5261 | 5294 | memset(key, 0, sizeof(key)); |
|---|
| 5262 | 5295 | |
|---|
| 5263 | 5296 | data = file->private_data; |
|---|
| 5264 | | - if ( !data->writelen ) return; |
|---|
| 5297 | + if (!data->writelen) return; |
|---|
| 5265 | 5298 | |
|---|
| 5266 | 5299 | if (data->wbuffer[0] >= '0' && data->wbuffer[0] <= '3' && |
|---|
| 5267 | 5300 | (data->wbuffer[1] == ' ' || data->wbuffer[1] == '\n')) { |
|---|
| .. | .. |
|---|
| 5281 | 5314 | return; |
|---|
| 5282 | 5315 | } |
|---|
| 5283 | 5316 | |
|---|
| 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 | + } |
|---|
| 5285 | 5328 | switch(i%3) { |
|---|
| 5286 | 5329 | case 0: |
|---|
| 5287 | | - key[i/3] = hex_to_bin(data->wbuffer[i+j])<<4; |
|---|
| 5330 | + key[i/3] = (u8)val << 4; |
|---|
| 5288 | 5331 | break; |
|---|
| 5289 | 5332 | case 1: |
|---|
| 5290 | | - key[i/3] |= hex_to_bin(data->wbuffer[i+j]); |
|---|
| 5333 | + key[i/3] |= (u8)val; |
|---|
| 5291 | 5334 | break; |
|---|
| 5292 | 5335 | } |
|---|
| 5293 | 5336 | } |
|---|
| .. | .. |
|---|
| 5299 | 5342 | } |
|---|
| 5300 | 5343 | } |
|---|
| 5301 | 5344 | |
|---|
| 5302 | | -static int proc_wepkey_open( struct inode *inode, struct file *file ) |
|---|
| 5345 | +static int proc_wepkey_open(struct inode *inode, struct file *file) |
|---|
| 5303 | 5346 | { |
|---|
| 5304 | 5347 | struct proc_data *data; |
|---|
| 5305 | 5348 | struct net_device *dev = PDE_DATA(inode); |
|---|
| .. | .. |
|---|
| 5307 | 5350 | char *ptr; |
|---|
| 5308 | 5351 | WepKeyRid wkr; |
|---|
| 5309 | 5352 | __le16 lastindex; |
|---|
| 5310 | | - int j=0; |
|---|
| 5353 | + int j = 0; |
|---|
| 5311 | 5354 | int rc; |
|---|
| 5312 | 5355 | |
|---|
| 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) |
|---|
| 5314 | 5357 | return -ENOMEM; |
|---|
| 5315 | 5358 | memset(&wkr, 0, sizeof(wkr)); |
|---|
| 5316 | 5359 | data = file->private_data; |
|---|
| 5317 | | - if ((data->rbuffer = kzalloc( 180, GFP_KERNEL )) == NULL) { |
|---|
| 5360 | + if ((data->rbuffer = kzalloc(180, GFP_KERNEL)) == NULL) { |
|---|
| 5318 | 5361 | kfree (file->private_data); |
|---|
| 5319 | 5362 | return -ENOMEM; |
|---|
| 5320 | 5363 | } |
|---|
| 5321 | 5364 | data->writelen = 0; |
|---|
| 5322 | 5365 | data->maxwritelen = 80; |
|---|
| 5323 | | - if ((data->wbuffer = kzalloc( 80, GFP_KERNEL )) == NULL) { |
|---|
| 5366 | + if ((data->wbuffer = kzalloc(80, GFP_KERNEL)) == NULL) { |
|---|
| 5324 | 5367 | kfree (data->rbuffer); |
|---|
| 5325 | 5368 | kfree (file->private_data); |
|---|
| 5326 | 5369 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 5341 | 5384 | le16_to_cpu(wkr.klen)); |
|---|
| 5342 | 5385 | } |
|---|
| 5343 | 5386 | readWepKeyRid(ai, &wkr, 0, 1); |
|---|
| 5344 | | - } while((lastindex != wkr.kindex) && (j < 180-30)); |
|---|
| 5387 | + } while ((lastindex != wkr.kindex) && (j < 180-30)); |
|---|
| 5345 | 5388 | |
|---|
| 5346 | | - data->readlen = strlen( data->rbuffer ); |
|---|
| 5389 | + data->readlen = strlen(data->rbuffer); |
|---|
| 5347 | 5390 | return 0; |
|---|
| 5348 | 5391 | } |
|---|
| 5349 | 5392 | |
|---|
| .. | .. |
|---|
| 5356 | 5399 | char *ptr; |
|---|
| 5357 | 5400 | SsidRid SSID_rid; |
|---|
| 5358 | 5401 | |
|---|
| 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) |
|---|
| 5360 | 5403 | return -ENOMEM; |
|---|
| 5361 | 5404 | data = file->private_data; |
|---|
| 5362 | | - if ((data->rbuffer = kmalloc( 104, GFP_KERNEL )) == NULL) { |
|---|
| 5405 | + if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) { |
|---|
| 5363 | 5406 | kfree (file->private_data); |
|---|
| 5364 | 5407 | return -ENOMEM; |
|---|
| 5365 | 5408 | } |
|---|
| .. | .. |
|---|
| 5387 | 5430 | *ptr++ = '\n'; |
|---|
| 5388 | 5431 | } |
|---|
| 5389 | 5432 | *ptr = '\0'; |
|---|
| 5390 | | - data->readlen = strlen( data->rbuffer ); |
|---|
| 5433 | + data->readlen = strlen(data->rbuffer); |
|---|
| 5391 | 5434 | return 0; |
|---|
| 5392 | 5435 | } |
|---|
| 5393 | 5436 | |
|---|
| 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 | +{ |
|---|
| 5395 | 5439 | struct proc_data *data; |
|---|
| 5396 | 5440 | struct net_device *dev = PDE_DATA(inode); |
|---|
| 5397 | 5441 | struct airo_info *ai = dev->ml_priv; |
|---|
| .. | .. |
|---|
| 5399 | 5443 | char *ptr; |
|---|
| 5400 | 5444 | APListRid *APList_rid = &ai->APList; |
|---|
| 5401 | 5445 | |
|---|
| 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) |
|---|
| 5403 | 5447 | return -ENOMEM; |
|---|
| 5404 | 5448 | data = file->private_data; |
|---|
| 5405 | | - if ((data->rbuffer = kmalloc( 104, GFP_KERNEL )) == NULL) { |
|---|
| 5449 | + if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) { |
|---|
| 5406 | 5450 | kfree (file->private_data); |
|---|
| 5407 | 5451 | return -ENOMEM; |
|---|
| 5408 | 5452 | } |
|---|
| 5409 | 5453 | data->writelen = 0; |
|---|
| 5410 | 5454 | 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) { |
|---|
| 5412 | 5456 | kfree (data->rbuffer); |
|---|
| 5413 | 5457 | kfree (file->private_data); |
|---|
| 5414 | 5458 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 5416 | 5460 | data->on_close = proc_APList_on_close; |
|---|
| 5417 | 5461 | |
|---|
| 5418 | 5462 | ptr = data->rbuffer; |
|---|
| 5419 | | - for( i = 0; i < 4; i++ ) { |
|---|
| 5463 | + for (i = 0; i < 4; i++) { |
|---|
| 5420 | 5464 | // We end when we find a zero MAC |
|---|
| 5421 | | - if ( !*(int*)APList_rid->ap[i] && |
|---|
| 5465 | + if (!*(int*)APList_rid->ap[i] && |
|---|
| 5422 | 5466 | !*(int*)&APList_rid->ap[i][2]) break; |
|---|
| 5423 | 5467 | ptr += sprintf(ptr, "%pM\n", APList_rid->ap[i]); |
|---|
| 5424 | 5468 | } |
|---|
| 5425 | 5469 | if (i==0) ptr += sprintf(ptr, "Not using specific APs\n"); |
|---|
| 5426 | 5470 | |
|---|
| 5427 | 5471 | *ptr = '\0'; |
|---|
| 5428 | | - data->readlen = strlen( data->rbuffer ); |
|---|
| 5472 | + data->readlen = strlen(data->rbuffer); |
|---|
| 5429 | 5473 | return 0; |
|---|
| 5430 | 5474 | } |
|---|
| 5431 | 5475 | |
|---|
| 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 | +{ |
|---|
| 5433 | 5478 | struct proc_data *data; |
|---|
| 5434 | 5479 | struct net_device *dev = PDE_DATA(inode); |
|---|
| 5435 | 5480 | struct airo_info *ai = dev->ml_priv; |
|---|
| .. | .. |
|---|
| 5439 | 5484 | /* If doLoseSync is not 1, we won't do a Lose Sync */ |
|---|
| 5440 | 5485 | int doLoseSync = -1; |
|---|
| 5441 | 5486 | |
|---|
| 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) |
|---|
| 5443 | 5488 | return -ENOMEM; |
|---|
| 5444 | 5489 | data = file->private_data; |
|---|
| 5445 | | - if ((data->rbuffer = kmalloc( 1024, GFP_KERNEL )) == NULL) { |
|---|
| 5490 | + if ((data->rbuffer = kmalloc(1024, GFP_KERNEL)) == NULL) { |
|---|
| 5446 | 5491 | kfree (file->private_data); |
|---|
| 5447 | 5492 | return -ENOMEM; |
|---|
| 5448 | 5493 | } |
|---|
| .. | .. |
|---|
| 5456 | 5501 | Cmd cmd; |
|---|
| 5457 | 5502 | Resp rsp; |
|---|
| 5458 | 5503 | |
|---|
| 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 | + } |
|---|
| 5460 | 5509 | 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); |
|---|
| 5463 | 5514 | return -ERESTARTSYS; |
|---|
| 5515 | + } |
|---|
| 5464 | 5516 | issuecommand(ai, &cmd, &rsp); |
|---|
| 5465 | 5517 | up(&ai->sem); |
|---|
| 5466 | 5518 | data->readlen = 0; |
|---|
| .. | .. |
|---|
| 5473 | 5525 | Since it is a rare condition, we'll just live with it, otherwise |
|---|
| 5474 | 5526 | we have to add a spin lock... */ |
|---|
| 5475 | 5527 | 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)) { |
|---|
| 5477 | 5529 | ptr += sprintf(ptr, "%pM %.*s rssi = %d", |
|---|
| 5478 | 5530 | BSSList_rid.bssid, |
|---|
| 5479 | 5531 | (int)BSSList_rid.ssidLen, |
|---|
| .. | .. |
|---|
| 5488 | 5540 | rc = readBSSListRid(ai, 0, &BSSList_rid); |
|---|
| 5489 | 5541 | } |
|---|
| 5490 | 5542 | *ptr = '\0'; |
|---|
| 5491 | | - data->readlen = strlen( data->rbuffer ); |
|---|
| 5543 | + data->readlen = strlen(data->rbuffer); |
|---|
| 5492 | 5544 | return 0; |
|---|
| 5493 | 5545 | } |
|---|
| 5494 | 5546 | |
|---|
| 5495 | | -static int proc_close( struct inode *inode, struct file *file ) |
|---|
| 5547 | +static int proc_close(struct inode *inode, struct file *file) |
|---|
| 5496 | 5548 | { |
|---|
| 5497 | 5549 | struct proc_data *data = file->private_data; |
|---|
| 5498 | 5550 | |
|---|
| .. | .. |
|---|
| 5509 | 5561 | will switch WEP modes to see if that will help. If the card is |
|---|
| 5510 | 5562 | associated we will check every minute to see if anything has |
|---|
| 5511 | 5563 | changed. */ |
|---|
| 5512 | | -static void timer_func( struct net_device *dev ) { |
|---|
| 5564 | +static void timer_func(struct net_device *dev) |
|---|
| 5565 | +{ |
|---|
| 5513 | 5566 | struct airo_info *apriv = dev->ml_priv; |
|---|
| 5514 | 5567 | |
|---|
| 5515 | 5568 | /* We don't have a link so try changing the authtype */ |
|---|
| .. | .. |
|---|
| 5577 | 5630 | pci_disable_device(pdev); |
|---|
| 5578 | 5631 | } |
|---|
| 5579 | 5632 | |
|---|
| 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) |
|---|
| 5581 | 5634 | { |
|---|
| 5582 | | - struct net_device *dev = pci_get_drvdata(pdev); |
|---|
| 5635 | + struct net_device *dev = dev_get_drvdata(dev_d); |
|---|
| 5583 | 5636 | struct airo_info *ai = dev->ml_priv; |
|---|
| 5584 | 5637 | Cmd cmd; |
|---|
| 5585 | 5638 | Resp rsp; |
|---|
| .. | .. |
|---|
| 5595 | 5648 | return -EAGAIN; |
|---|
| 5596 | 5649 | disable_MAC(ai, 0); |
|---|
| 5597 | 5650 | netif_device_detach(dev); |
|---|
| 5598 | | - ai->power = state; |
|---|
| 5651 | + ai->power = PMSG_SUSPEND; |
|---|
| 5599 | 5652 | cmd.cmd = HOSTSLEEP; |
|---|
| 5600 | 5653 | issuecommand(ai, &cmd, &rsp); |
|---|
| 5601 | 5654 | |
|---|
| 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); |
|---|
| 5605 | 5656 | return 0; |
|---|
| 5606 | 5657 | } |
|---|
| 5607 | 5658 | |
|---|
| 5608 | | -static int airo_pci_resume(struct pci_dev *pdev) |
|---|
| 5659 | +static int __maybe_unused airo_pci_resume(struct device *dev_d) |
|---|
| 5609 | 5660 | { |
|---|
| 5610 | | - struct net_device *dev = pci_get_drvdata(pdev); |
|---|
| 5661 | + struct net_device *dev = dev_get_drvdata(dev_d); |
|---|
| 5611 | 5662 | 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; |
|---|
| 5613 | 5664 | |
|---|
| 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); |
|---|
| 5617 | 5666 | |
|---|
| 5618 | 5667 | if (prev_state != PCI_D1) { |
|---|
| 5619 | 5668 | reset_card(dev, 0); |
|---|
| .. | .. |
|---|
| 5647 | 5696 | } |
|---|
| 5648 | 5697 | #endif |
|---|
| 5649 | 5698 | |
|---|
| 5650 | | -static int __init airo_init_module( void ) |
|---|
| 5699 | +static int __init airo_init_module(void) |
|---|
| 5651 | 5700 | { |
|---|
| 5652 | 5701 | int i; |
|---|
| 5653 | 5702 | |
|---|
| .. | .. |
|---|
| 5663 | 5712 | |
|---|
| 5664 | 5713 | for (i = 0; i < 4 && io[i] && irq[i]; i++) { |
|---|
| 5665 | 5714 | 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)) { |
|---|
| 5668 | 5717 | /* do nothing */ ; |
|---|
| 5718 | + } |
|---|
| 5669 | 5719 | } |
|---|
| 5670 | 5720 | |
|---|
| 5671 | 5721 | #ifdef CONFIG_PCI |
|---|
| .. | .. |
|---|
| 5685 | 5735 | return 0; |
|---|
| 5686 | 5736 | } |
|---|
| 5687 | 5737 | |
|---|
| 5688 | | -static void __exit airo_cleanup_module( void ) |
|---|
| 5738 | +static void __exit airo_cleanup_module(void) |
|---|
| 5689 | 5739 | { |
|---|
| 5690 | 5740 | struct airo_info *ai; |
|---|
| 5691 | | - while(!list_empty(&airo_devices)) { |
|---|
| 5741 | + while (!list_empty(&airo_devices)) { |
|---|
| 5692 | 5742 | ai = list_entry(airo_devices.next, struct airo_info, dev_list); |
|---|
| 5693 | 5743 | airo_print_info(ai->dev->name, "Unregistering..."); |
|---|
| 5694 | 5744 | stop_airo_card(ai->dev, 1); |
|---|
| .. | .. |
|---|
| 5788 | 5838 | int rc = -EINPROGRESS; /* Call commit handler */ |
|---|
| 5789 | 5839 | |
|---|
| 5790 | 5840 | /* If setting by frequency, convert to a channel */ |
|---|
| 5791 | | - if(fwrq->e == 1) { |
|---|
| 5841 | + if (fwrq->e == 1) { |
|---|
| 5792 | 5842 | int f = fwrq->m / 100000; |
|---|
| 5793 | 5843 | |
|---|
| 5794 | 5844 | /* Hack to fall through... */ |
|---|
| .. | .. |
|---|
| 5802 | 5852 | int channel = fwrq->m; |
|---|
| 5803 | 5853 | /* We should do a better check than that, |
|---|
| 5804 | 5854 | * based on the card capability !!! */ |
|---|
| 5805 | | - if((channel < 1) || (channel > 14)) { |
|---|
| 5855 | + if ((channel < 1) || (channel > 14)) { |
|---|
| 5806 | 5856 | airo_print_dbg(dev->name, "New channel value of %d is invalid!", |
|---|
| 5807 | 5857 | fwrq->m); |
|---|
| 5808 | 5858 | rc = -EINVAL; |
|---|
| .. | .. |
|---|
| 5836 | 5886 | readStatusRid(local, &status_rid, 1); |
|---|
| 5837 | 5887 | |
|---|
| 5838 | 5888 | ch = le16_to_cpu(status_rid.channel); |
|---|
| 5839 | | - if((ch > 0) && (ch < 15)) { |
|---|
| 5889 | + if ((ch > 0) && (ch < 15)) { |
|---|
| 5840 | 5890 | fwrq->m = 100000 * |
|---|
| 5841 | 5891 | ieee80211_channel_to_frequency(ch, NL80211_BAND_2GHZ); |
|---|
| 5842 | 5892 | fwrq->e = 1; |
|---|
| .. | .. |
|---|
| 5940 | 5990 | else if (is_broadcast_ether_addr(awrq->sa_data) || |
|---|
| 5941 | 5991 | is_zero_ether_addr(awrq->sa_data)) { |
|---|
| 5942 | 5992 | memset(&cmd, 0, sizeof(cmd)); |
|---|
| 5943 | | - cmd.cmd=CMD_LOSE_SYNC; |
|---|
| 5993 | + cmd.cmd = CMD_LOSE_SYNC; |
|---|
| 5944 | 5994 | if (down_interruptible(&local->sem)) |
|---|
| 5945 | 5995 | return -ERESTARTSYS; |
|---|
| 5946 | 5996 | issuecommand(local, &cmd, &rsp); |
|---|
| .. | .. |
|---|
| 5989 | 6039 | struct airo_info *local = dev->ml_priv; |
|---|
| 5990 | 6040 | |
|---|
| 5991 | 6041 | /* Check the size of the string */ |
|---|
| 5992 | | - if(dwrq->length > 16) { |
|---|
| 6042 | + if (dwrq->length > 16) { |
|---|
| 5993 | 6043 | return -E2BIG; |
|---|
| 5994 | 6044 | } |
|---|
| 5995 | 6045 | readConfigRid(local, 1); |
|---|
| .. | .. |
|---|
| 6037 | 6087 | readCapabilityRid(local, &cap_rid, 1); |
|---|
| 6038 | 6088 | |
|---|
| 6039 | 6089 | /* Which type of value ? */ |
|---|
| 6040 | | - if((vwrq->value < 8) && (vwrq->value >= 0)) { |
|---|
| 6090 | + if ((vwrq->value < 8) && (vwrq->value >= 0)) { |
|---|
| 6041 | 6091 | /* Setting by rate index */ |
|---|
| 6042 | 6092 | /* Find value in the magic rate table */ |
|---|
| 6043 | 6093 | brate = cap_rid.supportedRates[vwrq->value]; |
|---|
| .. | .. |
|---|
| 6046 | 6096 | u8 normvalue = (u8) (vwrq->value/500000); |
|---|
| 6047 | 6097 | |
|---|
| 6048 | 6098 | /* 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]) { |
|---|
| 6051 | 6101 | brate = normvalue; |
|---|
| 6052 | 6102 | break; |
|---|
| 6053 | 6103 | } |
|---|
| 6054 | 6104 | } |
|---|
| 6055 | 6105 | } |
|---|
| 6056 | 6106 | /* -1 designed the max rate (mostly auto mode) */ |
|---|
| 6057 | | - if(vwrq->value == -1) { |
|---|
| 6107 | + if (vwrq->value == -1) { |
|---|
| 6058 | 6108 | /* 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) |
|---|
| 6061 | 6111 | break; |
|---|
| 6062 | 6112 | } |
|---|
| 6063 | | - if(i != 0) |
|---|
| 6113 | + if (i != 0) |
|---|
| 6064 | 6114 | brate = cap_rid.supportedRates[i - 1]; |
|---|
| 6065 | 6115 | } |
|---|
| 6066 | 6116 | /* Check that it is valid */ |
|---|
| 6067 | | - if(brate == 0) { |
|---|
| 6117 | + if (brate == 0) { |
|---|
| 6068 | 6118 | return -EINVAL; |
|---|
| 6069 | 6119 | } |
|---|
| 6070 | 6120 | |
|---|
| 6071 | 6121 | readConfigRid(local, 1); |
|---|
| 6072 | 6122 | /* Now, check if we want a fixed or auto value */ |
|---|
| 6073 | | - if(vwrq->fixed == 0) { |
|---|
| 6123 | + if (vwrq->fixed == 0) { |
|---|
| 6074 | 6124 | /* Fill all the rates up to this max rate */ |
|---|
| 6075 | 6125 | memset(local->config.rates, 0, 8); |
|---|
| 6076 | | - for(i = 0 ; i < 8 ; i++) { |
|---|
| 6126 | + for (i = 0 ; i < 8 ; i++) { |
|---|
| 6077 | 6127 | local->config.rates[i] = cap_rid.supportedRates[i]; |
|---|
| 6078 | | - if(local->config.rates[i] == brate) |
|---|
| 6128 | + if (local->config.rates[i] == brate) |
|---|
| 6079 | 6129 | break; |
|---|
| 6080 | 6130 | } |
|---|
| 6081 | 6131 | } else { |
|---|
| .. | .. |
|---|
| 6123 | 6173 | struct airo_info *local = dev->ml_priv; |
|---|
| 6124 | 6174 | int rthr = vwrq->value; |
|---|
| 6125 | 6175 | |
|---|
| 6126 | | - if(vwrq->disabled) |
|---|
| 6176 | + if (vwrq->disabled) |
|---|
| 6127 | 6177 | rthr = AIRO_DEF_MTU; |
|---|
| 6128 | | - if((rthr < 0) || (rthr > AIRO_DEF_MTU)) { |
|---|
| 6178 | + if ((rthr < 0) || (rthr > AIRO_DEF_MTU)) { |
|---|
| 6129 | 6179 | return -EINVAL; |
|---|
| 6130 | 6180 | } |
|---|
| 6131 | 6181 | readConfigRid(local, 1); |
|---|
| .. | .. |
|---|
| 6166 | 6216 | struct airo_info *local = dev->ml_priv; |
|---|
| 6167 | 6217 | int fthr = vwrq->value; |
|---|
| 6168 | 6218 | |
|---|
| 6169 | | - if(vwrq->disabled) |
|---|
| 6219 | + if (vwrq->disabled) |
|---|
| 6170 | 6220 | fthr = AIRO_DEF_MTU; |
|---|
| 6171 | | - if((fthr < 256) || (fthr > AIRO_DEF_MTU)) { |
|---|
| 6221 | + if ((fthr < 256) || (fthr > AIRO_DEF_MTU)) { |
|---|
| 6172 | 6222 | return -EINVAL; |
|---|
| 6173 | 6223 | } |
|---|
| 6174 | 6224 | fthr &= ~0x1; /* Get an even value - is it really needed ??? */ |
|---|
| .. | .. |
|---|
| 6345 | 6395 | else |
|---|
| 6346 | 6396 | key.len = MIN_KEY_SIZE; |
|---|
| 6347 | 6397 | /* Check if the key is not marked as invalid */ |
|---|
| 6348 | | - if(!(dwrq->flags & IW_ENCODE_NOKEY)) { |
|---|
| 6398 | + if (!(dwrq->flags & IW_ENCODE_NOKEY)) { |
|---|
| 6349 | 6399 | /* Cleanup */ |
|---|
| 6350 | 6400 | memset(key.key, 0, MAX_KEY_SIZE); |
|---|
| 6351 | 6401 | /* Copy the key in the driver */ |
|---|
| .. | .. |
|---|
| 6362 | 6412 | /* WE specify that if a valid key is set, encryption |
|---|
| 6363 | 6413 | * should be enabled (user may turn it off later) |
|---|
| 6364 | 6414 | * This is also how "iwconfig ethX key on" works */ |
|---|
| 6365 | | - if((index == current_index) && (key.len > 0) && |
|---|
| 6415 | + if ((index == current_index) && (key.len > 0) && |
|---|
| 6366 | 6416 | (local->config.authType == AUTH_OPEN)) |
|---|
| 6367 | 6417 | set_auth_type(local, AUTH_ENCRYPT); |
|---|
| 6368 | 6418 | } else { |
|---|
| .. | .. |
|---|
| 6385 | 6435 | /* Read the flags */ |
|---|
| 6386 | 6436 | if (dwrq->flags & IW_ENCODE_DISABLED) |
|---|
| 6387 | 6437 | set_auth_type(local, AUTH_OPEN); /* disable encryption */ |
|---|
| 6388 | | - if(dwrq->flags & IW_ENCODE_RESTRICTED) |
|---|
| 6438 | + if (dwrq->flags & IW_ENCODE_RESTRICTED) |
|---|
| 6389 | 6439 | set_auth_type(local, AUTH_SHAREDKEY); /* Only Both */ |
|---|
| 6390 | 6440 | if (dwrq->flags & IW_ENCODE_OPEN) |
|---|
| 6391 | 6441 | set_auth_type(local, AUTH_ENCRYPT); /* Only Wep */ |
|---|
| .. | .. |
|---|
| 6463 | 6513 | struct airo_info *local = dev->ml_priv; |
|---|
| 6464 | 6514 | struct iw_point *encoding = &wrqu->encoding; |
|---|
| 6465 | 6515 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
|---|
| 6466 | | - int perm = ( encoding->flags & IW_ENCODE_TEMP ? 0 : 1 ); |
|---|
| 6516 | + int perm = (encoding->flags & IW_ENCODE_TEMP ? 0 : 1); |
|---|
| 6467 | 6517 | __le16 currentAuthType = local->config.authType; |
|---|
| 6468 | 6518 | int idx, key_len, alg = ext->alg, set_key = 1, rc; |
|---|
| 6469 | 6519 | wep_key_t key; |
|---|
| .. | .. |
|---|
| 6545 | 6595 | /* Read the flags */ |
|---|
| 6546 | 6596 | if (encoding->flags & IW_ENCODE_DISABLED) |
|---|
| 6547 | 6597 | set_auth_type(local, AUTH_OPEN); /* disable encryption */ |
|---|
| 6548 | | - if(encoding->flags & IW_ENCODE_RESTRICTED) |
|---|
| 6598 | + if (encoding->flags & IW_ENCODE_RESTRICTED) |
|---|
| 6549 | 6599 | set_auth_type(local, AUTH_SHAREDKEY); /* Only Both */ |
|---|
| 6550 | 6600 | if (encoding->flags & IW_ENCODE_OPEN) |
|---|
| 6551 | 6601 | set_auth_type(local, AUTH_ENCRYPT); |
|---|
| .. | .. |
|---|
| 6611 | 6661 | /* We can't return the key, so set the proper flag and return zero */ |
|---|
| 6612 | 6662 | encoding->flags |= IW_ENCODE_NOKEY; |
|---|
| 6613 | 6663 | memset(extra, 0, 16); |
|---|
| 6614 | | - |
|---|
| 6664 | + |
|---|
| 6615 | 6665 | /* Copy the key to the user buffer */ |
|---|
| 6616 | 6666 | wep_key_len = get_wep_key(local, idx, &buf[0], sizeof(buf)); |
|---|
| 6617 | 6667 | if (wep_key_len < 0) { |
|---|
| .. | .. |
|---|
| 6811 | 6861 | struct airo_info *local = dev->ml_priv; |
|---|
| 6812 | 6862 | int rc = -EINVAL; |
|---|
| 6813 | 6863 | |
|---|
| 6814 | | - if(vwrq->disabled) { |
|---|
| 6864 | + if (vwrq->disabled) { |
|---|
| 6815 | 6865 | return -EINVAL; |
|---|
| 6816 | 6866 | } |
|---|
| 6817 | 6867 | readConfigRid(local, 1); |
|---|
| 6818 | | - if(vwrq->flags & IW_RETRY_LIMIT) { |
|---|
| 6868 | + if (vwrq->flags & IW_RETRY_LIMIT) { |
|---|
| 6819 | 6869 | __le16 v = cpu_to_le16(vwrq->value); |
|---|
| 6820 | | - if(vwrq->flags & IW_RETRY_LONG) |
|---|
| 6870 | + if (vwrq->flags & IW_RETRY_LONG) |
|---|
| 6821 | 6871 | local->config.longRetryLimit = v; |
|---|
| 6822 | 6872 | else if (vwrq->flags & IW_RETRY_SHORT) |
|---|
| 6823 | 6873 | local->config.shortRetryLimit = v; |
|---|
| .. | .. |
|---|
| 6829 | 6879 | set_bit (FLAG_COMMIT, &local->flags); |
|---|
| 6830 | 6880 | rc = -EINPROGRESS; /* Call commit handler */ |
|---|
| 6831 | 6881 | } |
|---|
| 6832 | | - if(vwrq->flags & IW_RETRY_LIFETIME) { |
|---|
| 6882 | + if (vwrq->flags & IW_RETRY_LIFETIME) { |
|---|
| 6833 | 6883 | local->config.txLifetime = cpu_to_le16(vwrq->value / 1024); |
|---|
| 6834 | 6884 | set_bit (FLAG_COMMIT, &local->flags); |
|---|
| 6835 | 6885 | rc = -EINPROGRESS; /* Call commit handler */ |
|---|
| .. | .. |
|---|
| 6852 | 6902 | |
|---|
| 6853 | 6903 | readConfigRid(local, 1); |
|---|
| 6854 | 6904 | /* Note : by default, display the min retry number */ |
|---|
| 6855 | | - if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { |
|---|
| 6905 | + if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { |
|---|
| 6856 | 6906 | vwrq->flags = IW_RETRY_LIFETIME; |
|---|
| 6857 | 6907 | vwrq->value = le16_to_cpu(local->config.txLifetime) * 1024; |
|---|
| 6858 | | - } else if((vwrq->flags & IW_RETRY_LONG)) { |
|---|
| 6908 | + } else if ((vwrq->flags & IW_RETRY_LONG)) { |
|---|
| 6859 | 6909 | vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; |
|---|
| 6860 | 6910 | vwrq->value = le16_to_cpu(local->config.longRetryLimit); |
|---|
| 6861 | 6911 | } else { |
|---|
| 6862 | 6912 | vwrq->flags = IW_RETRY_LIMIT; |
|---|
| 6863 | 6913 | vwrq->value = le16_to_cpu(local->config.shortRetryLimit); |
|---|
| 6864 | | - if(local->config.shortRetryLimit != local->config.longRetryLimit) |
|---|
| 6914 | + if (local->config.shortRetryLimit != local->config.longRetryLimit) |
|---|
| 6865 | 6915 | vwrq->flags |= IW_RETRY_SHORT; |
|---|
| 6866 | 6916 | } |
|---|
| 6867 | 6917 | |
|---|
| .. | .. |
|---|
| 6893 | 6943 | /* Should be based on cap_rid.country to give only |
|---|
| 6894 | 6944 | * what the current card support */ |
|---|
| 6895 | 6945 | k = 0; |
|---|
| 6896 | | - for(i = 0; i < 14; i++) { |
|---|
| 6946 | + for (i = 0; i < 14; i++) { |
|---|
| 6897 | 6947 | range->freq[k].i = i + 1; /* List index */ |
|---|
| 6898 | 6948 | range->freq[k].m = 100000 * |
|---|
| 6899 | 6949 | ieee80211_channel_to_frequency(i + 1, NL80211_BAND_2GHZ); |
|---|
| .. | .. |
|---|
| 6923 | 6973 | } |
|---|
| 6924 | 6974 | range->avg_qual.noise = 0x100 - 85; /* -85 dBm */ |
|---|
| 6925 | 6975 | |
|---|
| 6926 | | - for(i = 0 ; i < 8 ; i++) { |
|---|
| 6976 | + for (i = 0 ; i < 8 ; i++) { |
|---|
| 6927 | 6977 | range->bitrate[i] = cap_rid.supportedRates[i] * 500000; |
|---|
| 6928 | | - if(range->bitrate[i] == 0) |
|---|
| 6978 | + if (range->bitrate[i] == 0) |
|---|
| 6929 | 6979 | break; |
|---|
| 6930 | 6980 | } |
|---|
| 6931 | 6981 | range->num_bitrates = i; |
|---|
| .. | .. |
|---|
| 6933 | 6983 | /* Set an indication of the max TCP throughput |
|---|
| 6934 | 6984 | * in bit/s that we can expect using this interface. |
|---|
| 6935 | 6985 | * May be use for QoS stuff... Jean II */ |
|---|
| 6936 | | - if(i > 2) |
|---|
| 6986 | + if (i > 2) |
|---|
| 6937 | 6987 | range->throughput = 5000 * 1000; |
|---|
| 6938 | 6988 | else |
|---|
| 6939 | 6989 | range->throughput = 1500 * 1000; |
|---|
| .. | .. |
|---|
| 6943 | 6993 | range->min_frag = 256; |
|---|
| 6944 | 6994 | range->max_frag = AIRO_DEF_MTU; |
|---|
| 6945 | 6995 | |
|---|
| 6946 | | - if(cap_rid.softCap & cpu_to_le16(2)) { |
|---|
| 6996 | + if (cap_rid.softCap & cpu_to_le16(2)) { |
|---|
| 6947 | 6997 | // WEP: RC4 40 bits |
|---|
| 6948 | 6998 | range->encoding_size[0] = 5; |
|---|
| 6949 | 6999 | // RC4 ~128 bits |
|---|
| .. | .. |
|---|
| 6967 | 7017 | range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; |
|---|
| 6968 | 7018 | |
|---|
| 6969 | 7019 | /* Transmit Power - values are in mW */ |
|---|
| 6970 | | - for(i = 0 ; i < 8 ; i++) { |
|---|
| 7020 | + for (i = 0 ; i < 8 ; i++) { |
|---|
| 6971 | 7021 | range->txpower[i] = le16_to_cpu(cap_rid.txPowerLevels[i]); |
|---|
| 6972 | | - if(range->txpower[i] == 0) |
|---|
| 7022 | + if (range->txpower[i] == 0) |
|---|
| 6973 | 7023 | break; |
|---|
| 6974 | 7024 | } |
|---|
| 6975 | 7025 | range->num_txpower = i; |
|---|
| .. | .. |
|---|
| 7240 | 7290 | /* Initiate a scan command */ |
|---|
| 7241 | 7291 | ai->scan_timeout = RUN_AT(3*HZ); |
|---|
| 7242 | 7292 | memset(&cmd, 0, sizeof(cmd)); |
|---|
| 7243 | | - cmd.cmd=CMD_LISTBSS; |
|---|
| 7293 | + cmd.cmd = CMD_LISTBSS; |
|---|
| 7244 | 7294 | issuecommand(ai, &cmd, &rsp); |
|---|
| 7245 | 7295 | wake = 1; |
|---|
| 7246 | 7296 | |
|---|
| .. | .. |
|---|
| 7281 | 7331 | |
|---|
| 7282 | 7332 | /* Add the ESSID */ |
|---|
| 7283 | 7333 | iwe.u.data.length = bss->ssidLen; |
|---|
| 7284 | | - if(iwe.u.data.length > 32) |
|---|
| 7334 | + if (iwe.u.data.length > 32) |
|---|
| 7285 | 7335 | iwe.u.data.length = 32; |
|---|
| 7286 | 7336 | iwe.cmd = SIOCGIWESSID; |
|---|
| 7287 | 7337 | iwe.u.data.flags = 1; |
|---|
| .. | .. |
|---|
| 7291 | 7341 | /* Add mode */ |
|---|
| 7292 | 7342 | iwe.cmd = SIOCGIWMODE; |
|---|
| 7293 | 7343 | capabilities = bss->cap; |
|---|
| 7294 | | - if(capabilities & (CAP_ESS | CAP_IBSS)) { |
|---|
| 7295 | | - if(capabilities & CAP_ESS) |
|---|
| 7344 | + if (capabilities & (CAP_ESS | CAP_IBSS)) { |
|---|
| 7345 | + if (capabilities & CAP_ESS) |
|---|
| 7296 | 7346 | iwe.u.mode = IW_MODE_MASTER; |
|---|
| 7297 | 7347 | else |
|---|
| 7298 | 7348 | iwe.u.mode = IW_MODE_ADHOC; |
|---|
| .. | .. |
|---|
| 7332 | 7382 | |
|---|
| 7333 | 7383 | /* Add encryption capability */ |
|---|
| 7334 | 7384 | iwe.cmd = SIOCGIWENCODE; |
|---|
| 7335 | | - if(capabilities & CAP_PRIVACY) |
|---|
| 7385 | + if (capabilities & CAP_PRIVACY) |
|---|
| 7336 | 7386 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; |
|---|
| 7337 | 7387 | else |
|---|
| 7338 | 7388 | iwe.u.data.flags = IW_ENCODE_DISABLED; |
|---|
| .. | .. |
|---|
| 7348 | 7398 | /* Those two flags are ignored... */ |
|---|
| 7349 | 7399 | iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; |
|---|
| 7350 | 7400 | /* Max 8 values */ |
|---|
| 7351 | | - for(i = 0 ; i < 8 ; i++) { |
|---|
| 7401 | + for (i = 0 ; i < 8 ; i++) { |
|---|
| 7352 | 7402 | /* NULL terminated */ |
|---|
| 7353 | | - if(bss->rates[i] == 0) |
|---|
| 7403 | + if (bss->rates[i] == 0) |
|---|
| 7354 | 7404 | break; |
|---|
| 7355 | 7405 | /* Bit rate given in 500 kb/s units (+ 0x80) */ |
|---|
| 7356 | 7406 | iwe.u.bitrate.value = ((bss->rates[i] & 0x7f) * 500000); |
|---|
| .. | .. |
|---|
| 7458 | 7508 | &net->bss); |
|---|
| 7459 | 7509 | |
|---|
| 7460 | 7510 | /* Check if there is space for one more entry */ |
|---|
| 7461 | | - if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) { |
|---|
| 7511 | + if ((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) { |
|---|
| 7462 | 7512 | /* Ask user space to try again with a bigger buffer */ |
|---|
| 7463 | 7513 | err = -E2BIG; |
|---|
| 7464 | 7514 | goto out; |
|---|
| .. | .. |
|---|
| 7496 | 7546 | |
|---|
| 7497 | 7547 | readSsidRid(local, &SSID_rid); |
|---|
| 7498 | 7548 | if (test_bit(FLAG_MPI,&local->flags)) |
|---|
| 7499 | | - setup_card(local, dev->dev_addr, 1 ); |
|---|
| 7549 | + setup_card(local, dev->dev_addr, 1); |
|---|
| 7500 | 7550 | else |
|---|
| 7501 | 7551 | reset_airo_card(dev); |
|---|
| 7502 | 7552 | disable_MAC(local, 1); |
|---|
| .. | .. |
|---|
| 7640 | 7690 | { |
|---|
| 7641 | 7691 | int val = AIROMAGIC; |
|---|
| 7642 | 7692 | aironet_ioctl com; |
|---|
| 7643 | | - if (copy_from_user(&com,rq->ifr_data,sizeof(com))) |
|---|
| 7693 | + if (copy_from_user(&com, rq->ifr_data, sizeof(com))) |
|---|
| 7644 | 7694 | rc = -EFAULT; |
|---|
| 7645 | | - else if (copy_to_user(com.data,(char *)&val,sizeof(val))) |
|---|
| 7695 | + else if (copy_to_user(com.data, (char *)&val, sizeof(val))) |
|---|
| 7646 | 7696 | rc = -EFAULT; |
|---|
| 7647 | 7697 | } |
|---|
| 7648 | 7698 | break; |
|---|
| .. | .. |
|---|
| 7656 | 7706 | */ |
|---|
| 7657 | 7707 | { |
|---|
| 7658 | 7708 | aironet_ioctl com; |
|---|
| 7659 | | - if (copy_from_user(&com,rq->ifr_data,sizeof(com))) { |
|---|
| 7709 | + if (copy_from_user(&com, rq->ifr_data, sizeof(com))) { |
|---|
| 7660 | 7710 | rc = -EFAULT; |
|---|
| 7661 | 7711 | break; |
|---|
| 7662 | 7712 | } |
|---|
| 7663 | 7713 | |
|---|
| 7664 | 7714 | /* Separate R/W functions bracket legality here |
|---|
| 7665 | 7715 | */ |
|---|
| 7666 | | - if ( com.command == AIRORSWVERSION ) { |
|---|
| 7716 | + if (com.command == AIRORSWVERSION) { |
|---|
| 7667 | 7717 | if (copy_to_user(com.data, swversion, sizeof(swversion))) |
|---|
| 7668 | 7718 | rc = -EFAULT; |
|---|
| 7669 | 7719 | else |
|---|
| 7670 | 7720 | rc = 0; |
|---|
| 7671 | 7721 | } |
|---|
| 7672 | | - else if ( com.command <= AIRORRID) |
|---|
| 7722 | + else if (com.command <= AIRORRID) |
|---|
| 7673 | 7723 | rc = readrids(dev,&com); |
|---|
| 7674 | | - else if ( com.command >= AIROPCAP && com.command <= (AIROPLEAPUSR+2) ) |
|---|
| 7724 | + else if (com.command >= AIROPCAP && com.command <= (AIROPLEAPUSR+2)) |
|---|
| 7675 | 7725 | rc = writerids(dev,&com); |
|---|
| 7676 | | - else if ( com.command >= AIROFLSHRST && com.command <= AIRORESTART ) |
|---|
| 7726 | + else if (com.command >= AIROFLSHRST && com.command <= AIRORESTART) |
|---|
| 7677 | 7727 | rc = flashcard(dev,&com); |
|---|
| 7678 | 7728 | else |
|---|
| 7679 | 7729 | rc = -EINVAL; /* Bad command in ioctl */ |
|---|
| .. | .. |
|---|
| 7775 | 7825 | * as needed. This represents the READ side of control I/O to |
|---|
| 7776 | 7826 | * the card |
|---|
| 7777 | 7827 | */ |
|---|
| 7778 | | -static int readrids(struct net_device *dev, aironet_ioctl *comp) { |
|---|
| 7828 | +static int readrids(struct net_device *dev, aironet_ioctl *comp) |
|---|
| 7829 | +{ |
|---|
| 7779 | 7830 | unsigned short ridcode; |
|---|
| 7780 | 7831 | unsigned char *iobuf; |
|---|
| 7781 | 7832 | int len; |
|---|
| .. | .. |
|---|
| 7805 | 7856 | case AIROGSTATSC32: ridcode = RID_STATS; break; |
|---|
| 7806 | 7857 | case AIROGMICSTATS: |
|---|
| 7807 | 7858 | if (copy_to_user(comp->data, &ai->micstats, |
|---|
| 7808 | | - min((int)comp->len,(int)sizeof(ai->micstats)))) |
|---|
| 7859 | + min((int)comp->len, (int)sizeof(ai->micstats)))) |
|---|
| 7809 | 7860 | return -EFAULT; |
|---|
| 7810 | 7861 | return 0; |
|---|
| 7811 | 7862 | case AIRORRID: ridcode = comp->ridnum; break; |
|---|
| .. | .. |
|---|
| 7822 | 7873 | if ((iobuf = kzalloc(RIDSIZE, GFP_KERNEL)) == NULL) |
|---|
| 7823 | 7874 | return -ENOMEM; |
|---|
| 7824 | 7875 | |
|---|
| 7825 | | - PC4500_readrid(ai,ridcode,iobuf,RIDSIZE, 1); |
|---|
| 7876 | + PC4500_readrid(ai, ridcode, iobuf, RIDSIZE, 1); |
|---|
| 7826 | 7877 | /* get the count of bytes in the rid docs say 1st 2 bytes is it. |
|---|
| 7827 | 7878 | * then return it to the user |
|---|
| 7828 | 7879 | * 9/22/2000 Honor user given length |
|---|
| .. | .. |
|---|
| 7841 | 7892 | * Danger Will Robinson write the rids here |
|---|
| 7842 | 7893 | */ |
|---|
| 7843 | 7894 | |
|---|
| 7844 | | -static int writerids(struct net_device *dev, aironet_ioctl *comp) { |
|---|
| 7895 | +static int writerids(struct net_device *dev, aironet_ioctl *comp) |
|---|
| 7896 | +{ |
|---|
| 7845 | 7897 | struct airo_info *ai = dev->ml_priv; |
|---|
| 7846 | 7898 | int ridcode; |
|---|
| 7847 | 7899 | int enabled; |
|---|
| .. | .. |
|---|
| 7898 | 7950 | if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL) |
|---|
| 7899 | 7951 | return -ENOMEM; |
|---|
| 7900 | 7952 | |
|---|
| 7901 | | - PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDSIZE, 1); |
|---|
| 7953 | + PC4500_readrid(ai, RID_STATSDELTACLEAR, iobuf, RIDSIZE, 1); |
|---|
| 7902 | 7954 | |
|---|
| 7903 | 7955 | enabled = ai->micstats.enabled; |
|---|
| 7904 | | - memset(&ai->micstats,0,sizeof(ai->micstats)); |
|---|
| 7956 | + memset(&ai->micstats, 0, sizeof(ai->micstats)); |
|---|
| 7905 | 7957 | ai->micstats.enabled = enabled; |
|---|
| 7906 | 7958 | |
|---|
| 7907 | 7959 | if (copy_to_user(comp->data, iobuf, |
|---|
| .. | .. |
|---|
| 7915 | 7967 | default: |
|---|
| 7916 | 7968 | return -EOPNOTSUPP; /* Blarg! */ |
|---|
| 7917 | 7969 | } |
|---|
| 7918 | | - if(comp->len > RIDSIZE) |
|---|
| 7970 | + if (comp->len > RIDSIZE) |
|---|
| 7919 | 7971 | return -EINVAL; |
|---|
| 7920 | 7972 | |
|---|
| 7921 | 7973 | if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL) |
|---|
| 7922 | 7974 | return -ENOMEM; |
|---|
| 7923 | 7975 | |
|---|
| 7924 | | - if (copy_from_user(iobuf,comp->data,comp->len)) { |
|---|
| 7976 | + if (copy_from_user(iobuf, comp->data, comp->len)) { |
|---|
| 7925 | 7977 | kfree (iobuf); |
|---|
| 7926 | 7978 | return -EFAULT; |
|---|
| 7927 | 7979 | } |
|---|
| .. | .. |
|---|
| 7938 | 7990 | clear_bit (FLAG_ADHOC, &ai->flags); |
|---|
| 7939 | 7991 | } |
|---|
| 7940 | 7992 | |
|---|
| 7941 | | - if((*writer)(ai, ridcode, iobuf,comp->len,1)) { |
|---|
| 7993 | + if ((*writer)(ai, ridcode, iobuf, comp->len, 1)) { |
|---|
| 7942 | 7994 | kfree (iobuf); |
|---|
| 7943 | 7995 | return -EIO; |
|---|
| 7944 | 7996 | } |
|---|
| .. | .. |
|---|
| 7955 | 8007 | * Flash command switch table |
|---|
| 7956 | 8008 | */ |
|---|
| 7957 | 8009 | |
|---|
| 7958 | | -static int flashcard(struct net_device *dev, aironet_ioctl *comp) { |
|---|
| 8010 | +static int flashcard(struct net_device *dev, aironet_ioctl *comp) |
|---|
| 8011 | +{ |
|---|
| 7959 | 8012 | int z; |
|---|
| 7960 | 8013 | |
|---|
| 7961 | 8014 | /* Only super-user can modify flash */ |
|---|
| .. | .. |
|---|
| 7974 | 8027 | return setflashmode((struct airo_info *)dev->ml_priv); |
|---|
| 7975 | 8028 | |
|---|
| 7976 | 8029 | case AIROFLSHGCHR: /* Get char from aux */ |
|---|
| 7977 | | - if(comp->len != sizeof(int)) |
|---|
| 8030 | + if (comp->len != sizeof(int)) |
|---|
| 7978 | 8031 | return -EINVAL; |
|---|
| 7979 | | - if (copy_from_user(&z,comp->data,comp->len)) |
|---|
| 8032 | + if (copy_from_user(&z, comp->data, comp->len)) |
|---|
| 7980 | 8033 | return -EFAULT; |
|---|
| 7981 | 8034 | return flashgchar((struct airo_info *)dev->ml_priv, z, 8000); |
|---|
| 7982 | 8035 | |
|---|
| 7983 | 8036 | case AIROFLSHPCHR: /* Send char to card. */ |
|---|
| 7984 | | - if(comp->len != sizeof(int)) |
|---|
| 8037 | + if (comp->len != sizeof(int)) |
|---|
| 7985 | 8038 | return -EINVAL; |
|---|
| 7986 | | - if (copy_from_user(&z,comp->data,comp->len)) |
|---|
| 8039 | + if (copy_from_user(&z, comp->data, comp->len)) |
|---|
| 7987 | 8040 | return -EFAULT; |
|---|
| 7988 | 8041 | return flashpchar((struct airo_info *)dev->ml_priv, z, 8000); |
|---|
| 7989 | 8042 | |
|---|
| 7990 | 8043 | case AIROFLPUTBUF: /* Send 32k to card */ |
|---|
| 7991 | 8044 | if (!AIRO_FLASH(dev)) |
|---|
| 7992 | 8045 | return -ENOMEM; |
|---|
| 7993 | | - if(comp->len > FLASHSIZE) |
|---|
| 8046 | + if (comp->len > FLASHSIZE) |
|---|
| 7994 | 8047 | return -EINVAL; |
|---|
| 7995 | 8048 | if (copy_from_user(AIRO_FLASH(dev), comp->data, comp->len)) |
|---|
| 7996 | 8049 | return -EFAULT; |
|---|
| .. | .. |
|---|
| 8014 | 8067 | * card. |
|---|
| 8015 | 8068 | */ |
|---|
| 8016 | 8069 | |
|---|
| 8017 | | -static int cmdreset(struct airo_info *ai) { |
|---|
| 8070 | +static int cmdreset(struct airo_info *ai) |
|---|
| 8071 | +{ |
|---|
| 8018 | 8072 | disable_MAC(ai, 1); |
|---|
| 8019 | 8073 | |
|---|
| 8020 | | - if(!waitbusy (ai)){ |
|---|
| 8074 | + if (!waitbusy (ai)) { |
|---|
| 8021 | 8075 | airo_print_info(ai->dev->name, "Waitbusy hang before RESET"); |
|---|
| 8022 | 8076 | return -EBUSY; |
|---|
| 8023 | 8077 | } |
|---|
| 8024 | 8078 | |
|---|
| 8025 | | - OUT4500(ai,COMMAND,CMD_SOFTRESET); |
|---|
| 8079 | + OUT4500(ai, COMMAND, CMD_SOFTRESET); |
|---|
| 8026 | 8080 | |
|---|
| 8027 | 8081 | ssleep(1); /* WAS 600 12/7/00 */ |
|---|
| 8028 | 8082 | |
|---|
| 8029 | | - if(!waitbusy (ai)){ |
|---|
| 8083 | + if (!waitbusy (ai)) { |
|---|
| 8030 | 8084 | airo_print_info(ai->dev->name, "Waitbusy hang AFTER RESET"); |
|---|
| 8031 | 8085 | return -EBUSY; |
|---|
| 8032 | 8086 | } |
|---|
| .. | .. |
|---|
| 8038 | 8092 | * mode |
|---|
| 8039 | 8093 | */ |
|---|
| 8040 | 8094 | |
|---|
| 8041 | | -static int setflashmode (struct airo_info *ai) { |
|---|
| 8095 | +static int setflashmode (struct airo_info *ai) |
|---|
| 8096 | +{ |
|---|
| 8042 | 8097 | set_bit (FLAG_FLASHING, &ai->flags); |
|---|
| 8043 | 8098 | |
|---|
| 8044 | 8099 | OUT4500(ai, SWS0, FLASH_COMMAND); |
|---|
| 8045 | 8100 | OUT4500(ai, SWS1, FLASH_COMMAND); |
|---|
| 8046 | 8101 | if (probe) { |
|---|
| 8047 | 8102 | OUT4500(ai, SWS0, FLASH_COMMAND); |
|---|
| 8048 | | - OUT4500(ai, COMMAND,0x10); |
|---|
| 8103 | + OUT4500(ai, COMMAND, 0x10); |
|---|
| 8049 | 8104 | } else { |
|---|
| 8050 | 8105 | OUT4500(ai, SWS2, FLASH_COMMAND); |
|---|
| 8051 | 8106 | OUT4500(ai, SWS3, FLASH_COMMAND); |
|---|
| 8052 | | - OUT4500(ai, COMMAND,0); |
|---|
| 8107 | + OUT4500(ai, COMMAND, 0); |
|---|
| 8053 | 8108 | } |
|---|
| 8054 | 8109 | msleep(500); /* 500ms delay */ |
|---|
| 8055 | 8110 | |
|---|
| 8056 | | - if(!waitbusy(ai)) { |
|---|
| 8111 | + if (!waitbusy(ai)) { |
|---|
| 8057 | 8112 | clear_bit (FLAG_FLASHING, &ai->flags); |
|---|
| 8058 | 8113 | airo_print_info(ai->dev->name, "Waitbusy hang after setflash mode"); |
|---|
| 8059 | 8114 | return -EIO; |
|---|
| .. | .. |
|---|
| 8065 | 8120 | * x 50us for echo . |
|---|
| 8066 | 8121 | */ |
|---|
| 8067 | 8122 | |
|---|
| 8068 | | -static int flashpchar(struct airo_info *ai,int byte,int dwelltime) { |
|---|
| 8123 | +static int flashpchar(struct airo_info *ai, int byte, int dwelltime) |
|---|
| 8124 | +{ |
|---|
| 8069 | 8125 | int echo; |
|---|
| 8070 | 8126 | int waittime; |
|---|
| 8071 | 8127 | |
|---|
| 8072 | 8128 | byte |= 0x8000; |
|---|
| 8073 | 8129 | |
|---|
| 8074 | | - if(dwelltime == 0 ) |
|---|
| 8130 | + if (dwelltime == 0) |
|---|
| 8075 | 8131 | dwelltime = 200; |
|---|
| 8076 | 8132 | |
|---|
| 8077 | | - waittime=dwelltime; |
|---|
| 8133 | + waittime = dwelltime; |
|---|
| 8078 | 8134 | |
|---|
| 8079 | 8135 | /* Wait for busy bit d15 to go false indicating buffer empty */ |
|---|
| 8080 | 8136 | while ((IN4500 (ai, SWS0) & 0x8000) && waittime > 0) { |
|---|
| .. | .. |
|---|
| 8083 | 8139 | } |
|---|
| 8084 | 8140 | |
|---|
| 8085 | 8141 | /* timeout for busy clear wait */ |
|---|
| 8086 | | - if(waittime <= 0 ){ |
|---|
| 8142 | + if (waittime <= 0) { |
|---|
| 8087 | 8143 | airo_print_info(ai->dev->name, "flash putchar busywait timeout!"); |
|---|
| 8088 | 8144 | return -EBUSY; |
|---|
| 8089 | 8145 | } |
|---|
| 8090 | 8146 | |
|---|
| 8091 | 8147 | /* Port is clear now write byte and wait for it to echo back */ |
|---|
| 8092 | 8148 | do { |
|---|
| 8093 | | - OUT4500(ai,SWS0,byte); |
|---|
| 8149 | + OUT4500(ai, SWS0, byte); |
|---|
| 8094 | 8150 | udelay(50); |
|---|
| 8095 | 8151 | dwelltime -= 50; |
|---|
| 8096 | | - echo = IN4500(ai,SWS1); |
|---|
| 8152 | + echo = IN4500(ai, SWS1); |
|---|
| 8097 | 8153 | } while (dwelltime >= 0 && echo != byte); |
|---|
| 8098 | 8154 | |
|---|
| 8099 | | - OUT4500(ai,SWS1,0); |
|---|
| 8155 | + OUT4500(ai, SWS1, 0); |
|---|
| 8100 | 8156 | |
|---|
| 8101 | 8157 | return (echo == byte) ? 0 : -EIO; |
|---|
| 8102 | 8158 | } |
|---|
| .. | .. |
|---|
| 8105 | 8161 | * Get a character from the card matching matchbyte |
|---|
| 8106 | 8162 | * Step 3) |
|---|
| 8107 | 8163 | */ |
|---|
| 8108 | | -static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime){ |
|---|
| 8164 | +static int flashgchar(struct airo_info *ai, int matchbyte, int dwelltime) |
|---|
| 8165 | +{ |
|---|
| 8109 | 8166 | int rchar; |
|---|
| 8110 | | - unsigned char rbyte=0; |
|---|
| 8167 | + unsigned char rbyte = 0; |
|---|
| 8111 | 8168 | |
|---|
| 8112 | 8169 | do { |
|---|
| 8113 | | - rchar = IN4500(ai,SWS1); |
|---|
| 8170 | + rchar = IN4500(ai, SWS1); |
|---|
| 8114 | 8171 | |
|---|
| 8115 | | - if(dwelltime && !(0x8000 & rchar)){ |
|---|
| 8172 | + if (dwelltime && !(0x8000 & rchar)) { |
|---|
| 8116 | 8173 | dwelltime -= 10; |
|---|
| 8117 | 8174 | mdelay(10); |
|---|
| 8118 | 8175 | continue; |
|---|
| 8119 | 8176 | } |
|---|
| 8120 | 8177 | rbyte = 0xff & rchar; |
|---|
| 8121 | 8178 | |
|---|
| 8122 | | - if( (rbyte == matchbyte) && (0x8000 & rchar) ){ |
|---|
| 8123 | | - OUT4500(ai,SWS1,0); |
|---|
| 8179 | + if ((rbyte == matchbyte) && (0x8000 & rchar)) { |
|---|
| 8180 | + OUT4500(ai, SWS1, 0); |
|---|
| 8124 | 8181 | return 0; |
|---|
| 8125 | 8182 | } |
|---|
| 8126 | | - if( rbyte == 0x81 || rbyte == 0x82 || rbyte == 0x83 || rbyte == 0x1a || 0xffff == rchar) |
|---|
| 8183 | + if (rbyte == 0x81 || rbyte == 0x82 || rbyte == 0x83 || rbyte == 0x1a || 0xffff == rchar) |
|---|
| 8127 | 8184 | break; |
|---|
| 8128 | | - OUT4500(ai,SWS1,0); |
|---|
| 8185 | + OUT4500(ai, SWS1, 0); |
|---|
| 8129 | 8186 | |
|---|
| 8130 | | - }while(dwelltime > 0); |
|---|
| 8187 | + } while (dwelltime > 0); |
|---|
| 8131 | 8188 | return -EIO; |
|---|
| 8132 | 8189 | } |
|---|
| 8133 | 8190 | |
|---|
| .. | .. |
|---|
| 8136 | 8193 | * send to the card |
|---|
| 8137 | 8194 | */ |
|---|
| 8138 | 8195 | |
|---|
| 8139 | | -static int flashputbuf(struct airo_info *ai){ |
|---|
| 8196 | +static int flashputbuf(struct airo_info *ai) |
|---|
| 8197 | +{ |
|---|
| 8140 | 8198 | int nwords; |
|---|
| 8141 | 8199 | |
|---|
| 8142 | 8200 | /* Write stuff */ |
|---|
| 8143 | 8201 | if (test_bit(FLAG_MPI,&ai->flags)) |
|---|
| 8144 | 8202 | memcpy_toio(ai->pciaux + 0x8000, ai->flash, FLASHSIZE); |
|---|
| 8145 | 8203 | else { |
|---|
| 8146 | | - OUT4500(ai,AUXPAGE,0x100); |
|---|
| 8147 | | - OUT4500(ai,AUXOFF,0); |
|---|
| 8204 | + OUT4500(ai, AUXPAGE, 0x100); |
|---|
| 8205 | + OUT4500(ai, AUXOFF, 0); |
|---|
| 8148 | 8206 | |
|---|
| 8149 | | - for(nwords=0;nwords != FLASHSIZE / 2;nwords++){ |
|---|
| 8150 | | - OUT4500(ai,AUXDATA,ai->flash[nwords] & 0xffff); |
|---|
| 8207 | + for (nwords = 0; nwords != FLASHSIZE / 2; nwords++) { |
|---|
| 8208 | + OUT4500(ai, AUXDATA, ai->flash[nwords] & 0xffff); |
|---|
| 8151 | 8209 | } |
|---|
| 8152 | 8210 | } |
|---|
| 8153 | | - OUT4500(ai,SWS0,0x8000); |
|---|
| 8211 | + OUT4500(ai, SWS0, 0x8000); |
|---|
| 8154 | 8212 | |
|---|
| 8155 | 8213 | return 0; |
|---|
| 8156 | 8214 | } |
|---|
| .. | .. |
|---|
| 8158 | 8216 | /* |
|---|
| 8159 | 8217 | * |
|---|
| 8160 | 8218 | */ |
|---|
| 8161 | | -static int flashrestart(struct airo_info *ai,struct net_device *dev){ |
|---|
| 8162 | | - int i,status; |
|---|
| 8219 | +static int flashrestart(struct airo_info *ai, struct net_device *dev) |
|---|
| 8220 | +{ |
|---|
| 8221 | + int i, status; |
|---|
| 8163 | 8222 | |
|---|
| 8164 | 8223 | ssleep(1); /* Added 12/7/00 */ |
|---|
| 8165 | 8224 | clear_bit (FLAG_FLASHING, &ai->flags); |
|---|
| .. | .. |
|---|
| 8171 | 8230 | status = setup_card(ai, dev->dev_addr, 1); |
|---|
| 8172 | 8231 | |
|---|
| 8173 | 8232 | if (!test_bit(FLAG_MPI,&ai->flags)) |
|---|
| 8174 | | - for( i = 0; i < MAX_FIDS; i++ ) { |
|---|
| 8233 | + for (i = 0; i < MAX_FIDS; i++) { |
|---|
| 8175 | 8234 | ai->fids[i] = transmit_allocate |
|---|
| 8176 | | - ( ai, AIRO_DEF_MTU, i >= MAX_FIDS / 2 ); |
|---|
| 8235 | + (ai, AIRO_DEF_MTU, i >= MAX_FIDS / 2); |
|---|
| 8177 | 8236 | } |
|---|
| 8178 | 8237 | |
|---|
| 8179 | 8238 | ssleep(1); /* Added 12/7/00 */ |
|---|