aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-20 13:26:46 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-20 13:26:46 -0500
commit91aa69315ef9a76b8f734438617a2e32812b630f (patch)
treeb97040209da15734102f1a40589db887b4c2b06f /drivers
parenta5527c6a586537c1af7ae6db30bb444ee4abdfe8 (diff)
parent6606e17a7f1c3bc1b1e83d0c517f11d094e55bf1 (diff)
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (21 commits) natsemi: Support Aculab E1/T1 PMXc cPCI carrier cards natsemi: Add support for using MII port with no PHY skge: race with workq and RTNL Replace local random function with random32() s2io: RTNL and flush_scheduled_work deadlock 8139too: RTNL and flush_scheduled_work deadlock sis190: RTNL and flush_scheduled_work deadlock r8169: RTNL and flush_scheduled_work deadlock [PATCH] ieee80211softmac: Fix setting of initial transmit rates [PATCH] bcm43xx: OFDM fix for rev 1 cards [PATCH] bcm43xx: Fix for 4311 and 02/07/07 specification changes [PATCH] prism54: correct assignment of DOT1XENABLE in WE-19 codepaths [PATCH] zd1211rw: Readd zd_addr_t cast [PATCH] bcm43xx: Fix for oops on resume [PATCH] bcm43xx: Ignore ampdu status reports [PATCH] wavelan: Use ARRAY_SIZE macro when appropriate [PATCH] hostap: Use ARRAY_SIZE macro when appropriate [PATCH] misc-wireless: Use ARRAY_SIZE macro when appropriate [PATCH] ipw2100: Use ARRAY_SIZE macro when appropriate [PATCH] bcm43xx: Janitorial change - remove two unused variables ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/8139too.c40
-rw-r--r--drivers/net/hamradio/baycom_epp.c13
-rw-r--r--drivers/net/hamradio/hdlcdrv.c13
-rw-r--r--drivers/net/hamradio/yam.c11
-rw-r--r--drivers/net/natsemi.c43
-rw-r--r--drivers/net/r8169.c25
-rw-r--r--drivers/net/s2io.c21
-rw-r--r--drivers/net/sis190.c7
-rw-r--r--drivers/net/skge.c9
-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
24 files changed, 256 insertions, 240 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 35ad5cff18e6..99304b2aa86e 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -1109,6 +1109,8 @@ static void __devexit rtl8139_remove_one (struct pci_dev *pdev)
1109 1109
1110 assert (dev != NULL); 1110 assert (dev != NULL);
1111 1111
1112 flush_scheduled_work();
1113
1112 unregister_netdev (dev); 1114 unregister_netdev (dev);
1113 1115
1114 __rtl8139_cleanup_dev (dev); 1116 __rtl8139_cleanup_dev (dev);
@@ -1603,18 +1605,21 @@ static void rtl8139_thread (struct work_struct *work)
1603 struct net_device *dev = tp->mii.dev; 1605 struct net_device *dev = tp->mii.dev;
1604 unsigned long thr_delay = next_tick; 1606 unsigned long thr_delay = next_tick;
1605 1607
1608 rtnl_lock();
1609
1610 if (!netif_running(dev))
1611 goto out_unlock;
1612
1606 if (tp->watchdog_fired) { 1613 if (tp->watchdog_fired) {
1607 tp->watchdog_fired = 0; 1614 tp->watchdog_fired = 0;
1608 rtl8139_tx_timeout_task(work); 1615 rtl8139_tx_timeout_task(work);
1609 } else if (rtnl_trylock()) { 1616 } else
1610 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1617 rtl8139_thread_iter(dev, tp, tp->mmio_addr);
1611 rtnl_unlock ();
1612 } else {
1613 /* unlikely race. mitigate with fast poll. */
1614 thr_delay = HZ / 2;
1615 }
1616 1618
1617 schedule_delayed_work(&tp->thread, thr_delay); 1619 if (tp->have_thread)
1620 schedule_delayed_work(&tp->thread, thr_delay);
1621out_unlock:
1622 rtnl_unlock ();
1618} 1623}
1619 1624
1620static void rtl8139_start_thread(struct rtl8139_private *tp) 1625static void rtl8139_start_thread(struct rtl8139_private *tp)
@@ -1626,19 +1631,11 @@ static void rtl8139_start_thread(struct rtl8139_private *tp)
1626 return; 1631 return;
1627 1632
1628 tp->have_thread = 1; 1633 tp->have_thread = 1;
1634 tp->watchdog_fired = 0;
1629 1635
1630 schedule_delayed_work(&tp->thread, next_tick); 1636 schedule_delayed_work(&tp->thread, next_tick);
1631} 1637}
1632 1638
1633static void rtl8139_stop_thread(struct rtl8139_private *tp)
1634{
1635 if (tp->have_thread) {
1636 cancel_rearming_delayed_work(&tp->thread);
1637 tp->have_thread = 0;
1638 } else
1639 flush_scheduled_work();
1640}
1641
1642static inline void rtl8139_tx_clear (struct rtl8139_private *tp) 1639static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
1643{ 1640{
1644 tp->cur_tx = 0; 1641 tp->cur_tx = 0;
@@ -1696,12 +1693,11 @@ static void rtl8139_tx_timeout (struct net_device *dev)
1696{ 1693{
1697 struct rtl8139_private *tp = netdev_priv(dev); 1694 struct rtl8139_private *tp = netdev_priv(dev);
1698 1695
1696 tp->watchdog_fired = 1;
1699 if (!tp->have_thread) { 1697 if (!tp->have_thread) {
1700 INIT_DELAYED_WORK(&tp->thread, rtl8139_tx_timeout_task); 1698 INIT_DELAYED_WORK(&tp->thread, rtl8139_thread);
1701 schedule_delayed_work(&tp->thread, next_tick); 1699 schedule_delayed_work(&tp->thread, next_tick);
1702 } else 1700 }
1703 tp->watchdog_fired = 1;
1704
1705} 1701}
1706 1702
1707static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev) 1703static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
@@ -2233,8 +2229,6 @@ static int rtl8139_close (struct net_device *dev)
2233 2229
2234 netif_stop_queue (dev); 2230 netif_stop_queue (dev);
2235 2231
2236 rtl8139_stop_thread(tp);
2237
2238 if (netif_msg_ifdown(tp)) 2232 if (netif_msg_ifdown(tp))
2239 printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n", 2233 printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n",
2240 dev->name, RTL_R16 (IntrStatus)); 2234 dev->name, RTL_R16 (IntrStatus));
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 153b6dc80af4..84aa2117c0ee 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -52,6 +52,7 @@
52#include <linux/hdlcdrv.h> 52#include <linux/hdlcdrv.h>
53#include <linux/baycom.h> 53#include <linux/baycom.h>
54#include <linux/jiffies.h> 54#include <linux/jiffies.h>
55#include <linux/random.h>
55#include <net/ax25.h> 56#include <net/ax25.h>
56#include <asm/uaccess.h> 57#include <asm/uaccess.h>
57 58
@@ -433,16 +434,6 @@ static void encode_hdlc(struct baycom_state *bc)
433 434
434/* ---------------------------------------------------------------------- */ 435/* ---------------------------------------------------------------------- */
435 436
436static unsigned short random_seed;
437
438static inline unsigned short random_num(void)
439{
440 random_seed = 28629 * random_seed + 157;
441 return random_seed;
442}
443
444/* ---------------------------------------------------------------------- */
445
446static int transmit(struct baycom_state *bc, int cnt, unsigned char stat) 437static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
447{ 438{
448 struct parport *pp = bc->pdev->port; 439 struct parport *pp = bc->pdev->port;
@@ -464,7 +455,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
464 if ((--bc->hdlctx.slotcnt) > 0) 455 if ((--bc->hdlctx.slotcnt) > 0)
465 return 0; 456 return 0;
466 bc->hdlctx.slotcnt = bc->ch_params.slottime; 457 bc->hdlctx.slotcnt = bc->ch_params.slottime;
467 if ((random_num() % 256) > bc->ch_params.ppersist) 458 if ((random32() % 256) > bc->ch_params.ppersist)
468 return 0; 459 return 0;
469 } 460 }
470 } 461 }
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 452873e7c68f..f5a17ad9d3d6 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -56,6 +56,7 @@
56#include <linux/if_arp.h> 56#include <linux/if_arp.h>
57#include <linux/skbuff.h> 57#include <linux/skbuff.h>
58#include <linux/hdlcdrv.h> 58#include <linux/hdlcdrv.h>
59#include <linux/random.h>
59#include <net/ax25.h> 60#include <net/ax25.h>
60#include <asm/uaccess.h> 61#include <asm/uaccess.h>
61 62
@@ -371,16 +372,6 @@ static void start_tx(struct net_device *dev, struct hdlcdrv_state *s)
371 372
372/* ---------------------------------------------------------------------- */ 373/* ---------------------------------------------------------------------- */
373 374
374static unsigned short random_seed;
375
376static inline unsigned short random_num(void)
377{
378 random_seed = 28629 * random_seed + 157;
379 return random_seed;
380}
381
382/* ---------------------------------------------------------------------- */
383
384void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s) 375void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
385{ 376{
386 if (!s || s->magic != HDLCDRV_MAGIC || s->hdlctx.ptt || !s->skb) 377 if (!s || s->magic != HDLCDRV_MAGIC || s->hdlctx.ptt || !s->skb)
@@ -396,7 +387,7 @@ void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
396 if ((--s->hdlctx.slotcnt) > 0) 387 if ((--s->hdlctx.slotcnt) > 0)
397 return; 388 return;
398 s->hdlctx.slotcnt = s->ch_params.slottime; 389 s->hdlctx.slotcnt = s->ch_params.slottime;
399 if ((random_num() % 256) > s->ch_params.ppersist) 390 if ((random32() % 256) > s->ch_params.ppersist)
400 return; 391 return;
401 start_tx(dev, s); 392 start_tx(dev, s);
402} 393}
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 08f27119a807..ee3ea4fa729f 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -50,6 +50,7 @@
50#include <linux/slab.h> 50#include <linux/slab.h>
51#include <linux/errno.h> 51#include <linux/errno.h>
52#include <linux/bitops.h> 52#include <linux/bitops.h>
53#include <linux/random.h>
53#include <asm/io.h> 54#include <asm/io.h>
54#include <asm/system.h> 55#include <asm/system.h>
55#include <linux/interrupt.h> 56#include <linux/interrupt.h>
@@ -566,14 +567,6 @@ static void yam_start_tx(struct net_device *dev, struct yam_port *yp)
566 ptt_on(dev); 567 ptt_on(dev);
567} 568}
568 569
569static unsigned short random_seed;
570
571static inline unsigned short random_num(void)
572{
573 random_seed = 28629 * random_seed + 157;
574 return random_seed;
575}
576
577static void yam_arbitrate(struct net_device *dev) 570static void yam_arbitrate(struct net_device *dev)
578{ 571{
579 struct yam_port *yp = netdev_priv(dev); 572 struct yam_port *yp = netdev_priv(dev);
@@ -600,7 +593,7 @@ static void yam_arbitrate(struct net_device *dev)
600 yp->slotcnt = yp->slot / 10; 593 yp->slotcnt = yp->slot / 10;
601 594
602 /* is random > persist ? */ 595 /* is random > persist ? */
603 if ((random_num() % 256) > yp->pers) 596 if ((random32() % 256) > yp->pers)
604 return; 597 return;
605 598
606 yam_start_tx(dev, yp); 599 yam_start_tx(dev, yp);
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index ffa0afd2eddc..adf29dd66798 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -244,6 +244,9 @@ enum {
244 MII_EN_SCRM = 0x0004, /* enable scrambler (tp) */ 244 MII_EN_SCRM = 0x0004, /* enable scrambler (tp) */
245}; 245};
246 246
247enum {
248 NATSEMI_FLAG_IGNORE_PHY = 0x1,
249};
247 250
248/* array of board data directly indexed by pci_tbl[x].driver_data */ 251/* array of board data directly indexed by pci_tbl[x].driver_data */
249static const struct { 252static const struct {
@@ -251,10 +254,12 @@ static const struct {
251 unsigned long flags; 254 unsigned long flags;
252 unsigned int eeprom_size; 255 unsigned int eeprom_size;
253} natsemi_pci_info[] __devinitdata = { 256} natsemi_pci_info[] __devinitdata = {
257 { "Aculab E1/T1 PMXc cPCI carrier card", NATSEMI_FLAG_IGNORE_PHY, 128 },
254 { "NatSemi DP8381[56]", 0, 24 }, 258 { "NatSemi DP8381[56]", 0, 24 },
255}; 259};
256 260
257static const struct pci_device_id natsemi_pci_tbl[] __devinitdata = { 261static const struct pci_device_id natsemi_pci_tbl[] __devinitdata = {
262 { PCI_VENDOR_ID_NS, 0x0020, 0x12d9, 0x000c, 0, 0, 0 },
258 { PCI_VENDOR_ID_NS, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 263 { PCI_VENDOR_ID_NS, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
259 { } /* terminate list */ 264 { } /* terminate list */
260}; 265};
@@ -568,6 +573,8 @@ struct netdev_private {
568 u32 intr_status; 573 u32 intr_status;
569 /* Do not touch the nic registers */ 574 /* Do not touch the nic registers */
570 int hands_off; 575 int hands_off;
576 /* Don't pay attention to the reported link state. */
577 int ignore_phy;
571 /* external phy that is used: only valid if dev->if_port != PORT_TP */ 578 /* external phy that is used: only valid if dev->if_port != PORT_TP */
572 int mii; 579 int mii;
573 int phy_addr_external; 580 int phy_addr_external;
@@ -696,7 +703,10 @@ static void __devinit natsemi_init_media (struct net_device *dev)
696 struct netdev_private *np = netdev_priv(dev); 703 struct netdev_private *np = netdev_priv(dev);
697 u32 tmp; 704 u32 tmp;
698 705
699 netif_carrier_off(dev); 706 if (np->ignore_phy)
707 netif_carrier_on(dev);
708 else
709 netif_carrier_off(dev);
700 710
701 /* get the initial settings from hardware */ 711 /* get the initial settings from hardware */
702 tmp = mdio_read(dev, MII_BMCR); 712 tmp = mdio_read(dev, MII_BMCR);
@@ -806,8 +816,13 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
806 np->hands_off = 0; 816 np->hands_off = 0;
807 np->intr_status = 0; 817 np->intr_status = 0;
808 np->eeprom_size = natsemi_pci_info[chip_idx].eeprom_size; 818 np->eeprom_size = natsemi_pci_info[chip_idx].eeprom_size;
819 if (natsemi_pci_info[chip_idx].flags & NATSEMI_FLAG_IGNORE_PHY)
820 np->ignore_phy = 1;
821 else
822 np->ignore_phy = 0;
809 823
810 /* Initial port: 824 /* Initial port:
825 * - If configured to ignore the PHY set up for external.
811 * - If the nic was configured to use an external phy and if find_mii 826 * - If the nic was configured to use an external phy and if find_mii
812 * finds a phy: use external port, first phy that replies. 827 * finds a phy: use external port, first phy that replies.
813 * - Otherwise: internal port. 828 * - Otherwise: internal port.
@@ -815,7 +830,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
815 * The address would be used to access a phy over the mii bus, but 830 * The address would be used to access a phy over the mii bus, but
816 * the internal phy is accessed through mapped registers. 831 * the internal phy is accessed through mapped registers.
817 */ 832 */
818 if (readl(ioaddr + ChipConfig) & CfgExtPhy) 833 if (np->ignore_phy || readl(ioaddr + ChipConfig) & CfgExtPhy)
819 dev->if_port = PORT_MII; 834 dev->if_port = PORT_MII;
820 else 835 else
821 dev->if_port = PORT_TP; 836 dev->if_port = PORT_TP;
@@ -825,7 +840,9 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
825 840
826 if (dev->if_port != PORT_TP) { 841 if (dev->if_port != PORT_TP) {
827 np->phy_addr_external = find_mii(dev); 842 np->phy_addr_external = find_mii(dev);
828 if (np->phy_addr_external == PHY_ADDR_NONE) { 843 /* If we're ignoring the PHY it doesn't matter if we can't
844 * find one. */
845 if (!np->ignore_phy && np->phy_addr_external == PHY_ADDR_NONE) {
829 dev->if_port = PORT_TP; 846 dev->if_port = PORT_TP;
830 np->phy_addr_external = PHY_ADDR_INTERNAL; 847 np->phy_addr_external = PHY_ADDR_INTERNAL;
831 } 848 }
@@ -891,6 +908,8 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
891 printk("%02x, IRQ %d", dev->dev_addr[i], irq); 908 printk("%02x, IRQ %d", dev->dev_addr[i], irq);
892 if (dev->if_port == PORT_TP) 909 if (dev->if_port == PORT_TP)
893 printk(", port TP.\n"); 910 printk(", port TP.\n");
911 else if (np->ignore_phy)
912 printk(", port MII, ignoring PHY\n");
894 else 913 else
895 printk(", port MII, phy ad %d.\n", np->phy_addr_external); 914 printk(", port MII, phy ad %d.\n", np->phy_addr_external);
896 } 915 }
@@ -1571,9 +1590,13 @@ static void check_link(struct net_device *dev)
1571{ 1590{
1572 struct netdev_private *np = netdev_priv(dev); 1591 struct netdev_private *np = netdev_priv(dev);
1573 void __iomem * ioaddr = ns_ioaddr(dev); 1592 void __iomem * ioaddr = ns_ioaddr(dev);
1574 int duplex; 1593 int duplex = np->duplex;
1575 u16 bmsr; 1594 u16 bmsr;
1576 1595
1596 /* If we are ignoring the PHY then don't try reading it. */
1597 if (np->ignore_phy)
1598 goto propagate_state;
1599
1577 /* The link status field is latched: it remains low after a temporary 1600 /* The link status field is latched: it remains low after a temporary
1578 * link failure until it's read. We need the current link status, 1601 * link failure until it's read. We need the current link status,
1579 * thus read twice. 1602 * thus read twice.
@@ -1585,7 +1608,7 @@ static void check_link(struct net_device *dev)
1585 if (netif_carrier_ok(dev)) { 1608 if (netif_carrier_ok(dev)) {
1586 if (netif_msg_link(np)) 1609 if (netif_msg_link(np))
1587 printk(KERN_NOTICE "%s: link down.\n", 1610 printk(KERN_NOTICE "%s: link down.\n",
1588 dev->name); 1611 dev->name);
1589 netif_carrier_off(dev); 1612 netif_carrier_off(dev);
1590 undo_cable_magic(dev); 1613 undo_cable_magic(dev);
1591 } 1614 }
@@ -1609,6 +1632,7 @@ static void check_link(struct net_device *dev)
1609 duplex = 1; 1632 duplex = 1;
1610 } 1633 }
1611 1634
1635propagate_state:
1612 /* if duplex is set then bit 28 must be set, too */ 1636 /* if duplex is set then bit 28 must be set, too */
1613 if (duplex ^ !!(np->rx_config & RxAcceptTx)) { 1637 if (duplex ^ !!(np->rx_config & RxAcceptTx)) {
1614 if (netif_msg_link(np)) 1638 if (netif_msg_link(np))
@@ -2819,6 +2843,15 @@ static int netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
2819 } 2843 }
2820 2844
2821 /* 2845 /*
2846 * If we're ignoring the PHY then autoneg and the internal
2847 * transciever are really not going to work so don't let the
2848 * user select them.
2849 */
2850 if (np->ignore_phy && (ecmd->autoneg == AUTONEG_ENABLE ||
2851 ecmd->port == PORT_TP))
2852 return -EINVAL;
2853
2854 /*
2822 * maxtxpkt, maxrxpkt: ignored for now. 2855 * maxtxpkt, maxrxpkt: ignored for now.
2823 * 2856 *
2824 * transceiver: 2857 * transceiver:
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 5598d86380b4..13cf06ee97f7 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1733,6 +1733,8 @@ rtl8169_remove_one(struct pci_dev *pdev)
1733 assert(dev != NULL); 1733 assert(dev != NULL);
1734 assert(tp != NULL); 1734 assert(tp != NULL);
1735 1735
1736 flush_scheduled_work();
1737
1736 unregister_netdev(dev); 1738 unregister_netdev(dev);
1737 rtl8169_release_board(pdev, dev, tp->mmio_addr); 1739 rtl8169_release_board(pdev, dev, tp->mmio_addr);
1738 pci_set_drvdata(pdev, NULL); 1740 pci_set_drvdata(pdev, NULL);
@@ -2161,10 +2163,13 @@ static void rtl8169_reinit_task(struct work_struct *work)
2161 struct net_device *dev = tp->dev; 2163 struct net_device *dev = tp->dev;
2162 int ret; 2164 int ret;
2163 2165
2164 if (netif_running(dev)) { 2166 rtnl_lock();
2165 rtl8169_wait_for_quiescence(dev); 2167
2166 rtl8169_close(dev); 2168 if (!netif_running(dev))
2167 } 2169 goto out_unlock;
2170
2171 rtl8169_wait_for_quiescence(dev);
2172 rtl8169_close(dev);
2168 2173
2169 ret = rtl8169_open(dev); 2174 ret = rtl8169_open(dev);
2170 if (unlikely(ret < 0)) { 2175 if (unlikely(ret < 0)) {
@@ -2179,6 +2184,9 @@ static void rtl8169_reinit_task(struct work_struct *work)
2179 } 2184 }
2180 rtl8169_schedule_work(dev, rtl8169_reinit_task); 2185 rtl8169_schedule_work(dev, rtl8169_reinit_task);
2181 } 2186 }
2187
2188out_unlock:
2189 rtnl_unlock();
2182} 2190}
2183 2191
2184static void rtl8169_reset_task(struct work_struct *work) 2192static void rtl8169_reset_task(struct work_struct *work)
@@ -2187,8 +2195,10 @@ static void rtl8169_reset_task(struct work_struct *work)
2187 container_of(work, struct rtl8169_private, task.work); 2195 container_of(work, struct rtl8169_private, task.work);
2188 struct net_device *dev = tp->dev; 2196 struct net_device *dev = tp->dev;
2189 2197
2198 rtnl_lock();
2199
2190 if (!netif_running(dev)) 2200 if (!netif_running(dev))
2191 return; 2201 goto out_unlock;
2192 2202
2193 rtl8169_wait_for_quiescence(dev); 2203 rtl8169_wait_for_quiescence(dev);
2194 2204
@@ -2210,6 +2220,9 @@ static void rtl8169_reset_task(struct work_struct *work)
2210 } 2220 }
2211 rtl8169_schedule_work(dev, rtl8169_reset_task); 2221 rtl8169_schedule_work(dev, rtl8169_reset_task);
2212 } 2222 }
2223
2224out_unlock:
2225 rtnl_unlock();
2213} 2226}
2214 2227
2215static void rtl8169_tx_timeout(struct net_device *dev) 2228static void rtl8169_tx_timeout(struct net_device *dev)
@@ -2722,8 +2735,6 @@ static void rtl8169_down(struct net_device *dev)
2722 2735
2723 netif_stop_queue(dev); 2736 netif_stop_queue(dev);
2724 2737
2725 flush_scheduled_work();
2726
2727core_down: 2738core_down:
2728 spin_lock_irq(&tp->lock); 2739 spin_lock_irq(&tp->lock);
2729 2740
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index e8e0d94e9bdd..fd85648d98d1 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -3758,7 +3758,6 @@ static int s2io_close(struct net_device *dev)
3758{ 3758{
3759 struct s2io_nic *sp = dev->priv; 3759 struct s2io_nic *sp = dev->priv;
3760 3760
3761 flush_scheduled_work();
3762 netif_stop_queue(dev); 3761 netif_stop_queue(dev);
3763 /* Reset card, kill tasklet and free Tx and Rx buffers. */ 3762 /* Reset card, kill tasklet and free Tx and Rx buffers. */
3764 s2io_card_down(sp); 3763 s2io_card_down(sp);
@@ -5847,9 +5846,14 @@ static void s2io_set_link(struct work_struct *work)
5847 register u64 val64; 5846 register u64 val64;
5848 u16 subid; 5847 u16 subid;
5849 5848
5849 rtnl_lock();
5850
5851 if (!netif_running(dev))
5852 goto out_unlock;
5853
5850 if (test_and_set_bit(0, &(nic->link_state))) { 5854 if (test_and_set_bit(0, &(nic->link_state))) {
5851 /* The card is being reset, no point doing anything */ 5855 /* The card is being reset, no point doing anything */
5852 return; 5856 goto out_unlock;
5853 } 5857 }
5854 5858
5855 subid = nic->pdev->subsystem_device; 5859 subid = nic->pdev->subsystem_device;
@@ -5903,6 +5907,9 @@ static void s2io_set_link(struct work_struct *work)
5903 s2io_link(nic, LINK_DOWN); 5907 s2io_link(nic, LINK_DOWN);
5904 } 5908 }
5905 clear_bit(0, &(nic->link_state)); 5909 clear_bit(0, &(nic->link_state));
5910
5911out_unlock:
5912 rtnl_lock();
5906} 5913}
5907 5914
5908static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, 5915static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
@@ -6356,6 +6363,11 @@ static void s2io_restart_nic(struct work_struct *work)
6356 struct s2io_nic *sp = container_of(work, struct s2io_nic, rst_timer_task); 6363 struct s2io_nic *sp = container_of(work, struct s2io_nic, rst_timer_task);
6357 struct net_device *dev = sp->dev; 6364 struct net_device *dev = sp->dev;
6358 6365
6366 rtnl_lock();
6367
6368 if (!netif_running(dev))
6369 goto out_unlock;
6370
6359 s2io_card_down(sp); 6371 s2io_card_down(sp);
6360 if (s2io_card_up(sp)) { 6372 if (s2io_card_up(sp)) {
6361 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n", 6373 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n",
@@ -6364,7 +6376,8 @@ static void s2io_restart_nic(struct work_struct *work)
6364 netif_wake_queue(dev); 6376 netif_wake_queue(dev);
6365 DBG_PRINT(ERR_DBG, "%s: was reset by Tx watchdog timer\n", 6377 DBG_PRINT(ERR_DBG, "%s: was reset by Tx watchdog timer\n",
6366 dev->name); 6378 dev->name);
6367 6379out_unlock:
6380 rtnl_unlock();
6368} 6381}
6369 6382
6370/** 6383/**
@@ -7173,6 +7186,8 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev)
7173 return; 7186 return;
7174 } 7187 }
7175 7188
7189 flush_scheduled_work();
7190
7176 sp = dev->priv; 7191 sp = dev->priv;
7177 unregister_netdev(dev); 7192 unregister_netdev(dev);
7178 7193
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 45d91b159100..b08508b35833 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -909,6 +909,9 @@ static void sis190_phy_task(struct work_struct *work)
909 909
910 rtnl_lock(); 910 rtnl_lock();
911 911
912 if (!netif_running(dev))
913 goto out_unlock;
914
912 val = mdio_read(ioaddr, phy_id, MII_BMCR); 915 val = mdio_read(ioaddr, phy_id, MII_BMCR);
913 if (val & BMCR_RESET) { 916 if (val & BMCR_RESET) {
914 // FIXME: needlessly high ? -- FR 02/07/2005 917 // FIXME: needlessly high ? -- FR 02/07/2005
@@ -981,6 +984,7 @@ static void sis190_phy_task(struct work_struct *work)
981 netif_carrier_on(dev); 984 netif_carrier_on(dev);
982 } 985 }
983 986
987out_unlock:
984 rtnl_unlock(); 988 rtnl_unlock();
985} 989}
986 990
@@ -1102,8 +1106,6 @@ static void sis190_down(struct net_device *dev)
1102 1106
1103 netif_stop_queue(dev); 1107 netif_stop_queue(dev);
1104 1108
1105 flush_scheduled_work();
1106
1107 do { 1109 do {
1108 spin_lock_irq(&tp->lock); 1110 spin_lock_irq(&tp->lock);
1109 1111
@@ -1857,6 +1859,7 @@ static void __devexit sis190_remove_one(struct pci_dev *pdev)
1857 struct net_device *dev = pci_get_drvdata(pdev); 1859 struct net_device *dev = pci_get_drvdata(pdev);
1858 1860
1859 sis190_mii_remove(dev); 1861 sis190_mii_remove(dev);
1862 flush_scheduled_work();
1860 unregister_netdev(dev); 1863 unregister_netdev(dev);
1861 sis190_release_board(pdev); 1864 sis190_release_board(pdev);
1862 pci_set_drvdata(pdev, NULL); 1865 pci_set_drvdata(pdev, NULL);
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index e482e7fcbb2b..c3d2e0a2c4e6 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -1419,7 +1419,8 @@ static void xm_link_timer(struct work_struct *work)
1419 mutex_unlock(&hw->phy_mutex); 1419 mutex_unlock(&hw->phy_mutex);
1420 1420
1421nochange: 1421nochange:
1422 schedule_delayed_work(&skge->link_thread, LINK_HZ); 1422 if (netif_running(dev))
1423 schedule_delayed_work(&skge->link_thread, LINK_HZ);
1423} 1424}
1424 1425
1425static void genesis_mac_init(struct skge_hw *hw, int port) 1426static void genesis_mac_init(struct skge_hw *hw, int port)
@@ -2530,7 +2531,7 @@ static int skge_down(struct net_device *dev)
2530 2531
2531 netif_stop_queue(dev); 2532 netif_stop_queue(dev);
2532 if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC) 2533 if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC)
2533 cancel_rearming_delayed_work(&skge->link_thread); 2534 cancel_delayed_work(&skge->link_thread);
2534 2535
2535 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF); 2536 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
2536 if (hw->chip_id == CHIP_ID_GENESIS) 2537 if (hw->chip_id == CHIP_ID_GENESIS)
@@ -3690,6 +3691,8 @@ static void __devexit skge_remove(struct pci_dev *pdev)
3690 if (!hw) 3691 if (!hw)
3691 return; 3692 return;
3692 3693
3694 flush_scheduled_work();
3695
3693 if ((dev1 = hw->dev[1])) 3696 if ((dev1 = hw->dev[1]))
3694 unregister_netdev(dev1); 3697 unregister_netdev(dev1);
3695 dev0 = hw->dev[0]; 3698 dev0 = hw->dev[0];
@@ -3704,8 +3707,6 @@ static void __devexit skge_remove(struct pci_dev *pdev)
3704 skge_write16(hw, B0_LED, LED_STAT_OFF); 3707 skge_write16(hw, B0_LED, LED_STAT_OFF);
3705 skge_write8(hw, B0_CTST, CS_RST_SET); 3708 skge_write8(hw, B0_CTST, CS_RST_SET);
3706 3709
3707 flush_scheduled_work();
3708
3709 free_irq(pdev->irq, hw); 3710 free_irq(pdev->irq, hw);
3710 pci_release_regions(pdev); 3711 pci_release_regions(pdev);
3711 pci_disable_device(pdev); 3712 pci_disable_device(pdev);
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),