Browse Source

v1.4.1 refesh based upon upstrea 17.01 branch

RISCi_ATOM 2 years ago
parent
commit
92a7239b36
100 changed files with 5446 additions and 2159 deletions
  1. 3 3
      include/kernel-version.mk
  2. 1 1
      package/Makefile
  3. 3 4
      package/boot/uboot-ar71xx/Makefile
  4. 3 3
      package/boot/uboot-envtools/Makefile
  5. 47 40
      package/boot/uboot-envtools/files/ar71xx
  6. 1 1
      package/boot/uboot-envtools/files/imx6
  7. 2 3
      package/boot/uboot-envtools/files/ipq
  8. 8 8
      package/boot/uboot-envtools/files/kirkwood
  9. 3 3
      package/boot/uboot-envtools/files/lantiq
  10. 3 1
      package/boot/uboot-envtools/files/mvebu
  11. 3 3
      package/boot/uboot-envtools/files/oxnas
  12. 9 9
      package/boot/uboot-envtools/files/ramips
  13. 52 142
      package/boot/uboot-sunxi/Makefile
  14. 4 5
      package/boot/uboot-xburst/Makefile
  15. 65 0
      package/devel/binutils/patches/0001-Do-not-pass-host-compiler-sanitization-flags-on-to-l.patch
  16. 1258 0
      package/devel/binutils/patches/0002-When-building-target-binaries-ensure-that-the-warnin.patch
  17. 16 4
      package/kernel/mac80211/patches/020-01-rt2x00-avoid-introducing-a-USB-dependency-in-the-rt2.patch
  18. 61 0
      package/kernel/mac80211/patches/020-02-rt2x00usb-do-not-anchor-rx-and-tx-urb-s.patch
  19. 75 0
      package/kernel/mac80211/patches/020-03-rt2x00usb-fix-anchor-initialization.patch
  20. 28 0
      package/kernel/mac80211/patches/020-04-rt61pci-use-entry-directly.patch
  21. 181 0
      package/kernel/mac80211/patches/020-05-rt2x00-call-entry-directly-in-rt2x00_dump_frame.patch
  22. 59 0
      package/kernel/mac80211/patches/020-06-rt2x00-remove-queue_entry-from-skbdesc.patch
  23. 84 0
      package/kernel/mac80211/patches/020-07-rt2500usb-don-t-mark-register-accesses-as-inline.patch
  24. 94 0
      package/kernel/mac80211/patches/020-08-rt2x00-rt2800lib-move-rt2800_drv_data-declaration-in.patch
  25. 94 0
      package/kernel/mac80211/patches/020-09-rt2800-identify-station-based-on-status-WCID.patch
  26. 178 0
      package/kernel/mac80211/patches/020-10-rt2x00-separte-filling-tx-status-from-rt2x00lib_txdo.patch
  27. 88 0
      package/kernel/mac80211/patches/020-11-rt2x00-separte-clearing-entry-from-rt2x00lib_txdone.patch
  28. 92 0
      package/kernel/mac80211/patches/020-12-rt2x00-add-txdone-nomatch-function.patch
  29. 54 0
      package/kernel/mac80211/patches/020-13-rt2x00-fixup-fill_tx_status-for-nomatch-case.patch
  30. 191 0
      package/kernel/mac80211/patches/020-14-rt2x00-use-txdone_nomatch-on-rt2800usb.patch
  31. 88 0
      package/kernel/mac80211/patches/020-15-rt2800-status-based-rate-flags-for-nomatch-case.patch
  32. 43 0
      package/kernel/mac80211/patches/020-16-rt2800-use-TXOP_BACKOFF-for-probe-frames.patch
  33. 28 0
      package/kernel/mac80211/patches/020-17-rt2x00-fix-rt2x00debug_dump_frame-comment.patch
  34. 37 0
      package/kernel/mac80211/patches/020-18-rt2x00-fix-TX_PWR_CFG_4-register-definition.patch
  35. 2077 0
      package/kernel/mac80211/patches/020-19-rt2x00-add-support-for-MT7620.patch
  36. 54 0
      package/kernel/mac80211/patches/021-01-rt2800-fix-LNA-gain-assignment-for-MT7620.patch
  37. 34 0
      package/kernel/mac80211/patches/021-02-rt2800-do-VCO-calibration-after-programming-ALC.patch
  38. 50 0
      package/kernel/mac80211/patches/021-03-rt2800-fix-mt7620-vco-calibration-registers.patch
  39. 41 0
      package/kernel/mac80211/patches/021-04-rt2800-fix-mt7620-E2-channel-registers.patch
  40. 1 1
      package/kernel/mac80211/patches/030-rt2x00_options.patch
  41. 0 9
      package/kernel/mac80211/patches/040-brcmutil_option.patch
  42. 0 52
      package/kernel/mac80211/patches/318-0001-brcmfmac-check-brcmf_bus_get_memdump-result-for-erro.patch
  43. 0 38
      package/kernel/mac80211/patches/319-0002-brcmfmac-be-more-verbose-when-PSM-s-watchdog-fires.patch
  44. 0 44
      package/kernel/mac80211/patches/319-0003-brcmfmac-use-wiphy_read_of_freq_limits-to-respect-li.patch
  45. 0 43
      package/kernel/mac80211/patches/319-0004-brcmfmac-merge-two-brcmf_err-macros-into-one.patch
  46. 0 69
      package/kernel/mac80211/patches/319-0005-brcmfmac-switch-to-C-function-__brcmf_err-for-printi.patch
  47. 0 46
      package/kernel/mac80211/patches/319-0006-brcmfmac-merge-two-remaining-brcmf_err-macros.patch
  48. 47 0
      package/kernel/mac80211/patches/324-ath9k_hw-fix-channel-maximum-power-level-test.patch
  49. 29 0
      package/kernel/mac80211/patches/325-mac80211-unconditionally-start-new-netdev-queues-wit.patch
  50. 38 6
      package/kernel/mac80211/patches/402-ath_regd_optional.patch
  51. 2 2
      package/kernel/mac80211/patches/403-world_regd_fixup.patch
  52. 4 4
      package/kernel/mac80211/patches/406-ath_relax_default_regd.patch
  53. 4 4
      package/kernel/mac80211/patches/600-01-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch
  54. 1 1
      package/kernel/mac80211/patches/600-02-rt2x00-rt2800lib-enable-support-for-RT3883.patch
  55. 2 2
      package/kernel/mac80211/patches/600-03-rt2x00-rt2800lib-add-rf_vals-for-RF3853.patch
  56. 2 2
      package/kernel/mac80211/patches/600-04-rt2x00-rt2800lib-enable-VCO-calibration-for-RF3853.patch
  57. 2 2
      package/kernel/mac80211/patches/600-05-rt2x00-rt2800lib-add-channel-configuration-function-.patch
  58. 1 1
      package/kernel/mac80211/patches/600-06-rt2x00-rt2800lib-enable-RF3853-support.patch
  59. 6 6
      package/kernel/mac80211/patches/600-07-rt2x00-rt2800lib-add-MAC-register-initialization-for.patch
  60. 2 2
      package/kernel/mac80211/patches/600-09-rt2x00-rt2800lib-add-BBP-register-initialization-for.patch
  61. 5 5
      package/kernel/mac80211/patches/600-10-rt2x00-rt2800lib-add-RFCSR-initialization-for-RT3883.patch
  62. 1 1
      package/kernel/mac80211/patches/600-11-rt2x00-rt2800lib-use-the-extended-EEPROM-map-for-RT3.patch
  63. 1 1
      package/kernel/mac80211/patches/600-12-rt2x00-rt2800lib-force-rf-type-to-RF3853-on-RT3883.patch
  64. 8 8
      package/kernel/mac80211/patches/600-13-rt2x00-rt2800lib-add-channel-configuration-code-for-.patch
  65. 1 1
      package/kernel/mac80211/patches/600-14-rt2x00-rt2800lib-fix-txpower_to_dev-function-for-RT3.patch
  66. 3 3
      package/kernel/mac80211/patches/600-15-rt2x00-rt2800lib-use-correct-txpower-calculation-fun.patch
  67. 2 2
      package/kernel/mac80211/patches/600-16-rt2x00-rt2800lib-hardcode-txmixer-gain-values-to-zer.patch
  68. 1 1
      package/kernel/mac80211/patches/600-17-rt2x00-rt2800lib-use-correct-RT-XWI-size-for-RT3883.patch
  69. 1 1
      package/kernel/mac80211/patches/600-18-rt2x00-rt2800lib-fix-antenna-configuration-for-RT388.patch
  70. 2 2
      package/kernel/mac80211/patches/600-19-rt2x00-rt2800lib-fix-LNA-gain-configuration-for-RT38.patch
  71. 3 3
      package/kernel/mac80211/patches/600-20-rt2x00-rt2800lib-fix-VGC-setup-for-RT3883.patch
  72. 3 3
      package/kernel/mac80211/patches/600-21-rt2x00-rt2800lib-fix-EEPROM-LNA-validation-for-RT388.patch
  73. 1 1
      package/kernel/mac80211/patches/600-22-rt2x00-rt2800lib-fix-txpower-compensation-for-RT3883.patch
  74. 1 1
      package/kernel/mac80211/patches/600-23-rt2x00-rt2800mmio-add-a-workaround-for-spurious-TX_F.patch
  75. 8 8
      package/kernel/mac80211/patches/602-rt2x00-introduce-rt2x00eeprom.patch
  76. 2 2
      package/kernel/mac80211/patches/606-rt2x00-allow_disabling_bands_through_platform_data.patch
  77. 1 1
      package/kernel/mac80211/patches/607-rt2x00-add_platform_data_mac_addr.patch
  78. 1 1
      package/kernel/mac80211/patches/608-rt2x00-allow_disabling_bands_through_dts.patch
  79. 1 1
      package/kernel/mac80211/patches/610-rt2x00-change-led-polarity-from-OF.patch
  80. 1 1
      package/kernel/mac80211/patches/611-rt2x00-add-AP+STA-support.patch
  81. 0 20
      package/kernel/mac80211/patches/620-rt2x00-enable-rt2800soc-for-mt7620.patch
  82. 0 1200
      package/kernel/mac80211/patches/621-rt2x00-add-support-for-mt7620.patch
  83. 10 0
      package/kernel/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch
  84. 0 21
      package/kernel/mac80211/patches/801-libertas-configure-sysfs-links.patch
  85. 0 11
      package/kernel/mac80211/patches/802-libertas-set-wireless-macaddr.patch
  86. 0 27
      package/kernel/mac80211/patches/850-brcmsmac-remove-extra-regulation-restriction.patch
  87. 0 97
      package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch
  88. 0 50
      package/kernel/mac80211/patches/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch
  89. 0 27
      package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch
  90. 0 60
      package/kernel/mac80211/patches/863-brcmfmac-add-in-driver-tables-with-country-codes.patch
  91. 0 23
      package/kernel/mac80211/patches/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch
  92. 20 0
      package/kernel/mac80211/patches/940-mwl8k_init_devices_synchronously.patch
  93. 1 1
      package/libs/libmnl/Makefile
  94. 1 2
      package/libs/libnetfilter-conntrack/Makefile
  95. 1 2
      package/libs/libnetfilter-cthelper/Makefile
  96. 1 1
      package/libs/libnetfilter-cttimeout/Makefile
  97. 1 2
      package/libs/libnetfilter-log/Makefile
  98. 1 1
      package/libs/libnfnetlink/Makefile
  99. 7 0
      package/libs/libubox/Makefile
  100. 3 3
      package/libs/mbedtls/Makefile

+ 3 - 3
include/kernel-version.mk

@@ -3,10 +3,10 @@
 LINUX_RELEASE?=1
 
 LINUX_VERSION-3.18 = .43
-LINUX_VERSION-4.4 = .52
+LINUX_VERSION-4.4 = .87
 
-LINUX_KERNEL_HASH-3.18.43 = f61362192b74424539f062a21aa7080f5d66fd8d4cfe2a38f33fab8889bf072c
-LINUX_KERNEL_HASH-4.4.52 = 0f1faafdae47da5f29e740ff655f91c2eb13c8cdfc4d039d903176bd56c2ecbb
+LINUX_KERNEL_HASH-3.18.43 = 1236e8123a6ce537d5029232560966feed054ae31776fe8481dd7d18cdd5492c
+LINUX_KERNEL_HASH-4.4.87 = f2e26505e3aecf622d4f4e1ede44b3b97a38739ad8b78ede14eb354f22d1387a
 
 ifdef KERNEL_PATCHVER
   LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))

+ 1 - 1
package/Makefile

@@ -56,7 +56,7 @@ $(curdir)/merge:
 $(curdir)/merge-index: $(curdir)/merge
 	(cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
 
-$(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/install $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
+$(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/compile $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
 	- find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
 	rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
 	[ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp

+ 3 - 4
package/boot/uboot-ar71xx/Makefile

@@ -9,16 +9,15 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=u-boot
-PKG_VERSION:=2010.03-libre
+PKG_VERSION:=2010.03
 PKG_RELEASE:=1
 
 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_HASH:=902d1b2c15787df55186fae4033685fb0c5a5a12755a08383e97c4a3e255925b
 PKG_SOURCE_URL:= \
-	https://librecmc.org/librecmc/downloads/sources/archive/v1.2.1/ \
+	http://mirror2.openwrt.org/sources \
 	ftp://ftp.denx.de/pub/u-boot
-
-PKG_MD5SUM:=526e01c8564ab8d1fd2c0e787a014b17
 PKG_TARGETS:=bin
 
 PKG_LICENSE:=GPL-2.0 GPL-2.0+

+ 3 - 3
package/boot/uboot-envtools/Makefile

@@ -9,15 +9,15 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uboot-envtools
 PKG_DISTNAME:=u-boot
-PKG_VERSION:=2015.10-librecmc
+PKG_VERSION:=2015.10
 PKG_RELEASE:=1
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/u-boot-$(PKG_VERSION)
 PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=\
-	https://librecmc.org/librecmc/downloads/sources/v1.3.4/ \
+	http://mirror2.openwrt.org/sources \
 	ftp://ftp.denx.de/pub/u-boot
-PKG_MD5SUM:=5e60d710ce19d2cd20c197ade9bbbc72
+PKG_HASH:=bdc68d5f9455ad933b059c735d983f2c8b6b552dafb062e5ff1444f623021955
 
 PKG_BUILD_DEPENDS:=+fstools
 

+ 47 - 40
package/boot/uboot-envtools/files/ar71xx

@@ -14,53 +14,60 @@ touch /etc/config/ubootenv
 board=$(ar71xx_board_name)
 
 case "$board" in
-alfa-ap120c | \
-all0258n | \
-ap90q | \
-cap324 | \
-cap4200ag | \
-carambola2 | \
-cpe830 | \
-cpe870 | \
-cr3000 | \
-cr5000 | \
-eap300v2 | \
-gl-ar300m | \
-hornet-ub | \
-hornet-ub-x2 | \
-jwap230 | \
-mr1750 | \
-mr1750v2 | \
-mr600 | \
-mr600v2 | \
-mr900 | \
-mr900v2 | \
-nbg6716 | \
-om5p-an | \
-om5p-ac | \
-om5p-acv2 | \
-om5p | \
-tube2h | \
-wndr3700)
+a40|\
+a60|\
+alfa-ap120c|\
+all0258n|\
+ap121f|\
+ap90q|\
+cap324|\
+cap4200ag|\
+carambola2|\
+cpe830|\
+cpe870|\
+cr3000|\
+cr5000|\
+eap300v2|\
+gl-ar300m|\
+hornet-ub|\
+hornet-ub-x2|\
+jwap230|\
+mr1750|\
+mr1750v2|\
+mr600|\
+mr600v2|\
+mr900|\
+mr900v2|\
+nbg6716|\
+om5p|\
+om5p-ac|\
+om5p-acv2|\
+om5p-an|\
+sr3200|\
+tube2h|\
+wndr3700|\
+xd3200)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
 	;;
-alfa-ap96 | \
-all0315n | \
-om2p | \
-om2pv2 | \
-om2p-hs | \
-om2p-hsv2 | \
-om2p-hsv3 | \
-om2p-lc)
+alfa-ap96|\
+all0315n|\
+om2p|\
+om2p-hs|\
+om2p-hsv2|\
+om2p-hsv3|\
+om2p-hsv4|\
+om2p-lc|\
+om2pv2|\
+om2pv4)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000"
 	;;
-dr531)
-	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0xf800" "0x10000"
-	;;
-dap-2695-a1 | \
+dap-2695-a1|\
 wzr-hp-ag300h)
 	ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x10000"
 	;;
+dr531)
+	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0xf800" "0x10000"
+	;;
 qihoo-c301)
 	ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x10000" "0x10000"
 	;;

+ 1 - 1
package/boot/uboot-envtools/files/imx6

@@ -25,7 +25,7 @@ case "$board" in
 		ubootenv_add_uci_config /dev/mmcblk0 0xd1400 0x20000 0x20000
 	fi
 	;;
-"wandboard")
+wandboard)
 	ubootenv_add_uci_config "/dev/mmcblk0" "0x60000" "0x2000" "0x2000"
 	;;
 esac

+ 2 - 3
package/boot/uboot-envtools/files/ipq

@@ -13,12 +13,11 @@ touch /etc/config/ubootenv
 
 board=$(ipq806x_board_name)
 
-
 case "$board" in
-"ea8500")
+ea8500)
 	ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
 	;;
-"nbg6817")
+nbg6817)
 	ubootenv_add_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
 	;;
 esac

+ 8 - 8
package/boot/uboot-envtools/files/kirkwood

@@ -14,16 +14,16 @@ touch /etc/config/ubootenv
 board=$(kirkwood_board_name)
 
 case "$board" in
-"dockstar" | \
-"guruplug-server-plus" | \
-"ib62x0" | \
-"linksys-viper" | \
-"pogo_e02" | \
-"sheevaplug" | \
-"sheevaplug-esata" )
+dockstar|\
+guruplug-server-plus|\
+ib62x0|\
+linksys-viper|\
+pogo_e02|\
+sheevaplug|\
+sheevaplug-esata)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
 	;;
-"linksys-audi")
+linksys-audi)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x4000" "0x4000"
 	;;
 esac

+ 3 - 3
package/boot/uboot-envtools/files/lantiq

@@ -14,15 +14,15 @@ touch /etc/config/ubootenv
 board=$(lantiq_board_name)
 
 case "$board" in
-GIGASX76X)
-	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
-	;;
 BTHOMEHUBV2B)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
 	;;
 BTHOMEHUBV3A)
 	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x4000" "0x4000" "1"
 	;;
+GIGASX76X)
+	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
+	;;
 P2812HNUF1)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x2000" "0x20000" "1"
 	;;

+ 3 - 1
package/boot/uboot-envtools/files/mvebu

@@ -15,7 +15,9 @@ touch /etc/config/ubootenv
 board=$(mvebu_board_name)
 
 case "$board" in
-armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby)
+armada-385-linksys-caiman|\
+armada-385-linksys-cobra|\
+armada-385-linksys-shelby)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x40000"
 	;;
 armada-385-linksys-rango)

+ 3 - 3
package/boot/uboot-envtools/files/oxnas

@@ -14,9 +14,9 @@ touch /etc/config/ubootenv
 board=$(oxnas_board_name)
 
 case "$board" in
-akitio | \
-stg212 | \
-kd20)
+akitio|\
+kd20|\
+stg212)
 	ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x4000" "0x1F000" "1"
 	ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x4000" "0x1F000" "1"
 	;;

+ 9 - 9
package/boot/uboot-envtools/files/ramips

@@ -14,18 +14,18 @@ touch /etc/config/ubootenv
 board=$(ramips_board_name)
 
 case "$board" in
-all0239-3g | \
-all0256n | \
+all0239-3g|\
+all0256n|\
 all5002)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
 	;;
-linkits7688 | \
-linkits7688d | \
-wsr-600 | \
-wsr-1166 | \
-br6425 | \
-miwifi-nano | \
-sk-wb8 | \
+br-6425|\
+linkits7688|\
+linkits7688d|\
+miwifi-nano|\
+sk-wb8|\
+wsr-1166|\
+wsr-600|\
 zbt-wg2626)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
 	;;

+ 52 - 142
package/boot/uboot-sunxi/Makefile

@@ -1,5 +1,6 @@
 #
 # Copyright (C) 2013-2016 OpenWrt.org
+# Copyright (C) 2017 Yousong Zhou
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -11,178 +12,87 @@ include $(INCLUDE_DIR)/kernel.mk
 PKG_NAME:=u-boot
 PKG_VERSION:=2016.03
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
-PKG_SOURCE_URL:= \
-	http://mirror2.openwrt.org/sources \
-	ftp://ftp.denx.de/pub/u-boot
-
-PKG_MD5SUM:=973c1d896be751321cc3aafa564f64b2
-
-PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
-
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_HASH:=e49337262ecac44dbdeac140f2c6ebd1eba345e0162b0464172e7f05583ed7bb
+PKG_MAINTAINER:=Zoltan HERPAI <wigyori@uid0.hu>
 PKG_LICENSE:=GPL-2.0 GPL-2.0+
 PKG_LICENSE_FILES:=Licenses/README
 
-include $(INCLUDE_DIR)/package.mk
-
-define uboot/Default
-  TITLE:=
-  CONFIG:=
-  IMAGE:=
-endef
-
-define uboot/A10-OLinuXino-Lime
-  TITLE:=U-Boot for the A10 OLinuXino LIME
-endef
-
-define uboot/A13-OLinuXino
-  TITLE:=U-Boot for the A13 OlinuXino
-endef
-
-define uboot/A20-OLinuXino-Lime
-  TITLE:=U-Boot for the A20 OLinuXino LIME
-endef
-
-define uboot/A20-OLinuXino_MICRO
-  TITLE:=U-Boot for A20 OLinuXino MICRO
-endef
+PKG_BUILD_PARALLEL:=1
 
-define uboot/Bananapi
-  TITLE:=U-Boot for Bananapi
-endef
-
-define uboot/Bananapro
-  TITLE:=U-Boot for Bananapro
-endef
-
-define uboot/Cubieboard
-  TITLE:=U-Boot for Cubieboard
-endef
-
-define uboot/Cubieboard2
-  TITLE:=U-Boot for Cubieboard2
-endef
-
-define uboot/Cubietruck
-  TITLE:=U-Boot for Cubietruck
-endef
-
-define uboot/Hummingbird_A31
-  TITLE:=U-Boot for the Hummingbird A31 board
-endef
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
 
-define uboot/Mele_M9
-  TITLE:=U-Boot for the Mele M9 (A31)
-endef
+include $(INCLUDE_DIR)/package.mk
 
-define uboot/OLIMEX_A13_SOM
-  TITLE:=U-Boot for the Olimex A13 SOM
+define Package/uboot/template
+define Package/uboot-sunxi-$(1)
+  SECTION:=boot
+  CATEGORY:=Boot Loaders
+  DEPENDS:=@TARGET_sunxi
+  TITLE:=U-Boot for $(2)
+  URL:=http://www.denx.de/wiki/U-Boot
+  VARIANT:=$(1)
 endef
 
-define uboot/Linksprite_pcDuino
-  TITLE:=U-Boot for Linksprite pcDuino
-endef  
-
-define uboot/Linksprite_pcDuino3
-  TITLE:=U-Boot for Linksprite pcDuino3
-endef  
-
-define uboot/Lamobo_R1
-  TITLE:=U-Boot for Lamobo R1
+define Package/uboot-sunxi-$(1)/install
+	$(CP) $(PKG_BUILD_DIR)/u-boot-sunxi-with-spl.bin \
+		$(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-u-boot-with-spl.bin
+	mkimage -C none -A arm -T script -d uEnv-$(if $(3),$(3),default).txt \
+		$(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-boot.scr
 endef
 
-define uboot/pangolin
-  TITLE:=U-Boot for Theobroma A31-yQ7 devboard
-endef
+UBOOT_SUNXI_PACKAGES += uboot-sunxi-$(1)
 
-define uboot/orangepi_plus
-  TITLE:=U-Boot for Orange Pi Plus (H3)
 endef
 
-UBOOTS:= \
-	A10-OLinuXino-Lime \
-	A13-OLinuXino \
-	A20-OLinuXino-Lime \
-	A20-OLinuXino_MICRO \
-	Bananapi \
-	Bananapro \
-	Cubieboard \
-	Cubieboard2 \
-	Cubietruck \
-	Hummingbird_A31 \
-	Mele_M9 \
-	OLIMEX_A13_SOM \
-	Linksprite_pcDuino \
-	Linksprite_pcDuino3 \
-	Lamobo_R1 \
-	orangepi_plus \
-	pangolin
+$(eval $(call Package/uboot/template,A10-OLinuXino-Lime,the A10 OLinuXino LIME))
+$(eval $(call Package/uboot/template,A13-OLinuXino,the A13 OlinuXino))
+$(eval $(call Package/uboot/template,A20-OLinuXino-Lime,the A20 OLinuXino LIME))
+$(eval $(call Package/uboot/template,A20-OLinuXino_MICRO,A20 OLinuXino MICRO))
+$(eval $(call Package/uboot/template,Bananapi,Bananapi))
+$(eval $(call Package/uboot/template,Bananapro,Bananapro))
+$(eval $(call Package/uboot/template,Cubieboard,Cubieboard))
+$(eval $(call Package/uboot/template,Cubieboard2,Cubieboard2))
+$(eval $(call Package/uboot/template,Cubietruck,Cubietruck))
+$(eval $(call Package/uboot/template,Hummingbird_A31,the Hummingbird A31 board))
+$(eval $(call Package/uboot/template,Mele_M9,the Mele M9 (A31)))
+$(eval $(call Package/uboot/template,OLIMEX_A13_SOM,the Olimex A13 SOM))
+$(eval $(call Package/uboot/template,Linksprite_pcDuino,Linksprite pcDuino))
+$(eval $(call Package/uboot/template,Linksprite_pcDuino3,Linksprite pcDuino3))
+$(eval $(call Package/uboot/template,Lamobo_R1,Lamobo R1))
+$(eval $(call Package/uboot/template,orangepi_plus,Orange Pi Plus (H3)))
+$(eval $(call Package/uboot/template,pangolin,Theobroma A31-yQ7 devboard,pangolin))
 
-define Package/uboot/template
-define Package/uboot-sunxi-$(1)
+define Package/uboot-sunxi-all
   SECTION:=boot
   CATEGORY:=Boot Loaders
   DEPENDS:=@TARGET_sunxi
-  TITLE:=$(2)
+  TITLE:=Meta package for selecting all variants of uboot-sunxi
   URL:=http://www.denx.de/wiki/U-Boot
-  VARIANT:=$(1)
-  MAINTAINER:=Zoltan HERPAI <wigyori@uid0.hu>
-endef
-endef
-
-define BuildUBootPackage
-	$(eval $(uboot/Default))
-	$(eval $(uboot/$(1)))
-	$(call Package/uboot/template,$(1),$(TITLE))
+  DEPENDS:=$(patsubst %,+%,$(UBOOT_SUNXI_PACKAGES))
 endef
 
 ifdef BUILD_VARIANT
-$(eval $(call uboot/$(BUILD_VARIANT)))
-UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
-UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
-endif
-
-# check if any specialized uEnv bootconfig is required
-ifeq ($(UBOOT_CONFIG),pangolin)
-	UENV:=pangolin
-else
-	UENV:=default
-endif
-
 define Build/Configure
-	$(MAKE) -C $(PKG_BUILD_DIR) \
-		USE_PRIVATE_LIBGCC=yes $(UBOOT_CONFIG)_defconfig
+	+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+		USE_PRIVATE_LIBGCC=yes $(BUILD_VARIANT)_defconfig
 endef
 
 define Build/Compile
-	$(MAKE) -C $(PKG_BUILD_DIR) \
+	+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
 		CROSS_COMPILE=$(TARGET_CROSS) \
 		DTCDIR=$(LINUX_DIR)/scripts/dtc/
 endef
-
-define Package/uboot/install/default
-	$(CP) $(PKG_BUILD_DIR)/u-boot.bin \
-		$(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-u-boot.bin
-	$(CP) $(PKG_BUILD_DIR)/spl/sunxi-spl.bin \
-		$(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-spl.bin
-	$(CP) $(PKG_BUILD_DIR)/u-boot-sunxi-with-spl.bin \
-		$(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-u-boot-with-spl.bin
-	$(CP) uEnv-$(UENV).txt \
-		$(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-uEnv.txt
-	mkimage -C none -A arm -T script -d $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-uEnv.txt \
-		$(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-boot.scr
+else	# BUILD_VARIANT
+define Build/Prepare
 endef
-
-define Package/uboot/install/template
-define Package/uboot-sunxi-$(1)/install
-	$(call Package/uboot/install/default,$(2))
+define Build/Configure
 endef
+define Build/Compile
 endef
+endif	# BUILD_VARIANT
 
-$(foreach u,$(UBOOTS), \
-	$(eval $(call Package/uboot/install/template,$(u),$(u))) \
-)
-
-$(foreach u,$(UBOOTS), \
-	$(eval $(call BuildUBootPackage,$(u))) \
-	$(eval $(call BuildPackage,uboot-sunxi-$(u))) \
+$(foreach pkg,$(UBOOT_SUNXI_PACKAGES), \
+  $(eval $(call BuildPackage,$(pkg))) \
 )
+$(eval $(call BuildPackage,uboot-sunxi-all))

+ 4 - 5
package/boot/uboot-xburst/Makefile

@@ -9,16 +9,15 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=u-boot
-PKG_VERSION:=2012.10-rc2-libre
+PKG_VERSION:=2012.10-rc2
 PKG_RELEASE:=1
 
 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:= \
-	https://librecmc.org/librecmc/downloads/sources/archive/ \
-
-
-PKG_MD5SUM:=ffd6e3795d221bc43c70bed97c919f70
+	http://mirror2.openwrt.org/sources \
+	ftp://ftp.denx.de/pub/u-boot
+PKG_HASH:=6d094cafa7ecea8b671fbdcd21130b6a4f5744fc47dd263e101ed5d3629dffd4
 PKG_TARGETS:=bin
 
 PKG_LICENSE:=GPL-2.0 GPL-2.0+

+ 65 - 0
package/devel/binutils/patches/0001-Do-not-pass-host-compiler-sanitization-flags-on-to-l.patch

@@ -0,0 +1,65 @@
+From 183eb37e25d903ccd68cc2d8f8a37e75872c03d2 Mon Sep 17 00:00:00 2001
+From: Nick Clifton <nickc@redhat.com>
+Date: Tue, 6 Sep 2016 17:35:35 +0100
+Subject: [PATCH 1/2] Do not pass host compiler sanitization flags on to linker
+ testsuite.
+
+	* Makefile.am (CFLAGS_FOR_TARGET): Define as a copy of CFLAGS but
+	without any sanitization options.
+	(CXXFLAGS_FOR_TARGET): Define as a copy of CXXFLAGS but	without
+	any sanitization options.
+	(check-DEJAGNU): Pass CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET
+	as CFLAGS and CXXFLAGS respectively.
+---
+ ld/Makefile.am | 8 ++++++--
+ ld/Makefile.in | 8 ++++++--
+ 2 files changed, 12 insertions(+), 4 deletions(-)
+
+--- a/ld/Makefile.am
++++ b/ld/Makefile.am
+@@ -136,6 +136,10 @@ CXX_FOR_TARGET = ` \
+     fi; \
+   fi`
+ 
++# Strip out sanitization options as we want to test building binaries without any extra paraphernalia
++CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
++CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
++
+ transform = s/^ld-new$$/$(installed_linker)/;@program_transform_name@
+ bin_PROGRAMS = ld-new
+ info_TEXINFOS = ld.texinfo
+@@ -2075,8 +2079,8 @@ check-DEJAGNU: site.exp
+ 	runtest=$(RUNTEST); \
+ 	if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+ 	  $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
+-		CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS)" \
+-		CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS)" \
++		CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS_FOR_TARGET)" \
++		CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+ 		CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \
+ 		OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" \
+ 		LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \
+--- a/ld/Makefile.in
++++ b/ld/Makefile.in
+@@ -507,6 +507,10 @@ CXX_FOR_TARGET = ` \
+     fi; \
+   fi`
+ 
++
++# Strip out sanitization options as they require special host libraries.
++CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
++CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
+ info_TEXINFOS = ld.texinfo
+ ld_TEXINFOS = configdoc.texi
+ noinst_TEXINFOS = ldint.texinfo
+@@ -3644,8 +3648,8 @@ check-DEJAGNU: site.exp
+ 	runtest=$(RUNTEST); \
+ 	if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+ 	  $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
+-		CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS)" \
+-		CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS)" \
++		CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS_FOR_TARGET)" \
++		CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+ 		CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \
+ 		OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" \
+ 		LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \

+ 1258 - 0
package/devel/binutils/patches/0002-When-building-target-binaries-ensure-that-the-warnin.patch

@@ -0,0 +1,1258 @@
+From b8ff24c72174effd5c5527866313982e28507275 Mon Sep 17 00:00:00 2001
+From: Vlad Zakharov <vzakhar@synopsys.com>
+Date: Mon, 26 Sep 2016 16:36:08 +0100
+Subject: [PATCH 2/2] When building target binaries, ensure that the warning
+ flags selected for the command line match the target compiler.
+
+bfd	* warning.m4 (AC_EGREP_CPP_FOR_BUILD): Introduce macro
+	to verify CC_FOR_BUILD compiler.
+	(AM_BINUTILS_WARNINGS): Introduce ac_cpp_for_build variable
+	and add CC_FOR_BUILD compiler checks.
+	* Makefile.in: Regenerate.
+	* configure: Likewise.
+	* doc/Makefile.in: Likewise.
+
+binutils	* Makefile.am: Replace AM_CLFAGS with AM_CFLAGS_FOR_BUILD
+	when building with CC_FOR_BUILD compiler.
+	* Makefile.in: Regenerate.
+	* configure: Likewise.
+	* doc/Makefile.in: Likewise.
+
+gas	* Makefile.in: Regenerate.
+	* configure: Likewise.
+	* doc/Makefile.in: Likewise.
+
+gold	* Makefile.in: Regenerate.
+	* configure: Likewise.
+	* testsuite/Makefile.in: Likewise.
+
+gprof	* Makefile.in: Regenerate.
+	* configure: Likewise.
+
+ld	* Makefile.in: Regenerate.
+	* configure: Likewise.
+
+opcodes	* Makefile.in: Regenerate.
+	* configure: Likewise.
+---
+ bfd/Makefile.in            |  1 +
+ bfd/configure              | 56 +++++++++++++++++++++++++++++++++++++++++-----
+ bfd/doc/Makefile.in        |  1 +
+ bfd/warning.m4             | 47 ++++++++++++++++++++++++++++++++++----
+ binutils/Makefile.am       | 10 +++++----
+ binutils/Makefile.in       | 10 +++++----
+ binutils/configure         | 56 +++++++++++++++++++++++++++++++++++++++++-----
+ binutils/doc/Makefile.in   |  1 +
+ gas/Makefile.in            |  1 +
+ gas/configure              | 56 +++++++++++++++++++++++++++++++++++++++++-----
+ gas/doc/Makefile.in        |  1 +
+ gold/Makefile.in           |  5 +++--
+ gold/configure             | 52 ++++++++++++++++++++++++++++++++++++++----
+ gold/testsuite/Makefile.in |  1 +
+ gprof/Makefile.in          |  1 +
+ gprof/configure            | 56 +++++++++++++++++++++++++++++++++++++++++-----
+ ld/Makefile.in             |  3 ++-
+ ld/configure               | 56 +++++++++++++++++++++++++++++++++++++++++-----
+ opcodes/Makefile.in        |  1 +
+ opcodes/configure          | 56 +++++++++++++++++++++++++++++++++++++++++-----
+ 20 files changed, 416 insertions(+), 55 deletions(-)
+
+--- a/bfd/Makefile.in
++++ b/bfd/Makefile.in
+@@ -288,6 +288,7 @@ TDEFINES = @TDEFINES@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ abs_builddir = @abs_builddir@
+--- a/bfd/configure
++++ b/bfd/configure
+@@ -659,6 +659,7 @@ MAINTAINER_MODE_FALSE
+ MAINTAINER_MODE_TRUE
+ WARN_WRITE_STRINGS
+ NO_WERROR
++WARN_CFLAGS_FOR_BUILD
+ WARN_CFLAGS
+ REPORT_BUGS_TEXI
+ REPORT_BUGS_TO
+@@ -11427,7 +11428,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11430 "configure"
++#line 11431 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11533,7 +11534,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11536 "configure"
++#line 11537 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -12240,8 +12241,12 @@ fi
+ # Set the 'development' global.
+ . $srcdir/../bfd/development.sh
+ 
++# Set acp_cpp_for_build variable
++ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
++
+ # Default set of GCC warnings to enable.
+ GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
++GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
+ 
+ # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -12286,6 +12291,36 @@ fi
+ rm -f conftest*
+ 
+ 
++# Verify CC_FOR_BUILD to be compatible with waring flags
++
++# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-3]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow"
++fi
++rm -f conftest*
++
++
++# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-4]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144"
++fi
++rm -f conftest*
++
++
+ # Check whether --enable-werror was given.
+ if test "${enable_werror+set}" = set; then :
+   enableval=$enable_werror; case "${enableval}" in
+@@ -12301,6 +12336,7 @@ case "${host}" in
+   *-*-mingw32*)
+     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
++      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
+     fi
+     ;;
+   *) ;;
+@@ -12314,25 +12350,32 @@ fi
+ NO_WERROR=
+ if test "${ERROR_ON_WARNING}" = yes ; then
+     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
++    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
+     NO_WERROR="-Wno-error"
+ fi
+ 
+ if test "${GCC}" = yes ; then
+   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
+ fi
+ 
+ # Check whether --enable-build-warnings was given.
+ if test "${enable_build_warnings+set}" = set; then :
+   enableval=$enable_build_warnings; case "${enableval}" in
+-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
++  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
+   no)	if test "${GCC}" = yes ; then
+ 	  WARN_CFLAGS="-w"
++      WARN_CFLAGS_FOR_BUILD="-w"
+ 	fi;;
+   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
++        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
+   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
+-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
++        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
++  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
++        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac
+ fi
+ 
+@@ -12343,6 +12386,7 @@ fi
+ 
+ 
+ 
++
+ 
+ 
+ 
+--- a/bfd/doc/Makefile.in
++++ b/bfd/doc/Makefile.in
+@@ -248,6 +248,7 @@ TDEFINES = @TDEFINES@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ abs_builddir = @abs_builddir@
+--- a/bfd/warning.m4
++++ b/bfd/warning.m4
+@@ -17,12 +17,34 @@ dnl along with this program; see the fil
+ dnl <http://www.gnu.org/licenses/>.
+ dnl
+ 
++# AC_EGREP_CPP_FOR_BUILD(PATTERN, PROGRAM,
++#              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++# ------------------------------------------------------
++AC_DEFUN([AC_EGREP_CPP_FOR_BUILD],
++[AC_LANG_PREPROC_REQUIRE()dnl
++AC_REQUIRE([AC_PROG_EGREP])dnl
++AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
++AS_IF([dnl eval is necessary to expand ac_cpp.
++dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
++(eval "$ac_cpp_for_build conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
++dnl Quote $1 to prevent m4 from eating character classes
++  $EGREP "[$1]" >/dev/null 2>&1],
++  [$3],
++  [$4])
++rm -f conftest*
++])# AC_EGREP_CPP_FOR_BUILD
++
++
+ AC_DEFUN([AM_BINUTILS_WARNINGS],[
+ # Set the 'development' global.
+ . $srcdir/../bfd/development.sh
+ 
++# Set acp_cpp_for_build variable
++ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
++
+ # Default set of GCC warnings to enable.
+ GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
++GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
+ 
+ # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
+ AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow")
+@@ -34,6 +56,14 @@ AC_EGREP_CPP([^[0-4]$],[__GNUC__],,GCC_W
+ WARN_WRITE_STRINGS=""
+ AC_EGREP_CPP([^[0-3]$],[__GNUC__],,WARN_WRITE_STRINGS="-Wwrite-strings")
+ 
++# Verify CC_FOR_BUILD to be compatible with waring flags
++
++# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
++AC_EGREP_CPP_FOR_BUILD([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow")
++
++# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
++AC_EGREP_CPP_FOR_BUILD([^[0-4]$],[__GNUC__],,GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144")
++
+ AC_ARG_ENABLE(werror,
+   [  --enable-werror         treat compile warnings as errors],
+   [case "${enableval}" in
+@@ -47,6 +77,7 @@ case "${host}" in
+   *-*-mingw32*)
+     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
++      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
+     fi
+     ;;
+   *) ;;
+@@ -60,25 +91,32 @@ fi
+ NO_WERROR=
+ if test "${ERROR_ON_WARNING}" = yes ; then
+     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
++    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
+     NO_WERROR="-Wno-error"
+ fi
+ 
+ if test "${GCC}" = yes ; then
+   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
+ fi
+ 
+ AC_ARG_ENABLE(build-warnings,
+ [  --enable-build-warnings enable build-time compiler warnings],
+ [case "${enableval}" in
+-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
++  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}" 
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
+   no)	if test "${GCC}" = yes ; then
+ 	  WARN_CFLAGS="-w"
++      WARN_CFLAGS_FOR_BUILD="-w" 
+ 	fi;;
+   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
++        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
+   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
+-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
++        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
++  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
++        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac])
+ 
+ if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
+@@ -86,6 +124,7 @@ if test x"$silent" != x"yes" && test x"$
+ fi
+ 
+ AC_SUBST(WARN_CFLAGS)
++AC_SUBST(WARN_CFLAGS_FOR_BUILD)
+ AC_SUBST(NO_WERROR)
+      AC_SUBST(WARN_WRITE_STRINGS)
+ ])
+--- a/binutils/Makefile.am
++++ b/binutils/Makefile.am
+@@ -47,8 +47,10 @@ ZLIB = @zlibdir@ -lz
+ ZLIBINC = @zlibinc@
+ 
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ NO_WERROR = @NO_WERROR@
+ AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
++AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC)
+ LIBICONV = @LIBICONV@
+ 
+ # these two are almost the same program
+@@ -305,17 +307,17 @@ sysinfo$(EXEEXT_FOR_BUILD): sysinfo.@OBJ
+ 	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@
+ 
+ syslex_wrap.@OBJEXT@: syslex_wrap.c syslex.c sysinfo.h config.h
+-	$(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c
++	$(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c
+ 
+ sysinfo.@OBJEXT@: sysinfo.c
+ 	if [ -r sysinfo.c ]; then \
+-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
++	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
+ 	else \
+-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
++	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
+ 	fi
+ 
+ bin2c$(EXEEXT_FOR_BUILD): bin2c.c
+-	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c
++	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c
+ 
+ embedspu: embedspu.sh Makefile
+ 	awk '/^program_transform_name=/ {print "program_transform_name=\"$(program_transform_name)\""; next} {print}' < $< > $@
+--- a/binutils/Makefile.in
++++ b/binutils/Makefile.in
+@@ -401,6 +401,7 @@ STRIP = @STRIP@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ YACC = `if [ -f ../bison/bison ]; then echo ../bison/bison -y -L$(srcdir)/../bison/; else echo @YACC@; fi`
+@@ -478,6 +479,7 @@ am__skipyacc =
+ ZLIB = @zlibdir@ -lz
+ ZLIBINC = @zlibinc@
+ AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
++AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) $(ZLIBINC)
+ 
+ # these two are almost the same program
+ AR_PROG = ar
+@@ -1370,17 +1372,17 @@ sysinfo$(EXEEXT_FOR_BUILD): sysinfo.@OBJ
+ 	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.@OBJEXT@ syslex_wrap.@OBJEXT@
+ 
+ syslex_wrap.@OBJEXT@: syslex_wrap.c syslex.c sysinfo.h config.h
+-	$(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c
++	$(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex_wrap.c
+ 
+ sysinfo.@OBJEXT@: sysinfo.c
+ 	if [ -r sysinfo.c ]; then \
+-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
++	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
+ 	else \
+-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
++	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
+ 	fi
+ 
+ bin2c$(EXEEXT_FOR_BUILD): bin2c.c
+-	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c
++	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c
+ 
+ embedspu: embedspu.sh Makefile
+ 	awk '/^program_transform_name=/ {print "program_transform_name=\"$(program_transform_name)\""; next} {print}' < $< > $@
+--- a/binutils/configure
++++ b/binutils/configure
+@@ -652,6 +652,7 @@ YFLAGS
+ YACC
+ WARN_WRITE_STRINGS
+ NO_WERROR
++WARN_CFLAGS_FOR_BUILD
+ WARN_CFLAGS
+ OTOOL64
+ OTOOL
+@@ -11225,7 +11226,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11228 "configure"
++#line 11229 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11331,7 +11332,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11334 "configure"
++#line 11335 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11945,8 +11946,12 @@ _ACEOF
+ # Set the 'development' global.
+ . $srcdir/../bfd/development.sh
+ 
++# Set acp_cpp_for_build variable
++ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
++
+ # Default set of GCC warnings to enable.
+ GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
++GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
+ 
+ # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -11991,6 +11996,36 @@ fi
+ rm -f conftest*
+ 
+ 
++# Verify CC_FOR_BUILD to be compatible with waring flags
++
++# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-3]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow"
++fi
++rm -f conftest*
++
++
++# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-4]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144"
++fi
++rm -f conftest*
++
++
+ # Check whether --enable-werror was given.
+ if test "${enable_werror+set}" = set; then :
+   enableval=$enable_werror; case "${enableval}" in
+@@ -12006,6 +12041,7 @@ case "${host}" in
+   *-*-mingw32*)
+     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
++      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
+     fi
+     ;;
+   *) ;;
+@@ -12019,25 +12055,32 @@ fi
+ NO_WERROR=
+ if test "${ERROR_ON_WARNING}" = yes ; then
+     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
++    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
+     NO_WERROR="-Wno-error"
+ fi
+ 
+ if test "${GCC}" = yes ; then
+   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
+ fi
+ 
+ # Check whether --enable-build-warnings was given.
+ if test "${enable_build_warnings+set}" = set; then :
+   enableval=$enable_build_warnings; case "${enableval}" in
+-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
++  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
+   no)	if test "${GCC}" = yes ; then
+ 	  WARN_CFLAGS="-w"
++      WARN_CFLAGS_FOR_BUILD="-w"
+ 	fi;;
+   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
++        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
+   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
+-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
++        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
++  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
++        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac
+ fi
+ 
+@@ -12048,6 +12091,7 @@ fi
+ 
+ 
+ 
++
+ 
+ 
+ 
+--- a/binutils/doc/Makefile.in
++++ b/binutils/doc/Makefile.in
+@@ -249,6 +249,7 @@ STRIP = @STRIP@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ YACC = @YACC@
+--- a/gas/Makefile.in
++++ b/gas/Makefile.in
+@@ -255,6 +255,7 @@ STRIP = @STRIP@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@ @WARN_WRITE_STRINGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ YACC = `if [ -f ../bison/bison ] ; then echo ../bison/bison -y -L../bison/bison ; else echo @YACC@ ; fi`
+--- a/gas/configure
++++ b/gas/configure
+@@ -642,6 +642,7 @@ cgen_cpu_prefix
+ GDBINIT
+ WARN_WRITE_STRINGS
+ NO_WERROR
++WARN_CFLAGS_FOR_BUILD
+ WARN_CFLAGS
+ OTOOL64
+ OTOOL
+@@ -10985,7 +10986,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 10988 "configure"
++#line 10989 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11091,7 +11092,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11094 "configure"
++#line 11095 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11721,8 +11722,12 @@ using_cgen=no
+ # Set the 'development' global.
+ . $srcdir/../bfd/development.sh
+ 
++# Set acp_cpp_for_build variable
++ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
++
+ # Default set of GCC warnings to enable.
+ GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
++GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
+ 
+ # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -11767,6 +11772,36 @@ fi
+ rm -f conftest*
+ 
+ 
++# Verify CC_FOR_BUILD to be compatible with waring flags
++
++# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-3]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow"
++fi
++rm -f conftest*
++
++
++# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-4]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144"
++fi
++rm -f conftest*
++
++
+ # Check whether --enable-werror was given.
+ if test "${enable_werror+set}" = set; then :
+   enableval=$enable_werror; case "${enableval}" in
+@@ -11782,6 +11817,7 @@ case "${host}" in
+   *-*-mingw32*)
+     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
++      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
+     fi
+     ;;
+   *) ;;
+@@ -11795,25 +11831,32 @@ fi
+ NO_WERROR=
+ if test "${ERROR_ON_WARNING}" = yes ; then
+     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
++    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
+     NO_WERROR="-Wno-error"
+ fi
+ 
+ if test "${GCC}" = yes ; then
+   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
+ fi
+ 
+ # Check whether --enable-build-warnings was given.
+ if test "${enable_build_warnings+set}" = set; then :
+   enableval=$enable_build_warnings; case "${enableval}" in
+-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
++  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
+   no)	if test "${GCC}" = yes ; then
+ 	  WARN_CFLAGS="-w"
++      WARN_CFLAGS_FOR_BUILD="-w"
+ 	fi;;
+   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
++        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
+   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
+-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
++        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
++  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
++        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac
+ fi
+ 
+@@ -11824,6 +11867,7 @@ fi
+ 
+ 
+ 
++
+ 
+ 
+ 
+--- a/gas/doc/Makefile.in
++++ b/gas/doc/Makefile.in
+@@ -230,6 +230,7 @@ STRIP = @STRIP@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ YACC = @YACC@
+--- a/gold/Makefile.in
++++ b/gold/Makefile.in
+@@ -87,8 +87,8 @@ subdir = .
+ DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
+ 	$(srcdir)/Makefile.am $(top_srcdir)/configure \
+ 	$(am__configure_deps) $(srcdir)/config.in \
+-	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in \
+-	ftruncate.c pread.c mremap.c ffsll.c yyscript.h yyscript.c \
++	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in ffsll.c \
++	mremap.c ftruncate.c pread.c yyscript.h yyscript.c \
+ 	$(srcdir)/../depcomp $(srcdir)/../ylwrap
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+@@ -409,6 +409,7 @@ TARGETOBJS = @TARGETOBJS@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_CXXFLAGS = @WARN_CXXFLAGS@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+--- a/gold/configure
++++ b/gold/configure
+@@ -609,6 +609,7 @@ GOLD_LDFLAGS
+ WARN_CXXFLAGS
+ WARN_WRITE_STRINGS
+ NO_WERROR
++WARN_CFLAGS_FOR_BUILD
+ WARN_CFLAGS
+ IFUNC_STATIC_FALSE
+ IFUNC_STATIC_TRUE
+@@ -6723,8 +6724,12 @@ fi
+ # Set the 'development' global.
+ . $srcdir/../bfd/development.sh
+ 
++# Set acp_cpp_for_build variable
++ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
++
+ # Default set of GCC warnings to enable.
+ GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
++GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
+ 
+ # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -6769,6 +6774,36 @@ fi
+ rm -f conftest*
+ 
+ 
++# Verify CC_FOR_BUILD to be compatible with waring flags
++
++# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-3]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow"
++fi
++rm -f conftest*
++
++
++# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-4]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144"
++fi
++rm -f conftest*
++
++
+ # Check whether --enable-werror was given.
+ if test "${enable_werror+set}" = set; then :
+   enableval=$enable_werror; case "${enableval}" in
+@@ -6784,6 +6819,7 @@ case "${host}" in
+   *-*-mingw32*)
+     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
++      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
+     fi
+     ;;
+   *) ;;
+@@ -6797,25 +6833,32 @@ fi
+ NO_WERROR=
+ if test "${ERROR_ON_WARNING}" = yes ; then
+     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
++    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
+     NO_WERROR="-Wno-error"
+ fi
+ 
+ if test "${GCC}" = yes ; then
+   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
+ fi
+ 
+ # Check whether --enable-build-warnings was given.
+ if test "${enable_build_warnings+set}" = set; then :
+   enableval=$enable_build_warnings; case "${enableval}" in
+-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
++  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
+   no)	if test "${GCC}" = yes ; then
+ 	  WARN_CFLAGS="-w"
++      WARN_CFLAGS_FOR_BUILD="-w"
+ 	fi;;
+   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
++        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
+   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
+-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
++        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
++  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
++        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac
+ fi
+ 
+@@ -6826,6 +6869,7 @@ fi
+ 
+ 
+ 
++
+ 
+ 
+ 
+--- a/gold/testsuite/Makefile.in
++++ b/gold/testsuite/Makefile.in
+@@ -2568,6 +2568,7 @@ TARGETOBJS = @TARGETOBJS@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_CXXFLAGS = @WARN_CXXFLAGS@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+--- a/gprof/Makefile.in
++++ b/gprof/Makefile.in
+@@ -267,6 +267,7 @@ STRIP = @STRIP@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ abs_builddir = @abs_builddir@
+--- a/gprof/configure
++++ b/gprof/configure
+@@ -604,6 +604,7 @@ LTLIBOBJS
+ LIBOBJS
+ WARN_WRITE_STRINGS
+ NO_WERROR
++WARN_CFLAGS_FOR_BUILD
+ WARN_CFLAGS
+ GENINSRC_NEVER_FALSE
+ GENINSRC_NEVER_TRUE
+@@ -10901,7 +10902,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 10904 "configure"
++#line 10905 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11007,7 +11008,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11010 "configure"
++#line 11011 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -12101,8 +12102,12 @@ fi
+ # Set the 'development' global.
+ . $srcdir/../bfd/development.sh
+ 
++# Set acp_cpp_for_build variable
++ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
++
+ # Default set of GCC warnings to enable.
+ GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
++GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
+ 
+ # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -12147,6 +12152,36 @@ fi
+ rm -f conftest*
+ 
+ 
++# Verify CC_FOR_BUILD to be compatible with waring flags
++
++# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-3]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow"
++fi
++rm -f conftest*
++
++
++# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-4]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144"
++fi
++rm -f conftest*
++
++
+ # Check whether --enable-werror was given.
+ if test "${enable_werror+set}" = set; then :
+   enableval=$enable_werror; case "${enableval}" in
+@@ -12162,6 +12197,7 @@ case "${host}" in
+   *-*-mingw32*)
+     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
++      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
+     fi
+     ;;
+   *) ;;
+@@ -12175,25 +12211,32 @@ fi
+ NO_WERROR=
+ if test "${ERROR_ON_WARNING}" = yes ; then
+     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
++    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
+     NO_WERROR="-Wno-error"
+ fi
+ 
+ if test "${GCC}" = yes ; then
+   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
+ fi
+ 
+ # Check whether --enable-build-warnings was given.
+ if test "${enable_build_warnings+set}" = set; then :
+   enableval=$enable_build_warnings; case "${enableval}" in
+-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
++  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
+   no)	if test "${GCC}" = yes ; then
+ 	  WARN_CFLAGS="-w"
++      WARN_CFLAGS_FOR_BUILD="-w"
+ 	fi;;
+   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
++        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
+   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
+-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
++        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
++  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
++        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac
+ fi
+ 
+@@ -12204,6 +12247,7 @@ fi
+ 
+ 
+ 
++
+ 
+ 
+ 
+--- a/ld/Makefile.in
++++ b/ld/Makefile.in
+@@ -354,6 +354,7 @@ TESTBFDLIB = @TESTBFDLIB@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ YACC = `if [ -f ../bison/bison ]; then echo ../bison/bison -y -L$(srcdir)/../bison/; else echo @YACC@; fi`
+@@ -508,7 +509,7 @@ CXX_FOR_TARGET = ` \
+   fi`
+ 
+ 
+-# Strip out sanitization options as they require special host libraries.
++# Strip out sanitization options as we want to test building binaries without any extra paraphernalia
+ CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
+ CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
+ info_TEXINFOS = ld.texinfo
+--- a/ld/configure
++++ b/ld/configure
+@@ -646,6 +646,7 @@ LIBINTL
+ USE_NLS
+ WARN_WRITE_STRINGS
+ NO_WERROR
++WARN_CFLAGS_FOR_BUILD
+ WARN_CFLAGS
+ installed_linker
+ install_as_default
+@@ -11723,7 +11724,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11726 "configure"
++#line 11727 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11829,7 +11830,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11832 "configure"
++#line 11833 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -15558,8 +15559,12 @@ fi
+ # Set the 'development' global.
+ . $srcdir/../bfd/development.sh
+ 
++# Set acp_cpp_for_build variable
++ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
++
+ # Default set of GCC warnings to enable.
+ GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
++GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
+ 
+ # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -15604,6 +15609,36 @@ fi
+ rm -f conftest*
+ 
+ 
++# Verify CC_FOR_BUILD to be compatible with waring flags
++
++# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-3]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow"
++fi
++rm -f conftest*
++
++
++# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-4]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144"
++fi
++rm -f conftest*
++
++
+ # Check whether --enable-werror was given.
+ if test "${enable_werror+set}" = set; then :
+   enableval=$enable_werror; case "${enableval}" in
+@@ -15619,6 +15654,7 @@ case "${host}" in
+   *-*-mingw32*)
+     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
++      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
+     fi
+     ;;
+   *) ;;
+@@ -15632,25 +15668,32 @@ fi
+ NO_WERROR=
+ if test "${ERROR_ON_WARNING}" = yes ; then
+     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
++    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
+     NO_WERROR="-Wno-error"
+ fi
+ 
+ if test "${GCC}" = yes ; then
+   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
+ fi
+ 
+ # Check whether --enable-build-warnings was given.
+ if test "${enable_build_warnings+set}" = set; then :
+   enableval=$enable_build_warnings; case "${enableval}" in
+-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
++  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
+   no)	if test "${GCC}" = yes ; then
+ 	  WARN_CFLAGS="-w"
++      WARN_CFLAGS_FOR_BUILD="-w"
+ 	fi;;
+   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
++        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
+   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
+-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
++        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
++  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
++        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac
+ fi
+ 
+@@ -15661,6 +15704,7 @@ fi
+ 
+ 
+ 
++
+ 
+ 
+ 
+--- a/opcodes/Makefile.in
++++ b/opcodes/Makefile.in
+@@ -267,6 +267,7 @@ STRIP = @STRIP@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
+ WARN_CFLAGS = @WARN_CFLAGS@
++WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
+ WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
+ XGETTEXT = @XGETTEXT@
+ abs_builddir = @abs_builddir@
+--- a/opcodes/configure
++++ b/opcodes/configure
+@@ -643,6 +643,7 @@ MAINTAINER_MODE_TRUE
+ NO_WMISSING_FIELD_INITIALIZERS
+ WARN_WRITE_STRINGS
+ NO_WERROR
++WARN_CFLAGS_FOR_BUILD
+ WARN_CFLAGS
+ OTOOL64
+ OTOOL
+@@ -11150,7 +11151,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11153 "configure"
++#line 11154 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11256,7 +11257,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 11259 "configure"
++#line 11260 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11508,8 +11509,12 @@ fi
+ # Set the 'development' global.
+ . $srcdir/../bfd/development.sh
+ 
++# Set acp_cpp_for_build variable
++ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
++
+ # Default set of GCC warnings to enable.
+ GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
++GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
+ 
+ # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -11554,6 +11559,36 @@ fi
+ rm -f conftest*
+ 
+ 
++# Verify CC_FOR_BUILD to be compatible with waring flags
++
++# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-3]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow"
++fi
++rm -f conftest*
++
++
++# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++__GNUC__
++_ACEOF
++if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
++  $EGREP "^[0-4]$" >/dev/null 2>&1; then :
++
++else
++  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144"
++fi
++rm -f conftest*
++
++
+ # Check whether --enable-werror was given.
+ if test "${enable_werror+set}" = set; then :
+   enableval=$enable_werror; case "${enableval}" in
+@@ -11569,6 +11604,7 @@ case "${host}" in
+   *-*-mingw32*)
+     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
++      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
+     fi
+     ;;
+   *) ;;
+@@ -11582,25 +11618,32 @@ fi
+ NO_WERROR=
+ if test "${ERROR_ON_WARNING}" = yes ; then
+     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
++    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
+     NO_WERROR="-Wno-error"
+ fi
+ 
+ if test "${GCC}" = yes ; then
+   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
+ fi
+ 
+ # Check whether --enable-build-warnings was given.
+ if test "${enable_build_warnings+set}" = set; then :
+   enableval=$enable_build_warnings; case "${enableval}" in
+-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
++  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
+   no)	if test "${GCC}" = yes ; then
+ 	  WARN_CFLAGS="-w"
++      WARN_CFLAGS_FOR_BUILD="-w"
+ 	fi;;
+   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
++        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
++        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
+   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
+-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
++        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
++        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
++  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
++        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac
+ fi
+ 
+@@ -11611,6 +11654,7 @@ fi
+ 
+ 
+ 
++
+ 
+ 
+ ac_ext=c

+ 16 - 4
package/kernel/mac80211/patches/317-rt2x00-avoid-introducing-a-USB-dependency-in-the-rt2.patch → package/kernel/mac80211/patches/020-01-rt2x00-avoid-introducing-a-USB-dependency-in-the-rt2.patch

@@ -1,6 +1,7 @@
+From 6232c17438ed01f43665197db5a98a4a4f77ef47 Mon Sep 17 00:00:00 2001
 From: Stanislaw Gruszka <sgruszka@redhat.com>
 Date: Thu, 2 Feb 2017 10:57:40 +0100
-Subject: [PATCH] rt2x00: avoid introducing a USB dependency in the
+Subject: [PATCH 01/19] rt2x00: avoid introducing a USB dependency in the
  rt2x00lib module
 
 As reported by Felix:
@@ -16,11 +17,17 @@ Cc: Vishal Thanki <vishalthanki@gmail.com>
 Reported-by: Felix Fietkau <nbd@nbd.name>
 Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB")
 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
 ---
+ drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 23 ++++++++---------------
+ drivers/net/wireless/ralink/rt2x00/rt2x00usb.c |  5 +++++
+ 2 files changed, 13 insertions(+), 15 deletions(-)
 
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+index 8fcbc8dc94c1..4b08007f93f7 100644
 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-@@ -1436,21 +1436,6 @@ void rt2x00lib_remove_dev(struct rt2x00_
+@@ -1436,21 +1436,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
  	cancel_work_sync(&rt2x00dev->intf_work);
  	cancel_delayed_work_sync(&rt2x00dev->autowakeup_work);
  	cancel_work_sync(&rt2x00dev->sleep_work);
@@ -42,7 +49,7 @@ Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
  
  	/*
  	 * Kill the tx status tasklet.
-@@ -1466,6 +1451,14 @@ void rt2x00lib_remove_dev(struct rt2x00_
+@@ -1466,6 +1451,14 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
  	 */
  	rt2x00lib_uninitialize(rt2x00dev);
  
@@ -57,9 +64,11 @@ Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
  	/*
  	 * Free extra components
  	 */
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+index 838ca58d2dd6..5a2bf9f63cd7 100644
 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
-@@ -744,6 +744,11 @@ void rt2x00usb_uninitialize(struct rt2x0
+@@ -744,6 +744,11 @@ void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev)
  {
  	struct data_queue *queue;
  
@@ -71,3 +80,6 @@ Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
  	queue_for_each(rt2x00dev, queue)
  		rt2x00usb_free_entries(queue);
  }
+-- 
+2.12.1
+

+ 61 - 0
package/kernel/mac80211/patches/020-02-rt2x00usb-do-not-anchor-rx-and-tx-urb-s.patch

@@ -0,0 +1,61 @@
+From 93c7018ec16bb83399dd4db61c361a6d6aba0d5a Mon Sep 17 00:00:00 2001
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+Date: Wed, 8 Feb 2017 12:18:09 +0100
+Subject: [PATCH 02/19] rt2x00usb: do not anchor rx and tx urb's
+
+We might kill TX or RX urb during rt2x00usb_flush_entry(), what can
+cause anchor list corruption like shown below:
+
+[ 2074.035633] WARNING: CPU: 2 PID: 14480 at lib/list_debug.c:33 __list_add+0xac/0xc0
+[ 2074.035634] list_add corruption. prev->next should be next (ffff88020f362c28), but was dead000000000100. (prev=ffff8801d161bb70).
+<snip>
+[ 2074.035670] Call Trace:
+[ 2074.035672]  [<ffffffff813bde47>] dump_stack+0x63/0x8c
+[ 2074.035674]  [<ffffffff810a2231>] __warn+0xd1/0xf0
+[ 2074.035676]  [<ffffffff810a22af>] warn_slowpath_fmt+0x5f/0x80
+[ 2074.035678]  [<ffffffffa073855d>] ? rt2x00usb_register_write_lock+0x3d/0x60 [rt2800usb]
+[ 2074.035679]  [<ffffffff813dbe4c>] __list_add+0xac/0xc0
+[ 2074.035681]  [<ffffffff81591c6c>] usb_anchor_urb+0x4c/0xa0
+[ 2074.035683]  [<ffffffffa07322af>] rt2x00usb_kick_rx_entry+0xaf/0x100 [rt2x00usb]
+[ 2074.035684]  [<ffffffffa0732322>] rt2x00usb_clear_entry+0x22/0x30 [rt2x00usb]
+
+To fix do not anchor TX and RX urb's, it is not needed as during
+shutdown we kill those urbs in rt2x00usb_free_entries().
+
+Cc: Vishal Thanki <vishalthanki@gmail.com>
+Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB")
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+index 5a2bf9f63cd7..fe13dd07cc2a 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+@@ -319,10 +319,8 @@ static bool rt2x00usb_kick_tx_entry(struct queue_entry *entry, void *data)
+ 			  entry->skb->data, length,
+ 			  rt2x00usb_interrupt_txdone, entry);
+ 
+-	usb_anchor_urb(entry_priv->urb, rt2x00dev->anchor);
+ 	status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
+ 	if (status) {
+-		usb_unanchor_urb(entry_priv->urb);
+ 		if (status == -ENODEV)
+ 			clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
+ 		set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
+@@ -410,10 +408,8 @@ static bool rt2x00usb_kick_rx_entry(struct queue_entry *entry, void *data)
+ 			  entry->skb->data, entry->skb->len,
+ 			  rt2x00usb_interrupt_rxdone, entry);
+ 
+-	usb_anchor_urb(entry_priv->urb, rt2x00dev->anchor);
+ 	status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
+ 	if (status) {
+-		usb_unanchor_urb(entry_priv->urb);
+ 		if (status == -ENODEV)
+ 			clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
+ 		set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
+-- 
+2.12.1
+

+ 75 - 0
package/kernel/mac80211/patches/020-03-rt2x00usb-fix-anchor-initialization.patch

@@ -0,0 +1,75 @@
+From 0488a6121dfe6cbd44de15ea3627913b7549a1e9 Mon Sep 17 00:00:00 2001
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+Date: Wed, 8 Feb 2017 12:18:10 +0100
+Subject: [PATCH 03/19] rt2x00usb: fix anchor initialization
+
+If device fail to initialize we can OOPS in rt2x00lib_remove_dev(), due
+to using uninitialized usb_anchor structure:
+
+[  855.435820] ieee80211 phy3: rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed for offset 0x1000 with error -19
+[  855.435826] ieee80211 phy3: rt2800_probe_rt: Error - Invalid RT chipset 0x0000, rev 0000 detected
+[  855.435829] ieee80211 phy3: rt2x00lib_probe_dev: Error - Failed to allocate device
+[  855.435845] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
+[  855.435900] IP: _raw_spin_lock_irq+0xd/0x30
+[  855.435926] PGD 0
+[  855.435953] Oops: 0002 [#1] SMP
+<snip>
+[  855.437011] Call Trace:
+[  855.437029]  ? usb_kill_anchored_urbs+0x27/0xc0
+[  855.437061]  rt2x00lib_remove_dev+0x190/0x1c0 [rt2x00lib]
+[  855.437097]  rt2x00lib_probe_dev+0x246/0x7a0 [rt2x00lib]
+[  855.437149]  ? ieee80211_roc_setup+0x9e/0xd0 [mac80211]
+[  855.437183]  ? __kmalloc+0x1af/0x1f0
+[  855.437207]  ? rt2x00usb_probe+0x13d/0xc50 [rt2x00usb]
+[  855.437240]  rt2x00usb_probe+0x155/0xc50 [rt2x00usb]
+[  855.437273]  rt2800usb_probe+0x15/0x20 [rt2800usb]
+[  855.437304]  usb_probe_interface+0x159/0x2d0
+[  855.437333]  driver_probe_device+0x2bb/0x460
+
+Patch changes initialization sequence to fix the problem.
+
+Cc: Vishal Thanki <vishalthanki@gmail.com>
+Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB")
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+index fe13dd07cc2a..c696f0ad6a68 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+@@ -825,10 +825,6 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
+ 	if (retval)
+ 		goto exit_free_device;
+ 
+-	retval = rt2x00lib_probe_dev(rt2x00dev);
+-	if (retval)
+-		goto exit_free_reg;
+-
+ 	rt2x00dev->anchor = devm_kmalloc(&usb_dev->dev,
+ 					sizeof(struct usb_anchor),
+ 					GFP_KERNEL);
+@@ -836,10 +832,17 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
+ 		retval = -ENOMEM;
+ 		goto exit_free_reg;
+ 	}
+-
+ 	init_usb_anchor(rt2x00dev->anchor);
++
++	retval = rt2x00lib_probe_dev(rt2x00dev);
++	if (retval)
++		goto exit_free_anchor;
++
+ 	return 0;
+ 
++exit_free_anchor:
++	usb_kill_anchored_urbs(rt2x00dev->anchor);
++
+ exit_free_reg:
+ 	rt2x00usb_free_reg(rt2x00dev);
+ 
+-- 
+2.12.1
+

+ 28 - 0
package/kernel/mac80211/patches/020-04-rt61pci-use-entry-directly.patch

@@ -0,0 +1,28 @@
+From 80a97eae304631f57ff8560f87c0b18b95321443 Mon Sep 17 00:00:00 2001
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+Date: Wed, 8 Feb 2017 13:51:29 +0100
+Subject: [PATCH 04/19] rt61pci: use entry directly
+
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt61pci.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt61pci.c b/drivers/net/wireless/ralink/rt2x00/rt61pci.c
+index 5306a3b2622d..8adb5f3abe15 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt61pci.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt61pci.c
+@@ -1903,8 +1903,7 @@ static void rt61pci_write_tx_desc(struct queue_entry *entry,
+ 
+ 	rt2x00_desc_read(txd, 5, &word);
+ 	rt2x00_set_field32(&word, TXD_W5_PID_TYPE, entry->queue->qid);
+-	rt2x00_set_field32(&word, TXD_W5_PID_SUBTYPE,
+-			   skbdesc->entry->entry_idx);
++	rt2x00_set_field32(&word, TXD_W5_PID_SUBTYPE, entry->entry_idx);
+ 	rt2x00_set_field32(&word, TXD_W5_TX_POWER,
+ 			   TXPOWER_TO_DEV(entry->queue->rt2x00dev->tx_power));
+ 	rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
+-- 
+2.12.1
+

+ 181 - 0
package/kernel/mac80211/patches/020-05-rt2x00-call-entry-directly-in-rt2x00_dump_frame.patch

@@ -0,0 +1,181 @@
+From 2ceb813798e1fd33e71a574771828c0f298e077b Mon Sep 17 00:00:00 2001
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+Date: Wed, 8 Feb 2017 13:51:30 +0100
+Subject: [PATCH 05/19] rt2x00: call entry directly in rt2x00_dump_frame
+
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2400pci.c   | 2 +-
+ drivers/net/wireless/ralink/rt2x00/rt2500pci.c   | 2 +-
+ drivers/net/wireless/ralink/rt2x00/rt2500usb.c   | 2 +-
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c   | 2 +-
+ drivers/net/wireless/ralink/rt2x00/rt2x00.h      | 4 ++--
+ drivers/net/wireless/ralink/rt2x00/rt2x00debug.c | 7 ++++---
+ drivers/net/wireless/ralink/rt2x00/rt2x00dev.c   | 4 ++--
+ drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 2 +-
+ drivers/net/wireless/ralink/rt2x00/rt61pci.c     | 2 +-
+ drivers/net/wireless/ralink/rt2x00/rt73usb.c     | 2 +-
+ 10 files changed, 15 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2400pci.c b/drivers/net/wireless/ralink/rt2x00/rt2400pci.c
+index 085c5b423bdf..19874439ac40 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2400pci.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2400pci.c
+@@ -1200,7 +1200,7 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,
+ 	/*
+ 	 * Dump beacon to userspace through debugfs.
+ 	 */
+-	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
++	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry);
+ out:
+ 	/*
+ 	 * Enable beaconing again.
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2500pci.c b/drivers/net/wireless/ralink/rt2x00/rt2500pci.c
+index 9832fd50c793..791434de8052 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2500pci.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2500pci.c
+@@ -1349,7 +1349,7 @@ static void rt2500pci_write_beacon(struct queue_entry *entry,
+ 	/*
+ 	 * Dump beacon to userspace through debugfs.
+ 	 */
+-	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
++	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry);
+ out:
+ 	/*
+ 	 * Enable beaconing again.
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
+index cd3ab5a9e98d..62357465fe29 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
+@@ -1170,7 +1170,7 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,
+ 	/*
+ 	 * Dump beacon to userspace through debugfs.
+ 	 */
+-	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
++	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry);
+ 
+ 	/*
+ 	 * USB devices cannot blindly pass the skb->len as the
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+index 572cdea4ca25..8223a1520316 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -1014,7 +1014,7 @@ void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc)
+ 	/*
+ 	 * Dump beacon to userspace through debugfs.
+ 	 */
+-	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
++	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry);
+ 
+ 	/*
+ 	 * Write entire beacon with TXWI and padding to register.
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+index ea299c4e7ada..26869b3bef45 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+@@ -1400,11 +1400,11 @@ void rt2x00queue_flush_queues(struct rt2x00_dev *rt2x00dev, bool drop);
+  */
+ #ifdef CPTCFG_RT2X00_LIB_DEBUGFS
+ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
+-			    enum rt2x00_dump_type type, struct sk_buff *skb);
++			    enum rt2x00_dump_type type, struct queue_entry *entry);
+ #else
+ static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
+ 					  enum rt2x00_dump_type type,
+-					  struct sk_buff *skb)
++					  struct queue_entry *entry)
+ {
+ }
+ #endif /* CPTCFG_RT2X00_LIB_DEBUGFS */
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
+index 72ae530e4a3b..964aefdc11f0 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
+@@ -157,9 +157,10 @@ void rt2x00debug_update_crypto(struct rt2x00_dev *rt2x00dev,
+ }
+ 
+ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
+-			    enum rt2x00_dump_type type, struct sk_buff *skb)
++			    enum rt2x00_dump_type type, struct queue_entry *entry)
+ {
+ 	struct rt2x00debug_intf *intf = rt2x00dev->debugfs_intf;
++	struct sk_buff *skb = entry->skb;
+ 	struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
+ 	struct sk_buff *skbcopy;
+ 	struct rt2x00dump_hdr *dump_hdr;
+@@ -196,8 +197,8 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
+ 	dump_hdr->chip_rf = cpu_to_le16(rt2x00dev->chip.rf);
+ 	dump_hdr->chip_rev = cpu_to_le16(rt2x00dev->chip.rev);
+ 	dump_hdr->type = cpu_to_le16(type);
+-	dump_hdr->queue_index = skbdesc->entry->queue->qid;
+-	dump_hdr->entry_index = skbdesc->entry->entry_idx;
++	dump_hdr->queue_index = entry->queue->qid;
++	dump_hdr->entry_index = entry->entry_idx;
+ 	dump_hdr->timestamp_sec = cpu_to_le32(timestamp.tv_sec);
+ 	dump_hdr->timestamp_usec = cpu_to_le32(timestamp.tv_usec);
+ 
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+index 4b08007f93f7..dd6678109b7e 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -363,7 +363,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
+ 	 * Send frame to debugfs immediately, after this call is completed
+ 	 * we are going to overwrite the skb->cb array.
+ 	 */
+-	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry->skb);
++	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry);
+ 
+ 	/*
+ 	 * Determine if the frame has been successfully transmitted and
+@@ -772,7 +772,7 @@ void rt2x00lib_rxdone(struct queue_entry *entry, gfp_t gfp)
+ 	 */
+ 	rt2x00link_update_stats(rt2x00dev, entry->skb, &rxdesc);
+ 	rt2x00debug_update_crypto(rt2x00dev, &rxdesc);
+-	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_RXDONE, entry->skb);
++	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_RXDONE, entry);
+ 
+ 	/*
+ 	 * Initialize RX status information, and send frame
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
+index b2364d378774..380daf4e1b8d 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
+@@ -544,7 +544,7 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
+ 	 * All processing on the frame has been completed, this means
+ 	 * it is now ready to be dumped to userspace through debugfs.
+ 	 */
+-	rt2x00debug_dump_frame(queue->rt2x00dev, DUMP_FRAME_TX, entry->skb);
++	rt2x00debug_dump_frame(queue->rt2x00dev, DUMP_FRAME_TX, entry);
+ }
+ 
+ static void rt2x00queue_kick_tx_queue(struct data_queue *queue,
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt61pci.c b/drivers/net/wireless/ralink/rt2x00/rt61pci.c
+index 8adb5f3abe15..973d418b8113 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt61pci.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt61pci.c
+@@ -1988,7 +1988,7 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
+ 	/*
+ 	 * Dump beacon to userspace through debugfs.
+ 	 */
+-	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
++	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry);
+ 
+ 	/*
+ 	 * Write entire beacon with descriptor and padding to register.
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt73usb.c b/drivers/net/wireless/ralink/rt2x00/rt73usb.c
+index 1a29c4d205a5..bb8d307a789f 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt73usb.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt73usb.c
+@@ -1557,7 +1557,7 @@ static void rt73usb_write_beacon(struct queue_entry *entry,
+ 	/*
+ 	 * Dump beacon to userspace through debugfs.
+ 	 */
+-	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
++	rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry);
+ 
+ 	/*
+ 	 * Write entire beacon with descriptor and padding to register.
+-- 
+2.12.1
+

+ 59 - 0
package/kernel/mac80211/patches/020-06-rt2x00-remove-queue_entry-from-skbdesc.patch

@@ -0,0 +1,59 @@
+From cf81db30a6edcca791b1bfa5348a162471121d11 Mon Sep 17 00:00:00 2001
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+Date: Wed, 8 Feb 2017 13:51:31 +0100
+Subject: [PATCH 06/19] rt2x00: remove queue_entry from skbdesc
+
+queue_entry field of skbdesc is not read any more, remove it to allow
+skbdesc contain other data.
+
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 3 ---
+ drivers/net/wireless/ralink/rt2x00/rt2x00queue.h | 2 --
+ 2 files changed, 5 deletions(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
+index 380daf4e1b8d..e1660b92b20c 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
+@@ -83,7 +83,6 @@ struct sk_buff *rt2x00queue_alloc_rxskb(struct queue_entry *entry, gfp_t gfp)
+ 	 */
+ 	skbdesc = get_skb_frame_desc(skb);
+ 	memset(skbdesc, 0, sizeof(*skbdesc));
+-	skbdesc->entry = entry;
+ 
+ 	if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_DMA)) {
+ 		dma_addr_t skb_dma;
+@@ -689,7 +688,6 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
+ 		goto out;
+ 	}
+ 
+-	skbdesc->entry = entry;
+ 	entry->skb = skb;
+ 
+ 	/*
+@@ -774,7 +772,6 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
+ 	 */
+ 	skbdesc = get_skb_frame_desc(intf->beacon->skb);
+ 	memset(skbdesc, 0, sizeof(*skbdesc));
+-	skbdesc->entry = intf->beacon;
+ 
+ 	/*
+ 	 * Send beacon to hardware.
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h
+index 2233b911a1d7..22d18818e850 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h
+@@ -116,8 +116,6 @@ struct skb_frame_desc {
+ 	__le32 iv[2];
+ 
+ 	dma_addr_t skb_dma;
+-
+-	struct queue_entry *entry;
+ };
+ 
+ /**
+-- 
+2.12.1
+

+ 84 - 0
package/kernel/mac80211/patches/020-07-rt2500usb-don-t-mark-register-accesses-as-inline.patch

@@ -0,0 +1,84 @@
+From 7272416609126e8910b7f0d0e3dba008aa87830c Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Tue, 14 Feb 2017 22:28:33 +0100
+Subject: [PATCH 07/19] rt2500usb: don't mark register accesses as inline
+
+When CONFIG_KASAN is set, we get a rather large stack here:
+
+drivers/net/wireless/ralink/rt2x00/rt2500usb.c: In function 'rt2500usb_set_device_state':
+drivers/net/wireless/ralink/rt2x00/rt2500usb.c:1074:1: error: the frame size of 3032 bytes is larger than 100 bytes [-Werror=frame-larger-than=]
+
+If we don't force those functions to be inline, the compiler can figure this
+out better itself and not inline the functions when doing so would be harmful,
+reducing the stack size to a merge 256 bytes.
+
+Note that there is another problem that manifests in this driver, as a result
+of the typecheck() macro causing even larger stack frames.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2500usb.c | 19 +++++--------------
+ 1 file changed, 5 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
+index 62357465fe29..0d2670a56c4c 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
+@@ -55,7 +55,7 @@ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
+  * If the csr_mutex is already held then the _lock variants must
+  * be used instead.
+  */
+-static inline void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
++static void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
+ 					   const unsigned int offset,
+ 					   u16 *value)
+ {
+@@ -66,7 +66,7 @@ static inline void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
+ 	*value = le16_to_cpu(reg);
+ }
+ 
+-static inline void rt2500usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
++static void rt2500usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
+ 						const unsigned int offset,
+ 						u16 *value)
+ {
+@@ -77,16 +77,7 @@ static inline void rt2500usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
+ 	*value = le16_to_cpu(reg);
+ }
+ 
+-static inline void rt2500usb_register_multiread(struct rt2x00_dev *rt2x00dev,
+-						const unsigned int offset,
+-						void *value, const u16 length)
+-{
+-	rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
+-				      USB_VENDOR_REQUEST_IN, offset,
+-				      value, length);
+-}
+-
+-static inline void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
++static void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
+ 					    const unsigned int offset,
+ 					    u16 value)
+ {
+@@ -96,7 +87,7 @@ static inline void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
+ 				      &reg, sizeof(reg));
+ }
+ 
+-static inline void rt2500usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
++static void rt2500usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
+ 						 const unsigned int offset,
+ 						 u16 value)
+ {
+@@ -106,7 +97,7 @@ static inline void rt2500usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
+ 				       &reg, sizeof(reg), REGISTER_TIMEOUT);
+ }
+ 
+-static inline void rt2500usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
++static void rt2500usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
+ 						 const unsigned int offset,
+ 						 void *value, const u16 length)
+ {
+-- 
+2.12.1
+

+ 94 - 0
package/kernel/mac80211/patches/020-08-rt2x00-rt2800lib-move-rt2800_drv_data-declaration-in.patch

@@ -0,0 +1,94 @@
+From 96609f366c6f792421e1939c5c834abbe24eb88a Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Wed, 15 Feb 2017 10:25:04 +0100
+Subject: [PATCH 08/19] rt2x00: rt2800lib: move rt2800_drv_data declaration
+ into rt2800lib.h
+
+The rt2800_drv_data structure contains driver specific
+information. Move the declaration into the rt2800lib.h
+header which is a more logical place for it. Also fix
+the comment style to avoid checkpatch warning.
+
+The patch contains no functional changes, it is in
+preparation for the next patch.
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800.h    | 25 -------------------------
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.h | 23 +++++++++++++++++++++++
+ 2 files changed, 23 insertions(+), 25 deletions(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h b/drivers/net/wireless/ralink/rt2x00/rt2800.h
+index 256496bfbafb..0e7051d8132f 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
+@@ -2987,29 +2987,4 @@ enum rt2800_eeprom_word {
+  */
+ #define BCN_TBTT_OFFSET 64
+ 
+-/*
+- * Hardware has 255 WCID table entries. First 32 entries are reserved for
+- * shared keys. Since parts of the pairwise key table might be shared with
+- * the beacon frame buffers 6 & 7 we could only use the first 222 entries.
+- */
+-#define WCID_START	33
+-#define WCID_END	222
+-#define STA_IDS_SIZE	(WCID_END - WCID_START + 2)
+-
+-/*
+- * RT2800 driver data structure
+- */
+-struct rt2800_drv_data {
+-	u8 calibration_bw20;
+-	u8 calibration_bw40;
+-	u8 bbp25;
+-	u8 bbp26;
+-	u8 txmixer_gain_24g;
+-	u8 txmixer_gain_5g;
+-	u8 max_psdu;
+-	unsigned int tbtt_tick;
+-	unsigned int ampdu_factor_cnt[4];
+-	DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
+-};
+-
+ #endif /* RT2800_H */
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
+index 0a8b4df665fe..8e1ae138c3f1 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
+@@ -20,6 +20,29 @@
+ #ifndef RT2800LIB_H
+ #define RT2800LIB_H
+ 
++/*
++ * Hardware has 255 WCID table entries. First 32 entries are reserved for
++ * shared keys. Since parts of the pairwise key table might be shared with
++ * the beacon frame buffers 6 & 7 we could only use the first 222 entries.
++ */
++#define WCID_START	33
++#define WCID_END	222
++#define STA_IDS_SIZE	(WCID_END - WCID_START + 2)
++
++/* RT2800 driver data structure */
++struct rt2800_drv_data {
++	u8 calibration_bw20;
++	u8 calibration_bw40;
++	u8 bbp25;
++	u8 bbp26;
++	u8 txmixer_gain_24g;
++	u8 txmixer_gain_5g;
++	u8 max_psdu;
++	unsigned int tbtt_tick;
++	unsigned int ampdu_factor_cnt[4];
++	DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
++};
++
+ struct rt2800_ops {
+ 	void (*register_read)(struct rt2x00_dev *rt2x00dev,
+ 			      const unsigned int offset, u32 *value);
+-- 
+2.12.1
+

+ 94 - 0
package/kernel/mac80211/patches/020-09-rt2800-identify-station-based-on-status-WCID.patch

@@ -0,0 +1,94 @@
+From a13d985f26f6df07d5c5c0e190477628e236babc Mon Sep 17 00:00:00 2001
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+Date: Wed, 15 Feb 2017 10:25:05 +0100
+Subject: [PATCH 09/19] rt2800: identify station based on status WCID
+
+Add framework to identify sta based on tx status WCID. This is currently
+not used, will start be utilized in the future patch.
+
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c   | 5 +++++
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.h   | 1 +
+ drivers/net/wireless/ralink/rt2x00/rt2x00queue.h | 3 ++-
+ 3 files changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+index 8223a1520316..46405cce35e0 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -855,11 +855,13 @@ EXPORT_SYMBOL_GPL(rt2800_process_rxwi);
+ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
+ {
+ 	struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
++	struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
+ 	struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
+ 	struct txdone_entry_desc txdesc;
+ 	u32 word;
+ 	u16 mcs, real_mcs;
+ 	int aggr, ampdu;
++	int wcid;
+ 
+ 	/*
+ 	 * Obtain the status about this packet.
+@@ -872,6 +874,7 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
+ 
+ 	real_mcs = rt2x00_get_field32(status, TX_STA_FIFO_MCS);
+ 	aggr = rt2x00_get_field32(status, TX_STA_FIFO_TX_AGGRE);
++	wcid = rt2x00_get_field32(status, TX_STA_FIFO_WCID);
+ 
+ 	/*
+ 	 * If a frame was meant to be sent as a single non-aggregated MPDU
+@@ -1468,6 +1471,7 @@ int rt2800_sta_add(struct rt2x00_dev *rt2x00dev, struct ieee80211_vif *vif,
+ 		return 0;
+ 
+ 	__set_bit(wcid - WCID_START, drv_data->sta_ids);
++	drv_data->wcid_to_sta[wcid - WCID_START] = sta;
+ 
+ 	/*
+ 	 * Clean up WCID attributes and write STA address to the device.
+@@ -1498,6 +1502,7 @@ int rt2800_sta_remove(struct rt2x00_dev *rt2x00dev, struct ieee80211_sta *sta)
+ 	 * get renewed when the WCID is reused.
+ 	 */
+ 	rt2800_config_wcid(rt2x00dev, NULL, wcid);
++	drv_data->wcid_to_sta[wcid - WCID_START] = NULL;
+ 	__clear_bit(wcid - WCID_START, drv_data->sta_ids);
+ 
+ 	return 0;
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
+index 8e1ae138c3f1..6811d677a6e7 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
+@@ -41,6 +41,7 @@ struct rt2800_drv_data {
+ 	unsigned int tbtt_tick;
+ 	unsigned int ampdu_factor_cnt[4];
+ 	DECLARE_BITMAP(sta_ids, STA_IDS_SIZE);
++	struct ieee80211_sta *wcid_to_sta[STA_IDS_SIZE];
+ };
+ 
+ struct rt2800_ops {
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h
+index 22d18818e850..9b297fce4692 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h
+@@ -102,7 +102,7 @@ enum skb_frame_desc_flags {
+  *	of the scope of the skb->data pointer.
+  * @iv: IV/EIV data used during encryption/decryption.
+  * @skb_dma: (PCI-only) the DMA address associated with the sk buffer.
+- * @entry: The entry to which this sk buffer belongs.
++ * @sta: The station where sk buffer was sent.
+  */
+ struct skb_frame_desc {
+ 	u8 flags;
+@@ -116,6 +116,7 @@ struct skb_frame_desc {
+ 	__le32 iv[2];
+ 
+ 	dma_addr_t skb_dma;
++	struct ieee80211_sta *sta;
+ };
+ 
+ /**
+-- 
+2.12.1
+

+ 178 - 0
package/kernel/mac80211/patches/020-10-rt2x00-separte-filling-tx-status-from-rt2x00lib_txdo.patch

@@ -0,0 +1,178 @@
+From 5edb05afebba8f488a30db29550e55c42eea6d6a Mon Sep 17 00:00:00 2001
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+Date: Wed, 15 Feb 2017 10:25:06 +0100
+Subject: [PATCH 10/19] rt2x00: separte filling tx status from rt2x00lib_txdone
+
+This makes rt2x00lib_txdone a bit simpler and will allow to reuse code
+in different variant of txdone which I'm preparing.
+
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 141 +++++++++++++------------
+ 1 file changed, 76 insertions(+), 65 deletions(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+index dd6678109b7e..b5d90fefc96b 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -313,73 +313,14 @@ static inline int rt2x00lib_txdone_bar_status(struct queue_entry *entry)
+ 	return ret;
+ }
+ 
+-void rt2x00lib_txdone(struct queue_entry *entry,
+-		      struct txdone_entry_desc *txdesc)
++static void rt2x00lib_fill_tx_status(struct rt2x00_dev *rt2x00dev,
++				     struct ieee80211_tx_info *tx_info,
++				     struct skb_frame_desc *skbdesc,
++				     struct txdone_entry_desc *txdesc,
++				     bool success)
+ {
+-	struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
+-	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
+-	struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
+-	unsigned int header_length, i;
+ 	u8 rate_idx, rate_flags, retry_rates;
+-	u8 skbdesc_flags = skbdesc->flags;
+-	bool success;
+-
+-	/*
+-	 * Unmap the skb.
+-	 */
+-	rt2x00queue_unmap_skb(entry);
+-
+-	/*
+-	 * Remove the extra tx headroom from the skb.
+-	 */
+-	skb_pull(entry->skb, rt2x00dev->extra_tx_headroom);
+-
+-	/*
+-	 * Signal that the TX descriptor is no longer in the skb.
+-	 */
+-	skbdesc->flags &= ~SKBDESC_DESC_IN_SKB;
+-
+-	/*
+-	 * Determine the length of 802.11 header.
+-	 */
+-	header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
+-
+-	/*
+-	 * Remove L2 padding which was added during
+-	 */
+-	if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_L2PAD))
+-		rt2x00queue_remove_l2pad(entry->skb, header_length);
+-
+-	/*
+-	 * If the IV/EIV data was stripped from the frame before it was
+-	 * passed to the hardware, we should now reinsert it again because
+-	 * mac80211 will expect the same data to be present it the
+-	 * frame as it was passed to us.
+-	 */
+-	if (rt2x00_has_cap_hw_crypto(rt2x00dev))
+-		rt2x00crypto_tx_insert_iv(entry->skb, header_length);