aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/airo.c4
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h8
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_ilt.c15
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_ilt.h1
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c20
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_phy.c195
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_radio.c13
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_xmit.h10
-rw-r--r--drivers/net/wireless/hostap/hostap.h3
-rw-r--r--drivers/net/wireless/ipw2100.c14
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c8
-rw-r--r--drivers/net/wireless/prism54/oid_mgt.c4
-rw-r--r--drivers/net/wireless/wavelan.c14
-rw-r--r--drivers/net/wireless/wavelan.p.h3
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c2
-rw-r--r--include/linux/wireless.h4
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_module.c13
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c11
18 files changed, 157 insertions, 185 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index b08055abe83a..a8c2bfe26c27 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1623,7 +1623,7 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
1623 1623
1624 crypto_cipher_setkey(tfm, pkey, 16); 1624 crypto_cipher_setkey(tfm, pkey, 16);
1625 counter = 0; 1625 counter = 0;
1626 for (i = 0; i < (sizeof(context->coeff)/sizeof(context->coeff[0])); ) { 1626 for (i = 0; i < ARRAY_SIZE(context->coeff); ) {
1627 aes_counter[15] = (u8)(counter >> 0); 1627 aes_counter[15] = (u8)(counter >> 0);
1628 aes_counter[14] = (u8)(counter >> 8); 1628 aes_counter[14] = (u8)(counter >> 8);
1629 aes_counter[13] = (u8)(counter >> 16); 1629 aes_counter[13] = (u8)(counter >> 16);
@@ -1632,7 +1632,7 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
1632 memcpy (plain, aes_counter, 16); 1632 memcpy (plain, aes_counter, 16);
1633 crypto_cipher_encrypt_one(tfm, plain, plain); 1633 crypto_cipher_encrypt_one(tfm, plain, plain);
1634 cipher = plain; 1634 cipher = plain;
1635 for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { 1635 for (j = 0; (j < 16) && (i < ARRAY_SIZE(context->coeff)); ) {
1636 context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); 1636 context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
1637 j += 4; 1637 j += 4;
1638 } 1638 }
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index 0e790efae683..95ff175d8f33 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -21,7 +21,7 @@
21#define PFX KBUILD_MODNAME ": " 21#define PFX KBUILD_MODNAME ": "
22 22
23#define BCM43xx_SWITCH_CORE_MAX_RETRIES 50 23#define BCM43xx_SWITCH_CORE_MAX_RETRIES 50
24#define BCM43xx_IRQWAIT_MAX_RETRIES 50 24#define BCM43xx_IRQWAIT_MAX_RETRIES 100
25 25
26#define BCM43xx_IO_SIZE 8192 26#define BCM43xx_IO_SIZE 8192
27 27
@@ -333,7 +333,7 @@
333#define BCM43xx_SBF_PS2 0x04000000 333#define BCM43xx_SBF_PS2 0x04000000
334#define BCM43xx_SBF_NO_SSID_BCAST 0x08000000 334#define BCM43xx_SBF_NO_SSID_BCAST 0x08000000
335#define BCM43xx_SBF_TIME_UPDATE 0x10000000 335#define BCM43xx_SBF_TIME_UPDATE 0x10000000
336#define BCM43xx_SBF_80000000 0x80000000 /*FIXME: fix name*/ 336#define BCM43xx_SBF_MODE_G 0x80000000
337 337
338/* Microcode */ 338/* Microcode */
339#define BCM43xx_UCODE_REVISION 0x0000 339#define BCM43xx_UCODE_REVISION 0x0000
@@ -507,8 +507,6 @@ struct bcm43xx_sprominfo {
507 u8 et1macaddr[6]; 507 u8 et1macaddr[6];
508 u8 et0phyaddr:5; 508 u8 et0phyaddr:5;
509 u8 et1phyaddr:5; 509 u8 et1phyaddr:5;
510 u8 et0mdcport:1;
511 u8 et1mdcport:1;
512 u8 boardrev; 510 u8 boardrev;
513 u8 locale:4; 511 u8 locale:4;
514 u8 antennas_aphy:2; 512 u8 antennas_aphy:2;
@@ -542,7 +540,7 @@ struct bcm43xx_lopair {
542 540
543struct bcm43xx_phyinfo { 541struct bcm43xx_phyinfo {
544 /* Hardware Data */ 542 /* Hardware Data */
545 u8 version; 543 u8 analog;
546 u8 type; 544 u8 type;
547 u8 rev; 545 u8 rev;
548 u16 antenna_diversity; 546 u16 antenna_diversity;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_ilt.c b/drivers/net/wireless/bcm43xx/bcm43xx_ilt.c
index ad8e569d1faf..f2b8dbac55a4 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_ilt.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_ilt.c
@@ -325,6 +325,21 @@ void bcm43xx_ilt_write(struct bcm43xx_private *bcm, u16 offset, u16 val)
325 } 325 }
326} 326}
327 327
328void bcm43xx_ilt_write32(struct bcm43xx_private *bcm, u16 offset, u32 val)
329{
330 if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A) {
331 bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset);
332 mmiowb();
333 bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_DATA2, (val & 0xFFFF0000) >> 16);
334 bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_DATA1, val & 0x0000FFFF);
335 } else {
336 bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_CTRL, offset);
337 mmiowb();
338 bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_DATA2, (val & 0xFFFF0000) >> 16);
339 bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_G_DATA1, val & 0x0000FFFF);
340 }
341}
342
328u16 bcm43xx_ilt_read(struct bcm43xx_private *bcm, u16 offset) 343u16 bcm43xx_ilt_read(struct bcm43xx_private *bcm, u16 offset)
329{ 344{
330 if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A) { 345 if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A) {
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_ilt.h b/drivers/net/wireless/bcm43xx/bcm43xx_ilt.h
index 464521abf73c..d7eaf5f25b7f 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_ilt.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_ilt.h
@@ -27,6 +27,7 @@ extern const u16 bcm43xx_ilt_sigmasqr2[BCM43xx_ILT_SIGMASQR_SIZE];
27 27
28 28
29void bcm43xx_ilt_write(struct bcm43xx_private *bcm, u16 offset, u16 val); 29void bcm43xx_ilt_write(struct bcm43xx_private *bcm, u16 offset, u16 val);
30void bcm43xx_ilt_write32(struct bcm43xx_private *bcm, u16 offset, u32 val);
30u16 bcm43xx_ilt_read(struct bcm43xx_private *bcm, u16 offset); 31u16 bcm43xx_ilt_read(struct bcm43xx_private *bcm, u16 offset);
31 32
32#endif /* BCM43xx_ILT_H_ */ 33#endif /* BCM43xx_ILT_H_ */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 2e400aacc436..73c831a3b747 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -851,8 +851,6 @@ static int bcm43xx_sprom_extract(struct bcm43xx_private *bcm)
851 value = sprom[BCM43xx_SPROM_ETHPHY]; 851 value = sprom[BCM43xx_SPROM_ETHPHY];
852 bcm->sprom.et0phyaddr = (value & 0x001F); 852 bcm->sprom.et0phyaddr = (value & 0x001F);
853 bcm->sprom.et1phyaddr = (value & 0x03E0) >> 5; 853 bcm->sprom.et1phyaddr = (value & 0x03E0) >> 5;
854 bcm->sprom.et0mdcport = (value & (1 << 14)) >> 14;
855 bcm->sprom.et1mdcport = (value & (1 << 15)) >> 15;
856 854
857 /* boardrev, antennas, locale */ 855 /* boardrev, antennas, locale */
858 value = sprom[BCM43xx_SPROM_BOARDREV]; 856 value = sprom[BCM43xx_SPROM_BOARDREV];
@@ -1449,12 +1447,10 @@ static void handle_irq_transmit_status(struct bcm43xx_private *bcm)
1449 1447
1450 bcm43xx_debugfs_log_txstat(bcm, &stat); 1448 bcm43xx_debugfs_log_txstat(bcm, &stat);
1451 1449
1452 if (stat.flags & BCM43xx_TXSTAT_FLAG_IGNORE) 1450 if (stat.flags & BCM43xx_TXSTAT_FLAG_AMPDU)
1451 continue;
1452 if (stat.flags & BCM43xx_TXSTAT_FLAG_INTER)
1453 continue; 1453 continue;
1454 if (!(stat.flags & BCM43xx_TXSTAT_FLAG_ACK)) {
1455 //TODO: packet was not acked (was lost)
1456 }
1457 //TODO: There are more (unknown) flags to test. see bcm43xx_main.h
1458 1454
1459 if (bcm43xx_using_pio(bcm)) 1455 if (bcm43xx_using_pio(bcm))
1460 bcm43xx_pio_handle_xmitstatus(bcm, &stat); 1456 bcm43xx_pio_handle_xmitstatus(bcm, &stat);
@@ -3696,7 +3692,7 @@ static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm)
3696{ 3692{
3697 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); 3693 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
3698 u16 value; 3694 u16 value;
3699 u8 phy_version; 3695 u8 phy_analog;
3700 u8 phy_type; 3696 u8 phy_type;
3701 u8 phy_rev; 3697 u8 phy_rev;
3702 int phy_rev_ok = 1; 3698 int phy_rev_ok = 1;
@@ -3704,12 +3700,12 @@ static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm)
3704 3700
3705 value = bcm43xx_read16(bcm, BCM43xx_MMIO_PHY_VER); 3701 value = bcm43xx_read16(bcm, BCM43xx_MMIO_PHY_VER);
3706 3702
3707 phy_version = (value & 0xF000) >> 12; 3703 phy_analog = (value & 0xF000) >> 12;
3708 phy_type = (value & 0x0F00) >> 8; 3704 phy_type = (value & 0x0F00) >> 8;
3709 phy_rev = (value & 0x000F); 3705 phy_rev = (value & 0x000F);
3710 3706
3711 dprintk(KERN_INFO PFX "Detected PHY: Version: %x, Type %x, Revision %x\n", 3707 dprintk(KERN_INFO PFX "Detected PHY: Analog: %x, Type %x, Revision %x\n",
3712 phy_version, phy_type, phy_rev); 3708 phy_analog, phy_type, phy_rev);
3713 3709
3714 switch (phy_type) { 3710 switch (phy_type) {
3715 case BCM43xx_PHYTYPE_A: 3711 case BCM43xx_PHYTYPE_A:
@@ -3752,7 +3748,7 @@ static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm)
3752 phy_rev); 3748 phy_rev);
3753 } 3749 }
3754 3750
3755 phy->version = phy_version; 3751 phy->analog = phy_analog;
3756 phy->type = phy_type; 3752 phy->type = phy_type;
3757 phy->rev = phy_rev; 3753 phy->rev = phy_rev;
3758 if ((phy_type == BCM43xx_PHYTYPE_B) || (phy_type == BCM43xx_PHYTYPE_G)) { 3754 if ((phy_type == BCM43xx_PHYTYPE_B) || (phy_type == BCM43xx_PHYTYPE_G)) {
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
index 52ce2a9334fb..3a5c9c2b2150 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
@@ -205,8 +205,8 @@ static void bcm43xx_phy_init_pctl(struct bcm43xx_private *bcm)
205 (bcm->board_type == 0x0416)) 205 (bcm->board_type == 0x0416))
206 return; 206 return;
207 207
208 bcm43xx_write16(bcm, 0x03E6, bcm43xx_read16(bcm, 0x03E6) & 0xFFDF);
209 bcm43xx_phy_write(bcm, 0x0028, 0x8018); 208 bcm43xx_phy_write(bcm, 0x0028, 0x8018);
209 bcm43xx_write16(bcm, 0x03E6, bcm43xx_read16(bcm, 0x03E6) & 0xFFDF);
210 210
211 if (phy->type == BCM43xx_PHYTYPE_G) { 211 if (phy->type == BCM43xx_PHYTYPE_G) {
212 if (!phy->connected) 212 if (!phy->connected)
@@ -317,6 +317,13 @@ static void bcm43xx_phy_agcsetup(struct bcm43xx_private *bcm)
317 bcm43xx_ilt_write(bcm, offset + 0x0801, 7); 317 bcm43xx_ilt_write(bcm, offset + 0x0801, 7);
318 bcm43xx_ilt_write(bcm, offset + 0x0802, 16); 318 bcm43xx_ilt_write(bcm, offset + 0x0802, 16);
319 bcm43xx_ilt_write(bcm, offset + 0x0803, 28); 319 bcm43xx_ilt_write(bcm, offset + 0x0803, 28);
320
321 if (phy->rev >= 6) {
322 bcm43xx_phy_write(bcm, 0x0426, (bcm43xx_phy_read(bcm, 0x0426)
323 & 0xFFFC));
324 bcm43xx_phy_write(bcm, 0x0426, (bcm43xx_phy_read(bcm, 0x0426)
325 & 0xEFFF));
326 }
320} 327}
321 328
322static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm) 329static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
@@ -337,7 +344,7 @@ static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
337 for (i = 0; i < BCM43xx_ILT_NOISEG1_SIZE; i++) 344 for (i = 0; i < BCM43xx_ILT_NOISEG1_SIZE; i++)
338 bcm43xx_ilt_write(bcm, 0x1800 + i, bcm43xx_ilt_noiseg1[i]); 345 bcm43xx_ilt_write(bcm, 0x1800 + i, bcm43xx_ilt_noiseg1[i]);
339 for (i = 0; i < BCM43xx_ILT_ROTOR_SIZE; i++) 346 for (i = 0; i < BCM43xx_ILT_ROTOR_SIZE; i++)
340 bcm43xx_ilt_write(bcm, 0x2000 + i, bcm43xx_ilt_rotor[i]); 347 bcm43xx_ilt_write32(bcm, 0x2000 + i, bcm43xx_ilt_rotor[i]);
341 } else { 348 } else {
342 /* nrssi values are signed 6-bit values. Not sure why we write 0x7654 here... */ 349 /* nrssi values are signed 6-bit values. Not sure why we write 0x7654 here... */
343 bcm43xx_nrssi_hw_write(bcm, 0xBA98, (s16)0x7654); 350 bcm43xx_nrssi_hw_write(bcm, 0xBA98, (s16)0x7654);
@@ -377,7 +384,7 @@ static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
377 384
378 if (phy->rev == 1) { 385 if (phy->rev == 1) {
379 for (i = 0; i < BCM43xx_ILT_RETARD_SIZE; i++) 386 for (i = 0; i < BCM43xx_ILT_RETARD_SIZE; i++)
380 bcm43xx_ilt_write(bcm, 0x2400 + i, bcm43xx_ilt_retard[i]); 387 bcm43xx_ilt_write32(bcm, 0x2400 + i, bcm43xx_ilt_retard[i]);
381 for (i = 0; i < 4; i++) { 388 for (i = 0; i < 4; i++) {
382 bcm43xx_ilt_write(bcm, 0x5404 + i, 0x0020); 389 bcm43xx_ilt_write(bcm, 0x5404 + i, 0x0020);
383 bcm43xx_ilt_write(bcm, 0x5408 + i, 0x0020); 390 bcm43xx_ilt_write(bcm, 0x5408 + i, 0x0020);
@@ -500,10 +507,10 @@ static void bcm43xx_phy_setupa(struct bcm43xx_private *bcm)
500 for (i = 0; i < BCM43xx_ILT_NOISEA2_SIZE; i++) 507 for (i = 0; i < BCM43xx_ILT_NOISEA2_SIZE; i++)
501 bcm43xx_ilt_write(bcm, 0x1800 + i, bcm43xx_ilt_noisea2[i]); 508 bcm43xx_ilt_write(bcm, 0x1800 + i, bcm43xx_ilt_noisea2[i]);
502 for (i = 0; i < BCM43xx_ILT_ROTOR_SIZE; i++) 509 for (i = 0; i < BCM43xx_ILT_ROTOR_SIZE; i++)
503 bcm43xx_ilt_write(bcm, 0x2000 + i, bcm43xx_ilt_rotor[i]); 510 bcm43xx_ilt_write32(bcm, 0x2000 + i, bcm43xx_ilt_rotor[i]);
504 bcm43xx_phy_init_noisescaletbl(bcm); 511 bcm43xx_phy_init_noisescaletbl(bcm);
505 for (i = 0; i < BCM43xx_ILT_RETARD_SIZE; i++) 512 for (i = 0; i < BCM43xx_ILT_RETARD_SIZE; i++)
506 bcm43xx_ilt_write(bcm, 0x2400 + i, bcm43xx_ilt_retard[i]); 513 bcm43xx_ilt_write32(bcm, 0x2400 + i, bcm43xx_ilt_retard[i]);
507 break; 514 break;
508 case 3: 515 case 3:
509 for (i = 0; i < 64; i++) 516 for (i = 0; i < 64; i++)
@@ -729,19 +736,19 @@ static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm)
729 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); 736 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
730 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm); 737 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
731 u16 offset; 738 u16 offset;
739 u16 value;
740 u8 old_channel;
732 741
733 if (phy->version == 1 && 742 if (phy->analog == 1)
734 radio->version == 0x2050) {
735 bcm43xx_radio_write16(bcm, 0x007A, 743 bcm43xx_radio_write16(bcm, 0x007A,
736 bcm43xx_radio_read16(bcm, 0x007A) 744 bcm43xx_radio_read16(bcm, 0x007A)
737 | 0x0050); 745 | 0x0050);
738 }
739 if ((bcm->board_vendor != PCI_VENDOR_ID_BROADCOM) && 746 if ((bcm->board_vendor != PCI_VENDOR_ID_BROADCOM) &&
740 (bcm->board_type != 0x0416)) { 747 (bcm->board_type != 0x0416)) {
748 value = 0x2120;
741 for (offset = 0x00A8 ; offset < 0x00C7; offset++) { 749 for (offset = 0x00A8 ; offset < 0x00C7; offset++) {
742 bcm43xx_phy_write(bcm, offset, 750 bcm43xx_phy_write(bcm, offset, value);
743 (bcm43xx_phy_read(bcm, offset) + 0x2020) 751 value += 0x0202;
744 & 0x3F3F);
745 } 752 }
746 } 753 }
747 bcm43xx_phy_write(bcm, 0x0035, 754 bcm43xx_phy_write(bcm, 0x0035,
@@ -750,7 +757,7 @@ static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm)
750 if (radio->version == 0x2050) 757 if (radio->version == 0x2050)
751 bcm43xx_phy_write(bcm, 0x0038, 0x0667); 758 bcm43xx_phy_write(bcm, 0x0038, 0x0667);
752 759
753 if (phy->connected) { 760 if (phy->type == BCM43xx_PHYTYPE_G) {
754 if (radio->version == 0x2050) { 761 if (radio->version == 0x2050) {
755 bcm43xx_radio_write16(bcm, 0x007A, 762 bcm43xx_radio_write16(bcm, 0x007A,
756 bcm43xx_radio_read16(bcm, 0x007A) 763 bcm43xx_radio_read16(bcm, 0x007A)
@@ -776,7 +783,7 @@ static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm)
776 bcm43xx_phy_read(bcm, BCM43xx_PHY_RADIO_BITFIELD) | (1 << 11)); 783 bcm43xx_phy_read(bcm, BCM43xx_PHY_RADIO_BITFIELD) | (1 << 11));
777 } 784 }
778 785
779 if (phy->version == 1 && radio->version == 0x2050) { 786 if (phy->analog == 1) {
780 bcm43xx_phy_write(bcm, 0x0026, 0xCE00); 787 bcm43xx_phy_write(bcm, 0x0026, 0xCE00);
781 bcm43xx_phy_write(bcm, 0x0021, 0x3763); 788 bcm43xx_phy_write(bcm, 0x0021, 0x3763);
782 bcm43xx_phy_write(bcm, 0x0022, 0x1BC3); 789 bcm43xx_phy_write(bcm, 0x0022, 0x1BC3);
@@ -787,14 +794,15 @@ static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm)
787 bcm43xx_phy_write(bcm, 0x0030, 0x00C6); 794 bcm43xx_phy_write(bcm, 0x0030, 0x00C6);
788 bcm43xx_write16(bcm, 0x03EC, 0x3F22); 795 bcm43xx_write16(bcm, 0x03EC, 0x3F22);
789 796
790 if (phy->version == 1 && radio->version == 0x2050) 797 if (phy->analog == 1)
791 bcm43xx_phy_write(bcm, 0x0020, 0x3E1C); 798 bcm43xx_phy_write(bcm, 0x0020, 0x3E1C);
792 else 799 else
793 bcm43xx_phy_write(bcm, 0x0020, 0x301C); 800 bcm43xx_phy_write(bcm, 0x0020, 0x301C);
794 801
795 if (phy->version == 0) 802 if (phy->analog == 0)
796 bcm43xx_write16(bcm, 0x03E4, 0x3000); 803 bcm43xx_write16(bcm, 0x03E4, 0x3000);
797 804
805 old_channel = radio->channel;
798 /* Force to channel 7, even if not supported. */ 806 /* Force to channel 7, even if not supported. */
799 bcm43xx_radio_selectchannel(bcm, 7, 0); 807 bcm43xx_radio_selectchannel(bcm, 7, 0);
800 808
@@ -816,11 +824,11 @@ static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm)
816 824
817 bcm43xx_radio_write16(bcm, 0x007A, bcm43xx_radio_read16(bcm, 0x007A) | 0x0007); 825 bcm43xx_radio_write16(bcm, 0x007A, bcm43xx_radio_read16(bcm, 0x007A) | 0x0007);
818 826
819 bcm43xx_radio_selectchannel(bcm, BCM43xx_RADIO_DEFAULT_CHANNEL_BG, 0); 827 bcm43xx_radio_selectchannel(bcm, old_channel, 0);
820 828
821 bcm43xx_phy_write(bcm, 0x0014, 0x0080); 829 bcm43xx_phy_write(bcm, 0x0014, 0x0080);
822 bcm43xx_phy_write(bcm, 0x0032, 0x00CA); 830 bcm43xx_phy_write(bcm, 0x0032, 0x00CA);
823 bcm43xx_phy_write(bcm, 0x88A3, 0x002A); 831 bcm43xx_phy_write(bcm, 0x002A, 0x88A3);
824 832
825 bcm43xx_radio_set_txpower_bg(bcm, 0xFFFF, 0xFFFF, 0xFFFF); 833 bcm43xx_radio_set_txpower_bg(bcm, 0xFFFF, 0xFFFF, 0xFFFF);
826 834
@@ -835,61 +843,24 @@ static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm)
835 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); 843 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
836 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm); 844 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
837 u16 offset, val; 845 u16 offset, val;
846 u8 old_channel;
838 847
839 bcm43xx_phy_write(bcm, 0x003E, 0x817A); 848 bcm43xx_phy_write(bcm, 0x003E, 0x817A);
840 bcm43xx_radio_write16(bcm, 0x007A, 849 bcm43xx_radio_write16(bcm, 0x007A,
841 (bcm43xx_radio_read16(bcm, 0x007A) | 0x0058)); 850 (bcm43xx_radio_read16(bcm, 0x007A) | 0x0058));
842 if ((radio->manufact == 0x17F) && 851 if (radio->revision == 4 ||
843 (radio->version == 0x2050) && 852 radio->revision == 5) {
844 (radio->revision == 3 || 853 bcm43xx_radio_write16(bcm, 0x0051, 0x0037);
845 radio->revision == 4 || 854 bcm43xx_radio_write16(bcm, 0x0052, 0x0070);
846 radio->revision == 5)) { 855 bcm43xx_radio_write16(bcm, 0x0053, 0x00B3);
847 bcm43xx_radio_write16(bcm, 0x0051, 0x001F); 856 bcm43xx_radio_write16(bcm, 0x0054, 0x009B);
848 bcm43xx_radio_write16(bcm, 0x0052, 0x0040);
849 bcm43xx_radio_write16(bcm, 0x0053, 0x005B);
850 bcm43xx_radio_write16(bcm, 0x0054, 0x0098);
851 bcm43xx_radio_write16(bcm, 0x005A, 0x0088); 857 bcm43xx_radio_write16(bcm, 0x005A, 0x0088);
852 bcm43xx_radio_write16(bcm, 0x005B, 0x0088); 858 bcm43xx_radio_write16(bcm, 0x005B, 0x0088);
853 bcm43xx_radio_write16(bcm, 0x005D, 0x0088); 859 bcm43xx_radio_write16(bcm, 0x005D, 0x0088);
854 bcm43xx_radio_write16(bcm, 0x005E, 0x0088); 860 bcm43xx_radio_write16(bcm, 0x005E, 0x0088);
855 bcm43xx_radio_write16(bcm, 0x007D, 0x0088); 861 bcm43xx_radio_write16(bcm, 0x007D, 0x0088);
856 } 862 }
857 if ((radio->manufact == 0x17F) && 863 if (radio->revision == 8) {
858 (radio->version == 0x2050) &&
859 (radio->revision == 6)) {
860 bcm43xx_radio_write16(bcm, 0x0051, 0x0000);
861 bcm43xx_radio_write16(bcm, 0x0052, 0x0040);
862 bcm43xx_radio_write16(bcm, 0x0053, 0x00B7);
863 bcm43xx_radio_write16(bcm, 0x0054, 0x0098);
864 bcm43xx_radio_write16(bcm, 0x005A, 0x0088);
865 bcm43xx_radio_write16(bcm, 0x005B, 0x008B);
866 bcm43xx_radio_write16(bcm, 0x005C, 0x00B5);
867 bcm43xx_radio_write16(bcm, 0x005D, 0x0088);
868 bcm43xx_radio_write16(bcm, 0x005E, 0x0088);
869 bcm43xx_radio_write16(bcm, 0x007D, 0x0088);
870 bcm43xx_radio_write16(bcm, 0x007C, 0x0001);
871 bcm43xx_radio_write16(bcm, 0x007E, 0x0008);
872 }
873 if ((radio->manufact == 0x17F) &&
874 (radio->version == 0x2050) &&
875 (radio->revision == 7)) {
876 bcm43xx_radio_write16(bcm, 0x0051, 0x0000);
877 bcm43xx_radio_write16(bcm, 0x0052, 0x0040);
878 bcm43xx_radio_write16(bcm, 0x0053, 0x00B7);
879 bcm43xx_radio_write16(bcm, 0x0054, 0x0098);
880 bcm43xx_radio_write16(bcm, 0x005A, 0x0088);
881 bcm43xx_radio_write16(bcm, 0x005B, 0x00A8);
882 bcm43xx_radio_write16(bcm, 0x005C, 0x0075);
883 bcm43xx_radio_write16(bcm, 0x005D, 0x00F5);
884 bcm43xx_radio_write16(bcm, 0x005E, 0x00B8);
885 bcm43xx_radio_write16(bcm, 0x007D, 0x00E8);
886 bcm43xx_radio_write16(bcm, 0x007C, 0x0001);
887 bcm43xx_radio_write16(bcm, 0x007E, 0x0008);
888 bcm43xx_radio_write16(bcm, 0x007B, 0x0000);
889 }
890 if ((radio->manufact == 0x17F) &&
891 (radio->version == 0x2050) &&
892 (radio->revision == 8)) {
893 bcm43xx_radio_write16(bcm, 0x0051, 0x0000); 864 bcm43xx_radio_write16(bcm, 0x0051, 0x0000);
894 bcm43xx_radio_write16(bcm, 0x0052, 0x0040); 865 bcm43xx_radio_write16(bcm, 0x0052, 0x0040);
895 bcm43xx_radio_write16(bcm, 0x0053, 0x00B7); 866 bcm43xx_radio_write16(bcm, 0x0053, 0x00B7);
@@ -933,20 +904,26 @@ static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm)
933 bcm43xx_phy_read(bcm, 0x0802) | 0x0100); 904 bcm43xx_phy_read(bcm, 0x0802) | 0x0100);
934 bcm43xx_phy_write(bcm, 0x042B, 905 bcm43xx_phy_write(bcm, 0x042B,
935 bcm43xx_phy_read(bcm, 0x042B) | 0x2000); 906 bcm43xx_phy_read(bcm, 0x042B) | 0x2000);
907 bcm43xx_phy_write(bcm, 0x5B, 0x0000);
908 bcm43xx_phy_write(bcm, 0x5C, 0x0000);
936 } 909 }
937 910
938 /* Force to channel 7, even if not supported. */ 911 old_channel = radio->channel;
939 bcm43xx_radio_selectchannel(bcm, 7, 0); 912 if (old_channel >= 8)
913 bcm43xx_radio_selectchannel(bcm, 1, 0);
914 else
915 bcm43xx_radio_selectchannel(bcm, 13, 0);
940 916
941 bcm43xx_radio_write16(bcm, 0x0050, 0x0020); 917 bcm43xx_radio_write16(bcm, 0x0050, 0x0020);
942 bcm43xx_radio_write16(bcm, 0x0050, 0x0023); 918 bcm43xx_radio_write16(bcm, 0x0050, 0x0023);
943 udelay(40); 919 udelay(40);
944 bcm43xx_radio_write16(bcm, 0x007C, (bcm43xx_radio_read16(bcm, 0x007C) | 0x0002)); 920 if (radio->revision < 6 || radio-> revision == 8) {
945 bcm43xx_radio_write16(bcm, 0x0050, 0x0020); 921 bcm43xx_radio_write16(bcm, 0x007C, (bcm43xx_radio_read16(bcm, 0x007C)
946 if (radio->manufact == 0x17F && 922 | 0x0002));
947 radio->version == 0x2050 &&
948 radio->revision <= 2) {
949 bcm43xx_radio_write16(bcm, 0x0050, 0x0020); 923 bcm43xx_radio_write16(bcm, 0x0050, 0x0020);
924 }
925 if (radio->revision <= 2) {
926 bcm43xx_radio_write16(bcm, 0x007C, 0x0020);
950 bcm43xx_radio_write16(bcm, 0x005A, 0x0070); 927 bcm43xx_radio_write16(bcm, 0x005A, 0x0070);
951 bcm43xx_radio_write16(bcm, 0x005B, 0x007B); 928 bcm43xx_radio_write16(bcm, 0x005B, 0x007B);
952 bcm43xx_radio_write16(bcm, 0x005C, 0x00B0); 929 bcm43xx_radio_write16(bcm, 0x005C, 0x00B0);
@@ -954,46 +931,41 @@ static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm)
954 bcm43xx_radio_write16(bcm, 0x007A, 931 bcm43xx_radio_write16(bcm, 0x007A,
955 (bcm43xx_radio_read16(bcm, 0x007A) & 0x00F8) | 0x0007); 932 (bcm43xx_radio_read16(bcm, 0x007A) & 0x00F8) | 0x0007);
956 933
957 bcm43xx_radio_selectchannel(bcm, BCM43xx_RADIO_DEFAULT_CHANNEL_BG, 0); 934 bcm43xx_radio_selectchannel(bcm, old_channel, 0);
958 935
959 bcm43xx_phy_write(bcm, 0x0014, 0x0200); 936 bcm43xx_phy_write(bcm, 0x0014, 0x0200);
960 if (radio->version == 0x2050){ 937 if (radio->revision >= 6)
961 if (radio->revision == 3 || 938 bcm43xx_phy_write(bcm, 0x002A, 0x88C2);
962 radio->revision == 4 || 939 else
963 radio->revision == 5) 940 bcm43xx_phy_write(bcm, 0x002A, 0x8AC0);
964 bcm43xx_phy_write(bcm, 0x002A, 0x8AC0);
965 else
966 bcm43xx_phy_write(bcm, 0x002A, 0x88C2);
967 }
968 bcm43xx_phy_write(bcm, 0x0038, 0x0668); 941 bcm43xx_phy_write(bcm, 0x0038, 0x0668);
969 bcm43xx_radio_set_txpower_bg(bcm, 0xFFFF, 0xFFFF, 0xFFFF); 942 bcm43xx_radio_set_txpower_bg(bcm, 0xFFFF, 0xFFFF, 0xFFFF);
970 if (radio->version == 0x2050) { 943 if (radio->revision <= 5)
971 if (radio->revision == 3 || 944 bcm43xx_phy_write(bcm, 0x005D, bcm43xx_phy_read(bcm, 0x005D) | 0x0003);
972 radio->revision == 4 || 945 if (radio->revision <= 2)
973 radio->revision == 5) 946 bcm43xx_radio_write16(bcm, 0x005D, 0x000D);
974 bcm43xx_phy_write(bcm, 0x005D, bcm43xx_phy_read(bcm, 0x005D) | 0x0003);
975 else if (radio->revision <= 2)
976 bcm43xx_radio_write16(bcm, 0x005D, 0x000D);
977 }
978 947
979 if (phy->rev == 4) 948 if (phy->analog == 4){
980 bcm43xx_phy_write(bcm, 0x0002, (bcm43xx_phy_read(bcm, 0x0002) & 0xFFC0) | 0x0004);
981 else
982 bcm43xx_write16(bcm, 0x03E4, 0x0009); 949 bcm43xx_write16(bcm, 0x03E4, 0x0009);
950 bcm43xx_phy_write(bcm, 0x61, bcm43xx_phy_read(bcm, 0x61) & 0xFFF);
951 } else {
952 bcm43xx_phy_write(bcm, 0x0002, (bcm43xx_phy_read(bcm, 0x0002) & 0xFFC0) | 0x0004);
953 }
954 if (phy->type == BCM43xx_PHYTYPE_G)
955 bcm43xx_write16(bcm, 0x03E6, 0x0);
983 if (phy->type == BCM43xx_PHYTYPE_B) { 956 if (phy->type == BCM43xx_PHYTYPE_B) {
984 bcm43xx_write16(bcm, 0x03E6, 0x8140); 957 bcm43xx_write16(bcm, 0x03E6, 0x8140);
985 bcm43xx_phy_write(bcm, 0x0016, 0x0410); 958 bcm43xx_phy_write(bcm, 0x0016, 0x0410);
986 bcm43xx_phy_write(bcm, 0x0017, 0x0820); 959 bcm43xx_phy_write(bcm, 0x0017, 0x0820);
987 bcm43xx_phy_write(bcm, 0x0062, 0x0007); 960 bcm43xx_phy_write(bcm, 0x0062, 0x0007);
988 (void) bcm43xx_radio_calibrationvalue(bcm); 961 (void) bcm43xx_radio_calibrationvalue(bcm);
989 bcm43xx_phy_lo_b_measure(bcm); 962 bcm43xx_phy_lo_g_measure(bcm);
990 if (bcm->sprom.boardflags & BCM43xx_BFL_RSSI) { 963 if (bcm->sprom.boardflags & BCM43xx_BFL_RSSI) {
991 bcm43xx_calc_nrssi_slope(bcm); 964 bcm43xx_calc_nrssi_slope(bcm);
992 bcm43xx_calc_nrssi_threshold(bcm); 965 bcm43xx_calc_nrssi_threshold(bcm);
993 } 966 }
994 bcm43xx_phy_init_pctl(bcm); 967 bcm43xx_phy_init_pctl(bcm);
995 } else 968 }
996 bcm43xx_write16(bcm, 0x03E6, 0x0);
997} 969}
998 970
999static void bcm43xx_calc_loopback_gain(struct bcm43xx_private *bcm) 971static void bcm43xx_calc_loopback_gain(struct bcm43xx_private *bcm)
@@ -1063,7 +1035,7 @@ static void bcm43xx_calc_loopback_gain(struct bcm43xx_private *bcm)
1063 bcm43xx_phy_write(bcm, 0x005A, 0x0780); 1035 bcm43xx_phy_write(bcm, 0x005A, 0x0780);
1064 bcm43xx_phy_write(bcm, 0x0059, 0xC810); 1036 bcm43xx_phy_write(bcm, 0x0059, 0xC810);
1065 bcm43xx_phy_write(bcm, 0x0058, 0x000D); 1037 bcm43xx_phy_write(bcm, 0x0058, 0x000D);
1066 if (phy->version == 0) { 1038 if (phy->analog == 0) {
1067 bcm43xx_phy_write(bcm, 0x0003, 0x0122); 1039 bcm43xx_phy_write(bcm, 0x0003, 0x0122);
1068 } else { 1040 } else {
1069 bcm43xx_phy_write(bcm, 0x000A, 1041 bcm43xx_phy_write(bcm, 0x000A,
@@ -1205,27 +1177,30 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1205 if (phy->rev >= 2) { 1177 if (phy->rev >= 2) {
1206 bcm43xx_phy_write(bcm, 0x0814, 0x0000); 1178 bcm43xx_phy_write(bcm, 0x0814, 0x0000);
1207 bcm43xx_phy_write(bcm, 0x0815, 0x0000); 1179 bcm43xx_phy_write(bcm, 0x0815, 0x0000);
1208 if (phy->rev == 2) 1180 }
1209 bcm43xx_phy_write(bcm, 0x0811, 0x0000); 1181 if (phy->rev == 2) {
1210 else if (phy->rev >= 3) 1182 bcm43xx_phy_write(bcm, 0x0811, 0x0000);
1211 bcm43xx_phy_write(bcm, 0x0811, 0x0400);
1212 bcm43xx_phy_write(bcm, 0x0015, 0x00C0); 1183 bcm43xx_phy_write(bcm, 0x0015, 0x00C0);
1213 if (phy->connected) { 1184 }
1214 tmp = bcm43xx_phy_read(bcm, 0x0400) & 0xFF; 1185 if (phy->rev >= 3) {
1215 if (tmp < 6) { 1186 bcm43xx_phy_write(bcm, 0x0811, 0x0400);
1216 bcm43xx_phy_write(bcm, 0x04C2, 0x1816); 1187 bcm43xx_phy_write(bcm, 0x0015, 0x00C0);
1217 bcm43xx_phy_write(bcm, 0x04C3, 0x8006); 1188 }
1218 if (tmp != 3) { 1189 if (phy->connected) {
1219 bcm43xx_phy_write(bcm, 0x04CC, 1190 tmp = bcm43xx_phy_read(bcm, 0x0400) & 0xFF;
1220 (bcm43xx_phy_read(bcm, 0x04CC) 1191 if (tmp < 6) {
1221 & 0x00FF) | 0x1F00); 1192 bcm43xx_phy_write(bcm, 0x04C2, 0x1816);
1222 } 1193 bcm43xx_phy_write(bcm, 0x04C3, 0x8006);
1194 if (tmp != 3) {
1195 bcm43xx_phy_write(bcm, 0x04CC,
1196 (bcm43xx_phy_read(bcm, 0x04CC)
1197 & 0x00FF) | 0x1F00);
1223 } 1198 }
1224 } 1199 }
1225 } 1200 }
1226 if (phy->rev < 3 && phy->connected) 1201 if (phy->rev < 3 && phy->connected)
1227 bcm43xx_phy_write(bcm, 0x047E, 0x0078); 1202 bcm43xx_phy_write(bcm, 0x047E, 0x0078);
1228 if (phy->rev >= 6 && phy->rev <= 8) { 1203 if (radio->revision == 8) {
1229 bcm43xx_phy_write(bcm, 0x0801, bcm43xx_phy_read(bcm, 0x0801) | 0x0080); 1204 bcm43xx_phy_write(bcm, 0x0801, bcm43xx_phy_read(bcm, 0x0801) | 0x0080);
1230 bcm43xx_phy_write(bcm, 0x043E, bcm43xx_phy_read(bcm, 0x043E) | 0x0004); 1205 bcm43xx_phy_write(bcm, 0x043E, bcm43xx_phy_read(bcm, 0x043E) | 0x0004);
1231 } 1206 }
@@ -1638,14 +1613,14 @@ void bcm43xx_phy_set_baseband_attenuation(struct bcm43xx_private *bcm,
1638 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); 1613 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
1639 u16 value; 1614 u16 value;
1640 1615
1641 if (phy->version == 0) { 1616 if (phy->analog == 0) {
1642 value = (bcm43xx_read16(bcm, 0x03E6) & 0xFFF0); 1617 value = (bcm43xx_read16(bcm, 0x03E6) & 0xFFF0);
1643 value |= (baseband_attenuation & 0x000F); 1618 value |= (baseband_attenuation & 0x000F);
1644 bcm43xx_write16(bcm, 0x03E6, value); 1619 bcm43xx_write16(bcm, 0x03E6, value);
1645 return; 1620 return;
1646 } 1621 }
1647 1622
1648 if (phy->version > 1) { 1623 if (phy->analog > 1) {
1649 value = bcm43xx_phy_read(bcm, 0x0060) & ~0x003C; 1624 value = bcm43xx_phy_read(bcm, 0x0060) & ~0x003C;
1650 value |= (baseband_attenuation << 2) & 0x003C; 1625 value |= (baseband_attenuation << 2) & 0x003C;
1651 } else { 1626 } else {
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
index af19a07032a3..32beb91b7164 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
@@ -1393,11 +1393,12 @@ u16 bcm43xx_radio_init2050(struct bcm43xx_private *bcm)
1393 backup[12] = bcm43xx_read16(bcm, BCM43xx_MMIO_CHANNEL_EXT); 1393 backup[12] = bcm43xx_read16(bcm, BCM43xx_MMIO_CHANNEL_EXT);
1394 1394
1395 // Initialization 1395 // Initialization
1396 if (phy->version == 0) { 1396 if (phy->analog == 0) {
1397 bcm43xx_write16(bcm, 0x03E6, 0x0122); 1397 bcm43xx_write16(bcm, 0x03E6, 0x0122);
1398 } else { 1398 } else {
1399 if (phy->version >= 2) 1399 if (phy->analog >= 2)
1400 bcm43xx_write16(bcm, 0x03E6, 0x0040); 1400 bcm43xx_phy_write(bcm, 0x0003, (bcm43xx_phy_read(bcm, 0x0003)
1401 & 0xFFBF) | 0x0040);
1401 bcm43xx_write16(bcm, BCM43xx_MMIO_CHANNEL_EXT, 1402 bcm43xx_write16(bcm, BCM43xx_MMIO_CHANNEL_EXT,
1402 (bcm43xx_read16(bcm, BCM43xx_MMIO_CHANNEL_EXT) | 0x2000)); 1403 (bcm43xx_read16(bcm, BCM43xx_MMIO_CHANNEL_EXT) | 0x2000));
1403 } 1404 }
@@ -1405,7 +1406,7 @@ u16 bcm43xx_radio_init2050(struct bcm43xx_private *bcm)
1405 ret = bcm43xx_radio_calibrationvalue(bcm); 1406 ret = bcm43xx_radio_calibrationvalue(bcm);
1406 1407
1407 if (phy->type == BCM43xx_PHYTYPE_B) 1408 if (phy->type == BCM43xx_PHYTYPE_B)
1408 bcm43xx_radio_write16(bcm, 0x0078, 0x0003); 1409 bcm43xx_radio_write16(bcm, 0x0078, 0x0026);
1409 1410
1410 bcm43xx_phy_write(bcm, 0x0015, 0xBFAF); 1411 bcm43xx_phy_write(bcm, 0x0015, 0xBFAF);
1411 bcm43xx_phy_write(bcm, 0x002B, 0x1403); 1412 bcm43xx_phy_write(bcm, 0x002B, 0x1403);
@@ -1416,7 +1417,7 @@ u16 bcm43xx_radio_init2050(struct bcm43xx_private *bcm)
1416 (bcm43xx_radio_read16(bcm, 0x0051) | 0x0004)); 1417 (bcm43xx_radio_read16(bcm, 0x0051) | 0x0004));
1417 bcm43xx_radio_write16(bcm, 0x0052, 0x0000); 1418 bcm43xx_radio_write16(bcm, 0x0052, 0x0000);
1418 bcm43xx_radio_write16(bcm, 0x0043, 1419 bcm43xx_radio_write16(bcm, 0x0043,
1419 bcm43xx_radio_read16(bcm, 0x0043) | 0x0009); 1420 (bcm43xx_radio_read16(bcm, 0x0043) & 0xFFF0) | 0x0009);
1420 bcm43xx_phy_write(bcm, 0x0058, 0x0000); 1421 bcm43xx_phy_write(bcm, 0x0058, 0x0000);
1421 1422
1422 for (i = 0; i < 16; i++) { 1423 for (i = 0; i < 16; i++) {
@@ -1488,7 +1489,7 @@ u16 bcm43xx_radio_init2050(struct bcm43xx_private *bcm)
1488 bcm43xx_phy_write(bcm, 0x0059, backup[17]); 1489 bcm43xx_phy_write(bcm, 0x0059, backup[17]);
1489 bcm43xx_phy_write(bcm, 0x0058, backup[18]); 1490 bcm43xx_phy_write(bcm, 0x0058, backup[18]);
1490 bcm43xx_write16(bcm, 0x03E6, backup[11]); 1491 bcm43xx_write16(bcm, 0x03E6, backup[11]);
1491 if (phy->version != 0) 1492 if (phy->analog != 0)
1492 bcm43xx_write16(bcm, BCM43xx_MMIO_CHANNEL_EXT, backup[12]); 1493 bcm43xx_write16(bcm, BCM43xx_MMIO_CHANNEL_EXT, backup[12]);
1493 bcm43xx_phy_write(bcm, 0x0035, backup[10]); 1494 bcm43xx_phy_write(bcm, 0x0035, backup[10]);
1494 bcm43xx_radio_selectchannel(bcm, radio->channel, 1); 1495 bcm43xx_radio_selectchannel(bcm, radio->channel, 1);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h
index 2aed19e35c77..9ecf2bf0d25d 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h
@@ -137,14 +137,8 @@ struct bcm43xx_xmitstatus {
137 u16 unknown; //FIXME 137 u16 unknown; //FIXME
138}; 138};
139 139
140#define BCM43xx_TXSTAT_FLAG_ACK 0x01 140#define BCM43xx_TXSTAT_FLAG_AMPDU 0x10
141//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x02 141#define BCM43xx_TXSTAT_FLAG_INTER 0x20
142//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x04
143//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x08
144//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x10
145#define BCM43xx_TXSTAT_FLAG_IGNORE 0x20
146//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x40
147//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x80
148 142
149u8 bcm43xx_plcp_get_ratecode_cck(const u8 bitrate); 143u8 bcm43xx_plcp_get_ratecode_cck(const u8 bitrate);
150u8 bcm43xx_plcp_get_ratecode_ofdm(const u8 bitrate); 144u8 bcm43xx_plcp_get_ratecode_ofdm(const u8 bitrate);
diff --git a/drivers/net/wireless/hostap/hostap.h b/drivers/net/wireless/hostap/hostap.h
index e89c890d16fd..ef37a75d550b 100644
--- a/drivers/net/wireless/hostap/hostap.h
+++ b/drivers/net/wireless/hostap/hostap.h
@@ -2,13 +2,14 @@
2#define HOSTAP_H 2#define HOSTAP_H
3 3
4#include <linux/ethtool.h> 4#include <linux/ethtool.h>
5#include <linux/kernel.h>
5 6
6#include "hostap_wlan.h" 7#include "hostap_wlan.h"
7#include "hostap_ap.h" 8#include "hostap_ap.h"
8 9
9static const long freq_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 10static const long freq_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
10 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; 11 2447, 2452, 2457, 2462, 2467, 2472, 2484 };
11#define FREQ_COUNT (sizeof(freq_list) / sizeof(freq_list[0])) 12#define FREQ_COUNT ARRAY_SIZE(freq_list)
12 13
13/* hostap.c */ 14/* hostap.c */
14 15
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index d0639a45cd2c..ad6e4a428355 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -2888,7 +2888,7 @@ static int __ipw2100_tx_process(struct ipw2100_priv *priv)
2888 2888
2889#ifdef CONFIG_IPW2100_DEBUG 2889#ifdef CONFIG_IPW2100_DEBUG
2890 if (packet->info.c_struct.cmd->host_command_reg < 2890 if (packet->info.c_struct.cmd->host_command_reg <
2891 sizeof(command_types) / sizeof(*command_types)) 2891 ARRAY_SIZE(command_types))
2892 IPW_DEBUG_TX("Command '%s (%d)' processed: %d.\n", 2892 IPW_DEBUG_TX("Command '%s (%d)' processed: %d.\n",
2893 command_types[packet->info.c_struct.cmd-> 2893 command_types[packet->info.c_struct.cmd->
2894 host_command_reg], 2894 host_command_reg],
@@ -3736,7 +3736,7 @@ static ssize_t show_registers(struct device *d, struct device_attribute *attr,
3736 3736
3737 out += sprintf(out, "%30s [Address ] : Hex\n", "Register"); 3737 out += sprintf(out, "%30s [Address ] : Hex\n", "Register");
3738 3738
3739 for (i = 0; i < (sizeof(hw_data) / sizeof(*hw_data)); i++) { 3739 for (i = 0; i < ARRAY_SIZE(hw_data); i++) {
3740 read_register(dev, hw_data[i].addr, &val); 3740 read_register(dev, hw_data[i].addr, &val);
3741 out += sprintf(out, "%30s [%08X] : %08X\n", 3741 out += sprintf(out, "%30s [%08X] : %08X\n",
3742 hw_data[i].name, hw_data[i].addr, val); 3742 hw_data[i].name, hw_data[i].addr, val);
@@ -3757,7 +3757,7 @@ static ssize_t show_hardware(struct device *d, struct device_attribute *attr,
3757 3757
3758 out += sprintf(out, "%30s [Address ] : Hex\n", "NIC entry"); 3758 out += sprintf(out, "%30s [Address ] : Hex\n", "NIC entry");
3759 3759
3760 for (i = 0; i < (sizeof(nic_data) / sizeof(*nic_data)); i++) { 3760 for (i = 0; i < ARRAY_SIZE(nic_data); i++) {
3761 u8 tmp8; 3761 u8 tmp8;
3762 u16 tmp16; 3762 u16 tmp16;
3763 u32 tmp32; 3763 u32 tmp32;
@@ -3894,13 +3894,11 @@ static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,
3894 if (priv->status & STATUS_RF_KILL_MASK) 3894 if (priv->status & STATUS_RF_KILL_MASK)
3895 return 0; 3895 return 0;
3896 3896
3897 if (loop >= sizeof(ord_data) / sizeof(*ord_data)) 3897 if (loop >= ARRAY_SIZE(ord_data))
3898 loop = 0; 3898 loop = 0;
3899 3899
3900 /* sysfs provides us PAGE_SIZE buffer */ 3900 /* sysfs provides us PAGE_SIZE buffer */
3901 while (len < PAGE_SIZE - 128 && 3901 while (len < PAGE_SIZE - 128 && loop < ARRAY_SIZE(ord_data)) {
3902 loop < (sizeof(ord_data) / sizeof(*ord_data))) {
3903
3904 val_len = sizeof(u32); 3902 val_len = sizeof(u32);
3905 3903
3906 if (ipw2100_get_ordinal(priv, ord_data[loop].index, &val, 3904 if (ipw2100_get_ordinal(priv, ord_data[loop].index, &val,
@@ -6589,7 +6587,7 @@ static const long ipw2100_rates_11b[] = {
6589 11000000 6587 11000000
6590}; 6588};
6591 6589
6592#define RATE_COUNT (sizeof(ipw2100_rates_11b) / sizeof(ipw2100_rates_11b[0])) 6590#define RATE_COUNT ARRAY_SIZE(ipw2100_rates_11b)
6593 6591
6594static int ipw2100_wx_get_name(struct net_device *dev, 6592static int ipw2100_wx_get_name(struct net_device *dev,
6595 struct iw_request_info *info, 6593 struct iw_request_info *info,
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index 838d510213c6..841b3c136ad9 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -1395,11 +1395,16 @@ static int prism54_set_auth(struct net_device *ndev,
1395 break; 1395 break;
1396 1396
1397 case IW_AUTH_RX_UNENCRYPTED_EAPOL: 1397 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1398 dot1x = param->value ? 1 : 0; 1398 /* dot1x should be the opposite of RX_UNENCRYPTED_EAPOL;
1399 * turn off dot1x when allowing receipt of unencrypted EAPOL
1400 * frames, turn on dot1x when receipt should be disallowed
1401 */
1402 dot1x = param->value ? 0 : 0x01;
1399 break; 1403 break;
1400 1404
1401 case IW_AUTH_PRIVACY_INVOKED: 1405 case IW_AUTH_PRIVACY_INVOKED:
1402 privinvoked = param->value ? 1 : 0; 1406 privinvoked = param->value ? 1 : 0;
1407 break;
1403 1408
1404 case IW_AUTH_DROP_UNENCRYPTED: 1409 case IW_AUTH_DROP_UNENCRYPTED:
1405 exunencrypt = param->value ? 1 : 0; 1410 exunencrypt = param->value ? 1 : 0;
@@ -1589,6 +1594,7 @@ static int prism54_set_encodeext(struct net_device *ndev,
1589 } 1594 }
1590 key.type = DOT11_PRIV_TKIP; 1595 key.type = DOT11_PRIV_TKIP;
1591 key.length = KEY_SIZE_TKIP; 1596 key.length = KEY_SIZE_TKIP;
1597 break;
1592 default: 1598 default:
1593 return -EINVAL; 1599 return -EINVAL;
1594 } 1600 }
diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c
index e6cf9df2c206..42780320cd5c 100644
--- a/drivers/net/wireless/prism54/oid_mgt.c
+++ b/drivers/net/wireless/prism54/oid_mgt.c
@@ -16,6 +16,8 @@
16 * 16 *
17 */ 17 */
18 18
19#include <linux/kernel.h>
20
19#include "prismcompat.h" 21#include "prismcompat.h"
20#include "islpci_dev.h" 22#include "islpci_dev.h"
21#include "islpci_mgt.h" 23#include "islpci_mgt.h"
@@ -692,7 +694,7 @@ mgt_update_addr(islpci_private *priv)
692 return ret; 694 return ret;
693} 695}
694 696
695#define VEC_SIZE(a) (sizeof(a)/sizeof(a[0])) 697#define VEC_SIZE(a) ARRAY_SIZE(a)
696 698
697int 699int
698mgt_commit(islpci_private *priv) 700mgt_commit(islpci_private *priv)
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index 24221e476cd3..2aa3c761dd83 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -28,7 +28,7 @@
28 */ 28 */
29static u8 wv_irq_to_psa(int irq) 29static u8 wv_irq_to_psa(int irq)
30{ 30{
31 if (irq < 0 || irq >= NELS(irqvals)) 31 if (irq < 0 || irq >= ARRAY_SIZE(irqvals))
32 return 0; 32 return 0;
33 33
34 return irqvals[irq]; 34 return irqvals[irq];
@@ -42,7 +42,7 @@ static int __init wv_psa_to_irq(u8 irqval)
42{ 42{
43 int irq; 43 int irq;
44 44
45 for (irq = 0; irq < NELS(irqvals); irq++) 45 for (irq = 0; irq < ARRAY_SIZE(irqvals); irq++)
46 if (irqvals[irq] == irqval) 46 if (irqvals[irq] == irqval)
47 return irq; 47 return irq;
48 48
@@ -1695,7 +1695,7 @@ static int wv_frequency_list(unsigned long ioaddr, /* I/O port of the card */
1695 /* Look in the table if the frequency is allowed */ 1695 /* Look in the table if the frequency is allowed */
1696 if (table[9 - (freq / 16)] & (1 << (freq % 16))) { 1696 if (table[9 - (freq / 16)] & (1 << (freq % 16))) {
1697 /* Compute approximate channel number */ 1697 /* Compute approximate channel number */
1698 while ((c < NELS(channel_bands)) && 1698 while ((c < ARRAY_SIZE(channel_bands)) &&
1699 (((channel_bands[c] >> 1) - 24) < freq)) 1699 (((channel_bands[c] >> 1) - 24) < freq))
1700 c++; 1700 c++;
1701 list[i].i = c; /* Set the list index */ 1701 list[i].i = c; /* Set the list index */
@@ -4269,7 +4269,7 @@ struct net_device * __init wavelan_probe(int unit)
4269 printk(KERN_DEBUG "%s: <-wavelan_probe()\n", dev->name); 4269 printk(KERN_DEBUG "%s: <-wavelan_probe()\n", dev->name);
4270#endif 4270#endif
4271 } else { /* Scan all possible addresses of the WaveLAN hardware. */ 4271 } else { /* Scan all possible addresses of the WaveLAN hardware. */
4272 for (i = 0; i < NELS(iobase); i++) { 4272 for (i = 0; i < ARRAY_SIZE(iobase); i++) {
4273 dev->irq = def_irq; 4273 dev->irq = def_irq;
4274 if (wavelan_config(dev, iobase[i]) == 0) { 4274 if (wavelan_config(dev, iobase[i]) == 0) {
4275#ifdef DEBUG_CALLBACK_TRACE 4275#ifdef DEBUG_CALLBACK_TRACE
@@ -4280,7 +4280,7 @@ struct net_device * __init wavelan_probe(int unit)
4280 break; 4280 break;
4281 } 4281 }
4282 } 4282 }
4283 if (i == NELS(iobase)) 4283 if (i == ARRAY_SIZE(iobase))
4284 r = -ENODEV; 4284 r = -ENODEV;
4285 } 4285 }
4286 if (r) 4286 if (r)
@@ -4327,14 +4327,14 @@ int __init init_module(void)
4327#endif 4327#endif
4328 4328
4329 /* Copy the basic set of address to be probed. */ 4329 /* Copy the basic set of address to be probed. */
4330 for (i = 0; i < NELS(iobase); i++) 4330 for (i = 0; i < ARRAY_SIZE(iobase); i++)
4331 io[i] = iobase[i]; 4331 io[i] = iobase[i];
4332 } 4332 }
4333 4333
4334 4334
4335 /* Loop on all possible base addresses. */ 4335 /* Loop on all possible base addresses. */
4336 i = -1; 4336 i = -1;
4337 while ((io[++i] != 0) && (i < NELS(io))) { 4337 while ((io[++i] != 0) && (i < ARRAY_SIZE(io))) {
4338 struct net_device *dev = alloc_etherdev(sizeof(net_local)); 4338 struct net_device *dev = alloc_etherdev(sizeof(net_local));
4339 if (!dev) 4339 if (!dev)
4340 break; 4340 break;
diff --git a/drivers/net/wireless/wavelan.p.h b/drivers/net/wireless/wavelan.p.h
index 72b646c77d5a..fe242812d858 100644
--- a/drivers/net/wireless/wavelan.p.h
+++ b/drivers/net/wireless/wavelan.p.h
@@ -449,9 +449,6 @@ static const char *version = "wavelan.c : v24 (SMP + wireless extensions) 11/12/
449/* Watchdog temporisation */ 449/* Watchdog temporisation */
450#define WATCHDOG_JIFFIES (512*HZ/100) 450#define WATCHDOG_JIFFIES (512*HZ/100)
451 451
452/* Macro to get the number of elements in an array */
453#define NELS(a) (sizeof(a) / sizeof(a[0]))
454
455/* ------------------------ PRIVATE IOCTL ------------------------ */ 452/* ------------------------ PRIVATE IOCTL ------------------------ */
456 453
457#define SIOCSIPQTHR SIOCIWFIRSTPRIV /* Set quality threshold */ 454#define SIOCSIPQTHR SIOCIWFIRSTPRIV /* Set quality threshold */
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 12dfc0b6efe6..9c64f894b71b 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -113,7 +113,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr
113 113
114 /* Allocate a single memory block for values and addresses. */ 114 /* Allocate a single memory block for values and addresses. */
115 count16 = 2*count; 115 count16 = 2*count;
116 a16 = kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), 116 a16 = (zd_addr_t *) kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)),
117 GFP_NOFS); 117 GFP_NOFS);
118 if (!a16) { 118 if (!a16) {
119 dev_dbg_f(zd_chip_dev(chip), 119 dev_dbg_f(zd_chip_dev(chip),
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index 7c269f4992eb..447c52beb691 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -334,7 +334,7 @@
334 * separate range because of collisions with other tools such as 334 * separate range because of collisions with other tools such as
335 * 'mii-tool'. 335 * 'mii-tool'.
336 * We now have 32 commands, so a bit more space ;-). 336 * We now have 32 commands, so a bit more space ;-).
337 * Also, all 'odd' commands are only usable by root and don't return the 337 * Also, all 'even' commands are only usable by root and don't return the
338 * content of ifr/iwr to user (but you are not obliged to use the set/get 338 * content of ifr/iwr to user (but you are not obliged to use the set/get
339 * convention, just use every other two command). More details in iwpriv.c. 339 * convention, just use every other two command). More details in iwpriv.c.
340 * And I repeat : you are not forced to use them with iwpriv, but you 340 * And I repeat : you are not forced to use them with iwpriv, but you
@@ -348,7 +348,7 @@
348#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */ 348#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
349#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST) 349#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
350 350
351/* Even : get (world access), odd : set (root access) */ 351/* Odd : get (world access), even : set (root access) */
352#define IW_IS_SET(cmd) (!((cmd) & 0x1)) 352#define IW_IS_SET(cmd) (!((cmd) & 0x1))
353#define IW_IS_GET(cmd) ((cmd) & 0x1) 353#define IW_IS_GET(cmd) ((cmd) & 0x1)
354 354
diff --git a/net/ieee80211/softmac/ieee80211softmac_module.c b/net/ieee80211/softmac/ieee80211softmac_module.c
index 4f8c3ef70819..e9cdc6615ddc 100644
--- a/net/ieee80211/softmac/ieee80211softmac_module.c
+++ b/net/ieee80211/softmac/ieee80211softmac_module.c
@@ -265,17 +265,10 @@ void ieee80211softmac_init_bss(struct ieee80211softmac_device *mac)
265 /* Change the default txrate to the highest possible value. 265 /* Change the default txrate to the highest possible value.
266 * The txrate machine will lower it, if it is too high. 266 * The txrate machine will lower it, if it is too high.
267 */ 267 */
268 /* FIXME: We don't correctly handle backing down to lower 268 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
269 rates, so 801.11g devices start off at 11M for now. People 269 txrates->user_rate = IEEE80211_OFDM_RATE_24MB;
270 can manually change it if they really need to, but 11M is 270 else
271 more reliable. Note similar logic in
272 ieee80211softmac_wx_set_rate() */
273 if (ieee->modulation & IEEE80211_CCK_MODULATION) {
274 txrates->user_rate = IEEE80211_CCK_RATE_11MB; 271 txrates->user_rate = IEEE80211_CCK_RATE_11MB;
275 } else if (ieee->modulation & IEEE80211_OFDM_MODULATION) {
276 txrates->user_rate = IEEE80211_OFDM_RATE_54MB;
277 } else
278 assert(0);
279 272
280 txrates->default_rate = IEEE80211_CCK_RATE_1MB; 273 txrates->default_rate = IEEE80211_CCK_RATE_1MB;
281 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; 274 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index c306d52566e0..f13937bf9e8c 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -177,15 +177,10 @@ ieee80211softmac_wx_set_rate(struct net_device *net_dev,
177 int err = -EINVAL; 177 int err = -EINVAL;
178 178
179 if (in_rate == -1) { 179 if (in_rate == -1) {
180 /* FIXME: We don't correctly handle backing down to lower 180 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
181 rates, so 801.11g devices start off at 11M for now. People 181 in_rate = 24000000;
182 can manually change it if they really need to, but 11M is
183 more reliable. Note similar logic in
184 ieee80211softmac_wx_set_rate() */
185 if (ieee->modulation & IEEE80211_CCK_MODULATION)
186 in_rate = 11000000;
187 else 182 else
188 in_rate = 54000000; 183 in_rate = 11000000;
189 } 184 }
190 185
191 switch (in_rate) { 186 switch (in_rate) {