aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-03-13 17:50:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-13 17:50:18 -0500
commitd89b218b801fd93ea95880f1c7fde348cbcc51c5 (patch)
treecd3c34e1811f9b2bc10ecfb957bf26cbd04c677e /drivers/net
parent80a186074e72e2cd61f6716d90cf32ce54981a56 (diff)
parentbec68ff1637ca00bb1585a03a7be8a13380084de (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (108 commits) bridge: ensure to unlock in error path in br_multicast_query(). drivers/net/tulip/eeprom.c: fix bogus "(null)" in tulip init messages sky2: Avoid rtnl_unlock without rtnl_lock ipv6: Send netlink notification when DAD fails drivers/net/tg3.c: change the field used with the TG3_FLAG_10_100_ONLY constant ipconfig: Handle devices which take some time to come up. mac80211: Fix memory leak in ieee80211_if_write() mac80211: Fix (dynamic) power save entry ipw2200: use kmalloc for large local variables ath5k: read eeprom IQ calibration values correctly for G mode ath5k: fix I/Q calibration (for real) ath5k: fix TSF reset ath5k: use fixed antenna for tx descriptors libipw: split ieee->networks into small pieces mac80211: Fix sta_mtx unlocking on insert STA failure path rt2x00: remove KSEG1ADDR define from rt2x00soc.h net: add ColdFire support to the smc91x driver asix: fix setting mac address for AX88772 ipv6 ip6_tunnel: eliminate unused recursion field from ip6_tnl{}. net: Fix dev_mc_add() ...
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/arm/ks8695net.c2
-rw-r--r--drivers/net/benet/be.h5
-rw-r--r--drivers/net/benet/be_cmds.c6
-rw-r--r--drivers/net/benet/be_hw.h5
-rw-r--r--drivers/net/benet/be_main.c25
-rw-r--r--drivers/net/can/bfin_can.c3
-rw-r--r--drivers/net/can/usb/ems_usb.c4
-rw-r--r--drivers/net/cassini.c2
-rw-r--r--drivers/net/cpmac.c14
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c1
-rw-r--r--drivers/net/davinci_emac.c2
-rw-r--r--drivers/net/e1000e/defines.h2
-rw-r--r--drivers/net/e1000e/ich8lan.c10
-rw-r--r--drivers/net/gianfar.c5
-rw-r--r--drivers/net/irda/irda-usb.c4
-rw-r--r--drivers/net/qlcnic/qlcnic.h13
-rw-r--r--drivers/net/qlcnic/qlcnic_ethtool.c17
-rw-r--r--drivers/net/qlcnic/qlcnic_hw.c32
-rw-r--r--drivers/net/qlcnic/qlcnic_init.c156
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c5
-rw-r--r--drivers/net/r8169.c4
-rw-r--r--drivers/net/s2io.c6
-rw-r--r--drivers/net/sky2.c2
-rw-r--r--drivers/net/smc91x.h42
-rw-r--r--drivers/net/tg3.c4
-rw-r--r--drivers/net/tulip/eeprom.c54
-rw-r--r--drivers/net/typhoon.c6
-rw-r--r--drivers/net/usb/asix.c30
-rw-r--r--drivers/net/usb/pegasus.h6
-rw-r--r--drivers/net/wireless/airo.c3
-rw-r--r--drivers/net/wireless/ath/ar9170/ar9170.h1
-rw-r--r--drivers/net/wireless/ath/ar9170/main.c10
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.c170
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c41
-rw-r--r--drivers/net/wireless/ath/ath5k/reg.h1
-rw-r--r--drivers/net/wireless/ath/ath5k/reset.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c4
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c19
-rw-r--r--drivers/net/wireless/ipw2x00/libipw.h2
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_module.c37
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c159
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c49
-rw-r--r--drivers/net/wireless/rndis_wlan.c66
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00soc.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00soc.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c10
53 files changed, 690 insertions, 398 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 7029cd50c458..0ba5b8e50a7c 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -907,7 +907,7 @@ config SMC91X
907 select CRC32 907 select CRC32
908 select MII 908 select MII
909 depends on ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || \ 909 depends on ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || \
910 MIPS || BLACKFIN || MN10300 910 MIPS || BLACKFIN || MN10300 || COLDFIRE
911 help 911 help
912 This is a driver for SMC's 91x series of Ethernet chipsets, 912 This is a driver for SMC's 91x series of Ethernet chipsets,
913 including the SMC91C94 and the SMC91C111. Say Y if you want it 913 including the SMC91C94 and the SMC91C111. Say Y if you want it
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index 8ca639127dbc..a1d4188c430b 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -575,9 +575,9 @@ static int ks8695_poll(struct napi_struct *napi, int budget)
575 if (work_done < budget) { 575 if (work_done < budget) {
576 unsigned long flags; 576 unsigned long flags;
577 spin_lock_irqsave(&ksp->rx_lock, flags); 577 spin_lock_irqsave(&ksp->rx_lock, flags);
578 __napi_complete(napi);
578 /*enable rx interrupt*/ 579 /*enable rx interrupt*/
579 writel(isr | mask_bit, KS8695_IRQ_VA + KS8695_INTEN); 580 writel(isr | mask_bit, KS8695_IRQ_VA + KS8695_INTEN);
580 __napi_complete(napi);
581 spin_unlock_irqrestore(&ksp->rx_lock, flags); 581 spin_unlock_irqrestore(&ksp->rx_lock, flags);
582 } 582 }
583 return work_done; 583 return work_done;
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index be81fb2d10f7..8f0752553681 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -290,11 +290,6 @@ extern const struct ethtool_ops be_ethtool_ops;
290 290
291#define drvr_stats(adapter) (&adapter->stats.drvr_stats) 291#define drvr_stats(adapter) (&adapter->stats.drvr_stats)
292 292
293static inline unsigned int be_pci_func(struct be_adapter *adapter)
294{
295 return PCI_FUNC(adapter->pdev->devfn);
296}
297
298#define BE_SET_NETDEV_OPS(netdev, ops) (netdev->netdev_ops = ops) 293#define BE_SET_NETDEV_OPS(netdev, ops) (netdev->netdev_ops = ops)
299 294
300#define PAGE_SHIFT_4K 12 295#define PAGE_SHIFT_4K 12
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 4b1f80519ca4..c59215361f4e 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -465,8 +465,6 @@ int be_cmd_eq_create(struct be_adapter *adapter,
465 465
466 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); 466 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
467 467
468 AMAP_SET_BITS(struct amap_eq_context, func, req->context,
469 be_pci_func(adapter));
470 AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1); 468 AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1);
471 /* 4byte eqe*/ 469 /* 4byte eqe*/
472 AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0); 470 AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0);
@@ -629,7 +627,6 @@ int be_cmd_cq_create(struct be_adapter *adapter,
629 AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1); 627 AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1);
630 AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id); 628 AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id);
631 AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1); 629 AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1);
632 AMAP_SET_BITS(struct amap_cq_context, func, ctxt, be_pci_func(adapter));
633 be_dws_cpu_to_le(ctxt, sizeof(req->context)); 630 be_dws_cpu_to_le(ctxt, sizeof(req->context));
634 631
635 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); 632 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
@@ -678,7 +675,6 @@ int be_cmd_mccq_create(struct be_adapter *adapter,
678 675
679 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); 676 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size);
680 677
681 AMAP_SET_BITS(struct amap_mcc_context, fid, ctxt, be_pci_func(adapter));
682 AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1); 678 AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1);
683 AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt, 679 AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt,
684 be_encoded_q_len(mccq->len)); 680 be_encoded_q_len(mccq->len));
@@ -727,8 +723,6 @@ int be_cmd_txq_create(struct be_adapter *adapter,
727 723
728 AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, 724 AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt,
729 be_encoded_q_len(txq->len)); 725 be_encoded_q_len(txq->len));
730 AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt,
731 be_pci_func(adapter));
732 AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1); 726 AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1);
733 AMAP_SET_BITS(struct amap_tx_context, cq_id_send, ctxt, cq->id); 727 AMAP_SET_BITS(struct amap_tx_context, cq_id_send, ctxt, cq->id);
734 728
diff --git a/drivers/net/benet/be_hw.h b/drivers/net/benet/be_hw.h
index 5ffb149181ad..2d4a4b827637 100644
--- a/drivers/net/benet/be_hw.h
+++ b/drivers/net/benet/be_hw.h
@@ -114,8 +114,7 @@
114#define IMG_TYPE_ISCSI_BACKUP 9 114#define IMG_TYPE_ISCSI_BACKUP 9
115#define IMG_TYPE_FCOE_FW_ACTIVE 10 115#define IMG_TYPE_FCOE_FW_ACTIVE 10
116#define IMG_TYPE_FCOE_FW_BACKUP 11 116#define IMG_TYPE_FCOE_FW_BACKUP 11
117#define IMG_TYPE_NCSI_BITFILE 13 117#define IMG_TYPE_NCSI_FW 13
118#define IMG_TYPE_NCSI_8051 14
119 118
120#define FLASHROM_OPER_FLASH 1 119#define FLASHROM_OPER_FLASH 1
121#define FLASHROM_OPER_SAVE 2 120#define FLASHROM_OPER_SAVE 2
@@ -127,6 +126,7 @@
127#define FLASH_IMAGE_MAX_SIZE_g3 (2097152) /* Max fw image size */ 126#define FLASH_IMAGE_MAX_SIZE_g3 (2097152) /* Max fw image size */
128#define FLASH_BIOS_IMAGE_MAX_SIZE_g3 (524288) /* Max OPTION ROM img sz */ 127#define FLASH_BIOS_IMAGE_MAX_SIZE_g3 (524288) /* Max OPTION ROM img sz */
129#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g3 (1048576) /* Max Redboot image sz */ 128#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g3 (1048576) /* Max Redboot image sz */
129#define FLASH_NCSI_IMAGE_MAX_SIZE_g3 (262144) /* Max NSCI image sz */
130 130
131#define FLASH_NCSI_MAGIC (0x16032009) 131#define FLASH_NCSI_MAGIC (0x16032009)
132#define FLASH_NCSI_DISABLED (0) 132#define FLASH_NCSI_DISABLED (0)
@@ -144,6 +144,7 @@
144#define FLASH_FCoE_BIOS_START_g2 (524288) 144#define FLASH_FCoE_BIOS_START_g2 (524288)
145#define FLASH_REDBOOT_START_g2 (0) 145#define FLASH_REDBOOT_START_g2 (0)
146 146
147#define FLASH_NCSI_START_g3 (15990784)
147#define FLASH_iSCSI_PRIMARY_IMAGE_START_g3 (2097152) 148#define FLASH_iSCSI_PRIMARY_IMAGE_START_g3 (2097152)
148#define FLASH_iSCSI_BACKUP_IMAGE_START_g3 (4194304) 149#define FLASH_iSCSI_BACKUP_IMAGE_START_g3 (4194304)
149#define FLASH_FCoE_PRIMARY_IMAGE_START_g3 (6291456) 150#define FLASH_FCoE_PRIMARY_IMAGE_START_g3 (6291456)
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index a703ed8e24fe..43e8032f9236 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -1382,7 +1382,7 @@ rx_eq_free:
1382/* There are 8 evt ids per func. Retruns the evt id's bit number */ 1382/* There are 8 evt ids per func. Retruns the evt id's bit number */
1383static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id) 1383static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id)
1384{ 1384{
1385 return eq_id - 8 * be_pci_func(adapter); 1385 return eq_id % 8;
1386} 1386}
1387 1387
1388static irqreturn_t be_intx(int irq, void *dev) 1388static irqreturn_t be_intx(int irq, void *dev)
@@ -1880,8 +1880,9 @@ static int be_flash_data(struct be_adapter *adapter,
1880 const u8 *p = fw->data; 1880 const u8 *p = fw->data;
1881 struct be_cmd_write_flashrom *req = flash_cmd->va; 1881 struct be_cmd_write_flashrom *req = flash_cmd->va;
1882 struct flash_comp *pflashcomp; 1882 struct flash_comp *pflashcomp;
1883 int num_comp;
1883 1884
1884 struct flash_comp gen3_flash_types[8] = { 1885 struct flash_comp gen3_flash_types[9] = {
1885 { FLASH_iSCSI_PRIMARY_IMAGE_START_g3, IMG_TYPE_ISCSI_ACTIVE, 1886 { FLASH_iSCSI_PRIMARY_IMAGE_START_g3, IMG_TYPE_ISCSI_ACTIVE,
1886 FLASH_IMAGE_MAX_SIZE_g3}, 1887 FLASH_IMAGE_MAX_SIZE_g3},
1887 { FLASH_REDBOOT_START_g3, IMG_TYPE_REDBOOT, 1888 { FLASH_REDBOOT_START_g3, IMG_TYPE_REDBOOT,
@@ -1897,7 +1898,9 @@ static int be_flash_data(struct be_adapter *adapter,
1897 { FLASH_FCoE_PRIMARY_IMAGE_START_g3, IMG_TYPE_FCOE_FW_ACTIVE, 1898 { FLASH_FCoE_PRIMARY_IMAGE_START_g3, IMG_TYPE_FCOE_FW_ACTIVE,
1898 FLASH_IMAGE_MAX_SIZE_g3}, 1899 FLASH_IMAGE_MAX_SIZE_g3},
1899 { FLASH_FCoE_BACKUP_IMAGE_START_g3, IMG_TYPE_FCOE_FW_BACKUP, 1900 { FLASH_FCoE_BACKUP_IMAGE_START_g3, IMG_TYPE_FCOE_FW_BACKUP,
1900 FLASH_IMAGE_MAX_SIZE_g3} 1901 FLASH_IMAGE_MAX_SIZE_g3},
1902 { FLASH_NCSI_START_g3, IMG_TYPE_NCSI_FW,
1903 FLASH_NCSI_IMAGE_MAX_SIZE_g3}
1901 }; 1904 };
1902 struct flash_comp gen2_flash_types[8] = { 1905 struct flash_comp gen2_flash_types[8] = {
1903 { FLASH_iSCSI_PRIMARY_IMAGE_START_g2, IMG_TYPE_ISCSI_ACTIVE, 1906 { FLASH_iSCSI_PRIMARY_IMAGE_START_g2, IMG_TYPE_ISCSI_ACTIVE,
@@ -1921,11 +1924,16 @@ static int be_flash_data(struct be_adapter *adapter,
1921 if (adapter->generation == BE_GEN3) { 1924 if (adapter->generation == BE_GEN3) {
1922 pflashcomp = gen3_flash_types; 1925 pflashcomp = gen3_flash_types;
1923 filehdr_size = sizeof(struct flash_file_hdr_g3); 1926 filehdr_size = sizeof(struct flash_file_hdr_g3);
1927 num_comp = 9;
1924 } else { 1928 } else {
1925 pflashcomp = gen2_flash_types; 1929 pflashcomp = gen2_flash_types;
1926 filehdr_size = sizeof(struct flash_file_hdr_g2); 1930 filehdr_size = sizeof(struct flash_file_hdr_g2);
1931 num_comp = 8;
1927 } 1932 }
1928 for (i = 0; i < 8; i++) { 1933 for (i = 0; i < num_comp; i++) {
1934 if ((pflashcomp[i].optype == IMG_TYPE_NCSI_FW) &&
1935 memcmp(adapter->fw_ver, "3.102.148.0", 11) < 0)
1936 continue;
1929 if ((pflashcomp[i].optype == IMG_TYPE_REDBOOT) && 1937 if ((pflashcomp[i].optype == IMG_TYPE_REDBOOT) &&
1930 (!be_flash_redboot(adapter, fw->data, 1938 (!be_flash_redboot(adapter, fw->data,
1931 pflashcomp[i].offset, pflashcomp[i].size, 1939 pflashcomp[i].offset, pflashcomp[i].size,
@@ -1985,16 +1993,7 @@ int be_load_fw(struct be_adapter *adapter, u8 *func)
1985 struct be_dma_mem flash_cmd; 1993 struct be_dma_mem flash_cmd;
1986 int status, i = 0; 1994 int status, i = 0;
1987 const u8 *p; 1995 const u8 *p;
1988 char fw_ver[FW_VER_LEN];
1989 char fw_cfg;
1990
1991 status = be_cmd_get_fw_ver(adapter, fw_ver);
1992 if (status)
1993 return status;
1994 1996
1995 fw_cfg = *(fw_ver + 2);
1996 if (fw_cfg == '0')
1997 fw_cfg = '1';
1998 strcpy(fw_file, func); 1997 strcpy(fw_file, func);
1999 1998
2000 status = request_firmware(&fw, fw_file, &adapter->pdev->dev); 1999 status = request_firmware(&fw, fw_file, &adapter->pdev->dev);
diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
index bf7f9ba2d903..866905fa4119 100644
--- a/drivers/net/can/bfin_can.c
+++ b/drivers/net/can/bfin_can.c
@@ -26,6 +26,7 @@
26 26
27#define DRV_NAME "bfin_can" 27#define DRV_NAME "bfin_can"
28#define BFIN_CAN_TIMEOUT 100 28#define BFIN_CAN_TIMEOUT 100
29#define TX_ECHO_SKB_MAX 1
29 30
30/* 31/*
31 * transmit and receive channels 32 * transmit and receive channels
@@ -593,7 +594,7 @@ struct net_device *alloc_bfin_candev(void)
593 struct net_device *dev; 594 struct net_device *dev;
594 struct bfin_can_priv *priv; 595 struct bfin_can_priv *priv;
595 596
596 dev = alloc_candev(sizeof(*priv)); 597 dev = alloc_candev(sizeof(*priv), TX_ECHO_SKB_MAX);
597 if (!dev) 598 if (!dev)
598 return NULL; 599 return NULL;
599 600
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 11c87840cc00..33451092b8e8 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -876,9 +876,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
876 return NETDEV_TX_OK; 876 return NETDEV_TX_OK;
877 877
878nomem: 878nomem:
879 if (skb) 879 dev_kfree_skb(skb);
880 dev_kfree_skb(skb);
881
882 stats->tx_dropped++; 880 stats->tx_dropped++;
883 881
884 return NETDEV_TX_OK; 882 return NETDEV_TX_OK;
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 7cbcfb0ade1c..9bd155e4111c 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -5072,7 +5072,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5072 INIT_WORK(&cp->reset_task, cas_reset_task); 5072 INIT_WORK(&cp->reset_task, cas_reset_task);
5073 5073
5074 /* Default link parameters */ 5074 /* Default link parameters */
5075 if (link_mode >= 0 && link_mode <= 6) 5075 if (link_mode >= 0 && link_mode < 6)
5076 cp->link_cntl = link_modes[link_mode]; 5076 cp->link_cntl = link_modes[link_mode];
5077 else 5077 else
5078 cp->link_cntl = BMCR_ANENABLE; 5078 cp->link_cntl = BMCR_ANENABLE;
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index b85c81f60d10..60777fd90b33 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -28,6 +28,7 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29 29
30#include <linux/netdevice.h> 30#include <linux/netdevice.h>
31#include <linux/if_vlan.h>
31#include <linux/etherdevice.h> 32#include <linux/etherdevice.h>
32#include <linux/ethtool.h> 33#include <linux/ethtool.h>
33#include <linux/skbuff.h> 34#include <linux/skbuff.h>
@@ -55,9 +56,9 @@ module_param(dumb_switch, int, 0444);
55MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable"); 56MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable");
56MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus"); 57MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus");
57 58
58#define CPMAC_VERSION "0.5.1" 59#define CPMAC_VERSION "0.5.2"
59/* frame size + 802.1q tag */ 60/* frame size + 802.1q tag + FCS size */
60#define CPMAC_SKB_SIZE (ETH_FRAME_LEN + 4) 61#define CPMAC_SKB_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
61#define CPMAC_QUEUES 8 62#define CPMAC_QUEUES 8
62 63
63/* Ethernet registers */ 64/* Ethernet registers */
@@ -1136,8 +1137,9 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1136 } 1137 }
1137 1138
1138 if (phy_id == PHY_MAX_ADDR) { 1139 if (phy_id == PHY_MAX_ADDR) {
1139 dev_err(&pdev->dev, "no PHY present\n"); 1140 dev_err(&pdev->dev, "no PHY present, falling back to switch on MDIO bus 0\n");
1140 return -ENODEV; 1141 strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */
1142 phy_id = pdev->id;
1141 } 1143 }
1142 1144
1143 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); 1145 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
@@ -1290,8 +1292,8 @@ void __devexit cpmac_exit(void)
1290{ 1292{
1291 platform_driver_unregister(&cpmac_driver); 1293 platform_driver_unregister(&cpmac_driver);
1292 mdiobus_unregister(cpmac_mii); 1294 mdiobus_unregister(cpmac_mii);
1293 mdiobus_free(cpmac_mii);
1294 iounmap(cpmac_mii->priv); 1295 iounmap(cpmac_mii->priv);
1296 mdiobus_free(cpmac_mii);
1295} 1297}
1296 1298
1297module_init(cpmac_init); 1299module_init(cpmac_init);
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 3e453e1d97e7..9e3e8750b46a 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -1294,6 +1294,7 @@ static void cxgb_down(struct adapter *adapter)
1294 1294
1295 free_irq_resources(adapter); 1295 free_irq_resources(adapter);
1296 quiesce_rx(adapter); 1296 quiesce_rx(adapter);
1297 t3_sge_stop(adapter);
1297 flush_workqueue(cxgb3_wq); /* wait for external IRQ handler */ 1298 flush_workqueue(cxgb3_wq); /* wait for external IRQ handler */
1298} 1299}
1299 1300
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 13f9869927e3..8bd086aee56d 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -2385,7 +2385,7 @@ static int emac_dev_open(struct net_device *ndev)
2385 struct emac_priv *priv = netdev_priv(ndev); 2385 struct emac_priv *priv = netdev_priv(ndev);
2386 2386
2387 netif_carrier_off(ndev); 2387 netif_carrier_off(ndev);
2388 for (cnt = 0; cnt <= ETH_ALEN; cnt++) 2388 for (cnt = 0; cnt < ETH_ALEN; cnt++)
2389 ndev->dev_addr[cnt] = priv->mac_addr[cnt]; 2389 ndev->dev_addr[cnt] = priv->mac_addr[cnt];
2390 2390
2391 /* Configuration items */ 2391 /* Configuration items */
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index db05ec355749..e301e26d6897 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -320,6 +320,8 @@
320#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ 320#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */
321 321
322/* Header split receive */ 322/* Header split receive */
323#define E1000_RFCTL_NFSW_DIS 0x00000040
324#define E1000_RFCTL_NFSR_DIS 0x00000080
323#define E1000_RFCTL_ACK_DIS 0x00001000 325#define E1000_RFCTL_ACK_DIS 0x00001000
324#define E1000_RFCTL_EXTEN 0x00008000 326#define E1000_RFCTL_EXTEN 0x00008000
325#define E1000_RFCTL_IPV6_EX_DIS 0x00010000 327#define E1000_RFCTL_IPV6_EX_DIS 0x00010000
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 54d03a0ce3ce..8b5e157e9c87 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -2740,6 +2740,16 @@ static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
2740 reg &= ~(1 << 31); 2740 reg &= ~(1 << 31);
2741 ew32(STATUS, reg); 2741 ew32(STATUS, reg);
2742 } 2742 }
2743
2744 /*
2745 * work-around descriptor data corruption issue during nfs v2 udp
2746 * traffic, just disable the nfs filtering capability
2747 */
2748 reg = er32(RFCTL);
2749 reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
2750 ew32(RFCTL, reg);
2751
2752 return;
2743} 2753}
2744 2754
2745/** 2755/**
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 61a7b4351e78..b6715553cf17 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -2021,7 +2021,6 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2021 } 2021 }
2022 2022
2023 /* setup the TxBD length and buffer pointer for the first BD */ 2023 /* setup the TxBD length and buffer pointer for the first BD */
2024 tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
2025 txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data, 2024 txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data,
2026 skb_headlen(skb), DMA_TO_DEVICE); 2025 skb_headlen(skb), DMA_TO_DEVICE);
2027 2026
@@ -2053,6 +2052,10 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2053 2052
2054 txbdp_start->lstatus = lstatus; 2053 txbdp_start->lstatus = lstatus;
2055 2054
2055 eieio(); /* force lstatus write before tx_skbuff */
2056
2057 tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
2058
2056 /* Update the current skb pointer to the next entry we will use 2059 /* Update the current skb pointer to the next entry we will use
2057 * (wrapping if necessary) */ 2060 * (wrapping if necessary) */
2058 tx_queue->skb_curtx = (tx_queue->skb_curtx + 1) & 2061 tx_queue->skb_curtx = (tx_queue->skb_curtx + 1) &
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index e8e33bb9d876..2c9b3af16612 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1651,6 +1651,8 @@ static int irda_usb_probe(struct usb_interface *intf,
1651 1651
1652 self->rx_urb = kcalloc(self->max_rx_urb, sizeof(struct urb *), 1652 self->rx_urb = kcalloc(self->max_rx_urb, sizeof(struct urb *),
1653 GFP_KERNEL); 1653 GFP_KERNEL);
1654 if (!self->rx_urb)
1655 goto err_free_net;
1654 1656
1655 for (i = 0; i < self->max_rx_urb; i++) { 1657 for (i = 0; i < self->max_rx_urb; i++) {
1656 self->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); 1658 self->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
@@ -1783,6 +1785,8 @@ err_out_2:
1783err_out_1: 1785err_out_1:
1784 for (i = 0; i < self->max_rx_urb; i++) 1786 for (i = 0; i < self->max_rx_urb; i++)
1785 usb_free_urb(self->rx_urb[i]); 1787 usb_free_urb(self->rx_urb[i]);
1788 kfree(self->rx_urb);
1789err_free_net:
1786 free_netdev(net); 1790 free_netdev(net);
1787err_out: 1791err_out:
1788 return ret; 1792 return ret;
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index b40a851ec7d1..0da94b208db1 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -423,6 +423,11 @@ struct qlcnic_adapter_stats {
423 u64 lro_pkts; 423 u64 lro_pkts;
424 u64 rxbytes; 424 u64 rxbytes;
425 u64 txbytes; 425 u64 txbytes;
426 u64 lrobytes;
427 u64 lso_frames;
428 u64 xmit_on;
429 u64 xmit_off;
430 u64 skb_alloc_failure;
426}; 431};
427 432
428/* 433/*
@@ -1095,11 +1100,11 @@ struct qlcnic_brdinfo {
1095 1100
1096static const struct qlcnic_brdinfo qlcnic_boards[] = { 1101static const struct qlcnic_brdinfo qlcnic_boards[] = {
1097 {0x1077, 0x8020, 0x1077, 0x203, 1102 {0x1077, 0x8020, 0x1077, 0x203,
1098 "8200 Series Single Port 10GbE Converged Network Adapter \ 1103 "8200 Series Single Port 10GbE Converged Network Adapter "
1099 (TCP/IP Networking)"}, 1104 "(TCP/IP Networking)"},
1100 {0x1077, 0x8020, 0x1077, 0x207, 1105 {0x1077, 0x8020, 0x1077, 0x207,
1101 "8200 Series Dual Port 10GbE Converged Network Adapter \ 1106 "8200 Series Dual Port 10GbE Converged Network Adapter "
1102 (TCP/IP Networking)"}, 1107 "(TCP/IP Networking)"},
1103 {0x1077, 0x8020, 0x1077, 0x20b, 1108 {0x1077, 0x8020, 0x1077, 0x20b,
1104 "3200 Series Dual Port 10Gb Intelligent Ethernet Adapter"}, 1109 "3200 Series Dual Port 10Gb Intelligent Ethernet Adapter"},
1105 {0x1077, 0x8020, 0x1077, 0x20c, 1110 {0x1077, 0x8020, 0x1077, 0x20c,
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index 8da6ec8c13b9..f83e15fe3e1b 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -59,6 +59,17 @@ static const struct qlcnic_stats qlcnic_gstrings_stats[] = {
59 QLC_SIZEOF(stats.rxbytes), QLC_OFF(stats.rxbytes)}, 59 QLC_SIZEOF(stats.rxbytes), QLC_OFF(stats.rxbytes)},
60 {"tx_bytes", 60 {"tx_bytes",
61 QLC_SIZEOF(stats.txbytes), QLC_OFF(stats.txbytes)}, 61 QLC_SIZEOF(stats.txbytes), QLC_OFF(stats.txbytes)},
62 {"lrobytes",
63 QLC_SIZEOF(stats.lrobytes), QLC_OFF(stats.lrobytes)},
64 {"lso_frames",
65 QLC_SIZEOF(stats.lso_frames), QLC_OFF(stats.lso_frames)},
66 {"xmit_on",
67 QLC_SIZEOF(stats.xmit_on), QLC_OFF(stats.xmit_on)},
68 {"xmit_off",
69 QLC_SIZEOF(stats.xmit_off), QLC_OFF(stats.xmit_off)},
70 {"skb_alloc_failure", QLC_SIZEOF(stats.skb_alloc_failure),
71 QLC_OFF(stats.skb_alloc_failure)},
72
62}; 73};
63 74
64#define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) 75#define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats)
@@ -785,6 +796,11 @@ qlcnic_get_ethtool_stats(struct net_device *dev,
785 } 796 }
786} 797}
787 798
799static u32 qlcnic_get_tx_csum(struct net_device *dev)
800{
801 return dev->features & NETIF_F_IP_CSUM;
802}
803
788static u32 qlcnic_get_rx_csum(struct net_device *dev) 804static u32 qlcnic_get_rx_csum(struct net_device *dev)
789{ 805{
790 struct qlcnic_adapter *adapter = netdev_priv(dev); 806 struct qlcnic_adapter *adapter = netdev_priv(dev);
@@ -995,6 +1011,7 @@ const struct ethtool_ops qlcnic_ethtool_ops = {
995 .set_ringparam = qlcnic_set_ringparam, 1011 .set_ringparam = qlcnic_set_ringparam,
996 .get_pauseparam = qlcnic_get_pauseparam, 1012 .get_pauseparam = qlcnic_get_pauseparam,
997 .set_pauseparam = qlcnic_set_pauseparam, 1013 .set_pauseparam = qlcnic_set_pauseparam,
1014 .get_tx_csum = qlcnic_get_tx_csum,
998 .set_tx_csum = ethtool_op_set_tx_csum, 1015 .set_tx_csum = ethtool_op_set_tx_csum,
999 .set_sg = ethtool_op_set_sg, 1016 .set_sg = ethtool_op_set_sg,
1000 .get_tso = qlcnic_get_tso, 1017 .get_tso = qlcnic_get_tso,
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index 99a4d1379d00..da00e162b6d3 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -349,6 +349,7 @@ qlcnic_send_cmd_descs(struct qlcnic_adapter *adapter,
349 if (nr_desc >= qlcnic_tx_avail(tx_ring)) { 349 if (nr_desc >= qlcnic_tx_avail(tx_ring)) {
350 netif_tx_stop_queue(tx_ring->txq); 350 netif_tx_stop_queue(tx_ring->txq);
351 __netif_tx_unlock_bh(tx_ring->txq); 351 __netif_tx_unlock_bh(tx_ring->txq);
352 adapter->stats.xmit_off++;
352 return -EBUSY; 353 return -EBUSY;
353 } 354 }
354 355
@@ -397,20 +398,16 @@ qlcnic_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr,
397 return qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); 398 return qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
398} 399}
399 400
400static int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, 401static int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, u8 *addr)
401 u8 *addr, struct list_head *del_list)
402{ 402{
403 struct list_head *head; 403 struct list_head *head;
404 struct qlcnic_mac_list_s *cur; 404 struct qlcnic_mac_list_s *cur;
405 405
406 /* look up if already exists */ 406 /* look up if already exists */
407 list_for_each(head, del_list) { 407 list_for_each(head, &adapter->mac_list) {
408 cur = list_entry(head, struct qlcnic_mac_list_s, list); 408 cur = list_entry(head, struct qlcnic_mac_list_s, list);
409 409 if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0)
410 if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0) {
411 list_move_tail(head, &adapter->mac_list);
412 return 0; 410 return 0;
413 }
414 } 411 }
415 412
416 cur = kzalloc(sizeof(struct qlcnic_mac_list_s), GFP_ATOMIC); 413 cur = kzalloc(sizeof(struct qlcnic_mac_list_s), GFP_ATOMIC);
@@ -432,14 +429,9 @@ void qlcnic_set_multi(struct net_device *netdev)
432 struct dev_mc_list *mc_ptr; 429 struct dev_mc_list *mc_ptr;
433 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 430 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
434 u32 mode = VPORT_MISS_MODE_DROP; 431 u32 mode = VPORT_MISS_MODE_DROP;
435 LIST_HEAD(del_list);
436 struct list_head *head;
437 struct qlcnic_mac_list_s *cur;
438 432
439 list_splice_tail_init(&adapter->mac_list, &del_list); 433 qlcnic_nic_add_mac(adapter, adapter->mac_addr);
440 434 qlcnic_nic_add_mac(adapter, bcast_addr);
441 qlcnic_nic_add_mac(adapter, adapter->mac_addr, &del_list);
442 qlcnic_nic_add_mac(adapter, bcast_addr, &del_list);
443 435
444 if (netdev->flags & IFF_PROMISC) { 436 if (netdev->flags & IFF_PROMISC) {
445 mode = VPORT_MISS_MODE_ACCEPT_ALL; 437 mode = VPORT_MISS_MODE_ACCEPT_ALL;
@@ -454,22 +446,12 @@ void qlcnic_set_multi(struct net_device *netdev)
454 446
455 if (!netdev_mc_empty(netdev)) { 447 if (!netdev_mc_empty(netdev)) {
456 netdev_for_each_mc_addr(mc_ptr, netdev) { 448 netdev_for_each_mc_addr(mc_ptr, netdev) {
457 qlcnic_nic_add_mac(adapter, mc_ptr->dmi_addr, 449 qlcnic_nic_add_mac(adapter, mc_ptr->dmi_addr);
458 &del_list);
459 } 450 }
460 } 451 }
461 452
462send_fw_cmd: 453send_fw_cmd:
463 qlcnic_nic_set_promisc(adapter, mode); 454 qlcnic_nic_set_promisc(adapter, mode);
464 head = &del_list;
465 while (!list_empty(head)) {
466 cur = list_entry(head->next, struct qlcnic_mac_list_s, list);
467
468 qlcnic_sre_macaddr_change(adapter,
469 cur->mac_addr, QLCNIC_MAC_DEL);
470 list_del(&cur->list);
471 kfree(cur);
472 }
473} 455}
474 456
475int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, u32 mode) 457int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, u32 mode)
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c
index ea00ab4d4feb..7c34e4e29b3f 100644
--- a/drivers/net/qlcnic/qlcnic_init.c
+++ b/drivers/net/qlcnic/qlcnic_init.c
@@ -568,21 +568,123 @@ struct uni_table_desc *qlcnic_get_table_desc(const u8 *unirom, int section)
568 return NULL; 568 return NULL;
569} 569}
570 570
571#define FILEHEADER_SIZE (14 * 4)
572
571static int 573static int
572qlcnic_set_product_offs(struct qlcnic_adapter *adapter) 574qlcnic_validate_header(struct qlcnic_adapter *adapter)
573{ 575{
574 struct uni_table_desc *ptab_descr;
575 const u8 *unirom = adapter->fw->data; 576 const u8 *unirom = adapter->fw->data;
576 u32 i; 577 struct uni_table_desc *directory = (struct uni_table_desc *) &unirom[0];
578 __le32 fw_file_size = adapter->fw->size;
577 __le32 entries; 579 __le32 entries;
580 __le32 entry_size;
581 __le32 tab_size;
582
583 if (fw_file_size < FILEHEADER_SIZE)
584 return -EINVAL;
585
586 entries = cpu_to_le32(directory->num_entries);
587 entry_size = cpu_to_le32(directory->entry_size);
588 tab_size = cpu_to_le32(directory->findex) + (entries * entry_size);
589
590 if (fw_file_size < tab_size)
591 return -EINVAL;
592
593 return 0;
594}
595
596static int
597qlcnic_validate_bootld(struct qlcnic_adapter *adapter)
598{
599 struct uni_table_desc *tab_desc;
600 struct uni_data_desc *descr;
601 const u8 *unirom = adapter->fw->data;
602 int idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
603 QLCNIC_UNI_BOOTLD_IDX_OFF));
604 __le32 offs;
605 __le32 tab_size;
606 __le32 data_size;
607
608 tab_desc = qlcnic_get_table_desc(unirom, QLCNIC_UNI_DIR_SECT_BOOTLD);
609
610 if (!tab_desc)
611 return -EINVAL;
612
613 tab_size = cpu_to_le32(tab_desc->findex) +
614 (cpu_to_le32(tab_desc->entry_size * (idx + 1)));
615
616 if (adapter->fw->size < tab_size)
617 return -EINVAL;
618
619 offs = cpu_to_le32(tab_desc->findex) +
620 (cpu_to_le32(tab_desc->entry_size) * (idx));
621 descr = (struct uni_data_desc *)&unirom[offs];
622
623 data_size = descr->findex + cpu_to_le32(descr->size);
624
625 if (adapter->fw->size < data_size)
626 return -EINVAL;
627
628 return 0;
629}
630
631static int
632qlcnic_validate_fw(struct qlcnic_adapter *adapter)
633{
634 struct uni_table_desc *tab_desc;
635 struct uni_data_desc *descr;
636 const u8 *unirom = adapter->fw->data;
637 int idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
638 QLCNIC_UNI_FIRMWARE_IDX_OFF));
639 __le32 offs;
640 __le32 tab_size;
641 __le32 data_size;
642
643 tab_desc = qlcnic_get_table_desc(unirom, QLCNIC_UNI_DIR_SECT_FW);
644
645 if (!tab_desc)
646 return -EINVAL;
647
648 tab_size = cpu_to_le32(tab_desc->findex) +
649 (cpu_to_le32(tab_desc->entry_size * (idx + 1)));
650
651 if (adapter->fw->size < tab_size)
652 return -EINVAL;
653
654 offs = cpu_to_le32(tab_desc->findex) +
655 (cpu_to_le32(tab_desc->entry_size) * (idx));
656 descr = (struct uni_data_desc *)&unirom[offs];
657 data_size = descr->findex + cpu_to_le32(descr->size);
658
659 if (adapter->fw->size < data_size)
660 return -EINVAL;
661
662 return 0;
663}
664
665static int
666qlcnic_validate_product_offs(struct qlcnic_adapter *adapter)
667{
668 struct uni_table_desc *ptab_descr;
669 const u8 *unirom = adapter->fw->data;
578 int mn_present = qlcnic_has_mn(adapter); 670 int mn_present = qlcnic_has_mn(adapter);
671 __le32 entries;
672 __le32 entry_size;
673 __le32 tab_size;
674 u32 i;
579 675
580 ptab_descr = qlcnic_get_table_desc(unirom, 676 ptab_descr = qlcnic_get_table_desc(unirom,
581 QLCNIC_UNI_DIR_SECT_PRODUCT_TBL); 677 QLCNIC_UNI_DIR_SECT_PRODUCT_TBL);
582 if (ptab_descr == NULL) 678 if (!ptab_descr)
583 return -1; 679 return -EINVAL;
584 680
585 entries = cpu_to_le32(ptab_descr->num_entries); 681 entries = cpu_to_le32(ptab_descr->num_entries);
682 entry_size = cpu_to_le32(ptab_descr->entry_size);
683 tab_size = cpu_to_le32(ptab_descr->findex) + (entries * entry_size);
684
685 if (adapter->fw->size < tab_size)
686 return -EINVAL;
687
586nomn: 688nomn:
587 for (i = 0; i < entries; i++) { 689 for (i = 0; i < entries; i++) {
588 690
@@ -609,7 +711,37 @@ nomn:
609 mn_present = 0; 711 mn_present = 0;
610 goto nomn; 712 goto nomn;
611 } 713 }
612 return -1; 714 return -EINVAL;
715}
716
717static int
718qlcnic_validate_unified_romimage(struct qlcnic_adapter *adapter)
719{
720 if (qlcnic_validate_header(adapter)) {
721 dev_err(&adapter->pdev->dev,
722 "unified image: header validation failed\n");
723 return -EINVAL;
724 }
725
726 if (qlcnic_validate_product_offs(adapter)) {
727 dev_err(&adapter->pdev->dev,
728 "unified image: product validation failed\n");
729 return -EINVAL;
730 }
731
732 if (qlcnic_validate_bootld(adapter)) {
733 dev_err(&adapter->pdev->dev,
734 "unified image: bootld validation failed\n");
735 return -EINVAL;
736 }
737
738 if (qlcnic_validate_fw(adapter)) {
739 dev_err(&adapter->pdev->dev,
740 "unified image: firmware validation failed\n");
741 return -EINVAL;
742 }
743
744 return 0;
613} 745}
614 746
615static 747static
@@ -715,7 +847,7 @@ qlcnic_get_bios_version(struct qlcnic_adapter *adapter)
715 bios_ver = cpu_to_le32(*((u32 *) (&fw->data[prd_off]) 847 bios_ver = cpu_to_le32(*((u32 *) (&fw->data[prd_off])
716 + QLCNIC_UNI_BIOS_VERSION_OFF)); 848 + QLCNIC_UNI_BIOS_VERSION_OFF));
717 849
718 return (bios_ver << 24) + ((bios_ver >> 8) & 0xff00) + (bios_ver >> 24); 850 return (bios_ver << 16) + ((bios_ver >> 8) & 0xff00) + (bios_ver >> 24);
719} 851}
720 852
721int 853int
@@ -858,7 +990,7 @@ qlcnic_validate_firmware(struct qlcnic_adapter *adapter)
858 u8 fw_type = adapter->fw_type; 990 u8 fw_type = adapter->fw_type;
859 991
860 if (fw_type == QLCNIC_UNIFIED_ROMIMAGE) { 992 if (fw_type == QLCNIC_UNIFIED_ROMIMAGE) {
861 if (qlcnic_set_product_offs(adapter)) 993 if (qlcnic_validate_unified_romimage(adapter))
862 return -EINVAL; 994 return -EINVAL;
863 995
864 min_size = QLCNIC_UNI_FW_MIN_SIZE; 996 min_size = QLCNIC_UNI_FW_MIN_SIZE;
@@ -1114,8 +1246,10 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
1114 struct pci_dev *pdev = adapter->pdev; 1246 struct pci_dev *pdev = adapter->pdev;
1115 1247
1116 buffer->skb = dev_alloc_skb(rds_ring->skb_size); 1248 buffer->skb = dev_alloc_skb(rds_ring->skb_size);
1117 if (!buffer->skb) 1249 if (!buffer->skb) {
1250 adapter->stats.skb_alloc_failure++;
1118 return -ENOMEM; 1251 return -ENOMEM;
1252 }
1119 1253
1120 skb = buffer->skb; 1254 skb = buffer->skb;
1121 1255
@@ -1289,7 +1423,7 @@ qlcnic_process_lro(struct qlcnic_adapter *adapter,
1289 netif_receive_skb(skb); 1423 netif_receive_skb(skb);
1290 1424
1291 adapter->stats.lro_pkts++; 1425 adapter->stats.lro_pkts++;
1292 adapter->stats.rxbytes += length; 1426 adapter->stats.lrobytes += length;
1293 1427
1294 return buffer; 1428 return buffer;
1295} 1429}
@@ -1505,6 +1639,8 @@ qlcnic_process_rcv_diag(struct qlcnic_adapter *adapter,
1505 adapter->diag_cnt++; 1639 adapter->diag_cnt++;
1506 1640
1507 dev_kfree_skb_any(skb); 1641 dev_kfree_skb_any(skb);
1642 adapter->stats.rx_pkts++;
1643 adapter->stats.rxbytes += length;
1508 1644
1509 return buffer; 1645 return buffer;
1510} 1646}
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 665e8e56b6a8..fc721564e69e 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -118,6 +118,7 @@ qlcnic_update_cmd_producer(struct qlcnic_adapter *adapter,
118 if (qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH) { 118 if (qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH) {
119 netif_stop_queue(adapter->netdev); 119 netif_stop_queue(adapter->netdev);
120 smp_mb(); 120 smp_mb();
121 adapter->stats.xmit_off++;
121 } 122 }
122} 123}
123 124
@@ -1385,6 +1386,7 @@ qlcnic_tso_check(struct net_device *netdev,
1385 int copied, offset, copy_len, hdr_len = 0, tso = 0, vlan_oob = 0; 1386 int copied, offset, copy_len, hdr_len = 0, tso = 0, vlan_oob = 0;
1386 struct cmd_desc_type0 *hwdesc; 1387 struct cmd_desc_type0 *hwdesc;
1387 struct vlan_ethhdr *vh; 1388 struct vlan_ethhdr *vh;
1389 struct qlcnic_adapter *adapter = netdev_priv(netdev);
1388 1390
1389 if (protocol == cpu_to_be16(ETH_P_8021Q)) { 1391 if (protocol == cpu_to_be16(ETH_P_8021Q)) {
1390 1392
@@ -1494,6 +1496,7 @@ qlcnic_tso_check(struct net_device *netdev,
1494 1496
1495 tx_ring->producer = producer; 1497 tx_ring->producer = producer;
1496 barrier(); 1498 barrier();
1499 adapter->stats.lso_frames++;
1497} 1500}
1498 1501
1499static int 1502static int
@@ -1573,6 +1576,7 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1573 1576
1574 if (unlikely(no_of_desc + 2 > qlcnic_tx_avail(tx_ring))) { 1577 if (unlikely(no_of_desc + 2 > qlcnic_tx_avail(tx_ring))) {
1575 netif_stop_queue(netdev); 1578 netif_stop_queue(netdev);
1579 adapter->stats.xmit_off++;
1576 return NETDEV_TX_BUSY; 1580 return NETDEV_TX_BUSY;
1577 } 1581 }
1578 1582
@@ -1880,6 +1884,7 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter)
1880 if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) { 1884 if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) {
1881 netif_wake_queue(netdev); 1885 netif_wake_queue(netdev);
1882 adapter->tx_timeo_cnt = 0; 1886 adapter->tx_timeo_cnt = 0;
1887 adapter->stats.xmit_on++;
1883 } 1888 }
1884 __netif_tx_unlock(tx_ring->txq); 1889 __netif_tx_unlock(tx_ring->txq);
1885 } 1890 }
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index dfc3573c91bb..9d3ebf3e975e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -4270,7 +4270,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
4270 4270
4271 tp->cur_tx += frags + 1; 4271 tp->cur_tx += frags + 1;
4272 4272
4273 smp_wmb(); 4273 wmb();
4274 4274
4275 RTL_W8(TxPoll, NPQ); /* set polling bit */ 4275 RTL_W8(TxPoll, NPQ); /* set polling bit */
4276 4276
@@ -4621,7 +4621,7 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
4621 * until it does. 4621 * until it does.
4622 */ 4622 */
4623 tp->intr_mask = 0xffff; 4623 tp->intr_mask = 0xffff;
4624 smp_wmb(); 4624 wmb();
4625 RTL_W16(IntrMask, tp->intr_event); 4625 RTL_W16(IntrMask, tp->intr_event);
4626 } 4626 }
4627 4627
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 43bc66aa8405..df70657260dd 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -923,8 +923,8 @@ static int init_shared_mem(struct s2io_nic *nic)
923 tmp_v_addr = mac_control->stats_mem; 923 tmp_v_addr = mac_control->stats_mem;
924 mac_control->stats_info = (struct stat_block *)tmp_v_addr; 924 mac_control->stats_info = (struct stat_block *)tmp_v_addr;
925 memset(tmp_v_addr, 0, size); 925 memset(tmp_v_addr, 0, size);
926 DBG_PRINT(INIT_DBG, "%s: Ring Mem PHY: 0x%llx\n", dev->name, 926 DBG_PRINT(INIT_DBG, "%s: Ring Mem PHY: 0x%llx\n",
927 (unsigned long long)tmp_p_addr); 927 dev_name(&nic->pdev->dev), (unsigned long long)tmp_p_addr);
928 mac_control->stats_info->sw_stat.mem_allocated += mem_allocated; 928 mac_control->stats_info->sw_stat.mem_allocated += mem_allocated;
929 return SUCCESS; 929 return SUCCESS;
930} 930}
@@ -3480,7 +3480,7 @@ static void s2io_reset(struct s2io_nic *sp)
3480 struct swStat *swstats; 3480 struct swStat *swstats;
3481 3481
3482 DBG_PRINT(INIT_DBG, "%s: Resetting XFrame card %s\n", 3482 DBG_PRINT(INIT_DBG, "%s: Resetting XFrame card %s\n",
3483 __func__, sp->dev->name); 3483 __func__, pci_name(sp->pdev));
3484 3484
3485 /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */ 3485 /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */
3486 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd)); 3486 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd));
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 653bdd76ef46..d8ec4c11fd49 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -4863,6 +4863,7 @@ static int sky2_resume(struct pci_dev *pdev)
4863 if (!hw) 4863 if (!hw)
4864 return 0; 4864 return 0;
4865 4865
4866 rtnl_lock();
4866 err = pci_set_power_state(pdev, PCI_D0); 4867 err = pci_set_power_state(pdev, PCI_D0);
4867 if (err) 4868 if (err)
4868 goto out; 4869 goto out;
@@ -4884,7 +4885,6 @@ static int sky2_resume(struct pci_dev *pdev)
4884 sky2_write32(hw, B0_IMSK, Y2_IS_BASE); 4885 sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
4885 napi_enable(&hw->napi); 4886 napi_enable(&hw->napi);
4886 4887
4887 rtnl_lock();
4888 for (i = 0; i < hw->ports; i++) { 4888 for (i = 0; i < hw->ports; i++) {
4889 err = sky2_reattach(hw->dev[i]); 4889 err = sky2_reattach(hw->dev[i]);
4890 if (err) 4890 if (err)
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 54799544bda3..8d2772cc42f2 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -330,6 +330,48 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
330 330
331#include <unit/smc91111.h> 331#include <unit/smc91111.h>
332 332
333#elif defined(CONFIG_ARCH_MSM)
334
335#define SMC_CAN_USE_8BIT 0
336#define SMC_CAN_USE_16BIT 1
337#define SMC_CAN_USE_32BIT 0
338#define SMC_NOWAIT 1
339
340#define SMC_inw(a, r) readw((a) + (r))
341#define SMC_outw(v, a, r) writew(v, (a) + (r))
342#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
343#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
344
345#define SMC_IRQ_FLAGS IRQF_TRIGGER_HIGH
346
347#elif defined(CONFIG_COLDFIRE)
348
349#define SMC_CAN_USE_8BIT 0
350#define SMC_CAN_USE_16BIT 1
351#define SMC_CAN_USE_32BIT 0
352#define SMC_NOWAIT 1
353
354static inline void mcf_insw(void *a, unsigned char *p, int l)
355{
356 u16 *wp = (u16 *) p;
357 while (l-- > 0)
358 *wp++ = readw(a);
359}
360
361static inline void mcf_outsw(void *a, unsigned char *p, int l)
362{
363 u16 *wp = (u16 *) p;
364 while (l-- > 0)
365 writew(*wp++, a);
366}
367
368#define SMC_inw(a, r) _swapw(readw((a) + (r)))
369#define SMC_outw(v, a, r) writew(_swapw(v), (a) + (r))
370#define SMC_insw(a, r, p, l) mcf_insw(a + r, p, l)
371#define SMC_outsw(a, r, p, l) mcf_outsw(a + r, p, l)
372
373#define SMC_IRQ_FLAGS (IRQF_DISABLED)
374
333#else 375#else
334 376
335/* 377/*
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 0fa7688ab483..22cf1c446de3 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -5279,7 +5279,7 @@ static void tg3_poll_controller(struct net_device *dev)
5279 struct tg3 *tp = netdev_priv(dev); 5279 struct tg3 *tp = netdev_priv(dev);
5280 5280
5281 for (i = 0; i < tp->irq_cnt; i++) 5281 for (i = 0; i < tp->irq_cnt; i++)
5282 tg3_interrupt(tp->napi[i].irq_vec, dev); 5282 tg3_interrupt(tp->napi[i].irq_vec, &tp->napi[i]);
5283} 5283}
5284#endif 5284#endif
5285 5285
@@ -9776,7 +9776,7 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
9776 ADVERTISED_Pause | 9776 ADVERTISED_Pause |
9777 ADVERTISED_Asym_Pause; 9777 ADVERTISED_Asym_Pause;
9778 9778
9779 if (!(tp->tg3_flags2 & TG3_FLAG_10_100_ONLY)) 9779 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY))
9780 mask |= ADVERTISED_1000baseT_Half | 9780 mask |= ADVERTISED_1000baseT_Half |
9781 ADVERTISED_1000baseT_Full; 9781 ADVERTISED_1000baseT_Full;
9782 9782
diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
index 93f4e8309f81..49f05d1431f5 100644
--- a/drivers/net/tulip/eeprom.c
+++ b/drivers/net/tulip/eeprom.c
@@ -143,6 +143,12 @@ static void __devinit tulip_build_fake_mediatable(struct tulip_private *tp)
143 143
144void __devinit tulip_parse_eeprom(struct net_device *dev) 144void __devinit tulip_parse_eeprom(struct net_device *dev)
145{ 145{
146 /*
147 dev is not registered at this point, so logging messages can't
148 use dev_<level> or netdev_<level> but dev->name is good via a
149 hack in the caller
150 */
151
146 /* The last media info list parsed, for multiport boards. */ 152 /* The last media info list parsed, for multiport boards. */
147 static struct mediatable *last_mediatable; 153 static struct mediatable *last_mediatable;
148 static unsigned char *last_ee_data; 154 static unsigned char *last_ee_data;
@@ -161,15 +167,14 @@ void __devinit tulip_parse_eeprom(struct net_device *dev)
161 if (ee_data[0] == 0xff) { 167 if (ee_data[0] == 0xff) {
162 if (last_mediatable) { 168 if (last_mediatable) {
163 controller_index++; 169 controller_index++;
164 dev_info(&dev->dev, 170 pr_info("%s: Controller %d of multiport board\n",
165 "Controller %d of multiport board\n", 171 dev->name, controller_index);
166 controller_index);
167 tp->mtable = last_mediatable; 172 tp->mtable = last_mediatable;
168 ee_data = last_ee_data; 173 ee_data = last_ee_data;
169 goto subsequent_board; 174 goto subsequent_board;
170 } else 175 } else
171 dev_info(&dev->dev, 176 pr_info("%s: Missing EEPROM, this interface may not work correctly!\n",
172 "Missing EEPROM, this interface may not work correctly!\n"); 177 dev->name);
173 return; 178 return;
174 } 179 }
175 /* Do a fix-up based on the vendor half of the station address prefix. */ 180 /* Do a fix-up based on the vendor half of the station address prefix. */
@@ -181,15 +186,14 @@ void __devinit tulip_parse_eeprom(struct net_device *dev)
181 i++; /* An Accton EN1207, not an outlaw Maxtech. */ 186 i++; /* An Accton EN1207, not an outlaw Maxtech. */
182 memcpy(ee_data + 26, eeprom_fixups[i].newtable, 187 memcpy(ee_data + 26, eeprom_fixups[i].newtable,
183 sizeof(eeprom_fixups[i].newtable)); 188 sizeof(eeprom_fixups[i].newtable));
184 dev_info(&dev->dev, 189 pr_info("%s: Old format EEPROM on '%s' board. Using substitute media control info\n",
185 "Old format EEPROM on '%s' board. Using substitute media control info\n", 190 dev->name, eeprom_fixups[i].name);
186 eeprom_fixups[i].name);
187 break; 191 break;
188 } 192 }
189 } 193 }
190 if (eeprom_fixups[i].name == NULL) { /* No fixup found. */ 194 if (eeprom_fixups[i].name == NULL) { /* No fixup found. */
191 dev_info(&dev->dev, 195 pr_info("%s: Old style EEPROM with no media selection information\n",
192 "Old style EEPROM with no media selection information\n"); 196 dev->name);
193 return; 197 return;
194 } 198 }
195 } 199 }
@@ -217,8 +221,8 @@ subsequent_board:
217 /* there is no phy information, don't even try to build mtable */ 221 /* there is no phy information, don't even try to build mtable */
218 if (count == 0) { 222 if (count == 0) {
219 if (tulip_debug > 0) 223 if (tulip_debug > 0)
220 dev_warn(&dev->dev, 224 pr_warning("%s: no phy info, aborting mtable build\n",
221 "no phy info, aborting mtable build\n"); 225 dev->name);
222 return; 226 return;
223 } 227 }
224 228
@@ -234,8 +238,10 @@ subsequent_board:
234 mtable->has_nonmii = mtable->has_mii = mtable->has_reset = 0; 238 mtable->has_nonmii = mtable->has_mii = mtable->has_reset = 0;
235 mtable->csr15dir = mtable->csr15val = 0; 239 mtable->csr15dir = mtable->csr15val = 0;
236 240
237 dev_info(&dev->dev, "EEPROM default media type %s\n", 241 pr_info("%s: EEPROM default media type %s\n",
238 media & 0x0800 ? "Autosense" : medianame[media & MEDIA_MASK]); 242 dev->name,
243 media & 0x0800 ? "Autosense"
244 : medianame[media & MEDIA_MASK]);
239 for (i = 0; i < count; i++) { 245 for (i = 0; i < count; i++) {
240 struct medialeaf *leaf = &mtable->mleaf[i]; 246 struct medialeaf *leaf = &mtable->mleaf[i];
241 247
@@ -298,17 +304,17 @@ subsequent_board:
298 } 304 }
299 if (tulip_debug > 1 && leaf->media == 11) { 305 if (tulip_debug > 1 && leaf->media == 11) {
300 unsigned char *bp = leaf->leafdata; 306 unsigned char *bp = leaf->leafdata;
301 dev_info(&dev->dev, 307 pr_info("%s: MII interface PHY %d, setup/reset sequences %d/%d long, capabilities %02x %02x\n",
302 "MII interface PHY %d, setup/reset sequences %d/%d long, capabilities %02x %02x\n", 308 dev->name,
303 bp[0], bp[1], bp[2 + bp[1]*2], 309 bp[0], bp[1], bp[2 + bp[1]*2],
304 bp[5 + bp[2 + bp[1]*2]*2], 310 bp[5 + bp[2 + bp[1]*2]*2],
305 bp[4 + bp[2 + bp[1]*2]*2]); 311 bp[4 + bp[2 + bp[1]*2]*2]);
306 } 312 }
307 dev_info(&dev->dev, 313 pr_info("%s: Index #%d - Media %s (#%d) described by a %s (%d) block\n",
308 "Index #%d - Media %s (#%d) described by a %s (%d) block\n", 314 dev->name,
309 i, medianame[leaf->media & 15], leaf->media, 315 i, medianame[leaf->media & 15], leaf->media,
310 leaf->type < ARRAY_SIZE(block_name) ? block_name[leaf->type] : "<unknown>", 316 leaf->type < ARRAY_SIZE(block_name) ? block_name[leaf->type] : "<unknown>",
311 leaf->type); 317 leaf->type);
312 } 318 }
313 if (new_advertise) 319 if (new_advertise)
314 tp->sym_advertise = new_advertise; 320 tp->sym_advertise = new_advertise;
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 2fbf15235c05..cd24e5f2b2a2 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -480,7 +480,7 @@ typhoon_hello(struct typhoon *tp)
480 typhoon_inc_cmd_index(&ring->lastWrite, 1); 480 typhoon_inc_cmd_index(&ring->lastWrite, 1);
481 481
482 INIT_COMMAND_NO_RESPONSE(cmd, TYPHOON_CMD_HELLO_RESP); 482 INIT_COMMAND_NO_RESPONSE(cmd, TYPHOON_CMD_HELLO_RESP);
483 smp_wmb(); 483 wmb();
484 iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY); 484 iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY);
485 spin_unlock(&tp->command_lock); 485 spin_unlock(&tp->command_lock);
486 } 486 }
@@ -1311,13 +1311,15 @@ typhoon_init_interface(struct typhoon *tp)
1311 1311
1312 tp->txlo_dma_addr = le32_to_cpu(iface->txLoAddr); 1312 tp->txlo_dma_addr = le32_to_cpu(iface->txLoAddr);
1313 tp->card_state = Sleeping; 1313 tp->card_state = Sleeping;
1314 smp_wmb();
1315 1314
1316 tp->offload = TYPHOON_OFFLOAD_IP_CHKSUM | TYPHOON_OFFLOAD_TCP_CHKSUM; 1315 tp->offload = TYPHOON_OFFLOAD_IP_CHKSUM | TYPHOON_OFFLOAD_TCP_CHKSUM;
1317 tp->offload |= TYPHOON_OFFLOAD_UDP_CHKSUM | TSO_OFFLOAD_ON; 1316 tp->offload |= TYPHOON_OFFLOAD_UDP_CHKSUM | TSO_OFFLOAD_ON;
1318 1317
1319 spin_lock_init(&tp->command_lock); 1318 spin_lock_init(&tp->command_lock);
1320 spin_lock_init(&tp->state_lock); 1319 spin_lock_init(&tp->state_lock);
1320
1321 /* Force the writes to the shared memory area out before continuing. */
1322 wmb();
1321} 1323}
1322 1324
1323static void 1325static void
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 20e34608fa4a..9e05639435f2 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -54,6 +54,7 @@ static const char driver_name [] = "asix";
54#define AX_CMD_WRITE_IPG0 0x12 54#define AX_CMD_WRITE_IPG0 0x12
55#define AX_CMD_WRITE_IPG1 0x13 55#define AX_CMD_WRITE_IPG1 0x13
56#define AX_CMD_READ_NODE_ID 0x13 56#define AX_CMD_READ_NODE_ID 0x13
57#define AX_CMD_WRITE_NODE_ID 0x14
57#define AX_CMD_WRITE_IPG2 0x14 58#define AX_CMD_WRITE_IPG2 0x14
58#define AX_CMD_WRITE_MULTI_FILTER 0x16 59#define AX_CMD_WRITE_MULTI_FILTER 0x16
59#define AX88172_CMD_READ_NODE_ID 0x17 60#define AX88172_CMD_READ_NODE_ID 0x17
@@ -165,6 +166,7 @@ static const char driver_name [] = "asix";
165/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ 166/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
166struct asix_data { 167struct asix_data {
167 u8 multi_filter[AX_MCAST_FILTER_SIZE]; 168 u8 multi_filter[AX_MCAST_FILTER_SIZE];
169 u8 mac_addr[ETH_ALEN];
168 u8 phymode; 170 u8 phymode;
169 u8 ledmode; 171 u8 ledmode;
170 u8 eeprom_len; 172 u8 eeprom_len;
@@ -732,6 +734,30 @@ static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
732 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); 734 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
733} 735}
734 736
737static int asix_set_mac_address(struct net_device *net, void *p)
738{
739 struct usbnet *dev = netdev_priv(net);
740 struct asix_data *data = (struct asix_data *)&dev->data;
741 struct sockaddr *addr = p;
742
743 if (netif_running(net))
744 return -EBUSY;
745 if (!is_valid_ether_addr(addr->sa_data))
746 return -EADDRNOTAVAIL;
747
748 memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
749
750 /* We use the 20 byte dev->data
751 * for our 6 byte mac buffer
752 * to avoid allocating memory that
753 * is tricky to free later */
754 memcpy(data->mac_addr, addr->sa_data, ETH_ALEN);
755 asix_write_cmd_async(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
756 data->mac_addr);
757
758 return 0;
759}
760
735/* We need to override some ethtool_ops so we require our 761/* We need to override some ethtool_ops so we require our
736 own structure so we don't interfere with other usbnet 762 own structure so we don't interfere with other usbnet
737 devices that may be connected at the same time. */ 763 devices that may be connected at the same time. */
@@ -919,7 +945,7 @@ static const struct net_device_ops ax88772_netdev_ops = {
919 .ndo_start_xmit = usbnet_start_xmit, 945 .ndo_start_xmit = usbnet_start_xmit,
920 .ndo_tx_timeout = usbnet_tx_timeout, 946 .ndo_tx_timeout = usbnet_tx_timeout,
921 .ndo_change_mtu = usbnet_change_mtu, 947 .ndo_change_mtu = usbnet_change_mtu,
922 .ndo_set_mac_address = eth_mac_addr, 948 .ndo_set_mac_address = asix_set_mac_address,
923 .ndo_validate_addr = eth_validate_addr, 949 .ndo_validate_addr = eth_validate_addr,
924 .ndo_do_ioctl = asix_ioctl, 950 .ndo_do_ioctl = asix_ioctl,
925 .ndo_set_multicast_list = asix_set_multicast, 951 .ndo_set_multicast_list = asix_set_multicast,
@@ -1213,7 +1239,7 @@ static const struct net_device_ops ax88178_netdev_ops = {
1213 .ndo_stop = usbnet_stop, 1239 .ndo_stop = usbnet_stop,
1214 .ndo_start_xmit = usbnet_start_xmit, 1240 .ndo_start_xmit = usbnet_start_xmit,
1215 .ndo_tx_timeout = usbnet_tx_timeout, 1241 .ndo_tx_timeout = usbnet_tx_timeout,
1216 .ndo_set_mac_address = eth_mac_addr, 1242 .ndo_set_mac_address = asix_set_mac_address,
1217 .ndo_validate_addr = eth_validate_addr, 1243 .ndo_validate_addr = eth_validate_addr,
1218 .ndo_set_multicast_list = asix_set_multicast, 1244 .ndo_set_multicast_list = asix_set_multicast,
1219 .ndo_do_ioctl = asix_ioctl, 1245 .ndo_do_ioctl = asix_ioctl,
diff --git a/drivers/net/usb/pegasus.h b/drivers/net/usb/pegasus.h
index 5d02f0200737..b90d8766ab74 100644
--- a/drivers/net/usb/pegasus.h
+++ b/drivers/net/usb/pegasus.h
@@ -177,7 +177,7 @@ PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x400c,
177PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0xabc1, 177PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0xabc1,
178 DEFAULT_GPIO_RESET ) 178 DEFAULT_GPIO_RESET )
179PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x200c, 179PEGASUS_DEV( "USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x200c,
180 DEFAULT_GPIO_RESET | PEGASUS_II ) 180 DEFAULT_GPIO_RESET | PEGASUS_II )
181PEGASUS_DEV( "Accton USB 10/100 Ethernet Adapter", VENDOR_ACCTON, 0x1046, 181PEGASUS_DEV( "Accton USB 10/100 Ethernet Adapter", VENDOR_ACCTON, 0x1046,
182 DEFAULT_GPIO_RESET ) 182 DEFAULT_GPIO_RESET )
183PEGASUS_DEV( "SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046, 183PEGASUS_DEV( "SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046,
@@ -208,6 +208,8 @@ PEGASUS_DEV( "Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100,
208 */ 208 */
209PEGASUS_DEV_CLASS( "Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, 0x00, 209PEGASUS_DEV_CLASS( "Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, 0x00,
210 DEFAULT_GPIO_RESET | PEGASUS_II ) 210 DEFAULT_GPIO_RESET | PEGASUS_II )
211PEGASUS_DEV( "Belkin F5U122 10/100 USB Ethernet", VENDOR_BELKIN, 0x0122,
212 DEFAULT_GPIO_RESET | PEGASUS_II )
211PEGASUS_DEV( "Billionton USB-100", VENDOR_BILLIONTON, 0x0986, 213PEGASUS_DEV( "Billionton USB-100", VENDOR_BILLIONTON, 0x0986,
212 DEFAULT_GPIO_RESET ) 214 DEFAULT_GPIO_RESET )
213PEGASUS_DEV( "Billionton USBLP-100", VENDOR_BILLIONTON, 0x0987, 215PEGASUS_DEV( "Billionton USBLP-100", VENDOR_BILLIONTON, 0x0987,
@@ -249,7 +251,7 @@ PEGASUS_DEV( "GIGABYTE GN-BR402W Wireless Router", VENDOR_GIGABYTE, 0x8002,
249PEGASUS_DEV( "Hawking UF100 10/100 Ethernet", VENDOR_HAWKING, 0x400c, 251PEGASUS_DEV( "Hawking UF100 10/100 Ethernet", VENDOR_HAWKING, 0x400c,
250 DEFAULT_GPIO_RESET | PEGASUS_II ) 252 DEFAULT_GPIO_RESET | PEGASUS_II )
251PEGASUS_DEV( "HP hn210c Ethernet USB", VENDOR_HP, 0x811c, 253PEGASUS_DEV( "HP hn210c Ethernet USB", VENDOR_HP, 0x811c,
252 DEFAULT_GPIO_RESET | PEGASUS_II ) 254 DEFAULT_GPIO_RESET | PEGASUS_II )
253PEGASUS_DEV( "IO DATA USB ET/TX", VENDOR_IODATA, 0x0904, 255PEGASUS_DEV( "IO DATA USB ET/TX", VENDOR_IODATA, 0x0904,
254 DEFAULT_GPIO_RESET ) 256 DEFAULT_GPIO_RESET )
255PEGASUS_DEV( "IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913, 257PEGASUS_DEV( "IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913,
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 698d5672a070..dc5018a6d9ed 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -5255,7 +5255,8 @@ static int set_wep_key(struct airo_info *ai, u16 index, const char *key,
5255 WepKeyRid wkr; 5255 WepKeyRid wkr;
5256 int rc; 5256 int rc;
5257 5257
5258 WARN_ON(keylen == 0); 5258 if (WARN_ON(keylen == 0))
5259 return -1;
5259 5260
5260 memset(&wkr, 0, sizeof(wkr)); 5261 memset(&wkr, 0, sizeof(wkr));
5261 wkr.len = cpu_to_le16(sizeof(wkr)); 5262 wkr.len = cpu_to_le16(sizeof(wkr));
diff --git a/drivers/net/wireless/ath/ar9170/ar9170.h b/drivers/net/wireless/ath/ar9170/ar9170.h
index 8c8ce67971e9..dc662b76a1c8 100644
--- a/drivers/net/wireless/ath/ar9170/ar9170.h
+++ b/drivers/net/wireless/ath/ar9170/ar9170.h
@@ -166,6 +166,7 @@ struct ar9170 {
166 struct ath_common common; 166 struct ath_common common;
167 struct mutex mutex; 167 struct mutex mutex;
168 enum ar9170_device_state state; 168 enum ar9170_device_state state;
169 bool registered;
169 unsigned long bad_hw_nagger; 170 unsigned long bad_hw_nagger;
170 171
171 int (*open)(struct ar9170 *); 172 int (*open)(struct ar9170 *);
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 08dc42da0f63..257c734733d1 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -2701,7 +2701,8 @@ int ar9170_register(struct ar9170 *ar, struct device *pdev)
2701 dev_info(pdev, "Atheros AR9170 is registered as '%s'\n", 2701 dev_info(pdev, "Atheros AR9170 is registered as '%s'\n",
2702 wiphy_name(ar->hw->wiphy)); 2702 wiphy_name(ar->hw->wiphy));
2703 2703
2704 return err; 2704 ar->registered = true;
2705 return 0;
2705 2706
2706err_unreg: 2707err_unreg:
2707 ieee80211_unregister_hw(ar->hw); 2708 ieee80211_unregister_hw(ar->hw);
@@ -2712,11 +2713,14 @@ err_out:
2712 2713
2713void ar9170_unregister(struct ar9170 *ar) 2714void ar9170_unregister(struct ar9170 *ar)
2714{ 2715{
2716 if (ar->registered) {
2715#ifdef CONFIG_AR9170_LEDS 2717#ifdef CONFIG_AR9170_LEDS
2716 ar9170_unregister_leds(ar); 2718 ar9170_unregister_leds(ar);
2717#endif /* CONFIG_AR9170_LEDS */ 2719#endif /* CONFIG_AR9170_LEDS */
2718 2720
2719 kfree_skb(ar->rx_failover);
2720 ieee80211_unregister_hw(ar->hw); 2721 ieee80211_unregister_hw(ar->hw);
2722 }
2723
2724 kfree_skb(ar->rx_failover);
2721 mutex_destroy(&ar->mutex); 2725 mutex_destroy(&ar->mutex);
2722} 2726}
diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c
index 0f361186b78f..4e30197afff6 100644
--- a/drivers/net/wireless/ath/ar9170/usb.c
+++ b/drivers/net/wireless/ath/ar9170/usb.c
@@ -582,43 +582,6 @@ static int ar9170_usb_upload(struct ar9170_usb *aru, const void *data,
582 return 0; 582 return 0;
583} 583}
584 584
585static int ar9170_usb_request_firmware(struct ar9170_usb *aru)
586{
587 int err = 0;
588
589 err = request_firmware(&aru->firmware, "ar9170.fw",
590 &aru->udev->dev);
591 if (!err) {
592 aru->init_values = NULL;
593 return 0;
594 }
595
596 if (aru->req_one_stage_fw) {
597 dev_err(&aru->udev->dev, "ar9170.fw firmware file "
598 "not found and is required for this device\n");
599 return -EINVAL;
600 }
601
602 dev_err(&aru->udev->dev, "ar9170.fw firmware file "
603 "not found, trying old firmware...\n");
604
605 err = request_firmware(&aru->init_values, "ar9170-1.fw",
606 &aru->udev->dev);
607 if (err) {
608 dev_err(&aru->udev->dev, "file with init values not found.\n");
609 return err;
610 }
611
612 err = request_firmware(&aru->firmware, "ar9170-2.fw", &aru->udev->dev);
613 if (err) {
614 release_firmware(aru->init_values);
615 dev_err(&aru->udev->dev, "firmware file not found.\n");
616 return err;
617 }
618
619 return err;
620}
621
622static int ar9170_usb_reset(struct ar9170_usb *aru) 585static int ar9170_usb_reset(struct ar9170_usb *aru)
623{ 586{
624 int ret, lock = (aru->intf->condition != USB_INTERFACE_BINDING); 587 int ret, lock = (aru->intf->condition != USB_INTERFACE_BINDING);
@@ -757,6 +720,103 @@ err_out:
757 return err; 720 return err;
758} 721}
759 722
723static void ar9170_usb_firmware_failed(struct ar9170_usb *aru)
724{
725 struct device *parent = aru->udev->dev.parent;
726
727 /* unbind anything failed */
728 if (parent)
729 down(&parent->sem);
730 device_release_driver(&aru->udev->dev);
731 if (parent)
732 up(&parent->sem);
733}
734
735static void ar9170_usb_firmware_finish(const struct firmware *fw, void *context)
736{
737 struct ar9170_usb *aru = context;
738 int err;
739
740 aru->firmware = fw;
741
742 if (!fw) {
743 dev_err(&aru->udev->dev, "firmware file not found.\n");
744 goto err_freefw;
745 }
746
747 err = ar9170_usb_init_device(aru);
748 if (err)
749 goto err_freefw;
750
751 err = ar9170_usb_open(&aru->common);
752 if (err)
753 goto err_unrx;
754
755 err = ar9170_register(&aru->common, &aru->udev->dev);
756
757 ar9170_usb_stop(&aru->common);
758 if (err)
759 goto err_unrx;
760
761 return;
762
763 err_unrx:
764 ar9170_usb_cancel_urbs(aru);
765
766 err_freefw:
767 ar9170_usb_firmware_failed(aru);
768}
769
770static void ar9170_usb_firmware_inits(const struct firmware *fw,
771 void *context)
772{
773 struct ar9170_usb *aru = context;
774 int err;
775
776 if (!fw) {
777 dev_err(&aru->udev->dev, "file with init values not found.\n");
778 ar9170_usb_firmware_failed(aru);
779 return;
780 }
781
782 aru->init_values = fw;
783
784 /* ok so we have the init values -- get code for two-stage */
785
786 err = request_firmware_nowait(THIS_MODULE, 1, "ar9170-2.fw",
787 &aru->udev->dev, GFP_KERNEL, aru,
788 ar9170_usb_firmware_finish);
789 if (err)
790 ar9170_usb_firmware_failed(aru);
791}
792
793static void ar9170_usb_firmware_step2(const struct firmware *fw, void *context)
794{
795 struct ar9170_usb *aru = context;
796 int err;
797
798 if (fw) {
799 ar9170_usb_firmware_finish(fw, context);
800 return;
801 }
802
803 if (aru->req_one_stage_fw) {
804 dev_err(&aru->udev->dev, "ar9170.fw firmware file "
805 "not found and is required for this device\n");
806 ar9170_usb_firmware_failed(aru);
807 return;
808 }
809
810 dev_err(&aru->udev->dev, "ar9170.fw firmware file "
811 "not found, trying old firmware...\n");
812
813 err = request_firmware_nowait(THIS_MODULE, 1, "ar9170-1.fw",
814 &aru->udev->dev, GFP_KERNEL, aru,
815 ar9170_usb_firmware_inits);
816 if (err)
817 ar9170_usb_firmware_failed(aru);
818}
819
760static bool ar9170_requires_one_stage(const struct usb_device_id *id) 820static bool ar9170_requires_one_stage(const struct usb_device_id *id)
761{ 821{
762 if (!id->driver_info) 822 if (!id->driver_info)
@@ -814,33 +874,9 @@ static int ar9170_usb_probe(struct usb_interface *intf,
814 if (err) 874 if (err)
815 goto err_freehw; 875 goto err_freehw;
816 876
817 err = ar9170_usb_request_firmware(aru); 877 return request_firmware_nowait(THIS_MODULE, 1, "ar9170.fw",
818 if (err) 878 &aru->udev->dev, GFP_KERNEL, aru,
819 goto err_freehw; 879 ar9170_usb_firmware_step2);
820
821 err = ar9170_usb_init_device(aru);
822 if (err)
823 goto err_freefw;
824
825 err = ar9170_usb_open(ar);
826 if (err)
827 goto err_unrx;
828
829 err = ar9170_register(ar, &udev->dev);
830
831 ar9170_usb_stop(ar);
832 if (err)
833 goto err_unrx;
834
835 return 0;
836
837err_unrx:
838 ar9170_usb_cancel_urbs(aru);
839
840err_freefw:
841 release_firmware(aru->init_values);
842 release_firmware(aru->firmware);
843
844err_freehw: 880err_freehw:
845 usb_set_intfdata(intf, NULL); 881 usb_set_intfdata(intf, NULL);
846 usb_put_dev(udev); 882 usb_put_dev(udev);
@@ -860,12 +896,12 @@ static void ar9170_usb_disconnect(struct usb_interface *intf)
860 ar9170_unregister(&aru->common); 896 ar9170_unregister(&aru->common);
861 ar9170_usb_cancel_urbs(aru); 897 ar9170_usb_cancel_urbs(aru);
862 898
863 release_firmware(aru->init_values);
864 release_firmware(aru->firmware);
865
866 usb_put_dev(aru->udev); 899 usb_put_dev(aru->udev);
867 usb_set_intfdata(intf, NULL); 900 usb_set_intfdata(intf, NULL);
868 ieee80211_free_hw(aru->common.hw); 901 ieee80211_free_hw(aru->common.hw);
902
903 release_firmware(aru->init_values);
904 release_firmware(aru->firmware);
869} 905}
870 906
871#ifdef CONFIG_PM 907#ifdef CONFIG_PM
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 6a3f4da7fb48..10b52262b232 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -429,8 +429,8 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
429 ee->ee_margin_tx_rx[mode] = (val >> 8) & 0x3f; 429 ee->ee_margin_tx_rx[mode] = (val >> 8) & 0x3f;
430 430
431 AR5K_EEPROM_READ(o++, val); 431 AR5K_EEPROM_READ(o++, val);
432 ee->ee_i_cal[mode] = (val >> 8) & 0x3f; 432 ee->ee_i_cal[mode] = (val >> 5) & 0x3f;
433 ee->ee_q_cal[mode] = (val >> 3) & 0x1f; 433 ee->ee_q_cal[mode] = val & 0x1f;
434 434
435 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_2) { 435 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_2) {
436 AR5K_EEPROM_READ(o++, val); 436 AR5K_EEPROM_READ(o++, val);
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 72474c0ccaff..eff3323efb4b 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -1386,38 +1386,39 @@ static int ath5k_hw_rf511x_calibrate(struct ath5k_hw *ah,
1386 goto done; 1386 goto done;
1387 1387
1388 /* Calibration has finished, get the results and re-run */ 1388 /* Calibration has finished, get the results and re-run */
1389
1390 /* work around empty results which can apparently happen on 5212 */
1389 for (i = 0; i <= 10; i++) { 1391 for (i = 0; i <= 10; i++) {
1390 iq_corr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_CORR); 1392 iq_corr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_CORR);
1391 i_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_I); 1393 i_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_I);
1392 q_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_Q); 1394 q_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_Q);
1395 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_CALIBRATE,
1396 "iq_corr:%x i_pwr:%x q_pwr:%x", iq_corr, i_pwr, q_pwr);
1397 if (i_pwr && q_pwr)
1398 break;
1393 } 1399 }
1394 1400
1395 i_coffd = ((i_pwr >> 1) + (q_pwr >> 1)) >> 7; 1401 i_coffd = ((i_pwr >> 1) + (q_pwr >> 1)) >> 7;
1396 q_coffd = q_pwr >> 7; 1402 q_coffd = q_pwr >> 7;
1397 1403
1398 /* No correction */ 1404 /* protect against divide by 0 and loss of sign bits */
1399 if (i_coffd == 0 || q_coffd == 0) 1405 if (i_coffd == 0 || q_coffd < 2)
1400 goto done; 1406 goto done;
1401 1407
1402 i_coff = ((-iq_corr) / i_coffd); 1408 i_coff = (-iq_corr) / i_coffd;
1403 1409 i_coff = clamp(i_coff, -32, 31); /* signed 6 bit */
1404 /* Boundary check */
1405 if (i_coff > 31)
1406 i_coff = 31;
1407 if (i_coff < -32)
1408 i_coff = -32;
1409 1410
1410 q_coff = (((s32)i_pwr / q_coffd) - 128); 1411 q_coff = (i_pwr / q_coffd) - 128;
1412 q_coff = clamp(q_coff, -16, 15); /* signed 5 bit */
1411 1413
1412 /* Boundary check */ 1414 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_CALIBRATE,
1413 if (q_coff > 15) 1415 "new I:%d Q:%d (i_coffd:%x q_coffd:%x)",
1414 q_coff = 15; 1416 i_coff, q_coff, i_coffd, q_coffd);
1415 if (q_coff < -16)
1416 q_coff = -16;
1417 1417
1418 /* Commit new I/Q value */ 1418 /* Commit new I/Q values (set enable bit last to match HAL sources) */
1419 AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_ENABLE | 1419 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_Q_I_COFF, i_coff);
1420 ((u32)q_coff) | ((u32)i_coff << AR5K_PHY_IQ_CORR_Q_I_COFF_S)); 1420 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_Q_Q_COFF, q_coff);
1421 AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_ENABLE);
1421 1422
1422 /* Re-enable calibration -if we don't we'll commit 1423 /* Re-enable calibration -if we don't we'll commit
1423 * the same values again and again */ 1424 * the same values again and again */
@@ -1873,7 +1874,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
1873 break; 1874 break;
1874 case AR5K_ANTMODE_FIXED_A: 1875 case AR5K_ANTMODE_FIXED_A:
1875 def_ant = 1; 1876 def_ant = 1;
1876 tx_ant = 0; 1877 tx_ant = 1;
1877 use_def_for_tx = true; 1878 use_def_for_tx = true;
1878 update_def_on_tx = false; 1879 update_def_on_tx = false;
1879 use_def_for_rts = true; 1880 use_def_for_rts = true;
@@ -1882,7 +1883,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
1882 break; 1883 break;
1883 case AR5K_ANTMODE_FIXED_B: 1884 case AR5K_ANTMODE_FIXED_B:
1884 def_ant = 2; 1885 def_ant = 2;
1885 tx_ant = 0; 1886 tx_ant = 2;
1886 use_def_for_tx = true; 1887 use_def_for_tx = true;
1887 update_def_on_tx = false; 1888 update_def_on_tx = false;
1888 use_def_for_rts = true; 1889 use_def_for_rts = true;
diff --git a/drivers/net/wireless/ath/ath5k/reg.h b/drivers/net/wireless/ath/ath5k/reg.h
index 4cb9c5df9f46..1464f89b249c 100644
--- a/drivers/net/wireless/ath/ath5k/reg.h
+++ b/drivers/net/wireless/ath/ath5k/reg.h
@@ -2187,6 +2187,7 @@
2187 */ 2187 */
2188#define AR5K_PHY_IQ 0x9920 /* Register Address */ 2188#define AR5K_PHY_IQ 0x9920 /* Register Address */
2189#define AR5K_PHY_IQ_CORR_Q_Q_COFF 0x0000001f /* Mask for q correction info */ 2189#define AR5K_PHY_IQ_CORR_Q_Q_COFF 0x0000001f /* Mask for q correction info */
2190#define AR5K_PHY_IQ_CORR_Q_Q_COFF_S 0
2190#define AR5K_PHY_IQ_CORR_Q_I_COFF 0x000007e0 /* Mask for i correction info */ 2191#define AR5K_PHY_IQ_CORR_Q_I_COFF 0x000007e0 /* Mask for i correction info */
2191#define AR5K_PHY_IQ_CORR_Q_I_COFF_S 5 2192#define AR5K_PHY_IQ_CORR_Q_I_COFF_S 5
2192#define AR5K_PHY_IQ_CORR_ENABLE 0x00000800 /* Enable i/q correction */ 2193#define AR5K_PHY_IQ_CORR_ENABLE 0x00000800 /* Enable i/q correction */
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index a35a7db0fc4c..cbf28e379843 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -851,12 +851,15 @@ static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah,
851 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1, 851 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1,
852 AR5K_INIT_CYCRSSI_THR1); 852 AR5K_INIT_CYCRSSI_THR1);
853 853
854 /* I/Q correction 854 /* I/Q correction (set enable bit last to match HAL sources) */
855 * TODO: Per channel i/q infos ? */ 855 /* TODO: Per channel i/q infos ? */
856 AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, 856 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0) {
857 AR5K_PHY_IQ_CORR_ENABLE | 857 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_Q_I_COFF,
858 (ee->ee_i_cal[ee_mode] << AR5K_PHY_IQ_CORR_Q_I_COFF_S) | 858 ee->ee_i_cal[ee_mode]);
859 ee->ee_q_cal[ee_mode]); 859 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_Q_Q_COFF,
860 ee->ee_q_cal[ee_mode]);
861 AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_ENABLE);
862 }
860 863
861 /* Heavy clipping -disable for now */ 864 /* Heavy clipping -disable for now */
862 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_5_1) 865 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_5_1)
@@ -1379,11 +1382,10 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1379 ath5k_hw_set_sleep_clock(ah, true); 1382 ath5k_hw_set_sleep_clock(ah, true);
1380 1383
1381 /* 1384 /*
1382 * Disable beacons and reset the register 1385 * Disable beacons and reset the TSF
1383 */ 1386 */
1384 AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE | 1387 AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
1385 AR5K_BEACON_RESET_TSF); 1388 ath5k_hw_reset_tsf(ah);
1386
1387 return 0; 1389 return 0;
1388} 1390}
1389 1391
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index ac34a055c713..0e79e58cf4c9 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -1323,7 +1323,7 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
1323 1323
1324static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband, 1324static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
1325 struct ieee80211_sta *sta, void *priv_sta, 1325 struct ieee80211_sta *sta, void *priv_sta,
1326 u32 changed) 1326 u32 changed, enum nl80211_channel_type oper_chan_type)
1327{ 1327{
1328 struct ath_softc *sc = priv; 1328 struct ath_softc *sc = priv;
1329 struct ath_rate_priv *ath_rc_priv = priv_sta; 1329 struct ath_rate_priv *ath_rc_priv = priv_sta;
@@ -1340,8 +1340,8 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
1340 if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION) 1340 if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION)
1341 return; 1341 return;
1342 1342
1343 if (sc->hw->conf.channel_type == NL80211_CHAN_HT40MINUS || 1343 if (oper_chan_type == NL80211_CHAN_HT40MINUS ||
1344 sc->hw->conf.channel_type == NL80211_CHAN_HT40PLUS) 1344 oper_chan_type == NL80211_CHAN_HT40PLUS)
1345 oper_cw40 = true; 1345 oper_cw40 = true;
1346 1346
1347 oper_sgi40 = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? 1347 oper_sgi40 = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 47294f90bbe5..b2c8207f7bc1 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2258,7 +2258,7 @@ void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an)
2258 if (ATH_TXQ_SETUP(sc, i)) { 2258 if (ATH_TXQ_SETUP(sc, i)) {
2259 txq = &sc->tx.txq[i]; 2259 txq = &sc->tx.txq[i];
2260 2260
2261 spin_lock(&txq->axq_lock); 2261 spin_lock_bh(&txq->axq_lock);
2262 2262
2263 list_for_each_entry_safe(ac, 2263 list_for_each_entry_safe(ac,
2264 ac_tmp, &txq->axq_acq, list) { 2264 ac_tmp, &txq->axq_acq, list) {
@@ -2279,7 +2279,7 @@ void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an)
2279 } 2279 }
2280 } 2280 }
2281 2281
2282 spin_unlock(&txq->axq_lock); 2282 spin_unlock_bh(&txq->axq_lock);
2283 } 2283 }
2284 } 2284 }
2285} 2285}
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 63c2a7ade5fb..5c7aa1b1eb56 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -3177,14 +3177,27 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
3177 int total_nr = 0; 3177 int total_nr = 0;
3178 int i; 3178 int i;
3179 struct pci_pool *pool; 3179 struct pci_pool *pool;
3180 u32 *virts[CB_NUMBER_OF_ELEMENTS_SMALL]; 3180 void **virts;
3181 dma_addr_t phys[CB_NUMBER_OF_ELEMENTS_SMALL]; 3181 dma_addr_t *phys;
3182 3182
3183 IPW_DEBUG_TRACE("<< : \n"); 3183 IPW_DEBUG_TRACE("<< : \n");
3184 3184
3185 virts = kmalloc(sizeof(void *) * CB_NUMBER_OF_ELEMENTS_SMALL,
3186 GFP_KERNEL);
3187 if (!virts)
3188 return -ENOMEM;
3189
3190 phys = kmalloc(sizeof(dma_addr_t) * CB_NUMBER_OF_ELEMENTS_SMALL,
3191 GFP_KERNEL);
3192 if (!phys) {
3193 kfree(virts);
3194 return -ENOMEM;
3195 }
3185 pool = pci_pool_create("ipw2200", priv->pci_dev, CB_MAX_LENGTH, 0, 0); 3196 pool = pci_pool_create("ipw2200", priv->pci_dev, CB_MAX_LENGTH, 0, 0);
3186 if (!pool) { 3197 if (!pool) {
3187 IPW_ERROR("pci_pool_create failed\n"); 3198 IPW_ERROR("pci_pool_create failed\n");
3199 kfree(phys);
3200 kfree(virts);
3188 return -ENOMEM; 3201 return -ENOMEM;
3189 } 3202 }
3190 3203
@@ -3254,6 +3267,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
3254 pci_pool_free(pool, virts[i], phys[i]); 3267 pci_pool_free(pool, virts[i], phys[i]);
3255 3268
3256 pci_pool_destroy(pool); 3269 pci_pool_destroy(pool);
3270 kfree(phys);
3271 kfree(virts);
3257 3272
3258 return ret; 3273 return ret;
3259} 3274}
diff --git a/drivers/net/wireless/ipw2x00/libipw.h b/drivers/net/wireless/ipw2x00/libipw.h
index bf45391172f3..a6d5e42647e4 100644
--- a/drivers/net/wireless/ipw2x00/libipw.h
+++ b/drivers/net/wireless/ipw2x00/libipw.h
@@ -797,7 +797,7 @@ struct libipw_device {
797 /* Probe / Beacon management */ 797 /* Probe / Beacon management */
798 struct list_head network_free_list; 798 struct list_head network_free_list;
799 struct list_head network_list; 799 struct list_head network_list;
800 struct libipw_network *networks; 800 struct libipw_network *networks[MAX_NETWORK_COUNT];
801 int scans; 801 int scans;
802 int scan_age; 802 int scan_age;
803 803
diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c
index 1ae0b2b02c38..2fa55867bd8b 100644
--- a/drivers/net/wireless/ipw2x00/libipw_module.c
+++ b/drivers/net/wireless/ipw2x00/libipw_module.c
@@ -67,16 +67,17 @@ void *libipw_wiphy_privid = &libipw_wiphy_privid;
67 67
68static int libipw_networks_allocate(struct libipw_device *ieee) 68static int libipw_networks_allocate(struct libipw_device *ieee)
69{ 69{
70 if (ieee->networks) 70 int i, j;
71 return 0; 71
72 72 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
73 ieee->networks = 73 ieee->networks[i] = kzalloc(sizeof(struct libipw_network),
74 kzalloc(MAX_NETWORK_COUNT * sizeof(struct libipw_network), 74 GFP_KERNEL);
75 GFP_KERNEL); 75 if (!ieee->networks[i]) {
76 if (!ieee->networks) { 76 LIBIPW_ERROR("Out of memory allocating beacons\n");
77 printk(KERN_WARNING "%s: Out of memory allocating beacons\n", 77 for (j = 0; j < i; j++)
78 ieee->dev->name); 78 kfree(ieee->networks[j]);
79 return -ENOMEM; 79 return -ENOMEM;
80 }
80 } 81 }
81 82
82 return 0; 83 return 0;
@@ -97,15 +98,11 @@ static inline void libipw_networks_free(struct libipw_device *ieee)
97{ 98{
98 int i; 99 int i;
99 100
100 if (!ieee->networks) 101 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
101 return; 102 if (ieee->networks[i]->ibss_dfs)
102 103 kfree(ieee->networks[i]->ibss_dfs);
103 for (i = 0; i < MAX_NETWORK_COUNT; i++) 104 kfree(ieee->networks[i]);
104 if (ieee->networks[i].ibss_dfs) 105 }
105 kfree(ieee->networks[i].ibss_dfs);
106
107 kfree(ieee->networks);
108 ieee->networks = NULL;
109} 106}
110 107
111void libipw_networks_age(struct libipw_device *ieee, 108void libipw_networks_age(struct libipw_device *ieee,
@@ -130,7 +127,7 @@ static void libipw_networks_initialize(struct libipw_device *ieee)
130 INIT_LIST_HEAD(&ieee->network_free_list); 127 INIT_LIST_HEAD(&ieee->network_free_list);
131 INIT_LIST_HEAD(&ieee->network_list); 128 INIT_LIST_HEAD(&ieee->network_list);
132 for (i = 0; i < MAX_NETWORK_COUNT; i++) 129 for (i = 0; i < MAX_NETWORK_COUNT; i++)
133 list_add_tail(&ieee->networks[i].list, 130 list_add_tail(&ieee->networks[i]->list,
134 &ieee->network_free_list); 131 &ieee->network_free_list);
135} 132}
136 133
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 303cc8193adc..e0678d921055 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -184,7 +184,7 @@ static int iwl3945_hwrate_to_plcp_idx(u8 plcp)
184{ 184{
185 int idx; 185 int idx;
186 186
187 for (idx = 0; idx < IWL_RATE_COUNT; idx++) 187 for (idx = 0; idx < IWL_RATE_COUNT_3945; idx++)
188 if (iwl3945_rates[idx].plcp == plcp) 188 if (iwl3945_rates[idx].plcp == plcp)
189 return idx; 189 return idx;
190 return -1; 190 return -1;
@@ -805,7 +805,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv,
805 int sta_id, int tx_id) 805 int sta_id, int tx_id)
806{ 806{
807 u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value; 807 u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value;
808 u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT - 1); 808 u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT_3945);
809 u16 rate_mask; 809 u16 rate_mask;
810 int rate; 810 int rate;
811 u8 rts_retry_limit; 811 u8 rts_retry_limit;
@@ -2146,7 +2146,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv)
2146 2146
2147 /* fill in channel group's nominal powers for each rate */ 2147 /* fill in channel group's nominal powers for each rate */
2148 for (rate_index = 0; 2148 for (rate_index = 0;
2149 rate_index < IWL_RATE_COUNT; rate_index++, clip_pwrs++) { 2149 rate_index < IWL_RATE_COUNT_3945; rate_index++, clip_pwrs++) {
2150 switch (rate_index) { 2150 switch (rate_index) {
2151 case IWL_RATE_36M_INDEX_TABLE: 2151 case IWL_RATE_36M_INDEX_TABLE:
2152 if (i == 0) /* B/G */ 2152 if (i == 0) /* B/G */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 6aeb82b6992f..818367b57bab 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1463,59 +1463,66 @@ static void iwl_nic_start(struct iwl_priv *priv)
1463} 1463}
1464 1464
1465 1465
1466static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
1467static int iwl_mac_setup_register(struct iwl_priv *priv);
1468
1469static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first)
1470{
1471 const char *name_pre = priv->cfg->fw_name_pre;
1472
1473 if (first)
1474 priv->fw_index = priv->cfg->ucode_api_max;
1475 else
1476 priv->fw_index--;
1477
1478 if (priv->fw_index < priv->cfg->ucode_api_min) {
1479 IWL_ERR(priv, "no suitable firmware found!\n");
1480 return -ENOENT;
1481 }
1482
1483 sprintf(priv->firmware_name, "%s%d%s",
1484 name_pre, priv->fw_index, ".ucode");
1485
1486 IWL_DEBUG_INFO(priv, "attempting to load firmware '%s'\n",
1487 priv->firmware_name);
1488
1489 return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name,
1490 &priv->pci_dev->dev, GFP_KERNEL, priv,
1491 iwl_ucode_callback);
1492}
1493
1466/** 1494/**
1467 * iwl_read_ucode - Read uCode images from disk file. 1495 * iwl_ucode_callback - callback when firmware was loaded
1468 * 1496 *
1469 * Copy into buffers for card to fetch via bus-mastering 1497 * If loaded successfully, copies the firmware into buffers
1498 * for the card to fetch (via DMA).
1470 */ 1499 */
1471static int iwl_read_ucode(struct iwl_priv *priv) 1500static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1472{ 1501{
1502 struct iwl_priv *priv = context;
1473 struct iwl_ucode_header *ucode; 1503 struct iwl_ucode_header *ucode;
1474 int ret = -EINVAL, index;
1475 const struct firmware *ucode_raw;
1476 const char *name_pre = priv->cfg->fw_name_pre;
1477 const unsigned int api_max = priv->cfg->ucode_api_max; 1504 const unsigned int api_max = priv->cfg->ucode_api_max;
1478 const unsigned int api_min = priv->cfg->ucode_api_min; 1505 const unsigned int api_min = priv->cfg->ucode_api_min;
1479 char buf[25];
1480 u8 *src; 1506 u8 *src;
1481 size_t len; 1507 size_t len;
1482 u32 api_ver, build; 1508 u32 api_ver, build;
1483 u32 inst_size, data_size, init_size, init_data_size, boot_size; 1509 u32 inst_size, data_size, init_size, init_data_size, boot_size;
1510 int err;
1484 u16 eeprom_ver; 1511 u16 eeprom_ver;
1485 1512
1486 /* Ask kernel firmware_class module to get the boot firmware off disk. 1513 if (!ucode_raw) {
1487 * request_firmware() is synchronous, file is in memory on return. */ 1514 IWL_ERR(priv, "request for firmware file '%s' failed.\n",
1488 for (index = api_max; index >= api_min; index--) { 1515 priv->firmware_name);
1489 sprintf(buf, "%s%d%s", name_pre, index, ".ucode"); 1516 goto try_again;
1490 ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev);
1491 if (ret < 0) {
1492 IWL_ERR(priv, "%s firmware file req failed: %d\n",
1493 buf, ret);
1494 if (ret == -ENOENT)
1495 continue;
1496 else
1497 goto error;
1498 } else {
1499 if (index < api_max)
1500 IWL_ERR(priv, "Loaded firmware %s, "
1501 "which is deprecated. "
1502 "Please use API v%u instead.\n",
1503 buf, api_max);
1504
1505 IWL_DEBUG_INFO(priv, "Got firmware '%s' file (%zd bytes) from disk\n",
1506 buf, ucode_raw->size);
1507 break;
1508 }
1509 } 1517 }
1510 1518
1511 if (ret < 0) 1519 IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n",
1512 goto error; 1520 priv->firmware_name, ucode_raw->size);
1513 1521
1514 /* Make sure that we got at least the v1 header! */ 1522 /* Make sure that we got at least the v1 header! */
1515 if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) { 1523 if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) {
1516 IWL_ERR(priv, "File size way too small!\n"); 1524 IWL_ERR(priv, "File size way too small!\n");
1517 ret = -EINVAL; 1525 goto try_again;
1518 goto err_release;
1519 } 1526 }
1520 1527
1521 /* Data from ucode file: header followed by uCode images */ 1528 /* Data from ucode file: header followed by uCode images */
@@ -1540,10 +1547,9 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1540 IWL_ERR(priv, "Driver unable to support your firmware API. " 1547 IWL_ERR(priv, "Driver unable to support your firmware API. "
1541 "Driver supports v%u, firmware is v%u.\n", 1548 "Driver supports v%u, firmware is v%u.\n",
1542 api_max, api_ver); 1549 api_max, api_ver);
1543 priv->ucode_ver = 0; 1550 goto try_again;
1544 ret = -EINVAL;
1545 goto err_release;
1546 } 1551 }
1552
1547 if (api_ver != api_max) 1553 if (api_ver != api_max)
1548 IWL_ERR(priv, "Firmware has old API version. Expected v%u, " 1554 IWL_ERR(priv, "Firmware has old API version. Expected v%u, "
1549 "got v%u. New firmware can be obtained " 1555 "got v%u. New firmware can be obtained "
@@ -1585,6 +1591,12 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1585 IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n", 1591 IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n",
1586 boot_size); 1592 boot_size);
1587 1593
1594 /*
1595 * For any of the failures below (before allocating pci memory)
1596 * we will try to load a version with a smaller API -- maybe the
1597 * user just got a corrupted version of the latest API.
1598 */
1599
1588 /* Verify size of file vs. image size info in file's header */ 1600 /* Verify size of file vs. image size info in file's header */
1589 if (ucode_raw->size != 1601 if (ucode_raw->size !=
1590 priv->cfg->ops->ucode->get_header_size(api_ver) + 1602 priv->cfg->ops->ucode->get_header_size(api_ver) +
@@ -1594,41 +1606,35 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1594 IWL_DEBUG_INFO(priv, 1606 IWL_DEBUG_INFO(priv,
1595 "uCode file size %d does not match expected size\n", 1607 "uCode file size %d does not match expected size\n",
1596 (int)ucode_raw->size); 1608 (int)ucode_raw->size);
1597 ret = -EINVAL; 1609 goto try_again;
1598 goto err_release;
1599 } 1610 }
1600 1611
1601 /* Verify that uCode images will fit in card's SRAM */ 1612 /* Verify that uCode images will fit in card's SRAM */
1602 if (inst_size > priv->hw_params.max_inst_size) { 1613 if (inst_size > priv->hw_params.max_inst_size) {
1603 IWL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", 1614 IWL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n",
1604 inst_size); 1615 inst_size);
1605 ret = -EINVAL; 1616 goto try_again;
1606 goto err_release;
1607 } 1617 }
1608 1618
1609 if (data_size > priv->hw_params.max_data_size) { 1619 if (data_size > priv->hw_params.max_data_size) {
1610 IWL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", 1620 IWL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n",
1611 data_size); 1621 data_size);
1612 ret = -EINVAL; 1622 goto try_again;
1613 goto err_release;
1614 } 1623 }
1615 if (init_size > priv->hw_params.max_inst_size) { 1624 if (init_size > priv->hw_params.max_inst_size) {
1616 IWL_INFO(priv, "uCode init instr len %d too large to fit in\n", 1625 IWL_INFO(priv, "uCode init instr len %d too large to fit in\n",
1617 init_size); 1626 init_size);
1618 ret = -EINVAL; 1627 goto try_again;
1619 goto err_release;
1620 } 1628 }
1621 if (init_data_size > priv->hw_params.max_data_size) { 1629 if (init_data_size > priv->hw_params.max_data_size) {
1622 IWL_INFO(priv, "uCode init data len %d too large to fit in\n", 1630 IWL_INFO(priv, "uCode init data len %d too large to fit in\n",
1623 init_data_size); 1631 init_data_size);
1624 ret = -EINVAL; 1632 goto try_again;
1625 goto err_release;
1626 } 1633 }
1627 if (boot_size > priv->hw_params.max_bsm_size) { 1634 if (boot_size > priv->hw_params.max_bsm_size) {
1628 IWL_INFO(priv, "uCode boot instr len %d too large to fit in\n", 1635 IWL_INFO(priv, "uCode boot instr len %d too large to fit in\n",
1629 boot_size); 1636 boot_size);
1630 ret = -EINVAL; 1637 goto try_again;
1631 goto err_release;
1632 } 1638 }
1633 1639
1634 /* Allocate ucode buffers for card's bus-master loading ... */ 1640 /* Allocate ucode buffers for card's bus-master loading ... */
@@ -1712,20 +1718,36 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1712 IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", len); 1718 IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", len);
1713 memcpy(priv->ucode_boot.v_addr, src, len); 1719 memcpy(priv->ucode_boot.v_addr, src, len);
1714 1720
1721 /**************************************************
1722 * This is still part of probe() in a sense...
1723 *
1724 * 9. Setup and register with mac80211 and debugfs
1725 **************************************************/
1726 err = iwl_mac_setup_register(priv);
1727 if (err)
1728 goto out_unbind;
1729
1730 err = iwl_dbgfs_register(priv, DRV_NAME);
1731 if (err)
1732 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
1733
1715 /* We have our copies now, allow OS release its copies */ 1734 /* We have our copies now, allow OS release its copies */
1716 release_firmware(ucode_raw); 1735 release_firmware(ucode_raw);
1717 return 0; 1736 return;
1737
1738 try_again:
1739 /* try next, if any */
1740 if (iwl_request_firmware(priv, false))
1741 goto out_unbind;
1742 release_firmware(ucode_raw);
1743 return;
1718 1744
1719 err_pci_alloc: 1745 err_pci_alloc:
1720 IWL_ERR(priv, "failed to allocate pci memory\n"); 1746 IWL_ERR(priv, "failed to allocate pci memory\n");
1721 ret = -ENOMEM;
1722 iwl_dealloc_ucode_pci(priv); 1747 iwl_dealloc_ucode_pci(priv);
1723 1748 out_unbind:
1724 err_release: 1749 device_release_driver(&priv->pci_dev->dev);
1725 release_firmware(ucode_raw); 1750 release_firmware(ucode_raw);
1726
1727 error:
1728 return ret;
1729} 1751}
1730 1752
1731static const char *desc_lookup_text[] = { 1753static const char *desc_lookup_text[] = {
@@ -2631,7 +2653,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2631 */ 2653 */
2632 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 2654 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
2633 2655
2634 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX + 1; 2656 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
2635 /* we create the 802.11 header and a zero-length SSID element */ 2657 /* we create the 802.11 header and a zero-length SSID element */
2636 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2; 2658 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2;
2637 2659
@@ -2667,21 +2689,7 @@ static int iwl_mac_start(struct ieee80211_hw *hw)
2667 2689
2668 /* we should be verifying the device is ready to be opened */ 2690 /* we should be verifying the device is ready to be opened */
2669 mutex_lock(&priv->mutex); 2691 mutex_lock(&priv->mutex);
2670
2671 /* fetch ucode file from disk, alloc and copy to bus-master buffers ...
2672 * ucode filename and max sizes are card-specific. */
2673
2674 if (!priv->ucode_code.len) {
2675 ret = iwl_read_ucode(priv);
2676 if (ret) {
2677 IWL_ERR(priv, "Could not read microcode: %d\n", ret);
2678 mutex_unlock(&priv->mutex);
2679 return ret;
2680 }
2681 }
2682
2683 ret = __iwl_up(priv); 2692 ret = __iwl_up(priv);
2684
2685 mutex_unlock(&priv->mutex); 2693 mutex_unlock(&priv->mutex);
2686 2694
2687 if (ret) 2695 if (ret)
@@ -3654,17 +3662,10 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3654 iwl_power_initialize(priv); 3662 iwl_power_initialize(priv);
3655 iwl_tt_initialize(priv); 3663 iwl_tt_initialize(priv);
3656 3664
3657 /************************************************** 3665 err = iwl_request_firmware(priv, true);
3658 * 9. Setup and register with mac80211 and debugfs
3659 **************************************************/
3660 err = iwl_mac_setup_register(priv);
3661 if (err) 3666 if (err)
3662 goto out_remove_sysfs; 3667 goto out_remove_sysfs;
3663 3668
3664 err = iwl_dbgfs_register(priv, DRV_NAME);
3665 if (err)
3666 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
3667
3668 return 0; 3669 return 0;
3669 3670
3670 out_remove_sysfs: 3671 out_remove_sysfs:
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index ab891b958042..6054c5fba0c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1132,6 +1132,7 @@ struct iwl_priv {
1132 u8 rev_id; 1132 u8 rev_id;
1133 1133
1134 /* uCode images, save to reload in case of failure */ 1134 /* uCode images, save to reload in case of failure */
1135 int fw_index; /* firmware we're trying to load */
1135 u32 ucode_ver; /* version of ucode, copy of 1136 u32 ucode_ver; /* version of ucode, copy of
1136 iwl_ucode.ver */ 1137 iwl_ucode.ver */
1137 struct fw_desc ucode_code; /* runtime inst */ 1138 struct fw_desc ucode_code; /* runtime inst */
@@ -1142,6 +1143,7 @@ struct iwl_priv {
1142 struct fw_desc ucode_boot; /* bootstrap inst */ 1143 struct fw_desc ucode_boot; /* bootstrap inst */
1143 enum ucode_type ucode_type; 1144 enum ucode_type ucode_type;
1144 u8 ucode_write_complete; /* the image write is complete */ 1145 u8 ucode_write_complete; /* the image write is complete */
1146 char firmware_name[25];
1145 1147
1146 1148
1147 struct iwl_rxon_time_cmd rxon_timing; 1149 struct iwl_rxon_time_cmd rxon_timing;
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index dd9ff2ed645a..bd2f7c420563 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -638,20 +638,9 @@ u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
638 if (left < 0) 638 if (left < 0)
639 return 0; 639 return 0;
640 *pos++ = WLAN_EID_SSID; 640 *pos++ = WLAN_EID_SSID;
641 if (!priv->is_internal_short_scan && 641 *pos++ = 0;
642 priv->scan_request->n_ssids) { 642
643 struct cfg80211_ssid *ssid = 643 len += 2;
644 priv->scan_request->ssids;
645
646 /* Broadcast if ssid_len is 0 */
647 *pos++ = ssid->ssid_len;
648 memcpy(pos, ssid->ssid, ssid->ssid_len);
649 pos += ssid->ssid_len;
650 len += 2 + ssid->ssid_len;
651 } else {
652 *pos++ = 0;
653 len += 2;
654 }
655 644
656 if (WARN_ON(left < ie_len)) 645 if (WARN_ON(left < ie_len))
657 return len; 646 return len;
@@ -780,26 +769,20 @@ static void iwl_bg_request_scan(struct work_struct *data)
780 if (priv->is_internal_short_scan) { 769 if (priv->is_internal_short_scan) {
781 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n"); 770 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
782 } else if (priv->scan_request->n_ssids) { 771 } else if (priv->scan_request->n_ssids) {
772 int i, p = 0;
783 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); 773 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
784 /* 774 for (i = 0; i < priv->scan_request->n_ssids; i++) {
785 * The first SSID to scan is stuffed into the probe request 775 /* always does wildcard anyway */
786 * template and the remaining ones are handled through the 776 if (!priv->scan_request->ssids[i].ssid_len)
787 * direct_scan array. 777 continue;
788 */ 778 scan->direct_scan[p].id = WLAN_EID_SSID;
789 if (priv->scan_request->n_ssids > 1) { 779 scan->direct_scan[p].len =
790 int i, p = 0; 780 priv->scan_request->ssids[i].ssid_len;
791 for (i = 1; i < priv->scan_request->n_ssids; i++) { 781 memcpy(scan->direct_scan[p].ssid,
792 if (!priv->scan_request->ssids[i].ssid_len) 782 priv->scan_request->ssids[i].ssid,
793 continue; 783 priv->scan_request->ssids[i].ssid_len);
794 scan->direct_scan[p].id = WLAN_EID_SSID; 784 n_probes++;
795 scan->direct_scan[p].len = 785 p++;
796 priv->scan_request->ssids[i].ssid_len;
797 memcpy(scan->direct_scan[p].ssid,
798 priv->scan_request->ssids[i].ssid,
799 priv->scan_request->ssids[i].ssid_len);
800 n_probes++;
801 p++;
802 }
803 } 786 }
804 is_active = true; 787 is_active = true;
805 } else 788 } else
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 9f6d6bf06b8e..2887047069f2 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -1496,51 +1496,67 @@ static void set_multicast_list(struct usbnet *usbdev)
1496{ 1496{
1497 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1497 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1498 struct dev_mc_list *mclist; 1498 struct dev_mc_list *mclist;
1499 __le32 filter; 1499 __le32 filter, basefilter;
1500 int ret, i, size; 1500 int ret;
1501 char *buf; 1501 char *mc_addrs = NULL;
1502 int mc_count;
1502 1503
1503 filter = RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_BROADCAST; 1504 basefilter = filter = RNDIS_PACKET_TYPE_DIRECTED |
1505 RNDIS_PACKET_TYPE_BROADCAST;
1504 1506
1505 netif_addr_lock_bh(usbdev->net);
1506 if (usbdev->net->flags & IFF_PROMISC) { 1507 if (usbdev->net->flags & IFF_PROMISC) {
1507 filter |= RNDIS_PACKET_TYPE_PROMISCUOUS | 1508 filter |= RNDIS_PACKET_TYPE_PROMISCUOUS |
1508 RNDIS_PACKET_TYPE_ALL_LOCAL; 1509 RNDIS_PACKET_TYPE_ALL_LOCAL;
1509 } else if (usbdev->net->flags & IFF_ALLMULTI || 1510 } else if (usbdev->net->flags & IFF_ALLMULTI) {
1510 netdev_mc_count(usbdev->net) > priv->multicast_size) { 1511 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST;
1512 }
1513
1514 if (filter != basefilter)
1515 goto set_filter;
1516
1517 /*
1518 * mc_list should be accessed holding the lock, so copy addresses to
1519 * local buffer first.
1520 */
1521 netif_addr_lock_bh(usbdev->net);
1522 mc_count = netdev_mc_count(usbdev->net);
1523 if (mc_count > priv->multicast_size) {
1511 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST; 1524 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST;
1512 } else if (!netdev_mc_empty(usbdev->net)) { 1525 } else if (mc_count) {
1513 size = min(priv->multicast_size, netdev_mc_count(usbdev->net)); 1526 int i = 0;
1514 buf = kmalloc(size * ETH_ALEN, GFP_KERNEL); 1527
1515 if (!buf) { 1528 mc_addrs = kmalloc(mc_count * ETH_ALEN, GFP_ATOMIC);
1529 if (!mc_addrs) {
1516 netdev_warn(usbdev->net, 1530 netdev_warn(usbdev->net,
1517 "couldn't alloc %d bytes of memory\n", 1531 "couldn't alloc %d bytes of memory\n",
1518 size * ETH_ALEN); 1532 mc_count * ETH_ALEN);
1519 netif_addr_unlock_bh(usbdev->net); 1533 netif_addr_unlock_bh(usbdev->net);
1520 return; 1534 return;
1521 } 1535 }
1522 1536
1523 i = 0; 1537 netdev_for_each_mc_addr(mclist, usbdev->net)
1524 netdev_for_each_mc_addr(mclist, usbdev->net) { 1538 memcpy(mc_addrs + i++ * ETH_ALEN,
1525 if (i == size) 1539 mclist->dmi_addr, ETH_ALEN);
1526 break; 1540 }
1527 memcpy(buf + i++ * ETH_ALEN, mclist->dmi_addr, ETH_ALEN); 1541 netif_addr_unlock_bh(usbdev->net);
1528 }
1529 1542
1530 ret = rndis_set_oid(usbdev, OID_802_3_MULTICAST_LIST, buf, 1543 if (filter != basefilter)
1531 i * ETH_ALEN); 1544 goto set_filter;
1532 if (ret == 0 && i > 0) 1545
1546 if (mc_count) {
1547 ret = rndis_set_oid(usbdev, OID_802_3_MULTICAST_LIST, mc_addrs,
1548 mc_count * ETH_ALEN);
1549 kfree(mc_addrs);
1550 if (ret == 0)
1533 filter |= RNDIS_PACKET_TYPE_MULTICAST; 1551 filter |= RNDIS_PACKET_TYPE_MULTICAST;
1534 else 1552 else
1535 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST; 1553 filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST;
1536 1554
1537 netdev_dbg(usbdev->net, "OID_802_3_MULTICAST_LIST(%d, max: %d) -> %d\n", 1555 netdev_dbg(usbdev->net, "OID_802_3_MULTICAST_LIST(%d, max: %d) -> %d\n",
1538 i, priv->multicast_size, ret); 1556 mc_count, priv->multicast_size, ret);
1539
1540 kfree(buf);
1541 } 1557 }
1542 netif_addr_unlock_bh(usbdev->net);
1543 1558
1559set_filter:
1544 ret = rndis_set_oid(usbdev, OID_GEN_CURRENT_PACKET_FILTER, &filter, 1560 ret = rndis_set_oid(usbdev, OID_GEN_CURRENT_PACKET_FILTER, &filter,
1545 sizeof(filter)); 1561 sizeof(filter));
1546 if (ret < 0) { 1562 if (ret < 0) {
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index aca8c124f434..91cce2d0f6db 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -1225,7 +1225,7 @@ MODULE_LICENSE("GPL");
1225#ifdef CONFIG_RT2800PCI_SOC 1225#ifdef CONFIG_RT2800PCI_SOC
1226static int rt2800soc_probe(struct platform_device *pdev) 1226static int rt2800soc_probe(struct platform_device *pdev)
1227{ 1227{
1228 return rt2x00soc_probe(pdev, rt2800pci_ops); 1228 return rt2x00soc_probe(pdev, &rt2800pci_ops);
1229} 1229}
1230 1230
1231static struct platform_driver rt2800soc_driver = { 1231static struct platform_driver rt2800soc_driver = {
diff --git a/drivers/net/wireless/rt2x00/rt2x00soc.c b/drivers/net/wireless/rt2x00/rt2x00soc.c
index 4efdc96010f6..111c0ff5c6c7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00soc.c
+++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
@@ -112,6 +112,7 @@ exit_free_device:
112 112
113 return retval; 113 return retval;
114} 114}
115EXPORT_SYMBOL_GPL(rt2x00soc_probe);
115 116
116int rt2x00soc_remove(struct platform_device *pdev) 117int rt2x00soc_remove(struct platform_device *pdev)
117{ 118{
diff --git a/drivers/net/wireless/rt2x00/rt2x00soc.h b/drivers/net/wireless/rt2x00/rt2x00soc.h
index 4739edfe2f00..474cbfc1efc7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00soc.h
+++ b/drivers/net/wireless/rt2x00/rt2x00soc.h
@@ -26,8 +26,6 @@
26#ifndef RT2X00SOC_H 26#ifndef RT2X00SOC_H
27#define RT2X00SOC_H 27#define RT2X00SOC_H
28 28
29#define KSEG1ADDR(__ptr) __ptr
30
31/* 29/*
32 * SoC driver handlers. 30 * SoC driver handlers.
33 */ 31 */
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index e77aec8d0a84..290d70bc5d22 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2352,6 +2352,8 @@ static struct usb_device_id rt73usb_device_table[] = {
2352 { USB_DEVICE(0x0411, 0x00f4), USB_DEVICE_DATA(&rt73usb_ops) }, 2352 { USB_DEVICE(0x0411, 0x00f4), USB_DEVICE_DATA(&rt73usb_ops) },
2353 { USB_DEVICE(0x0411, 0x0116), USB_DEVICE_DATA(&rt73usb_ops) }, 2353 { USB_DEVICE(0x0411, 0x0116), USB_DEVICE_DATA(&rt73usb_ops) },
2354 { USB_DEVICE(0x0411, 0x0119), USB_DEVICE_DATA(&rt73usb_ops) }, 2354 { USB_DEVICE(0x0411, 0x0119), USB_DEVICE_DATA(&rt73usb_ops) },
2355 /* CEIVA */
2356 { USB_DEVICE(0x178d, 0x02be), USB_DEVICE_DATA(&rt73usb_ops) },
2355 /* CNet */ 2357 /* CNet */
2356 { USB_DEVICE(0x1371, 0x9022), USB_DEVICE_DATA(&rt73usb_ops) }, 2358 { USB_DEVICE(0x1371, 0x9022), USB_DEVICE_DATA(&rt73usb_ops) },
2357 { USB_DEVICE(0x1371, 0x9032), USB_DEVICE_DATA(&rt73usb_ops) }, 2359 { USB_DEVICE(0x1371, 0x9032), USB_DEVICE_DATA(&rt73usb_ops) },
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index a22a19203120..00e09e26c826 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -350,7 +350,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
350 first_idx = info->status.rates[0].idx; 350 first_idx = info->status.rates[0].idx;
351 ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates)); 351 ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates));
352 retries = &zd_retry_rates[first_idx]; 352 retries = &zd_retry_rates[first_idx];
353 ZD_ASSERT(0<=retry && retry<=retries->count); 353 ZD_ASSERT(1 <= retry && retry <= retries->count);
354 354
355 info->status.rates[0].idx = retries->rate[0]; 355 info->status.rates[0].idx = retries->rate[0];
356 info->status.rates[0].count = 1; // (retry > 1 ? 2 : 1); 356 info->status.rates[0].count = 1; // (retry > 1 ? 2 : 1);
@@ -360,7 +360,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
360 info->status.rates[i].count = 1; // ((i==retry-1) && success ? 1:2); 360 info->status.rates[i].count = 1; // ((i==retry-1) && success ? 1:2);
361 } 361 }
362 for (; i<IEEE80211_TX_MAX_RATES && i<retry; i++) { 362 for (; i<IEEE80211_TX_MAX_RATES && i<retry; i++) {
363 info->status.rates[i].idx = retries->rate[retry-1]; 363 info->status.rates[i].idx = retries->rate[retry - 1];
364 info->status.rates[i].count = 1; // (success ? 1:2); 364 info->status.rates[i].count = 1; // (success ? 1:2);
365 } 365 }
366 if (i<IEEE80211_TX_MAX_RATES) 366 if (i<IEEE80211_TX_MAX_RATES)
@@ -424,12 +424,10 @@ void zd_mac_tx_failed(struct urb *urb)
424 first_idx = info->status.rates[0].idx; 424 first_idx = info->status.rates[0].idx;
425 ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates)); 425 ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates));
426 retries = &zd_retry_rates[first_idx]; 426 retries = &zd_retry_rates[first_idx];
427 if (retry < 0 || retry > retries->count) { 427 if (retry <= 0 || retry > retries->count)
428 continue; 428 continue;
429 }
430 429
431 ZD_ASSERT(0<=retry && retry<=retries->count); 430 final_idx = retries->rate[retry - 1];
432 final_idx = retries->rate[retry-1];
433 final_rate = zd_rates[final_idx].hw_value; 431 final_rate = zd_rates[final_idx].hw_value;
434 432
435 if (final_rate != tx_status->rate) { 433 if (final_rate != tx_status->rate) {