*
* @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
* We recommend using nested, driver-specific attributes within this.
-@@ -787,6 +801,11 @@ enum nl80211_commands {
+@@ -787,6 +801,33 @@ enum nl80211_commands {
* This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
* for non-automatic settings.
*
+ * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
+ * means support for per-station GTKs.
+ *
++ * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
++ * This can be used to mask out antennas which are not attached or should
++ * not be used for transmitting. If an antenna is not selected in this
++ * bitmap the hardware is not allowed to transmit on this antenna.
++ *
++ * Each bit represents one antenna, starting with antenna 1 at the first
++ * bit. Depending on which antennas are selected in the bitmap, 802.11n
++ * drivers can derive which chainmasks to use (if all antennas belonging to
++ * a particular chain are disabled this chain should be disabled) and if
++ * a chain has diversity antennas wether diversity should be used or not.
++ * HT capabilities (STBC, TX Beamforming, Antenna selection) can be
++ * derived from the available chains after applying the antenna mask.
++ * Non-802.11n drivers can derive wether to use diversity or not.
++ * Drivers may reject configurations or RX/TX mask combinations they cannot
++ * support by returning -EINVAL.
++ *
++ * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
++ * This can be used to mask out antennas which are not attached or should
++ * not be used for receiving. If an antenna is not selected in this bitmap
++ * the hardware should not be configured to receive on this antenna.
++ * For a more detailed descripton see @NL80211_ATTR_WIPHY_ANTENNA_TX.
++ *
+ * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
+ *
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
*/
-@@ -951,6 +970,13 @@ enum nl80211_attrs {
+@@ -951,6 +992,16 @@ enum nl80211_attrs {
NL80211_ATTR_RX_FRAME_TYPES,
NL80211_ATTR_FRAME_TYPE,
+
+ NL80211_ATTR_SUPPORT_IBSS_RSN,
+
++ NL80211_ATTR_WIPHY_ANTENNA_TX,
++ NL80211_ATTR_WIPHY_ANTENNA_RX,
++
+ NL80211_ATTR_MCAST_RATE,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
-@@ -1006,6 +1032,8 @@ enum nl80211_attrs {
+@@ -1006,6 +1057,8 @@ enum nl80211_attrs {
* @NL80211_IFTYPE_WDS: wireless distribution interface
* @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
* @NL80211_IFTYPE_MESH_POINT: mesh point
* @NL80211_IFTYPE_MAX: highest interface type number currently defined
* @NUM_NL80211_IFTYPES: number of defined interface types
*
-@@ -1022,6 +1050,8 @@ enum nl80211_iftype {
+@@ -1022,6 +1075,8 @@ enum nl80211_iftype {
NL80211_IFTYPE_WDS,
NL80211_IFTYPE_MONITOR,
NL80211_IFTYPE_MESH_POINT,
/* keep last */
NUM_NL80211_IFTYPES,
-@@ -1111,6 +1141,8 @@ enum nl80211_rate_info {
+@@ -1111,6 +1166,8 @@ enum nl80211_rate_info {
* @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
* @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
* station)
*/
enum nl80211_sta_info {
__NL80211_STA_INFO_INVALID,
-@@ -1124,6 +1156,8 @@ enum nl80211_sta_info {
+@@ -1124,6 +1181,8 @@ enum nl80211_sta_info {
NL80211_STA_INFO_TX_BITRATE,
NL80211_STA_INFO_RX_PACKETS,
NL80211_STA_INFO_TX_PACKETS,
/* keep last */
__NL80211_STA_INFO_AFTER_LAST,
-@@ -1382,6 +1416,17 @@ enum nl80211_reg_rule_flags {
+@@ -1277,7 +1336,11 @@ enum nl80211_bitrate_attr {
+ * wireless core it thinks its knows the regulatory domain we should be in.
+ * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
+ * 802.11 country information element with regulatory information it
+- * thinks we should consider.
++ * thinks we should consider. cfg80211 only processes the country
++ * code from the IE, and relies on the regulatory domain information
++ * structure pased by userspace (CRDA) from our wireless-regdb.
++ * If a channel is enabled but the country code indicates it should
++ * be disabled we disable the channel and re-enable it upon disassociation.
+ */
+ enum nl80211_reg_initiator {
+ NL80211_REGDOM_SET_BY_CORE,
+@@ -1382,6 +1445,17 @@ enum nl80211_reg_rule_flags {
* @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved
* @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
* @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
* @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
* currently defined
* @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
-@@ -1390,6 +1435,12 @@ enum nl80211_survey_info {
+@@ -1390,6 +1464,12 @@ enum nl80211_survey_info {
__NL80211_SURVEY_INFO_INVALID,
NL80211_SURVEY_INFO_FREQUENCY,
NL80211_SURVEY_INFO_NOISE,
/* keep last */
__NL80211_SURVEY_INFO_AFTER_LAST,
-@@ -1636,11 +1687,14 @@ enum nl80211_auth_type {
+@@ -1636,11 +1716,14 @@ enum nl80211_auth_type {
* @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key
* @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key
* @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS)
};
/**
-@@ -1671,6 +1725,9 @@ enum nl80211_wpa_versions {
+@@ -1671,6 +1754,9 @@ enum nl80211_wpa_versions {
* CCMP keys, each six bytes in little endian
* @NL80211_KEY_DEFAULT: flag indicating default key
* @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
* @__NL80211_KEY_AFTER_LAST: internal
* @NL80211_KEY_MAX: highest key attribute
*/
-@@ -1682,6 +1739,7 @@ enum nl80211_key_attributes {
+@@ -1682,6 +1768,7 @@ enum nl80211_key_attributes {
NL80211_KEY_SEQ,
NL80211_KEY_DEFAULT,
NL80211_KEY_DEFAULT_MGMT,
PKG_NAME:=mac80211
-PKG_VERSION:=2010-10-19
+PKG_VERSION:=2010-12-09
PKG_RELEASE:=1
PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
# http://www.orbit-lab.org/kernel/compat-wireless-2.6/2010/11 \
# http://wireless.kernel.org/download/compat-wireless-2.6
-PKG_MD5SUM:=3bad1752f0154baa57a4d94774bd2ccf
+PKG_MD5SUM:=94b6eaaa2c8245d1b5d6b6f16b75a701
PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION)
[ -n "$fixed" -a -n "$channel" ] && iw dev "$ifname" set channel "$channel"
fi
- # txpower is not yet implemented in iw
config_get vif_txpower "$vif" txpower
# use vif_txpower (from wifi-iface) to override txpower (from
# wifi-device) if the latter doesn't exist
txpower="${txpower:-$vif_txpower}"
- [ -z "$txpower" ] || iwconfig "$ifname" txpower "${txpower%%.*}"
+ [ -z "$txpower" ] || iw dev "$ifname" set txpower fixed "${txpower%%.*}00"
done
local start_hostapd=
--- a/config.mk
+++ b/config.mk
-@@ -300,8 +300,8 @@ endif #CONFIG_SSB
+@@ -301,8 +301,8 @@ endif #CONFIG_SSB
CONFIG_P54_PCI=m
ifeq ($(CONFIG_MAC80211),y)
$(error "ERROR: you have MAC80211 compiled into the kernel, CONFIG_MAC80211=y, as such you cannot replace its mac80211 driver. You need this set to CONFIG_MAC80211=m. If you are using Fedora upgrade your kernel as later version should this set as modular. For further information on Fedora see https://bugzilla.redhat.com/show_bug.cgi?id=470143. If you are using your own kernel recompile it and make mac80211 modular")
-@@ -585,8 +585,8 @@ endif #CONFIG_COMPAT_KERNEL_27
+@@ -590,8 +590,8 @@ endif #CONFIG_COMPAT_KERNEL_27
# We need the backported rfkill module on kernel < 2.6.31.
# In more recent kernel versions use the in kernel rfkill module.
ifdef CONFIG_COMPAT_KERNEL_31
+# CONFIG_RFKILL_BACKPORT_INPUT=y
endif #CONFIG_COMPAT_KERNEL_31
+--- a/include/linux/rfkill.h
++++ b/include/linux/rfkill.h
+@@ -3,6 +3,10 @@
+
+ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
+
++#undef CONFIG_RFKILL
++#undef CONFIG_RFKILL_LEDS
++#undef CONFIG_RFKILL_MODULE
++
+ #include_next <linux/rfkill.h>
+
+ #else
else
include $(KLIB_BUILD)/.config
endif
-@@ -283,21 +282,6 @@ CONFIG_IPW2200_QOS=y
+@@ -285,19 +284,18 @@ CONFIG_IPW2200_QOS=y
# % echo 1 > /sys/bus/pci/drivers/ipw2200/*/rtap_iface
endif #CONFIG_WIRELESS_EXT
-ifdef CONFIG_SSB
-# Sonics Silicon Backplane
-CONFIG_SSB_SPROM=y
--# CONFIG_SSB_DEBUG=y
-
-CONFIG_SSB_BLOCKIO=y
-CONFIG_SSB_PCIHOST=y
-# CONFIG_SSB_DEBUG=y
-CONFIG_SSB_DRIVER_PCICORE=y
-endif #CONFIG_SSB
--
++# ifdef CONFIG_SSB
++# # Sonics Silicon Backplane
++# CONFIG_SSB_SPROM=y
++# CONFIG_SSB_BLOCKIO=y
++# CONFIG_SSB_PCIHOST=y
++# CONFIG_SSB_B43_PCI_BRIDGE=y
++# ifdef CONFIG_PCMCIA
++# CONFIG_SSB_PCMCIAHOST=y
++# endif #CONFIG_PCMCIA
++# # CONFIG_SSB_DEBUG=y
++# CONFIG_SSB_DRIVER_PCICORE=y
++# endif #CONFIG_SSB
+
CONFIG_P54_PCI=m
- # CONFIG_B44=m
-@@ -485,7 +469,6 @@ endif #CONFIG_SPI_MASTER end of SPI driv
+@@ -486,7 +484,6 @@ endif #CONFIG_SPI_MASTER end of SPI driv
ifdef CONFIG_MMC
endif
# mac80211 test driver
-@@ -314,13 +314,13 @@ endif #CONFIG_CRC_ITU_T
+@@ -326,13 +326,13 @@ endif #CONFIG_CRC_ITU_T
CONFIG_MWL8K=m
# Ethernet drivers go here
endif #CONFIG_COMPAT_KERNEL_27
ifdef CONFIG_WIRELESS_EXT
-@@ -371,17 +371,17 @@ CONFIG_ZD1211RW=m
+@@ -383,21 +383,21 @@ CONFIG_ZD1211RW=m
# Note: this depends on CONFIG_USB_NET_RNDIS_HOST and CONFIG_USB_NET_CDCETHER
# it also requires new RNDIS_HOST and CDC_ETHER modules which we add
ifdef CONFIG_COMPAT_KERNEL_29
-CONFIG_USB_NET_COMPAT_RNDIS_HOST=m
-CONFIG_USB_NET_COMPAT_RNDIS_WLAN=m
+# CONFIG_USB_NET_COMPAT_RNDIS_HOST=m
++# CONFIG_USB_NET_COMPAT_RNDIS_WLAN=m
+ endif #CONFIG_USB_NET_CDCETHER
+ ifdef CONFIG_USB_NET_CDCETHER_MODULE
+-CONFIG_USB_NET_COMPAT_RNDIS_HOST=m
+-CONFIG_USB_NET_COMPAT_RNDIS_WLAN=m
++# CONFIG_USB_NET_COMPAT_RNDIS_HOST=m
+# CONFIG_USB_NET_COMPAT_RNDIS_WLAN=m
endif #CONFIG_USB_NET_CDCETHER
-CONFIG_USB_NET_COMPAT_CDCETHER=m
# enable mesh networking too
CONFIG_MAC80211_MESH=y
-@@ -240,7 +240,7 @@ CONFIG_B43_PCI_AUTOSELECT=y
+@@ -242,7 +242,7 @@ CONFIG_B43_PCI_AUTOSELECT=y
ifdef CONFIG_PCMCIA
CONFIG_B43_PCMCIA=y
endif #CONFIG_PCMCIA
CONFIG_B43_PHY_LP=y
CONFIG_B43_NPHY=y
# CONFIG_B43_FORCE_PIO=y
-@@ -249,7 +249,7 @@ CONFIG_B43_NPHY=y
+@@ -251,7 +251,7 @@ CONFIG_B43_NPHY=y
CONFIG_B43LEGACY=m
CONFIG_B43LEGACY_HWRNG=y
CONFIG_B43LEGACY_PCI_AUTOSELECT=y
# CONFIG_B43LEGACY_DEBUG=y
CONFIG_B43LEGACY_DMA=y
CONFIG_B43LEGACY_PIO=y
-@@ -542,7 +542,7 @@ endif
+@@ -561,7 +561,7 @@ endif
# p54
CONFIG_P54_COMMON=m
# Atheros
CONFIG_ATH_COMMON=m
---- a/drivers/net/wireless/ath/ath9k/gpio.c
-+++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -54,6 +54,7 @@ static void ath_led_blink_work(struct wo
- sc->sc_flags |= SC_OP_LED_ON;
- }
-
-+#ifdef CONFIG_LEDS_CLASS
- static void ath_led_brightness(struct led_classdev *led_cdev,
- enum led_brightness brightness)
- {
-@@ -90,10 +91,12 @@ static void ath_led_brightness(struct le
- break;
- }
- }
-+#endif
-
- static int ath_register_led(struct ath_softc *sc, struct ath_led *led,
- char *trigger)
- {
-+#ifdef CONFIG_LEDS_CLASS
- int ret;
-
- led->sc = sc;
-@@ -108,14 +111,19 @@ static int ath_register_led(struct ath_s
- else
- led->registered = 1;
- return ret;
-+#else
-+ return 0;
-+#endif
- }
-
- static void ath_unregister_led(struct ath_led *led)
- {
-+#ifdef CONFIG_LEDS_CLASS
- if (led->registered) {
- led_classdev_unregister(&led->led_cdev);
- led->registered = 0;
- }
-+#endif
- }
-
- void ath_deinit_leds(struct ath_softc *sc)
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
-@@ -860,6 +860,7 @@ static void ath9k_led_brightness_work(st
+@@ -864,6 +864,7 @@ static void ath9k_led_brightness_work(st
}
}
static void ath9k_led_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
-@@ -871,6 +872,7 @@ static void ath9k_led_brightness(struct
+@@ -875,6 +876,7 @@ static void ath9k_led_brightness(struct
ieee80211_queue_delayed_work(priv->hw,
&led->brightness_work, 0);
}
static void ath9k_led_stop_brightness(struct ath9k_htc_priv *priv)
{
-@@ -883,6 +885,7 @@ static void ath9k_led_stop_brightness(st
+@@ -887,6 +889,7 @@ static void ath9k_led_stop_brightness(st
static int ath9k_register_led(struct ath9k_htc_priv *priv, struct ath_led *led,
char *trigger)
{
int ret;
led->priv = priv;
-@@ -900,14 +903,19 @@ static int ath9k_register_led(struct ath
+@@ -904,14 +907,19 @@ static int ath9k_register_led(struct ath
INIT_DELAYED_WORK(&led->brightness_work, ath9k_led_brightness_work);
return ret;
else
include $(KLIB_BUILD)/.config
endif
-@@ -221,7 +221,7 @@ CONFIG_B43=m
+@@ -223,7 +223,7 @@ CONFIG_B43=m
CONFIG_B43_HWRNG=y
CONFIG_B43_PCI_AUTOSELECT=y
ifdef CONFIG_PCMCIA
--- a/config.mk
+++ b/config.mk
-@@ -452,7 +452,7 @@ endif #CONFIG_SPI_MASTER end of SPI driv
+@@ -467,7 +467,7 @@ endif #CONFIG_SPI_MASTER end of SPI driv
ifdef CONFIG_MMC
+# CONFIG_B43_SDIO=y
ifdef CONFIG_CRC7
- CONFIG_WL1251_SDIO=m
+ ifdef CONFIG_WL12XX_PLATFORM_DATA
+++ /dev/null
---- a/drivers/net/wireless/ath/ath5k/base.h
-+++ b/drivers/net/wireless/ath/ath5k/base.h
-@@ -46,7 +46,7 @@
- #include <linux/wireless.h>
- #include <linux/if_ether.h>
- #include <linux/leds.h>
--#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
-+#if 0
- #include <linux/rfkill.h>
- #else
- #include <linux/rfkill_backport.h>
---- a/net/wireless/core.h
-+++ b/net/wireless/core.h
-@@ -11,7 +11,7 @@
- #include <linux/kref.h>
- #include <linux/rbtree.h>
- #include <linux/debugfs.h>
--#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
-+#if 0
- #include <linux/rfkill.h>
- #else
- #include <linux/rfkill_backport.h>
---- a/include/linux/rfkill_backport.h
-+++ b/include/linux/rfkill_backport.h
-@@ -149,7 +149,7 @@ struct rfkill_ops {
- int (*set_block)(void *data, bool blocked);
- };
-
--#if defined(CONFIG_RFKILL_BACKPORT) || defined(CONFIG_RFKILL_BACKPORT_MODULE)
-+#if 0
- /**
- * rfkill_alloc - allocate rfkill structure
- * @name: name of the struct -- the string is not copied internally
--- a/config.mk
+++ b/config.mk
-@@ -225,7 +225,7 @@ ifdef CONFIG_PCMCIA
+@@ -227,7 +227,7 @@ ifdef CONFIG_PCMCIA
endif #CONFIG_PCMCIA
# CONFIG_B43_LEDS=y
CONFIG_B43_PHY_LP=y
--- a/config.mk
+++ b/config.mk
-@@ -274,12 +274,12 @@ CONFIG_RTL8180=m
+@@ -289,7 +289,7 @@ CONFIG_RTL8180=m
CONFIG_ADM8211=m
CONFIG_RT2400PCI=m
CONFIG_RT2500PCI=m
ifdef CONFIG_CRC_CCITT
- CONFIG_RT2800PCI=m
--CONFIG_RT2800PCI_PCI=y
-+# CONFIG_RT2800PCI_PCI=y
- # CONFIG_RT2800PCI_RT30XX=y
- # CONFIG_RT2800PCI_RT35XX=y
- # CONFIG_RT2800PCI_SOC=y
-@@ -402,7 +402,7 @@ CONFIG_RT2800USB_RT30XX=y
- CONFIG_RT2800USB_RT35XX=y
+@@ -418,7 +418,7 @@ CONFIG_RT2800USB=m
+ # CONFIG_RT2800USB_RT35XX=y
CONFIG_RT2800USB_UNKNOWN=y
endif #CONFIG_CRC_CCITT
-CONFIG_RT2X00_LIB_USB=m
--- a/config.mk
+++ b/config.mk
-@@ -204,7 +204,7 @@ CONFIG_ATH9K_COMMON=m
+@@ -206,7 +206,7 @@ CONFIG_ATH9K_COMMON=m
# as default once we get minstrel properly tested and blessed by
# our systems engineering team. CCK rates also need to be used
# for long range considerations.
--- /dev/null
+--- a/drivers/net/wireless/b43/main.c
++++ b/drivers/net/wireless/b43/main.c
+@@ -322,83 +322,59 @@ static int b43_ratelimit(struct b43_wl *
+
+ void b43info(struct b43_wl *wl, const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+
+ if (b43_modparam_verbose < B43_VERBOSITY_INFO)
+ return;
+ if (!b43_ratelimit(wl))
+ return;
+-
+ va_start(args, fmt);
+-
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- printk(KERN_INFO "b43-%s: %pV",
+- (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf);
+-
++ printk(KERN_INFO "b43-%s: ",
++ (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan");
++ vprintk(fmt, args);
+ va_end(args);
+ }
+
+ void b43err(struct b43_wl *wl, const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+
+ if (b43_modparam_verbose < B43_VERBOSITY_ERROR)
+ return;
+ if (!b43_ratelimit(wl))
+ return;
+-
+ va_start(args, fmt);
+-
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- printk(KERN_ERR "b43-%s ERROR: %pV",
+- (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf);
+-
++ printk(KERN_ERR "b43-%s ERROR: ",
++ (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan");
++ vprintk(fmt, args);
+ va_end(args);
+ }
+
+ void b43warn(struct b43_wl *wl, const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+
+ if (b43_modparam_verbose < B43_VERBOSITY_WARN)
+ return;
+ if (!b43_ratelimit(wl))
+ return;
+-
+ va_start(args, fmt);
+-
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- printk(KERN_WARNING "b43-%s warning: %pV",
+- (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf);
+-
++ printk(KERN_WARNING "b43-%s warning: ",
++ (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan");
++ vprintk(fmt, args);
+ va_end(args);
+ }
+
+ void b43dbg(struct b43_wl *wl, const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+
+ if (b43_modparam_verbose < B43_VERBOSITY_DEBUG)
+ return;
+-
+ va_start(args, fmt);
+-
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- printk(KERN_DEBUG "b43-%s debug: %pV",
+- (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf);
+-
++ printk(KERN_DEBUG "b43-%s debug: ",
++ (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan");
++ vprintk(fmt, args);
+ va_end(args);
+ }
+
+--- a/drivers/net/wireless/b43legacy/main.c
++++ b/drivers/net/wireless/b43legacy/main.c
+@@ -181,75 +181,52 @@ static int b43legacy_ratelimit(struct b4
+
+ void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+
+ if (!b43legacy_ratelimit(wl))
+ return;
+-
+ va_start(args, fmt);
+-
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- printk(KERN_INFO "b43legacy-%s: %pV",
+- (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf);
+-
++ printk(KERN_INFO "b43legacy-%s: ",
++ (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan");
++ vprintk(fmt, args);
+ va_end(args);
+ }
+
+ void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+
+ if (!b43legacy_ratelimit(wl))
+ return;
+-
+ va_start(args, fmt);
+-
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- printk(KERN_ERR "b43legacy-%s ERROR: %pV",
+- (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf);
+-
++ printk(KERN_ERR "b43legacy-%s ERROR: ",
++ (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan");
++ vprintk(fmt, args);
+ va_end(args);
+ }
+
+ void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+
+ if (!b43legacy_ratelimit(wl))
+ return;
+-
+ va_start(args, fmt);
+-
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- printk(KERN_WARNING "b43legacy-%s warning: %pV",
+- (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf);
+-
++ printk(KERN_WARNING "b43legacy-%s warning: ",
++ (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan");
++ vprintk(fmt, args);
+ va_end(args);
+ }
+
+ #if B43legacy_DEBUG
+ void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+
+ va_start(args, fmt);
+-
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- printk(KERN_DEBUG "b43legacy-%s debug: %pV",
+- (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf);
+-
++ printk(KERN_DEBUG "b43legacy-%s debug: ",
++ (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan");
++ vprintk(fmt, args);
+ va_end(args);
+ }
+ #endif /* DEBUG */
+--- a/drivers/net/wireless/ath/main.c
++++ b/drivers/net/wireless/ath/main.c
+@@ -60,16 +60,13 @@ EXPORT_SYMBOL(ath_rxbuf_alloc);
+ int ath_printk(const char *level, struct ath_common *common,
+ const char *fmt, ...)
+ {
+- struct va_format vaf;
+ va_list args;
+ int rtn;
+
+ va_start(args, fmt);
+
+- vaf.fmt = fmt;
+- vaf.va = &args;
+-
+- rtn = printk("%sath: %pV", level, &vaf);
++ printk("%sath: ", level);
++ rtn = vprintk(fmt, args);
+
+ va_end(args);
+
--- a/include/linux/compat-2.6.36.h
+++ b/include/linux/compat-2.6.36.h
-@@ -56,6 +56,8 @@ static inline int pcmcia_write_config_by
- return pcmcia_access_configuration_register(p_dev, ®);
- }
+@@ -90,6 +90,8 @@ struct pm_qos_request_list {
+
+ #endif
+#define PCI_EEPROM_WIDTH_93C86 8
+
--- a/compat/compat-2.6.28.c
+++ b/compat/compat-2.6.28.c
-@@ -89,7 +89,7 @@ EXPORT_SYMBOL_GPL(usb_poison_urb);
+@@ -86,7 +86,7 @@ EXPORT_SYMBOL_GPL(usb_poison_urb);
#endif
#endif /* CONFIG_USB */
struct pcmcia_cfg_mem {
--- a/compat/compat-2.6.33.c
+++ b/compat/compat-2.6.33.c
-@@ -14,7 +14,7 @@
-
+@@ -11,7 +11,7 @@
+ #include <linux/compat.h>
#include <linux/autoconf.h>
-#if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
/**
* pccard_loop_tuple() - loop over tuples in the CIS
-@@ -76,7 +76,7 @@ next_entry:
+@@ -73,7 +73,7 @@ next_entry:
EXPORT_SYMBOL(pccard_loop_tuple);
/* Source: drivers/pcmcia/cistpl.c */
--- a/compat/compat-2.6.28.c
+++ b/compat/compat-2.6.28.c
-@@ -168,7 +168,7 @@ EXPORT_SYMBOL(pcmcia_loop_config);
+@@ -165,7 +165,7 @@ EXPORT_SYMBOL(pcmcia_loop_config);
#endif /* CONFIG_PCMCIA */
{
--- a/compat/compat-2.6.29.c
+++ b/compat/compat-2.6.29.c
-@@ -52,7 +52,7 @@ void netdev_attach_ops(struct net_device
+@@ -49,7 +49,7 @@ void netdev_attach_ops(struct net_device
EXPORT_SYMBOL(netdev_attach_ops);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
#endif
--- a/config.mk
+++ b/config.mk
-@@ -389,7 +389,7 @@ endif #CONFIG_COMPAT_KERNEL_29
+@@ -405,7 +405,7 @@ endif #CONFIG_COMPAT_KERNEL_29
# This activates a threading fix for usb urb.
# this is mainline commit: b3e670443b7fb8a2d29831b62b44a039c283e351
# This fix will be included in some stable releases.
--- /dev/null
+--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
++++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
+@@ -27,6 +27,7 @@
+ *
+ *****************************************************************************/
+
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/kernel.h>
+--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
++++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
+@@ -27,6 +27,7 @@
+ *
+ *****************************************************************************/
+
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/kernel.h>
+--- a/drivers/net/wireless/libertas_tf/cmd.c
++++ b/drivers/net/wireless/libertas_tf/cmd.c
+@@ -7,6 +7,7 @@
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/slab.h>
+--- a/drivers/net/wireless/libertas_tf/if_usb.c
++++ b/drivers/net/wireless/libertas_tf/if_usb.c
+@@ -9,6 +9,7 @@
+ */
+ #define DRV_NAME "lbtf_usb"
+
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include "libertas_tf.h"
+--- a/drivers/net/wireless/libertas_tf/main.c
++++ b/drivers/net/wireless/libertas_tf/main.c
+@@ -7,6 +7,7 @@
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/slab.h>
+--- a/net/wireless/core.c
++++ b/net/wireless/core.c
+@@ -4,6 +4,7 @@
+ * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
+ */
+
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/if.h>
+--- a/net/wireless/lib80211.c
++++ b/net/wireless/lib80211.c
+@@ -13,6 +13,7 @@
+ *
+ */
+
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/module.h>
+--- a/net/wireless/lib80211_crypt_tkip.c
++++ b/net/wireless/lib80211_crypt_tkip.c
+@@ -10,6 +10,7 @@
+ * more details.
+ */
+
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/err.h>
+--- a/net/wireless/reg.c
++++ b/net/wireless/reg.c
+@@ -33,6 +33,7 @@
+ *
+ */
+
++#undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/kernel.h>
---- a/drivers/net/wireless/ath/ath5k/reset.c
-+++ b/drivers/net/wireless/ath/ath5k/reset.c
-@@ -1334,10 +1334,18 @@ int ath5k_hw_reset(struct ath5k_hw *ah,
+--- a/drivers/net/wireless/ath/ath5k/initvals.c
++++ b/drivers/net/wireless/ath/ath5k/initvals.c
+@@ -58,8 +58,14 @@ static const struct ath5k_ini ar5210_ini
+ { AR5K_IMR, 0 },
+ { AR5K_IER, AR5K_IER_DISABLE },
+ { AR5K_BSR, 0, AR5K_INI_READ },
++#ifndef CONFIG_ATHEROS_AR71XX
+ { AR5K_TXCFG, AR5K_DMASIZE_128B },
+ { AR5K_RXCFG, AR5K_DMASIZE_128B },
++#else
++ /* WAR for AR71xx PCI bug */
++ { AR5K_TXCFG, AR5K_DMASIZE_4B },
++ { AR5K_RXCFG, AR5K_DMASIZE_4B },
++#endif
+ { AR5K_CFG, AR5K_INIT_CFG },
+ { AR5K_TOPS, 8 },
+ { AR5K_RXNOFRM, 8 },
+--- a/drivers/net/wireless/ath/ath5k/dma.c
++++ b/drivers/net/wireless/ath/ath5k/dma.c
+@@ -787,10 +787,18 @@ void ath5k_hw_dma_init(struct ath5k_hw *
* guess we can tweak it and see how it goes ;-)
*/
if (ah->ah_version != AR5K_AR5210) {
}
/* Pre-enable interrupts on 5211/5212*/
---- a/drivers/net/wireless/ath/ath5k/initvals.c
-+++ b/drivers/net/wireless/ath/ath5k/initvals.c
-@@ -58,8 +58,14 @@ static const struct ath5k_ini ar5210_ini
- { AR5K_IMR, 0 },
- { AR5K_IER, AR5K_IER_DISABLE },
- { AR5K_BSR, 0, AR5K_INI_READ },
-+#ifndef CONFIG_ATHEROS_AR71XX
- { AR5K_TXCFG, AR5K_DMASIZE_128B },
- { AR5K_RXCFG, AR5K_DMASIZE_128B },
-+#else
-+ /* WAR for AR71xx PCI bug */
-+ { AR5K_TXCFG, AR5K_DMASIZE_4B },
-+ { AR5K_RXCFG, AR5K_DMASIZE_4B },
-+#endif
- { AR5K_CFG, AR5K_INIT_CFG },
- { AR5K_TOPS, 8 },
- { AR5K_RXNOFRM, 8 },
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -927,6 +927,12 @@ int ath9k_init_debug(struct ath_hw *ah)
+ sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca))
+ goto err;
+
++ debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
++ sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
++
++ debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
++ sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
++
+ sc->debug.regidx = 0;
+ return 0;
+ err:
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -795,6 +795,8 @@ struct ath_hw {
+ int initPDADC;
+ int PDADCdelta;
+ u8 led_pin;
++ u32 gpio_mask;
++ u32 gpio_val;
+
+ struct ar5416IniArray iniModes;
+ struct ar5416IniArray iniCommon;
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1171,6 +1171,20 @@ static bool ath9k_hw_channel_change(stru
+ return true;
+ }
+
++static void ath9k_hw_apply_gpio_override(struct ath_hw *ah)
++{
++ u32 gpio_mask = ah->gpio_mask;
++ int i;
++
++ for (i = 0; gpio_mask; i++, gpio_mask >>= 1) {
++ if (!(gpio_mask & 1))
++ continue;
++
++ ath9k_hw_cfg_output(ah, i, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
++ ath9k_hw_set_gpio(ah, i, !!(ah->gpio_val & BIT(i)));
++ }
++}
++
+ bool ath9k_hw_check_alive(struct ath_hw *ah)
+ {
+ int count = 50;
+@@ -1457,6 +1471,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+ if (AR_SREV_9300_20_OR_LATER(ah))
+ ar9003_hw_bb_watchdog_config(ah);
+
++ ath9k_hw_apply_gpio_override(ah);
++
+ return 0;
+ }
+ EXPORT_SYMBOL(ath9k_hw_reset);
+++ /dev/null
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -224,8 +224,8 @@ static int nl80211_prepare_netdev_dump(s
- }
-
- *rdev = cfg80211_get_dev_from_ifindex(sock_net(skb->sk), ifidx);
-- if (IS_ERR(dev)) {
-- err = PTR_ERR(dev);
-+ if (IS_ERR(*rdev)) {
-+ err = PTR_ERR(*rdev);
- goto out_rtnl;
- }
-
+++ /dev/null
---- a/include/net/regulatory.h
-+++ b/include/net/regulatory.h
-@@ -43,6 +43,12 @@ enum environment_cap {
- * @intersect: indicates whether the wireless core should intersect
- * the requested regulatory domain with the presently set regulatory
- * domain.
-+ * @processed: indicates whether or not this requests has already been
-+ * processed. When the last request is processed it means that the
-+ * currently regulatory domain set on cfg80211 is updated from
-+ * CRDA and can be used by other regulatory requests. When a
-+ * the last request is not yet processed we must yield until it
-+ * is processed before processing any new requests.
- * @country_ie_checksum: checksum of the last processed and accepted
- * country IE
- * @country_ie_env: lets us know if the AP is telling us we are outdoor,
-@@ -54,6 +60,7 @@ struct regulatory_request {
- enum nl80211_reg_initiator initiator;
- char alpha2[2];
- bool intersect;
-+ bool processed;
- enum environment_cap country_ie_env;
- struct list_head list;
- };
---- a/net/wireless/reg.c
-+++ b/net/wireless/reg.c
-@@ -96,6 +96,9 @@ struct reg_beacon {
- struct ieee80211_channel chan;
- };
-
-+static void reg_todo(struct work_struct *work);
-+static DECLARE_WORK(reg_work, reg_todo);
-+
- /* We keep a static world regulatory domain in case of the absence of CRDA */
- static const struct ieee80211_regdomain world_regdom = {
- .n_reg_rules = 5,
-@@ -1215,6 +1218,21 @@ static int ignore_request(struct wiphy *
- return -EINVAL;
- }
-
-+static void reg_set_request_processed(void)
-+{
-+ bool need_more_processing = false;
-+
-+ last_request->processed = true;
-+
-+ spin_lock(®_requests_lock);
-+ if (!list_empty(®_requests_list))
-+ need_more_processing = true;
-+ spin_unlock(®_requests_lock);
-+
-+ if (need_more_processing)
-+ schedule_work(®_work);
-+}
-+
- /**
- * __regulatory_hint - hint to the wireless core a regulatory domain
- * @wiphy: if the hint comes from country information from an AP, this
-@@ -1290,8 +1308,10 @@ new_request:
- * have applied the requested regulatory domain before we just
- * inform userspace we have processed the request
- */
-- if (r == -EALREADY)
-+ if (r == -EALREADY) {
- nl80211_send_reg_change_event(last_request);
-+ reg_set_request_processed();
-+ }
- return r;
- }
-
-@@ -1307,16 +1327,13 @@ static void reg_process_hint(struct regu
-
- BUG_ON(!reg_request->alpha2);
-
-- mutex_lock(&cfg80211_mutex);
-- mutex_lock(®_mutex);
--
- if (wiphy_idx_valid(reg_request->wiphy_idx))
- wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
-
- if (reg_request->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
- !wiphy) {
- kfree(reg_request);
-- goto out;
-+ return;
- }
-
- r = __regulatory_hint(wiphy, reg_request);
-@@ -1324,28 +1341,46 @@ static void reg_process_hint(struct regu
- if (r == -EALREADY && wiphy &&
- wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY)
- wiphy_update_regulatory(wiphy, initiator);
--out:
-- mutex_unlock(®_mutex);
-- mutex_unlock(&cfg80211_mutex);
- }
-
--/* Processes regulatory hints, this is all the NL80211_REGDOM_SET_BY_* */
-+/*
-+ * Processes regulatory hints, this is all the NL80211_REGDOM_SET_BY_*
-+ * Regulatory hints come on a first come first serve basis and we
-+ * must process each one atomically.
-+ */
- static void reg_process_pending_hints(void)
-- {
-+{
- struct regulatory_request *reg_request;
-
-+ mutex_lock(&cfg80211_mutex);
-+ mutex_lock(®_mutex);
-+
-+ /* When last_request->processed becomes true this will be rescheduled */
-+ if (last_request && !last_request->processed) {
-+ REG_DBG_PRINT("Pending regulatory request, waiting "
-+ "for it to be processed...");
-+ goto out;
-+ }
-+
- spin_lock(®_requests_lock);
-- while (!list_empty(®_requests_list)) {
-- reg_request = list_first_entry(®_requests_list,
-- struct regulatory_request,
-- list);
-- list_del_init(®_request->list);
-
-+ if (list_empty(®_requests_list)) {
- spin_unlock(®_requests_lock);
-- reg_process_hint(reg_request);
-- spin_lock(®_requests_lock);
-+ goto out;
- }
-+
-+ reg_request = list_first_entry(®_requests_list,
-+ struct regulatory_request,
-+ list);
-+ list_del_init(®_request->list);
-+
- spin_unlock(®_requests_lock);
-+
-+ reg_process_hint(reg_request);
-+
-+out:
-+ mutex_unlock(®_mutex);
-+ mutex_unlock(&cfg80211_mutex);
- }
-
- /* Processes beacon hints -- this has nothing to do with country IEs */
-@@ -1392,8 +1427,6 @@ static void reg_todo(struct work_struct
- reg_process_pending_beacon_hints();
- }
-
--static DECLARE_WORK(reg_work, reg_todo);
--
- static void queue_regulatory_request(struct regulatory_request *request)
- {
- if (isalpha(request->alpha2[0]))
-@@ -1428,12 +1461,7 @@ static int regulatory_hint_core(const ch
- request->alpha2[1] = alpha2[1];
- request->initiator = NL80211_REGDOM_SET_BY_CORE;
-
-- /*
-- * This ensures last_request is populated once modules
-- * come swinging in and calling regulatory hints and
-- * wiphy_apply_custom_regulatory().
-- */
-- reg_process_hint(request);
-+ queue_regulatory_request(request);
-
- return 0;
- }
-@@ -1959,6 +1987,8 @@ int set_regdom(const struct ieee80211_re
-
- nl80211_send_reg_change_event(last_request);
-
-+ reg_set_request_processed();
-+
- mutex_unlock(®_mutex);
-
- return r;
--- /dev/null
+--- a/net/mac80211/led.c
++++ b/net/mac80211/led.c
+@@ -54,12 +54,22 @@ void ieee80211_led_radio(struct ieee8021
+ led_trigger_event(local->radio_led, LED_OFF);
+ }
+
++void ieee80211_led_names(struct ieee80211_local *local)
++{
++ snprintf(local->rx_led_name, sizeof(local->rx_led_name),
++ "%srx", wiphy_name(local->hw.wiphy));
++ snprintf(local->tx_led_name, sizeof(local->tx_led_name),
++ "%stx", wiphy_name(local->hw.wiphy));
++ snprintf(local->assoc_led_name, sizeof(local->assoc_led_name),
++ "%sassoc", wiphy_name(local->hw.wiphy));
++ snprintf(local->radio_led_name, sizeof(local->radio_led_name),
++ "%sradio", wiphy_name(local->hw.wiphy));
++}
++
+ void ieee80211_led_init(struct ieee80211_local *local)
+ {
+ local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
+ if (local->rx_led) {
+- snprintf(local->rx_led_name, sizeof(local->rx_led_name),
+- "%srx", wiphy_name(local->hw.wiphy));
+ local->rx_led->name = local->rx_led_name;
+ if (led_trigger_register(local->rx_led)) {
+ kfree(local->rx_led);
+@@ -69,8 +79,6 @@ void ieee80211_led_init(struct ieee80211
+
+ local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
+ if (local->tx_led) {
+- snprintf(local->tx_led_name, sizeof(local->tx_led_name),
+- "%stx", wiphy_name(local->hw.wiphy));
+ local->tx_led->name = local->tx_led_name;
+ if (led_trigger_register(local->tx_led)) {
+ kfree(local->tx_led);
+@@ -80,8 +88,6 @@ void ieee80211_led_init(struct ieee80211
+
+ local->assoc_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
+ if (local->assoc_led) {
+- snprintf(local->assoc_led_name, sizeof(local->assoc_led_name),
+- "%sassoc", wiphy_name(local->hw.wiphy));
+ local->assoc_led->name = local->assoc_led_name;
+ if (led_trigger_register(local->assoc_led)) {
+ kfree(local->assoc_led);
+@@ -91,14 +97,19 @@ void ieee80211_led_init(struct ieee80211
+
+ local->radio_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
+ if (local->radio_led) {
+- snprintf(local->radio_led_name, sizeof(local->radio_led_name),
+- "%sradio", wiphy_name(local->hw.wiphy));
+ local->radio_led->name = local->radio_led_name;
+ if (led_trigger_register(local->radio_led)) {
+ kfree(local->radio_led);
+ local->radio_led = NULL;
+ }
+ }
++
++ if (local->tpt_led_trigger) {
++ if (led_trigger_register(&local->tpt_led_trigger->trig)) {
++ kfree(local->tpt_led_trigger);
++ local->tpt_led_trigger = NULL;
++ }
++ }
+ }
+
+ void ieee80211_led_exit(struct ieee80211_local *local)
+@@ -119,15 +130,18 @@ void ieee80211_led_exit(struct ieee80211
+ led_trigger_unregister(local->rx_led);
+ kfree(local->rx_led);
+ }
++
++ if (local->tpt_led_trigger) {
++ led_trigger_unregister(&local->tpt_led_trigger->trig);
++ kfree(local->tpt_led_trigger);
++ }
+ }
+
+ char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
+ {
+ struct ieee80211_local *local = hw_to_local(hw);
+
+- if (local->radio_led)
+- return local->radio_led_name;
+- return NULL;
++ return local->radio_led_name;
+ }
+ EXPORT_SYMBOL(__ieee80211_get_radio_led_name);
+
+@@ -135,9 +149,7 @@ char *__ieee80211_get_assoc_led_name(str
+ {
+ struct ieee80211_local *local = hw_to_local(hw);
+
+- if (local->assoc_led)
+- return local->assoc_led_name;
+- return NULL;
++ return local->assoc_led_name;
+ }
+ EXPORT_SYMBOL(__ieee80211_get_assoc_led_name);
+
+@@ -145,9 +157,7 @@ char *__ieee80211_get_tx_led_name(struct
+ {
+ struct ieee80211_local *local = hw_to_local(hw);
+
+- if (local->tx_led)
+- return local->tx_led_name;
+- return NULL;
++ return local->tx_led_name;
+ }
+ EXPORT_SYMBOL(__ieee80211_get_tx_led_name);
+
+@@ -155,8 +165,115 @@ char *__ieee80211_get_rx_led_name(struct
+ {
+ struct ieee80211_local *local = hw_to_local(hw);
+
+- if (local->rx_led)
+- return local->rx_led_name;
+- return NULL;
++ return local->rx_led_name;
+ }
+ EXPORT_SYMBOL(__ieee80211_get_rx_led_name);
++
++static unsigned long tpt_trig_traffic(struct ieee80211_local *local,
++ struct tpt_led_trigger *tpt_trig)
++{
++ unsigned long traffic, delta;
++
++ traffic = tpt_trig->tx_bytes + tpt_trig->rx_bytes;
++
++ delta = traffic - tpt_trig->prev_traffic;
++ tpt_trig->prev_traffic = traffic;
++ return DIV_ROUND_UP(delta, 1024 / 8);
++}
++
++static void tpt_trig_timer(unsigned long data)
++{
++ struct ieee80211_local *local = (void *)data;
++ struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
++ struct led_classdev *led_cdev;
++ unsigned long on, off, tpt;
++ int i;
++
++ if (!tpt_trig->running)
++ return;
++
++ mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ));
++
++ tpt = tpt_trig_traffic(local, tpt_trig);
++
++ /* default to just solid on */
++ on = 1;
++ off = 0;
++
++ for (i = tpt_trig->blink_table_len - 1; i >= 0; i--) {
++ if (tpt_trig->blink_table[i].throughput < 0 ||
++ tpt > tpt_trig->blink_table[i].throughput) {
++ off = tpt_trig->blink_table[i].blink_time / 2;
++ on = tpt_trig->blink_table[i].blink_time - off;
++ break;
++ }
++ }
++
++ read_lock(&tpt_trig->trig.leddev_list_lock);
++ list_for_each_entry(led_cdev, &tpt_trig->trig.led_cdevs, trig_list)
++ led_blink_set(led_cdev, &on, &off);
++ read_unlock(&tpt_trig->trig.leddev_list_lock);
++}
++
++extern char *__ieee80211_create_tpt_led_trigger(
++ struct ieee80211_hw *hw,
++ const struct ieee80211_tpt_blink *blink_table,
++ unsigned int blink_table_len)
++{
++ struct ieee80211_local *local = hw_to_local(hw);
++ struct tpt_led_trigger *tpt_trig;
++
++ if (WARN_ON(local->tpt_led_trigger))
++ return NULL;
++
++ tpt_trig = kzalloc(sizeof(struct tpt_led_trigger), GFP_KERNEL);
++ if (!tpt_trig)
++ return NULL;
++
++ snprintf(tpt_trig->name, sizeof(tpt_trig->name),
++ "%stpt", wiphy_name(local->hw.wiphy));
++
++ tpt_trig->trig.name = tpt_trig->name;
++
++ tpt_trig->blink_table = blink_table;
++ tpt_trig->blink_table_len = blink_table_len;
++
++ setup_timer(&tpt_trig->timer, tpt_trig_timer, (unsigned long)local);
++
++ local->tpt_led_trigger = tpt_trig;
++
++ return tpt_trig->name;
++}
++EXPORT_SYMBOL(__ieee80211_create_tpt_led_trigger);
++
++void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
++{
++ struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
++
++ if (!tpt_trig)
++ return;
++
++ /* reset traffic */
++ tpt_trig_traffic(local, tpt_trig);
++ tpt_trig->running = true;
++
++ tpt_trig_timer((unsigned long)local);
++ mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ));
++}
++
++void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local)
++{
++ struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
++ struct led_classdev *led_cdev;
++
++ if (!tpt_trig)
++ return;
++
++ tpt_trig->running = false;
++ del_timer_sync(&tpt_trig->timer);
++
++ read_lock(&tpt_trig->trig.leddev_list_lock);
++ list_for_each_entry(led_cdev, &tpt_trig->trig.led_cdevs, trig_list)
++ led_brightness_set(led_cdev, LED_OFF);
++ read_unlock(&tpt_trig->trig.leddev_list_lock);
++}
+--- a/net/mac80211/led.h
++++ b/net/mac80211/led.h
+@@ -12,14 +12,17 @@
+ #include "ieee80211_i.h"
+
+ #ifdef CONFIG_MAC80211_LEDS
+-extern void ieee80211_led_rx(struct ieee80211_local *local);
+-extern void ieee80211_led_tx(struct ieee80211_local *local, int q);
+-extern void ieee80211_led_assoc(struct ieee80211_local *local,
+- bool associated);
+-extern void ieee80211_led_radio(struct ieee80211_local *local,
+- bool enabled);
+-extern void ieee80211_led_init(struct ieee80211_local *local);
+-extern void ieee80211_led_exit(struct ieee80211_local *local);
++void ieee80211_led_rx(struct ieee80211_local *local);
++void ieee80211_led_tx(struct ieee80211_local *local, int q);
++void ieee80211_led_assoc(struct ieee80211_local *local,
++ bool associated);
++void ieee80211_led_radio(struct ieee80211_local *local,
++ bool enabled);
++void ieee80211_led_names(struct ieee80211_local *local);
++void ieee80211_led_init(struct ieee80211_local *local);
++void ieee80211_led_exit(struct ieee80211_local *local);
++void ieee80211_start_tpt_led_trig(struct ieee80211_local *local);
++void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local);
+ #else
+ static inline void ieee80211_led_rx(struct ieee80211_local *local)
+ {
+@@ -35,10 +38,37 @@ static inline void ieee80211_led_radio(s
+ bool enabled)
+ {
+ }
++static inline void ieee80211_led_names(struct ieee80211_local *local)
++{
++}
+ static inline void ieee80211_led_init(struct ieee80211_local *local)
+ {
+ }
+ static inline void ieee80211_led_exit(struct ieee80211_local *local)
+ {
+ }
++static inline void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
++{
++}
++static inline void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local)
++{
++}
++#endif
++
++static inline void
++ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, __le16 fc, int bytes)
++{
++#ifdef CONFIG_MAC80211_LEDS
++ if (local->tpt_led_trigger && ieee80211_is_data(fc))
++ local->tpt_led_trigger->tx_bytes += bytes;
++#endif
++}
++
++static inline void
++ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, __le16 fc, int bytes)
++{
++#ifdef CONFIG_MAC80211_LEDS
++ if (local->tpt_led_trigger && ieee80211_is_data(fc))
++ local->tpt_led_trigger->rx_bytes += bytes;
+ #endif
++}
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -602,6 +602,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(
+ /* init dummy netdev for use w/ NAPI */
+ init_dummy_netdev(&local->napi_dev);
+
++ ieee80211_led_names(local);
++
+ return local_to_hw(local);
+ }
+ EXPORT_SYMBOL(ieee80211_alloc_hw);
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -1856,11 +1856,26 @@ struct ieee80211_hw *ieee80211_alloc_hw(
+ */
+ int ieee80211_register_hw(struct ieee80211_hw *hw);
+
++/**
++ * struct ieee80211_tpt_blink - throughput blink description
++ * @throughput: throughput in Kbit/sec
++ * @blink_time: blink time in milliseconds
++ * (full cycle, ie. one off + one on period)
++ */
++struct ieee80211_tpt_blink {
++ int throughput;
++ int blink_time;
++};
++
+ #ifdef CONFIG_MAC80211_LEDS
+ extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
+ extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
+ extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
+ extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
++extern char *__ieee80211_create_tpt_led_trigger(
++ struct ieee80211_hw *hw,
++ const struct ieee80211_tpt_blink *blink_table,
++ unsigned int blink_table_len);
+ #endif
+ /**
+ * ieee80211_get_tx_led_name - get name of TX LED
+@@ -1939,6 +1954,29 @@ static inline char *ieee80211_get_radio_
+ }
+
+ /**
++ * ieee80211_create_tpt_led_trigger - create throughput LED trigger
++ * @hw: the hardware to create the trigger for
++ * @blink_table: the blink table -- needs to be ordered by throughput
++ * @blink_table_len: size of the blink table
++ *
++ * This function returns %NULL (in case of error, or if no LED
++ * triggers are configured) or the name of the new trigger.
++ * This function must be called before ieee80211_register_hw().
++ */
++static inline char *
++ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
++ const struct ieee80211_tpt_blink *blink_table,
++ unsigned int blink_table_len)
++{
++#ifdef CONFIG_MAC80211_LEDS
++ return __ieee80211_create_tpt_led_trigger(hw, blink_table,
++ blink_table_len);
++#else
++ return NULL;
++#endif
++}
++
++/**
+ * ieee80211_unregister_hw - Unregister a hardware device
+ *
+ * This function instructs mac80211 to free allocated resources
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -23,6 +23,7 @@
+ #include <linux/types.h>
+ #include <linux/spinlock.h>
+ #include <linux/etherdevice.h>
++#include <linux/leds.h>
+ #include <net/ieee80211_radiotap.h>
+ #include <net/cfg80211.h>
+ #include <net/mac80211.h>
+@@ -629,6 +630,19 @@ enum queue_stop_reason {
+ IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
+ };
+
++#ifdef CONFIG_MAC80211_LEDS
++struct tpt_led_trigger {
++ struct led_trigger trig;
++ char name[32];
++ const struct ieee80211_tpt_blink *blink_table;
++ unsigned int blink_table_len;
++ struct timer_list timer;
++ bool running;
++ unsigned long prev_traffic;
++ unsigned long tx_bytes, rx_bytes;
++};
++#endif
++
+ /**
+ * mac80211 scan flags - currently active scan mode
+ *
+@@ -842,6 +856,7 @@ struct ieee80211_local {
+ #ifdef CONFIG_MAC80211_LEDS
+ int tx_led_counter, rx_led_counter;
+ struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
++ struct tpt_led_trigger *tpt_led_trigger;
+ char tx_led_name[32], rx_led_name[32],
+ assoc_led_name[32], radio_led_name[32];
+ #endif
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -220,6 +220,7 @@ static int ieee80211_do_open(struct net_
+ /* we're brought up, everything changes */
+ hw_reconf_flags = ~0;
+ ieee80211_led_radio(local, true);
++ ieee80211_start_tpt_led_trig(local);
+ }
+
+ /*
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -2888,6 +2888,9 @@ void ieee80211_rx(struct ieee80211_hw *h
+ return;
+ }
+
++ ieee80211_tpt_led_trig_rx(local,
++ ((struct ieee80211_hdr *)skb->data)->frame_control,
++ skb->len);
+ __ieee80211_rx_handle_packet(hw, skb);
+
+ rcu_read_unlock();
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -1293,6 +1293,7 @@ static int __ieee80211_tx(struct ieee802
+
+ while (skb) {
+ int q = skb_get_queue_mapping(skb);
++ __le16 fc;
+
+ spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
+ ret = IEEE80211_TX_OK;
+@@ -1335,6 +1336,7 @@ static int __ieee80211_tx(struct ieee802
+ else
+ info->control.sta = NULL;
+
++ fc = ((struct ieee80211_hdr *)skb->data)->frame_control;
+ ret = drv_tx(local, skb);
+ if (WARN_ON(ret != NETDEV_TX_OK && skb->len != len)) {
+ dev_kfree_skb(skb);
+@@ -1345,6 +1347,7 @@ static int __ieee80211_tx(struct ieee802
+ return IEEE80211_TX_AGAIN;
+ }
+
++ ieee80211_tpt_led_trig_tx(local, fc, len);
+ *skbp = skb = next;
+ ieee80211_led_tx(local, 1);
+ fragm = true;
+--- a/net/mac80211/util.c
++++ b/net/mac80211/util.c
+@@ -1141,6 +1141,7 @@ u32 ieee80211_sta_get_rates(struct ieee8
+ void ieee80211_stop_device(struct ieee80211_local *local)
+ {
+ ieee80211_led_radio(local, false);
++ ieee80211_stop_tpt_led_trig(local);
+
+ cancel_work_sync(&local->reconfig_filter);
+
+@@ -1175,6 +1176,7 @@ int ieee80211_reconfig(struct ieee80211_
+ }
+
+ ieee80211_led_radio(local, true);
++ ieee80211_start_tpt_led_trig(local);
+ }
+
+ /* add interfaces */
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -1685,17 +1685,20 @@ static void ath_tx_start_dma(struct ath_
+ struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct list_head bf_head;
+- struct ath_atx_tid *tid;
++ struct ath_atx_tid *tid = NULL;
+ u8 tidno;
+
+ spin_lock_bh(&txctl->txq->axq_lock);
+
+- if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && txctl->an) {
++ if (ieee80211_is_data_qos(hdr->frame_control) && txctl->an) {
+ tidno = ieee80211_get_qos_ctl(hdr)[0] &
+ IEEE80211_QOS_CTL_TID_MASK;
+ tid = ATH_AN_2_TID(txctl->an, tidno);
+
+ WARN_ON(tid->ac->txq != txctl->txq);
++ }
++
++ if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
+ /*
+ * Try aggregation if it's a unicast data frame
+ * and the destination is HT capable.
+@@ -1712,7 +1715,7 @@ static void ath_tx_start_dma(struct ath_
+ ar9003_hw_set_paprd_txdesc(sc->sc_ah, bf->bf_desc,
+ bf->bf_state.bfs_paprd);
+
+- ath_tx_send_normal(sc, txctl->txq, NULL, &bf_head);
++ ath_tx_send_normal(sc, txctl->txq, tid, &bf_head);
+ }
+
+ spin_unlock_bh(&txctl->txq->axq_lock);
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -284,11 +284,9 @@ static void ath9k_hw_read_revisions(stru
+
+ static void ath9k_hw_disablepcie(struct ath_hw *ah)
+ {
+- if (AR_SREV_9100(ah))
++ if (!AR_SREV_5416(ah))
+ return;
+
+- ENABLE_REGWRITE_BUFFER(ah);
+-
+ REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
+ REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
+ REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029);
+@@ -300,8 +298,6 @@ static void ath9k_hw_disablepcie(struct
+ REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007);
+
+ REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
+-
+- REGWRITE_BUFFER_FLUSH(ah);
+ }
+
+ /* This should work for all families including legacy */
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1940,7 +1940,9 @@ static u64 ath9k_get_tsf(struct ieee8021
+ struct ath_softc *sc = aphy->sc;
+
+ mutex_lock(&sc->mutex);
++ ath9k_ps_wakeup(sc);
+ tsf = ath9k_hw_gettsf64(sc->sc_ah);
++ ath9k_ps_restore(sc);
+ mutex_unlock(&sc->mutex);
+
+ return tsf;
+@@ -1952,7 +1954,9 @@ static void ath9k_set_tsf(struct ieee802
+ struct ath_softc *sc = aphy->sc;
+
+ mutex_lock(&sc->mutex);
++ ath9k_ps_wakeup(sc);
+ ath9k_hw_settsf64(sc->sc_ah, tsf);
++ ath9k_ps_restore(sc);
+ mutex_unlock(&sc->mutex);
+ }
+
--- /dev/null
+--- a/net/mac80211/driver-ops.h
++++ b/net/mac80211/driver-ops.h
+@@ -381,7 +381,7 @@ static inline void drv_reset_tsf(struct
+
+ static inline int drv_tx_last_beacon(struct ieee80211_local *local)
+ {
+- int ret = 1;
++ int ret = 0; /* default unsuported op for less congestion */
+
+ might_sleep();
+
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -128,6 +128,9 @@ static void ath_unregister_led(struct at
+@@ -120,6 +120,9 @@ static void ath_unregister_led(struct at
void ath_deinit_leds(struct ath_softc *sc)
{
ath_unregister_led(&sc->assoc_led);
sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
ath_unregister_led(&sc->tx_led);
-@@ -141,6 +144,9 @@ void ath_init_leds(struct ath_softc *sc)
+@@ -133,6 +136,9 @@ void ath_init_leds(struct ath_softc *sc)
char *trigger;
int ret;
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -33,7 +33,7 @@ int modparam_nohwcrypt;
+ module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
+ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption");
+
+-int led_blink;
++int led_blink = 1;
+ module_param_named(blink, led_blink, int, 0444);
+ MODULE_PARM_DESC(blink, "Enable LED blink on activity");
+
#include <asm/unaligned.h>
#include "hw.h"
-@@ -449,8 +450,16 @@ static int ath9k_hw_init_macaddr(struct
+@@ -436,8 +437,16 @@ static int ath9k_hw_init_macaddr(struct
common->macaddr[2 * i] = eeval >> 8;
common->macaddr[2 * i + 1] = eeval & 0xff;
}
- if (sum == 0 || sum == 0xffff * 3)
- return -EADDRNOTAVAIL;
+ if (!is_valid_ether_addr(common->macaddr)) {
-+ ath_print(common, ATH_DBG_EEPROM,
++ ath_err(common,
+ "eeprom contains invalid mac address: %pM\n",
+ common->macaddr);
+
+ random_ether_addr(common->macaddr);
-+ ath_print(common, ATH_DBG_EEPROM,
++ ath_err(common,
+ "random mac address will be used: %pM\n",
+ common->macaddr);
+ }
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/pci.c
-+++ b/drivers/net/wireless/ath/ath9k/pci.c
-@@ -16,6 +16,7 @@
-
- #include <linux/nl80211.h>
- #include <linux/pci.h>
-+#include <linux/ath9k_platform.h>
- #include "ath9k.h"
-
- static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = {
-@@ -53,21 +54,36 @@ static void ath_pci_read_cachesize(struc
-
- static bool ath_pci_eeprom_read(struct ath_common *common, u32 off, u16 *data)
- {
-- struct ath_hw *ah = (struct ath_hw *) common->ah;
-+ struct ath_softc *sc = (struct ath_softc *) common->priv;
-+ struct ath9k_platform_data *pdata = sc->dev->platform_data;
-
-- common->ops->read(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
-+ if (pdata) {
-+ if (off >= (ARRAY_SIZE(pdata->eeprom_data))) {
-+ ath_print(common, ATH_DBG_FATAL,
-+ "%s: eeprom read failed, offset %08x "
-+ "is out of range\n",
-+ __func__, off);
-+ }
-+
-+ *data = pdata->eeprom_data[off];
-+ } else {
-+ struct ath_hw *ah = (struct ath_hw *) common->ah;
-+
-+ common->ops->read(ah, AR5416_EEPROM_OFFSET +
-+ (off << AR5416_EEPROM_S));
-+
-+ if (!ath9k_hw_wait(ah,
-+ AR_EEPROM_STATUS_DATA,
-+ AR_EEPROM_STATUS_DATA_BUSY |
-+ AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0,
-+ AH_WAIT_TIMEOUT)) {
-+ return false;
-+ }
-
-- if (!ath9k_hw_wait(ah,
-- AR_EEPROM_STATUS_DATA,
-- AR_EEPROM_STATUS_DATA_BUSY |
-- AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0,
-- AH_WAIT_TIMEOUT)) {
-- return false;
-+ *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
-+ AR_EEPROM_STATUS_DATA_VAL);
- }
-
-- *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
-- AR_EEPROM_STATUS_DATA_VAL);
--
- return true;
- }
-
--- /dev/null
+--- a/drivers/net/wireless/ath/regd.c
++++ b/drivers/net/wireless/ath/regd.c
+@@ -37,7 +37,8 @@
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
+
+ /* We allow IBSS on these on a case by case basis by regulatory domain */
+-#define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5350+10, 40, 0, 30,\
++#define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5250, 40, 0, 30, 0), \
++ REG_RULE(5250, 5350+10, 40, 0, 30,\
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
+ #define ATH9K_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 40, 0, 30,\
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -15,6 +15,7 @@
- */
-
- #include <linux/nl80211.h>
-+#include <linux/ath9k_platform.h>
- #include "ath9k.h"
- #include "btcoex.h"
-
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -559,6 +559,7 @@ static int ath9k_init_softc(u16 devid, s
- {
- struct ath_hw *ah = NULL;
- struct ath_common *common;
-+ struct ath9k_platform_data *pdata;
- int ret = 0, i;
- int csz = 0;
-
-@@ -570,6 +571,10 @@ static int ath9k_init_softc(u16 devid, s
- ah->hw_version.subsysid = subsysid;
- sc->sc_ah = ah;
-
-+ pdata = (struct ath9k_platform_data *) sc->dev->platform_data;
-+ if (!pdata)
-+ ah->ah_flags |= AH_USE_EEPROM;
-+
- common = ath9k_hw_common(ah);
- common->ops = &ath9k_common_ops;
- common->bus_ops = bus_ops;
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -420,10 +420,6 @@ static void ath9k_hw_init_defaults(struc
- ah->hw_version.magic = AR5416_MAGIC;
- ah->hw_version.subvendorid = 0;
-
-- ah->ah_flags = 0;
-- if (!AR_SREV_9100(ah))
-- ah->ah_flags = AH_USE_EEPROM;
--
- ah->atim_window = 0;
- ah->sta_id1_defaults =
- AR_STA_ID1_CRPT_MIC_ENABLE |
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -17,8 +17,10 @@
- #include <linux/io.h>
- #include <linux/slab.h>
- #include <linux/etherdevice.h>
-+#include <linux/ath9k_platform.h>
- #include <asm/unaligned.h>
-
-+#include "ath9k.h"
- #include "hw.h"
- #include "hw-ops.h"
- #include "rc.h"
-@@ -434,18 +436,23 @@ static void ath9k_hw_init_defaults(struc
- static int ath9k_hw_init_macaddr(struct ath_hw *ah)
- {
- struct ath_common *common = ath9k_hw_common(ah);
-+ struct ath_softc *sc = (struct ath_softc *) common->priv;
-+ struct ath9k_platform_data *pdata = sc->dev->platform_data;
- u32 sum;
- int i;
- u16 eeval;
- u32 EEP_MAC[] = { EEP_MAC_LSW, EEP_MAC_MID, EEP_MAC_MSW };
-
- sum = 0;
-- for (i = 0; i < 3; i++) {
-- eeval = ah->eep_ops->get_eeprom(ah, EEP_MAC[i]);
-- sum += eeval;
-- common->macaddr[2 * i] = eeval >> 8;
-- common->macaddr[2 * i + 1] = eeval & 0xff;
-- }
-+ if (pdata && pdata->macaddr)
-+ memcpy(common->macaddr, pdata->macaddr, ETH_ALEN);
-+ else
-+ for (i = 0; i < 3; i++) {
-+ eeval = ah->eep_ops->get_eeprom(ah, EEP_MAC[i]);
-+ sum += eeval;
-+ common->macaddr[2 * i] = eeval >> 8;
-+ common->macaddr[2 * i + 1] = eeval & 0xff;
-+ }
- if (!is_valid_ether_addr(common->macaddr)) {
- ath_print(common, ATH_DBG_EEPROM,
- "eeprom contains invalid mac address: %pM\n",
--- a/include/linux/ath9k_platform.h
+++ b/include/linux/ath9k_platform.h
@@ -23,6 +23,7 @@
};
#endif /* _LINUX_ATH9K_PLATFORM_H */
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -15,6 +15,7 @@
+ */
+
+ #include <linux/slab.h>
++#include <linux/ath9k_platform.h>
+
+ #include "ath9k.h"
+
+@@ -522,6 +523,7 @@ static void ath9k_init_misc(struct ath_s
+ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
+ const struct ath_bus_ops *bus_ops)
+ {
++ struct ath9k_platform_data *pdata = sc->dev->platform_data;
+ struct ath_hw *ah = NULL;
+ struct ath_common *common;
+ int ret = 0, i;
+@@ -535,7 +537,7 @@ static int ath9k_init_softc(u16 devid, s
+ ah->hw_version.subsysid = subsysid;
+ sc->sc_ah = ah;
+
+- if (!sc->dev->platform_data)
++ if (!pdata)
+ ah->ah_flags |= AH_USE_EEPROM;
+
+ common = ath9k_hw_common(ah);
+@@ -568,6 +570,9 @@ static int ath9k_init_softc(u16 devid, s
+ if (ret)
+ goto err_hw;
+
++ if (pdata && pdata->macaddr)
++ memcpy(common->macaddr, pdata->macaddr, ETH_ALEN);
++
+ ret = ath9k_init_queues(sc);
+ if (ret)
+ goto err_queues;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1420,7 +1420,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
-
- if (ah->config.rx_intr_mitigation) {
- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500);
-- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000);
-+ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 500);
- }
-
- if (ah->config.tx_intr_mitigation) {
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -16,6 +16,7 @@
-
- #include <linux/slab.h>
-
-+#include "linux/ath9k_platform.h"
- #include "ath9k.h"
-
- static char *dev_info = "ath9k";
-@@ -574,6 +575,8 @@ static int ath9k_init_softc(u16 devid, s
- pdata = (struct ath9k_platform_data *) sc->dev->platform_data;
- if (!pdata)
- ah->ah_flags |= AH_USE_EEPROM;
-+ else
-+ sc->quirk_wndr3700 = pdata->quirk_wndr3700;
-
- common = ath9k_hw_common(ah);
- common->ops = &ath9k_common_ops;
-@@ -704,6 +707,24 @@ void ath9k_set_hw_capab(struct ath_softc
- SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
- }
-
-+#ifdef CONFIG_ATHEROS_AR71XX
-+static void wndr3700_init_antenna(struct ath_hw *ah)
-+{
-+ ath9k_hw_cfg_output(ah, 6, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+ ath9k_hw_cfg_output(ah, 7, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+ ath9k_hw_cfg_output(ah, 8, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+ ath9k_hw_cfg_output(ah, 9, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+
-+ /* select the first antenna group */
-+ ath9k_hw_set_gpio(ah, 6, 0);
-+ ath9k_hw_set_gpio(ah, 7, 1);
-+ ath9k_hw_set_gpio(ah, 8, 0);
-+ ath9k_hw_set_gpio(ah, 9, 1);
-+}
-+#else
-+static inline void wndr3700_init_antenna(struct ath_hw *ah) {}
-+#endif /* CONFIG_ATHEROS_AR71XX */
-+
- int ath9k_init_device(u16 devid, struct ath_softc *sc, u16 subsysid,
- const struct ath_bus_ops *bus_ops)
- {
-@@ -723,6 +744,9 @@ int ath9k_init_device(u16 devid, struct
- common = ath9k_hw_common(ah);
- ath9k_set_hw_capab(sc, hw);
-
-+ if (sc->quirk_wndr3700)
-+ wndr3700_init_antenna(ah);
-+
- /* Initialize regulatory */
- error = ath_regd_init(&common->regulatory, sc->hw->wiphy,
- ath9k_reg_notifier);
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -635,6 +635,8 @@ struct ath_softc {
-
- int beacon_interval;
-
-+ bool quirk_wndr3700;
-+
- #ifdef CONFIG_ATH9K_DEBUGFS
- struct ath9k_debug debug;
- #endif
---- a/include/linux/ath9k_platform.h
-+++ b/include/linux/ath9k_platform.h
-@@ -24,6 +24,8 @@
- struct ath9k_platform_data {
- u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
- u8 *macaddr;
-+
-+ bool quirk_wndr3700;
- };
-
- #endif /* _LINUX_ATH9K_PLATFORM_H */
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -537,8 +537,14 @@ static int ath9k_init_softc(u16 devid, s
+ ah->hw_version.subsysid = subsysid;
+ sc->sc_ah = ah;
+
+- if (!pdata)
++ if (!pdata) {
+ ah->ah_flags |= AH_USE_EEPROM;
++ sc->sc_ah->led_pin = -1;
++ } else {
++ sc->sc_ah->gpio_mask = pdata->gpio_mask;
++ sc->sc_ah->gpio_val = pdata->gpio_val;
++ sc->sc_ah->led_pin = pdata->led_pin;
++ }
+
+ common = ath9k_hw_common(ah);
+ common->ops = &ath9k_common_ops;
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -794,7 +794,7 @@ struct ath_hw {
+ u32 originalGain[22];
+ int initPDADC;
+ int PDADCdelta;
+- u8 led_pin;
++ int led_pin;
+ u32 gpio_mask;
+ u32 gpio_val;
+
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
++++ b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -139,10 +139,12 @@ void ath_init_leds(struct ath_softc *sc)
+ if (AR_SREV_9100(sc->sc_ah))
+ return;
+
+- if (AR_SREV_9287(sc->sc_ah))
+- sc->sc_ah->led_pin = ATH_LED_PIN_9287;
+- else
+- sc->sc_ah->led_pin = ATH_LED_PIN_DEF;
++ if (sc->sc_ah->led_pin < 0) {
++ if (AR_SREV_9287(sc->sc_ah))
++ sc->sc_ah->led_pin = ATH_LED_PIN_9287;
++ else
++ sc->sc_ah->led_pin = ATH_LED_PIN_DEF;
++ }
+
+ /* Configure gpio 1 for output */
+ ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -24,6 +24,10 @@
+ struct ath9k_platform_data {
+ u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
+ u8 *macaddr;
++
++ int led_pin;
++ u32 gpio_mask;
++ u32 gpio_val;
+ };
+
+ #endif /* _LINUX_ATH9K_PLATFORM_H */
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/gpio.c
-+++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -147,7 +147,9 @@ void ath_init_leds(struct ath_softc *sc)
- if (AR_SREV_9100(sc->sc_ah))
- return;
-
-- if (AR_SREV_9287(sc->sc_ah))
-+ if (sc->quirk_wndr3700)
-+ sc->sc_ah->led_pin = ATH_LED_PIN_WNDR3700;
-+ else if (AR_SREV_9287(sc->sc_ah))
- sc->sc_ah->led_pin = ATH_LED_PIN_9287;
- else
- sc->sc_ah->led_pin = ATH_LED_PIN_DEF;
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -455,6 +455,7 @@ void ath9k_btcoex_timer_pause(struct ath
-
- #define ATH_LED_PIN_DEF 1
- #define ATH_LED_PIN_9287 8
-+#define ATH_LED_PIN_WNDR3700 5
- #define ATH_LED_ON_DURATION_IDLE 350 /* in msecs */
- #define ATH_LED_OFF_DURATION_IDLE 250 /* in msecs */
-
#include "ath5k.h"
#include "reg.h"
-@@ -34,6 +36,18 @@
- static int ath5k_hw_eeprom_read(struct ath5k_hw *ah, u32 offset, u16 *data)
- {
- u32 status, timeout;
-+ struct ath5k_platform_data *pdata = NULL;
-+
-+ if (ah->ah_sc->pdev)
-+ pdata = ah->ah_sc->pdev->dev.platform_data;
-+
-+ if (pdata && pdata->eeprom_data && pdata->eeprom_data[0] == AR5K_EEPROM_MAGIC_VALUE)
-+ {
-+ ATH5K_INFO(ah->ah_sc, "using eeprom-content from platform_data\n");
-+ if (offset >= ATH5K_PLAT_EEP_MAX_WORDS) return -EIO;
-+ *data = pdata->eeprom_data[offset];
-+ return 0;
-+ }
-
- /*
- * Initialize EEPROM access
-@@ -1788,7 +1802,7 @@ ath5k_eeprom_init(struct ath5k_hw *ah)
+@@ -1726,7 +1728,7 @@ ath5k_eeprom_read_spur_chans(struct ath5
}
/*
*/
int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
{
-@@ -1796,6 +1810,16 @@ int ath5k_eeprom_read_mac(struct ath5k_h
+@@ -1734,6 +1736,16 @@ int ath5k_eeprom_read_mac(struct ath5k_h
u32 total, offset;
u16 data;
int octet, ret;
+ return 0;
+ }
- ret = ath5k_hw_eeprom_read(ah, 0x20, &data);
+ ret = ath5k_hw_nvram_read(ah, 0x20, &data);
if (ret)
+--- a/drivers/net/wireless/ath/ath5k/pci.c
++++ b/drivers/net/wireless/ath/ath5k/pci.c
+@@ -17,6 +17,7 @@
+ #include <linux/nl80211.h>
+ #include <linux/pci.h>
+ #include <linux/pci-aspm.h>
++#include <linux/ath5k_platform.h>
+ #include "../ath.h"
+ #include "ath5k.h"
+ #include "debug.h"
+@@ -73,6 +74,19 @@ bool ath5k_pci_eeprom_read(struct ath_co
+ {
+ struct ath5k_hw *ah = (struct ath5k_hw *) common->ah;
+ u32 status, timeout;
++ struct ath5k_platform_data *pdata = NULL;
++
++ if (ah->ah_sc->pdev)
++ pdata = ah->ah_sc->pdev->dev.platform_data;
++
++ if (pdata && pdata->eeprom_data && pdata->eeprom_data[0] == AR5K_EEPROM_MAGIC_VALUE)
++ {
++ if (offset >= ATH5K_PLAT_EEP_MAX_WORDS)
++ return -EIO;
++
++ *data = pdata->eeprom_data[offset];
++ return 0;
++ }
+
+ /*
+ * Initialize EEPROM access
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -861,6 +861,53 @@ static const struct file_operations fops
- .owner = THIS_MODULE
+@@ -871,6 +871,53 @@ static const struct file_operations fops
+ .llseek = default_llseek,
};
+static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
int ath9k_init_debug(struct ath_hw *ah)
{
struct ath_common *common = ath9k_hw_common(ah);
-@@ -920,6 +967,10 @@ int ath9k_init_debug(struct ath_hw *ah)
- sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca))
- goto err;
+@@ -933,6 +980,10 @@ int ath9k_init_debug(struct ath_hw *ah)
+ debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
+ sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
+ if (!debugfs_create_file("eeprom", S_IRUSR,
+ sc->debug.debugfs_phy, sc, &fops_eeprom))
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -177,8 +177,8 @@ void ath_descdma_cleanup(struct ath_soft
-
- /* returns delimiter padding required given the packet length */
- #define ATH_AGGR_GET_NDELIM(_len) \
-- (((((_len) + ATH_AGGR_DELIM_SZ) < ATH_AGGR_MINPLEN) ? \
-- (ATH_AGGR_MINPLEN - (_len) - ATH_AGGR_DELIM_SZ) : 0) >> 2)
-+ (((_len) >= ATH_AGGR_MINPLEN) ? 0 : \
-+ DIV_ROUND_UP(ATH_AGGR_MINPLEN - (_len), ATH_AGGR_DELIM_SZ))
-
- #define BAW_WITHIN(_start, _bawsz, _seqno) \
- ((((_seqno) - (_start)) & 4095) < (_bawsz))
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -438,26 +438,20 @@ void ath9k_btcoex_timer_pause(struct ath
+
+ #define ATH_LED_PIN_DEF 1
+ #define ATH_LED_PIN_9287 8
+-#define ATH_LED_ON_DURATION_IDLE 350 /* in msecs */
+-#define ATH_LED_OFF_DURATION_IDLE 250 /* in msecs */
+-
+-enum ath_led_type {
+- ATH_LED_RADIO,
+- ATH_LED_ASSOC,
+- ATH_LED_TX,
+- ATH_LED_RX
+-};
+-
+-struct ath_led {
+- struct ath_softc *sc;
+- struct led_classdev led_cdev;
+- enum ath_led_type led_type;
+- char name[32];
+- bool registered;
+-};
+
++#ifdef CONFIG_MAC80211_LEDS
+ void ath_init_leds(struct ath_softc *sc);
+ void ath_deinit_leds(struct ath_softc *sc);
++#else
++static inline void ath_init_leds(struct ath_softc *sc)
++{
++}
++
++static inline void ath_deinit_leds(struct ath_softc *sc)
++{
++}
++#endif
++
+
+ /* Antenna diversity/combining */
+ #define ATH_ANT_RX_CURRENT_SHIFT 4
+@@ -608,15 +602,11 @@ struct ath_softc {
+ struct ath_beacon beacon;
+ struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
+
+- struct ath_led radio_led;
+- struct ath_led assoc_led;
+- struct ath_led tx_led;
+- struct ath_led rx_led;
+- struct delayed_work ath_led_blink_work;
+- int led_on_duration;
+- int led_off_duration;
+- int led_on_cnt;
+- int led_off_cnt;
++#ifdef CONFIG_MAC80211_LEDS
++ bool led_registered;
++ char led_name[32];
++ struct led_classdev led_cdev;
++#endif
+
+ int beacon_interval;
+
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
++++ b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -20,120 +20,25 @@
+ /* LED functions */
+ /********************************/
+
+-static void ath_led_blink_work(struct work_struct *work)
+-{
+- struct ath_softc *sc = container_of(work, struct ath_softc,
+- ath_led_blink_work.work);
+-
+- if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED))
+- return;
+-
+- if ((sc->led_on_duration == ATH_LED_ON_DURATION_IDLE) ||
+- (sc->led_off_duration == ATH_LED_OFF_DURATION_IDLE))
+- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
+- else
+- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin,
+- (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0);
+-
+- ieee80211_queue_delayed_work(sc->hw,
+- &sc->ath_led_blink_work,
+- (sc->sc_flags & SC_OP_LED_ON) ?
+- msecs_to_jiffies(sc->led_off_duration) :
+- msecs_to_jiffies(sc->led_on_duration));
+-
+- sc->led_on_duration = sc->led_on_cnt ?
+- max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25) :
+- ATH_LED_ON_DURATION_IDLE;
+- sc->led_off_duration = sc->led_off_cnt ?
+- max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10) :
+- ATH_LED_OFF_DURATION_IDLE;
+- sc->led_on_cnt = sc->led_off_cnt = 0;
+- if (sc->sc_flags & SC_OP_LED_ON)
+- sc->sc_flags &= ~SC_OP_LED_ON;
+- else
+- sc->sc_flags |= SC_OP_LED_ON;
+-}
+-
++#ifdef CONFIG_MAC80211_LEDS
+ static void ath_led_brightness(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+ {
+- struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev);
+- struct ath_softc *sc = led->sc;
+-
+- switch (brightness) {
+- case LED_OFF:
+- if (led->led_type == ATH_LED_ASSOC ||
+- led->led_type == ATH_LED_RADIO) {
+- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin,
+- (led->led_type == ATH_LED_RADIO));
+- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
+- if (led->led_type == ATH_LED_RADIO)
+- sc->sc_flags &= ~SC_OP_LED_ON;
+- } else {
+- sc->led_off_cnt++;
+- }
+- break;
+- case LED_FULL:
+- if (led->led_type == ATH_LED_ASSOC) {
+- sc->sc_flags |= SC_OP_LED_ASSOCIATED;
+- if (led_blink)
+- ieee80211_queue_delayed_work(sc->hw,
+- &sc->ath_led_blink_work, 0);
+- } else if (led->led_type == ATH_LED_RADIO) {
+- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
+- sc->sc_flags |= SC_OP_LED_ON;
+- } else {
+- sc->led_on_cnt++;
+- }
+- break;
+- default:
+- break;
+- }
+-}
+-
+-static int ath_register_led(struct ath_softc *sc, struct ath_led *led,
+- char *trigger)
+-{
+- int ret;
+-
+- led->sc = sc;
+- led->led_cdev.name = led->name;
+- led->led_cdev.default_trigger = trigger;
+- led->led_cdev.brightness_set = ath_led_brightness;
+-
+- ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->led_cdev);
+- if (ret)
+- ath_err(ath9k_hw_common(sc->sc_ah),
+- "Failed to register led:%s", led->name);
+- else
+- led->registered = 1;
+- return ret;
+-}
+-
+-static void ath_unregister_led(struct ath_led *led)
+-{
+- if (led->registered) {
+- led_classdev_unregister(&led->led_cdev);
+- led->registered = 0;
+- }
++ struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev);
++ ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF));
+ }
+
+ void ath_deinit_leds(struct ath_softc *sc)
+ {
+- if (AR_SREV_9100(sc->sc_ah))
++ if (!sc->led_registered)
+ return;
+
+- ath_unregister_led(&sc->assoc_led);
+- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
+- ath_unregister_led(&sc->tx_led);
+- ath_unregister_led(&sc->rx_led);
+- ath_unregister_led(&sc->radio_led);
+- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
++ ath_led_brightness(&sc->led_cdev, LED_OFF);
++ led_classdev_unregister(&sc->led_cdev);
+ }
+
+ void ath_init_leds(struct ath_softc *sc)
+ {
+- char *trigger;
+ int ret;
+
+ if (AR_SREV_9100(sc->sc_ah))
+@@ -152,48 +57,22 @@ void ath_init_leds(struct ath_softc *sc)
+ /* LED off, active low */
+ ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
+
+- if (led_blink)
+- INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work);
++ if (!led_blink)
++ sc->led_cdev.default_trigger =
++ ieee80211_get_radio_led_name(sc->hw);
++
++ snprintf(sc->led_name, sizeof(sc->led_name),
++ "ath9k-%s", wiphy_name(sc->hw->wiphy));
++ sc->led_cdev.name = sc->led_name;
++ sc->led_cdev.brightness_set = ath_led_brightness;
++
++ ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev);
++ if (ret < 0)
++ return;
+
+- trigger = ieee80211_get_radio_led_name(sc->hw);
+- snprintf(sc->radio_led.name, sizeof(sc->radio_led.name),
+- "ath9k-%s::radio", wiphy_name(sc->hw->wiphy));
+- ret = ath_register_led(sc, &sc->radio_led, trigger);
+- sc->radio_led.led_type = ATH_LED_RADIO;
+- if (ret)
+- goto fail;
+-
+- trigger = ieee80211_get_assoc_led_name(sc->hw);
+- snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name),
+- "ath9k-%s::assoc", wiphy_name(sc->hw->wiphy));
+- ret = ath_register_led(sc, &sc->assoc_led, trigger);
+- sc->assoc_led.led_type = ATH_LED_ASSOC;
+- if (ret)
+- goto fail;
+-
+- trigger = ieee80211_get_tx_led_name(sc->hw);
+- snprintf(sc->tx_led.name, sizeof(sc->tx_led.name),
+- "ath9k-%s::tx", wiphy_name(sc->hw->wiphy));
+- ret = ath_register_led(sc, &sc->tx_led, trigger);
+- sc->tx_led.led_type = ATH_LED_TX;
+- if (ret)
+- goto fail;
+-
+- trigger = ieee80211_get_rx_led_name(sc->hw);
+- snprintf(sc->rx_led.name, sizeof(sc->rx_led.name),
+- "ath9k-%s::rx", wiphy_name(sc->hw->wiphy));
+- ret = ath_register_led(sc, &sc->rx_led, trigger);
+- sc->rx_led.led_type = ATH_LED_RX;
+- if (ret)
+- goto fail;
+-
+- return;
+-
+-fail:
+- if (led_blink)
+- cancel_delayed_work_sync(&sc->ath_led_blink_work);
+- ath_deinit_leds(sc);
++ sc->led_registered = true;
+ }
++#endif
+
+ /*******************/
+ /* Rfkill */
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1275,9 +1275,6 @@ static void ath9k_stop(struct ieee80211_
+
+ aphy->state = ATH_WIPHY_INACTIVE;
+
+- if (led_blink)
+- cancel_delayed_work_sync(&sc->ath_led_blink_work);
+-
+ cancel_delayed_work_sync(&sc->tx_complete_work);
+ cancel_work_sync(&sc->paprd_work);
+ cancel_work_sync(&sc->hw_check_work);
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -139,6 +139,21 @@ static struct ieee80211_rate ath9k_legac
+ RATE(540, 0x0c, 0),
+ };
+
++#ifdef CONFIG_MAC80211_LEDS
++static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = {
++ { .throughput = 0 * 1024, .blink_time = 334 },
++ { .throughput = 1 * 1024, .blink_time = 260 },
++ { .throughput = 5 * 1024, .blink_time = 220 },
++ { .throughput = 10 * 1024, .blink_time = 190 },
++ { .throughput = 20 * 1024, .blink_time = 170 },
++ { .throughput = 50 * 1024, .blink_time = 150 },
++ { .throughput = 70 * 1024, .blink_time = 130 },
++ { .throughput = 100 * 1024, .blink_time = 110 },
++ { .throughput = 200 * 1024, .blink_time = 80 },
++ { .throughput = 300 * 1024, .blink_time = 50 },
++};
++#endif
++
+ static void ath9k_deinit_softc(struct ath_softc *sc);
+
+ /*
+@@ -742,6 +757,12 @@ int ath9k_init_device(u16 devid, struct
+
+ ath9k_init_txpower_limits(sc);
+
++#ifdef CONFIG_MAC80211_LEDS
++ /* must be initialized before ieee80211_register_hw */
++ sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw,
++ ath9k_tpt_blink, ARRAY_SIZE(ath9k_tpt_blink));
++#endif
++
+ /* Register with mac80211 */
+ error = ieee80211_register_hw(hw);
+ if (error)
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-@@ -2133,6 +2133,7 @@ static void ath9k_hw_ar9300_set_txpower(
- u8 twiceMaxRegulatoryPower,
- u8 powerLimit)
- {
-+ struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
- struct ath_common *common = ath9k_hw_common(ah);
- u8 targetPowerValT2[ar9300RateSize];
- unsigned int i = 0;
-@@ -2180,6 +2181,7 @@ static void ath9k_hw_ar9300_set_txpower(
- i = ALL_TARGET_HT20_0_8_16; /* ht20 */
-
- ah->txpower_limit = targetPowerValT2[i];
-+ regulatory->max_power_level = ratesArray[i];
-
- ar9003_hw_calibration_apply(ah, chan->channel);
- }
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -417,7 +417,7 @@ static void ath9k_hw_init_defaults(struc
+ AR_STA_ID1_MCAST_KSRCH;
+ ah->beacon_interval = 100;
+ ah->enable_32kHz_clock = DONT_USE_32KHZ;
+- ah->slottime = (u32) -1;
++ ah->slottime = 9;
+ ah->globaltxtimeout = (u32) -1;
+ ah->power_mode = ATH9K_PM_UNDEFINED;
+ }
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -813,7 +813,7 @@ void ath9k_hw_init_global_settings(struc
+ if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ)
+ acktimeout += 64 - sifstime - ah->slottime;
+
+- ath9k_hw_setslottime(ah, slottime);
++ ath9k_hw_setslottime(ah, ah->slottime);
+ ath9k_hw_set_ack_timeout(ah, acktimeout);
+ ath9k_hw_set_cts_timeout(ah, acktimeout);
+ if (ah->globaltxtimeout != (u32) -1)
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/eeprom.h
-+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
-@@ -680,7 +680,8 @@ struct eeprom_ops {
- void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
- void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
- u16 cfgCtl, u8 twiceAntennaReduction,
-- u8 twiceMaxRegulatoryPower, u8 powerLimit);
-+ u8 twiceMaxRegulatoryPower, u8 powerLimit,
-+ bool test);
- u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
- };
-
---- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-@@ -726,7 +726,7 @@ static void ath9k_hw_4k_set_txpower(stru
- u16 cfgCtl,
- u8 twiceAntennaReduction,
- u8 twiceMaxRegulatoryPower,
-- u8 powerLimit)
-+ u8 powerLimit, bool test)
- {
- struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
- struct ar5416_eeprom_4k *pEepData = &ah->eeprom.map4k;
-@@ -751,15 +751,20 @@ static void ath9k_hw_4k_set_txpower(stru
-
- ath9k_hw_set_4k_power_cal_table(ah, chan, &txPowerIndexOffset);
-
-+ regulatory->max_power_level = 0;
- for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
- ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
- if (ratesArray[i] > AR5416_MAX_RATE_POWER)
- ratesArray[i] = AR5416_MAX_RATE_POWER;
-+
-+ if (ratesArray[i] > regulatory->max_power_level)
-+ regulatory->max_power_level = ratesArray[i];
- }
-
-+ if (test)
-+ return;
-
- /* Update regulatory */
--
- i = rate6mb;
- if (IS_CHAN_HT40(chan))
- i = rateHt40_0;
---- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-@@ -853,7 +853,7 @@ static void ath9k_hw_ar9287_set_txpower(
- struct ath9k_channel *chan, u16 cfgCtl,
- u8 twiceAntennaReduction,
- u8 twiceMaxRegulatoryPower,
-- u8 powerLimit)
-+ u8 powerLimit, bool test)
- {
- struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
- struct ar9287_eeprom *pEepData = &ah->eeprom.map9287;
-@@ -877,12 +877,26 @@ static void ath9k_hw_ar9287_set_txpower(
-
- ath9k_hw_set_ar9287_power_cal_table(ah, chan, &txPowerIndexOffset);
-
-+ regulatory->max_power_level = 0;
- for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
- ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
- if (ratesArray[i] > AR9287_MAX_RATE_POWER)
- ratesArray[i] = AR9287_MAX_RATE_POWER;
-+
-+ if (ratesArray[i] > regulatory->max_power_level)
-+ regulatory->max_power_level = ratesArray[i];
- }
-
-+ if (test)
-+ return;
-+
-+ if (IS_CHAN_2GHZ(chan))
-+ i = rate1l;
-+ else
-+ i = rate6mb;
-+
-+ regulatory->max_power_level = ratesArray[i];
-+
- if (AR_SREV_9280_20_OR_LATER(ah)) {
- for (i = 0; i < Ar5416RateSize; i++)
- ratesArray[i] -= AR9287_PWR_TABLE_OFFSET_DB * 2;
-@@ -971,17 +985,6 @@ static void ath9k_hw_ar9287_set_txpower(
- | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8)
- | ATH9K_POW_SM(ratesArray[rateDupCck], 0));
- }
--
-- if (IS_CHAN_2GHZ(chan))
-- i = rate1l;
-- else
-- i = rate6mb;
--
-- if (AR_SREV_9280_20_OR_LATER(ah))
-- regulatory->max_power_level =
-- ratesArray[i] + AR9287_PWR_TABLE_OFFSET_DB * 2;
-- else
-- regulatory->max_power_level = ratesArray[i];
- }
-
- static void ath9k_hw_ar9287_set_addac(struct ath_hw *ah,
---- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
-@@ -1258,7 +1258,7 @@ static void ath9k_hw_def_set_txpower(str
- u16 cfgCtl,
- u8 twiceAntennaReduction,
- u8 twiceMaxRegulatoryPower,
-- u8 powerLimit)
-+ u8 powerLimit, bool test)
- {
- #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta)
- struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
-@@ -1285,12 +1285,44 @@ static void ath9k_hw_def_set_txpower(str
-
- ath9k_hw_set_def_power_cal_table(ah, chan, &txPowerIndexOffset);
-
-+ regulatory->max_power_level = 0;
- for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
- ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
- if (ratesArray[i] > AR5416_MAX_RATE_POWER)
- ratesArray[i] = AR5416_MAX_RATE_POWER;
-+ if (ratesArray[i] > regulatory->max_power_level)
-+ regulatory->max_power_level = ratesArray[i];
- }
-
-+ if (!test) {
-+ i = rate6mb;
-+
-+ if (IS_CHAN_HT40(chan))
-+ i = rateHt40_0;
-+ else if (IS_CHAN_HT20(chan))
-+ i = rateHt20_0;
-+
-+ regulatory->max_power_level = ratesArray[i];
-+ }
-+
-+ switch(ar5416_get_ntxchains(ah->txchainmask)) {
-+ case 1:
-+ break;
-+ case 2:
-+ regulatory->max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
-+ break;
-+ case 3:
-+ regulatory->max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
-+ break;
-+ default:
-+ ath_print(ath9k_hw_common(ah), ATH_DBG_EEPROM,
-+ "Invalid chainmask configuration\n");
-+ break;
-+ }
-+
-+ if (test)
-+ return;
-+
- if (AR_SREV_9280_20_OR_LATER(ah)) {
- for (i = 0; i < Ar5416RateSize; i++) {
- int8_t pwr_table_offset;
-@@ -1387,34 +1419,6 @@ static void ath9k_hw_def_set_txpower(str
- REG_WRITE(ah, AR_PHY_POWER_TX_SUB,
- ATH9K_POW_SM(pModal->pwrDecreaseFor3Chain, 6)
- | ATH9K_POW_SM(pModal->pwrDecreaseFor2Chain, 0));
--
-- i = rate6mb;
--
-- if (IS_CHAN_HT40(chan))
-- i = rateHt40_0;
-- else if (IS_CHAN_HT20(chan))
-- i = rateHt20_0;
--
-- if (AR_SREV_9280_20_OR_LATER(ah))
-- regulatory->max_power_level =
-- ratesArray[i] + AR5416_PWR_TABLE_OFFSET_DB * 2;
-- else
-- regulatory->max_power_level = ratesArray[i];
--
-- switch(ar5416_get_ntxchains(ah->txchainmask)) {
-- case 1:
-- break;
-- case 2:
-- regulatory->max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
-- break;
-- case 3:
-- regulatory->max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
-- break;
-- default:
-- ath_print(ath9k_hw_common(ah), ATH_DBG_EEPROM,
-- "Invalid chainmask configuration\n");
-- break;
-- }
- }
-
- static u8 ath9k_hw_def_get_num_ant_config(struct ath_hw *ah,
---- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-@@ -2131,7 +2131,7 @@ static void ath9k_hw_ar9300_set_txpower(
- struct ath9k_channel *chan, u16 cfgCtl,
- u8 twiceAntennaReduction,
- u8 twiceMaxRegulatoryPower,
-- u8 powerLimit)
-+ u8 powerLimit, bool test)
- {
- struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
- struct ath_common *common = ath9k_hw_common(ah);
-@@ -2145,7 +2145,16 @@ static void ath9k_hw_ar9300_set_txpower(
- twiceMaxRegulatoryPower,
- powerLimit);
-
-- while (i < ar9300RateSize) {
-+ regulatory->max_power_level = 0;
-+ for (i = 0; i < ar9300RateSize; i++) {
-+ if (targetPowerValT2[i] > regulatory->max_power_level)
-+ regulatory->max_power_level = targetPowerValT2[i];
-+ }
-+
-+ if (test)
-+ return;
-+
-+ for (i = 0; i < ar9300RateSize; i++) {
- ath_print(common, ATH_DBG_EEPROM,
- "TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
- i++;
-@@ -2160,9 +2169,6 @@ static void ath9k_hw_ar9300_set_txpower(
- i++;
- }
-
-- /* Write target power array to registers */
-- ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
--
- /*
- * This is the TX power we send back to driver core,
- * and it can use to pass to userspace to display our
-@@ -2181,8 +2187,10 @@ static void ath9k_hw_ar9300_set_txpower(
- i = ALL_TARGET_HT20_0_8_16; /* ht20 */
-
- ah->txpower_limit = targetPowerValT2[i];
-- regulatory->max_power_level = ratesArray[i];
-+ regulatory->max_power_level = targetPowerValT2[i];
-
-+ /* Write target power array to registers */
-+ ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
- ar9003_hw_calibration_apply(ah, chan->channel);
- }
-
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1178,7 +1178,7 @@ static bool ath9k_hw_channel_change(stru
- channel->max_antenna_gain * 2,
- channel->max_power * 2,
- min((u32) MAX_RATE_POWER,
-- (u32) regulatory->power_limit));
-+ (u32) regulatory->power_limit), false);
-
- ath9k_hw_rfbus_done(ah);
-
-@@ -2177,7 +2177,7 @@ bool ath9k_hw_disable(struct ath_hw *ah)
- }
- EXPORT_SYMBOL(ath9k_hw_disable);
-
--void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
-+void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
- {
- struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
- struct ath9k_channel *chan = ah->curchan;
-@@ -2190,7 +2190,7 @@ void ath9k_hw_set_txpowerlimit(struct at
- channel->max_antenna_gain * 2,
- channel->max_power * 2,
- min((u32) MAX_RATE_POWER,
-- (u32) regulatory->power_limit));
-+ (u32) regulatory->power_limit), test);
- }
- EXPORT_SYMBOL(ath9k_hw_set_txpowerlimit);
-
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -860,7 +860,7 @@ u32 ath9k_hw_getrxfilter(struct ath_hw *
- void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
- bool ath9k_hw_phy_disable(struct ath_hw *ah);
- bool ath9k_hw_disable(struct ath_hw *ah);
--void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit);
-+void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test);
- void ath9k_hw_setopmode(struct ath_hw *ah);
- void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1);
- void ath9k_hw_setbssidmask(struct ath_hw *ah);
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -24,7 +24,7 @@ static void ath_update_txpow(struct ath_
- struct ath_hw *ah = sc->sc_ah;
-
- if (sc->curtxpow != sc->config.txpowlimit) {
-- ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit);
-+ ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit, false);
- /* read back in case value is clamped */
- sc->curtxpow = ath9k_hw_regulatory(ah)->power_limit;
- }
---- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
-@@ -614,7 +614,7 @@ static int ar9003_hw_process_ini(struct
- channel->max_antenna_gain * 2,
- channel->max_power * 2,
- min((u32) MAX_RATE_POWER,
-- (u32) regulatory->power_limit));
-+ (u32) regulatory->power_limit), false);
-
- return 0;
- }
---- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
-+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
-@@ -875,7 +875,7 @@ static int ar5008_hw_process_ini(struct
- channel->max_antenna_gain * 2,
- channel->max_power * 2,
- min((u32) MAX_RATE_POWER,
-- (u32) regulatory->power_limit));
-+ (u32) regulatory->power_limit), false);
-
- /* Write analog registers */
- if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
---- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
-+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
-@@ -29,7 +29,7 @@ static void ath_update_txpow(struct ath9
- struct ath_hw *ah = priv->ah;
-
- if (priv->curtxpow != priv->txpowlimit) {
-- ath9k_hw_set_txpowerlimit(ah, priv->txpowlimit);
-+ ath9k_hw_set_txpowerlimit(ah, priv->txpowlimit, false);
- /* read back in case value is clamped */
- priv->curtxpow = ath9k_hw_regulatory(ah)->power_limit;
- }
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -650,6 +650,37 @@ err_hw:
- return ret;
- }
-
-+static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
-+{
-+ struct ieee80211_supported_band *sband;
-+ struct ieee80211_channel *chan;
-+ struct ath_hw *ah = sc->sc_ah;
-+ struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
-+ int i;
-+
-+ sband = &sc->sbands[band];
-+ for (i = 0; i < sband->n_channels; i++) {
-+ chan = &sband->channels[i];
-+ ah->curchan = &ah->channels[chan->hw_value];
-+ ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20);
-+ ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true);
-+ chan->max_power = reg->max_power_level / 2;
-+ }
-+}
-+
-+static void ath9k_init_txpower_limits(struct ath_softc *sc)
-+{
-+ struct ath_hw *ah = sc->sc_ah;
-+ struct ath9k_channel *curchan = ah->curchan;
-+
-+ if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
-+ ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ);
-+ if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
-+ ath9k_init_band_txpower(sc, IEEE80211_BAND_5GHZ);
-+
-+ ah->curchan = curchan;
-+}
-+
- void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
- {
- struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-@@ -765,6 +796,8 @@ int ath9k_init_device(u16 devid, struct
- if (error != 0)
- goto error_rx;
-
-+ ath9k_init_txpower_limits(sc);
-+
- /* Register with mac80211 */
- error = ieee80211_register_hw(hw);
- if (error)
---- a/drivers/net/wireless/ath/ath9k/common.c
-+++ b/drivers/net/wireless/ath/ath9k/common.c
-@@ -107,12 +107,10 @@ static u32 ath9k_get_extchanmode(struct
- /*
- * Update internal channel flags.
- */
--void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
-- struct ath9k_channel *ichan)
-+void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
-+ struct ieee80211_channel *chan,
-+ enum nl80211_channel_type channel_type)
- {
-- struct ieee80211_channel *chan = hw->conf.channel;
-- struct ieee80211_conf *conf = &hw->conf;
--
- ichan->channel = chan->center_freq;
- ichan->chan = chan;
-
-@@ -124,9 +122,8 @@ void ath9k_cmn_update_ichannel(struct ie
- ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
- }
-
-- if (conf_is_ht(conf))
-- ichan->chanmode = ath9k_get_extchanmode(chan,
-- conf->channel_type);
-+ if (channel_type != NL80211_CHAN_NO_HT)
-+ ichan->chanmode = ath9k_get_extchanmode(chan, channel_type);
- }
- EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
-
-@@ -142,7 +139,7 @@ struct ath9k_channel *ath9k_cmn_get_curc
-
- chan_idx = curchan->hw_value;
- channel = &ah->channels[chan_idx];
-- ath9k_cmn_update_ichannel(hw, channel);
-+ ath9k_cmn_update_ichannel(channel, curchan, hw->conf.channel_type);
-
- return channel;
- }
---- a/drivers/net/wireless/ath/ath9k/common.h
-+++ b/drivers/net/wireless/ath/ath9k/common.h
-@@ -62,8 +62,9 @@ enum ath_stomp_type {
-
- int ath9k_cmn_padpos(__le16 frame_control);
- int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
--void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
-- struct ath9k_channel *ichan);
-+void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
-+ struct ieee80211_channel *chan,
-+ enum nl80211_channel_type channel_type);
- struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
- struct ath_hw *ah);
- int ath9k_cmn_count_streams(unsigned int chainmask, int max);
---- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
-+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
-@@ -1405,7 +1405,9 @@ static int ath9k_htc_config(struct ieee8
- ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
- curchan->center_freq);
-
-- ath9k_cmn_update_ichannel(hw, &priv->ah->channels[pos]);
-+ ath9k_cmn_update_ichannel(&priv->ah->channels[pos],
-+ hw->conf.channel,
-+ hw->conf.channel_type);
-
- if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
- ath_print(common, ATH_DBG_FATAL,
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -309,7 +309,6 @@ struct ath_rx {
- u8 rxotherant;
- u32 *rxlink;
- unsigned int rxfilter;
-- spinlock_t rxflushlock;
- spinlock_t rxbuflock;
- struct list_head rxbuf;
- struct ath_descdma rxdma;
-@@ -600,9 +599,9 @@ struct ath_softc {
- struct ath_hw *sc_ah;
- void __iomem *mem;
- int irq;
-- spinlock_t sc_resetlock;
- spinlock_t sc_serial_rw;
- spinlock_t sc_pm_lock;
-+ spinlock_t sc_pcu_lock;
- struct mutex mutex;
- struct work_struct paprd_work;
- struct work_struct hw_check_work;
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -228,6 +228,8 @@ int ath_set_channel(struct ath_softc *sc
-
- ath9k_ps_wakeup(sc);
-
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+
- /*
- * This is only performed if the channel settings have
- * actually changed.
-@@ -239,6 +241,7 @@ int ath_set_channel(struct ath_softc *sc
- */
- ath9k_hw_disable_interrupts(ah);
- ath_drain_all_txq(sc, false);
-+
- stopped = ath_stoprecv(sc);
-
- /* XXX: do not flush receive queue here. We don't want
-@@ -257,18 +260,14 @@ int ath_set_channel(struct ath_softc *sc
- channel->center_freq, conf_is_ht40(conf),
- fastcc);
-
-- spin_lock_bh(&sc->sc_resetlock);
--
- r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
- if (r) {
- ath_print(common, ATH_DBG_FATAL,
- "Unable to reset channel (%u MHz), "
- "reset status %d\n",
- channel->center_freq, r);
-- spin_unlock_bh(&sc->sc_resetlock);
- goto ps_restore;
- }
-- spin_unlock_bh(&sc->sc_resetlock);
-
- if (ath_startrecv(sc) != 0) {
- ath_print(common, ATH_DBG_FATAL,
-@@ -287,6 +286,8 @@ int ath_set_channel(struct ath_softc *sc
- }
-
- ps_restore:
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-+
- ath9k_ps_restore(sc);
- return r;
- }
-@@ -600,6 +601,8 @@ void ath9k_tasklet(unsigned long data)
- return;
- }
-
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+
- if (!ath9k_hw_check_alive(ah))
- ieee80211_queue_work(sc->hw, &sc->hw_check_work);
-
-@@ -610,15 +613,12 @@ void ath9k_tasklet(unsigned long data)
- rxmask = (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
-
- if (status & rxmask) {
-- spin_lock_bh(&sc->rx.rxflushlock);
--
- /* Check for high priority Rx first */
- if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
- (status & ATH9K_INT_RXHP))
- ath_rx_tasklet(sc, 0, true);
-
- ath_rx_tasklet(sc, 0, false);
-- spin_unlock_bh(&sc->rx.rxflushlock);
- }
-
- if (status & ATH9K_INT_TX) {
-@@ -644,6 +644,8 @@ void ath9k_tasklet(unsigned long data)
-
- /* re-enable hardware interrupt */
- ath9k_hw_enable_interrupts(ah);
-+
-+ spin_unlock_bh(&sc->sc_pcu_lock);
- ath9k_ps_restore(sc);
- }
-
-@@ -871,12 +873,13 @@ void ath_radio_enable(struct ath_softc *
- int r;
-
- ath9k_ps_wakeup(sc);
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+
- ath9k_hw_configpcipowersave(ah, 0, 0);
-
- if (!ah->curchan)
- ah->curchan = ath_get_curchannel(sc, sc->hw);
-
-- spin_lock_bh(&sc->sc_resetlock);
- r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
- if (r) {
- ath_print(common, ATH_DBG_FATAL,
-@@ -884,15 +887,14 @@ void ath_radio_enable(struct ath_softc *
- "reset status %d\n",
- channel->center_freq, r);
- }
-- spin_unlock_bh(&sc->sc_resetlock);
-
- ath_update_txpow(sc);
- if (ath_startrecv(sc) != 0) {
- ath_print(common, ATH_DBG_FATAL,
- "Unable to restart recv logic\n");
-+ spin_unlock_bh(&sc->sc_pcu_lock);
- return;
- }
--
- if (sc->sc_flags & SC_OP_BEACONS)
- ath_beacon_config(sc, NULL); /* restart beacons */
-
-@@ -905,6 +907,8 @@ void ath_radio_enable(struct ath_softc *
- ath9k_hw_set_gpio(ah, ah->led_pin, 0);
-
- ieee80211_wake_queues(hw);
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-+
- ath9k_ps_restore(sc);
- }
-
-@@ -915,6 +919,8 @@ void ath_radio_disable(struct ath_softc
- int r;
-
- ath9k_ps_wakeup(sc);
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+
- ieee80211_stop_queues(hw);
-
- /*
-@@ -930,13 +936,13 @@ void ath_radio_disable(struct ath_softc
- ath9k_hw_disable_interrupts(ah);
-
- ath_drain_all_txq(sc, false); /* clear pending tx frames */
-+
- ath_stoprecv(sc); /* turn off frame recv */
- ath_flushrecv(sc); /* flush recv queue */
-
- if (!ah->curchan)
- ah->curchan = ath_get_curchannel(sc, hw);
-
-- spin_lock_bh(&sc->sc_resetlock);
- r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
- if (r) {
- ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
-@@ -944,11 +950,14 @@ void ath_radio_disable(struct ath_softc
- "reset status %d\n",
- channel->center_freq, r);
- }
-- spin_unlock_bh(&sc->sc_resetlock);
-
- ath9k_hw_phy_disable(ah);
-+
- ath9k_hw_configpcipowersave(ah, 1, 1);
-+
-+ spin_unlock_bh(&sc->sc_pcu_lock);
- ath9k_ps_restore(sc);
-+
- ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP);
- }
-
-@@ -962,19 +971,20 @@ int ath_reset(struct ath_softc *sc, bool
- /* Stop ANI */
- del_timer_sync(&common->ani.timer);
-
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+
- ieee80211_stop_queues(hw);
-
- ath9k_hw_disable_interrupts(ah);
- ath_drain_all_txq(sc, retry_tx);
-+
- ath_stoprecv(sc);
- ath_flushrecv(sc);
-
-- spin_lock_bh(&sc->sc_resetlock);
- r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
- if (r)
- ath_print(common, ATH_DBG_FATAL,
- "Unable to reset hardware; reset status %d\n", r);
-- spin_unlock_bh(&sc->sc_resetlock);
-
- if (ath_startrecv(sc) != 0)
- ath_print(common, ATH_DBG_FATAL,
-@@ -1004,6 +1014,7 @@ int ath_reset(struct ath_softc *sc, bool
- }
-
- ieee80211_wake_queues(hw);
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-
- /* Start ANI */
- ath_start_ani(common);
-@@ -1142,17 +1153,16 @@ static int ath9k_start(struct ieee80211_
- * be followed by initialization of the appropriate bits
- * and then setup of the interrupt mask.
- */
-- spin_lock_bh(&sc->sc_resetlock);
-+ spin_lock_bh(&sc->sc_pcu_lock);
- r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
- if (r) {
- ath_print(common, ATH_DBG_FATAL,
- "Unable to reset hardware; reset status %d "
- "(freq %u MHz)\n", r,
- curchan->center_freq);
-- spin_unlock_bh(&sc->sc_resetlock);
-+ spin_unlock_bh(&sc->sc_pcu_lock);
- goto mutex_unlock;
- }
-- spin_unlock_bh(&sc->sc_resetlock);
-
- /*
- * This is needed only to setup initial state
-@@ -1171,8 +1181,10 @@ static int ath9k_start(struct ieee80211_
- ath_print(common, ATH_DBG_FATAL,
- "Unable to start recv logic\n");
- r = -EIO;
-+ spin_unlock_bh(&sc->sc_pcu_lock);
- goto mutex_unlock;
- }
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-
- /* Setup our intr mask. */
- ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL |
-@@ -1367,6 +1379,8 @@ static void ath9k_stop(struct ieee80211_
- ath9k_btcoex_timer_pause(sc);
- }
-
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+
- /* make sure h/w will not generate any interrupt
- * before setting the invalid flag. */
- ath9k_hw_disable_interrupts(ah);
-@@ -1381,6 +1395,9 @@ static void ath9k_stop(struct ieee80211_
- /* disable HAL and put h/w to sleep */
- ath9k_hw_disable(ah);
- ath9k_hw_configpcipowersave(ah, 1, 1);
-+
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-+
- ath9k_ps_restore(sc);
-
- /* Finally, put the chip in FULL SLEEP mode */
---- a/drivers/net/wireless/ath/ath9k/recv.c
-+++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -297,19 +297,17 @@ static void ath_edma_start_recv(struct a
- ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_LP,
- sc->rx.rx_edma[ATH9K_RX_QUEUE_LP].rx_fifo_hwsize);
-
-- spin_unlock_bh(&sc->rx.rxbuflock);
--
- ath_opmode_init(sc);
-
- ath9k_hw_startpcureceive(sc->sc_ah, (sc->sc_flags & SC_OP_OFFCHANNEL));
-+
-+ spin_unlock_bh(&sc->rx.rxbuflock);
- }
-
- static void ath_edma_stop_recv(struct ath_softc *sc)
- {
-- spin_lock_bh(&sc->rx.rxbuflock);
- ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_HP);
- ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_LP);
-- spin_unlock_bh(&sc->rx.rxbuflock);
- }
-
- int ath_rx_init(struct ath_softc *sc, int nbufs)
-@@ -319,7 +317,7 @@ int ath_rx_init(struct ath_softc *sc, in
- struct ath_buf *bf;
- int error = 0;
-
-- spin_lock_init(&sc->rx.rxflushlock);
-+ spin_lock_init(&sc->sc_pcu_lock);
- sc->sc_flags &= ~SC_OP_RXFLUSH;
- spin_lock_init(&sc->rx.rxbuflock);
-
-@@ -506,9 +504,9 @@ int ath_startrecv(struct ath_softc *sc)
- ath9k_hw_rxena(ah);
-
- start_recv:
-- spin_unlock_bh(&sc->rx.rxbuflock);
- ath_opmode_init(sc);
- ath9k_hw_startpcureceive(ah, (sc->sc_flags & SC_OP_OFFCHANNEL));
-+ spin_unlock_bh(&sc->rx.rxbuflock);
-
- return 0;
- }
-@@ -518,6 +516,7 @@ bool ath_stoprecv(struct ath_softc *sc)
- struct ath_hw *ah = sc->sc_ah;
- bool stopped;
-
-+ spin_lock_bh(&sc->rx.rxbuflock);
- ath9k_hw_stoppcurecv(ah);
- ath9k_hw_setrxfilter(ah, 0);
- stopped = ath9k_hw_stopdmarecv(ah);
-@@ -526,19 +525,18 @@ bool ath_stoprecv(struct ath_softc *sc)
- ath_edma_stop_recv(sc);
- else
- sc->rx.rxlink = NULL;
-+ spin_unlock_bh(&sc->rx.rxbuflock);
-
- return stopped;
- }
-
- void ath_flushrecv(struct ath_softc *sc)
- {
-- spin_lock_bh(&sc->rx.rxflushlock);
- sc->sc_flags |= SC_OP_RXFLUSH;
- if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
- ath_rx_tasklet(sc, 1, true);
- ath_rx_tasklet(sc, 1, false);
- sc->sc_flags &= ~SC_OP_RXFLUSH;
-- spin_unlock_bh(&sc->rx.rxflushlock);
- }
-
- static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -588,7 +588,6 @@ static int ath9k_init_softc(u16 devid, s
- spin_lock_init(&common->cc_lock);
-
- spin_lock_init(&sc->wiphy_lock);
-- spin_lock_init(&sc->sc_resetlock);
- spin_lock_init(&sc->sc_serial_rw);
- spin_lock_init(&sc->sc_pm_lock);
- mutex_init(&sc->mutex);
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -1142,13 +1142,11 @@ void ath_drain_all_txq(struct ath_softc
- ath_print(common, ATH_DBG_FATAL,
- "Failed to stop TX DMA. Resetting hardware!\n");
-
-- spin_lock_bh(&sc->sc_resetlock);
- r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
- if (r)
- ath_print(common, ATH_DBG_FATAL,
- "Unable to reset hardware; reset status %d\n",
- r);
-- spin_unlock_bh(&sc->sc_resetlock);
- }
-
- for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -183,6 +183,9 @@ static void ath_update_survey_stats(stru
- struct ath_cycle_counters *cc = &common->cc_survey;
- unsigned int div = common->clockrate * 1000;
-
-+ if (!ah->curchan)
-+ return;
-+
- if (ah->power_mode == ATH9K_PM_AWAKE)
- ath_hw_cycle_counters_update(common);
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
-@@ -237,13 +237,15 @@ static int ar9002_hw_proc_txdesc(struct
- status = ACCESS_ONCE(ads->ds_txstatus1);
- if (status & AR_FrmXmitOK)
- ts->ts_status |= ATH9K_TX_ACKED;
-- if (status & AR_ExcessiveRetries)
-- ts->ts_status |= ATH9K_TXERR_XRETRY;
-- if (status & AR_Filtered)
-- ts->ts_status |= ATH9K_TXERR_FILT;
-- if (status & AR_FIFOUnderrun) {
-- ts->ts_status |= ATH9K_TXERR_FIFO;
-- ath9k_hw_updatetxtriglevel(ah, true);
-+ else {
-+ if (status & AR_ExcessiveRetries)
-+ ts->ts_status |= ATH9K_TXERR_XRETRY;
-+ if (status & AR_Filtered)
-+ ts->ts_status |= ATH9K_TXERR_FILT;
-+ if (status & AR_FIFOUnderrun) {
-+ ts->ts_status |= ATH9K_TXERR_FIFO;
-+ ath9k_hw_updatetxtriglevel(ah, true);
-+ }
- }
- if (status & AR_TxTimerExpired)
- ts->ts_status |= ATH9K_TXERR_TIMER_EXPIRED;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -673,6 +673,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_
- u16 aggr_limit = 0, al = 0, bpad = 0,
- al_delta, h_baw = tid->baw_size / 2;
- enum ATH_AGGR_STATUS status = ATH_AGGR_DONE;
-+ struct ieee80211_tx_info *tx_info;
-
- bf_first = list_first_entry(&tid->buf_q, struct ath_buf, list);
-
-@@ -699,6 +700,11 @@ static enum ATH_AGGR_STATUS ath_tx_form_
- break;
- }
-
-+ tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
-+ if (nframes && ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
-+ !(tx_info->control.rates[0].flags & IEEE80211_TX_RC_MCS)))
-+ break;
-+
- /* do not exceed subframe limit */
- if (nframes >= min((int)h_baw, ATH_AMPDU_SUBFRAME_DEFAULT)) {
- status = ATH_AGGR_LIMITED;
+++ /dev/null
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -506,7 +506,9 @@ minstrel_ht_set_rate(struct minstrel_pri
- if (!mr->retry_updated)
- minstrel_calc_retransmit(mp, mi, index);
-
-- if (mr->probability < MINSTREL_FRAC(20, 100))
-+ if (sample)
-+ rate->count = 1;
-+ else if (mr->probability < MINSTREL_FRAC(20, 100))
- rate->count = 2;
- else if (rtscts)
- rate->count = mr->retry_count_rtscts;
+++ /dev/null
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -407,8 +407,8 @@ minstrel_ht_tx_status(void *priv, struct
- mi->ampdu_len += info->status.ampdu_len;
-
- if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
-- mi->sample_wait = 4 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
-- mi->sample_tries = 3;
-+ mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
-+ mi->sample_tries = 2;
- mi->sample_count--;
- }
-
-@@ -564,7 +564,7 @@ minstrel_get_sample_rate(struct minstrel
- */
- if (minstrel_get_duration(sample_idx) >
- minstrel_get_duration(mi->max_tp_rate)) {
-- if (mr->sample_skipped < 10)
-+ if (mr->sample_skipped < 20)
- goto next;
-
- if (mi->sample_slow++ > 2)
-@@ -588,6 +588,7 @@ minstrel_ht_get_rate(void *priv, struct
- struct minstrel_ht_sta *mi = &msp->ht;
- struct minstrel_priv *mp = priv;
- int sample_idx;
-+ bool sample = false;
-
- if (rate_control_send_low(sta, priv_sta, txrc))
- return;
-@@ -598,10 +599,11 @@ minstrel_ht_get_rate(void *priv, struct
- info->flags |= mi->tx_flags;
- sample_idx = minstrel_get_sample_rate(mp, mi);
- if (sample_idx >= 0) {
-+ sample = true;
- minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx,
- txrc, true, false);
- minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate,
-- txrc, false, true);
-+ txrc, false, false);
- info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
- } else {
- minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate,
-@@ -609,7 +611,7 @@ minstrel_ht_get_rate(void *priv, struct
- minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2,
- txrc, false, true);
- }
-- minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate, txrc, false, true);
-+ minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate, txrc, false, !sample);
-
- ar[3].count = 0;
- ar[3].idx = -1;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -581,7 +581,7 @@ void ath_hw_check(struct work_struct *wo
-
- msleep(1);
- }
-- ath_reset(sc, false);
-+ ath_reset(sc, true);
-
- out:
- ath9k_ps_restore(sc);
-@@ -599,7 +599,7 @@ void ath9k_tasklet(unsigned long data)
- ath9k_ps_wakeup(sc);
-
- if (status & ATH9K_INT_FATAL) {
-- ath_reset(sc, false);
-+ ath_reset(sc, true);
- ath9k_ps_restore(sc);
- return;
- }
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -2161,7 +2161,7 @@ static void ath_tx_complete_poll_work(st
- ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
- "tx hung, resetting the chip\n");
- ath9k_ps_wakeup(sc);
-- ath_reset(sc, false);
-+ ath_reset(sc, true);
- ath9k_ps_restore(sc);
- }
-
---- a/drivers/net/wireless/ath/ath9k/beacon.c
-+++ b/drivers/net/wireless/ath/ath9k/beacon.c
-@@ -370,7 +370,7 @@ void ath_beacon_tasklet(unsigned long da
- ath_print(common, ATH_DBG_BSTUCK,
- "beacon is officially stuck\n");
- sc->sc_flags |= SC_OP_TSF_RESET;
-- ath_reset(sc, false);
-+ ath_reset(sc, true);
- }
-
- return;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -1089,15 +1089,6 @@ void ath_draintxq(struct ath_softc *sc,
- txq->axq_tx_inprogress = false;
- spin_unlock_bh(&txq->axq_lock);
-
-- /* flush any pending frames if aggregation is enabled */
-- if (sc->sc_flags & SC_OP_TXAGGR) {
-- if (!retry_tx) {
-- spin_lock_bh(&txq->axq_lock);
-- ath_txq_drain_pending_buffers(sc, txq);
-- spin_unlock_bh(&txq->axq_lock);
-- }
-- }
--
- if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
- spin_lock_bh(&txq->axq_lock);
- while (!list_empty(&txq->txq_fifo_pending)) {
-@@ -1118,6 +1109,15 @@ void ath_draintxq(struct ath_softc *sc,
- }
- spin_unlock_bh(&txq->axq_lock);
- }
-+
-+ /* flush any pending frames if aggregation is enabled */
-+ if (sc->sc_flags & SC_OP_TXAGGR) {
-+ if (!retry_tx) {
-+ spin_lock_bh(&txq->axq_lock);
-+ ath_txq_drain_pending_buffers(sc, txq);
-+ spin_unlock_bh(&txq->axq_lock);
-+ }
-+ }
- }
-
- void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -195,7 +195,6 @@ enum ATH_AGGR_STATUS {
-
- #define ATH_TXFIFO_DEPTH 8
- struct ath_txq {
-- int axq_class;
- u32 axq_qnum;
- u32 *axq_link;
- struct list_head axq_q;
-@@ -208,11 +207,12 @@ struct ath_txq {
- struct list_head txq_fifo_pending;
- u8 txq_headidx;
- u8 txq_tailidx;
-+ int pending_frames;
- };
-
- struct ath_atx_ac {
-+ struct ath_txq *txq;
- int sched;
-- int qnum;
- struct list_head list;
- struct list_head tid_q;
- };
-@@ -290,12 +290,11 @@ struct ath_tx_control {
- struct ath_tx {
- u16 seq_no;
- u32 txqsetup;
-- int hwq_map[WME_NUM_AC];
- spinlock_t txbuflock;
- struct list_head txbuf;
- struct ath_txq txq[ATH9K_NUM_TX_QUEUES];
- struct ath_descdma txdma;
-- int pending_frames[WME_NUM_AC];
-+ struct ath_txq *txq_map[WME_NUM_AC];
- };
-
- struct ath_rx_edma {
-@@ -325,7 +324,6 @@ void ath_rx_cleanup(struct ath_softc *sc
- int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp);
- struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype);
- void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq);
--int ath_tx_setup(struct ath_softc *sc, int haltype);
- void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx);
- void ath_draintxq(struct ath_softc *sc,
- struct ath_txq *txq, bool retry_tx);
-@@ -665,7 +663,6 @@ struct ath_wiphy {
-
- void ath9k_tasklet(unsigned long data);
- int ath_reset(struct ath_softc *sc, bool retry_tx);
--int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
- int ath_cabq_update(struct ath_softc *);
-
- static inline void ath_read_cachesize(struct ath_common *common, int *csz)
---- a/drivers/net/wireless/ath/ath9k/beacon.c
-+++ b/drivers/net/wireless/ath/ath9k/beacon.c
-@@ -28,7 +28,7 @@ int ath_beaconq_config(struct ath_softc
- struct ath_hw *ah = sc->sc_ah;
- struct ath_common *common = ath9k_hw_common(ah);
- struct ath9k_tx_queue_info qi, qi_be;
-- int qnum;
-+ struct ath_txq *txq;
-
- ath9k_hw_get_txq_props(ah, sc->beacon.beaconq, &qi);
- if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
-@@ -38,8 +38,8 @@ int ath_beaconq_config(struct ath_softc
- qi.tqi_cwmax = 0;
- } else {
- /* Adhoc mode; important thing is to use 2x cwmin. */
-- qnum = sc->tx.hwq_map[WME_AC_BE];
-- ath9k_hw_get_txq_props(ah, qnum, &qi_be);
-+ txq = sc->tx.txq_map[WME_AC_BE];
-+ ath9k_hw_get_txq_props(ah, txq->axq_qnum, &qi_be);
- qi.tqi_aifs = qi_be.tqi_aifs;
- qi.tqi_cwmin = 4*qi_be.tqi_cwmin;
- qi.tqi_cwmax = qi_be.tqi_cwmax;
---- a/drivers/net/wireless/ath/ath9k/common.h
-+++ b/drivers/net/wireless/ath/ath9k/common.h
-@@ -31,10 +31,11 @@
- #define WME_MAX_BA WME_BA_BMP_SIZE
- #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA)
-
--#define WME_AC_BE 0
--#define WME_AC_BK 1
--#define WME_AC_VI 2
--#define WME_AC_VO 3
-+/* These must match mac80211 skb queue mapping numbers */
-+#define WME_AC_VO 0
-+#define WME_AC_VI 1
-+#define WME_AC_BE 2
-+#define WME_AC_BK 3
- #define WME_NUM_AC 4
-
- #define ATH_RSSI_DUMMY_MARKER 0x127
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -331,7 +331,7 @@ void ath_paprd_calibrate(struct work_str
- struct ath_tx_control txctl;
- struct ath9k_hw_cal_data *caldata = ah->caldata;
- struct ath_common *common = ath9k_hw_common(ah);
-- int qnum, ftype;
-+ int ftype;
- int chain_ok = 0;
- int chain;
- int len = 1800;
-@@ -358,8 +358,7 @@ void ath_paprd_calibrate(struct work_str
- memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
-
- memset(&txctl, 0, sizeof(txctl));
-- qnum = sc->tx.hwq_map[WME_AC_BE];
-- txctl.txq = &sc->tx.txq[qnum];
-+ txctl.txq = sc->tx.txq_map[WME_AC_BE];
-
- ath9k_ps_wakeup(sc);
- ar9003_paprd_init_table(ah);
-@@ -1025,56 +1024,6 @@ int ath_reset(struct ath_softc *sc, bool
- return r;
- }
-
--static int ath_get_hal_qnum(u16 queue, struct ath_softc *sc)
--{
-- int qnum;
--
-- switch (queue) {
-- case 0:
-- qnum = sc->tx.hwq_map[WME_AC_VO];
-- break;
-- case 1:
-- qnum = sc->tx.hwq_map[WME_AC_VI];
-- break;
-- case 2:
-- qnum = sc->tx.hwq_map[WME_AC_BE];
-- break;
-- case 3:
-- qnum = sc->tx.hwq_map[WME_AC_BK];
-- break;
-- default:
-- qnum = sc->tx.hwq_map[WME_AC_BE];
-- break;
-- }
--
-- return qnum;
--}
--
--int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc)
--{
-- int qnum;
--
-- switch (queue) {
-- case WME_AC_VO:
-- qnum = 0;
-- break;
-- case WME_AC_VI:
-- qnum = 1;
-- break;
-- case WME_AC_BE:
-- qnum = 2;
-- break;
-- case WME_AC_BK:
-- qnum = 3;
-- break;
-- default:
-- qnum = -1;
-- break;
-- }
--
-- return qnum;
--}
--
- /* XXX: Remove me once we don't depend on ath9k_channel for all
- * this redundant data */
- void ath9k_update_ichannel(struct ath_softc *sc, struct ieee80211_hw *hw,
-@@ -1244,7 +1193,6 @@ static int ath9k_tx(struct ieee80211_hw
- struct ath_tx_control txctl;
- int padpos, padsize;
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-- int qnum;
-
- if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
- ath_print(common, ATH_DBG_XMIT,
-@@ -1317,8 +1265,7 @@ static int ath9k_tx(struct ieee80211_hw
- memmove(skb->data, skb->data + padsize, padpos);
- }
-
-- qnum = ath_get_hal_qnum(skb_get_queue_mapping(skb), sc);
-- txctl.txq = &sc->tx.txq[qnum];
-+ txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
-
- ath_print(common, ATH_DBG_XMIT, "transmitting packet, skb: %p\n", skb);
-
-@@ -1802,12 +1749,15 @@ static int ath9k_conf_tx(struct ieee8021
- struct ath_wiphy *aphy = hw->priv;
- struct ath_softc *sc = aphy->sc;
- struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-+ struct ath_txq *txq;
- struct ath9k_tx_queue_info qi;
-- int ret = 0, qnum;
-+ int ret = 0;
-
- if (queue >= WME_NUM_AC)
- return 0;
-
-+ txq = sc->tx.txq_map[queue];
-+
- mutex_lock(&sc->mutex);
-
- memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
-@@ -1816,20 +1766,19 @@ static int ath9k_conf_tx(struct ieee8021
- qi.tqi_cwmin = params->cw_min;
- qi.tqi_cwmax = params->cw_max;
- qi.tqi_burstTime = params->txop;
-- qnum = ath_get_hal_qnum(queue, sc);
-
- ath_print(common, ATH_DBG_CONFIG,
- "Configure tx [queue/halq] [%d/%d], "
- "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
-- queue, qnum, params->aifs, params->cw_min,
-+ queue, txq->axq_qnum, params->aifs, params->cw_min,
- params->cw_max, params->txop);
-
-- ret = ath_txq_update(sc, qnum, &qi);
-+ ret = ath_txq_update(sc, txq->axq_qnum, &qi);
- if (ret)
- ath_print(common, ATH_DBG_FATAL, "TXQ Update failed\n");
-
- if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)
-- if ((qnum == sc->tx.hwq_map[WME_AC_BE]) && !ret)
-+ if (queue == WME_AC_BE && !ret)
- ath_beaconq_config(sc);
-
- mutex_unlock(&sc->mutex);
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -124,7 +124,7 @@ static void ath_tx_queue_tid(struct ath_
-
- static void ath_tx_resume_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
- {
-- struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum];
-+ struct ath_txq *txq = tid->ac->txq;
-
- WARN_ON(!tid->paused);
-
-@@ -142,7 +142,7 @@ unlock:
-
- static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
- {
-- struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum];
-+ struct ath_txq *txq = tid->ac->txq;
- struct ath_buf *bf;
- struct list_head bf_head;
- struct ath_tx_status ts;
-@@ -817,7 +817,7 @@ void ath_tx_aggr_stop(struct ath_softc *
- {
- struct ath_node *an = (struct ath_node *)sta->drv_priv;
- struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid);
-- struct ath_txq *txq = &sc->tx.txq[txtid->ac->qnum];
-+ struct ath_txq *txq = txtid->ac->txq;
-
- if (txtid->state & AGGR_CLEANUP)
- return;
-@@ -888,10 +888,16 @@ struct ath_txq *ath_txq_setup(struct ath
- struct ath_hw *ah = sc->sc_ah;
- struct ath_common *common = ath9k_hw_common(ah);
- struct ath9k_tx_queue_info qi;
-+ static const int subtype_txq_to_hwq[] = {
-+ [WME_AC_BE] = ATH_TXQ_AC_BE,
-+ [WME_AC_BK] = ATH_TXQ_AC_BK,
-+ [WME_AC_VI] = ATH_TXQ_AC_VI,
-+ [WME_AC_VO] = ATH_TXQ_AC_VO,
-+ };
- int qnum, i;
-
- memset(&qi, 0, sizeof(qi));
-- qi.tqi_subtype = subtype;
-+ qi.tqi_subtype = subtype_txq_to_hwq[subtype];
- qi.tqi_aifs = ATH9K_TXQ_USEDEFAULT;
- qi.tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
- qi.tqi_cwmax = ATH9K_TXQ_USEDEFAULT;
-@@ -940,7 +946,6 @@ struct ath_txq *ath_txq_setup(struct ath
- if (!ATH_TXQ_SETUP(sc, qnum)) {
- struct ath_txq *txq = &sc->tx.txq[qnum];
-
-- txq->axq_class = subtype;
- txq->axq_qnum = qnum;
- txq->axq_link = NULL;
- INIT_LIST_HEAD(&txq->axq_q);
-@@ -1210,24 +1215,6 @@ void ath_txq_schedule(struct ath_softc *
- }
- }
-
--int ath_tx_setup(struct ath_softc *sc, int haltype)
--{
-- struct ath_txq *txq;
--
-- if (haltype >= ARRAY_SIZE(sc->tx.hwq_map)) {
-- ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
-- "HAL AC %u out of range, max %zu!\n",
-- haltype, ARRAY_SIZE(sc->tx.hwq_map));
-- return 0;
-- }
-- txq = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, haltype);
-- if (txq != NULL) {
-- sc->tx.hwq_map[haltype] = txq->axq_qnum;
-- return 1;
-- } else
-- return 0;
--}
--
- /***********/
- /* TX, DMA */
- /***********/
-@@ -1708,6 +1695,7 @@ static void ath_tx_start_dma(struct ath_
- goto tx_done;
- }
-
-+ WARN_ON(tid->ac->txq != txctl->txq);
- if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
- /*
- * Try aggregation if it's a unicast data frame
-@@ -1747,6 +1735,7 @@ int ath_tx_start(struct ieee80211_hw *hw
- return -1;
- }
-
-+ q = skb_get_queue_mapping(skb);
- r = ath_tx_setup_buffer(hw, bf, skb, txctl);
- if (unlikely(r)) {
- ath_print(common, ATH_DBG_FATAL, "TX mem alloc failure\n");
-@@ -1756,8 +1745,9 @@ int ath_tx_start(struct ieee80211_hw *hw
- * we will at least have to run TX completionon one buffer
- * on the queue */
- spin_lock_bh(&txq->axq_lock);
-- if (!txq->stopped && txq->axq_depth > 1) {
-- ath_mac80211_stop_queue(sc, skb_get_queue_mapping(skb));
-+ if (txq == sc->tx.txq_map[q] && !txq->stopped &&
-+ txq->axq_depth > 1) {
-+ ath_mac80211_stop_queue(sc, q);
- txq->stopped = 1;
- }
- spin_unlock_bh(&txq->axq_lock);
-@@ -1767,13 +1757,10 @@ int ath_tx_start(struct ieee80211_hw *hw
- return r;
- }
-
-- q = skb_get_queue_mapping(skb);
-- if (q >= 4)
-- q = 0;
--
- spin_lock_bh(&txq->axq_lock);
-- if (++sc->tx.pending_frames[q] > ATH_MAX_QDEPTH && !txq->stopped) {
-- ath_mac80211_stop_queue(sc, skb_get_queue_mapping(skb));
-+ if (txq == sc->tx.txq_map[q] &&
-+ ++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
-+ ath_mac80211_stop_queue(sc, q);
- txq->stopped = 1;
- }
- spin_unlock_bh(&txq->axq_lock);
-@@ -1841,7 +1828,8 @@ exit:
- /*****************/
-
- static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
-- struct ath_wiphy *aphy, int tx_flags)
-+ struct ath_wiphy *aphy, int tx_flags,
-+ struct ath_txq *txq)
- {
- struct ieee80211_hw *hw = sc->hw;
- struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
-@@ -1888,11 +1876,12 @@ static void ath_tx_complete(struct ath_s
- ath9k_tx_status(hw, skb);
- else {
- q = skb_get_queue_mapping(skb);
-- if (q >= 4)
-- q = 0;
--
-- if (--sc->tx.pending_frames[q] < 0)
-- sc->tx.pending_frames[q] = 0;
-+ if (txq == sc->tx.txq_map[q]) {
-+ spin_lock_bh(&txq->axq_lock);
-+ if (WARN_ON(--txq->pending_frames < 0))
-+ txq->pending_frames = 0;
-+ spin_unlock_bh(&txq->axq_lock);
-+ }
-
- ieee80211_tx_status(hw, skb);
- }
-@@ -1927,8 +1916,8 @@ static void ath_tx_complete_buf(struct a
- else
- complete(&sc->paprd_complete);
- } else {
-- ath_debug_stat_tx(sc, txq, bf, ts);
-- ath_tx_complete(sc, skb, bf->aphy, tx_flags);
-+ ath_debug_stat_tx(sc, bf, ts);
-+ ath_tx_complete(sc, skb, bf->aphy, tx_flags, txq);
- }
- /* At this point, skb (bf->bf_mpdu) is consumed...make sure we don't
- * accidentally reference it later.
-@@ -2018,16 +2007,13 @@ static void ath_tx_rc_status(struct ath_
- tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1;
- }
-
--static void ath_wake_mac80211_queue(struct ath_softc *sc, struct ath_txq *txq)
-+static void ath_wake_mac80211_queue(struct ath_softc *sc, int qnum)
- {
-- int qnum;
--
-- qnum = ath_get_mac80211_qnum(txq->axq_class, sc);
-- if (qnum == -1)
-- return;
-+ struct ath_txq *txq;
-
-+ txq = sc->tx.txq_map[qnum];
- spin_lock_bh(&txq->axq_lock);
-- if (txq->stopped && sc->tx.pending_frames[qnum] < ATH_MAX_QDEPTH) {
-+ if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
- if (ath_mac80211_start_queue(sc, qnum))
- txq->stopped = 0;
- }
-@@ -2044,6 +2030,7 @@ static void ath_tx_processq(struct ath_s
- struct ath_tx_status ts;
- int txok;
- int status;
-+ int qnum;
-
- ath_print(common, ATH_DBG_QUEUE, "tx queue %d (%x), link %p\n",
- txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum),
-@@ -2119,12 +2106,15 @@ static void ath_tx_processq(struct ath_s
- ath_tx_rc_status(bf, &ts, txok ? 0 : 1, txok, true);
- }
-
-+ qnum = skb_get_queue_mapping(bf->bf_mpdu);
-+
- if (bf_isampdu(bf))
- ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, txok);
- else
- ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, txok, 0);
-
-- ath_wake_mac80211_queue(sc, txq);
-+ if (txq == sc->tx.txq_map[qnum])
-+ ath_wake_mac80211_queue(sc, qnum);
-
- spin_lock_bh(&txq->axq_lock);
- if (sc->sc_flags & SC_OP_TXAGGR)
-@@ -2194,6 +2184,7 @@ void ath_tx_edma_tasklet(struct ath_soft
- struct list_head bf_head;
- int status;
- int txok;
-+ int qnum;
-
- for (;;) {
- status = ath9k_hw_txprocdesc(ah, NULL, (void *)&txs);
-@@ -2237,13 +2228,16 @@ void ath_tx_edma_tasklet(struct ath_soft
- ath_tx_rc_status(bf, &txs, txok ? 0 : 1, txok, true);
- }
-
-+ qnum = skb_get_queue_mapping(bf->bf_mpdu);
-+
- if (bf_isampdu(bf))
- ath_tx_complete_aggr(sc, txq, bf, &bf_head, &txs, txok);
- else
- ath_tx_complete_buf(sc, bf, txq, &bf_head,
- &txs, txok, 0);
-
-- ath_wake_mac80211_queue(sc, txq);
-+ if (txq == sc->tx.txq_map[qnum])
-+ ath_wake_mac80211_queue(sc, qnum);
-
- spin_lock_bh(&txq->axq_lock);
- if (!list_empty(&txq->txq_fifo_pending)) {
-@@ -2375,7 +2369,7 @@ void ath_tx_node_init(struct ath_softc *
- for (acno = 0, ac = &an->ac[acno];
- acno < WME_NUM_AC; acno++, ac++) {
- ac->sched = false;
-- ac->qnum = sc->tx.hwq_map[acno];
-+ ac->txq = sc->tx.txq_map[acno];
- INIT_LIST_HEAD(&ac->tid_q);
- }
- }
-@@ -2385,17 +2379,13 @@ void ath_tx_node_cleanup(struct ath_soft
- struct ath_atx_ac *ac;
- struct ath_atx_tid *tid;
- struct ath_txq *txq;
-- int i, tidno;
-+ int tidno;
-
- for (tidno = 0, tid = &an->tid[tidno];
- tidno < WME_NUM_TID; tidno++, tid++) {
-- i = tid->ac->qnum;
--
-- if (!ATH_TXQ_SETUP(sc, i))
-- continue;
-
-- txq = &sc->tx.txq[i];
- ac = tid->ac;
-+ txq = ac->txq;
-
- spin_lock_bh(&txq->axq_lock);
-
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -157,6 +157,13 @@
- #define PAPRD_GAIN_TABLE_ENTRIES 32
- #define PAPRD_TABLE_SZ 24
-
-+enum ath_hw_txq_subtype {
-+ ATH_TXQ_AC_BE = 0,
-+ ATH_TXQ_AC_BK = 1,
-+ ATH_TXQ_AC_VI = 2,
-+ ATH_TXQ_AC_VO = 3,
-+};
-+
- enum ath_ini_subsys {
- ATH_INI_PRE = 0,
- ATH_INI_CORE,
---- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
-+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
-@@ -20,8 +20,15 @@
- /* TX */
- /******/
-
-+static const int subtype_txq_to_hwq[] = {
-+ [WME_AC_BE] = ATH_TXQ_AC_BE,
-+ [WME_AC_BK] = ATH_TXQ_AC_BK,
-+ [WME_AC_VI] = ATH_TXQ_AC_VI,
-+ [WME_AC_VO] = ATH_TXQ_AC_VO,
-+};
-+
- #define ATH9K_HTC_INIT_TXQ(subtype) do { \
-- qi.tqi_subtype = subtype; \
-+ qi.tqi_subtype = subtype_txq_to_hwq[subtype]; \
- qi.tqi_aifs = ATH9K_TXQ_USEDEFAULT; \
- qi.tqi_cwmin = ATH9K_TXQ_USEDEFAULT; \
- qi.tqi_cwmax = ATH9K_TXQ_USEDEFAULT; \
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -396,7 +396,8 @@ static void ath9k_init_crypto(struct ath
-
- static int ath9k_init_btcoex(struct ath_softc *sc)
- {
-- int r, qnum;
-+ struct ath_txq *txq;
-+ int r;
-
- switch (sc->sc_ah->btcoex_hw.scheme) {
- case ATH_BTCOEX_CFG_NONE:
-@@ -409,8 +410,8 @@ static int ath9k_init_btcoex(struct ath_
- r = ath_init_btcoex_timer(sc);
- if (r)
- return -1;
-- qnum = sc->tx.hwq_map[WME_AC_BE];
-- ath9k_hw_init_btcoex_hw(sc->sc_ah, qnum);
-+ txq = sc->tx.txq_map[WME_AC_BE];
-+ ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum);
- sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
- break;
- default:
-@@ -423,59 +424,18 @@ static int ath9k_init_btcoex(struct ath_
-
- static int ath9k_init_queues(struct ath_softc *sc)
- {
-- struct ath_common *common = ath9k_hw_common(sc->sc_ah);
- int i = 0;
-
-- for (i = 0; i < ARRAY_SIZE(sc->tx.hwq_map); i++)
-- sc->tx.hwq_map[i] = -1;
--
- sc->beacon.beaconq = ath9k_hw_beaconq_setup(sc->sc_ah);
-- if (sc->beacon.beaconq == -1) {
-- ath_print(common, ATH_DBG_FATAL,
-- "Unable to setup a beacon xmit queue\n");
-- goto err;
-- }
--
- sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0);
-- if (sc->beacon.cabq == NULL) {
-- ath_print(common, ATH_DBG_FATAL,
-- "Unable to setup CAB xmit queue\n");
-- goto err;
-- }
-
- sc->config.cabqReadytime = ATH_CABQ_READY_TIME;
- ath_cabq_update(sc);
-
-- if (!ath_tx_setup(sc, WME_AC_BK)) {
-- ath_print(common, ATH_DBG_FATAL,
-- "Unable to setup xmit queue for BK traffic\n");
-- goto err;
-- }
--
-- if (!ath_tx_setup(sc, WME_AC_BE)) {
-- ath_print(common, ATH_DBG_FATAL,
-- "Unable to setup xmit queue for BE traffic\n");
-- goto err;
-- }
-- if (!ath_tx_setup(sc, WME_AC_VI)) {
-- ath_print(common, ATH_DBG_FATAL,
-- "Unable to setup xmit queue for VI traffic\n");
-- goto err;
-- }
-- if (!ath_tx_setup(sc, WME_AC_VO)) {
-- ath_print(common, ATH_DBG_FATAL,
-- "Unable to setup xmit queue for VO traffic\n");
-- goto err;
-- }
-+ for (i = 0; i < WME_NUM_AC; i++)
-+ sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i);
-
- return 0;
--
--err:
-- for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
-- if (ATH_TXQ_SETUP(sc, i))
-- ath_tx_cleanupq(sc, &sc->tx.txq[i]);
--
-- return -EIO;
- }
-
- static int ath9k_init_channels_rates(struct ath_softc *sc)
---- a/drivers/net/wireless/ath/ath9k/virtual.c
-+++ b/drivers/net/wireless/ath/ath9k/virtual.c
-@@ -187,7 +187,7 @@ static int ath9k_send_nullfunc(struct at
- info->control.rates[1].idx = -1;
-
- memset(&txctl, 0, sizeof(struct ath_tx_control));
-- txctl.txq = &sc->tx.txq[sc->tx.hwq_map[WME_AC_VO]];
-+ txctl.txq = sc->tx.txq_map[WME_AC_VO];
- txctl.frame_type = ps ? ATH9K_IFT_PAUSE : ATH9K_IFT_UNPAUSE;
-
- if (ath_tx_start(aphy->hw, skb, &txctl) != 0)
---- a/drivers/net/wireless/ath/ath9k/debug.c
-+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -579,10 +579,10 @@ static const struct file_operations fops
- do { \
- len += snprintf(buf + len, size - len, \
- "%s%13u%11u%10u%10u\n", str, \
-- sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_BE]].elem, \
-- sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_BK]].elem, \
-- sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_VI]].elem, \
-- sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_VO]].elem); \
-+ sc->debug.stats.txstats[WME_AC_BE].elem, \
-+ sc->debug.stats.txstats[WME_AC_BK].elem, \
-+ sc->debug.stats.txstats[WME_AC_VI].elem, \
-+ sc->debug.stats.txstats[WME_AC_VO].elem); \
- } while(0)
-
- static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
-@@ -624,33 +624,35 @@ static ssize_t read_file_xmit(struct fil
- return retval;
- }
-
--void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
-- struct ath_buf *bf, struct ath_tx_status *ts)
-+void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
-+ struct ath_tx_status *ts)
- {
-- TX_STAT_INC(txq->axq_qnum, tx_pkts_all);
-- sc->debug.stats.txstats[txq->axq_qnum].tx_bytes_all += bf->bf_mpdu->len;
-+ int qnum = skb_get_queue_mapping(bf->bf_mpdu);
-+
-+ TX_STAT_INC(qnum, tx_pkts_all);
-+ sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
-
- if (bf_isampdu(bf)) {
- if (bf_isxretried(bf))
-- TX_STAT_INC(txq->axq_qnum, a_xretries);
-+ TX_STAT_INC(qnum, a_xretries);
- else
-- TX_STAT_INC(txq->axq_qnum, a_completed);
-+ TX_STAT_INC(qnum, a_completed);
- } else {
-- TX_STAT_INC(txq->axq_qnum, completed);
-+ TX_STAT_INC(qnum, completed);
- }
-
- if (ts->ts_status & ATH9K_TXERR_FIFO)
-- TX_STAT_INC(txq->axq_qnum, fifo_underrun);
-+ TX_STAT_INC(qnum, fifo_underrun);
- if (ts->ts_status & ATH9K_TXERR_XTXOP)
-- TX_STAT_INC(txq->axq_qnum, xtxop);
-+ TX_STAT_INC(qnum, xtxop);
- if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
-- TX_STAT_INC(txq->axq_qnum, timer_exp);
-+ TX_STAT_INC(qnum, timer_exp);
- if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
-- TX_STAT_INC(txq->axq_qnum, desc_cfg_err);
-+ TX_STAT_INC(qnum, desc_cfg_err);
- if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
-- TX_STAT_INC(txq->axq_qnum, data_underrun);
-+ TX_STAT_INC(qnum, data_underrun);
- if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
-- TX_STAT_INC(txq->axq_qnum, delim_underrun);
-+ TX_STAT_INC(qnum, delim_underrun);
- }
-
- static const struct file_operations fops_xmit = {
---- a/drivers/net/wireless/ath/ath9k/debug.h
-+++ b/drivers/net/wireless/ath/ath9k/debug.h
-@@ -169,8 +169,8 @@ void ath9k_exit_debug(struct ath_hw *ah)
- int ath9k_debug_create_root(void);
- void ath9k_debug_remove_root(void);
- void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
--void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
-- struct ath_buf *bf, struct ath_tx_status *ts);
-+void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
-+ struct ath_tx_status *ts);
- void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
-
- #else
-@@ -199,7 +199,6 @@ static inline void ath_debug_stat_interr
- }
-
- static inline void ath_debug_stat_tx(struct ath_softc *sc,
-- struct ath_txq *txq,
- struct ath_buf *bf,
- struct ath_tx_status *ts)
- {
+++ /dev/null
---- a/include/linux/nl80211.h
-+++ b/include/linux/nl80211.h
-@@ -804,6 +804,8 @@ enum nl80211_commands {
- * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
- * means support for per-station GTKs.
- *
-+ * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
-+ *
- * @NL80211_ATTR_MAX: highest attribute number currently defined
- * @__NL80211_ATTR_AFTER_LAST: internal use
- */
-@@ -973,6 +975,8 @@ enum nl80211_attrs {
-
- NL80211_ATTR_SUPPORT_IBSS_RSN,
-
-+ NL80211_ATTR_MCAST_RATE,
-+
- /* add attributes here, update the policy in nl80211.c */
-
- __NL80211_ATTR_AFTER_LAST,
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -924,6 +924,7 @@ struct cfg80211_disassoc_request {
- * @privacy: this is a protected network, keys will be configured
- * after joining
- * @basic_rates: bitmap of basic rates to use when creating the IBSS
-+ * @mcast_rate: multicast tx rate (in 100 kbps)
- */
- struct cfg80211_ibss_params {
- u8 *ssid;
-@@ -935,6 +936,7 @@ struct cfg80211_ibss_params {
- u32 basic_rates;
- bool channel_fixed;
- bool privacy;
-+ int mcast_rate;
- };
-
- /**
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -167,6 +167,7 @@ static const struct nla_policy nl80211_p
- [NL80211_ATTR_WIPHY_TX_POWER_SETTING] = { .type = NLA_U32 },
- [NL80211_ATTR_WIPHY_TX_POWER_LEVEL] = { .type = NLA_U32 },
- [NL80211_ATTR_FRAME_TYPE] = { .type = NLA_U16 },
-+ [NL80211_ATTR_MCAST_RATE] = { .type = NLA_U32 },
- };
-
- /* policy for the key attributes */
-@@ -3652,6 +3653,9 @@ static int nl80211_join_ibss(struct sk_b
- return -EINVAL;
- }
- }
-+ if (info->attrs[NL80211_ATTR_MCAST_RATE])
-+ ibss.mcast_rate =
-+ nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]);
-
- if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) {
- connkeys = nl80211_parse_connkeys(rdev,
+++ /dev/null
---- a/net/mac80211/ibss.c
-+++ b/net/mac80211/ibss.c
-@@ -914,6 +914,7 @@ int ieee80211_ibss_join(struct ieee80211
-
- sdata->u.ibss.privacy = params->privacy;
- sdata->u.ibss.basic_rates = params->basic_rates;
-+ sdata->vif.bss_conf.mcast_rate = params->mcast_rate;
-
- sdata->vif.bss_conf.beacon_int = params->beacon_interval;
-
---- a/include/net/mac80211.h
-+++ b/include/net/mac80211.h
-@@ -244,6 +244,7 @@ struct ieee80211_bss_conf {
- u16 assoc_capability;
- u64 timestamp;
- u32 basic_rates;
-+ u32 mcast_rate;
- u16 ht_operation_mode;
- s32 cqm_rssi_thold;
- u32 cqm_rssi_hyst;
-@@ -2644,7 +2645,7 @@ enum rate_control_changed {
- * @rate_idx_mask: user-requested rate mask (not MCS for now)
- * @skb: the skb that will be transmitted, the control information in it needs
- * to be filled in
-- * @ap: whether this frame is sent out in AP mode
-+ * @bss: whether this frame is sent out in AP or IBSS mode
- */
- struct ieee80211_tx_rate_control {
- struct ieee80211_hw *hw;
-@@ -2655,7 +2656,7 @@ struct ieee80211_tx_rate_control {
- bool rts, short_preamble;
- u8 max_rate_idx;
- u32 rate_idx_mask;
-- bool ap;
-+ bool bss;
- };
-
- struct rate_control_ops {
---- a/net/mac80211/rate.c
-+++ b/net/mac80211/rate.c
-@@ -210,10 +210,20 @@ static bool rc_no_data_or_no_ack(struct
- return ((info->flags & IEEE80211_TX_CTL_NO_ACK) || !ieee80211_is_data(fc));
- }
-
--static void rc_send_low_broadcast(s8 *idx, u32 basic_rates, u8 max_rate_idx)
-+static void rc_send_low_broadcast(s8 *idx, u32 basic_rates, u32 mcast_rate,
-+ struct ieee80211_supported_band *sband)
- {
- u8 i;
-
-+ if (mcast_rate) {
-+ for (i = 0; i < sband->n_bitrates; i++) {
-+ if (sband->bitrates[i].bitrate == mcast_rate) {
-+ *idx = i;
-+ return;
-+ }
-+ }
-+ }
-+
- if (basic_rates == 0)
- return; /* assume basic rates unknown and accept rate */
- if (*idx < 0)
-@@ -221,7 +231,7 @@ static void rc_send_low_broadcast(s8 *id
- if (basic_rates & (1 << *idx))
- return; /* selected rate is a basic rate */
-
-- for (i = *idx + 1; i <= max_rate_idx; i++) {
-+ for (i = *idx + 1; i <= sband->n_bitrates; i++) {
- if (basic_rates & (1 << i)) {
- *idx = i;
- return;
-@@ -242,10 +252,11 @@ bool rate_control_send_low(struct ieee80
- info->control.rates[0].count =
- (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
- 1 : txrc->hw->max_rate_tries;
-- if (!sta && txrc->ap)
-+ if (!sta && txrc->bss)
- rc_send_low_broadcast(&info->control.rates[0].idx,
- txrc->bss_conf->basic_rates,
-- txrc->sband->n_bitrates);
-+ txrc->bss_conf->mcast_rate,
-+ txrc->sband);
- return true;
- }
- return false;
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -622,7 +622,8 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
- txrc.max_rate_idx = -1;
- else
- txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
-- txrc.ap = tx->sdata->vif.type == NL80211_IFTYPE_AP;
-+ txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
-+ tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
-
- /* set up RTS protection if desired */
- if (len > tx->local->hw.wiphy->rts_threshold) {
-@@ -2312,7 +2313,7 @@ struct sk_buff *ieee80211_beacon_get_tim
- txrc.max_rate_idx = -1;
- else
- txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
-- txrc.ap = true;
-+ txrc.bss = true;
- rate_control_get_rate(sdata, NULL, &txrc);
-
- info->control.vif = vif;
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -94,11 +94,13 @@ void ath9k_ps_wakeup(struct ath_softc *s
- {
- struct ath_common *common = ath9k_hw_common(sc->sc_ah);
- unsigned long flags;
-+ enum ath9k_power_mode power_mode;
-
- spin_lock_irqsave(&sc->sc_pm_lock, flags);
- if (++sc->ps_usecount != 1)
- goto unlock;
-
-+ power_mode = sc->sc_ah->power_mode;
- ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
-
- /*
-@@ -106,10 +108,12 @@ void ath9k_ps_wakeup(struct ath_softc *s
- * useful data. Better clear them now so that they don't mess up
- * survey data results.
- */
-- spin_lock(&common->cc_lock);
-- ath_hw_cycle_counters_update(common);
-- memset(&common->cc_survey, 0, sizeof(common->cc_survey));
-- spin_unlock(&common->cc_lock);
-+ if (power_mode != ATH9K_PM_AWAKE) {
-+ spin_lock(&common->cc_lock);
-+ ath_hw_cycle_counters_update(common);
-+ memset(&common->cc_survey, 0, sizeof(common->cc_survey));
-+ spin_unlock(&common->cc_lock);
-+ }
-
- unlock:
- spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/beacon.c
-+++ b/drivers/net/wireless/ath/ath9k/beacon.c
-@@ -506,7 +506,7 @@ static void ath_beacon_config_ap(struct
- ath9k_hw_disable_interrupts(ah);
- ath9k_beacon_init(sc, nexttbtt, intval);
- sc->beacon.bmisscnt = 0;
-- ath9k_hw_enable_interrupts(ah);
-+ ath9k_hw_set_interrupts(ah, ah->imask);
-
- /* Clear the reset TSF flag, so that subsequent beacon updation
- will not reset the HW TSF. */
-@@ -689,7 +689,7 @@ static void ath_beacon_config_adhoc(stru
- ath9k_hw_disable_interrupts(ah);
- ath9k_beacon_init(sc, nexttbtt, intval);
- sc->beacon.bmisscnt = 0;
-- ath9k_hw_enable_interrupts(ah);
-+ ath9k_hw_set_interrupts(ah, ah->imask);
- }
-
- void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif)
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/recv.c
-+++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -517,7 +517,7 @@ bool ath_stoprecv(struct ath_softc *sc)
- bool stopped;
-
- spin_lock_bh(&sc->rx.rxbuflock);
-- ath9k_hw_stoppcurecv(ah);
-+ ath9k_hw_abortpcurecv(ah);
- ath9k_hw_setrxfilter(ah, 0);
- stopped = ath9k_hw_stopdmarecv(ah);
-
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -1125,7 +1125,7 @@ void ath_draintxq(struct ath_softc *sc,
- }
- }
-
--void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
-+bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
- {
- struct ath_hw *ah = sc->sc_ah;
- struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-@@ -1133,7 +1133,7 @@ void ath_drain_all_txq(struct ath_softc
- int i, npend = 0;
-
- if (sc->sc_flags & SC_OP_INVALID)
-- return;
-+ return true;
-
- /* Stop beacon queue */
- ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
-@@ -1147,23 +1147,15 @@ void ath_drain_all_txq(struct ath_softc
- }
- }
-
-- if (npend) {
-- int r;
--
-- ath_print(common, ATH_DBG_FATAL,
-- "Failed to stop TX DMA. Resetting hardware!\n");
--
-- r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
-- if (r)
-- ath_print(common, ATH_DBG_FATAL,
-- "Unable to reset hardware; reset status %d\n",
-- r);
-- }
-+ if (npend)
-+ ath_print(common, ATH_DBG_FATAL, "Failed to stop TX DMA!\n");
-
- for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
- if (ATH_TXQ_SETUP(sc, i))
- ath_draintxq(sc, &sc->tx.txq[i], retry_tx);
- }
-+
-+ return !npend;
- }
-
- void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq)
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -324,7 +324,7 @@ void ath_rx_cleanup(struct ath_softc *sc
- int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp);
- struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype);
- void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq);
--void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx);
-+bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx);
- void ath_draintxq(struct ath_softc *sc,
- struct ath_txq *txq, bool retry_tx);
- void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -247,9 +247,10 @@ int ath_set_channel(struct ath_softc *sc
- * the relevant bits of the h/w.
- */
- ath9k_hw_disable_interrupts(ah);
-- ath_drain_all_txq(sc, false);
-+ stopped = ath_drain_all_txq(sc, false);
-
-- stopped = ath_stoprecv(sc);
-+ if (!ath_stoprecv(sc))
-+ stopped = false;
-
- /* XXX: do not flush receive queue here. We don't want
- * to flush data frames already in queue because of
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
-@@ -593,6 +593,10 @@ static void rt2800pci_kill_tx_queue(stru
+@@ -592,6 +592,10 @@ static void rt2800pci_kill_tx_queue(stru
return;
}
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
-@@ -3897,6 +3897,7 @@ MODULE_FIRMWARE("mwl8k/helper_8366.fw");
- MODULE_FIRMWARE("mwl8k/fmimage_8366.fw");
+@@ -4056,6 +4056,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw")
+ MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API));
static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {
+ { PCI_VDEVICE(MARVELL, 0x2a02), .driver_data = MWL8363, },
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
-@@ -705,6 +705,7 @@ struct b43_wldev {
+@@ -718,6 +718,7 @@ struct b43_wldev {
bool qos_enabled; /* TRUE, if QoS is used. */
bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
bool use_pio; /* TRUE if next init should use PIO */
static int modparam_bad_frames_preempt;
module_param_named(bad_frames_preempt, modparam_bad_frames_preempt, int, 0444);
MODULE_PARM_DESC(bad_frames_preempt,
-@@ -2534,10 +2539,10 @@ static int b43_gpio_init(struct b43_wlde
+@@ -2540,10 +2545,10 @@ static int b43_gpio_init(struct b43_wlde
& ~B43_MACCTL_GPOUTSMSK);
b43_write16(dev, B43_MMIO_GPIO_MASK, b43_read16(dev, B43_MMIO_GPIO_MASK)
if (dev->dev->bus->chip_id == 0x4301) {
mask |= 0x0060;
set |= 0x0060;
-@@ -5094,10 +5099,10 @@ static void b43_print_driverinfo(void)
+@@ -5100,10 +5105,10 @@ static void b43_print_driverinfo(void)
feat_sdio = "S";
#endif
printk(KERN_INFO "Broadcom 43xx driver loaded "
b43-$(CONFIG_B43_PCMCIA) += pcmcia.o
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
-@@ -1810,9 +1810,11 @@ static void b43_do_interrupt_thread(stru
+@@ -1816,9 +1816,11 @@ static void b43_do_interrupt_thread(stru
dma_reason[4], dma_reason[5]);
b43err(dev->wl, "This device does not support DMA "
"on your system. It will now be switched to PIO.\n");
#
# Copyright 2007, 2008, 2010 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
#
---- a/scripts/athenable
-+++ b/scripts/athenable
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- #
- # Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- #
---- a/scripts/athload
-+++ b/scripts/athload
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- # Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- #
- # Loads ath5k or madwifi
---- a/scripts/b43enable
-+++ b/scripts/b43enable
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- #
- # Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- #
---- a/scripts/b43load
-+++ b/scripts/b43load
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- # Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- #
- # Loads new broadcom drivers (b43 and b43legacy) or the old ones (bcm43xx)
---- a/scripts/btload.sh
-+++ b/scripts/btload.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- MODULES="bluetooth btusb l2cap sco hidp rfcomm bnep"
- for i in $MODULES; do
- echo Loading $i...
---- a/scripts/btunload.sh
-+++ b/scripts/btunload.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- MODULES="hidp rfcomm bnep l2cap sco btusb bluetooth"
- echo Stoping bluetooth service..
- /etc/init.d/bluetooth stop
--- a/scripts/check_config.sh
+++ b/scripts/check_config.sh
@@ -1,4 +1,4 @@
# This script checks the compat-wireless configuration file and if changes were made
# regenerates the compat_autoconf header.
---- a/scripts/check_depmod
-+++ b/scripts/check_depmod
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- # Copyright 2009 Luis R. Rodriguez <mcgrof@gmail.com>
- #
- # Ensures your distribution likes to prefer updates/ over the kernel/
---- a/scripts/compress_modules
-+++ b/scripts/compress_modules
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- # To be used by distributions using compressed modules
-
- COMPRESSION_FOUND="n"
--- a/scripts/driver-select
+++ b/scripts/driver-select
@@ -1,4 +1,4 @@
# Copyright 2009 Luis R. Rodriguez <mcgrof@gmail.com>
#
# You can use this to make stable compat-wireless releases
---- a/scripts/iwl-enable
-+++ b/scripts/iwl-enable
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- #
- # Copyright 2007 Luis R. Rodriguez <lrodriguez@atheros.com>
- #
---- a/scripts/iwl-load
-+++ b/scripts/iwl-load
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- # Copyright 2008 Luis R. Rodriguez <lrodriguez@atheros.com>
- #
- # Loads new Intel iwl (iwlagn) or the old ones (iwl4965)
---- a/scripts/load.sh
-+++ b/scripts/load.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- MODULES="ipw2100 ipw2200 libertas_cs usb8xxx"
- MODULES="$MODULES p54pci p54usb"
- MODULES="$MODULES adm8211 zd1211rw"
---- a/scripts/modlib.sh
-+++ b/scripts/modlib.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- #
- # Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- #
--- a/scripts/skip-colors
+++ b/scripts/skip-colors
@@ -1,2 +1,2 @@
-#!/bin/bash
+#!/usr/bin/env bash
perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g'
---- a/scripts/unload.sh
-+++ b/scripts/unload.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
-
- # The old stack drivers and the mac80211 rc80211_simple modules
- # which is no longer on recent kernels (its internal)
---- a/scripts/update-initramfs
-+++ b/scripts/update-initramfs
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- # Copyright 2009 Luis R. Rodriguez <mcgrof@gmail.com>
- #
- # Since we provide ssb, the Ethernet module b44 some people may
---- a/scripts/wlload.sh
-+++ b/scripts/wlload.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- MODULES="ipw2100 ipw2200 libertas_cs usb8xxx"
- MODULES="$MODULES p54pci p54usb"
- MODULES="$MODULES adm8211 zd1211rw"
---- a/scripts/wlunload.sh
-+++ b/scripts/wlunload.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
-
- # The old stack drivers and the mac80211 rc80211_simple modules
- # which is no longer on recent kernels (its internal)