Browse Source

Use LEDE as base for Gluon

Matthias Schiffer 7 years ago
parent
commit
78b2775eec
100 changed files with 560 additions and 31391 deletions
  1. 2 3
      .gitignore
  2. 5 5
      LICENSE
  3. 102 452
      Makefile
  4. 90 34
      docs/dev/hardware.rst
  5. 2 3
      docs/site-example/site.mk
  6. 14 38
      docs/user/getting_started.rst
  7. 10 6
      docs/user/site.rst
  8. 0 22
      include/config
  9. 0 85
      include/gluon.mk
  10. 0 62
      include/toplevel.mk
  11. 0 67
      include/verbose.mk
  12. 4 6
      modules
  13. 2 0
      overlay/opkg.mk
  14. 14 5
      package/gluon-autoupdater/Makefile
  15. 5 9
      package/gluon-core/Makefile
  16. 1 1
      package/gluon-core/check_site.lua
  17. 32 23
      package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg
  18. 0 1
      package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/K50dropbear
  19. 1 1
      package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S13haveged
  20. 0 1
      package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50dropbear
  21. 21 0
      package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50dropbear
  22. 0 12
      package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50telnet
  23. 21 4
      package/gluon-site/Makefile
  24. 11 8
      package/gluon.mk
  25. 111 0
      patches/lede/0001-build-move-STAGING_DIR_HOSTPKG-and-BUILD_DIR_HOST-back-to-a-common-directory-for-all-targets.patch
  26. 0 0
      patches/lede/0002-procd-add-support-for-alternative-rc.d-directories.patch
  27. 43 0
      patches/lede/0003-base-files-disable-reset-button-handling.patch
  28. 0 0
      patches/lede/0004-hostapd-prevent-channel-switch-for-5GHz.patch
  29. 0 0
      patches/lede/0005-libjson-c-Add-support-for-custom-format-strings-for-doubles.patch
  30. 69 0
      patches/lede/0006-dropbear-add-a-failsafe-mode-that-will-always-allow-password-less-root-login.patch
  31. 0 36
      patches/openwrt/0001-tools-Makefile-fix-host-tools-build-dependencies.patch
  32. 0 118
      patches/openwrt/0003-odhcp6c-backport-from-LEDE-0d49f9f4b4da9d1960f82e68ae797290e4b9c434.patch
  33. 0 26
      patches/openwrt/0004-busybox-enable-telnet-only-when-root-password-is-really-empty-not-when-it-is-locked.patch
  34. 0 32
      patches/openwrt/0005-base-files-disable-reset-button-handling.patch
  35. 0 85
      patches/openwrt/0006-ar71xx-define-wmac-reset-function-for-QCA955x.patch
  36. 0 17348
      patches/openwrt/0007-mac80211-hostapd-iw-.-update.patch
  37. 0 24
      patches/openwrt/0008-iwinfo-update-NanoStation-Loco-txpower-offsets.patch
  38. 0 57
      patches/openwrt/0010-ipv6-fix-crash-on-ICMPv6-redirects-with-prohibited-blackholed-source.patch
  39. 0 16
      patches/openwrt/0011-lua-fix-installation-of-headers-for-host-build.patch
  40. 0 63
      patches/openwrt/0012-kernel-fs-seq_file-fallback-to-vmalloc-instead-of-oom-kill-processes.patch
  41. 0 74
      patches/openwrt/0013-fix-UBNT-XM-model-detection.patch
  42. 0 133
      patches/openwrt/0014-base-files-implemented-basic-GPIO-control.patch
  43. 0 32
      patches/openwrt/0015-ar71xx-assign-proper-GPIO-pin-for-Ubiquiti-Nanostation-models.patch
  44. 0 101
      patches/openwrt/0016-netifd-update-to-latest-version.patch
  45. 0 25
      patches/openwrt/0017-x86-fix-platform_export_bootpart-for-Xen-virtual-disks.patch
  46. 0 27
      patches/openwrt/0018-Support-LibreSSL-as-provider-of-openssl.patch
  47. 0 48
      patches/openwrt/0019-ar71xx-check-both-HWID-and-HWREV-on-upgrades-of-TP-LINK-devices.patch
  48. 0 45
      patches/openwrt/0020-ar71xx-avoid-AR71XX_MODEL-ending-with-a-space-on-some-TP-LINK-like-devices.patch
  49. 0 39
      patches/openwrt/0021-ar71xx-fix-the-revision-of-a-few-TP-LINK-devices-in-AR71XX_MODEL-to-match-labels-image-names.patch
  50. 0 41
      patches/openwrt/0022-ar71xx-build-image-for-TL-WR710N-v2.1.patch
  51. 0 2026
      patches/openwrt/0023-xtables-addons-build-fix-configure-compatiblity-with-POSIX-shells.patch
  52. 0 81
      patches/openwrt/0024-tools-add-tar-host-build-required-for-sort-name-which-was-only-added-in-the-latest-version.patch
  53. 0 31
      patches/openwrt/0025-tools-compile-flock-before-everything-else.patch
  54. 0 32
      patches/openwrt/0026-rules.mk-make-the-locked-template-available-even-if-flock-has-not-been-built-yet-fall-back-to-unlocked-shell-command.patch
  55. 0 20
      patches/openwrt/0027-build-add-locking-for-downloads-fixes-race-conditions-with-multiple-variants.patch
  56. 0 26
      patches/openwrt/0028-download.mk-fix-packed-checkout-mirroring-support.patch
  57. 0 2096
      patches/openwrt/0029-kernel-backport-spi-nor-driver-from-4.4.9.patch
  58. 0 115
      patches/openwrt/0030-kernel-mtd-spi-nor-wait-until-status-register-writes-are-ready.patch
  59. 0 56
      patches/openwrt/0031-kernel-mtd-spi-nor-unlock-Winbond-flashs.patch
  60. 0 46
      patches/openwrt/0032-ath79-dev-eth-fix-QCA9561-set-phy-interface-mode-and-mask.patch
  61. 0 33
      patches/openwrt/0033-ar71xx-use-correct-PLL-configuration-register-bitmask-for-QCA956x-SoC.patch
  62. 0 415
      patches/openwrt/0034-ar71xx-update-QCA956x-support.patch
  63. 0 176
      patches/openwrt/0035-ar71xx-fold-patch-622-MIPS-ath79-add-support-for-QCA956x-ethernet.patch-into-files.patch
  64. 0 22
      patches/openwrt/0036-ar71xx-fix-MDIO-bus-probe-on-QCA956x.patch
  65. 0 64
      patches/openwrt/0037-ar71xx-fix-qca956x-ethernet-initialization.patch
  66. 0 562
      patches/openwrt/0038-ar71xx-Support-for-Ubiquiti-UniFi-AP-AC-LITE.patch
  67. 0 21
      patches/openwrt/0039-ar71xx-Fix-eth0-support-for-Ubiquiti-UniFi-AP-AC.patch
  68. 0 193
      patches/openwrt/0040-ar71xx-Rename-unifiac-to-unifiac-lite.patch
  69. 0 274
      patches/openwrt/0041-ar71xx-Add-support-for-Ubiquiti-UniFi-AP-AC-PRO.patch
  70. 0 395
      patches/openwrt/0043-ath9k-add-HSR-tuner-support-for-UniFi-Outdoor-Plus.patch
  71. 0 41
      patches/openwrt/0044-ar71xx-Send-power-to-USB-port-on-WNR2200.patch
  72. 0 86
      patches/openwrt/0045-ar71xx-WNR2200-fix-for-random-WLAN-MAC.patch
  73. 0 251
      patches/openwrt/0046-ar71xx-WNR2200-enable-control-of-all-LEDs-and-buttons.patch
  74. 0 326
      patches/openwrt/0047-ar71xx-add-GL-AR150-support.patch
  75. 0 48
      patches/openwrt/0048-build-don-t-add-j-for-parallel-builds-with-Make-4.2.patch
  76. 0 30
      patches/openwrt/0049-tools-cmake-fix-parallel-build-with-Make-4.2.patch
  77. 0 143
      patches/openwrt/0050-linux-make-IPv6-builtin-if-selected-saves-30KB.patch
  78. 0 21
      patches/openwrt/0051-package-ipkg.mk-fix-Provides-for-packages-with-multiple-PROVIDES-entries.patch
  79. 0 154
      patches/openwrt/0052-kernel-remove-packaging-of-kmod-crypto-core-and-kmod-crypto-arc4.patch
  80. 0 24
      patches/openwrt/0053-x86-stop-relying-on-hexdump-for-image-build-signature.patch
  81. 0 34
      patches/openwrt/0054-mt76-fix-build-with-kernel-3.18.patch
  82. 0 41
      patches/openwrt/0055-ramips-Support-LEDs-on-D-Link-DIR-860L-B1.patch
  83. 0 56
      patches/openwrt/0056-ramips-add-button-support-and-make-LEDs-known-to-userspace-for-DIR-860L-B1.patch
  84. 0 22
      patches/openwrt/0057-ramips-set-correct-LAN-WAN-MAC-addresses-on-DIR-860L-B1.patch
  85. 0 323
      patches/openwrt/0058-ar71xx-add-support-for-TP-LINK-TL-WR842N-ND-v3.patch
  86. 0 18
      patches/openwrt/0059-x86-generic-enable-CONFIG_SATA_VIA.patch
  87. 0 45
      patches/openwrt/0060-libpcap-fix-dependency-of-install-shared-so-make-target.patch
  88. 0 38
      patches/openwrt/0061-ar71xx-add-revision-detection-for-D-Link-DIR-505-A1-A2.patch
  89. 0 28
      patches/openwrt/0062-ar71xx-don-t-use-D-Link-DIR-505-status-LED-as-ethernet-indicator.patch
  90. 0 35
      patches/openwrt/0063-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch
  91. 0 169
      patches/openwrt/0064-ar71xx-cpe510-split-profile-into-2-profiles-cpe210-and-cpe510.patch
  92. 0 555
      patches/openwrt/0065-firmware-utils-backport-tplink-safeloader-from-LEDE-05abcf518d5e2b7d6526fd7a87a88a268030694a.patch
  93. 0 26
      patches/openwrt/0066-ar71xx-split-CPE210-from-CPE510-profile.patch
  94. 0 437
      patches/openwrt/0067-dropbear-update-to-LEDE-277f85c21ae0ede4e15e66cbd801b9fb502531df.patch
  95. 0 567
      patches/openwrt/0068-ar71xx-Added-support-for-TL-WA801NDv3.patch
  96. 0 856
      patches/openwrt/0069-firmware-utils-mktplinkfw-backport-from-LEDE-a4fc62bc0ea4010ddbfbd738453c9db70988a57c.patch
  97. 0 38
      patches/openwrt/0070-ar71xx-backport-support-for-new-TP-Link-region-codes.patch
  98. 0 68
      patches/openwrt/0071-ath10k-firmware-add-ath10k-firmware-qca988x-11s.patch
  99. 0 124
      patches/openwrt/0072-ath9k-revert-temperature-compensation-support-patch-FS-111.patch
  100. 0 885
      patches/openwrt/0073-ath9k-remove-intermediate-queueing-patch-until-it-is-fixed-properly.patch

+ 2 - 3
.gitignore

@@ -1,7 +1,6 @@
 *~
 *~
-/build
+/lede
 /output
 /output
 /site
 /site
-/openwrt
+/tmp
 /packages
 /packages
-/modules.local

+ 5 - 5
LICENSE

@@ -1,7 +1,7 @@
 The code of Project Gluon may be distributed under the following terms, unless
 The code of Project Gluon may be distributed under the following terms, unless
 noted otherwise in individual files or subtrees.
 noted otherwise in individual files or subtrees.
 
 
-Copyright (c) 2013, Project Gluon
+Copyright (c) 2013-2017, Project Gluon
 All rights reserved.
 All rights reserved.
 
 
 Redistribution and use in source and binary forms, with or without
 Redistribution and use in source and binary forms, with or without
@@ -25,10 +25,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 
 
-OpenWrt is licensed under the terms of the GNU General Public License Version 2,
-which can be found under openwrt/LICENSE after the openwrt submodule has been
-obtained. This applies to the following submodules:
- * openwrt
+LEDE and OpenWrt are licensed under the terms of the GNU General Public License
+Version 2, which can be found at lede/LICENSE after the lede repository has been
+obtained. This applies to the following repositories:
+ * lede
  * packages/openwrt
  * packages/openwrt
  * packages/routing
  * packages/routing
  * packages/luci
  * packages/luci

+ 102 - 452
Makefile

@@ -4,503 +4,153 @@ LC_ALL:=C
 LANG:=C
 LANG:=C
 export LC_ALL LANG
 export LC_ALL LANG
 
 
-export SHELL:=/usr/bin/env bash
 
 
-GLUONPATH ?= $(PATH)
-export GLUONPATH := $(GLUONPATH)
+GLUON_SITEDIR ?= $(CURDIR)/site
+GLUON_TMPDIR ?= $(CURDIR)/tmp
 
 
-empty:=
-space:= $(empty) $(empty)
+GLUON_OUTPUTDIR ?= $(CURDIR)/output
+GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images
+GLUON_PACKAGEDIR ?= $(GLUON_OUTPUTDIR)/packages
 
 
-GLUONMAKE_EARLY = PATH=$(GLUONPATH) $(SUBMAKE) -C $(GLUON_ORIGOPENWRTDIR) -f $(GLUONDIR)/Makefile GLUON_TOOLS=0 QUILT=
-GLUONMAKE = PATH=$(GLUONPATH) $(SUBMAKE) -C $(GLUON_OPENWRTDIR) -f $(GLUONDIR)/Makefile
+export GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR DEVICES
 
 
-ifneq ($(OPENWRT_BUILD),1)
 
 
-GLUONDIR:=${CURDIR}
+$(GLUON_SITEDIR)/site.mk:
+	$(error No site configuration was found. Please check out a site configuration to $(GLUON_SITEDIR))
 
 
-include $(GLUONDIR)/include/gluon.mk
+-include $(GLUON_SITEDIR)/site.mk
 
 
-TOPDIR:=$(GLUON_ORIGOPENWRTDIR)
-export TOPDIR
-
-
-update: FORCE
-	$(GLUONDIR)/scripts/update.sh
-	$(GLUONDIR)/scripts/patch.sh
-
-update-patches: FORCE
-	$(GLUONDIR)/scripts/update.sh
-	$(GLUONDIR)/scripts/update-patches.sh
-	$(GLUONDIR)/scripts/patch.sh
-
--include $(TOPDIR)/include/host.mk
-
-_SINGLE=export MAKEFLAGS=$(space);
-
-override OPENWRT_BUILD=1
-override GLUON_TOOLS=1
-GREP_OPTIONS=
-export OPENWRT_BUILD GLUON_TOOLS GREP_OPTIONS
-
--include $(TOPDIR)/include/debug.mk
--include $(TOPDIR)/include/depends.mk
-include $(GLUONDIR)/include/toplevel.mk
-
-
-include $(GLUONDIR)/targets/targets.mk
-
-
-CheckTarget := [ -n '$(GLUON_TARGET)' -a -n '$(GLUON_TARGET_$(GLUON_TARGET)_BOARD)' ] \
-	|| (echo -e 'Please set GLUON_TARGET to a valid target. Gluon supports the following targets:$(subst $(space),\n * ,$(GLUON_TARGETS))'; false)
-
-
-CheckExternal := test -d $(GLUON_ORIGOPENWRTDIR) || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
-
-
-create-key: FORCE
-	@$(CheckExternal)
-	+@$(GLUONMAKE_EARLY) create-key
-
-prepare-target: FORCE
-	@$(CheckExternal)
-	@$(CheckTarget)
-	+@$(GLUONMAKE_EARLY) prepare-target
-
-all: prepare-target
-	+@$(GLUONMAKE) build-key
-	+@$(GLUONMAKE) prepare
-	+@$(GLUONMAKE) images
-	+@$(GLUONMAKE) modules
-
-prepare: prepare-target
-	+@$(GLUONMAKE) build-key
-	+@$(GLUONMAKE) $@
-
-clean download images modules: FORCE
-	@$(CheckExternal)
-	@$(CheckTarget)
-	+@$(GLUONMAKE_EARLY) maybe-prepare-target
-	+@$(GLUONMAKE) build-key
-	+@$(GLUONMAKE) $@
-
-toolchain/% package/% target/% image/%: FORCE
-	@$(CheckExternal)
-	@$(CheckTarget)
-	+@$(GLUONMAKE_EARLY) maybe-prepare-target
-	+@$(GLUONMAKE) build-key
-	+@$(GLUONMAKE) $@
-
-manifest: FORCE
-	@[ -n '$(GLUON_BRANCH)' ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
-	@echo '$(GLUON_PRIORITY)' | grep -qE '^([0-9]*\.)?[0-9]+$$' || (echo 'Please specify a numeric value for GLUON_PRIORITY to create a manifest.'; false)
-	@$(CheckExternal)
-
-	( \
-		echo 'BRANCH=$(GLUON_BRANCH)' && \
-		echo 'DATE=$(shell $(GLUON_ORIGOPENWRTDIR)/staging_dir/host/bin/lua $(GLUONDIR)/scripts/rfc3339date.lua)' && \
-		echo 'PRIORITY=$(GLUON_PRIORITY)' && \
-		echo \
-	) > $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp
-
-	+($(foreach GLUON_TARGET,$(GLUON_TARGETS), \
-		( [ ! -e $(BOARD_BUILDDIR)/prepared ] || ( $(GLUONMAKE) manifest GLUON_TARGET='$(GLUON_TARGET)' V=s$(OPENWRT_VERBOSE) ) ) && \
-	) :)
-
-	mkdir -p $(GLUON_IMAGEDIR)/sysupgrade
-	mv $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp $(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest
-
-dirclean : FORCE
-	for dir in build_dir dl staging_dir tmp; do \
-		rm -rf $(GLUON_ORIGOPENWRTDIR)/$$dir; \
-	done
-	rm -rf $(GLUON_BUILDDIR) $(GLUON_OUTPUTDIR)
-
-else
-
-TOPDIR=${CURDIR}
-export TOPDIR
-
-include rules.mk
+ifeq ($(GLUON_RELEASE),)
+$(error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line.)
+endif
 
 
-include $(GLUONDIR)/include/gluon.mk
+GLUON_LANGS ?= en
 
 
-include $(INCLUDE_DIR)/host.mk
-include $(INCLUDE_DIR)/depends.mk
-include $(INCLUDE_DIR)/subdir.mk
+export GLUON_RELEASE GLUON_ATH10K_MESH GLUON_REGION
 
 
-include package/Makefile
-include tools/Makefile
-include toolchain/Makefile
-include target/Makefile
 
 
+update: FORCE
+	@scripts/update.sh
+	@scripts/patch.sh
+	@scripts/feeds.sh
 
 
-PROFILES :=
-PROFILE_PACKAGES :=
+update-patches: FORCE
+	@scripts/update.sh
+	@scripts/update-patches.sh
+	@scripts/patch.sh
 
 
-define Profile
-  $(eval $(call Profile/Default))
-  $(eval $(call Profile/$(1)))
-endef
+update-feeds: FORCE
+	@scripts/feeds.sh
 
 
-define GluonProfile
-PROFILES += $(1)
-PROFILE_PACKAGES += $(filter-out -%,$(2) $(GLUON_$(1)_SITE_PACKAGES))
-GLUON_$(1)_PROFILE := $(if $(3),$(3),$(1))
-GLUON_$(1)_DEFAULT_PACKAGES := $(2)
-GLUON_$(1)_FACTORY_SUFFIX := -squashfs-factory
-GLUON_$(1)_SYSUPGRADE_SUFFIX := -squashfs-sysupgrade
-GLUON_$(1)_FACTORY_EXT := .bin
-GLUON_$(1)_SYSUPGRADE_EXT := .bin
-GLUON_$(1)_FACTORY_EXTRA :=
-GLUON_$(1)_SYSUPGRADE_EXTRA :=
-GLUON_$(1)_MODELS :=
-endef
 
 
-define GluonProfileFactorySuffix
-GLUON_$(1)_FACTORY_SUFFIX := $(2)
-GLUON_$(1)_FACTORY_EXT := $(3)
-GLUON_$(1)_FACTORY_EXTRA := $(4)
-endef
+GLUON_TARGETS :=
 
 
-define GluonProfileSysupgradeSuffix
-GLUON_$(1)_SYSUPGRADE_SUFFIX := $(2)
-GLUON_$(1)_SYSUPGRADE_EXT := $(3)
-GLUON_$(1)_SYSUPGRADE_EXTRA := $(4)
+define GluonTarget
+gluon_target := $(1)$$(if $(2),-$(2))
+GLUON_TARGETS += $$(gluon_target)
+GLUON_TARGET_$$(gluon_target)_BOARD := $(1)
+GLUON_TARGET_$$(gluon_target)_SUBTARGET := $(if $(3),$(3),$(2))
 endef
 endef
 
 
-define GluonModel
-GLUON_$(1)_MODELS += $(3)
-GLUON_$(1)_MODEL_$(3) := $(2)
-GLUON_$(1)_MODEL_$(3)_ALIASES :=
-endef
+include targets/targets.mk
 
 
-define GluonModelAlias
-GLUON_$(1)_MODEL_$(2)_ALIASES += $(3)
-endef
 
 
-
-export SHA512SUM := $(GLUONDIR)/scripts/sha512sum.sh
-
-
-prereq: FORCE
-	+$(NO_TRACE_MAKE) prereq
-
-prepare-tmpinfo: FORCE
-	@+$(MAKE) -r -s staging_dir/host/.prereq-build OPENWRT_BUILD= QUIET=0
-	mkdir -p tmp/info
-	$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk $(TOPDIR)/overlay/*/*.mk" SCAN_EXTRA=""
-	$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
-	for type in package target; do \
-		f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
-		[ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
-	done
-	[ tmp/.config-feeds.in -nt tmp/.packagefeeds ] || ./scripts/feeds feed_config > tmp/.config-feeds.in
-	./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
-	./scripts/metadata.pl package_feeds tmp/.packageinfo > tmp/.packagefeeds || { rm -f tmp/.packagefeeds; false; }
-	touch $(TOPDIR)/tmp/.build
-
-feeds: FORCE
-	rm -rf $(TOPDIR)/package/feeds
-	mkdir $(TOPDIR)/package/feeds
-	[ ! -f $(GLUON_SITEDIR)/modules ] || . $(GLUON_SITEDIR)/modules && for feed in $$GLUON_SITE_FEEDS; do ln -s ../../../packages/$$feed $(TOPDIR)/package/feeds/$$feed; done
-	ln -s ../../../package $(TOPDIR)/package/feeds/gluon
-	. $(GLUONDIR)/modules && for feed in $$GLUON_FEEDS; do ln -s ../../../packages/$$feed $(TOPDIR)/package/feeds/module_$$feed; done
-	+$(GLUONMAKE_EARLY) prepare-tmpinfo
-
-gluon-tools: FORCE
-	+$(GLUONMAKE_EARLY) tools/patch/install
-	+$(GLUONMAKE_EARLY) tools/sed/install
-	+$(GLUONMAKE_EARLY) tools/cmake/install
-	+$(GLUONMAKE_EARLY) package/lua/host/install package/usign/host/install
-
-
-
-early_prepared_stamp := $(GLUON_BUILDDIR)/prepared_$(shell \
-	( \
-		$(SHA512SUM) $(GLUONDIR)/modules; \
-		[ ! -r $(GLUON_SITEDIR)/modules ] || $(SHA512SUM) $(GLUON_SITEDIR)/modules \
-	) | $(SHA512SUM) )
-
-prepare-early: FORCE
-	for dir in build_dir dl staging_dir; do \
-		mkdir -p $(GLUON_ORIGOPENWRTDIR)/$$dir; \
-	done
-
-	+$(GLUONMAKE_EARLY) feeds
-	+$(GLUONMAKE_EARLY) gluon-tools
-
-	mkdir -p $$(dirname $(early_prepared_stamp))
-	touch $(early_prepared_stamp)
-
-$(early_prepared_stamp):
-	rm -f $(GLUON_BUILDDIR)/prepared_*
-	+$(GLUONMAKE_EARLY) prepare-early
-
-$(GLUON_OPKG_KEY): $(early_prepared_stamp) FORCE
-	[ -s $(GLUON_OPKG_KEY) -a -s $(GLUON_OPKG_KEY).pub ] || \
-		( mkdir -p $$(dirname $(GLUON_OPKG_KEY)) && $(STAGING_DIR_HOST)/bin/usign -G -s $(GLUON_OPKG_KEY) -p $(GLUON_OPKG_KEY).pub -c "Gluon opkg key" )
-
-$(GLUON_OPKG_KEY).pub: $(GLUON_OPKG_KEY)
-
-create-key: $(GLUON_OPKG_KEY).pub
-
-include $(GLUONDIR)/targets/targets.mk
-
-ifneq ($(GLUON_TARGET),)
-
-include $(GLUONDIR)/targets/$(GLUON_TARGET)/profiles.mk
+LEDEMAKE = $(MAKE) -C lede
 
 
 BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
 BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
-override SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
+SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
+LEDE_TARGET := $(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
 
 
-target_prepared_stamp := $(BOARD_BUILDDIR)/target-prepared
-gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared
-
-PREPARED_RELEASE = $$(cat $(gluon_prepared_stamp))
-IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE)
-MODULE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE)
-
-
-include $(INCLUDE_DIR)/target.mk
-
-build-key: FORCE
-	rm -f $(BUILD_KEY) $(BUILD_KEY).pub
-	cp $(GLUON_OPKG_KEY) $(BUILD_KEY)
-	cp $(GLUON_OPKG_KEY).pub $(BUILD_KEY).pub
-
-config: FORCE
-	+$(NO_TRACE_MAKE) scripts/config/conf OPENWRT_BUILD= QUIET=0
-	+$(GLUONMAKE) prepare-tmpinfo
-	( \
-		cat $(GLUONDIR)/include/config; \
-		echo 'CONFIG_TARGET_$(GLUON_TARGET_$(GLUON_TARGET)_BOARD)=y'; \
-		$(if $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET), \
-			echo 'CONFIG_TARGET_$(GLUON_TARGET_$(GLUON_TARGET)_BOARD)_$(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)=y'; \
-		) \
-		cat $(GLUONDIR)/targets/$(GLUON_TARGET)/config 2>/dev/null; \
-		echo 'CONFIG_BUILD_SUFFIX="gluon-$(GLUON_TARGET)"'; \
-		echo '$(patsubst %,CONFIG_PACKAGE_%=m,$(sort $(filter-out -%,$(DEFAULT_PACKAGES) $(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES) $(PROFILE_PACKAGES))))' \
-			| sed -e 's/ /\n/g'; \
-		echo '$(patsubst %,CONFIG_LUCI_LANG_%=y,$(GLUON_LANGS))' \
-			| sed -e 's/ /\n/g'; \
-	) > $(BOARD_BUILDDIR)/config.tmp
-	scripts/config/conf --defconfig=$(BOARD_BUILDDIR)/config.tmp Config.in
-	+$(SUBMAKE) tools/install
+export LEDE_TARGET
 
 
-prepare-target: $(GLUON_OPKG_KEY).pub
-	rm $(GLUON_OPENWRTDIR)/tmp || true
-	mkdir -p $(GLUON_OPENWRTDIR)/tmp
 
 
-	for link in build_dir config Config.in dl include Makefile package rules.mk scripts staging_dir target toolchain tools; do \
-		ln -sf $(GLUON_ORIGOPENWRTDIR)/$$link $(GLUON_OPENWRTDIR); \
-	done
+CheckTarget := [ '$(LEDE_TARGET)' ] \
+	|| (echo 'Please set GLUON_TARGET to a valid target. Gluon supports the following targets:'; $(foreach target,$(GLUON_TARGETS),echo ' * $(target)';) false)
 
 
-	+$(GLUONMAKE) config
-	touch $(target_prepared_stamp)
+CheckExternal := test -d lede || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
 
 
-$(target_prepared_stamp):
-	+$(GLUONMAKE_EARLY) prepare-target
 
 
-maybe-prepare-target: $(target_prepared_stamp)
-	+$(GLUONMAKE_EARLY) $(GLUON_OPKG_KEY).pub
+GLUON_DEFAULT_PACKAGES := -odhcpd -ppp -ppp-mod-pppoe -wpad-mini gluon-core ip6tables hostapd-mini
 
 
-$(BUILD_DIR)/.prepared: Makefile
-	@mkdir -p $$(dirname $@)
-	@touch $@
-
-$(toolchain/stamp-install): $(tools/stamp-install)
-$(package/stamp-compile): $(package/stamp-cleanup)
-
-
-clean: FORCE
-	+$(SUBMAKE) clean
-	rm -f $(gluon_prepared_stamp)
-
-
-download: FORCE
-	+$(SUBMAKE) tools/download
-	+$(SUBMAKE) toolchain/download
-	+$(SUBMAKE) package/download
-	+$(SUBMAKE) target/download
-
-toolchain: $(toolchain/stamp-install) $(tools/stamp-install)
-
-include $(INCLUDE_DIR)/kernel.mk
-
-kernel: FORCE
-	+$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) $(LINUX_DIR)/.image TARGET_BUILD=1
-	+$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) $(LINUX_DIR)/.modules TARGET_BUILD=1
-
-packages: $(package/stamp-compile)
-	$(_SINGLE)$(SUBMAKE) -r package/index
-
-prepare-image: FORCE
-	rm -rf $(BOARD_KDIR)
-	mkdir -p $(BOARD_KDIR)
-	-cp $(KERNEL_BUILD_DIR)/* $(BOARD_KDIR)/
-	+$(SUBMAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image image_prepare KDIR="$(BOARD_KDIR)"
+GLUON_PACKAGES :=
+define merge_packages
+  $(foreach pkg,$(1),
+    GLUON_PACKAGES := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$(GLUON_PACKAGES)) $(pkg))
+  )
+endef
+$(eval $(call merge_packages,$(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES)))
 
 
-prepare: FORCE
-	@$(STAGING_DIR_HOST)/bin/lua $(GLUONDIR)/scripts/site_config.lua \
-		|| (echo 'Your site configuration did not pass validation.'; false)
+GLUON_PACKAGES_YES := $(filter-out -%,$(GLUON_PACKAGES))
+GLUON_PACKAGES_NO := $(patsubst -%,%,$(filter -%,$(GLUON_PACKAGES)))
 
 
-	mkdir -p $(GLUON_IMAGEDIR) $(BOARD_BUILDDIR)
-	echo 'src packages file:../openwrt/bin/$(BOARD)/packages' > $(BOARD_BUILDDIR)/opkg.conf
 
 
-	+$(GLUONMAKE) toolchain
-	+$(GLUONMAKE) kernel
-	+$(GLUONMAKE) packages
-	+$(GLUONMAKE) prepare-image
+config: FORCE
+	@$(CheckExternal)
+	@$(CheckTarget)
 
 
-	echo "$(GLUON_RELEASE)" > $(gluon_prepared_stamp)
+	@( \
+		echo 'CONFIG_TARGET_$(BOARD)=y' \
+		$(if $(SUBTARGET),&& echo 'CONFIG_TARGET_$(BOARD)_$(SUBTARGET)=y') \
+		$(foreach pkg,$(GLUON_PACKAGES_NO),&& echo '# CONFIG_PACKAGE_$(pkg) is not set') \
+		&& scripts/target_config.sh generic \
+		&& GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config.sh '$(GLUON_TARGET)' \
+		$(foreach pkg,$(GLUON_PACKAGES_YES),&& echo 'CONFIG_PACKAGE_$(pkg)=y') \
+		$(foreach lang,$(GLUON_LANGS),&& echo 'CONFIG_LUCI_LANG_$(lang)=y') \
+		&& echo 'CONFIG_GLUON_RELEASE="$(GLUON_RELEASE)"' \
+		&& echo 'CONFIG_GLUON_SITEDIR="$(GLUON_SITEDIR)"' \
+		&& echo 'CONFIG_GLUON_BRANCH="$(GLUON_BRANCH)"' \
+	) > lede/.config
+	+@$(LEDEMAKE) defconfig
 
 
-$(gluon_prepared_stamp):
-	+$(GLUONMAKE) prepare
+	@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config_check.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES_YES)'
 
 
-modules: FORCE $(gluon_prepared_stamp)
-	-rm -f $(GLUON_MODULEDIR)/*/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)/*
-	-rmdir -p $(GLUON_MODULEDIR)/*/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)
-	mkdir -p $(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)
-	cp $(PACKAGE_DIR)/kmod-*.ipk $(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)
 
 
-	$(_SINGLE)$(SUBMAKE) -r package/index PACKAGE_DIR=$(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)
+LUA := lede/staging_dir/hostpkg/bin/lua
 
 
+$(LUA):
+	@$(CheckExternal)
 
 
-include $(INCLUDE_DIR)/package-ipkg.mk
+	+@[ -e lede/.config ] || $(LEDEMAKE) defconfig
+	+@$(LEDEMAKE) tools/install
+	+@$(LEDEMAKE) package/lua/host/install
 
 
-# override variables from rules.mk
-PACKAGE_DIR = $(GLUON_OPENWRTDIR)/bin/$(BOARD)/packages
+prepare-target: config $(LUA) ;
 
 
-PROFILE_BUILDDIR = $(BOARD_BUILDDIR)/profiles/$(PROFILE)
-PROFILE_KDIR = $(PROFILE_BUILDDIR)/kernel
-BIN_DIR = $(PROFILE_BUILDDIR)/images
+all: prepare-target
+	@GLUON_SITEDIR='$(GLUON_SITEDIR)' $(LUA) scripts/site_config.lua \
+                || (echo 'Your site configuration did not pass validation.'; false)
 
 
-TARGET_DIR = $(PROFILE_BUILDDIR)/root
+	@scripts/clean_output.sh
+	+@$(LEDEMAKE)
+	@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/copy_output.sh '$(GLUON_TARGET)'
 
 
-OPKG:= \
-  TMPDIR="$(TMP_DIR)" \
-  IPKG_INSTROOT="$(TARGET_DIR)" \
-  IPKG_CONF_DIR="$(TMP_DIR)" \
-  IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
-  $(STAGING_DIR_HOST)/bin/opkg \
-	-f $(BOARD_BUILDDIR)/opkg.conf \
-	--cache $(TMP_DIR)/dl \
-	--offline-root $(TARGET_DIR) \
-	--force-postinstall \
-	--add-dest root:/ \
-	--add-arch all:100 \
-	--add-arch $(ARCH_PACKAGES):200
+clean download: config
+	+@$(LEDEMAKE) $@
 
 
-EnableInitscript = ! grep -q '\#!/bin/sh /etc/rc.common' $(1) || bash ./etc/rc.common $(1) enable
+dirclean: FORCE
+	+@[ -e lede/.config ] || $(LEDEMAKE) defconfig
+	+@$(LEDEMAKE) dirclean
+	@rm -rf $(GLUON_TMPDIR) $(GLUON_OUTPUTDIR)
 
 
+manifest: $(LUA) FORCE
+	@[ '$(GLUON_BRANCH)' ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
+	@echo '$(GLUON_PRIORITY)' | grep -qE '^([0-9]*\.)?[0-9]+$$' || (echo 'Please specify a numeric value for GLUON_PRIORITY to create a manifest.'; false)
+	@$(CheckExternal)
 
 
-enable_initscripts: FORCE
-	cd $(TARGET_DIR) && ( export IPKG_INSTROOT=$(TARGET_DIR); \
-		$(foreach script,$(wildcard $(TARGET_DIR)/etc/init.d/*), \
-			$(call EnableInitscript,$(script)); \
-		) : \
-	)
-
-
-# Generate package list
-$(eval $(call merge-lists,INSTALL_PACKAGES,DEFAULT_PACKAGES GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_$(PROFILE)_DEFAULT_PACKAGES GLUON_$(PROFILE)_SITE_PACKAGES))
-
-package_install: FORCE
-	$(OPKG) update
-	$(OPKG) install $(PACKAGE_DIR)/base-files_*.ipk $(PACKAGE_DIR)/libc_*.ipk
-	$(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
-
-	$(OPKG) install $(INSTALL_PACKAGES)
-	+$(GLUONMAKE) enable_initscripts
-
-	rm -f $(TARGET_DIR)/usr/lib/opkg/lists/* $(TARGET_DIR)/tmp/opkg.lock
-	rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst*
-
-# Remove opkg database when opkg is not intalled
-	if [ ! -x $(TARGET_DIR)/bin/opkg ]; then rm -rf $(TARGET_DIR)/usr/lib/opkg; fi
-
-
-include $(INCLUDE_DIR)/version.mk
-
-opkg_config: FORCE
-	for d in base packages luci routing telephony management; do \
-		echo "src/gz %n_$$d %U/$$d"; \
-	done > $(TARGET_DIR)/etc/opkg/distfeeds.conf
-	$(VERSION_SED) $(TARGET_DIR)/etc/opkg/distfeeds.conf
-
-
-image: FORCE
-	rm -rf $(TARGET_DIR) $(BIN_DIR) $(PROFILE_KDIR)
-	mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TARGET_DIR)/tmp $(GLUON_IMAGEDIR)/factory $(GLUON_IMAGEDIR)/sysupgrade
-	cp -r $(BOARD_KDIR) $(PROFILE_KDIR)
-
-	+$(GLUONMAKE) package_install
-	+$(GLUONMAKE) opkg_config
-
-	$(call Image/mkfs/prepare)
-	$(_SINGLE)$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image install TARGET_BUILD=1 IMG_PREFIX=gluon \
-		PROFILE="$(GLUON_$(PROFILE)_PROFILE)" KDIR="$(PROFILE_KDIR)" TARGET_DIR="$(TARGET_DIR)" BIN_DIR="$(BIN_DIR)" TMP_DIR="$(TMP_DIR)"
-
-	$(foreach model,$(GLUON_$(PROFILE)_MODELS), \
-		$(if $(GLUON_$(PROFILE)_SYSUPGRADE_EXT), \
-			rm -f $(GLUON_IMAGEDIR)/sysupgrade/gluon-*-$(model)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) && \
-			cp $(BIN_DIR)/gluon-$(GLUON_$(PROFILE)_MODEL_$(model))$(GLUON_$(PROFILE)_SYSUPGRADE_SUFFIX)$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) $(GLUON_IMAGEDIR)/sysupgrade/$(IMAGE_PREFIX)-$(model)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) && \
-		) \
-		$(if $(GLUON_$(PROFILE)_FACTORY_EXT), \
-			rm -f $(GLUON_IMAGEDIR)/factory/gluon-*-$(model)$(GLUON_$(PROFILE)_FACTORY_EXT) && \
-			cp $(BIN_DIR)/gluon-$(GLUON_$(PROFILE)_MODEL_$(model))$(GLUON_$(PROFILE)_FACTORY_SUFFIX)$(GLUON_$(PROFILE)_FACTORY_EXT) $(GLUON_IMAGEDIR)/factory/$(IMAGE_PREFIX)-$(model)$(GLUON_$(PROFILE)_FACTORY_EXT) && \
-		) \
-		\
-		$(if $(GLUON_$(PROFILE)_SYSUPGRADE_EXTRA), \
-			rm -f $(GLUON_IMAGEDIR)/sysupgrade/gluon-*-$(model)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXTRA) && \
-			cp $(BIN_DIR)/gluon$(GLUON_$(PROFILE)_SYSUPGRADE_EXTRA) $(GLUON_IMAGEDIR)/sysupgrade/$(IMAGE_PREFIX)-$(model)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXTRA) && \
-		) \
-		$(if $(GLUON_$(PROFILE)_FACTORY_EXTRA), \
-			rm -f $(GLUON_IMAGEDIR)/factory/gluon-*-$(model)$(GLUON_$(PROFILE)_FACTORY_EXTRA) && \
-			cp $(BIN_DIR)/gluon$(GLUON_$(PROFILE)_FACTORY_EXTRA) $(GLUON_IMAGEDIR)/factory/$(IMAGE_PREFIX)-$(model)$(GLUON_$(PROFILE)_FACTORY_EXTRA) && \
-		) \
-		\
-		$(foreach alias,$(GLUON_$(PROFILE)_MODEL_$(model)_ALIASES), \
-			$(if $(GLUON_$(PROFILE)_SYSUPGRADE_EXT), \
-				rm -f $(GLUON_IMAGEDIR)/sysupgrade/gluon-*-$(alias)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) && \
-				ln -s $(IMAGE_PREFIX)-$(model)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) $(GLUON_IMAGEDIR)/sysupgrade/$(IMAGE_PREFIX)-$(alias)-sysupgrade$(GLUON_$(PROFILE)_SYSUPGRADE_EXT) && \
-			) \
-			$(if $(GLUON_$(PROFILE)_FACTORY_EXT), \
-				rm -f $(GLUON_IMAGEDIR)/factory/gluon-*-$(alias)$(GLUON_$(PROFILE)_FACTORY_EXT) && \
-				ln -s $(IMAGE_PREFIX)-$(model)$(GLUON_$(PROFILE)_FACTORY_EXT) $(GLUON_IMAGEDIR)/factory/$(IMAGE_PREFIX)-$(alias)$(GLUON_$(PROFILE)_FACTORY_EXT) && \
-			) \
-		) \
-	) :
-
-
-image/%: $(gluon_prepared_stamp)
-	+$(GLUONMAKE) image PROFILE="$(patsubst image/%,%,$@)" V=s$(OPENWRT_VERBOSE)
-
-call_image/%: FORCE
-	+$(GLUONMAKE) $(patsubst call_image/%,image/%,$@)
-
-images: $(patsubst %,call_image/%,$(PROFILES)) ;
-
-manifest: FORCE
-	( \
-		cd $(GLUON_IMAGEDIR)/sysupgrade; \
-		$(foreach profile,$(PROFILES), \
-			$(if $(GLUON_$(profile)_SYSUPGRADE_EXT), \
-				$(foreach model,$(GLUON_$(profile)_MODELS), \
-					file="$(IMAGE_PREFIX)-$(model)-sysupgrade$(GLUON_$(profile)_SYSUPGRADE_EXT)"; \
-					[ -e "$$file" ] && echo '$(model)' "$(PREPARED_RELEASE)" "$$($(SHA512SUM) "$$file")" "$$file"; \
-					\
-					$(foreach alias,$(GLUON_$(profile)_MODEL_$(model)_ALIASES), \
-						file="$(IMAGE_PREFIX)-$(alias)-sysupgrade$(GLUON_$(profile)_SYSUPGRADE_EXT)"; \
-						[ -e "$$file" ] && echo '$(alias)' "$(PREPARED_RELEASE)" "$$($(SHA512SUM) "$$file")" "$$file"; \
-					) \
-				) \
-			) \
+	@( \
+		echo 'BRANCH=$(GLUON_BRANCH)' && \
+		echo "DATE=$$($(LUA) scripts/rfc3339date.lua)" && \
+		echo 'PRIORITY=$(GLUON_PRIORITY)' && \
+		echo && \
+		$(foreach GLUON_TARGET,$(GLUON_TARGETS), \
+			GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/generate_manifest.sh '$(GLUON_TARGET)' && \
 		) : \
 		) : \
-	) >> $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp
+	) > 'tmp/$(GLUON_BRANCH).manifest.tmp'
 
 
-.PHONY: all create-key prepare images modules clean gluon-tools manifest
+	@mkdir -p '$(GLUON_IMAGEDIR)/sysupgrade'
+	@mv 'tmp/$(GLUON_BRANCH).manifest.tmp' '$(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest'
 
 
-endif
-endif
+FORCE: ;
+
+.PHONY: FORCE
+.NOTPARALLEL:

+ 90 - 34
docs/dev/hardware.rst

@@ -11,57 +11,114 @@ is a requirement. At the moment, Gluon's scripts can't handle devices
 without WLAN adapters (although such environments may also be interesting,
 without WLAN adapters (although such environments may also be interesting,
 e.g. for automated testing in virtual machines).
 e.g. for automated testing in virtual machines).
 
 
+
 .. _hardware-adding-profiles:
 .. _hardware-adding-profiles:
 
 
 Adding profiles
 Adding profiles
 ---------------
 ---------------
-The vast majority of devices with ath9k WLAN uses the ar71xx target of OpenWrt.
+The vast majority of devices with ath9k WLAN uses the ar71xx target of LEDE.
 If the hardware you want to add support for is also ar71xx, adding a new profile
 If the hardware you want to add support for is also ar71xx, adding a new profile
 is enough.
 is enough.
 
 
-Profiles are defined in ``targets/<target>-<subtarget>/profiles.mk``. There are two macros
-used to define which images are generated: ``GluonProfile`` and ``GluonModel``. The following examples
-are taken from ``profiles.mk`` of the ``ar71xx-generic`` target::
+Profiles are defined in ``targets/*`` in a shell-based DSL (so common shell
+commands syntax like ``if`` can be used.
 
 
-    $(eval $(call GluonProfile,TLWR1043))
-    $(eval $(call GluonModel,TLWR1043,tl-wr1043nd-v1-squashfs,tp-link-tl-wr1043n-nd-v1))
-    $(eval $(call GluonModel,TLWR1043,tl-wr1043nd-v2-squashfs,tp-link-tl-wr1043n-nd-v2))
+The ``device`` command is used to define an image build for a device. It takes
+two or three parameters.
 
 
-The ``GluonProfile`` macro takes at least one parameter, the profile name as it is
-defined in the Makefiles of OpenWrt (``openwrt/target/linux/<target>/<subtarget>/profiles/*``
-and ``openwrt/target/linux/<target>/image/Makefile``). If the target you are on doesn't define
-profiles (e.g. on x86), just add a single profile called ``Generic`` or similar.
+The first parameter defines the Gluon profile name, which is used to refer to the
+device and is part of the generated image name. The profile name must be same as
+the output of the following command (on the target device), so the autoupdater
+can work::
 
 
-It may optionally take a second parameter which defines additional packages to include for the profile
-(e.g. ath10k). The additional packages defined in ``openwrt/target/linux/<target>/<subtarget>/profiles/*``
-aren't used.
+    lua -e 'print(require("platform_info").get_image_name())'
 
 
-The ``GluonModel`` macro takes three parameters: The profile name, the suffix of the image file
-generated by OpenWrt (without the file extension), and the final image name of the Gluon image.
-The final image name must be the same that is returned by the following command.
+The second parameter defines the name of the image files generated by LEDE. Usually,
+it is also the LEDE profile name; for devices that still use the old image build
+code, a third parameter with the LEDE profile name can be passed. The profile names
+can be found in the image Makefiles in ``lede/target/linux/<target>/image/Makefile``.
 
 
-::
+Examples::
 
 
-    lua -e 'print(require("platform_info").get_image_name())'
+    device tp-link-tl-wr1043n-nd-v1 tl-wr1043nd-v1
+    device alfa-network-hornet-ub hornet-ub HORNETUB
+
+Suffixes and extensions
+'''''''''''''''''''''''
+
+By default, image files are expected to have the extension ``.bin``. In addition,
+the images generated by LEDE have a suffix before the extension that defaults to
+``-squashfs-factory`` and ``-squashfs-sysupgrade``.
+
+This can be changed using the ``factory`` and ``sysupgrade`` commands, either at
+the top of the file to set the defaults for all images, or for a single image. There
+are three forms with 0 to 2 arguments (all work with ``sysupgrade`` as well)::
+
+    factory SUFFIX .EXT
+    factory .EXT
+    factory
+
+When only an extension is given, the default suffix is retained. When no arguments
+are given, this signals that no factory (or sysupgrade) image exists.
+
+Aliases
+'''''''
+
+Sometimes multiple models use the same LEDE images. In this case, the ``alias``
+command can be used to create symlinks and additional entries in the autoupdater
+manifest for the alternative models.
+
+Standalone images
+'''''''''''''''''
+
+On targets without *per-device rootfs* support in LEDE, the commands described above
+can't be used. Instead, ``factory_image`` and ``sysupgrade_image`` are used::
 
 
+    factory_image PROFILE IMAGE .EXT
+    sysupgrade_image PROFILE IMAGE .EXT
 
 
-This is just so the autoupdater can work. The command has to be executed _on_ the target (eg. the hardware router with a flashed image). So you'll first have to build an image with a guessed name, and afterwards build a new, correctly named image. On targets which aren't supported by the autoupdater,
-``require("platform_info").get_image_name()`` will just return ``nil`` and the final image name
-may be defined arbitrarily.
+Again, the profile name must match the value printed by the aforementioned Lua
+command. The image name must match the part between the target name and the extension
+as generated by LEDE and is to be omitted when no such part exists.
+
+Packages
+''''''''
+
+The ``packages`` command takes an arbitrary number of arguments. Each argument
+defines an additional package to include in the images in addition to the default
+package sets defined by LEDE. When a package name is prefixed by a minus sign, the
+packages are excluded instead.
+
+The ``packages`` command may be used at the top of a target definition to modify
+the default package list for all images, or just for a single device (when the
+target supports *per-default rootfs*).
+
+
+Configuration
+'''''''''''''
+
+The ``config`` command allows to add arbitary target-specific LEDE configuration
+to be emitted to ``.config``.
+
+Notes
+'''''
 
 
 On devices with multiple WLAN adapters, care must also be taken that the primary MAC address is
 On devices with multiple WLAN adapters, care must also be taken that the primary MAC address is
 configured correctly. ``/lib/gluon/core/sysconfig/primary_mac`` should contain the MAC address which
 configured correctly. ``/lib/gluon/core/sysconfig/primary_mac`` should contain the MAC address which
 can be found on a label on most hardware; if it does not, ``/lib/gluon/upgrade/010-primary-mac``
 can be found on a label on most hardware; if it does not, ``/lib/gluon/upgrade/010-primary-mac``
 in ``gluon-core`` might need a fix. (There have also been cases in which the address was incorrect
 in ``gluon-core`` might need a fix. (There have also been cases in which the address was incorrect
-even on devices with only one WLAN adapter, in these cases an OpenWrt bug was the cause).
+even on devices with only one WLAN adapter, in these cases a LEDE bug was the cause).
+
 
 
 Adding support for new hardware targets
 Adding support for new hardware targets
 ---------------------------------------
 ---------------------------------------
+
 Adding a new target is much more complex than adding a new profile. There are two basic steps
 Adding a new target is much more complex than adding a new profile. There are two basic steps
 required for adding a new target:
 required for adding a new target:
 
 
-Adjust packages
-'''''''''''''''
+Package adjustments
+'''''''''''''''''''
+
 One package that definitely needs adjustments for every new target added is ``libplatforminfo`` (to be found in
 One package that definitely needs adjustments for every new target added is ``libplatforminfo`` (to be found in
 `packages/gluon/libs/libplatforminfo <https://github.com/freifunk-gluon/packages/tree/master/libs/libplatforminfo>`_).
 `packages/gluon/libs/libplatforminfo <https://github.com/freifunk-gluon/packages/tree/master/libs/libplatforminfo>`_).
 Start with a copy of an existing platform info source file and adjust it for the new target (or just add a symlink if
 Start with a copy of an existing platform info source file and adjust it for the new target (or just add a symlink if
@@ -71,15 +128,14 @@ On many targets, Gluon's network setup scripts (mainly in the packages ``gluon-c
 won't run correctly without some adjustments, so better double check that everything is fine there (and the files
 won't run correctly without some adjustments, so better double check that everything is fine there (and the files
 ``primary_mac``, ``lan_ifname`` and ``wan_ifname`` in ``/lib/gluon/core/sysconfig/`` contain sensible values).
 ``primary_mac``, ``lan_ifname`` and ``wan_ifname`` in ``/lib/gluon/core/sysconfig/`` contain sensible values).
 
 
-Add support to the build system
-'''''''''''''''''''''''''''''''
-A directory for the new target must be created under ``targets``, and it must be added
-to ``targets/targets.mk``. In the new target directory, the following files must be created:
-
-* profiles.mk
-* config (optional)
+Build system support
+''''''''''''''''''''
 
 
-For ``profiles.mk``, see :ref:`hardware-adding-profiles`.
-The file ``config`` can be used to add additional, target-specific options to the OpenWrt config.
+A definition for the new target must be created under ``targets``, and it must be added
+to ``targets/targets.mk``. The ``GluonTarget`` macro takes one to three arguments:
+the target name, the Gluon subtarget name (if the target has subtargets), and the
+LEDE subtarget name (if it differs from the Gluon subtarget). The third argument
+can be used to define multiple Gluon targets with different configuration for the
+same LEDE target, like it is done for the ``ar71xx-tiny`` target.
 
 
 After this, is should be sufficient to call ``make GLUON_TARGET=<target>`` to build the images for the new target.
 After this, is should be sufficient to call ``make GLUON_TARGET=<target>`` to build the images for the new target.

+ 2 - 3
docs/site-example/site.mk

@@ -1,11 +1,9 @@
 ##	gluon site.mk makefile example
 ##	gluon site.mk makefile example
 
 
 ##	GLUON_SITE_PACKAGES
 ##	GLUON_SITE_PACKAGES
-#		specify gluon/openwrt packages to include here
-#		The gluon-mesh-batman-adv-* package must come first because of the dependency resolution
+#		specify Gluon/LEDE packages to include here
 
 
 GLUON_SITE_PACKAGES := \
 GLUON_SITE_PACKAGES := \
-	gluon-mesh-batman-adv-15 \
 	gluon-alfred \
 	gluon-alfred \
 	gluon-respondd \
 	gluon-respondd \
 	gluon-autoupdater \
 	gluon-autoupdater \
@@ -21,6 +19,7 @@ GLUON_SITE_PACKAGES := \
 	gluon-luci-autoupdater \
 	gluon-luci-autoupdater \
 	gluon-luci-portconfig \
 	gluon-luci-portconfig \
 	gluon-luci-wifi-config \
 	gluon-luci-wifi-config \
+	gluon-mesh-batman-adv-15 \
 	gluon-mesh-vpn-fastd \
 	gluon-mesh-vpn-fastd \
 	gluon-radvd \
 	gluon-radvd \
 	gluon-setup-mode \
 	gluon-setup-mode \

+ 14 - 38
docs/user/getting_started.rst

@@ -85,7 +85,6 @@ Next go back to the top-level Gluon directory and build Gluon::
     make update                        # Get other repositories used by Gluon
     make update                        # Get other repositories used by Gluon
     make GLUON_TARGET=ar71xx-generic   # Build Gluon
     make GLUON_TARGET=ar71xx-generic   # Build Gluon
 
 
-When calling make, the OpenWrt build environment is prepared/updated.
 In case of errors read the messages carefully and try to fix the stated issues (e.g. install tools not available yet).
 In case of errors read the messages carefully and try to fix the stated issues (e.g. install tools not available yet).
 
 
 ``ar71xx-generic`` is the most common target and will generate images for most of the supported hardware.
 ``ar71xx-generic`` is the most common target and will generate images for most of the supported hardware.
@@ -95,7 +94,7 @@ You should reserve about 10GB of disk space for each `GLUON_TARGET`.
 
 
 The built images can be found in the directory `output/images`. Of these, the `factory`
 The built images can be found in the directory `output/images`. Of these, the `factory`
 images are to be used when flashing from the original firmware a device came with,
 images are to be used when flashing from the original firmware a device came with,
-and `sysupgrade` is to upgrade from other versions of Gluon or any other OpenWrt-based
+and `sysupgrade` is to upgrade from other versions of Gluon or any other OpenWrt/LEDE-based
 system.
 system.
 
 
 **Note:** The images for some models are identical; to save disk space, symlinks are generated instead
 **Note:** The images for some models are identical; to save disk space, symlinks are generated instead
@@ -111,39 +110,25 @@ There are two levels of `make clean`::
 
 
     make clean GLUON_TARGET=ar71xx-generic
     make clean GLUON_TARGET=ar71xx-generic
 
 
-will ensure all packages are rebuilt for a single target; this is what you normally want to do after an update.
+will ensure all packages are rebuilt for a single target. This normally not
+necessary, but may fix certain kinds of build failures.
 
 
 ::
 ::
 
 
     make dirclean
     make dirclean
 
 
-will clean the entire tree, so the toolchain will be rebuilt as well, which is
-not necessary in most cases, and will take a while.
-
-So in summary, to update and rebuild a Gluon build tree, the following commands should be used (repeat the
-``make clean`` and ``make`` for all targets you want to build):
-
-::
-
-    git pull
-    (cd site && git pull)
-    make update
-    make clean GLUON_TARGET=ar71xx-generic
-    make GLUON_TARGET=ar71xx-generic
-
+will clean the entire tree, so the toolchain will be rebuilt as well, which will take a while.
 
 
 opkg repositories
 opkg repositories
 -----------------
 -----------------
 
 
-Gluon is mostly compatible with OpenWrt, so the normal OpenWrt package repositories
-can be used for Gluon as well. It is advisable to setup a mirror or reverse proxy
-reachable over IPv6 and add it to ``site.conf`` as http://downloads.openwrt.org/ does
-not support IPv6.
+Gluon is mostly compatible with LEDE, so the normal LEDE package repositories
+can be used for Gluon as well.
 
 
 This is not true for kernel modules; the Gluon kernel is incompatible with the
 This is not true for kernel modules; the Gluon kernel is incompatible with the
-kernel of the default OpenWrt images. Therefore, Gluon will not only generate images,
-but also an opkg repository containing all kernel modules provided by OpenWrt/Gluon
-for the kernel of the generated images.
+kernel of the default LEDE images. Therefore, Gluon will not only generate images,
+but also an opkg repository containing all core packages provided by LEDE,
+including modules for the kernel of the generated images.
 
 
 Signing keys
 Signing keys
 ............
 ............
@@ -151,18 +136,14 @@ Signing keys
 Gluon does not support HTTPS for downloading packages; fortunately, opkg deploys
 Gluon does not support HTTPS for downloading packages; fortunately, opkg deploys
 public-key cryptography to ensure package integrity.
 public-key cryptography to ensure package integrity.
 
 
-The Gluon images will contain two public keys: the official OpenWrt signing key
+The Gluon images will contain public keys from two sources: the official LEDE keyring
 (to allow installing userspace packages) and a Gluon-specific key (which is used
 (to allow installing userspace packages) and a Gluon-specific key (which is used
-to sign the generated module repository).
+to sign the generated package repository).
 
 
-By default, Gluon will handle the generation and handling of the keys itself.
+LEDE will handle the generation and handling of the keys itself.
 When making firmware releases based on Gluon, it might make sense to store
 When making firmware releases based on Gluon, it might make sense to store
 the keypair, so updating the module repository later is possible.
 the keypair, so updating the module repository later is possible.
 
 
-The location the keys are stored at and read from can be changed
-(see :ref:`getting-started-make-variables`). To only generate the keypair
-at the configured location without doing a full build, use ``make create-key``.
-
 .. _getting-started-make-variables:
 .. _getting-started-make-variables:
 
 
 Make variables
 Make variables
@@ -217,13 +198,8 @@ GLUON_BUILDDIR
 GLUON_IMAGEDIR
 GLUON_IMAGEDIR
   Path where images will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/images``.
   Path where images will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/images``.
 
 
-GLUON_MODULEDIR
-  Path where the kernel module opkg repository will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/modules``.
-
-GLUON_OPKG_KEY
-  Path key file used to sign the module opkg repository. Defaults to ``$(GLUON_BULDDIR)/gluon-opkg-key``.
-
-  The private key will be stored as ``$(GLUON_OPKG_KEY)``, the public key as ``$(GLUON_OPKG_KEY).pub``.
+GLUON_PACKAGEDIR
+  Path where the opkg package repository will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/packages``.
 
 
 GLUON_OUTPUTDIR
 GLUON_OUTPUTDIR
   Path where output files will be stored. Defaults to ``output``.
   Path where output files will be stored. Defaults to ``output``.

+ 10 - 6
docs/user/site.rst

@@ -56,23 +56,27 @@ opkg \: optional
 
 
     There are two optional fields in the ``opkg`` section:
     There are two optional fields in the ``opkg`` section:
 
 
-    - ``openwrt`` overrides the default OpenWrt repository URL
+    - ``lede`` overrides the default LEDE repository URL. The default URL would
+      correspond to ``http://downloads.lede-project.org/snapshots/packages/%A``
+      and usually doesn't need to be changed when nodes are expected to have IPv6
+      internet connectivity.
     - ``extra`` specifies a table of additional repositories (with arbitrary keys)
     - ``extra`` specifies a table of additional repositories (with arbitrary keys)
 
 
     ::
     ::
 
 
       opkg = {
       opkg = {
-        openwrt = 'http://opkg.services.ffac/openwrt/%n/%v/%S/packages',
+        lede = 'http://opkg.services.ffac/lede/snapshots/packages/%A',
         extra = {
         extra = {
-          modules = 'http://opkg.services.ffac/modules/gluon-%GS-%GR/%S',
+          gluon = 'http://opkg.services.ffac/modules/gluon-%GS-%GR/%S',
         },
         },
       }
       }
 
 
     There are various patterns which can be used in the URLs:
     There are various patterns which can be used in the URLs:
 
 
-    - ``%n`` is replaced by the OpenWrt version codename (e.g. "chaos_calmer")
-    - ``%v`` is replaced by the OpenWrt version number (e.g. "15.05")
-    - ``%S`` is replaced by the target architecture (e.g. "ar71xx/generic")
+    - ``%n`` is replaced by the LEDE version codename
+    - ``%v`` is replaced by the LEDE version number (e.g. "17.01")
+    - ``%S`` is replaced by the target board (e.g. "ar71xx/generic")
+    - ``%A`` is replaced by the target architecture (e.g. "mips_24kc")
     - ``%GS`` is replaced by the Gluon site code (as specified in ``site.conf``)
     - ``%GS`` is replaced by the Gluon site code (as specified in ``site.conf``)
     - ``%GV`` is replaced by the Gluon version
     - ``%GV`` is replaced by the Gluon version
     - ``%GR`` is replaced by the Gluon release (as specified in ``site.mk``)
     - ``%GR`` is replaced by the Gluon release (as specified in ``site.mk``)

+ 0 - 22
include/config

@@ -1,22 +0,0 @@
-CONFIG_IMAGEOPT=y
-# CONFIG_PER_FEED_REPO is not set
-# CONFIG_TARGET_ROOTFS_INITRAMFS is not set
-CONFIG_DEVEL=y
-CONFIG_ALL_KMODS=y
-
-CONFIG_BUSYBOX_CUSTOM=y
-CONFIG_BUSYBOX_CONFIG_SHA512SUM=y
-# CONFIG_BUSYBOX_CONFIG_FEATURE_PREFER_IPV4_ADDRESS is not set
-CONFIG_BUSYBOX_CONFIG_IP=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_IP_ADDRESS=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_IP_LINK=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_IP_ROUTE=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_IP_TUNNEL=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_IP_RULE=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_WGET_TIMEOUT=y
-
-CONFIG_ATH_USER_REGD=y
-CONFIG_PACKAGE_ATH_DEBUG=y
-
-CONFIG_LUCI_SRCDIET=y

+ 0 - 85
include/gluon.mk

@@ -1,85 +0,0 @@
-ifneq ($(__gluon_inc),1)
-__gluon_inc=1
-
-GLUON_SITEDIR ?= $(GLUONDIR)/site
-GLUON_BUILDDIR ?= $(GLUONDIR)/build
-
-GLUON_ORIGOPENWRTDIR := $(GLUONDIR)/openwrt
-GLUON_SITE_CONFIG := $(GLUON_SITEDIR)/site.conf
-
-GLUON_OUTPUTDIR ?= $(GLUONDIR)/output
-GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images
-GLUON_MODULEDIR ?= $(GLUON_OUTPUTDIR)/modules
-
-GLUON_OPKG_KEY ?= $(GLUON_BUILDDIR)/gluon-opkg-key
-
-export GLUONDIR GLUON_SITEDIR GLUON_BUILDDIR GLUON_SITE_CONFIG GLUON_OUTPUTDIR GLUON_IMAGEDIR GLUON_MODULEDIR
-
-
-BOARD_BUILDDIR = $(GLUON_BUILDDIR)/$(GLUON_TARGET)
-BOARD_KDIR = $(BOARD_BUILDDIR)/kernel
-
-export BOARD_BUILDDIR
-
-
-LINUX_RELEASE := 2
-export LINUX_RELEASE
-
-
-GLUON_OPENWRTDIR = $(BOARD_BUILDDIR)/openwrt
-
-
-$(GLUON_SITEDIR)/site.mk:
-	$(error There was no site configuration found. Please check out a site configuration to $(GLUON_SITEDIR))
-
--include $(GLUON_SITEDIR)/site.mk
-
-
-GLUON_VERSION := $(shell cd $(GLUONDIR) && git describe --always --dirty=+ 2>/dev/null || echo unknown)
-export GLUON_VERSION
-
-GLUON_SITE_VERSION := $(shell cd $(GLUON_SITEDIR) && git --git-dir=.git describe --always --dirty=+ 2>/dev/null || echo unknown)
-export GLUON_SITE_VERSION
-
-GLUON_LANGS ?= en
-export GLUON_LANGS
-
-
-ifeq ($(OPENWRT_BUILD),1)
-ifeq ($(GLUON_TOOLS),1)
-
-GLUON_OPENWRT_FEEDS := base packages luci routing telephony management
-export GLUON_OPENWRT_FEEDS
-
-GLUON_SITE_CODE := $(shell $(GLUONDIR)/scripts/site.sh site_code)
-export GLUON_SITE_CODE
-
-ifeq ($(GLUON_RELEASE),)
-$(error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line.)
-endif
-export GLUON_RELEASE
-
-endif
-endif
-
-
-define merge-lists
-$(1) :=
-$(foreach var,$(2),$(1) := $$(filter-out -% $$(patsubst -%,%,$$(filter -%,$$($(var)))),$$($(1)) $$($(var)))
-)
-endef
-
-GLUON_TARGETS :=
-
-define GluonTarget
-gluon_target := $(1)$$(if $(2),-$(2))
-GLUON_TARGETS += $$(gluon_target)
-GLUON_TARGET_$$(gluon_target)_BOARD := $(1)
-GLUON_TARGET_$$(gluon_target)_SUBTARGET := $(2)
-endef
-
-GLUON_DEFAULT_PACKAGES := gluon-core firewall ip6tables -uboot-envtools -wpad-mini hostapd-mini
-
-override DEFAULT_PACKAGES.router :=
-
-endif #__gluon_inc

+ 0 - 62
include/toplevel.mk

@@ -1,62 +0,0 @@
-# Makefile for OpenWrt
-#
-# Copyright (C) 2007-2012 OpenWrt.org
-# Copyright (C) 2013-2014 Project Gluon
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-RELEASE:=Chaos Calmer
-PREP_MK= OPENWRT_BUILD= QUIET=0
-
-export IS_TTY=$(shell tty -s && echo 1 || echo 0)
-
-include $(GLUONDIR)/include/verbose.mk
-
-REVISION:=$(shell [ -d $(TOPDIR) ] && cd $(TOPDIR) && ./scripts/getver.sh 2>/dev/null)
-
-HOSTCC ?= gcc
-OPENWRTVERSION:=$(RELEASE)$(if $(REVISION), ($(REVISION)))
-export RELEASE
-export REVISION
-export OPENWRTVERSION
-export IS_TTY=$(shell tty -s && echo 1 || echo 0)
-export LD_LIBRARY_PATH:=$(subst ::,:,$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(STAGING_DIR_HOST)/lib)
-export DYLD_LIBRARY_PATH:=$(subst ::,:,$(if $(DYLD_LIBRARY_PATH),$(DYLD_LIBRARY_PATH):)$(STAGING_DIR_HOST)/lib)
-export GIT_CONFIG_PARAMETERS='core.autocrlf=false'
-export MAKE_JOBSERVER=$(filter --jobserver%,$(MAKEFLAGS))
-
-# prevent perforce from messing with the patch utility
-unexport P4PORT P4USER P4CONFIG P4CLIENT
-
-# prevent user defaults for quilt from interfering
-unexport QUILT_PATCHES QUILT_PATCH_OPTS
-
-unexport C_INCLUDE_PATH CROSS_COMPILE ARCH
-
-# prevent distro default LPATH from interfering
-unexport LPATH
-
-# make sure that a predefined CFLAGS variable does not disturb packages
-export CFLAGS=
-
-ifneq ($(shell $(HOSTCC) 2>&1 | grep clang),)
-  export HOSTCC_REAL?=$(HOSTCC)
-  export HOSTCC_WRAPPER:=$(TOPDIR)/scripts/clang-gcc-wrapper
-else
-  export HOSTCC_WRAPPER:=$(HOSTCC)
-endif
-
-SCAN_COOKIE?=$(shell echo $$$$)
-export SCAN_COOKIE
-
-SUBMAKE:=umask 022; $(SUBMAKE)
-
-ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024;
-
-FORCE: ;
-
-.PHONY: FORCE
-.NOTPARALLEL:
-

+ 0 - 67
include/verbose.mk

@@ -1,67 +0,0 @@
-# 
-# Copyright (C) 2006 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-ifndef OPENWRT_VERBOSE
-  OPENWRT_VERBOSE:=
-endif
-ifeq ("$(origin V)", "command line")
-  OPENWRT_VERBOSE:=$(V)
-endif
-
-ifeq ($(OPENWRT_VERBOSE),1)
-  OPENWRT_VERBOSE:=w
-endif
-ifeq ($(OPENWRT_VERBOSE),99)
-  OPENWRT_VERBOSE:=s
-endif
-
-ifeq ($(NO_TRACE_MAKE),)
-NO_TRACE_MAKE := $(MAKE) V=s$(OPENWRT_VERBOSE)
-export NO_TRACE_MAKE
-endif
-
-ifeq ($(IS_TTY),1)
-  ifneq ($(strip $(NO_COLOR)),1)
-    _Y:=\\033[33m
-    _R:=\\033[31m
-    _N:=\\033[m
-  endif
-endif
-
-ifeq ($(findstring s,$(OPENWRT_VERBOSE)),)
-  define MESSAGE
-	printf "$(_Y)%s$(_N)\n" "$(1)" >&8
-  endef
-
-  define ERROR_MESSAGE
-	printf "$(_R)%s$(_N)\n" "$(1)" >&8
-  endef
-
-  ifeq ($(QUIET),1)
-    ifneq ($(CURDIR),$(TOPDIR))
-      _DIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
-    else
-      _DIR:=
-    endif
-    _NULL:=$(if $(MAKECMDGOALS),$(shell \
-		$(call MESSAGE, make[$(MAKELEVEL)]$(if $(_DIR), -C $(_DIR)) $(MAKECMDGOALS)); \
-    ))
-    SUBMAKE=$(MAKE)
-  else
-    SILENT:=>/dev/null $(if $(findstring w,$(OPENWRT_VERBOSE)),,2>&1)
-    export QUIET:=1
-    SUBMAKE=cmd() { $(SILENT) $(MAKE) -s $$* < /dev/null || { echo "make $$*: build failed. Please re-run make with V=s to see what's going on"; false; } } 8>&1 9>&2; cmd
-  endif
-
-  .SILENT: $(MAKECMDGOALS)
-else
-  SUBMAKE=$(MAKE) -w
-  define MESSAGE
-    printf "%s\n" "$(1)"
-  endef
-  ERROR_MESSAGE=$(MESSAGE)
-endif

+ 4 - 6
modules

@@ -1,15 +1,13 @@
 GLUON_FEEDS='openwrt gluon routing luci'
 GLUON_FEEDS='openwrt gluon routing luci'
 
 
-OPENWRT_REPO=git://github.com/openwrt/openwrt.git
-OPENWRT_COMMIT=0f757bd2606971252f901ef3faf4dbd0086315f7
-OPENWRT_BRANCH=chaos_calmer
+LEDE_REPO=git://git.lede-project.org/source.git
+LEDE_COMMIT=b9a408c2b49ccfa0e906bda00ef77f4002e401fd
 
 
 PACKAGES_OPENWRT_REPO=git://github.com/openwrt/packages.git
 PACKAGES_OPENWRT_REPO=git://github.com/openwrt/packages.git
-PACKAGES_OPENWRT_COMMIT=73776792f7d58e982be9e5819450d4875b273159
-PACKAGES_OPENWRT_BRANCH=for-15.05
+PACKAGES_OPENWRT_COMMIT=ee211f94ec292f7ec3d563fcbc147359b6cf8290
 
 
 PACKAGES_GLUON_REPO=git://github.com/freifunk-gluon/packages.git
 PACKAGES_GLUON_REPO=git://github.com/freifunk-gluon/packages.git
-PACKAGES_GLUON_COMMIT=5c25ed888f9f2e05652a994fc0212e34304d58fa
+PACKAGES_GLUON_COMMIT=ef405e224082c26807fe24c02da9b02135fa46d0
 
 
 PACKAGES_ROUTING_REPO=git://github.com/openwrt-routing/packages.git
 PACKAGES_ROUTING_REPO=git://github.com/openwrt-routing/packages.git
 PACKAGES_ROUTING_COMMIT=d848d49d2443448b147c564c2dd8f64433b5fb9c
 PACKAGES_ROUTING_COMMIT=d848d49d2443448b147c564c2dd8f64433b5fb9c

+ 2 - 0
overlay/opkg.mk

@@ -0,0 +1,2 @@
+FEEDS_ENABLED := $(FEEDS_DISABLED)
+FEEDS_DISABLED :=

+ 14 - 5
package/gluon-autoupdater/Makefile

@@ -2,11 +2,13 @@ include $(TOPDIR)/rules.mk
 
 
 PKG_NAME:=gluon-autoupdater
 PKG_NAME:=gluon-autoupdater
 PKG_VERSION:=4
 PKG_VERSION:=4
-PKG_RELEASE:=$(GLUON_BRANCH)
 
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+PKG_CONFIG_DEPENDS := CONFIG_GLUON_BRANCH
 PKG_BUILD_DEPENDS := respondd
 PKG_BUILD_DEPENDS := respondd
 
 
+
 include ../gluon.mk
 include ../gluon.mk
 
 
 
 
@@ -17,6 +19,13 @@ define Package/gluon-autoupdater
   TITLE:=Automatically update firmware
   TITLE:=Automatically update firmware
 endef
 endef
 
 
+define Package/gluon-autoupdater/config
+config GLUON_BRANCH
+	string "Gluon autoupdater branch"
+	depends on PACKAGE_gluon-autoupdater
+	default ""
+endef
+
 define Build/Prepare
 define Build/Prepare
 	mkdir -p $(PKG_BUILD_DIR)
 	mkdir -p $(PKG_BUILD_DIR)
 	$(CP) ./src/* $(PKG_BUILD_DIR)/
 	$(CP) ./src/* $(PKG_BUILD_DIR)/
@@ -34,10 +43,10 @@ define Package/gluon-autoupdater/install
 	$(INSTALL_DIR) $(1)/lib/gluon/respondd
 	$(INSTALL_DIR) $(1)/lib/gluon/respondd
 	$(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/autoupdater.so
 	$(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/autoupdater.so
 
 
-	if [ '$(GLUON_BRANCH)' ]; then \
-		$(INSTALL_DIR) $(1)/lib/gluon/autoupdater; \
-		echo '$(GLUON_BRANCH)' > $(1)/lib/gluon/autoupdater/default_branch; \
-	fi
+ifneq ($(CONFIG_GLUON_BRANCH),"")
+	$(INSTALL_DIR) $(1)/lib/gluon/autoupdater
+	echo '$(call qstrip,$(CONFIG_GLUON_BRANCH))' > $(1)/lib/gluon/autoupdater/default_branch
+endif
 endef
 endef
 
 
 define Package/gluon-autoupdater/postinst
 define Package/gluon-autoupdater/postinst

+ 5 - 9
package/gluon-core/Makefile

@@ -1,8 +1,10 @@
 include $(TOPDIR)/rules.mk
 include $(TOPDIR)/rules.mk
 
 
 PKG_NAME:=gluon-core
 PKG_NAME:=gluon-core
-PKG_VERSION:=3
-PKG_RELEASE:=$(GLUON_VERSION)
+
+GLUON_VERSION = $(shell git describe --always --dirty=+ 2>/dev/null || echo unknown)
+PKG_VERSION:=$(if $(DUMP),x,$(GLUON_VERSION))
+
 
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
 
@@ -20,10 +22,6 @@ define Package/gluon-core/description
 	Gluon community wifi mesh firmware framework: core
 	Gluon community wifi mesh firmware framework: core
 endef
 endef
 
 
-define Build/Prepare
-	mkdir -p $(PKG_BUILD_DIR)
-endef
-
 define Build/Configure
 define Build/Configure
 endef
 endef
 
 
@@ -34,11 +32,9 @@ endef
 define Package/gluon-core/install
 define Package/gluon-core/install
 	$(CP) ./files/* $(1)/
 	$(CP) ./files/* $(1)/
 	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
 	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
-	$(SED) 's/__GLUON_OPENWRT_FEEDS__/{$(GLUON_OPENWRT_FEEDS:%="%",)}/' $(1)/lib/gluon/upgrade/500-opkg
 
 
 	$(INSTALL_DIR) $(1)/lib/gluon
 	$(INSTALL_DIR) $(1)/lib/gluon
-	echo "$(GLUON_VERSION)" > $(1)/lib/gluon/gluon-version
-	echo "$(GLUON_SITE_VERSION)" > $(1)/lib/gluon/site-version
+	echo '$(GLUON_VERSION)' > $(1)/lib/gluon/gluon-version
 endef
 endef
 
 
 define Package/gluon-core/postinst
 define Package/gluon-core/postinst

+ 1 - 1
package/gluon-core/check_site.lua

@@ -2,7 +2,7 @@ need_string 'site_code'
 need_string 'site_name'
 need_string 'site_name'
 
 
 if need_table('opkg', nil, false) then
 if need_table('opkg', nil, false) then
-  need_string('opkg.openwrt', false)
+  need_string('opkg.lede', false)
 
 
   function check_repo(k, _)
   function check_repo(k, _)
     -- this is not actually a uci name, but using the same naming rules here is fine
     -- this is not actually a uci name, but using the same naming rules here is fine

+ 32 - 23
package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg

@@ -8,42 +8,51 @@ local util = require 'luci.util'
 local subst = {}
 local subst = {}
 
 
 subst['%%v'] = util.trim(fs.readfile('/etc/openwrt_version'))
 subst['%%v'] = util.trim(fs.readfile('/etc/openwrt_version'))
-subst['%%n'], subst['%%S'] = util.exec('. /etc/openwrt_release; echo $DISTRIB_CODENAME; echo $DISTRIB_TARGET'):match('([^\n]*)\n([^\n]*)')
+subst['%%n'], subst['%%S'], subst['%%A'] = util.exec('. /etc/openwrt_release; echo "$DISTRIB_CODENAME"; echo "$DISTRIB_TARGET"; echo "$DISTRIB_ARCH"'):match('([^\n]*)\n([^\n]*)\n([^\n]*)')
 subst['%%GS'] = site.site_code
 subst['%%GS'] = site.site_code
 subst['%%GV'] = util.trim(fs.readfile('/lib/gluon/gluon-version'))
 subst['%%GV'] = util.trim(fs.readfile('/lib/gluon/gluon-version'))
 subst['%%GR'] = util.trim(fs.readfile('/lib/gluon/release'))
 subst['%%GR'] = util.trim(fs.readfile('/lib/gluon/release'))
 
 
 function replace_patterns(url)
 function replace_patterns(url)
-  for k, v in pairs(subst) do
-    url = url:gsub(k, v)
-  end
+	for k, v in pairs(subst) do
+		url = url:gsub(k, v)
+	end
 
 
-  return url
+	return url
 end
 end
 
 
 
 
-if site.opkg then
-  if site.opkg.openwrt then
-    local url = replace_patterns(site.opkg.openwrt)
-    local f = io.open('/etc/opkg/distfeeds.conf', 'w')
+local prefix = subst['%%n'] .. '_'
 
 
-    for _, v in ipairs(__GLUON_OPENWRT_FEEDS__) do
-      f:write(replace_patterns(string.format('src/gz %%n_%s %s/%s\n', v, site.opkg.openwrt, v)))
-    end
+local distfeeds = {}
+for line in io.lines('/etc/opkg/distfeeds.conf') do
+	table.insert(distfeeds, line)
+end
+
+local f = io.open('/etc/opkg/distfeeds.conf', 'w')
+
+for _, line in ipairs(distfeeds) do
+	local name = line:match('^src/gz%s' .. prefix .. '(%S+)%s')
+	if name == 'core' then
+		f:write('# ' .. line .. '\n')
+	elseif name and site.opkg and site.opkg.lede then
+		f:write(string.format('src/gz %s %s/%s\n', prefix .. name, replace_patterns(site.opkg.lede), name))
+	else
+		f:write(line .. '\n')
+	end
+end
 
 
-    f:close()
-  end
+f:close()
 
 
-  if site.opkg.extra and next(site.opkg.extra) then
-    local f = io.open('/etc/opkg/gluon.conf', 'w')
+if site.opkg and site.opkg.extra and next(site.opkg.extra) then
+	local f = io.open('/etc/opkg/gluon.conf', 'w')
 
 
-    for k, v in pairs(site.opkg.extra) do
-      f:write(string.format('src/gz %s %s\n', k, replace_patterns(v)))
-    end
+	for k, v in pairs(site.opkg.extra) do
+		f:write(string.format('src/gz %s %s\n', k, replace_patterns(v)))
+	end
 
 
-    f:close()
+	f:close()
 
 
-  else
-    os.remove('/etc/opkg/gluon.conf')
-  end
+else
+	os.remove('/etc/opkg/gluon.conf')
 end
 end

+ 0 - 1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/K50dropbear

@@ -1 +0,0 @@
-/etc/init.d/dropbear

+ 1 - 1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S13haveged

@@ -1,5 +1,5 @@
 #!/bin/sh /etc/rc.common
 #!/bin/sh /etc/rc.common
 
 
-if /etc/init.d/haveged enabled; then
+if [ -x /etc/init.d/haveged ] && /etc/init.d/haveged enabled; then
 	. /etc/init.d/haveged
 	. /etc/init.d/haveged
 fi
 fi

+ 0 - 1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50dropbear

@@ -1 +0,0 @@
-/etc/init.d/dropbear

+ 21 - 0
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50dropbear

@@ -0,0 +1,21 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+PROG=/usr/sbin/dropbear
+NAME=dropbear
+
+start_service() {
+	[ -x /etc/init.d/dropbear ] || return 0
+
+	. /etc/init.d/dropbear
+
+	[ -s /etc/dropbear/dropbear_rsa_host_key ] || keygen
+
+	. /lib/functions.sh
+	. /lib/functions/network.sh
+
+	procd_open_instance
+	procd_set_param command "$PROG" -F -f
+	procd_set_param respawn
+	procd_close_instance
+}

+ 0 - 12
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50telnet

@@ -1,12 +0,0 @@
-#!/bin/sh /etc/rc.common
-
-START=50
-
-USE_PROCD=1
-PROG=/usr/sbin/telnetd
-
-start_service() {
-	procd_open_instance
-	procd_set_param command "$PROG" -F -l /lib/gluon/setup-mode/ash-login
-	procd_close_instance
-}

+ 21 - 4
package/gluon-site/Makefile

@@ -1,9 +1,13 @@
 include $(TOPDIR)/rules.mk
 include $(TOPDIR)/rules.mk
 
 
 PKG_NAME:=gluon-site
 PKG_NAME:=gluon-site
-PKG_VERSION:=$(if $(GLUON_SITE_CODE),$(GLUON_SITE_CODE),1)
-PKG_RELEASE:=$(GLUON_RELEASE)
 
 
+GLUON_SITEDIR = '$(call qstrip,$(CONFIG_GLUON_SITEDIR))'
+GLUON_SITE_VERSION = $(shell ( cd $(GLUON_SITEDIR) && git --git-dir=.git describe --always --dirty=+ ) 2>/dev/null || echo unknown)
+PKG_VERSION:=$(if $(DUMP),x,$(GLUON_SITE_VERSION))
+
+
+PKG_CONFIG_DEPENDS := CONFIG_GLUON_RELEASE CONFIG_GLUON_SITEDIR
 PKG_FILE_DEPENDS := $(GLUON_SITEDIR)/site.conf $(GLUON_SITEDIR)/i18n/
 PKG_FILE_DEPENDS := $(GLUON_SITEDIR)/site.conf $(GLUON_SITEDIR)/i18n/
 PKG_BUILD_DEPENDS := luci-base/host lua-cjson/host
 PKG_BUILD_DEPENDS := luci-base/host lua-cjson/host
 
 
@@ -20,6 +24,18 @@ define Package/gluon-site
   TITLE:=Site-specific files of Gluon
   TITLE:=Site-specific files of Gluon
 endef
 endef
 
 
+define Package/gluon-site/config
+config GLUON_RELEASE
+	string "Gluon release number"
+	depends on PACKAGE_gluon-site
+	default ""
+
+config GLUON_SITEDIR
+	string "Gluon site configuration directory"
+	depends on PACKAGE_gluon-site
+	default ""
+endef
+
 define Build/Prepare
 define Build/Prepare
 	mkdir -p $(PKG_BUILD_DIR)
 	mkdir -p $(PKG_BUILD_DIR)
 endef
 endef
@@ -28,14 +44,15 @@ define Build/Configure
 endef
 endef
 
 
 define Build/Compile
 define Build/Compile
-	lua -e 'print(require("cjson").encode(assert(dofile("../../scripts/site_config.lua"))))' > $(PKG_BUILD_DIR)/site.json
+	GLUON_SITEDIR='$(call qstrip,$(CONFIG_GLUON_SITEDIR))' lua -e 'print(require("cjson").encode(assert(dofile("../../scripts/site_config.lua"))))' > $(PKG_BUILD_DIR)/site.json
 	$(call GluonBuildI18N,gluon-site,$(GLUON_SITEDIR)/i18n)
 	$(call GluonBuildI18N,gluon-site,$(GLUON_SITEDIR)/i18n)
 endef
 endef
 
 
 define Package/gluon-site/install
 define Package/gluon-site/install
 	$(INSTALL_DIR) $(1)/lib/gluon
 	$(INSTALL_DIR) $(1)/lib/gluon
 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/site.json $(1)/lib/gluon/
 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/site.json $(1)/lib/gluon/
-	echo "$(GLUON_RELEASE)" > $(1)/lib/gluon/release
+	echo '$(GLUON_SITE_VERSION)' > $(1)/lib/gluon/site-version
+	echo '$(call qstrip,$(CONFIG_GLUON_RELEASE))' > $(1)/lib/gluon/release
 
 
 	$(call GluonInstallI18N,gluon-site,$(1))
 	$(call GluonInstallI18N,gluon-site,$(1))
 endef
 endef

+ 11 - 8
package/gluon.mk

@@ -5,8 +5,13 @@ include $(INCLUDE_DIR)/package.mk
 
 
 # Annoyingly, make's shell function replaces all newlines with spaces, so we have to do some escaping work. Yuck.
 # Annoyingly, make's shell function replaces all newlines with spaces, so we have to do some escaping work. Yuck.
 define GluonCheckSite
 define GluonCheckSite
-[ -z "$$GLUONDIR" ] || sed -e 's/-@/\n/g' -e 's/+@/@/g' <<'END__GLUON__CHECK__SITE' | "$$GLUONDIR"/scripts/check_site.sh
-$(shell cat $(1) | sed -ne '1h; 1!H; $$ {g; s/@/+@/g; s/\n/-@/g; p}')
+[ -z "$$IPKG_INSTROOT" ] || sed -e 's/-@/\n/g' -e 's/+@/@/g' <<'END__GLUON__CHECK__SITE' | "${TOPDIR}/staging_dir/hostpkg/bin/lua" -e 'dofile()'
+local f = assert(io.open(os.getenv('IPKG_INSTROOT') .. '/lib/gluon/site.json'))
+local site_json = f:read('*a')
+f:close()
+
+site = require('cjson').decode(site_json)
+$(shell cat '$(TOPDIR)/../scripts/check_site_lib.lua' '$(1)' | sed -ne '1h; 1!H; $$ {g; s/@/+@/g; s/\n/-@/g; p}')
 END__GLUON__CHECK__SITE
 END__GLUON__CHECK__SITE
 endef
 endef
 
 
@@ -41,11 +46,9 @@ define GluonSrcDiet
 	rm -rf $(2)
 	rm -rf $(2)
 	$(CP) $(1) $(2)
 	$(CP) $(1) $(2)
 	$(FIND) $(2) -type f | while read src; do \
 	$(FIND) $(2) -type f | while read src; do \
-	if $(STAGING_DIR_HOST)/bin/lua $(STAGING_DIR_HOST)/bin/LuaSrcDiet \
-		--noopt-binequiv -o "$$$$src.o" "$$$$src"; \
-	then \
-		chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \
-		mv "$$$$src.o" "$$$$src"; \
-	fi; \
+		if LuaSrcDiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; then \
+			chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \
+			mv "$$$$src.o" "$$$$src"; \
+		fi; \
 	done
 	done
 endef
 endef

+ 111 - 0
patches/lede/0001-build-move-STAGING_DIR_HOSTPKG-and-BUILD_DIR_HOST-back-to-a-common-directory-for-all-targets.patch

@@ -0,0 +1,111 @@
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Sat, 14 Jan 2017 18:13:14 +0100
+Subject: build: move STAGING_DIR_HOSTPKG and BUILD_DIR_HOST back to a common directory for all targets
+
+$(STAGING_DIR)/host is kept in addition to $(STAGING_DIR_HOSTPKG) in most
+places; it is still used as destination for host files in Build/InstallDev.
+
+Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
+
+diff --git a/Makefile b/Makefile
+index b220dfd3c56a11f3e27d70e3d6e58cc6448abd2f..c1a7285c83df310e987eaef8376500d2b614eafb 100644
+--- a/Makefile
++++ b/Makefile
+@@ -55,7 +55,7 @@ clean: FORCE
+ 	rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(BUILD_LOG_DIR) $(TOPDIR)/staging_dir/packages
+ 
+ dirclean: clean
+-	rm -rf $(STAGING_DIR_HOST) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN)
++	rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/host $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN)
+ 	rm -rf $(TMP_DIR)
+ 
+ ifndef DUMP_TARGET_DB
+diff --git a/include/autotools.mk b/include/autotools.mk
+index c6aa47e0bef311697b4def7a7183d1ac59dcf599..7bd400ab36d052b39fcb76a66873c8673eb189a0 100644
+--- a/include/autotools.mk
++++ b/include/autotools.mk
+@@ -75,7 +75,7 @@ define autoreconf_target
+   $(strip $(call autoreconf, \
+     $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \
+     $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \
+-    $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS)))
++    $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR_HOSTPKG)/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS)))
+ endef
+ 
+ define patch_libtool_target
+diff --git a/include/cmake.mk b/include/cmake.mk
+index 5f572e9d7475e807ea56713ee2069dc98f5c1f6b..80c1b05937410cb9fce20e7b759577480cf390e7 100644
+--- a/include/cmake.mk
++++ b/include/cmake.mk
+@@ -34,7 +34,7 @@ CMAKE_NM:=$(call cmake_tool,$(TARGET_NM))
+ CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB))
+ 
+ CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR)/usr;$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT))
+-CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOST)
++CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOSTPKG);$(STAGING_DIR_HOST)
+ CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions
+ 
+ define Build/Configure/Default
+diff --git a/include/host-build.mk b/include/host-build.mk
+index 5cfbdeba5138c4362f82b7ae86b910a1f41f082a..fee7c6ce8fca6160a7055a8ccb9c0ebd0759032b 100644
+--- a/include/host-build.mk
++++ b/include/host-build.mk
+@@ -115,7 +115,7 @@ ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
+ endif
+ 
+ define Host/Exports/Default
+-  $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-* $(if $(IS_PACKAGE_BUILD),$$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*)),-I $$(p))
++  $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-* $(if $(IS_PACKAGE_BUILD),$$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR_HOSTPKG)/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*)),-I $$(p))
+   $(1) : export STAGING_PREFIX=$$(HOST_BUILD_PREFIX)
+   $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig:$$(HOST_BUILD_PREFIX)/lib/pkgconfig
+   $(1) : export PKG_CONFIG_LIBDIR=$$(HOST_BUILD_PREFIX)/lib/pkgconfig
+diff --git a/include/package.mk b/include/package.mk
+index 32485176577b040f6e4a561c5d1144509877bcdf..ea801288eadb139cc0dd2412b4c927c6bd7330e0 100644
+--- a/include/package.mk
++++ b/include/package.mk
+@@ -130,7 +130,7 @@ ifdef USE_SOURCE_DIR
+ endif
+ 
+ define Build/Exports/Default
+-  $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR)/usr/share/aclocal $$(STAGING_DIR)/usr/share/aclocal-* $$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*),-I $$(p))
++  $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR)/usr/share/aclocal $$(STAGING_DIR)/usr/share/aclocal-* $$(STAGING_DIR_HOSTPKG)/share/aclocal $$(STAGING_DIR_HOSTPKG)/share/aclocal-* $$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*),-I $$(p))
+   $(1) : export STAGING_PREFIX=$$(STAGING_DIR)/usr
+   $(1) : export PATH=$$(TARGET_PATH_PKG)
+   $(1) : export CONFIG_SITE:=$$(CONFIG_SITE)
+diff --git a/rules.mk b/rules.mk
+index 04fd936660bef4af49de5500cd2d7c3601c1b9f6..95b18f9e5c69de479db54c5bdb740103140dcf74 100644
+--- a/rules.mk
++++ b/rules.mk
+@@ -145,9 +145,9 @@ STAGING_DIR_ROOT:=$(STAGING_DIR)/root-$(BOARD)
+ BUILD_LOG_DIR:=$(TOPDIR)/logs
+ PKG_INFO_DIR := $(STAGING_DIR)/pkginfo
+ 
+-BUILD_DIR_HOST:=$(if $(IS_PACKAGE_BUILD),$(BUILD_DIR)/host,$(BUILD_DIR_BASE)/host)
++BUILD_DIR_HOST:=$(if $(IS_PACKAGE_BUILD),$(BUILD_DIR_BASE)/hostpkg,$(BUILD_DIR_BASE)/host)
+ STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host
+-STAGING_DIR_HOSTPKG:=$(STAGING_DIR)/host
++STAGING_DIR_HOSTPKG:=$(TOPDIR)/staging_dir/hostpkg
+ 
+ TARGET_PATH:=$(subst $(space),:,$(filter-out .,$(filter-out ./,$(subst :,$(space),$(PATH)))))
+ TARGET_INIT_PATH:=$(call qstrip,$(CONFIG_TARGET_INIT_PATH))
+@@ -206,7 +206,7 @@ ifndef DUMP
+     endif
+   endif
+ endif
+-TARGET_PATH_PKG:=$(STAGING_DIR)/host/bin:$(TARGET_PATH)
++TARGET_PATH_PKG:=$(STAGING_DIR)/host/bin:$(STAGING_DIR_HOSTPKG)/bin:$(TARGET_PATH)
+ 
+ ifeq ($(CONFIG_SOFT_FLOAT),y)
+   SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
+@@ -232,9 +232,9 @@ export PKG_CONFIG
+ 
+ HOSTCC:=gcc
+ HOSTCXX:=g++
+-HOST_CPPFLAGS:=-I$(STAGING_DIR_HOST)/include -I$(STAGING_DIR_HOST)/usr/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR)/host/include)
++HOST_CPPFLAGS:=-I$(STAGING_DIR_HOST)/include -I$(STAGING_DIR_HOST)/usr/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR_HOSTPKG)/include -I$(STAGING_DIR)/host/include)
+ HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS)
+-HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib -L$(STAGING_DIR_HOST)/usr/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR)/host/lib)
++HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib -L$(STAGING_DIR_HOST)/usr/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib)
+ 
+ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+   TARGET_AR:=$(TARGET_CROSS)gcc-ar

+ 0 - 0
patches/openwrt/0002-procd-add-support-for-alternative-rc.d-directories.patch → patches/lede/0002-procd-add-support-for-alternative-rc.d-directories.patch


+ 43 - 0
patches/lede/0003-base-files-disable-reset-button-handling.patch

@@ -0,0 +1,43 @@
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Sat, 21 Mar 2015 16:40:52 +0100
+Subject: base-files: disable reset button handling
+
+This conflicts with our reset button usage.
+
+diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset
+deleted file mode 100755
+index 4265767437e8eda3c758fe7f7941d7f608c95782..0000000000000000000000000000000000000000
+--- a/package/base-files/files/etc/rc.button/reset
++++ /dev/null
+@@ -1,31 +0,0 @@
+-#!/bin/sh
+-
+-. /lib/functions.sh
+-
+-OVERLAY="$( grep ' /overlay ' /proc/mounts )"
+-
+-case "$ACTION" in
+-pressed)
+-	[ -z "$OVERLAY" ] && return 0
+-
+-	return 5
+-;;
+-timeout)
+-	. /etc/diag.sh
+-	set_state failsafe
+-;;
+-released)
+-	if [ "$SEEN" -lt 1 ]
+-	then
+-		echo "REBOOT" > /dev/console
+-		sync
+-		reboot
+-	elif [ "$SEEN" -gt 5 -a -n "$OVERLAY" ]
+-	then
+-		echo "FACTORY RESET" > /dev/console
+-		jffs2reset -y && reboot &
+-	fi
+-;;
+-esac
+-
+-return 0

+ 0 - 0
patches/openwrt/0009-hostapd-prevent-channel-switch-for-5GHz.patch → patches/lede/0004-hostapd-prevent-channel-switch-for-5GHz.patch


+ 0 - 0
patches/openwrt/0042-libjson-c-Add-support-for-custom-format-strings-for-doubles.patch → patches/lede/0005-libjson-c-Add-support-for-custom-format-strings-for-doubles.patch


+ 69 - 0
patches/lede/0006-dropbear-add-a-failsafe-mode-that-will-always-allow-password-less-root-login.patch

@@ -0,0 +1,69 @@
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Tue, 27 Sep 2016 03:55:55 +0200
+Subject: dropbear: add a failsafe mode that will always allow password-less root login
+
+Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
+
+diff --git a/package/network/services/dropbear/patches/700-failsafe-mode.patch b/package/network/services/dropbear/patches/700-failsafe-mode.patch
+new file mode 100644
+index 0000000000000000000000000000000000000000..c6e45423e2dba1258549a5bfe4b5a59ac32d73d8
+--- /dev/null
++++ b/package/network/services/dropbear/patches/700-failsafe-mode.patch
+@@ -0,0 +1,57 @@
++--- a/runopts.h
+++++ b/runopts.h
++@@ -97,6 +97,8 @@ typedef struct svr_runopts {
++ 	int norootpass;
++ 	int allowblankpass;
++ 
+++	int failsafe_mode;
+++
++ #ifdef ENABLE_SVR_REMOTETCPFWD
++ 	int noremotetcp;
++ #endif
++--- a/svr-auth.c
+++++ b/svr-auth.c
++@@ -149,10 +149,11 @@ void recv_msg_userauth_request() {
++ 				AUTH_METHOD_NONE_LEN) == 0) {
++ 		TRACE(("recv_msg_userauth_request: 'none' request"))
++ 		if (valid_user
++-				&& (svr_opts.allowblankpass || !strcmp(ses.authstate.pw_name, "root"))
++-				&& !svr_opts.noauthpass
++-				&& !(svr_opts.norootpass && ses.authstate.pw_uid == 0) 
++-				&& ses.authstate.pw_passwd[0] == '\0') 
+++				&& ((svr_opts.failsafe_mode && !strcmp(ses.authstate.pw_name, "root"))
+++				|| ((svr_opts.allowblankpass || !strcmp(ses.authstate.pw_name, "root"))
+++					&& !svr_opts.noauthpass
+++					&& !(svr_opts.norootpass && ses.authstate.pw_uid == 0)
+++					&& ses.authstate.pw_passwd[0] == '\0')))
++ 		{
++			dropbear_log(LOG_NOTICE, 
++ 					"Auth succeeded with blank password for '%s' from %s",
++--- a/svr-runopts.c
+++++ b/svr-runopts.c
++@@ -72,6 +72,7 @@ static void printhelp(const char * progn
++ 					"-s		Disable password logins\n"
++ 					"-g		Disable password logins for root\n"
++ 					"-B		Allow blank password logins\n"
+++					"-f		Failsafe mode: always allow password-less root login\n"
++ #endif
++ #ifdef ENABLE_SVR_LOCALTCPFWD
++ 					"-j		Disable local port forwarding\n"
++@@ -130,6 +131,7 @@ void svr_getopts(int argc, char ** argv)
++ 	svr_opts.noauthpass = 0;
++ 	svr_opts.norootpass = 0;
++ 	svr_opts.allowblankpass = 0;
+++	svr_opts.failsafe_mode = 0;
++ 	svr_opts.inetdmode = 0;
++ 	svr_opts.portcount = 0;
++ 	svr_opts.hostkey = NULL;
++@@ -244,6 +246,9 @@ void svr_getopts(int argc, char ** argv)
++ 				case 'B':
++ 					svr_opts.allowblankpass = 1;
++ 					break;
+++				case 'f':
+++					svr_opts.failsafe_mode = 1;
+++					break;
++ #endif
++ 				case 'h':
++ 					printhelp(argv[0]);

+ 0 - 36
patches/openwrt/0001-tools-Makefile-fix-host-tools-build-dependencies.patch

@@ -1,36 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sat, 26 Jul 2014 06:10:23 +0200
-Subject: tools/Makefile: fix host tools build dependencies
-
-diff --git a/tools/Makefile b/tools/Makefile
-index d2fe2ffddf4b7207a937ca75efe1c2728e8067aa..c6cded8eccd81c422f99e7ee50754c4bc66decc7 100644
---- a/tools/Makefile
-+++ b/tools/Makefile
-@@ -95,10 +95,16 @@ define PrepareStaging
- endef
- 
- # preparatory work
-+ifneq ($(ARCH),)
-+staging_prepared = $(STAGING_DIR)/.prepared
-+
- $(STAGING_DIR)/.prepared: $(TMP_DIR)/.build
- 	$(call PrepareStaging,$(STAGING_DIR))
- 	mkdir -p $(BUILD_DIR)/stamp
- 	touch $@
-+else
-+staging_prepared :=
-+endif
- 
- $(STAGING_DIR_HOST)/.prepared: $(TMP_DIR)/.build
- 	$(call PrepareStaging,$(STAGING_DIR_HOST))
-@@ -110,8 +116,8 @@ $(STAGING_DIR_HOST)/.prepared: $(TMP_DIR)/.build
- 
- endif
- 
--$(curdir)//prepare = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared
--$(curdir)//compile = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared
-+$(curdir)//prepare = $(staging_prepared) $(STAGING_DIR_HOST)/.prepared
-+$(curdir)//compile = $(staging_prepared) $(STAGING_DIR_HOST)/.prepared
- 
- # prerequisites for the individual targets
- $(curdir)/ := .config prereq

+ 0 - 118
patches/openwrt/0003-odhcp6c-backport-from-LEDE-0d49f9f4b4da9d1960f82e68ae797290e4b9c434.patch

@@ -1,118 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Tue, 17 Jan 2017 22:08:21 +0100
-Subject: odhcp6c: backport from LEDE 0d49f9f4b4da9d1960f82e68ae797290e4b9c434
-
-diff --git a/package/network/ipv6/odhcp6c/Makefile b/package/network/ipv6/odhcp6c/Makefile
-index 3705705f6540dc841c7041e81f6d208a41a1f08a..a8e45588a52859daf14c68c665a53690b9d09be2 100644
---- a/package/network/ipv6/odhcp6c/Makefile
-+++ b/package/network/ipv6/odhcp6c/Makefile
-@@ -8,15 +8,16 @@
- include $(TOPDIR)/rules.mk
- 
- PKG_NAME:=odhcp6c
--PKG_VERSION:=2016-02-08
-+PKG_VERSION:=2017-01-07
- PKG_RELEASE=$(PKG_SOURCE_VERSION)
- 
- PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
- PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
--PKG_SOURCE_URL:=https://github.com/openwrt/odhcp6c.git
-+PKG_SOURCE_URL:=git://git.lede-project.org/project/odhcp6c.git
- PKG_SOURCE_PROTO:=git
--PKG_SOURCE_VERSION:=dc186d6d2b0dd4ad23ca5fc69c00e81f796ff6d9
--PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
-+PKG_SOURCE_VERSION:=d420f49396c627ce1072b83170889baf0720bc8b
-+PKG_MIRROR_HASH:=a7c599b5600b6cca9aec221dd32fc7754e0e942b0192bd902f1e789f53345127
-+PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
- PKG_LICENSE:=GPL-2.0
- 
- include $(INCLUDE_DIR)/package.mk
-@@ -30,7 +31,7 @@ define Package/odhcp6c
-   SECTION:=net
-   CATEGORY:=Network
-   TITLE:=Embedded DHCPv6-client for OpenWrt
--  DEPENDS:=+kmod-ipv6
-+  DEPENDS:=@IPV6 +libubox
- endef
- 
- define Package/odhcp6c/config
-diff --git a/package/network/ipv6/odhcp6c/files/dhcpv6.script b/package/network/ipv6/odhcp6c/files/dhcpv6.script
-index 677d35f4f92e82d6a7fe9ca01a35e071097baca8..1bb5e771b6dc80c1f5bceef88508d92cc69b1d3a 100755
---- a/package/network/ipv6/odhcp6c/files/dhcpv6.script
-+++ b/package/network/ipv6/odhcp6c/files/dhcpv6.script
-@@ -77,6 +77,11 @@ setup_interface () {
- 				-z "$RA_DNS" -a "$FAKE_ROUTES" = 1 ]; then
- 			RA_ROUTES="::/0,$SERVER,$valid,4096"
- 		fi
-+
-+		# RFC 7278
-+		if [ "$mask" -eq 64 -a -z "$PREFIXES" -a -n "$EXTENDPREFIX" ]; then
-+			proto_add_ipv6_prefix "$addr/$mask,$preferred,$valid"
-+		fi
- 	done
- 
- 	for entry in $RA_ROUTES; do
-@@ -180,7 +185,7 @@ setup_interface () {
- 	# Apply IPv6 / ND configuration
- 	HOPLIMIT=$(cat /proc/sys/net/ipv6/conf/$device/hop_limit)
- 	[ -n "$RA_HOPLIMIT" -a -n "$HOPLIMIT" ] && [ "$RA_HOPLIMIT" -gt "$HOPLIMIT" ] && echo "$RA_HOPLIMIT" > /proc/sys/net/ipv6/conf/$device/hop_limit
--	[ -n "$RA_MTU" ] && [ "$RA_MTU" -gt 0 ] && echo "$RA_MTU" > /proc/sys/net/ipv6/conf/$device/mtu
-+	[ -n "$RA_MTU" ] && [ "$RA_MTU" -ge 1280 ] && echo "$RA_MTU" > /proc/sys/net/ipv6/conf/$device/mtu 2>/dev/null
- 	[ -n "$RA_REACHABLE" ] && [ "$RA_REACHABLE" -gt 0 ] && echo "$RA_REACHABLE" > /proc/sys/net/ipv6/neigh/$device/base_reachable_time_ms
- 	[ -n "$RA_RETRANSMIT" ] && [ "$RA_RETRANSMIT" -gt 0 ] && echo "$RA_RETRANSMIT" > /proc/sys/net/ipv6/neigh/$device/retrans_time_ms
- 
-@@ -209,6 +214,6 @@ case "$2" in
- esac
- 
- # user rules
--[ -f /etc/odhcp6c.user ] && . /etc/odhcp6c.user
-+[ -f /etc/odhcp6c.user ] && . /etc/odhcp6c.user "@"
- 
- exit 0
-diff --git a/package/network/ipv6/odhcp6c/files/dhcpv6.sh b/package/network/ipv6/odhcp6c/files/dhcpv6.sh
-index 4a453fdc4d94d9298067a986b0e4c6054b6c0a60..9e3f6697335a55cf4be1751fec907a4ac93f09ec 100755
---- a/package/network/ipv6/odhcp6c/files/dhcpv6.sh
-+++ b/package/network/ipv6/odhcp6c/files/dhcpv6.sh
-@@ -13,6 +13,7 @@ proto_dhcpv6_init_config() {
- 	proto_config_add_string 'reqopts:list(uinteger)'
- 	proto_config_add_string 'noslaaconly:bool'
- 	proto_config_add_string 'forceprefix:bool'
-+	proto_config_add_string 'extendprefix:bool'
- 	proto_config_add_string 'norelease:bool'
- 	proto_config_add_string 'ip6prefix:ip6addr'
- 	proto_config_add_string iface_dslite
-@@ -29,14 +30,15 @@ proto_dhcpv6_init_config() {
- 	proto_config_add_int "soltimeout"
- 	proto_config_add_boolean fakeroutes
- 	proto_config_add_boolean sourcefilter
-+	proto_config_add_boolean keep_ra_dnslifetime
- }
- 
- proto_dhcpv6_setup() {
- 	local config="$1"
- 	local iface="$2"
- 
--	local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter
--	json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter
-+	local reqaddress reqprefix clientid reqopts noslaaconly forceprefix extendprefix norelease ip6prefix iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter keep_ra_dnslifetime
-+	json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix extendprefix norelease ip6prefix iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter keep_ra_dnslifetime
- 
- 
- 	# Configure
-@@ -60,6 +62,8 @@ proto_dhcpv6_setup() {
- 
- 	[ -n "$userclass" ] && append opts "-u$userclass"
- 
-+	[ "$keep_ra_dnslifetime" = "1" ] && append opts "-L"
-+
- 	for opt in $reqopts; do
- 		append opts "-r$opt"
- 	done
-@@ -78,6 +82,7 @@ proto_dhcpv6_setup() {
- 	[ -n "$zone" ] && proto_export "ZONE=$zone"
- 	[ "$fakeroutes" != "0" ] && proto_export "FAKE_ROUTES=1"
- 	[ "$sourcefilter" = "0" ] && proto_export "NOSOURCEFILTER=1"
-+	[ "$extendprefix" = "1" ] && proto_export "EXTENDPREFIX=1"
- 
- 	proto_export "INTERFACE=$config"
- 	proto_run_command "$config" odhcp6c \

+ 0 - 26
patches/openwrt/0004-busybox-enable-telnet-only-when-root-password-is-really-empty-not-when-it-is-locked.patch

@@ -1,26 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 5 Dec 2014 18:57:16 +0100
-Subject: busybox: enable telnet only when root password is really empty, not when it is locked
-
-diff --git a/package/utils/busybox/files/telnet b/package/utils/busybox/files/telnet
-index a1d1cdf9b18d69895e7a08a8b1318f1ff591ea07..f95be90490597f6251d8c3e1247b522dfd9e72c0 100755
---- a/package/utils/busybox/files/telnet
-+++ b/package/utils/busybox/files/telnet
-@@ -11,7 +11,7 @@ has_root_pwd() {
- 	      pwd="${pwd#*root:}"
- 	      pwd="${pwd%%:*}"
- 
--	test -n "${pwd#[\!x]}"
-+	test -n "${pwd}"
- }
- 
- get_root_home() {
-@@ -28,7 +28,7 @@ has_ssh_pubkey() {
- 
- start_service() {
- 	if ( ! has_ssh_pubkey && \
--	     ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \
-+	   ( ! has_root_pwd /etc/passwd || ! has_root_pwd /etc/shadow ) ) || \
- 	   ( ! /etc/init.d/dropbear enabled 2> /dev/null && ! /etc/init.d/sshd enabled 2> /dev/null );
- 	then
- 		procd_open_instance

+ 0 - 32
patches/openwrt/0005-base-files-disable-reset-button-handling.patch

@@ -1,32 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sat, 21 Mar 2015 16:40:52 +0100
-Subject: base-files: disable reset button handling
-
-This conflicts with our reset button usage.
-
-diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset
-deleted file mode 100755
-index 3e241460efbb08abaa775c1a7843b5fa3e237d44..0000000000000000000000000000000000000000
---- a/package/base-files/files/etc/rc.button/reset
-+++ /dev/null
-@@ -1,20 +0,0 @@
--#!/bin/sh
--
--[ "${ACTION}" = "released" ] || exit 0
--
--. /lib/functions.sh
--
--logger "$BUTTON pressed for $SEEN seconds"
--
--if [ "$SEEN" -lt 1 ]
--then
--	echo "REBOOT" > /dev/console
--	sync
--	reboot
--elif [ "$SEEN" -gt 5 ]
--then
--	echo "FACTORY RESET" > /dev/console
--	jffs2reset -y && reboot &
--fi
--
--return 0

+ 0 - 85
patches/openwrt/0006-ar71xx-define-wmac-reset-function-for-QCA955x.patch

@@ -1,85 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Tue, 19 Jul 2016 17:48:53 +0200
-Subject: ar71xx: define wmac reset function for QCA955x
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
-
-Backport of LEDE a176168a85477caa44eef7e979567d1d52868fde
-
-diff --git a/target/linux/ar71xx/patches-3.18/640-MIPS-ath79-add-QCA955x-wmac-reset.patch b/target/linux/ar71xx/patches-3.18/640-MIPS-ath79-add-QCA955x-wmac-reset.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..4ac5acd618748fc9ad0f091d110d2503cdc39d53
---- /dev/null
-+++ b/target/linux/ar71xx/patches-3.18/640-MIPS-ath79-add-QCA955x-wmac-reset.patch
-@@ -0,0 +1,71 @@
-+--- a/arch/mips/ath79/common.h
-++++ b/arch/mips/ath79/common.h
-+@@ -19,6 +19,8 @@
-+ #define ATH79_MEM_SIZE_MIN	(2 * 1024 * 1024)
-+ #define ATH79_MEM_SIZE_MAX	(128 * 1024 * 1024)
-+ 
-++extern void __iomem *ath79_ddr_base;
-++
-+ void ath79_clocks_init(void);
-+ unsigned long ath79_get_sys_clk_rate(const char *id);
-+ 
-+--- a/arch/mips/ath79/dev-wmac.c
-++++ b/arch/mips/ath79/dev-wmac.c
-+@@ -149,6 +149,27 @@ static void ar934x_wmac_setup(void)
-+ 		ath79_wmac_data.is_clk_25mhz = true;
-+ }
-+ 
-++static int ar955x_wmac_reset(void)
-++{
-++	int i;
-++
-++	/* Try to wait for WMAC DDR activity to stop */
-++	for (i = 0; i < 10; i++) {
-++		if (!(__raw_readl(ath79_ddr_base + QCA955X_DDR_CTL_CONFIG) &
-++		      QCA955X_DDR_CTL_CONFIG_ACT_WMAC))
-++			break;
-++
-++		udelay(10);
-++	}
-++
-++	ath79_device_reset_set(QCA955X_RESET_RTC);
-++	udelay(10);
-++	ath79_device_reset_clear(QCA955X_RESET_RTC);
-++	udelay(10);
-++
-++	return 0;
-++}
-++
-+ static void qca955x_wmac_setup(void)
-+ {
-+ 	u32 t;
-+@@ -165,6 +186,8 @@ static void qca955x_wmac_setup(void)
-+ 		ath79_wmac_data.is_clk_25mhz = false;
-+ 	else
-+ 		ath79_wmac_data.is_clk_25mhz = true;
-++
-++	ath79_wmac_data.external_reset = ar955x_wmac_reset;
-+ }
-+ 
-+ static bool __init
-+--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
-++++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
-+@@ -32,7 +32,7 @@
-+ #define AR71XX_SPI_SIZE		0x01000000
-+ 
-+ #define AR71XX_DDR_CTRL_BASE	(AR71XX_APB_BASE + 0x00000000)
-+-#define AR71XX_DDR_CTRL_SIZE	0x100
-++#define AR71XX_DDR_CTRL_SIZE	0x200
-+ #define AR71XX_UART_BASE	(AR71XX_APB_BASE + 0x00020000)
-+ #define AR71XX_UART_SIZE	0x100
-+ #define AR71XX_USB_CTRL_BASE	(AR71XX_APB_BASE + 0x00030000)
-+@@ -173,6 +173,9 @@
-+ #define AR934X_DDR_REG_FLUSH_PCIE	0xa8
-+ #define AR934X_DDR_REG_FLUSH_WMAC	0xac
-+ 
-++#define QCA955X_DDR_CTL_CONFIG		0x108
-++#define QCA955X_DDR_CTL_CONFIG_ACT_WMAC	BIT(23)
-++
-+ /*
-+  * PLL block
-+  */

File diff suppressed because it is too large
+ 0 - 17348
patches/openwrt/0007-mac80211-hostapd-iw-.-update.patch


+ 0 - 24
patches/openwrt/0008-iwinfo-update-NanoStation-Loco-txpower-offsets.patch

@@ -1,24 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Wed, 20 May 2015 23:15:20 +0200
-Subject: iwinfo: update NanoStation (Loco) txpower offsets
-
-diff --git a/package/network/utils/iwinfo/patches/001-update_nanostation_offsets.patch b/package/network/utils/iwinfo/patches/001-update_nanostation_offsets.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..1e13570fc2b585a8e33275116370f5438c899633
---- /dev/null
-+++ b/package/network/utils/iwinfo/patches/001-update_nanostation_offsets.patch
-@@ -0,0 +1,14 @@
-+--- a/hardware.txt
-++++ b/hardware.txt
-+@@ -42,8 +42,9 @@
-+ 0x168c 0x0027 0x0777 0x4082    7      0  "Ubiquiti" "SR71"
-+ 0x168c 0x0029 0x0777 0x4005    7      0  "Ubiquiti" "SR71-15"
-+ 0x168c 0x002a 0x0777 0xe302   12      0  "Ubiquiti" "PicoStation M2" /* ToDo: confirm offset */
-+-0x168c 0x002a 0x0777 0xe012   12      0  "Ubiquiti" "NanoStation M2" /* ToDo: confirm offset */
-+-0x168c 0x002a 0x0777 0xe005    5      0  "Ubiquiti" "NanoStation M5" /* ToDo: confirm offset */
-++0x168c 0x002a 0x0777 0xe012   11      0  "Ubiquiti" "NanoStation M2"
-++0x168c 0x002e 0x0777 0xe0a2    8      0  "Ubiquiti" "NanoStation Loco M2"
-++0x168c 0x002a 0x0777 0xe005   16      0  "Ubiquiti" "NanoStation M5"
-+ 0x168c 0x002a 0x0777 0xe202   12      0  "Ubiquiti" "Bullet M2"
-+ 0x168c 0x002a 0x0777 0xe805    5      0  "Ubiquiti" "Bullet M5"
-+ 0x168c 0x002a 0x0777 0xe345    0      0  "Ubiquiti" "WispStation M5" /* ToDo: confirm offset */

+ 0 - 57
patches/openwrt/0010-ipv6-fix-crash-on-ICMPv6-redirects-with-prohibited-blackholed-source.patch

@@ -1,57 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Mon, 2 Nov 2015 02:02:02 +0100
-Subject: ipv6: fix crash on ICMPv6 redirects with prohibited/blackholed source
-
-There are other error values besides ip6_null_entry that can be returned by
-ip6_route_redirect(): fib6_rule_action() can also result in
-ip6_blk_hole_entry and ip6_prohibit_entry if such ip rules are installed.
-
-Only checking for ip6_null_entry in rt6_do_redirect() causes ip6_ins_rt()
-to be called with rt->rt6i_table == NULL in these cases, making the kernel
-crash.
-
-diff --git a/target/linux/generic/patches-3.18/672-ipv6-fix-crash-on-ICMPv6-redirects-with-prohibited-blackholed-source.patch b/target/linux/generic/patches-3.18/672-ipv6-fix-crash-on-ICMPv6-redirects-with-prohibited-blackholed-source.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..6e4b3da3ad820e789f57df71b33ccfc5eaead01e
---- /dev/null
-+++ b/target/linux/generic/patches-3.18/672-ipv6-fix-crash-on-ICMPv6-redirects-with-prohibited-blackholed-source.patch
-@@ -0,0 +1,39 @@
-+From 7426eb388ade0f1ad800c408d7efa227d4f41408 Mon Sep 17 00:00:00 2001
-+Message-Id: <7426eb388ade0f1ad800c408d7efa227d4f41408.1446425986.git.mschiffer@universe-factory.net>
-+From: Matthias Schiffer <mschiffer@universe-factory.net>
-+Date: Mon, 2 Nov 2015 01:05:15 +0100
-+Subject: [PATCH] ipv6: fix crash on ICMPv6 redirects with
-+ prohibited/blackholed source
-+
-+There are other error values besides ip6_null_entry that can be returned by
-+ip6_route_redirect(): fib6_rule_action() can also result in
-+ip6_blk_hole_entry and ip6_prohibit_entry if such ip rules are installed.
-+
-+Only checking for ip6_null_entry in rt6_do_redirect() causes ip6_ins_rt()
-+to be called with rt->rt6i_table == NULL in these cases, making the kernel
-+crash.
-+
-+Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-+---
-+ net/ipv6/route.c | 3 +--
-+ 1 file changed, 1 insertion(+), 2 deletions(-)
-+
-+--- a/net/ipv6/route.c
-++++ b/net/ipv6/route.c
-+@@ -1766,7 +1766,6 @@ static int ip6_route_del(struct fib6_con
-+ 
-+ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_buff *skb)
-+ {
-+-	struct net *net = dev_net(skb->dev);
-+ 	struct netevent_redirect netevent;
-+ 	struct rt6_info *rt, *nrt = NULL;
-+ 	struct ndisc_options ndopts;
-+@@ -1827,7 +1826,7 @@ static void rt6_do_redirect(struct dst_e
-+ 	}
-+ 
-+ 	rt = (struct rt6_info *) dst;
-+-	if (rt == net->ipv6.ip6_null_entry) {
-++	if (rt->rt6i_flags & RTF_REJECT) {
-+ 		net_dbg_ratelimited("rt6_redirect: source isn't a valid nexthop for redirect target\n");
-+ 		return;
-+ 	}

+ 0 - 16
patches/openwrt/0011-lua-fix-installation-of-headers-for-host-build.patch

@@ -1,16 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Tue, 29 Dec 2015 22:48:52 +0100
-Subject: lua: fix installation of headers for host build
-
-diff --git a/package/utils/lua/Makefile b/package/utils/lua/Makefile
-index 72d56316b45dc484888d219aebd98e651edbe415..c37d99b485d58d955b86a033ea776adb54cfa414 100644
---- a/package/utils/lua/Makefile
-+++ b/package/utils/lua/Makefile
-@@ -140,6 +140,7 @@ define Host/Install
- 	$(MAKE) -C $(HOST_BUILD_DIR) \
- 		INSTALL_TOP="$(STAGING_DIR_HOST)" \
- 		install
-+	$(CP) $(HOST_BUILD_DIR)/src/lnum_config.h $(STAGING_DIR_HOST)/include/
- endef
- 
- define Build/InstallDev

+ 0 - 63
patches/openwrt/0012-kernel-fs-seq_file-fallback-to-vmalloc-instead-of-oom-kill-processes.patch

@@ -1,63 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Mon, 4 Jan 2016 10:22:52 +0100
-Subject: kernel: fs, seq_file: fallback to vmalloc instead of oom kill processes
-
-diff --git a/target/linux/generic/patches-3.18/089-fs-seq_file-fallback-to-vmalloc-instead-of-oom-kill-.patch b/target/linux/generic/patches-3.18/089-fs-seq_file-fallback-to-vmalloc-instead-of-oom-kill-.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..cad56f4275287b73dd5e769ea34daee064ee8d69
---- /dev/null
-+++ b/target/linux/generic/patches-3.18/089-fs-seq_file-fallback-to-vmalloc-instead-of-oom-kill-.patch
-@@ -0,0 +1,53 @@
-+From 5cec38ac866bfb8775638e71a86e4d8cac30caae Mon Sep 17 00:00:00 2001
-+Message-Id: <5cec38ac866bfb8775638e71a86e4d8cac30caae.1451899087.git.mschiffer@universe-factory.net>
-+From: David Rientjes <rientjes@google.com>
-+Date: Fri, 12 Dec 2014 16:56:16 -0800
-+Subject: [PATCH] fs, seq_file: fallback to vmalloc instead of oom kill
-+ processes
-+
-+Since commit 058504edd026 ("fs/seq_file: fallback to vmalloc allocation"),
-+seq_buf_alloc() falls back to vmalloc() when the kmalloc() for contiguous
-+memory fails.  This was done to address order-4 slab allocations for
-+reading /proc/stat on large machines and noticed because
-+PAGE_ALLOC_COSTLY_ORDER < 4, so there is no infinite loop in the page
-+allocator when allocating new slab for such high-order allocations.
-+
-+Contiguous memory isn't necessary for caller of seq_buf_alloc(), however.
-+Other GFP_KERNEL high-order allocations that are <=
-+PAGE_ALLOC_COSTLY_ORDER will simply loop forever in the page allocator and
-+oom kill processes as a result.
-+
-+We don't want to kill processes so that we can allocate contiguous memory
-+in situations when contiguous memory isn't necessary.
-+
-+This patch does the kmalloc() allocation with __GFP_NORETRY for high-order
-+allocations.  This still utilizes memory compaction and direct reclaim in
-+the allocation path, the only difference is that it will fail immediately
-+instead of oom kill processes when out of memory.
-+
-+[akpm@linux-foundation.org: add comment]
-+Signed-off-by: David Rientjes <rientjes@google.com>
-+Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
-+Cc: Christoph Hellwig <hch@infradead.org>
-+Cc: Al Viro <viro@zeniv.linux.org.uk>
-+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-+---
-+ fs/seq_file.c | 6 +++++-
-+ 1 file changed, 5 insertions(+), 1 deletion(-)
-+
-+--- a/fs/seq_file.c
-++++ b/fs/seq_file.c
-+@@ -36,7 +36,11 @@ static void *seq_buf_alloc(unsigned long
-+ {
-+ 	void *buf;
-+ 
-+-	buf = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
-++	/*
-++	 * __GFP_NORETRY to avoid oom-killings with high-order allocations -
-++	 * it's better to fall back to vmalloc() than to kill things.
-++	 */
-++	buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
-+ 	if (!buf && size > PAGE_SIZE)
-+ 		buf = vmalloc(size);
-+ 	return buf;

+ 0 - 74
patches/openwrt/0013-fix-UBNT-XM-model-detection.patch

@@ -1,74 +0,0 @@
-From: Neal Oakey <neal.oakey@bingo-ev.de>
-Date: Sun, 14 Feb 2016 20:58:20 +0100
-Subject: fix UBNT XM model detection
-
-Signed-off-by: Neal Oakey <neal.oakey@bingo-ev.de>
-
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index a9dca58847fe1fb62a69c5845fda3206407c6727..0aa1c865cbdeb0624147d4117d289a640d20a5ef 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -64,6 +64,40 @@ wndr3700_board_detect() {
- 	AR71XX_MODEL="$machine"
- }
- 
-+ubnt_get_mtd_part_magic() {
-+	ar71xx_get_mtd_offset_size_format EEPROM 4118 2 %02x
-+}
-+
-+ubnt_xm_board_detect() {
-+	local model
-+	local magic
-+
-+	magic="$(ubnt_get_mtd_part_magic)"
-+	case ${magic:0:3} in
-+		"e00"|\
-+		"e01"|\
-+		"e80")
-+			model="Ubiquiti NanoStation M"
-+			;;
-+		"e0a")
-+			model="Ubiquiti NanoStation loco M"
-+			;;
-+		"e1b"|\
-+		"e1d")
-+			model="Ubiquiti Rocket M"
-+			;;
-+		"e20"|\
-+		"e2d")
-+			model="Ubiquiti Bullet M"
-+			;;
-+		"e30")
-+			model="Ubiquiti PicoStation M"
-+			;;
-+	esac
-+
-+	[ ! -z "$model" ] && AR71XX_MODEL="${model}${magic:3:1}"
-+}
-+
- cybertan_get_hw_magic() {
- 	local part
- 
-@@ -478,12 +512,14 @@ ar71xx_board_detect() {
- 		;;
- 	*"Bullet M")
- 		name="bullet-m"
-+		ubnt_xm_board_detect
- 		;;
- 	*"Loco M XW")
- 		name="loco-m-xw"
- 		;;
- 	*"Nanostation M")
- 		name="nanostation-m"
-+		ubnt_xm_board_detect
- 		;;
- 	*"Nanostation M XW")
- 		name="nanostation-m-xw"
-@@ -685,6 +721,7 @@ ar71xx_board_detect() {
- 		;;
- 	*"Rocket M")
- 		name="rocket-m"
-+		ubnt_xm_board_detect
- 		;;
- 	*"Rocket M XW")
- 		name="rocket-m-xw"

+ 0 - 133
patches/openwrt/0014-base-files-implemented-basic-GPIO-control.patch

@@ -1,133 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Mon, 7 Mar 2016 06:07:21 +0100
-Subject: base-files: implemented basic GPIO control
-
-Internal GPIO pins are used for PoE passthrough setups in multi-port
-routers. This patch implemnets control over this hardware feature for
-Ubiquiti Nanostations and TP-Link CPE510.
-
-Signed-off-by: Lars Kruse <lists@sumpfralle.de>
-
-Backport of r46271
-
-diff --git a/package/base-files/files/etc/init.d/gpio_switch b/package/base-files/files/etc/init.d/gpio_switch
-new file mode 100755
-index 0000000000000000000000000000000000000000..1f1b44b2129ce2315943f6a10508eefb66412c48
---- /dev/null
-+++ b/package/base-files/files/etc/init.d/gpio_switch
-@@ -0,0 +1,42 @@
-+#!/bin/sh /etc/rc.common
-+# Copyright (C) 2015 OpenWrt.org
-+
-+START=98
-+STOP=10
-+USE_PROCD=1
-+
-+
-+load_gpio_switch()
-+{
-+	local name
-+	local gpio_pin
-+	local value
-+
-+	config_get gpio_pin "$1" gpio_pin
-+	config_get name "$1" name
-+	config_get value "$1" value 0
-+
-+	local gpio_path="/sys/class/gpio/gpio${gpio_pin}"
-+	# export GPIO pin for access
-+	[ -d "$gpio_path" ] || {
-+		echo "$gpio_pin" >/sys/class/gpio/export
-+		# we need to wait a bit until the GPIO appears
-+		[ -d "$gpio_path" ] || sleep 1
-+		echo out >"$gpio_path/direction"
-+	}
-+	# write 0 or 1 to the "value" field
-+	{ [ "$value" = "0" ] && echo "0" || echo "1"; } >"$gpio_path/value"
-+}
-+
-+service_triggers()
-+{
-+	procd_add_reload_trigger "system"
-+}
-+
-+start_service()
-+{
-+	[ -e /sys/class/gpio/ ] && {
-+		config_load system
-+		config_foreach load_gpio_switch gpio_switch
-+	}
-+}
-diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
-index 5a8809d68c89ac0431919f15dad5f5c33351bbf2..6577ecdcde0c856b3e6dd1b9337f23cb782ef2be 100644
---- a/package/base-files/files/lib/functions/uci-defaults.sh
-+++ b/package/base-files/files/lib/functions/uci-defaults.sh
-@@ -2,6 +2,7 @@
- # Copyright (C) 2011 OpenWrt.org
- 
- UCIDEF_LEDS_CHANGED=0
-+UCIDEF_GPIO_SWITCHES_CHANGED=0
- 
- ucidef_set_led_netdev() {
- 	local cfg="led_$1"
-@@ -180,6 +181,29 @@ ucidef_commit_leds()
- 	[ "$UCIDEF_LEDS_CHANGED" = "1" ] && uci commit system
- }
- 
-+ucidef_set_gpio_switch() {
-+	local cfg="gpio_switch_$1"
-+	local name="$2"
-+	local gpio_pin="$3"
-+	# use "0" as default value
-+	local default="${4:-0}"
-+
-+	uci -q get "system.$cfg" && return 0
-+
-+	uci batch <<EOF
-+set system.$cfg='gpio_switch'
-+set system.$cfg.name='$name'
-+set system.$cfg.gpio_pin='$gpio_pin'
-+set system.$cfg.value='$default'
-+EOF
-+	UCIDEF_GPIO_SWITCHES_CHANGED=1
-+}
-+
-+ucidef_commit_gpio_switches()
-+{
-+	[ "$UCIDEF_GPIO_SWITCHES_CHANGED" = "1" ] && uci commit system
-+}
-+
- ucidef_set_interface_loopback() {
- 	uci batch <<EOF
- set network.loopback='interface'
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches b/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-new file mode 100644
-index 0000000000000000000000000000000000000000..81d3982ed8bf98e01ce2e161017f088a1d0f60dc
---- /dev/null
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-@@ -0,0 +1,25 @@
-+#!/bin/sh
-+#
-+# Copyright (C) 2015 OpenWrt.org
-+#
-+
-+. /lib/functions/uci-defaults.sh
-+. /lib/ar71xx.sh
-+
-+board=$(ar71xx_board_name)
-+
-+case "$board" in
-+nanostation-m)
-+	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "2"
-+	;;
-+nanostation-m-xw)
-+	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "8"
-+	;;
-+cpe510)
-+	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "20"
-+	;;
-+esac
-+
-+ucidef_commit_gpio_switches
-+
-+exit 0

+ 0 - 32
patches/openwrt/0015-ar71xx-assign-proper-GPIO-pin-for-Ubiquiti-Nanostation-models.patch

@@ -1,32 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Mon, 7 Mar 2016 06:07:59 +0100
-Subject: ar71xx: assign proper GPIO pin for Ubiquiti Nanostation models
-
-The GPIO pins for "POE passthrough" of Ubiquiti Nanostation models are the
-following:
-* Ubiquiti Nanostation M XM: Pin 8
-* Ubiquiti Nanostation M XW: Pin 2
-
-The previous definition of the pins was mixed up between XM and XW model.
-
-Signed-off-by: Lars Kruse <lists@sumpfralle.de>
-
-Backport of r46922
-
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches b/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-index 81d3982ed8bf98e01ce2e161017f088a1d0f60dc..b41f27554b1e3eac19c22af59731771631a1135b 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-@@ -10,10 +10,10 @@ board=$(ar71xx_board_name)
- 
- case "$board" in
- nanostation-m)
--	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "2"
-+	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "8"
- 	;;
- nanostation-m-xw)
--	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "8"
-+	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "2"
- 	;;
- cpe510)
- 	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "20"

+ 0 - 101
patches/openwrt/0016-netifd-update-to-latest-version.patch

@@ -1,101 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 29 Jul 2016 21:28:24 +0200
-Subject: netifd: update to latest version
-
-diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
-index 619024bd708541dfb3bda28a963fc87a5d301a0d..dc83ca612bcd4c441e8fa0db77c98c8a1b97ad13 100644
---- a/package/network/config/netifd/Makefile
-+++ b/package/network/config/netifd/Makefile
-@@ -1,15 +1,15 @@
- include $(TOPDIR)/rules.mk
- 
- PKG_NAME:=netifd
--PKG_VERSION:=2015-12-16
-+PKG_VERSION:=2016-07-29
- PKG_RELEASE=$(PKG_SOURCE_VERSION)
- 
- PKG_SOURCE_PROTO:=git
- PKG_SOURCE_URL:=http://git.openwrt.org/project/netifd.git
- PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
--PKG_SOURCE_VERSION:=245527193e90906451be35c2b8e972b8712ea6ab
-+PKG_SOURCE_VERSION:=656c387974879105c2aaec6b62478d0195067f2d
- PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
--PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
-+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
- # PKG_MIRROR_MD5SUM:=
- # CMAKE_INSTALL:=1
- 
-diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
-index 542fc08958e001c2bfce7668ecd7d1c52a649e4e..bdadbbce6db6f9383a0e2c7fab25e7f5d8823091 100755
---- a/package/network/config/netifd/files/etc/init.d/network
-+++ b/package/network/config/netifd/files/etc/init.d/network
-@@ -21,7 +21,6 @@ start_service() {
- 	procd_set_param watch network.interface
- 	[ -e /proc/sys/kernel/core_pattern ] && {
- 		procd_set_param limits core="unlimited"
--		echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
- 	}
- 	procd_close_instance
- }
-diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
-index 0e88af9e96ad85e7c51ff0b497ce71342d2d1568..1d3a2091060aac6b89d8d10f915b11b251011a85 100755
---- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
-+++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
-@@ -12,6 +12,7 @@ proto_dhcp_init_config() {
- 	proto_config_add_string clientid
- 	proto_config_add_string vendorid
- 	proto_config_add_boolean 'broadcast:bool'
-+	proto_config_add_boolean 'release:bool'
- 	proto_config_add_string 'reqopts:list(string)'
- 	proto_config_add_string iface6rd
- 	proto_config_add_string sendopts
-@@ -26,8 +27,8 @@ proto_dhcp_setup() {
- 	local config="$1"
- 	local iface="$2"
- 
--	local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
--	json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
-+	local ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
-+	json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
- 
- 	local opt dhcpopts
- 	for opt in $reqopts; do
-@@ -39,6 +40,7 @@ proto_dhcp_setup() {
- 	done
- 
- 	[ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
-+	[ "$release" = 1 ] && release="-R" || release=
- 	[ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
- 	[ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd"
- 	[ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212"
-@@ -54,9 +56,9 @@ proto_dhcp_setup() {
- 		-s /lib/netifd/dhcp.script \
- 		-f -t 0 -i "$iface" \
- 		${ipaddr:+-r $ipaddr} \
--		${hostname:+-H $hostname} \
--		${vendorid:+-V $vendorid} \
--		$clientid $broadcast $dhcpopts
-+		${hostname:+-x "hostname:$hostname"} \
-+		${vendorid:+-V "$vendorid"} \
-+		$clientid $broadcast $release $dhcpopts
- }
- 
- proto_dhcp_renew() {
-diff --git a/package/network/config/netifd/files/sbin/ifup b/package/network/config/netifd/files/sbin/ifup
-index af3aaa8453ce93f52c2b89e743f43f9c509ad696..5515b91f76df2b5c36d46ac4b86dfc9bdcd78b1d 100755
---- a/package/network/config/netifd/files/sbin/ifup
-+++ b/package/network/config/netifd/files/sbin/ifup
-@@ -67,12 +67,10 @@ if [ -n "$setup_wifi" ] && grep -sq config /etc/config/wireless; then
- 		fi
- 	}
- 
--	local radio_devs
--	local network="$1"
-+	network="$1"
- 	config_load wireless
- 	config_foreach find_related_radios wifi-iface
- 
--	local dev
- 	for dev in $(echo "$radio_devs" | sort -u); do
- 		/sbin/wifi up "$dev"
- 	done

+ 0 - 25
patches/openwrt/0017-x86-fix-platform_export_bootpart-for-Xen-virtual-disks.patch

@@ -1,25 +0,0 @@
-From: Alexander Dahl <alex@netz39.de>
-Date: Thu, 17 Mar 2016 15:04:09 +0100
-Subject: x86: fix platform_export_bootpart() for Xen virtual disks
-
-Virtual disk devices in a Xen virtual machine (DomU) can be /dev/xvda,
-/dev/xvdb and so on with partitions like /dev/xdva1. Devices named like
-this where not considered before. This resulted in a non working
-sysupgrade, because the boot partition could not be found.
-
-Signed-off-by: Alexander Dahl <alex@netz39.de>
-Suggested-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
-index 73ab5ef0794c942495d18865fa2c2498b84e63e6..adc119c897ed840aef17c2041a48244d0922564e 100644
---- a/target/linux/x86/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
-@@ -17,7 +17,7 @@ platform_export_bootpart() {
- 			PARTUUID=[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]-02)
- 				uuid="${disk#PARTUUID=}"
- 				uuid="${uuid%-02}"
--				for disk in /dev/[hsv]d[a-z]; do
-+				for disk in /dev/[hsv]d[a-z] /dev/xvd[a-z]; do
- 					set -- $(dd if=$disk bs=1 skip=440 count=4 2>/dev/null | hexdump -v -e '4/1 "%02x "')
- 					if [ "$4$3$2$1" = "$uuid" ]; then
- 						export BOOTPART="${disk}1"

+ 0 - 27
patches/openwrt/0018-Support-LibreSSL-as-provider-of-openssl.patch

@@ -1,27 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Wed, 30 Mar 2016 02:59:19 +0200
-Subject: Support LibreSSL as provider of openssl
-
-The build scripts check for openssl by grepping the string "OpenSSL" in
-the output of openssl version command. LibreSSL fails this test as it
-outputs something like "LibreSSL 2.2.4". This patch fix the
-prereq-bulid.mk file so that it accepts LibreSSL as openssl provider as
-well.
-
-Signed-off-by: Marek Behun <kabel@blackhole.sk>
-
-Backport of r48267
-
-diff --git a/include/prereq-build.mk b/include/prereq-build.mk
-index 32c4adabb748c4026d507d40769b3201e2ac5599..f36d57ce06c46be7ac33f3034ad08a3ce603089d 100644
---- a/include/prereq-build.mk
-+++ b/include/prereq-build.mk
-@@ -151,7 +151,7 @@ $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
- 	file --version 2>&1 | grep file))
- 
- $(eval $(call SetupHostCommand,openssl,Please install the 'openssl' utility, \
--	openssl version | grep OpenSSL))
-+	openssl version | grep '\(OpenSSL\|LibreSSL\)'))
- 
- 
- # Install ldconfig stub

+ 0 - 48
patches/openwrt/0019-ar71xx-check-both-HWID-and-HWREV-on-upgrades-of-TP-LINK-devices.patch

@@ -1,48 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 1 Apr 2016 23:16:13 +0200
-Subject: ar71xx: check both HWID and HWREV on upgrades of TP-LINK devices
-
-There's no reason for us to be more lenient than the stock firmware, so
-better check the HWREV as well to avoid bricked devices.
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of r49105
-
-diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index 762cd760ceb9ff3917903dfd26a5a7a42175abfe..024e4930949c927efd36c3ac67cd351dcaa4bf7b 100755
---- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-@@ -66,6 +66,10 @@ tplink_get_image_hwid() {
- 	get_image "$@" | dd bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
- }
- 
-+tplink_get_image_mid() {
-+	get_image "$@" | dd bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
-+}
-+
- tplink_get_image_boot_size() {
- 	get_image "$@" | dd bs=4 count=1 skip=37 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
- }
-@@ -373,13 +377,17 @@ platform_check_image() {
- 		}
- 
- 		local hwid
--		local imageid
-+		local mid
-+		local imagehwid
-+		local imagemid
- 
- 		hwid=$(tplink_get_hwid)
--		imageid=$(tplink_get_image_hwid "$1")
-+		mid=$(tplink_get_mid)
-+		imagehwid=$(tplink_get_image_hwid "$1")
-+		imagemid=$(tplink_get_image_mid "$1")
- 
--		[ "$hwid" != "$imageid" ] && {
--			echo "Invalid image, hardware ID mismatch, hw:$hwid image:$imageid."
-+		[ "$hwid" != "$imagehwid" -o "$mid" != "$imagemid" ] && {
-+			echo "Invalid image, hardware ID mismatch, hw:$hwid $mid image:$imagehwid $imagemid."
- 			return 1
- 		}
- 

+ 0 - 45
patches/openwrt/0020-ar71xx-avoid-AR71XX_MODEL-ending-with-a-space-on-some-TP-LINK-like-devices.patch

@@ -1,45 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 1 Apr 2016 23:19:16 +0200
-Subject: ar71xx: avoid AR71XX_MODEL ending with a space on some TP-LINK-like devices
-
-Instead of adding the space when combining $model and $hwver, add the space
-to the beginning of $hwver, so the resulting string won't end with a space
-when $hwver is set to the empty string.
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of r49106
-
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index 0aa1c865cbdeb0624147d4117d289a640d20a5ef..96a37b4bec019d06c9283afc44b7961d150c05fb 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -133,7 +133,7 @@ tplink_board_detect() {
- 	hwid=$(tplink_get_hwid)
- 	mid=$(tplink_get_mid)
- 	hwver=${hwid:6:2}
--	hwver="v${hwver#0}"
-+	hwver=" v${hwver#0}"
- 
- 	case "$hwid" in
- 	"015000"*)
-@@ -196,8 +196,8 @@ tplink_board_detect() {
- 	"083000"*)
- 		model="TP-Link TL-WA830RE"
- 
--		if [ "$hwver" = 'v10' ]; then
--			hwver='v1'
-+		if [ "$hwver" = ' v10' ]; then
-+			hwver=' v1'
- 		fi
- 		;;
- 	"084100"*)
-@@ -296,7 +296,7 @@ tplink_board_detect() {
- 		;;
- 	esac
- 
--	AR71XX_MODEL="$model $hwver"
-+	AR71XX_MODEL="$model$hwver"
- }
- 
- tplink_pharos_get_model_string() {

+ 0 - 39
patches/openwrt/0021-ar71xx-fix-the-revision-of-a-few-TP-LINK-devices-in-AR71XX_MODEL-to-match-labels-image-names.patch

@@ -1,39 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 1 Apr 2016 23:21:32 +0200
-Subject: ar71xx: fix the revision of a few TP-LINK devices in AR71XX_MODEL to match labels/image names
-
-Let's not confuse users about the revisions of their devices when we can
-easily avoid it.
-
-Not tested on real hardware.
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of r49107
-
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index 96a37b4bec019d06c9283afc44b7961d150c05fb..6c106179bfa0c01308a03678aef1b7cf4caaf05b 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -162,6 +162,10 @@ tplink_board_detect() {
- 		;;
- 	"071000"*)
- 		model="TP-Link TL-WR710N"
-+
-+		if [ "$hwid" = '07100002' -a "$mid" = '00000002' ]; then
-+			hwver=' v2.1'
-+		fi
- 		;;
- 	"072001"*)
- 		model="TP-Link TL-WR720N"
-@@ -202,6 +206,10 @@ tplink_board_detect() {
- 		;;
- 	"084100"*)
- 		model="TP-Link TL-WR841N/ND"
-+
-+		if [ "$hwid" = '08410002' -a "$mid" = '00000002' ]; then
-+			hwver=' v1.5'
-+		fi
- 		;;
- 	"084200"*)
- 		model="TP-Link TL-WR842N/ND"

+ 0 - 41
patches/openwrt/0022-ar71xx-build-image-for-TL-WR710N-v2.1.patch

@@ -1,41 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sat, 2 Apr 2016 00:56:50 +0200
-Subject: ar71xx: build image for TL-WR710N v2.1
-
-This patch just extends target/linux/ar71xx/image/Makefile to build
-images also for version 2.1 of TL-WR710N
-patch against the latest git
-
-Signed off by: Norbert Wegener <nw@wegener-net.de>
-
-Backport of r47849
-
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index a8073f2ecadce8404dde77278302202fe494cd75..0783381baeddef2064df8faff89c49c2bed6a28b 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -476,6 +476,15 @@ define Device/tl-wr710n-v2
-     CONSOLE := ttyATH0,115200
- endef
- 
-+define Device/tl-wr710n-v2.1
-+    $(Device/tplink-8mlzma)
-+    BOARDNAME := TL-WR710N
-+    DEVICE_PROFILE := TLWR710
-+    TPLINK_HWID := 0x07100002
-+    TPLINK_HWREV := 0x00000002
-+    CONSOLE := ttyATH0,115200
-+endef
-+
- define Device/tl-wr720n-v3
-     $(Device/tplink-4mlzma)
-     BOARDNAME := TL-WR720N-v3
-@@ -491,7 +500,7 @@ define Device/tl-wr720n-v4
-     TPLINK_HWID := 0x07200104
-     CONSOLE := ttyATH0,115200
- endef
--TARGET_DEVICES += tl-wr703n-v1 tl-wr710n-v1 tl-wr710n-v2 tl-wr720n-v3 tl-wr720n-v4
-+TARGET_DEVICES += tl-wr703n-v1 tl-wr710n-v1 tl-wr710n-v2 tl-wr710n-v2.1 tl-wr720n-v3 tl-wr720n-v4
- 
- define Device/tl-wr740n-v4
-     $(Device/tplink-4mlzma)

+ 0 - 2026
patches/openwrt/0023-xtables-addons-build-fix-configure-compatiblity-with-POSIX-shells.patch

@@ -1,2026 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Tue, 5 Apr 2016 20:30:56 +0200
-Subject: xtables-addons: build: fix configure compatiblity with POSIX shells
-
-diff --git a/package/network/utils/xtables-addons/patches/001-build-fix-configure-compatiblity-with-POSIX-shells.patch b/package/network/utils/xtables-addons/patches/001-build-fix-configure-compatiblity-with-POSIX-shells.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..e0b11b5459e5e4cd49c80b76ed945eb96aa96e8d
---- /dev/null
-+++ b/package/network/utils/xtables-addons/patches/001-build-fix-configure-compatiblity-with-POSIX-shells.patch
-@@ -0,0 +1,51 @@
-+From f07a0a5cb8b3c5e1aee8b30c7fa21ccfbf24a95a Mon Sep 17 00:00:00 2001
-+Message-Id: <f07a0a5cb8b3c5e1aee8b30c7fa21ccfbf24a95a.1459880505.git.mschiffer@universe-factory.net>
-+From: Matthias Schiffer <mschiffer@universe-factory.net>
-+Date: Fri, 1 Apr 2016 22:24:00 +0200
-+Subject: [PATCH] build: fix configure compatiblity with POSIX shells
-+
-+The kernel version detection code uses some bashisms, which makes the build
-+fail on Debian systems where /bin/sh links to dash. Replace with POSIX-
-+conforming commands at the cost of requiring awk.
-+---
-+ configure.ac | 24 +++++++++---------------
-+ 1 file changed, 9 insertions(+), 15 deletions(-)
-+
-+diff --git a/configure.ac b/configure.ac
-+index 82a1355..5a5ea57 100644
-+--- a/configure.ac
-++++ b/configure.ac
-+@@ -44,21 +44,15 @@ regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
-+ 
-+ if test -n "$kbuilddir"; then
-+ 	AC_MSG_CHECKING([kernel version that we will build against])
-+-	krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
-+-	kmajor="${krel%%[[^0-9]]*}";
-+-	kmajor="$(($kmajor+0))";
-+-	krel="${krel:${#kmajor}}";
-+-	krel="${krel#.}";
-+-	kminor="${krel%%[[^0-9]]*}";
-+-	kminor="$(($kminor+0))";
-+-	krel="${krel:${#kminor}}";
-+-	krel="${krel#.}";
-+-	kmicro="${krel%%[[^0-9]]*}";
-+-	kmicro="$(($kmicro+0))";
-+-	krel="${krel:${#kmicro}}";
-+-	krel="${krel#.}";
-+-	kstable="${krel%%[[^0-9]]*}";
-+-	kstable="$(($kstable+0))";
-++	krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease | $AWK -v 'FS=[[^0-9.]]' '{print $1; exit}')";
-++	save_IFS=$IFS;
-++	IFS='.';
-++	set x $krel;
-++	IFS=$save_IFS;
-++	kmajor="$(($2+0))";
-++	kminor="$(($3+0))";
-++	kmicro="$(($4+0))";
-++	kstable="$(($5+0))";
-+ 	if test -z "$kmajor" -o -z "$kminor" -o -z "$kmicro"; then
-+ 		echo "WARNING: Version detection did not succeed. Continue at own luck.";
-+ 	else
-+-- 
-+2.8.0
-+
-diff --git a/package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch b/package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch
-index d3b7caa634ba0cc33b01bbf795f1f70995cb3dc6..6a7a099fcc3aad162fc2aaba70dac54882c2b464 100644
---- a/package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch
-+++ b/package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch
-@@ -1,1954 +1,11 @@
----- a/configure
--+++ b/configure
--@@ -1,9 +1,11 @@
-- #! /bin/sh
-- # Guess values for system-dependent variables and create Makefiles.
---# Generated by GNU Autoconf 2.69 for xtables-addons 2.5.
--+# Generated by GNU Autoconf 2.68 for xtables-addons 2.5.
-- #
-- #
---# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
--+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
--+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
--+# Foundation, Inc.
-- #
-- #
-- # This configure script is free software; the Free Software Foundation
--@@ -132,31 +134,6 @@ export LANGUAGE
-- # CDPATH.
-- (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-- 
---# Use a proper internal environment variable to ensure we don't fall
---  # into an infinite loop, continuously re-executing ourselves.
---  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
---    _as_can_reexec=no; export _as_can_reexec;
---    # We cannot yet assume a decent shell, so we have to provide a
---# neutralization value for shells without unset; and this also
---# works around shells that cannot unset nonexistent variables.
---# Preserve -v and -x to the replacement shell.
---BASH_ENV=/dev/null
---ENV=/dev/null
---(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
---case $- in # ((((
---  *v*x* | *x*v* ) as_opts=-vx ;;
---  *v* ) as_opts=-v ;;
---  *x* ) as_opts=-x ;;
---  * ) as_opts= ;;
---esac
---exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
---# Admittedly, this is quite paranoid, since all the known shells bail
---# out after a failed `exec'.
---$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
---as_fn_exit 255
---  fi
---  # We don't want this to propagate to other subprocesses.
---          { _as_can_reexec=; unset _as_can_reexec;}
-- if test "x$CONFIG_SHELL" = x; then
--   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
--   emulate sh
--@@ -190,8 +167,7 @@ if ( set x; as_fn_ret_success y && test 
-- else
--   exitcode=1; echo positional parameters were not saved.
-- fi
---test x\$exitcode = x0 || exit 1
---test -x / || exit 1"
--+test x\$exitcode = x0 || exit 1"
--   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
--   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
--   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
--@@ -244,25 +220,21 @@ IFS=$as_save_IFS
-- 
-- 
--       if test "x$CONFIG_SHELL" != x; then :
---  export CONFIG_SHELL
---             # We cannot yet assume a decent shell, so we have to provide a
---# neutralization value for shells without unset; and this also
---# works around shells that cannot unset nonexistent variables.
---# Preserve -v and -x to the replacement shell.
---BASH_ENV=/dev/null
---ENV=/dev/null
---(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
---case $- in # ((((
---  *v*x* | *x*v* ) as_opts=-vx ;;
---  *v* ) as_opts=-v ;;
---  *x* ) as_opts=-x ;;
---  * ) as_opts= ;;
---esac
---exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
---# Admittedly, this is quite paranoid, since all the known shells bail
---# out after a failed `exec'.
---$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
---exit 255
--+  # We cannot yet assume a decent shell, so we have to provide a
--+	# neutralization value for shells without unset; and this also
--+	# works around shells that cannot unset nonexistent variables.
--+	# Preserve -v and -x to the replacement shell.
--+	BASH_ENV=/dev/null
--+	ENV=/dev/null
--+	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
--+	export CONFIG_SHELL
--+	case $- in # ((((
--+	  *v*x* | *x*v* ) as_opts=-vx ;;
--+	  *v* ) as_opts=-v ;;
--+	  *x* ) as_opts=-x ;;
--+	  * ) as_opts= ;;
--+	esac
--+	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
-- fi
-- 
--     if test x$as_have_required = xno; then :
--@@ -364,14 +336,6 @@ $as_echo X"$as_dir" |
-- 
-- 
-- } # as_fn_mkdir_p
---
---# as_fn_executable_p FILE
---# -----------------------
---# Test if FILE is an executable regular file.
---as_fn_executable_p ()
---{
---  test -f "$1" && test -x "$1"
---} # as_fn_executable_p
-- # as_fn_append VAR VALUE
-- # ----------------------
-- # Append the text in VALUE to the end of the definition contained in VAR. Take
--@@ -493,10 +457,6 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
--   chmod +x "$as_me.lineno" ||
--     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-- 
---  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
---  # already done that, so ensure we don't try to do so again and fall
---  # in an infinite loop.  This has already happened in practice.
---  _as_can_reexec=no; export _as_can_reexec
--   # Don't try to exec as it changes $[0], causing all sort of problems
--   # (the dirname of $[0] is not the place where we might find the
--   # original and so on.  Autoconf is especially sensitive to this).
--@@ -531,16 +491,16 @@ if (echo >conf$$.file) 2>/dev/null; then
--     # ... but there are two gotchas:
--     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
--     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
---    # In both cases, we have to default to `cp -pR'.
--+    # In both cases, we have to default to `cp -p'.
--     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
---      as_ln_s='cp -pR'
--+      as_ln_s='cp -p'
--   elif ln conf$$.file conf$$ 2>/dev/null; then
--     as_ln_s=ln
--   else
---    as_ln_s='cp -pR'
--+    as_ln_s='cp -p'
--   fi
-- else
---  as_ln_s='cp -pR'
--+  as_ln_s='cp -p'
-- fi
-- rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-- rmdir conf$$.dir 2>/dev/null
--@@ -552,8 +512,28 @@ else
--   as_mkdir_p=false
-- fi
-- 
---as_test_x='test -x'
---as_executable_p=as_fn_executable_p
--+if test -x / >/dev/null 2>&1; then
--+  as_test_x='test -x'
--+else
--+  if ls -dL / >/dev/null 2>&1; then
--+    as_ls_L_option=L
--+  else
--+    as_ls_L_option=
--+  fi
--+  as_test_x='
--+    eval sh -c '\''
--+      if test -d "$1"; then
--+	test -d "$1/.";
--+      else
--+	case $1 in #(
--+	-*)set "./$1";;
--+	esac;
--+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
--+	???[sx]*):;;*)false;;esac;fi
--+    '\'' sh
--+  '
--+fi
--+as_executable_p=$as_test_x
-- 
-- # Sed expression to map a string onto a valid CPP name.
-- as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
--@@ -688,10 +668,6 @@ CPPFLAGS
-- LDFLAGS
-- CFLAGS
-- CC
---AM_BACKSLASH
---AM_DEFAULT_VERBOSITY
---AM_DEFAULT_V
---AM_V
-- am__untar
-- am__tar
-- AMTAR
--@@ -756,7 +732,6 @@ SHELL'
-- ac_subst_files=''
-- ac_user_opts='
-- enable_option_checking
---enable_silent_rules
-- enable_dependency_tracking
-- enable_static
-- enable_shared
--@@ -1237,6 +1212,8 @@ target=$target_alias
-- if test "x$host_alias" != x; then
--   if test "x$build_alias" = x; then
--     cross_compiling=maybe
--+    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
--+    If a cross compiler is detected then cross compile mode will be used" >&2
--   elif test "x$build_alias" != "x$host_alias"; then
--     cross_compiling=yes
--   fi
--@@ -1400,12 +1377,8 @@ Optional Features:
--   --disable-option-checking  ignore unrecognized --enable/--with options
--   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
--   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
---  --enable-silent-rules   less verbose build output (undo: "make V=1")
---  --disable-silent-rules  verbose build output (undo: "make V=0")
---  --enable-dependency-tracking
---                          do not reject slow dependency extractors
---  --disable-dependency-tracking
---                          speeds up one-time build
--+  --disable-dependency-tracking  speeds up one-time build
--+  --enable-dependency-tracking   do not reject slow dependency extractors
--   --enable-static[=PKGS]  build static libraries [default=no]
--   --enable-shared[=PKGS]  build shared libraries [default=yes]
--   --enable-fast-install[=PKGS]
--@@ -1415,7 +1388,7 @@ Optional Features:
-- Optional Packages:
--   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
--   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
---  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
--+  --with-pic              try to use only PIC/non-PIC objects [default=use
--                           both]
--   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
--   --with-sysroot=DIR Search for dependent libraries within DIR
--@@ -1512,9 +1485,9 @@ test -n "$ac_init_help" && exit $ac_stat
-- if $ac_init_version; then
--   cat <<\_ACEOF
-- xtables-addons configure 2.5
---generated by GNU Autoconf 2.69
--+generated by GNU Autoconf 2.68
-- 
---Copyright (C) 2012 Free Software Foundation, Inc.
--+Copyright (C) 2010 Free Software Foundation, Inc.
-- This configure script is free software; the Free Software Foundation
-- gives unlimited permission to copy, distribute and modify it.
-- _ACEOF
--@@ -1590,7 +1563,7 @@ $as_echo "$ac_try_echo"; } >&5
-- 	 test ! -s conftest.err
--        } && test -s conftest$ac_exeext && {
-- 	 test "$cross_compiling" = yes ||
---	 test -x conftest$ac_exeext
--+	 $as_test_x conftest$ac_exeext
--        }; then :
--   ac_retval=0
-- else
--@@ -1877,7 +1850,7 @@ This file contains any messages produced
-- running configure, to aid debugging if configure makes a mistake.
-- 
-- It was created by xtables-addons $as_me 2.5, which was
---generated by GNU Autoconf 2.69.  Invocation command line was
--+generated by GNU Autoconf 2.68.  Invocation command line was
-- 
--   $ $0 $@
-- 
--@@ -2293,7 +2266,7 @@ case $as_dir/ in #((
--     # by default.
--     for ac_prog in ginstall scoinst install; do
--       for ac_exec_ext in '' $ac_executable_extensions; do
---	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
--+	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
-- 	  if test $ac_prog = install &&
-- 	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-- 	    # AIX install.  It has an incompatible calling convention.
--@@ -2349,10 +2322,13 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCR
-- 
-- test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-- 
---am__api_version='1.14'
--+am__api_version='1.11'
-- 
-- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
-- $as_echo_n "checking whether build environment is sane... " >&6; }
--+# Just in case
--+sleep 1
--+echo timestamp > conftest.file
-- # Reject unsafe characters in $srcdir or the absolute working directory
-- # name.  Accept space and tab only in the latter.
-- am_lf='
--@@ -2363,40 +2339,32 @@ case `pwd` in
-- esac
-- case $srcdir in
--   *[\\\"\#\$\&\'\`$am_lf\ \	]*)
---    as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
--+    as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
-- esac
-- 
---# Do 'set' in a subshell so we don't clobber the current shell's
--+# Do `set' in a subshell so we don't clobber the current shell's
-- # arguments.  Must try -L first in case configure is actually a
-- # symlink; some systems play weird games with the mod time of symlinks
-- # (eg FreeBSD returns the mod time of the symlink's containing
-- # directory).
-- if (
---   am_has_slept=no
---   for am_try in 1 2; do
---     echo "timestamp, slept: $am_has_slept" > conftest.file
---     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
---     if test "$*" = "X"; then
---	# -L didn't work.
---	set X `ls -t "$srcdir/configure" conftest.file`
---     fi
---     if test "$*" != "X $srcdir/configure conftest.file" \
---	&& test "$*" != "X conftest.file $srcdir/configure"; then
--+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
--+   if test "$*" = "X"; then
--+      # -L didn't work.
--+      set X `ls -t "$srcdir/configure" conftest.file`
--+   fi
--+   rm -f conftest.file
--+   if test "$*" != "X $srcdir/configure conftest.file" \
--+      && test "$*" != "X conftest.file $srcdir/configure"; then
--+
--+      # If neither matched, then we have a broken ls.  This can happen
--+      # if, for instance, CONFIG_SHELL is bash and it inherits a
--+      # broken ls alias from the environment.  This has actually
--+      # happened.  Such a system could not be considered "sane".
--+      as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
--+alias in your environment" "$LINENO" 5
--+   fi
-- 
---	# If neither matched, then we have a broken ls.  This can happen
---	# if, for instance, CONFIG_SHELL is bash and it inherits a
---	# broken ls alias from the environment.  This has actually
---	# happened.  Such a system could not be considered "sane".
---	as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
---  alias in your environment" "$LINENO" 5
---     fi
---     if test "$2" = conftest.file || test $am_try -eq 2; then
---       break
---     fi
---     # Just in case.
---     sleep 1
---     am_has_slept=yes
---   done
--    test "$2" = conftest.file
--    )
-- then
--@@ -2408,16 +2376,6 @@ Check your system clock" "$LINENO" 5
-- fi
-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-- $as_echo "yes" >&6; }
---# If we didn't sleep, we still need to ensure time stamps of config.status and
---# generated files are strictly newer.
---am_sleep_pid=
---if grep 'slept: no' conftest.file >/dev/null 2>&1; then
---  ( sleep 1 ) &
---  am_sleep_pid=$!
---fi
---
---rm -f conftest.file
---
-- test "$program_prefix" != NONE &&
--   program_transform_name="s&^&$program_prefix&;$program_transform_name"
-- # Use a double $ so make ignores it.
--@@ -2440,12 +2398,12 @@ if test x"${MISSING+set}" != xset; then
--   esac
-- fi
-- # Use eval to expand $SHELL
---if eval "$MISSING --is-lightweight"; then
---  am_missing_run="$MISSING "
--+if eval "$MISSING --run true"; then
--+  am_missing_run="$MISSING --run "
-- else
--   am_missing_run=
---  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
---$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
--+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
--+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
-- fi
-- 
-- if test x"${install_sh}" != xset; then
--@@ -2457,10 +2415,10 @@ if test x"${install_sh}" != xset; then
--   esac
-- fi
-- 
---# Installed binaries are usually stripped using 'strip' when the user
---# run "make install-strip".  However 'strip' might not be the right
--+# Installed binaries are usually stripped using `strip' when the user
--+# run `make install-strip'.  However `strip' might not be the right
-- # tool to use in cross-compilation environments, therefore Automake
---# will honor the 'STRIP' environment variable to overrule this program.
--+# will honor the `STRIP' environment variable to overrule this program.
-- if test "$cross_compiling" != no; then
--   if test -n "$ac_tool_prefix"; then
--   # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
--@@ -2479,7 +2437,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_STRIP="${ac_tool_prefix}strip"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -2519,7 +2477,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_STRIP="strip"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -2570,7 +2528,7 @@ do
--   test -z "$as_dir" && as_dir=.
--     for ac_prog in mkdir gmkdir; do
-- 	 for ac_exec_ext in '' $ac_executable_extensions; do
---	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
--+	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
-- 	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
-- 	     'mkdir (GNU coreutils) '* | \
-- 	     'mkdir (coreutils) '* | \
--@@ -2599,6 +2557,12 @@ fi
-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
-- $as_echo "$MKDIR_P" >&6; }
-- 
--+mkdir_p="$MKDIR_P"
--+case $mkdir_p in
--+  [\\/$]* | ?:[\\/]*) ;;
--+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
--+esac
--+
-- for ac_prog in gawk mawk nawk awk
-- do
--   # Extract the first word of "$ac_prog", so it can be a program name with args.
--@@ -2617,7 +2581,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_AWK="$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -2681,45 +2645,6 @@ else
-- fi
-- rmdir .tst 2>/dev/null
-- 
---# Check whether --enable-silent-rules was given.
---if test "${enable_silent_rules+set}" = set; then :
---  enableval=$enable_silent_rules;
---fi
---
---case $enable_silent_rules in # (((
---  yes) AM_DEFAULT_VERBOSITY=0;;
---   no) AM_DEFAULT_VERBOSITY=1;;
---    *) AM_DEFAULT_VERBOSITY=1;;
---esac
---am_make=${MAKE-make}
---{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
---$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
---if ${am_cv_make_support_nested_variables+:} false; then :
---  $as_echo_n "(cached) " >&6
---else
---  if $as_echo 'TRUE=$(BAR$(V))
---BAR0=false
---BAR1=true
---V=1
---am__doit:
---	@$(TRUE)
---.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
---  am_cv_make_support_nested_variables=yes
---else
---  am_cv_make_support_nested_variables=no
---fi
---fi
---{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
---$as_echo "$am_cv_make_support_nested_variables" >&6; }
---if test $am_cv_make_support_nested_variables = yes; then
---    AM_V='$(V)'
---  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
---else
---  AM_V=$AM_DEFAULT_VERBOSITY
---  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
---fi
---AM_BACKSLASH='\'
---
-- if test "`cd $srcdir && pwd`" != "`pwd`"; then
--   # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
--   # is not polluted with repeated "-I."
--@@ -2770,111 +2695,18 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_ru
-- 
-- MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
-- 
---# For better backward compatibility.  To be removed once Automake 1.9.x
---# dies out for good.  For more background, see:
---# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
---# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
---mkdir_p='$(MKDIR_P)'
---
-- # We need awk for the "check" target.  The system "awk" is bad on
-- # some platforms.
-- # Always define AMTAR for backward compatibility.  Yes, it's still used
-- # in the wild :-(  We should find a proper way to deprecate it ...
-- AMTAR='$${TAR-tar}'
-- 
---
---# We'll loop over all known methods to create a tar archive until one works.
---_am_tools='gnutar  pax cpio none'
---
-- am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
-- 
-- 
-- 
-- 
-- 
---
---# POSIX will say in a future version that running "rm -f" with no argument
---# is OK; and we want to be able to make that assumption in our Makefile
---# recipes.  So use an aggressive probe to check that the usage we want is
---# actually supported "in the wild" to an acceptable degree.
---# See automake bug#10828.
---# To make any issue more visible, cause the running configure to be aborted
---# by default if the 'rm' program in use doesn't match our expectations; the
---# user can still override this though.
---if rm -f && rm -fr && rm -rf; then : OK; else
---  cat >&2 <<'END'
---Oops!
---
---Your 'rm' program seems unable to run without file operands specified
---on the command line, even when the '-f' option is present.  This is contrary
---to the behaviour of most rm programs out there, and not conforming with
---the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
---
---Please tell bug-automake@gnu.org about your system, including the value
---of your $PATH and any error possibly output before this message.  This
---can help us improve future automake versions.
---
---END
---  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
---    echo 'Configuration will proceed anyway, since you have set the' >&2
---    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
---    echo >&2
---  else
---    cat >&2 <<'END'
---Aborting the configuration process, to ensure you take notice of the issue.
---
---You can download and install GNU coreutils to get an 'rm' implementation
---that behaves properly: <http://www.gnu.org/software/coreutils/>.
---
---If you want to complete the configuration process using your problematic
---'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
---to "yes", and re-run configure.
---
---END
---    as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
---  fi
---fi
---
---# Check whether --enable-silent-rules was given.
---if test "${enable_silent_rules+set}" = set; then :
---  enableval=$enable_silent_rules;
---fi
---
---case $enable_silent_rules in # (((
---  yes) AM_DEFAULT_VERBOSITY=0;;
---   no) AM_DEFAULT_VERBOSITY=1;;
---    *) AM_DEFAULT_VERBOSITY=0;;
---esac
---am_make=${MAKE-make}
---{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
---$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
---if ${am_cv_make_support_nested_variables+:} false; then :
---  $as_echo_n "(cached) " >&6
---else
---  if $as_echo 'TRUE=$(BAR$(V))
---BAR0=false
---BAR1=true
---V=1
---am__doit:
---	@$(TRUE)
---.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
---  am_cv_make_support_nested_variables=yes
---else
---  am_cv_make_support_nested_variables=no
---fi
---fi
---{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
---$as_echo "$am_cv_make_support_nested_variables" >&6; }
---if test $am_cv_make_support_nested_variables = yes; then
---    AM_V='$(V)'
---  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
---else
---  AM_V=$AM_DEFAULT_VERBOSITY
---  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
---fi
---AM_BACKSLASH='\'
---
---
-- ac_ext=c
-- ac_cpp='$CPP $CPPFLAGS'
-- ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
--@@ -2897,7 +2729,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_CC="${ac_tool_prefix}gcc"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -2937,7 +2769,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_CC="gcc"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -2990,7 +2822,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_CC="${ac_tool_prefix}cc"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -3031,7 +2863,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
--        ac_prog_rejected=yes
--        continue
--@@ -3089,7 +2921,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -3133,7 +2965,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_CC="$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -3579,7 +3411,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_
-- /* end confdefs.h.  */
-- #include <stdarg.h>
-- #include <stdio.h>
---struct stat;
--+#include <sys/types.h>
--+#include <sys/stat.h>
-- /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-- struct buf { int x; };
-- FILE * (*rcsopen) (struct buf *, struct stat *, int);
--@@ -3663,65 +3496,6 @@ ac_cpp='$CPP $CPPFLAGS'
-- ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-- ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-- ac_compiler_gnu=$ac_cv_c_compiler_gnu
---
---ac_ext=c
---ac_cpp='$CPP $CPPFLAGS'
---ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
---ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
---ac_compiler_gnu=$ac_cv_c_compiler_gnu
---{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
---$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
---if ${am_cv_prog_cc_c_o+:} false; then :
---  $as_echo_n "(cached) " >&6
---else
---  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
---/* end confdefs.h.  */
---
---int
---main ()
---{
---
---  ;
---  return 0;
---}
---_ACEOF
---  # Make sure it works both with $CC and with simple cc.
---  # Following AC_PROG_CC_C_O, we do the test twice because some
---  # compilers refuse to overwrite an existing .o file with -o,
---  # though they will create one.
---  am_cv_prog_cc_c_o=yes
---  for am_i in 1 2; do
---    if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
---   ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
---   ac_status=$?
---   echo "$as_me:$LINENO: \$? = $ac_status" >&5
---   (exit $ac_status); } \
---         && test -f conftest2.$ac_objext; then
---      : OK
---    else
---      am_cv_prog_cc_c_o=no
---      break
---    fi
---  done
---  rm -f core conftest*
---  unset am_i
---fi
---{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
---$as_echo "$am_cv_prog_cc_c_o" >&6; }
---if test "$am_cv_prog_cc_c_o" != yes; then
---   # Losing compiler, so override with the script.
---   # FIXME: It is wrong to rewrite CC.
---   # But if we don't then we get into trouble of one sort or another.
---   # A longer-term fix would be to have automake use am__CC in this case,
---   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
---   CC="$am_aux_dir/compile $CC"
---fi
---ac_ext=c
---ac_cpp='$CPP $CPPFLAGS'
---ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
---ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
---ac_compiler_gnu=$ac_cv_c_compiler_gnu
---
-- DEPDIR="${am__leading_dot}deps"
-- 
-- ac_config_commands="$ac_config_commands depfiles"
--@@ -3741,7 +3515,7 @@ am__quote=
-- _am_result=none
-- # First try GNU make style include.
-- echo "include confinc" > confmf
---# Ignore all kinds of additional output from 'make'.
--+# Ignore all kinds of additional output from `make'.
-- case `$am_make -s -f confmf 2> /dev/null` in #(
-- *the\ am__doit\ target*)
--   am__include=include
--@@ -3797,8 +3571,8 @@ else
--   # We make a subdir and do the tests there.  Otherwise we can end up
--   # making bogus files that we don't know about and never remove.  For
--   # instance it was reported that on HP-UX the gcc test will end up
---  # making a dummy file named 'D' -- because '-MD' means "put the output
---  # in D".
--+  # making a dummy file named `D' -- because `-MD' means `put the output
--+  # in D'.
--   rm -rf conftest.dir
--   mkdir conftest.dir
--   # Copy depcomp to subdir because otherwise we won't find it if we're
--@@ -3833,16 +3607,16 @@ else
--     : > sub/conftest.c
--     for i in 1 2 3 4 5 6; do
--       echo '#include "conftst'$i'.h"' >> sub/conftest.c
---      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
---      # Solaris 10 /bin/sh.
---      echo '/* dummy */' > sub/conftst$i.h
--+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
--+      # Solaris 8's {/usr,}/bin/sh.
--+      touch sub/conftst$i.h
--     done
--     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-- 
---    # We check with '-c' and '-o' for the sake of the "dashmstdout"
--+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
--     # mode.  It turns out that the SunPro C++ compiler does not properly
---    # handle '-M -o', and we need to detect this.  Also, some Intel
---    # versions had trouble with output in subdirs.
--+    # handle `-M -o', and we need to detect this.  Also, some Intel
--+    # versions had trouble with output in subdirs
--     am__obj=sub/conftest.${OBJEXT-o}
--     am__minus_obj="-o $am__obj"
--     case $depmode in
--@@ -3851,8 +3625,8 @@ else
--       test "$am__universal" = false || continue
--       ;;
--     nosideeffect)
---      # After this tag, mechanisms are not by side-effect, so they'll
---      # only be used when explicitly requested.
--+      # after this tag, mechanisms are not by side-effect, so they'll
--+      # only be used when explicitly requested
--       if test "x$enable_dependency_tracking" = xyes; then
-- 	continue
--       else
--@@ -3860,7 +3634,7 @@ else
--       fi
--       ;;
--     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
---      # This compiler won't grok '-c -o', but also, the minuso test has
--+      # This compiler won't grok `-c -o', but also, the minuso test has
--       # not run yet.  These depmodes are late enough in the game, and
--       # so weak that their functioning should not be impacted.
--       am__obj=conftest.${OBJEXT-o}
--@@ -3914,6 +3688,131 @@ else
-- fi
-- 
-- 
--+if test "x$CC" != xcc; then
--+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5
--+$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
--+else
--+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5
--+$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
--+fi
--+set dummy $CC; ac_cc=`$as_echo "$2" |
--+		      sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
--+if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then :
--+  $as_echo_n "(cached) " >&6
--+else
--+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--+/* end confdefs.h.  */
--+
--+int
--+main ()
--+{
--+
--+  ;
--+  return 0;
--+}
--+_ACEOF
--+# Make sure it works both with $CC and with simple cc.
--+# We do the test twice because some compilers refuse to overwrite an
--+# existing .o file with -o, though they will create one.
--+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
--+rm -f conftest2.*
--+if { { case "(($ac_try" in
--+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
--+  *) ac_try_echo=$ac_try;;
--+esac
--+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
--+$as_echo "$ac_try_echo"; } >&5
--+  (eval "$ac_try") 2>&5
--+  ac_status=$?
--+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--+  test $ac_status = 0; } &&
--+   test -f conftest2.$ac_objext && { { case "(($ac_try" in
--+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
--+  *) ac_try_echo=$ac_try;;
--+esac
--+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
--+$as_echo "$ac_try_echo"; } >&5
--+  (eval "$ac_try") 2>&5
--+  ac_status=$?
--+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--+  test $ac_status = 0; };
--+then
--+  eval ac_cv_prog_cc_${ac_cc}_c_o=yes
--+  if test "x$CC" != xcc; then
--+    # Test first that cc exists at all.
--+    if { ac_try='cc -c conftest.$ac_ext >&5'
--+  { { case "(($ac_try" in
--+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
--+  *) ac_try_echo=$ac_try;;
--+esac
--+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
--+$as_echo "$ac_try_echo"; } >&5
--+  (eval "$ac_try") 2>&5
--+  ac_status=$?
--+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--+  test $ac_status = 0; }; }; then
--+      ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
--+      rm -f conftest2.*
--+      if { { case "(($ac_try" in
--+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
--+  *) ac_try_echo=$ac_try;;
--+esac
--+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
--+$as_echo "$ac_try_echo"; } >&5
--+  (eval "$ac_try") 2>&5
--+  ac_status=$?
--+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--+  test $ac_status = 0; } &&
--+	 test -f conftest2.$ac_objext && { { case "(($ac_try" in
--+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
--+  *) ac_try_echo=$ac_try;;
--+esac
--+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
--+$as_echo "$ac_try_echo"; } >&5
--+  (eval "$ac_try") 2>&5
--+  ac_status=$?
--+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
--+  test $ac_status = 0; };
--+      then
--+	# cc works too.
--+	:
--+      else
--+	# cc exists but doesn't like -o.
--+	eval ac_cv_prog_cc_${ac_cc}_c_o=no
--+      fi
--+    fi
--+  fi
--+else
--+  eval ac_cv_prog_cc_${ac_cc}_c_o=no
--+fi
--+rm -f core conftest*
--+
--+fi
--+if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
--+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
--+$as_echo "yes" >&6; }
--+else
--+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
--+$as_echo "no" >&6; }
--+
--+$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
--+
--+fi
--+
--+# FIXME: we rely on the cache variable name because
--+# there is no other way.
--+set dummy $CC
--+am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
--+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
--+if test "$am_t" != yes; then
--+   # Losing compiler, so override with the script.
--+   # FIXME: It is wrong to rewrite CC.
--+   # But if we don't then we get into trouble of one sort or another.
--+   # A longer-term fix would be to have automake use am__CC in this case,
--+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
--+   CC="$am_aux_dir/compile $CC"
--+fi
--+
-- 
-- 
-- if test -n "$ac_tool_prefix"; then
--@@ -3935,7 +3834,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -3979,7 +3878,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_AR="$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -4023,13 +3922,7 @@ $as_echo_n "checking the archiver ($AR) 
-- if ${am_cv_ar_interface+:} false; then :
--   $as_echo_n "(cached) " >&6
-- else
---  ac_ext=c
---ac_cpp='$CPP $CPPFLAGS'
---ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
---ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
---ac_compiler_gnu=$ac_cv_c_compiler_gnu
---
---   am_cv_ar_interface=ar
--+  am_cv_ar_interface=ar
--    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-- /* end confdefs.h.  */
-- int some_variable = 0;
--@@ -4060,11 +3953,6 @@ if ac_fn_c_try_compile "$LINENO"; then :
-- 
-- fi
-- rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
---   ac_ext=c
---ac_cpp='$CPP $CPPFLAGS'
---ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
---ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
---ac_compiler_gnu=$ac_cv_c_compiler_gnu
-- 
-- fi
-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5
--@@ -4126,8 +4014,8 @@ esac
-- 
-- 
-- 
---macro_version='2.4.2'
---macro_revision='1.3337'
--+macro_version='2.4'
--+macro_revision='1.3293'
-- 
-- 
-- 
--@@ -4305,7 +4193,7 @@ do
--     for ac_prog in sed gsed; do
--     for ac_exec_ext in '' $ac_executable_extensions; do
--       ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
---      as_fn_executable_p "$ac_path_SED" || continue
--+      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
-- # Check for GNU ac_path_SED and select it if it is found.
--   # Check for GNU $ac_path_SED
-- case `"$ac_path_SED" --version 2>&1` in
--@@ -4381,7 +4269,7 @@ do
--     for ac_prog in grep ggrep; do
--     for ac_exec_ext in '' $ac_executable_extensions; do
--       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
---      as_fn_executable_p "$ac_path_GREP" || continue
--+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-- # Check for GNU ac_path_GREP and select it if it is found.
--   # Check for GNU $ac_path_GREP
-- case `"$ac_path_GREP" --version 2>&1` in
--@@ -4447,7 +4335,7 @@ do
--     for ac_prog in egrep; do
--     for ac_exec_ext in '' $ac_executable_extensions; do
--       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
---      as_fn_executable_p "$ac_path_EGREP" || continue
--+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-- # Check for GNU ac_path_EGREP and select it if it is found.
--   # Check for GNU $ac_path_EGREP
-- case `"$ac_path_EGREP" --version 2>&1` in
--@@ -4514,7 +4402,7 @@ do
--     for ac_prog in fgrep; do
--     for ac_exec_ext in '' $ac_executable_extensions; do
--       ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
---      as_fn_executable_p "$ac_path_FGREP" || continue
--+      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
-- # Check for GNU ac_path_FGREP and select it if it is found.
--   # Check for GNU $ac_path_FGREP
-- case `"$ac_path_FGREP" --version 2>&1` in
--@@ -4770,7 +4658,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -4814,7 +4702,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -4972,11 +4860,6 @@ else
--     lt_cv_sys_max_cmd_len=196608
--     ;;
-- 
---  os2*)
---    # The test takes a long time on OS/2.
---    lt_cv_sys_max_cmd_len=8192
---    ;;
---
--   osf*)
--     # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
--     # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
--@@ -5016,7 +4899,7 @@ else
--       # If test is not a shell built-in, we'll probably end up computing a
--       # maximum length that is only half of the actual maximum length, but
--       # we can't tell.
---      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
--+      while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \
-- 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-- 	      test $i != 17 # 1/2 MB should be enough
--       do
--@@ -5238,7 +5121,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -5278,7 +5161,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_OBJDUMP="objdump"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -5445,7 +5328,7 @@ irix5* | irix6* | nonstopux*)
--   lt_cv_deplibs_check_method=pass_all
--   ;;
-- 
---# This must be glibc/ELF.
--+# This must be Linux ELF.
-- linux* | k*bsd*-gnu | kopensolaris*-gnu)
--   lt_cv_deplibs_check_method=pass_all
--   ;;
--@@ -5584,7 +5467,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -5624,7 +5507,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_DLLTOOL="dlltool"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -5727,7 +5610,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -5771,7 +5654,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_AR="$ac_prog"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -5896,7 +5779,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_STRIP="${ac_tool_prefix}strip"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -5936,7 +5819,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_STRIP="strip"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -5995,7 +5878,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -6035,7 +5918,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_RANLIB="ranlib"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -6085,13 +5968,13 @@ old_postuninstall_cmds=
-- if test -n "$RANLIB"; then
--   case $host_os in
--   openbsd*)
---    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
--+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
--     ;;
--   *)
---    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
--+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
--     ;;
--   esac
---  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
--+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-- fi
-- 
-- case $host_os in
--@@ -6238,7 +6121,6 @@ for ac_symprfx in "" "_"; do
--     # which start with @ or ?.
--     lt_cv_sys_global_symbol_pipe="$AWK '"\
-- "     {last_section=section; section=\$ 3};"\
---"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
-- "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
-- "     \$ 0!~/External *\|/{next};"\
-- "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
--@@ -6627,7 +6509,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
--     CFLAGS="$SAVE_CFLAGS"
--   fi
--   ;;
---*-*solaris*)
--+sparc*-*solaris*)
--   # Find out which ABI we are using.
--   echo 'int i;' > conftest.$ac_ext
--   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
--@@ -6638,20 +6520,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
--     case `/usr/bin/file conftest.o` in
--     *64-bit*)
--       case $lt_cv_prog_gnu_ld in
---      yes*)
---        case $host in
---        i?86-*-solaris*)
---          LD="${LD-ld} -m elf_x86_64"
---          ;;
---        sparc*-*-solaris*)
---          LD="${LD-ld} -m elf64_sparc"
---          ;;
---        esac
---        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
---        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
---          LD="${LD-ld}_sol2"
---        fi
---        ;;
--+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
--       *)
-- 	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
-- 	  LD="${LD-ld} -64"
--@@ -6684,7 +6553,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -6724,7 +6593,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -6804,7 +6673,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -6844,7 +6713,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -6896,7 +6765,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -6936,7 +6805,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_NMEDIT="nmedit"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -6988,7 +6857,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -7028,7 +6897,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_LIPO="lipo"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -7080,7 +6949,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -7120,7 +6989,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_OTOOL="otool"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -7172,7 +7041,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -7212,7 +7081,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_prog_ac_ct_OTOOL64="otool64"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -7291,13 +7160,7 @@ else
-- 	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-- 	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
--         _lt_result=$?
---	# If there is a non-empty error log, and "single_module"
---	# appears in it, assume the flag caused a linker warning
---        if test -s conftest.err && $GREP single_module conftest.err; then
---	  cat conftest.err >&5
---	# Otherwise, if the output was created with a 0 exit code from
---	# the compiler, it worked.
---	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
--+	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
-- 	  lt_cv_apple_cc_single_mod=yes
-- 	else
-- 	  cat conftest.err >&5
--@@ -7308,7 +7171,6 @@ else
-- fi
-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
-- $as_echo "$lt_cv_apple_cc_single_mod" >&6; }
---
--     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
-- $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
-- if ${lt_cv_ld_exported_symbols_list+:} false; then :
--@@ -7341,7 +7203,6 @@ rm -f core conftest.err conftest.$ac_obj
-- fi
-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
-- $as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
---
--     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
-- $as_echo_n "checking for -force_load linker flag... " >&6; }
-- if ${lt_cv_ld_force_load+:} false; then :
--@@ -7363,9 +7224,7 @@ _LT_EOF
--       echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
--       $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
--       _lt_result=$?
---      if test -s conftest.err && $GREP force_load conftest.err; then
---	cat conftest.err >&5
---      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
--+      if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
-- 	lt_cv_ld_force_load=yes
--       else
-- 	cat conftest.err >&5
--@@ -7740,22 +7599,7 @@ fi
-- 
-- # Check whether --with-pic was given.
-- if test "${with_pic+set}" = set; then :
---  withval=$with_pic; lt_p=${PACKAGE-default}
---    case $withval in
---    yes|no) pic_mode=$withval ;;
---    *)
---      pic_mode=default
---      # Look at the argument we got.  We use all the common list separators.
---      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
---      for lt_pkg in $withval; do
---	IFS="$lt_save_ifs"
---	if test "X$lt_pkg" = "X$lt_p"; then
---	  pic_mode=yes
---	fi
---      done
---      IFS="$lt_save_ifs"
---      ;;
---    esac
--+  withval=$with_pic; pic_mode="$withval"
-- else
--   pic_mode=default
-- fi
--@@ -7833,10 +7677,6 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtoo
-- 
-- 
-- 
---
---
---
---
-- test -z "$LN_S" && LN_S="ln -s"
-- 
-- 
--@@ -8126,10 +7966,6 @@ _lt_linker_boilerplate=`cat conftest.err
-- $RM -r conftest*
-- 
-- 
---## CAVEAT EMPTOR:
---## There is no encapsulation within the following macros, do not change
---## the running order or otherwise move them around unless you know exactly
---## what you are doing...
-- if test -n "$compiler"; then
-- 
-- lt_prog_compiler_no_builtin_flag=
--@@ -8296,9 +8132,7 @@ lt_prog_compiler_static=
--     case $cc_basename in
--     nvcc*) # Cuda Compiler Driver 2.2
--       lt_prog_compiler_wl='-Xlinker '
---      if test -n "$lt_prog_compiler_pic"; then
---        lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
---      fi
--+      lt_prog_compiler_pic='-Xcompiler -fPIC'
--       ;;
--     esac
--   else
--@@ -8389,33 +8223,18 @@ lt_prog_compiler_static=
-- 	;;
--       *)
-- 	case `$CC -V 2>&1 | sed 5q` in
---	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
--+	*Sun\ F* | *Sun*Fortran*)
-- 	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
-- 	  lt_prog_compiler_pic='-KPIC'
-- 	  lt_prog_compiler_static='-Bstatic'
-- 	  lt_prog_compiler_wl=''
-- 	  ;;
---	*Sun\ F* | *Sun*Fortran*)
---	  lt_prog_compiler_pic='-KPIC'
---	  lt_prog_compiler_static='-Bstatic'
---	  lt_prog_compiler_wl='-Qoption ld '
---	  ;;
-- 	*Sun\ C*)
-- 	  # Sun C 5.9
-- 	  lt_prog_compiler_pic='-KPIC'
-- 	  lt_prog_compiler_static='-Bstatic'
-- 	  lt_prog_compiler_wl='-Wl,'
-- 	  ;;
---        *Intel*\ [CF]*Compiler*)
---	  lt_prog_compiler_wl='-Wl,'
---	  lt_prog_compiler_pic='-fPIC'
---	  lt_prog_compiler_static='-static'
---	  ;;
---	*Portland\ Group*)
---	  lt_prog_compiler_wl='-Wl,'
---	  lt_prog_compiler_pic='-fpic'
---	  lt_prog_compiler_static='-Bstatic'
---	  ;;
-- 	esac
-- 	;;
--       esac
--@@ -8777,6 +8596,7 @@ $as_echo_n "checking whether the $compil
--   hardcode_direct=no
--   hardcode_direct_absolute=no
--   hardcode_libdir_flag_spec=
--+  hardcode_libdir_flag_spec_ld=
--   hardcode_libdir_separator=
--   hardcode_minus_L=no
--   hardcode_shlibpath_var=unsupported
--@@ -9026,7 +8846,8 @@ _LT_EOF
-- 	xlf* | bgf* | bgxlf* | mpixlf*)
-- 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
-- 	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
---	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
--+	  hardcode_libdir_flag_spec=
--+	  hardcode_libdir_flag_spec_ld='-rpath $libdir'
-- 	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-- 	  if test "x$supports_anon_versioning" = xyes; then
-- 	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
--@@ -9405,7 +9226,6 @@ fi
-- 	# The linker will not automatically build a static lib if we build a DLL.
-- 	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
-- 	enable_shared_with_static_runtimes=yes
---	exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
-- 	export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
-- 	# Don't use ranlib
-- 	old_postinstall_cmds='chmod 644 $oldlib'
--@@ -9451,7 +9271,6 @@ fi
--   hardcode_shlibpath_var=unsupported
--   if test "$lt_cv_ld_force_load" = "yes"; then
--     whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
---
--   else
--     whole_archive_flag_spec=''
--   fi
--@@ -9480,6 +9299,10 @@ fi
--       hardcode_shlibpath_var=no
--       ;;
-- 
--+    freebsd1*)
--+      ld_shlibs=no
--+      ;;
--+
--     # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
--     # support.  Future versions do this automatically, but an explicit c++rt0.o
--     # does not break anything, and helps significantly (at the cost of a little
--@@ -9492,7 +9315,7 @@ fi
--       ;;
-- 
--     # Unfortunately, older versions of FreeBSD 2 do not have this feature.
---    freebsd2.*)
--+    freebsd2*)
--       archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
--       hardcode_direct=yes
--       hardcode_minus_L=yes
--@@ -9531,6 +9354,7 @@ fi
--       fi
--       if test "$with_gnu_ld" = no; then
-- 	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
--+	hardcode_libdir_flag_spec_ld='+b $libdir'
-- 	hardcode_libdir_separator=:
-- 	hardcode_direct=yes
-- 	hardcode_direct_absolute=yes
--@@ -10154,6 +9978,11 @@ esac
-- 
-- 
-- 
--+
--+
--+
--+
--+
--   { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
-- $as_echo_n "checking dynamic linker characteristics... " >&6; }
-- 
--@@ -10243,7 +10072,7 @@ need_version=unknown
-- 
-- case $host_os in
-- aix3*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
--   shlibpath_var=LIBPATH
-- 
--@@ -10252,7 +10081,7 @@ aix3*)
--   ;;
-- 
-- aix[4-9]*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_lib_prefix=no
--   need_version=no
--   hardcode_into_libs=yes
--@@ -10317,7 +10146,7 @@ beos*)
--   ;;
-- 
-- bsdi[45]*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_version=no
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
--   soname_spec='${libname}${release}${shared_ext}$major'
--@@ -10456,7 +10285,7 @@ darwin* | rhapsody*)
--   ;;
-- 
-- dgux*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_lib_prefix=no
--   need_version=no
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
--@@ -10464,6 +10293,10 @@ dgux*)
--   shlibpath_var=LD_LIBRARY_PATH
--   ;;
-- 
--+freebsd1*)
--+  dynamic_linker=no
--+  ;;
--+
-- freebsd* | dragonfly*)
--   # DragonFly does not have aout.  When/if they implement a new
--   # versioning mechanism, adjust this.
--@@ -10471,7 +10304,7 @@ freebsd* | dragonfly*)
--     objformat=`/usr/bin/objformat`
--   else
--     case $host_os in
---    freebsd[23].*) objformat=aout ;;
--+    freebsd[123]*) objformat=aout ;;
--     *) objformat=elf ;;
--     esac
--   fi
--@@ -10489,7 +10322,7 @@ freebsd* | dragonfly*)
--   esac
--   shlibpath_var=LD_LIBRARY_PATH
--   case $host_os in
---  freebsd2.*)
--+  freebsd2*)
--     shlibpath_overrides_runpath=yes
--     ;;
--   freebsd3.[01]* | freebsdelf3.[01]*)
--@@ -10509,18 +10342,17 @@ freebsd* | dragonfly*)
--   ;;
-- 
-- gnu*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_lib_prefix=no
--   need_version=no
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
--   soname_spec='${libname}${release}${shared_ext}$major'
--   shlibpath_var=LD_LIBRARY_PATH
---  shlibpath_overrides_runpath=no
--   hardcode_into_libs=yes
--   ;;
-- 
-- haiku*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_lib_prefix=no
--   need_version=no
--   dynamic_linker="$host_os runtime_loader"
--@@ -10581,7 +10413,7 @@ hpux9* | hpux10* | hpux11*)
--   ;;
-- 
-- interix[3-9]*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_lib_prefix=no
--   need_version=no
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
--@@ -10597,7 +10429,7 @@ irix5* | irix6* | nonstopux*)
--     nonstopux*) version_type=nonstopux ;;
--     *)
-- 	if test "$lt_cv_prog_gnu_ld" = yes; then
---		version_type=linux # correct to gnu/linux during the next big refactor
--+		version_type=linux
-- 	else
-- 		version_type=irix
-- 	fi ;;
--@@ -10634,9 +10466,9 @@ linux*oldld* | linux*aout* | linux*coff*
--   dynamic_linker=no
--   ;;
-- 
---# This must be glibc/ELF.
--+# This must be Linux ELF.
-- linux* | k*bsd*-gnu | kopensolaris*-gnu)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_lib_prefix=no
--   need_version=no
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
--@@ -10718,7 +10550,7 @@ netbsd*)
--   ;;
-- 
-- newsos6)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
--   shlibpath_var=LD_LIBRARY_PATH
--   shlibpath_overrides_runpath=yes
--@@ -10787,7 +10619,7 @@ rdos*)
--   ;;
-- 
-- solaris*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_lib_prefix=no
--   need_version=no
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
--@@ -10812,7 +10644,7 @@ sunos4*)
--   ;;
-- 
-- sysv4 | sysv4.3*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
--   soname_spec='${libname}${release}${shared_ext}$major'
--   shlibpath_var=LD_LIBRARY_PATH
--@@ -10836,7 +10668,7 @@ sysv4 | sysv4.3*)
-- 
-- sysv4*MP*)
--   if test -d /usr/nec ;then
---    version_type=linux # correct to gnu/linux during the next big refactor
--+    version_type=linux
--     library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
--     soname_spec='$libname${shared_ext}.$major'
--     shlibpath_var=LD_LIBRARY_PATH
--@@ -10867,7 +10699,7 @@ sysv5* | sco3.2v5* | sco5v6* | unixware*
-- 
-- tpf*)
--   # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   need_lib_prefix=no
--   need_version=no
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
--@@ -10877,7 +10709,7 @@ tpf*)
--   ;;
-- 
-- uts4*)
---  version_type=linux # correct to gnu/linux during the next big refactor
--+  version_type=linux
--   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
--   soname_spec='${libname}${release}${shared_ext}$major'
--   shlibpath_var=LD_LIBRARY_PATH
--@@ -11659,8 +11491,6 @@ CC="$lt_save_CC"
-- 
-- 
-- 
---
---
--         ac_config_commands="$ac_config_commands libtool"
-- 
-- 
--@@ -11726,7 +11556,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -11769,7 +11599,7 @@ do
--   IFS=$as_save_IFS
--   test -z "$as_dir" && as_dir=.
--     for ac_exec_ext in '' $ac_executable_extensions; do
---  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--     ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
--     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--     break 2
--@@ -11932,7 +11762,7 @@ regular_CFLAGS="-Wall -Waggregate-return
-- if test -n "$kbuilddir"; then
-- 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking kernel version that we will build against" >&5
-- $as_echo_n "checking kernel version that we will build against... " >&6; }
---	krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
--+	krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
-- 	kmajor="${krel%%[^0-9]*}";
-- 	kmajor="$(($kmajor+0))";
-- 	krel="${krel:${#kmajor}}";
--@@ -12076,14 +11906,6 @@ LIBOBJS=$ac_libobjs
-- LTLIBOBJS=$ac_ltlibobjs
-- 
-- 
---{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
---$as_echo_n "checking that generated files are newer than configure... " >&6; }
---   if test -n "$am_sleep_pid"; then
---     # Hide warnings about reused PIDs.
---     wait $am_sleep_pid 2>/dev/null
---   fi
---   { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
---$as_echo "done" >&6; }
--  if test -n "$EXEEXT"; then
--   am__EXEEXT_TRUE=
--   am__EXEEXT_FALSE='#'
--@@ -12398,16 +12220,16 @@ if (echo >conf$$.file) 2>/dev/null; then
--     # ... but there are two gotchas:
--     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
--     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
---    # In both cases, we have to default to `cp -pR'.
--+    # In both cases, we have to default to `cp -p'.
--     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
---      as_ln_s='cp -pR'
--+      as_ln_s='cp -p'
--   elif ln conf$$.file conf$$ 2>/dev/null; then
--     as_ln_s=ln
--   else
---    as_ln_s='cp -pR'
--+    as_ln_s='cp -p'
--   fi
-- else
---  as_ln_s='cp -pR'
--+  as_ln_s='cp -p'
-- fi
-- rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-- rmdir conf$$.dir 2>/dev/null
--@@ -12467,16 +12289,28 @@ else
--   as_mkdir_p=false
-- fi
-- 
---
---# as_fn_executable_p FILE
---# -----------------------
---# Test if FILE is an executable regular file.
---as_fn_executable_p ()
---{
---  test -f "$1" && test -x "$1"
---} # as_fn_executable_p
---as_test_x='test -x'
---as_executable_p=as_fn_executable_p
--+if test -x / >/dev/null 2>&1; then
--+  as_test_x='test -x'
--+else
--+  if ls -dL / >/dev/null 2>&1; then
--+    as_ls_L_option=L
--+  else
--+    as_ls_L_option=
--+  fi
--+  as_test_x='
--+    eval sh -c '\''
--+      if test -d "$1"; then
--+	test -d "$1/.";
--+      else
--+	case $1 in #(
--+	-*)set "./$1";;
--+	esac;
--+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
--+	???[sx]*):;;*)false;;esac;fi
--+    '\'' sh
--+  '
--+fi
--+as_executable_p=$as_test_x
-- 
-- # Sed expression to map a string onto a valid CPP name.
-- as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
--@@ -12498,7 +12332,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
-- # values after options handling.
-- ac_log="
-- This file was extended by xtables-addons $as_me 2.5, which was
---generated by GNU Autoconf 2.69.  Invocation command line was
--+generated by GNU Autoconf 2.68.  Invocation command line was
-- 
--   CONFIG_FILES    = $CONFIG_FILES
--   CONFIG_HEADERS  = $CONFIG_HEADERS
--@@ -12564,10 +12398,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_writ
-- ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-- ac_cs_version="\\
-- xtables-addons config.status 2.5
---configured by $0, generated by GNU Autoconf 2.69,
--+configured by $0, generated by GNU Autoconf 2.68,
--   with options \\"\$ac_cs_config\\"
-- 
---Copyright (C) 2012 Free Software Foundation, Inc.
--+Copyright (C) 2010 Free Software Foundation, Inc.
-- This config.status script is free software; the Free Software Foundation
-- gives unlimited permission to copy, distribute and modify it."
-- 
--@@ -12658,7 +12492,7 @@ fi
-- _ACEOF
-- cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-- if \$ac_cs_recheck; then
---  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
--+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
--   shift
--   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
--   CONFIG_SHELL='$SHELL'
--@@ -12700,7 +12534,6 @@ pic_mode='`$ECHO "$pic_mode" | $SED "$de
-- enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
-- SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
-- ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
---PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
-- host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
-- host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
-- host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
--@@ -12783,6 +12616,7 @@ with_gnu_ld='`$ECHO "$with_gnu_ld" | $SE
-- allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
-- no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
-- hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
--+hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`'
-- hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
-- hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
-- hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
--@@ -12838,7 +12672,6 @@ _LTECHO_EOF'
-- # Quote evaled strings.
-- for var in SHELL \
-- ECHO \
---PATH_SEPARATOR \
-- SED \
-- GREP \
-- EGREP \
--@@ -12889,6 +12722,7 @@ with_gnu_ld \
-- allow_undefined_flag \
-- no_undefined_flag \
-- hardcode_libdir_flag_spec \
--+hardcode_libdir_flag_spec_ld \
-- hardcode_libdir_separator \
-- exclude_expsyms \
-- include_expsyms \
--@@ -13575,7 +13409,7 @@ $as_echo "$as_me: executing $ac_file com
-- 
--   case $ac_file$ac_mode in
--     "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
---  # Older Autoconf quotes --file arguments for eval, but not when files
--+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
--   # are listed without --file.  Let's play safe and only enable the eval
--   # if we detect the quoting.
--   case $CONFIG_FILES in
--@@ -13588,7 +13422,7 @@ $as_echo "$as_me: executing $ac_file com
--     # Strip MF so we end up with the name of the file.
--     mf=`echo "$mf" | sed -e 's/:.*$//'`
--     # Check whether this is an Automake generated Makefile or not.
---    # We used to match only the files named 'Makefile.in', but
--+    # We used to match only the files named `Makefile.in', but
--     # some people rename them; so instead we look at the file content.
--     # Grep'ing the first line is not enough: some people post-process
--     # each Makefile.in and add a new line on top of each file to say so.
--@@ -13622,19 +13456,21 @@ $as_echo X"$mf" |
--       continue
--     fi
--     # Extract the definition of DEPDIR, am__include, and am__quote
---    # from the Makefile without running 'make'.
--+    # from the Makefile without running `make'.
--     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
--     test -z "$DEPDIR" && continue
--     am__include=`sed -n 's/^am__include = //p' < "$mf"`
---    test -z "$am__include" && continue
--+    test -z "am__include" && continue
--     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
--+    # When using ansi2knr, U may be empty or an underscore; expand it
--+    U=`sed -n 's/^U = //p' < "$mf"`
--     # Find all dependency output files, they are included files with
--     # $(DEPDIR) in their names.  We invoke sed twice because it is the
--     # simplest approach to changing $(DEPDIR) to its actual value in the
--     # expansion.
--     for file in `sed -n "
--       s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
---	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
--+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
--       # Make sure the directory exists.
--       test -f "$dirpart/$file" && continue
--       fdir=`$as_dirname -- "$file" ||
--@@ -13688,8 +13524,8 @@ $as_echo X"$file" |
-- # NOTE: Changes made to this file will be lost: look at ltmain.sh.
-- #
-- #   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
---#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
---#                 Foundation, Inc.
--+#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
--+#                 Inc.
-- #   Written by Gordon Matzigkeit, 1996
-- #
-- #   This file is part of GNU Libtool.
--@@ -13743,9 +13579,6 @@ SHELL=$lt_SHELL
-- # An echo program that protects backslashes.
-- ECHO=$lt_ECHO
-- 
---# The PATH separator for the build system.
---PATH_SEPARATOR=$lt_PATH_SEPARATOR
---
-- # The host system.
-- host_alias=$host_alias
-- host=$host
--@@ -14047,6 +13880,10 @@ no_undefined_flag=$lt_no_undefined_flag
-- # This must work even if \$libdir does not exist
-- hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
-- 
--+# If ld is used when linking, flag to hardcode \$libdir into a binary
--+# during linking.  This must work even if \$libdir does not exist.
--+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
--+
-- # Whether we need a single "-rpath" flag with a separated argument.
-- hardcode_libdir_separator=$lt_hardcode_libdir_separator
-- 
- --- a/configure.ac
- +++ b/configure.ac
--@@ -44,7 +44,7 @@ regular_CFLAGS="-Wall -Waggregate-return
-+@@ -44,7 +44,7 @@ regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
-  
-  if test -n "$kbuilddir"; then
-  	AC_MSG_CHECKING([kernel version that we will build against])
---	krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
--+	krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
-- 	kmajor="${krel%%[[^0-9]]*}";
-- 	kmajor="$(($kmajor+0))";
-- 	krel="${krel:${#kmajor}}";
-+-	krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease | $AWK -v 'FS=[[^0-9.]]' '{print $1; exit}')";
-++	krel="$(make -sC "$kbuilddir" M=$PWD kernelversion | $AWK -v 'FS=[[^0-9.]]' '{print $1; exit}')";
-+ 	save_IFS=$IFS;
-+ 	IFS='.';
-+ 	set x $krel;

+ 0 - 81
patches/openwrt/0024-tools-add-tar-host-build-required-for-sort-name-which-was-only-added-in-the-latest-version.patch

@@ -1,81 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 24 Apr 2016 08:44:30 +0200
-Subject: tools: add tar host build, required for --sort=name which was only added in the latest version
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-
-Backport of r46876
-
-diff --git a/tools/Makefile b/tools/Makefile
-index c6cded8eccd81c422f99e7ee50754c4bc66decc7..98ce8c5f1577981136b277a800a3edd5edd4941e 100644
---- a/tools/Makefile
-+++ b/tools/Makefile
-@@ -81,6 +81,9 @@ endif
- # dependency for tools which have patches directory
- $(foreach tool, $(tools-y), $(if $(wildcard $(curdir)/$(tool)/patches),$(eval $(curdir)/$(tool)/compile += $(curdir)/patch/install)))
- 
-+$(foreach tool, $(tools-y), $(eval $(curdir)/$(tool)/compile += $(curdir)/tar/install))
-+tools-y += tar
-+
- $(curdir)/builddirs := $(tools-y) $(tools-dep) $(tools-)
- $(curdir)/builddirs-default := $(tools-y)
- 
-diff --git a/tools/tar/Makefile b/tools/tar/Makefile
-new file mode 100644
-index 0000000000000000000000000000000000000000..975e7835ef09131326ef10a7951c3866d6050801
---- /dev/null
-+++ b/tools/tar/Makefile
-@@ -0,0 +1,30 @@
-+#
-+# Copyright (C) 2015 OpenWrt.org
-+#
-+# This is free software, licensed under the GNU General Public License v2.
-+# See /LICENSE for more information.
-+#
-+include $(TOPDIR)/rules.mk
-+
-+PKG_NAME:=tar
-+PKG_VERSION:=1.28
-+
-+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
-+PKG_SOURCE_URL:=@GNU/tar
-+PKG_MD5SUM:=49b6306167724fe48f419a33a5beb857
-+
-+HOST_BUILD_PARALLEL := 1
-+
-+include $(INCLUDE_DIR)/host-build.mk
-+
-+HOSTCC := $(HOSTCC_NOCACHE)
-+HOSTCXX := $(HOSTCXX_NOCACHE)
-+
-+HOST_CONFIGURE_ARGS += \
-+	--without-posix-acls \
-+	--without-selinux \
-+	--without-xattrs \
-+	--disable-acl \
-+	--disable-nls
-+
-+$(eval $(call HostBuild))
-diff --git a/tools/tar/patches/100-fix_xattr_disable.patch b/tools/tar/patches/100-fix_xattr_disable.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..5735bd2364a4f324b54a3a49826921ead905d06f
---- /dev/null
-+++ b/tools/tar/patches/100-fix_xattr_disable.patch
-@@ -0,0 +1,17 @@
-+--- a/lib/xattr-at.c
-++++ b/lib/xattr-at.c
-+@@ -18,6 +18,8 @@
-+ 
-+ #include <config.h>
-+ 
-++#ifdef HAVE_XATTRS
-++
-+ #include "xattr-at.h"
-+ #include "openat.h"
-+ 
-+@@ -108,3 +110,5 @@
-+ #undef AT_FUNC_RESULT
-+ #undef AT_FUNC_POST_FILE_PARAM_DECLS
-+ #undef AT_FUNC_POST_FILE_ARGS
-++
-++#endif

+ 0 - 31
patches/openwrt/0025-tools-compile-flock-before-everything-else.patch

@@ -1,31 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 24 Apr 2016 08:44:47 +0200
-Subject: tools: compile flock before everything else
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-
-Backport of r48413
-
-diff --git a/tools/Makefile b/tools/Makefile
-index 98ce8c5f1577981136b277a800a3edd5edd4941e..3402c08d5c6729a510446a3e9cf586f2d8e15be4 100644
---- a/tools/Makefile
-+++ b/tools/Makefile
-@@ -26,7 +26,7 @@ endif
- tools-$(BUILD_TOOLCHAIN) += gmp mpfr mpc libelf
- tools-y += m4 libtool autoconf automake flex bison pkg-config sed mklibs
- tools-y += sstrip make-ext4fs e2fsprogs mtd-utils mkimage
--tools-y += firmware-utils patch-image patch quilt yaffs2 flock padjffs2
-+tools-y += firmware-utils patch-image patch quilt yaffs2 padjffs2
- tools-y += mm-macros missing-macros xz cmake scons bc findutils gengetopt patchelf
- tools-$(CONFIG_TARGET_orion_generic) += wrt350nv2-builder upslug2
- tools-$(CONFIG_powerpc) += upx
-@@ -84,6 +84,9 @@ $(foreach tool, $(tools-y), $(if $(wildcard $(curdir)/$(tool)/patches),$(eval $(
- $(foreach tool, $(tools-y), $(eval $(curdir)/$(tool)/compile += $(curdir)/tar/install))
- tools-y += tar
- 
-+$(curdir)/tar/compile := $(curdir)/flock/install
-+tools-y += flock
-+
- $(curdir)/builddirs := $(tools-y) $(tools-dep) $(tools-)
- $(curdir)/builddirs-default := $(tools-y)
- 

+ 0 - 32
patches/openwrt/0026-rules.mk-make-the-locked-template-available-even-if-flock-has-not-been-built-yet-fall-back-to-unlocked-shell-command.patch

@@ -1,32 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 24 Apr 2016 08:45:44 +0200
-Subject: rules.mk: make the locked template available even if flock has not been built yet (fall back to unlocked shell command)
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-
-Backport of r48414
-
-diff --git a/rules.mk b/rules.mk
-index 9d0134d2b26a52b74d30546cc3d51f7e71d1bc75..ece502609bd08af21be782a706f0bf6599895568 100644
---- a/rules.mk
-+++ b/rules.mk
-@@ -310,12 +310,16 @@ endef
- # Execute commands under flock
- # $(1) => The shell expression.
- # $(2) => The lock name. If not given, the global lock will be used.
--define locked
-+ifneq ($(wildcard $(STAGING_DIR_HOST)/bin/flock),)
-+  define locked
- 	SHELL= \
--	$(STAGING_DIR_HOST)/bin/flock \
-+	flock \
- 		$(TMP_DIR)/.$(if $(2),$(strip $(2)),global).flock \
- 		-c '$(subst ','\'',$(1))'
--endef
-+  endef
-+else
-+  locked=$(1)
-+endif
- 
- # Recursively copy paths into another directory, purge dangling
- # symlinks before.

+ 0 - 20
patches/openwrt/0027-build-add-locking-for-downloads-fixes-race-conditions-with-multiple-variants.patch

@@ -1,20 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 24 Apr 2016 08:48:45 +0200
-Subject: build: add locking for downloads (fixes race conditions with multiple variants)
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-
-Backport of r48416
-
-diff --git a/include/download.mk b/include/download.mk
-index e518cce4b2793152b7f4ef92509f2be07fb5cd62..9176b11c836123a37533c3d6cbaa2650a4f7c73d 100644
---- a/include/download.mk
-+++ b/include/download.mk
-@@ -182,6 +182,6 @@ define Download
- 
-   $(DL_DIR)/$(FILE):
- 	mkdir -p $(DL_DIR)
--	$(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown))
-+	$(call locked,$(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown)),$(FILE))
- 
- endef

+ 0 - 26
patches/openwrt/0028-download.mk-fix-packed-checkout-mirroring-support.patch

@@ -1,26 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 24 Apr 2016 08:49:27 +0200
-Subject: download.mk: fix packed checkout mirroring support
-
-Changeset r48416  broke the downloading of mirrored, packed scm checkouts.
-
-Fix this by removing the "@" sign in front of the download command which is
-now executed as part of a larger shell command under flock.
-
-Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
-
-Backport of r48733
-
-diff --git a/include/download.mk b/include/download.mk
-index 9176b11c836123a37533c3d6cbaa2650a4f7c73d..130bbc57ba89b4ad0b8e8600f45bf553ad6ecfa1 100644
---- a/include/download.mk
-+++ b/include/download.mk
-@@ -48,7 +48,7 @@ define DownloadMethod/default
- endef
- 
- define wrap_mirror
--	$(if $(if $(MIRROR),$(filter-out x,$(MIRROR_MD5SUM))),@$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" "" || ( $(1) ),$(1))
-+$(if $(if $(MIRROR),$(filter-out x,$(MIRROR_MD5SUM))),$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" "" || ( $(1) ),$(1))
- endef
- 
- define DownloadMethod/cvs

+ 0 - 2096
patches/openwrt/0029-kernel-backport-spi-nor-driver-from-4.4.9.patch

@@ -1,2096 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sat, 7 May 2016 00:07:51 +0200
-Subject: kernel: backport spi-nor driver from 4.4.9
-
-diff --git a/target/linux/ar71xx/patches-3.18/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch b/target/linux/ar71xx/patches-3.18/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
-index 568f5161b1e4639c005577ea46c2e0411f95ec7c..6a9132032ff1cefae213464d3212ef0d4e4b8011 100644
---- a/target/linux/ar71xx/patches-3.18/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
-+++ b/target/linux/ar71xx/patches-3.18/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
-@@ -1,11 +1,11 @@
- --- a/drivers/mtd/devices/m25p80.c
- +++ b/drivers/mtd/devices/m25p80.c
--@@ -246,7 +246,9 @@ static int m25p_probe(struct spi_device
-+@@ -229,7 +229,9 @@ static int m25p_probe(struct spi_device
-  
-  	ppdata.of_node = spi->dev.of_node;
-  
---	return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
--+	return mtd_device_parse_register(&flash->mtd,
-+-	return mtd_device_parse_register(&nor->mtd, NULL, &ppdata,
-++	return mtd_device_parse_register(&nor->mtd,
- +			data ? data->part_probes : NULL,
- +			&ppdata,
-  			data ? data->parts : NULL,
-diff --git a/target/linux/ar71xx/patches-3.18/412-mtd-m25p80-zero-partition-parser-data.patch b/target/linux/ar71xx/patches-3.18/412-mtd-m25p80-zero-partition-parser-data.patch
-index d51694d9fd2d6fa5a519ce27108c964b1b6f32f8..175acf630e0d0437936066b51ea086cf39740b30 100644
---- a/target/linux/ar71xx/patches-3.18/412-mtd-m25p80-zero-partition-parser-data.patch
-+++ b/target/linux/ar71xx/patches-3.18/412-mtd-m25p80-zero-partition-parser-data.patch
-@@ -1,10 +1,10 @@
- --- a/drivers/mtd/devices/m25p80.c
- +++ b/drivers/mtd/devices/m25p80.c
--@@ -244,6 +244,7 @@ static int m25p_probe(struct spi_device
-+@@ -227,6 +227,7 @@ static int m25p_probe(struct spi_device
-  	if (ret)
-  		return ret;
-  
- +	memset(&ppdata, '\0', sizeof(ppdata));
-  	ppdata.of_node = spi->dev.of_node;
-  
-- 	return mtd_device_parse_register(&flash->mtd,
-+ 	return mtd_device_parse_register(&nor->mtd,
-diff --git a/target/linux/ar71xx/patches-3.18/462-mtd-m25p80-set-spi-transfer-type.patch b/target/linux/ar71xx/patches-3.18/462-mtd-m25p80-set-spi-transfer-type.patch
-index 3320e5b845bdf2843f32e52b5b620ce880fd4e96..11bf9ff71b609b03239179bcd8977c2202f5c8cf 100644
---- a/target/linux/ar71xx/patches-3.18/462-mtd-m25p80-set-spi-transfer-type.patch
-+++ b/target/linux/ar71xx/patches-3.18/462-mtd-m25p80-set-spi-transfer-type.patch
-@@ -1,6 +1,6 @@
- --- a/drivers/mtd/devices/m25p80.c
- +++ b/drivers/mtd/devices/m25p80.c
--@@ -142,10 +142,12 @@ static int m25p80_read(struct spi_nor *n
-+@@ -137,10 +137,12 @@ static int m25p80_read(struct spi_nor *n
-  	flash->command[0] = nor->read_opcode;
-  	m25p_addr2cmd(nor, from, flash->command);
-  
-diff --git a/target/linux/ar71xx/patches-3.18/464-spi-ath79-fix-fast-flash-read.patch b/target/linux/ar71xx/patches-3.18/464-spi-ath79-fix-fast-flash-read.patch
-index e48665d6a09fdcc77d027274016c24fe78e8d95a..758d23181d49eff6afeb35b1fbbd8f36efa2cfca 100644
---- a/target/linux/ar71xx/patches-3.18/464-spi-ath79-fix-fast-flash-read.patch
-+++ b/target/linux/ar71xx/patches-3.18/464-spi-ath79-fix-fast-flash-read.patch
-@@ -1,6 +1,6 @@
- --- a/drivers/mtd/devices/m25p80.c
- +++ b/drivers/mtd/devices/m25p80.c
--@@ -142,6 +142,9 @@ static int m25p80_read(struct spi_nor *n
-+@@ -137,6 +137,9 @@ static int m25p80_read(struct spi_nor *n
-  	flash->command[0] = nor->read_opcode;
-  	m25p_addr2cmd(nor, from, flash->command);
-  
-@@ -25,7 +25,7 @@
-  	while (len--) {
- --- a/include/linux/spi/spi.h
- +++ b/include/linux/spi/spi.h
--@@ -637,6 +637,7 @@ struct spi_transfer {
-+@@ -633,6 +633,7 @@ struct spi_transfer {
-  	u16		delay_usecs;
-  	u32		speed_hz;
-  	enum spi_transfer_type type;
-diff --git a/target/linux/brcm63xx/patches-3.18/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch b/target/linux/brcm63xx/patches-3.18/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
-index b94969406deed4d6b8d51789235cd3e63e432c7c..be62e6789c883a5854a7bc9fae6dcc882090800f 100644
---- a/target/linux/brcm63xx/patches-3.18/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
-+++ b/target/linux/brcm63xx/patches-3.18/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
-@@ -11,12 +11,12 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
- 
- --- a/drivers/mtd/devices/m25p80.c
- +++ b/drivers/mtd/devices/m25p80.c
--@@ -246,7 +246,8 @@ static int m25p_probe(struct spi_device
-+@@ -229,7 +229,8 @@ static int m25p_probe(struct spi_device
-  
-  	ppdata.of_node = spi->dev.of_node;
-  
---	return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
--+	return mtd_device_parse_register(&flash->mtd,
-+-	return mtd_device_parse_register(&nor->mtd, NULL, &ppdata,
-++	return mtd_device_parse_register(&nor->mtd,
- +			data ? data->part_probe_types : NULL, &ppdata,
-  			data ? data->parts : NULL,
-  			data ? data->nr_parts : 0);
-diff --git a/target/linux/brcm63xx/patches-3.18/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch b/target/linux/brcm63xx/patches-3.18/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
-index 740fb2dafc4ece9e0c88630a1ad2b800f763ed59..3877442d21eb8f6a9fdacc415c60be78d61b3c5f 100644
---- a/target/linux/brcm63xx/patches-3.18/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
-+++ b/target/linux/brcm63xx/patches-3.18/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
-@@ -11,15 +11,15 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
- 
- --- a/drivers/mtd/devices/m25p80.c
- +++ b/drivers/mtd/devices/m25p80.c
--@@ -32,6 +32,7 @@ struct m25p {
-+@@ -31,6 +31,7 @@
-+ struct m25p {
-  	struct spi_device	*spi;
-  	struct spi_nor		spi_nor;
-- 	struct mtd_info		mtd;
- +	int			max_transfer_len;
-  	u8			command[MAX_CMD_SIZE];
-  };
-  
--@@ -121,7 +122,7 @@ static inline unsigned int m25p80_rx_nbi
-+@@ -119,7 +120,7 @@ static inline unsigned int m25p80_rx_nbi
-   * Read an address range from the nor chip.  The address range
-   * may be any size provided it is within the physical boundaries.
-   */
-@@ -28,7 +28,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
-  			size_t *retlen, u_char *buf)
-  {
-  	struct m25p *flash = nor->priv;
--@@ -157,6 +158,29 @@ static int m25p80_read(struct spi_nor *n
-+@@ -152,6 +153,29 @@ static int m25p80_read(struct spi_nor *n
-  	return 0;
-  }
-  
-@@ -58,7 +58,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
-  static int m25p80_erase(struct spi_nor *nor, loff_t offset)
-  {
-  	struct m25p *flash = nor->priv;
--@@ -240,6 +264,9 @@ static int m25p_probe(struct spi_device
-+@@ -223,6 +247,9 @@ static int m25p_probe(struct spi_device
-  	else
-  		flash_name = spi->modalias;
-  
-diff --git a/target/linux/brcm63xx/patches-3.18/414-MTD-m25p80-allow-passing-pp_data.patch b/target/linux/brcm63xx/patches-3.18/414-MTD-m25p80-allow-passing-pp_data.patch
-index b7bf57f697961a06d1ccef93ce4474f34f5e03e4..e421e9adbefb45fa837f686e253636781842fa7e 100644
---- a/target/linux/brcm63xx/patches-3.18/414-MTD-m25p80-allow-passing-pp_data.patch
-+++ b/target/linux/brcm63xx/patches-3.18/414-MTD-m25p80-allow-passing-pp_data.patch
-@@ -10,7 +10,7 @@ Subject: [PATCH 64/79] MTD: m25p80: allow passing pp_data
- 
- --- a/drivers/mtd/devices/m25p80.c
- +++ b/drivers/mtd/devices/m25p80.c
--@@ -267,6 +267,9 @@ static int m25p_probe(struct spi_device
-+@@ -250,6 +250,9 @@ static int m25p_probe(struct spi_device
-  	if (data)
-  		flash->max_transfer_len = data->max_transfer_len;
-  
-diff --git a/target/linux/generic/patches-3.18/043-mtd_GD25Q128B_support_backport_from_3.19.patch b/target/linux/generic/patches-3.18/043-mtd_GD25Q128B_support_backport_from_3.19.patch
-deleted file mode 100644
-index 4d0403bfd8a4a076cc9e91349463593adb79047c..0000000000000000000000000000000000000000
---- a/target/linux/generic/patches-3.18/043-mtd_GD25Q128B_support_backport_from_3.19.patch
-+++ /dev/null
-@@ -1,10 +0,0 @@
----- a/drivers/mtd/spi-nor/spi-nor.c
--+++ b/drivers/mtd/spi-nor/spi-nor.c
--@@ -510,6 +510,7 @@ static const struct spi_device_id spi_no
-- 	/* GigaDevice */
-- 	{ "gd25q32", INFO(0xc84016, 0, 64 * 1024,  64, SECT_4K) },
-- 	{ "gd25q64", INFO(0xc84017, 0, 64 * 1024, 128, SECT_4K) },
--+	{ "gd25q128", INFO(0xc84018, 0, 64 * 1024, 256, SECT_4K) },
-- 
-- 	/* Intel/Numonyx -- xxxs33b */
-- 	{ "160s33b",  INFO(0x898911, 0, 64 * 1024,  32, 0) },
-diff --git a/target/linux/generic/patches-3.18/093-m25p80_spi-nor_update_to_4.4.9.patch b/target/linux/generic/patches-3.18/093-m25p80_spi-nor_update_to_4.4.9.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..5f74d3a07ba62c9e1da0a0b2aef8abe309efdbb9
---- /dev/null
-+++ b/target/linux/generic/patches-3.18/093-m25p80_spi-nor_update_to_4.4.9.patch
-@@ -0,0 +1,1579 @@
-+--- a/drivers/mtd/devices/m25p80.c
-++++ b/drivers/mtd/devices/m25p80.c
-+@@ -31,7 +31,6 @@
-+ struct m25p {
-+ 	struct spi_device	*spi;
-+ 	struct spi_nor		spi_nor;
-+-	struct mtd_info		mtd;
-+ 	u8			command[MAX_CMD_SIZE];
-+ };
-+ 
-+@@ -62,8 +61,7 @@ static int m25p_cmdsz(struct spi_nor *no
-+ 	return 1 + nor->addr_width;
-+ }
-+ 
-+-static int m25p80_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len,
-+-			int wr_en)
-++static int m25p80_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
-+ {
-+ 	struct m25p *flash = nor->priv;
-+ 	struct spi_device *spi = flash->spi;
-+@@ -128,13 +126,10 @@ static int m25p80_read(struct spi_nor *n
-+ 	struct spi_device *spi = flash->spi;
-+ 	struct spi_transfer t[2];
-+ 	struct spi_message m;
-+-	int dummy = nor->read_dummy;
-+-	int ret;
-++	unsigned int dummy = nor->read_dummy;
-+ 
-+-	/* Wait till previous write/erase is done. */
-+-	ret = nor->wait_till_ready(nor);
-+-	if (ret)
-+-		return ret;
-++	/* convert the dummy cycles to the number of bytes */
-++	dummy /= 8;
-+ 
-+ 	spi_message_init(&m);
-+ 	memset(t, 0, (sizeof t));
-+@@ -160,20 +155,9 @@ static int m25p80_read(struct spi_nor *n
-+ static int m25p80_erase(struct spi_nor *nor, loff_t offset)
-+ {
-+ 	struct m25p *flash = nor->priv;
-+-	int ret;
-+ 
-+ 	dev_dbg(nor->dev, "%dKiB at 0x%08x\n",
-+-		flash->mtd.erasesize / 1024, (u32)offset);
-+-
-+-	/* Wait until finished previous write command. */
-+-	ret = nor->wait_till_ready(nor);
-+-	if (ret)
-+-		return ret;
-+-
-+-	/* Send write enable, then erase commands. */
-+-	ret = nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0, 0);
-+-	if (ret)
-+-		return ret;
-++		flash->spi_nor.mtd.erasesize / 1024, (u32)offset);
-+ 
-+ 	/* Set up command buffer. */
-+ 	flash->command[0] = nor->erase_opcode;
-+@@ -215,11 +199,10 @@ static int m25p_probe(struct spi_device
-+ 	nor->read_reg = m25p80_read_reg;
-+ 
-+ 	nor->dev = &spi->dev;
-+-	nor->mtd = &flash->mtd;
-++	nor->flash_node = spi->dev.of_node;
-+ 	nor->priv = flash;
-+ 
-+ 	spi_set_drvdata(spi, flash);
-+-	flash->mtd.priv = nor;
-+ 	flash->spi = spi;
-+ 
-+ 	if (spi->mode & SPI_RX_QUAD)
-+@@ -228,7 +211,7 @@ static int m25p_probe(struct spi_device
-+ 		mode = SPI_NOR_DUAL;
-+ 
-+ 	if (data && data->name)
-+-		flash->mtd.name = data->name;
-++		nor->mtd.name = data->name;
-+ 
-+ 	/* For some (historical?) reason many platforms provide two different
-+ 	 * names in flash_platform_data: "name" and "type". Quite often name is
-+@@ -246,7 +229,7 @@ static int m25p_probe(struct spi_device
-+ 
-+ 	ppdata.of_node = spi->dev.of_node;
-+ 
-+-	return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
-++	return mtd_device_parse_register(&nor->mtd, NULL, &ppdata,
-+ 			data ? data->parts : NULL,
-+ 			data ? data->nr_parts : 0);
-+ }
-+@@ -257,64 +240,68 @@ static int m25p_remove(struct spi_device
-+ 	struct m25p	*flash = spi_get_drvdata(spi);
-+ 
-+ 	/* Clean up MTD stuff. */
-+-	return mtd_device_unregister(&flash->mtd);
-++	return mtd_device_unregister(&flash->spi_nor.mtd);
-+ }
-+ 
-+-
-+ /*
-+- * XXX This needs to be kept in sync with spi_nor_ids.  We can't share
-+- * it with spi-nor, because if this is built as a module then modpost
-+- * won't be able to read it and add appropriate aliases.
-++ * Do NOT add to this array without reading the following:
-++ *
-++ * Historically, many flash devices are bound to this driver by their name. But
-++ * since most of these flash are compatible to some extent, and their
-++ * differences can often be differentiated by the JEDEC read-ID command, we
-++ * encourage new users to add support to the spi-nor library, and simply bind
-++ * against a generic string here (e.g., "jedec,spi-nor").
-++ *
-++ * Many flash names are kept here in this list (as well as in spi-nor.c) to
-++ * keep them available as module aliases for existing platforms.
-+  */
-+ static const struct spi_device_id m25p_ids[] = {
-+-	{"at25fs010"},	{"at25fs040"},	{"at25df041a"},	{"at25df321a"},
-+-	{"at25df641"},	{"at26f004"},	{"at26df081a"},	{"at26df161a"},
-+-	{"at26df321"},	{"at45db081d"},
-+-	{"en25f32"},	{"en25p32"},	{"en25q32b"},	{"en25p64"},
-+-	{"en25q64"},	{"en25qh128"},	{"en25qh256"},
-+-	{"f25l32pa"},
-+-	{"mr25h256"},	{"mr25h10"},
-+-	{"gd25q32"},	{"gd25q64"},
-+-	{"160s33b"},	{"320s33b"},	{"640s33b"},
-+-	{"mx25l2005a"},	{"mx25l4005a"},	{"mx25l8005"},	{"mx25l1606e"},
-+-	{"mx25l3205d"},	{"mx25l3255e"},	{"mx25l6405d"},	{"mx25l12805d"},
-+-	{"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
-+-	{"mx66l1g55g"},
-+-	{"n25q064"},	{"n25q128a11"},	{"n25q128a13"},	{"n25q256a"},
-+-	{"n25q512a"},	{"n25q512ax3"},	{"n25q00"},
-+-	{"pm25lv512"},	{"pm25lv010"},	{"pm25lq032"},
-+-	{"s25sl032p"},	{"s25sl064p"},	{"s25fl256s0"},	{"s25fl256s1"},
-+-	{"s25fl512s"},	{"s70fl01gs"},	{"s25sl12800"},	{"s25sl12801"},
-+-	{"s25fl129p0"},	{"s25fl129p1"},	{"s25sl004a"},	{"s25sl008a"},
-+-	{"s25sl016a"},	{"s25sl032a"},	{"s25sl064a"},	{"s25fl008k"},
-+-	{"s25fl016k"},	{"s25fl064k"},
-+-	{"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
-+-	{"sst25vf064c"},{"sst25wf512"},	{"sst25wf010"},	{"sst25wf020"},
-+-	{"sst25wf040"},
-+-	{"m25p05"},	{"m25p10"},	{"m25p20"},	{"m25p40"},
-+-	{"m25p80"},	{"m25p16"},	{"m25p32"},	{"m25p64"},
-+-	{"m25p128"},	{"n25q032"},
-++	/*
-++	 * Entries not used in DTs that should be safe to drop after replacing
-++	 * them with "nor-jedec" in platform data.
-++	 */
-++	{"s25sl064a"},	{"w25x16"},	{"m25p10"},	{"m25px64"},
-++
-++	/*
-++	 * Entries that were used in DTs without "nor-jedec" fallback and should
-++	 * be kept for backward compatibility.
-++	 */
-++	{"at25df321a"},	{"at25df641"},	{"at26df081a"},
-++	{"mr25h256"},
-++	{"mx25l4005a"},	{"mx25l1606e"},	{"mx25l6405d"},	{"mx25l12805d"},
-++	{"mx25l25635e"},{"mx66l51235l"},
-++	{"n25q064"},	{"n25q128a11"},	{"n25q128a13"},	{"n25q512a"},
-++	{"s25fl256s1"},	{"s25fl512s"},	{"s25sl12801"},	{"s25fl008k"},
-++	{"s25fl064k"},
-++	{"sst25vf040b"},{"sst25vf016b"},{"sst25vf032b"},{"sst25wf040"},
-++	{"m25p40"},	{"m25p80"},	{"m25p16"},	{"m25p32"},
-++	{"m25p64"},	{"m25p128"},
-++	{"w25x80"},	{"w25x32"},	{"w25q32"},	{"w25q32dw"},
-++	{"w25q80bl"},	{"w25q128"},	{"w25q256"},
-++
-++	/* Flashes that can't be detected using JEDEC */
-+ 	{"m25p05-nonjedec"},	{"m25p10-nonjedec"},	{"m25p20-nonjedec"},
-+ 	{"m25p40-nonjedec"},	{"m25p80-nonjedec"},	{"m25p16-nonjedec"},
-+ 	{"m25p32-nonjedec"},	{"m25p64-nonjedec"},	{"m25p128-nonjedec"},
-+-	{"m45pe10"},	{"m45pe80"},	{"m45pe16"},
-+-	{"m25pe20"},	{"m25pe80"},	{"m25pe16"},
-+-	{"m25px16"},	{"m25px32"},	{"m25px32-s0"},	{"m25px32-s1"},
-+-	{"m25px64"},	{"m25px80"},
-+-	{"w25x10"},	{"w25x20"},	{"w25x40"},	{"w25x80"},
-+-	{"w25x16"},	{"w25x32"},	{"w25q32"},	{"w25q32dw"},
-+-	{"w25x64"},	{"w25q64"},	{"w25q80"},	{"w25q80bl"},
-+-	{"w25q128"},	{"w25q256"},	{"cat25c11"},
-+-	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
-++
-+ 	{ },
-+ };
-+ MODULE_DEVICE_TABLE(spi, m25p_ids);
-+ 
-++static const struct of_device_id m25p_of_table[] = {
-++	/*
-++	 * Generic compatibility for SPI NOR that can be identified by the
-++	 * JEDEC READ ID opcode (0x9F). Use this, if possible.
-++	 */
-++	{ .compatible = "jedec,spi-nor" },
-++	{}
-++};
-++MODULE_DEVICE_TABLE(of, m25p_of_table);
-+ 
-+ static struct spi_driver m25p80_driver = {
-+ 	.driver = {
-+ 		.name	= "m25p80",
-+-		.owner	= THIS_MODULE,
-++		.of_match_table = m25p_of_table,
-+ 	},
-+ 	.id_table	= m25p_ids,
-+ 	.probe	= m25p_probe,
-+--- a/drivers/mtd/spi-nor/spi-nor.c
-++++ b/drivers/mtd/spi-nor/spi-nor.c
-+@@ -16,19 +16,63 @@
-+ #include <linux/device.h>
-+ #include <linux/mutex.h>
-+ #include <linux/math64.h>
-++#include <linux/sizes.h>
-+ 
-+-#include <linux/mtd/cfi.h>
-+ #include <linux/mtd/mtd.h>
-+ #include <linux/of_platform.h>
-+ #include <linux/spi/flash.h>
-+ #include <linux/mtd/spi-nor.h>
-+ 
-+ /* Define max times to check status register before we give up. */
-+-#define	MAX_READY_WAIT_JIFFIES	(40 * HZ) /* M25P16 specs 40s max chip erase */
-+ 
-+-#define JEDEC_MFR(_jedec_id)	((_jedec_id) >> 16)
-++/*
-++ * For everything but full-chip erase; probably could be much smaller, but kept
-++ * around for safety for now
-++ */
-++#define DEFAULT_READY_WAIT_JIFFIES		(40UL * HZ)
-++
-++/*
-++ * For full-chip erase, calibrated to a 2MB flash (M25P16); should be scaled up
-++ * for larger flash
-++ */
-++#define CHIP_ERASE_2MB_READY_WAIT_JIFFIES	(40UL * HZ)
-++
-++#define SPI_NOR_MAX_ID_LEN	6
-++
-++struct flash_info {
-++	char		*name;
-++
-++	/*
-++	 * This array stores the ID bytes.
-++	 * The first three bytes are the JEDIC ID.
-++	 * JEDEC ID zero means "no ID" (mostly older chips).
-++	 */
-++	u8		id[SPI_NOR_MAX_ID_LEN];
-++	u8		id_len;
-++
-++	/* The size listed here is what works with SPINOR_OP_SE, which isn't
-++	 * necessarily called a "sector" by the vendor.
-++	 */
-++	unsigned	sector_size;
-++	u16		n_sectors;
-++
-++	u16		page_size;
-++	u16		addr_width;
-++
-++	u16		flags;
-++#define	SECT_4K			0x01	/* SPINOR_OP_BE_4K works uniformly */
-++#define	SPI_NOR_NO_ERASE	0x02	/* No erase command needed */
-++#define	SST_WRITE		0x04	/* use SST byte programming */
-++#define	SPI_NOR_NO_FR		0x08	/* Can't do fastread */
-++#define	SECT_4K_PMC		0x10	/* SPINOR_OP_BE_4K_PMC works uniformly */
-++#define	SPI_NOR_DUAL_READ	0x20    /* Flash supports Dual Read */
-++#define	SPI_NOR_QUAD_READ	0x40    /* Flash supports Quad Read */
-++#define	USE_FSR			0x80	/* use flag status register */
-++};
-+ 
-+-static const struct spi_device_id *spi_nor_match_id(const char *name);
-++#define JEDEC_MFR(info)	((info)->id[0])
-++
-++static const struct flash_info *spi_nor_match_id(const char *name);
-+ 
-+ /*
-+  * Read the status register, returning its value in the location
-+@@ -98,7 +142,7 @@ static inline int spi_nor_read_dummy_cyc
-+ 	case SPI_NOR_FAST:
-+ 	case SPI_NOR_DUAL:
-+ 	case SPI_NOR_QUAD:
-+-		return 1;
-++		return 8;
-+ 	case SPI_NOR_NORMAL:
-+ 		return 0;
-+ 	}
-+@@ -112,7 +156,7 @@ static inline int spi_nor_read_dummy_cyc
-+ static inline int write_sr(struct spi_nor *nor, u8 val)
-+ {
-+ 	nor->cmd_buf[0] = val;
-+-	return nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 1, 0);
-++	return nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 1);
-+ }
-+ 
-+ /*
-+@@ -121,7 +165,7 @@ static inline int write_sr(struct spi_no
-+  */
-+ static inline int write_enable(struct spi_nor *nor)
-+ {
-+-	return nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0, 0);
-++	return nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0);
-+ }
-+ 
-+ /*
-+@@ -129,7 +173,7 @@ static inline int write_enable(struct sp
-+  */
-+ static inline int write_disable(struct spi_nor *nor)
-+ {
-+-	return nor->write_reg(nor, SPINOR_OP_WRDI, NULL, 0, 0);
-++	return nor->write_reg(nor, SPINOR_OP_WRDI, NULL, 0);
-+ }
-+ 
-+ static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd)
-+@@ -138,23 +182,24 @@ static inline struct spi_nor *mtd_to_spi
-+ }
-+ 
-+ /* Enable/disable 4-byte addressing mode. */
-+-static inline int set_4byte(struct spi_nor *nor, u32 jedec_id, int enable)
-++static inline int set_4byte(struct spi_nor *nor, const struct flash_info *info,
-++			    int enable)
-+ {
-+ 	int status;
-+ 	bool need_wren = false;
-+ 	u8 cmd;
-+ 
-+-	switch (JEDEC_MFR(jedec_id)) {
-+-	case CFI_MFR_ST: /* Micron, actually */
-++	switch (JEDEC_MFR(info)) {
-++	case SNOR_MFR_MICRON:
-+ 		/* Some Micron need WREN command; all will accept it */
-+ 		need_wren = true;
-+-	case CFI_MFR_MACRONIX:
-+-	case 0xEF /* winbond */:
-++	case SNOR_MFR_MACRONIX:
-++	case SNOR_MFR_WINBOND:
-+ 		if (need_wren)
-+ 			write_enable(nor);
-+ 
-+ 		cmd = enable ? SPINOR_OP_EN4B : SPINOR_OP_EX4B;
-+-		status = nor->write_reg(nor, cmd, NULL, 0, 0);
-++		status = nor->write_reg(nor, cmd, NULL, 0);
-+ 		if (need_wren)
-+ 			write_disable(nor);
-+ 
-+@@ -162,63 +207,73 @@ static inline int set_4byte(struct spi_n
-+ 	default:
-+ 		/* Spansion style */
-+ 		nor->cmd_buf[0] = enable << 7;
-+-		return nor->write_reg(nor, SPINOR_OP_BRWR, nor->cmd_buf, 1, 0);
-++		return nor->write_reg(nor, SPINOR_OP_BRWR, nor->cmd_buf, 1);
-+ 	}
-+ }
-+-
-+-static int spi_nor_wait_till_ready(struct spi_nor *nor)
-++static inline int spi_nor_sr_ready(struct spi_nor *nor)
-+ {
-+-	unsigned long deadline;
-+-	int sr;
-+-
-+-	deadline = jiffies + MAX_READY_WAIT_JIFFIES;
-+-
-+-	do {
-+-		cond_resched();
-++	int sr = read_sr(nor);
-++	if (sr < 0)
-++		return sr;
-++	else
-++		return !(sr & SR_WIP);
-++}
-+ 
-+-		sr = read_sr(nor);
-+-		if (sr < 0)
-+-			break;
-+-		else if (!(sr & SR_WIP))
-+-			return 0;
-+-	} while (!time_after_eq(jiffies, deadline));
-++static inline int spi_nor_fsr_ready(struct spi_nor *nor)
-++{
-++	int fsr = read_fsr(nor);
-++	if (fsr < 0)
-++		return fsr;
-++	else
-++		return fsr & FSR_READY;
-++}
-+ 
-+-	return -ETIMEDOUT;
-++static int spi_nor_ready(struct spi_nor *nor)
-++{
-++	int sr, fsr;
-++	sr = spi_nor_sr_ready(nor);
-++	if (sr < 0)
-++		return sr;
-++	fsr = nor->flags & SNOR_F_USE_FSR ? spi_nor_fsr_ready(nor) : 1;
-++	if (fsr < 0)
-++		return fsr;
-++	return sr && fsr;
-+ }
-+ 
-+-static int spi_nor_wait_till_fsr_ready(struct spi_nor *nor)
-++/*
-++ * Service routine to read status register until ready, or timeout occurs.
-++ * Returns non-zero if error.
-++ */
-++static int spi_nor_wait_till_ready_with_timeout(struct spi_nor *nor,
-++						unsigned long timeout_jiffies)
-+ {
-+ 	unsigned long deadline;
-+-	int sr;
-+-	int fsr;
-++	int timeout = 0, ret;
-+ 
-+-	deadline = jiffies + MAX_READY_WAIT_JIFFIES;
-++	deadline = jiffies + timeout_jiffies;
-++
-++	while (!timeout) {
-++		if (time_after_eq(jiffies, deadline))
-++			timeout = 1;
-++
-++		ret = spi_nor_ready(nor);
-++		if (ret < 0)
-++			return ret;
-++		if (ret)
-++			return 0;
-+ 
-+-	do {
-+ 		cond_resched();
-++	}
-+ 
-+-		sr = read_sr(nor);
-+-		if (sr < 0) {
-+-			break;
-+-		} else if (!(sr & SR_WIP)) {
-+-			fsr = read_fsr(nor);
-+-			if (fsr < 0)
-+-				break;
-+-			if (fsr & FSR_READY)
-+-				return 0;
-+-		}
-+-	} while (!time_after_eq(jiffies, deadline));
-++	dev_err(nor->dev, "flash operation timed out\n");
-+ 
-+ 	return -ETIMEDOUT;
-+ }
-+ 
-+-/*
-+- * Service routine to read status register until ready, or timeout occurs.
-+- * Returns non-zero if error.
-+- */
-+-static int wait_till_ready(struct spi_nor *nor)
-++static int spi_nor_wait_till_ready(struct spi_nor *nor)
-+ {
-+-	return nor->wait_till_ready(nor);
-++	return spi_nor_wait_till_ready_with_timeout(nor,
-++						    DEFAULT_READY_WAIT_JIFFIES);
-+ }
-+ 
-+ /*
-+@@ -228,19 +283,9 @@ static int wait_till_ready(struct spi_no
-+  */
-+ static int erase_chip(struct spi_nor *nor)
-+ {
-+-	int ret;
-+-
-+-	dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd->size >> 10));
-++	dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd.size >> 10));
-+ 
-+-	/* Wait until finished previous write command. */
-+-	ret = wait_till_ready(nor);
-+-	if (ret)
-+-		return ret;
-+-
-+-	/* Send write enable, then erase commands. */
-+-	write_enable(nor);
-+-
-+-	return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0, 0);
-++	return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0);
-+ }
-+ 
-+ static int spi_nor_lock_and_prep(struct spi_nor *nor, enum spi_nor_ops ops)
-+@@ -294,11 +339,28 @@ static int spi_nor_erase(struct mtd_info
-+ 
-+ 	/* whole-chip erase? */
-+ 	if (len == mtd->size) {
-++		unsigned long timeout;
-++
-++		write_enable(nor);
-++
-+ 		if (erase_chip(nor)) {
-+ 			ret = -EIO;
-+ 			goto erase_err;
-+ 		}
-+ 
-++		/*
-++		 * Scale the timeout linearly with the size of the flash, with
-++		 * a minimum calibrated to an old 2MB flash. We could try to
-++		 * pull these from CFI/SFDP, but these values should be good
-++		 * enough for now.
-++		 */
-++		timeout = max(CHIP_ERASE_2MB_READY_WAIT_JIFFIES,
-++			      CHIP_ERASE_2MB_READY_WAIT_JIFFIES *
-++			      (unsigned long)(mtd->size / SZ_2M));
-++		ret = spi_nor_wait_till_ready_with_timeout(nor, timeout);
-++		if (ret)
-++			goto erase_err;
-++
-+ 	/* REVISIT in some cases we could speed up erasing large regions
-+ 	 * by using SPINOR_OP_SE instead of SPINOR_OP_BE_4K.  We may have set up
-+ 	 * to use "small sector erase", but that's not always optimal.
-+@@ -307,6 +369,8 @@ static int spi_nor_erase(struct mtd_info
-+ 	/* "sector"-at-a-time erase */
-+ 	} else {
-+ 		while (len) {
-++			write_enable(nor);
-++
-+ 			if (nor->erase(nor, addr)) {
-+ 				ret = -EIO;
-+ 				goto erase_err;
-+@@ -314,9 +378,15 @@ static int spi_nor_erase(struct mtd_info
-+ 
-+ 			addr += mtd->erasesize;
-+ 			len -= mtd->erasesize;
-++
-++			ret = spi_nor_wait_till_ready(nor);
-++			if (ret)
-++				goto erase_err;
-+ 		}
-+ 	}
-+ 
-++	write_disable(nor);
-++
-+ 	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_ERASE);
-+ 
-+ 	instr->state = MTD_ERASE_DONE;
-+@@ -330,152 +400,267 @@ erase_err:
-+ 	return ret;
-+ }
-+ 
-+-static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
-++static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs,
-++				 uint64_t *len)
-+ {
-+-	struct spi_nor *nor = mtd_to_spi_nor(mtd);
-+-	uint32_t offset = ofs;
-+-	uint8_t status_old, status_new;
-+-	int ret = 0;
-++	struct mtd_info *mtd = &nor->mtd;
-++	u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
-++	int shift = ffs(mask) - 1;
-++	int pow;
-++
-++	if (!(sr & mask)) {
-++		/* No protection */
-++		*ofs = 0;
-++		*len = 0;
-++	} else {
-++		pow = ((sr & mask) ^ mask) >> shift;
-++		*len = mtd->size >> pow;
-++		*ofs = mtd->size - *len;
-++	}
-++}
-+ 
-+-	ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_LOCK);
-+-	if (ret)
-+-		return ret;
-++/*
-++ * Return 1 if the entire region is locked, 0 otherwise
-++ */
-++static int stm_is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len,
-++			    u8 sr)
-++{
-++	loff_t lock_offs;
-++	uint64_t lock_len;
-+ 
-+-	/* Wait until finished previous command */
-+-	ret = wait_till_ready(nor);
-+-	if (ret)
-+-		goto err;
-++	stm_get_locked_range(nor, sr, &lock_offs, &lock_len);
-++
-++	return (ofs + len <= lock_offs + lock_len) && (ofs >= lock_offs);
-++}
-++
-++/*
-++ * Lock a region of the flash. Compatible with ST Micro and similar flash.
-++ * Supports only the block protection bits BP{0,1,2} in the status register
-++ * (SR). Does not support these features found in newer SR bitfields:
-++ *   - TB: top/bottom protect - only handle TB=0 (top protect)
-++ *   - SEC: sector/block protect - only handle SEC=0 (block protect)
-++ *   - CMP: complement protect - only support CMP=0 (range is not complemented)
-++ *
-++ * Sample table portion for 8MB flash (Winbond w25q64fw):
-++ *
-++ *   SEC  |  TB   |  BP2  |  BP1  |  BP0  |  Prot Length  | Protected Portion
-++ *  --------------------------------------------------------------------------
-++ *    X   |   X   |   0   |   0   |   0   |  NONE         | NONE
-++ *    0   |   0   |   0   |   0   |   1   |  128 KB       | Upper 1/64
-++ *    0   |   0   |   0   |   1   |   0   |  256 KB       | Upper 1/32
-++ *    0   |   0   |   0   |   1   |   1   |  512 KB       | Upper 1/16
-++ *    0   |   0   |   1   |   0   |   0   |  1 MB         | Upper 1/8
-++ *    0   |   0   |   1   |   0   |   1   |  2 MB         | Upper 1/4
-++ *    0   |   0   |   1   |   1   |   0   |  4 MB         | Upper 1/2
-++ *    X   |   X   |   1   |   1   |   1   |  8 MB         | ALL
-++ *
-++ * Returns negative on errors, 0 on success.
-++ */
-++static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
-++{
-++	struct mtd_info *mtd = &nor->mtd;
-++	u8 status_old, status_new;
-++	u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
-++	u8 shift = ffs(mask) - 1, pow, val;
-+ 
-+ 	status_old = read_sr(nor);
-+ 
-+-	if (offset < mtd->size - (mtd->size / 2))
-+-		status_new = status_old | SR_BP2 | SR_BP1 | SR_BP0;
-+-	else if (offset < mtd->size - (mtd->size / 4))
-+-		status_new = (status_old & ~SR_BP0) | SR_BP2 | SR_BP1;
-+-	else if (offset < mtd->size - (mtd->size / 8))
-+-		status_new = (status_old & ~SR_BP1) | SR_BP2 | SR_BP0;
-+-	else if (offset < mtd->size - (mtd->size / 16))
-+-		status_new = (status_old & ~(SR_BP0 | SR_BP1)) | SR_BP2;
-+-	else if (offset < mtd->size - (mtd->size / 32))
-+-		status_new = (status_old & ~SR_BP2) | SR_BP1 | SR_BP0;
-+-	else if (offset < mtd->size - (mtd->size / 64))
-+-		status_new = (status_old & ~(SR_BP2 | SR_BP0)) | SR_BP1;
-+-	else
-+-		status_new = (status_old & ~(SR_BP2 | SR_BP1)) | SR_BP0;
-++	/* SPI NOR always locks to the end */
-++	if (ofs + len != mtd->size) {
-++		/* Does combined region extend to end? */
-++		if (!stm_is_locked_sr(nor, ofs + len, mtd->size - ofs - len,
-++				      status_old))
-++			return -EINVAL;
-++		len = mtd->size - ofs;
-++	}
-++
-++	/*
-++	 * Need smallest pow such that:
-++	 *
-++	 *   1 / (2^pow) <= (len / size)
-++	 *
-++	 * so (assuming power-of-2 size) we do:
-++	 *
-++	 *   pow = ceil(log2(size / len)) = log2(size) - floor(log2(len))
-++	 */
-++	pow = ilog2(mtd->size) - ilog2(len);
-++	val = mask - (pow << shift);
-++	if (val & ~mask)
-++		return -EINVAL;
-++	/* Don't "lock" with no region! */
-++	if (!(val & mask))
-++		return -EINVAL;
-++
-++	status_new = (status_old & ~mask) | val;
-+ 
-+ 	/* Only modify protection if it will not unlock other areas */
-+-	if ((status_new & (SR_BP2 | SR_BP1 | SR_BP0)) >
-+-				(status_old & (SR_BP2 | SR_BP1 | SR_BP0))) {
-+-		write_enable(nor);
-+-		ret = write_sr(nor, status_new);
-+-		if (ret)
-+-			goto err;
-++	if ((status_new & mask) <= (status_old & mask))
-++		return -EINVAL;
-++
-++	write_enable(nor);
-++	return write_sr(nor, status_new);
-++}
-++
-++/*
-++ * Unlock a region of the flash. See stm_lock() for more info
-++ *
-++ * Returns negative on errors, 0 on success.
-++ */
-++static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
-++{
-++	struct mtd_info *mtd = &nor->mtd;
-++	uint8_t status_old, status_new;
-++	u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
-++	u8 shift = ffs(mask) - 1, pow, val;
-++
-++	status_old = read_sr(nor);
-++
-++	/* Cannot unlock; would unlock larger region than requested */
-++	if (stm_is_locked_sr(nor, ofs - mtd->erasesize, mtd->erasesize,
-++			     status_old))
-++		return -EINVAL;
-++
-++	/*
-++	 * Need largest pow such that:
-++	 *
-++	 *   1 / (2^pow) >= (len / size)
-++	 *
-++	 * so (assuming power-of-2 size) we do:
-++	 *
-++	 *   pow = floor(log2(size / len)) = log2(size) - ceil(log2(len))
-++	 */
-++	pow = ilog2(mtd->size) - order_base_2(mtd->size - (ofs + len));
-++	if (ofs + len == mtd->size) {
-++		val = 0; /* fully unlocked */
-++	} else {
-++		val = mask - (pow << shift);
-++		/* Some power-of-two sizes are not supported */
-++		if (val & ~mask)
-++			return -EINVAL;
-+ 	}
-+ 
-+-err:
-+-	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
-+-	return ret;
-++	status_new = (status_old & ~mask) | val;
-++
-++	/* Only modify protection if it will not lock other areas */
-++	if ((status_new & mask) >= (status_old & mask))
-++		return -EINVAL;
-++
-++	write_enable(nor);
-++	return write_sr(nor, status_new);
-+ }
-+ 
-+-static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
-++/*
-++ * Check if a region of the flash is (completely) locked. See stm_lock() for
-++ * more info.
-++ *
-++ * Returns 1 if entire region is locked, 0 if any portion is unlocked, and
-++ * negative on errors.
-++ */
-++static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len)
-++{
-++	int status;
-++
-++	status = read_sr(nor);
-++	if (status < 0)
-++		return status;
-++
-++	return stm_is_locked_sr(nor, ofs, len, status);
-++}
-++
-++static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
-+ {
-+ 	struct spi_nor *nor = mtd_to_spi_nor(mtd);
-+-	uint32_t offset = ofs;
-+-	uint8_t status_old, status_new;
-+-	int ret = 0;
-++	int ret;
-+ 
-+-	ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
-++	ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_LOCK);
-+ 	if (ret)
-+ 		return ret;
-+ 
-+-	/* Wait until finished previous command */
-+-	ret = wait_till_ready(nor);
-+-	if (ret)
-+-		goto err;
-++	ret = nor->flash_lock(nor, ofs, len);
-+ 
-+-	status_old = read_sr(nor);
-++	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_UNLOCK);
-++	return ret;
-++}
-+ 
-+-	if (offset+len > mtd->size - (mtd->size / 64))
-+-		status_new = status_old & ~(SR_BP2 | SR_BP1 | SR_BP0);
-+-	else if (offset+len > mtd->size - (mtd->size / 32))
-+-		status_new = (status_old & ~(SR_BP2 | SR_BP1)) | SR_BP0;
-+-	else if (offset+len > mtd->size - (mtd->size / 16))
-+-		status_new = (status_old & ~(SR_BP2 | SR_BP0)) | SR_BP1;
-+-	else if (offset+len > mtd->size - (mtd->size / 8))
-+-		status_new = (status_old & ~SR_BP2) | SR_BP1 | SR_BP0;
-+-	else if (offset+len > mtd->size - (mtd->size / 4))
-+-		status_new = (status_old & ~(SR_BP0 | SR_BP1)) | SR_BP2;
-+-	else if (offset+len > mtd->size - (mtd->size / 2))
-+-		status_new = (status_old & ~SR_BP1) | SR_BP2 | SR_BP0;
-+-	else
-+-		status_new = (status_old & ~SR_BP0) | SR_BP2 | SR_BP1;
-++static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
-++{
-++	struct spi_nor *nor = mtd_to_spi_nor(mtd);
-++	int ret;
-+ 
-+-	/* Only modify protection if it will not lock other areas */
-+-	if ((status_new & (SR_BP2 | SR_BP1 | SR_BP0)) <
-+-				(status_old & (SR_BP2 | SR_BP1 | SR_BP0))) {
-+-		write_enable(nor);
-+-		ret = write_sr(nor, status_new);
-+-		if (ret)
-+-			goto err;
-+-	}
-++	ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
-++	if (ret)
-++		return ret;
-+ 
-+-err:
-+-	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_UNLOCK);
-++	ret = nor->flash_unlock(nor, ofs, len);
-++
-++	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
-+ 	return ret;
-+ }
-+ 
-+-struct flash_info {
-+-	/* JEDEC id zero means "no ID" (most older chips); otherwise it has
-+-	 * a high byte of zero plus three data bytes: the manufacturer id,
-+-	 * then a two byte device id.
-+-	 */
-+-	u32		jedec_id;
-+-	u16             ext_id;
-++static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
-++{
-++	struct spi_nor *nor = mtd_to_spi_nor(mtd);
-++	int ret;
-+ 
-+-	/* The size listed here is what works with SPINOR_OP_SE, which isn't
-+-	 * necessarily called a "sector" by the vendor.
-+-	 */
-+-	unsigned	sector_size;
-+-	u16		n_sectors;
-++	ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
-++	if (ret)
-++		return ret;
-+ 
-+-	u16		page_size;
-+-	u16		addr_width;
-++	ret = nor->flash_is_locked(nor, ofs, len);
-+ 
-+-	u16		flags;
-+-#define	SECT_4K			0x01	/* SPINOR_OP_BE_4K works uniformly */
-+-#define	SPI_NOR_NO_ERASE	0x02	/* No erase command needed */
-+-#define	SST_WRITE		0x04	/* use SST byte programming */
-+-#define	SPI_NOR_NO_FR		0x08	/* Can't do fastread */
-+-#define	SECT_4K_PMC		0x10	/* SPINOR_OP_BE_4K_PMC works uniformly */
-+-#define	SPI_NOR_DUAL_READ	0x20    /* Flash supports Dual Read */
-+-#define	SPI_NOR_QUAD_READ	0x40    /* Flash supports Quad Read */
-+-#define	USE_FSR			0x80	/* use flag status register */
-+-};
-++	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
-++	return ret;
-++}
-+ 
-++/* Used when the "_ext_id" is two bytes at most */
-+ #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)	\
-+-	((kernel_ulong_t)&(struct flash_info) {				\
-+-		.jedec_id = (_jedec_id),				\
-+-		.ext_id = (_ext_id),					\
-++		.id = {							\
-++			((_jedec_id) >> 16) & 0xff,			\
-++			((_jedec_id) >> 8) & 0xff,			\
-++			(_jedec_id) & 0xff,				\
-++			((_ext_id) >> 8) & 0xff,			\
-++			(_ext_id) & 0xff,				\
-++			},						\
-++		.id_len = (!(_jedec_id) ? 0 : (3 + ((_ext_id) ? 2 : 0))),	\
-++		.sector_size = (_sector_size),				\
-++		.n_sectors = (_n_sectors),				\
-++		.page_size = 256,					\
-++		.flags = (_flags),
-++
-++#define INFO6(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)	\
-++		.id = {							\
-++			((_jedec_id) >> 16) & 0xff,			\
-++			((_jedec_id) >> 8) & 0xff,			\
-++			(_jedec_id) & 0xff,				\
-++			((_ext_id) >> 16) & 0xff,			\
-++			((_ext_id) >> 8) & 0xff,			\
-++			(_ext_id) & 0xff,				\
-++			},						\
-++		.id_len = 6,						\
-+ 		.sector_size = (_sector_size),				\
-+ 		.n_sectors = (_n_sectors),				\
-+ 		.page_size = 256,					\
-+-		.flags = (_flags),					\
-+-	})
-++		.flags = (_flags),
-+ 
-+ #define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_width, _flags)	\
-+-	((kernel_ulong_t)&(struct flash_info) {				\
-+ 		.sector_size = (_sector_size),				\
-+ 		.n_sectors = (_n_sectors),				\
-+ 		.page_size = (_page_size),				\
-+ 		.addr_width = (_addr_width),				\
-+-		.flags = (_flags),					\
-+-	})
-++		.flags = (_flags),
-+ 
-+ /* NOTE: double check command sets and memory organization when you add
-+  * more nor chips.  This current list focusses on newer chips, which
-+  * have been converging on command sets which including JEDEC ID.
-++ *
-++ * All newly added entries should describe *hardware* and should use SECT_4K
-++ * (or SECT_4K_PMC) if hardware supports erasing 4 KiB sectors. For usage
-++ * scenarios excluding small sectors there is config option that can be
-++ * disabled: CONFIG_MTD_SPI_NOR_USE_4K_SECTORS.
-++ * For historical (and compatibility) reasons (before we got above config) some
-++ * old entries may be missing 4K flag.
-+  */
-+-static const struct spi_device_id spi_nor_ids[] = {
-++static const struct flash_info spi_nor_ids[] = {
-+ 	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
-+ 	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SECT_4K) },
-+ 	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SECT_4K) },
-+@@ -499,6 +684,7 @@ static const struct spi_device_id spi_no
-+ 	{ "en25q64",    INFO(0x1c3017, 0, 64 * 1024,  128, SECT_4K) },
-+ 	{ "en25qh128",  INFO(0x1c7018, 0, 64 * 1024,  256, 0) },
-+ 	{ "en25qh256",  INFO(0x1c7019, 0, 64 * 1024,  512, 0) },
-++	{ "en25s64",	INFO(0x1c3817, 0, 64 * 1024,  128, SECT_4K) },
-+ 
-+ 	/* ESMT */
-+ 	{ "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SECT_4K) },
-+@@ -507,16 +693,24 @@ static const struct spi_device_id spi_no
-+ 	{ "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-+ 	{ "mr25h10",  CAT25_INFO(128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-+ 
-++	/* Fujitsu */
-++	{ "mb85rs1mt", INFO(0x047f27, 0, 128 * 1024, 1, SPI_NOR_NO_ERASE) },
-++
-+ 	/* GigaDevice */
-+ 	{ "gd25q32", INFO(0xc84016, 0, 64 * 1024,  64, SECT_4K) },
-+ 	{ "gd25q64", INFO(0xc84017, 0, 64 * 1024, 128, SECT_4K) },
-++	{ "gd25q128", INFO(0xc84018, 0, 64 * 1024, 256, SECT_4K) },
-+ 
-+ 	/* Intel/Numonyx -- xxxs33b */
-+ 	{ "160s33b",  INFO(0x898911, 0, 64 * 1024,  32, 0) },
-+ 	{ "320s33b",  INFO(0x898912, 0, 64 * 1024,  64, 0) },
-+ 	{ "640s33b",  INFO(0x898913, 0, 64 * 1024, 128, 0) },
-+ 
-++	/* ISSI */
-++	{ "is25cd512", INFO(0x7f9d20, 0, 32 * 1024,   2, SECT_4K) },
-++
-+ 	/* Macronix */
-++	{ "mx25l512e",   INFO(0xc22010, 0, 64 * 1024,   1, SECT_4K) },
-+ 	{ "mx25l2005a",  INFO(0xc22012, 0, 64 * 1024,   4, SECT_4K) },
-+ 	{ "mx25l4005a",  INFO(0xc22013, 0, 64 * 1024,   8, SECT_4K) },
-+ 	{ "mx25l8005",   INFO(0xc22014, 0, 64 * 1024,  16, 0) },
-+@@ -524,6 +718,7 @@ static const struct spi_device_id spi_no
-+ 	{ "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, 0) },
-+ 	{ "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-+ 	{ "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, 0) },
-++	{ "mx25u6435f",  INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) },
-+ 	{ "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) },
-+ 	{ "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
-+ 	{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
-+@@ -532,13 +727,16 @@ static const struct spi_device_id spi_no
-+ 	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
-+ 
-+ 	/* Micron */
-+-	{ "n25q064",     INFO(0x20ba17, 0, 64 * 1024,  128, 0) },
-+-	{ "n25q128a11",  INFO(0x20bb18, 0, 64 * 1024,  256, 0) },
-+-	{ "n25q128a13",  INFO(0x20ba18, 0, 64 * 1024,  256, 0) },
-+-	{ "n25q256a",    INFO(0x20ba19, 0, 64 * 1024,  512, SECT_4K) },
-+-	{ "n25q512a",    INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
-+-	{ "n25q512ax3",  INFO(0x20ba20, 0, 64 * 1024, 1024, USE_FSR) },
-+-	{ "n25q00",      INFO(0x20ba21, 0, 64 * 1024, 2048, USE_FSR) },
-++	{ "n25q032",	 INFO(0x20ba16, 0, 64 * 1024,   64, SPI_NOR_QUAD_READ) },
-++	{ "n25q032a",	 INFO(0x20bb16, 0, 64 * 1024,   64, SPI_NOR_QUAD_READ) },
-++	{ "n25q064",     INFO(0x20ba17, 0, 64 * 1024,  128, SECT_4K | SPI_NOR_QUAD_READ) },
-++	{ "n25q064a",    INFO(0x20bb17, 0, 64 * 1024,  128, SECT_4K | SPI_NOR_QUAD_READ) },
-++	{ "n25q128a11",  INFO(0x20bb18, 0, 64 * 1024,  256, SPI_NOR_QUAD_READ) },
-++	{ "n25q128a13",  INFO(0x20ba18, 0, 64 * 1024,  256, SPI_NOR_QUAD_READ) },
-++	{ "n25q256a",    INFO(0x20ba19, 0, 64 * 1024,  512, SECT_4K | SPI_NOR_QUAD_READ) },
-++	{ "n25q512a",    INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
-++	{ "n25q512ax3",  INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
-++	{ "n25q00",      INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
-+ 
-+ 	/* PMC */
-+ 	{ "pm25lv512",   INFO(0,        0, 32 * 1024,    2, SECT_4K_PMC) },
-+@@ -549,23 +747,28 @@ static const struct spi_device_id spi_no
-+ 	 * for the chips listed here (without boot sectors).
-+ 	 */
-+ 	{ "s25sl032p",  INFO(0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-+-	{ "s25sl064p",  INFO(0x010216, 0x4d00,  64 * 1024, 128, 0) },
-++	{ "s25sl064p",  INFO(0x010216, 0x4d00,  64 * 1024, 128, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-+ 	{ "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) },
-+ 	{ "s25fl256s1", INFO(0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-+ 	{ "s25fl512s",  INFO(0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-+ 	{ "s70fl01gs",  INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) },
-+ 	{ "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024,  64, 0) },
-+ 	{ "s25sl12801", INFO(0x012018, 0x0301,  64 * 1024, 256, 0) },
-+-	{ "s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024,  64, 0) },
-+-	{ "s25fl129p1", INFO(0x012018, 0x4d01,  64 * 1024, 256, 0) },
-++	{ "s25fl128s",	INFO6(0x012018, 0x4d0180, 64 * 1024, 256, SECT_4K | SPI_NOR_QUAD_READ) },
-++	{ "s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-++	{ "s25fl129p1", INFO(0x012018, 0x4d01,  64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-+ 	{ "s25sl004a",  INFO(0x010212,      0,  64 * 1024,   8, 0) },
-+ 	{ "s25sl008a",  INFO(0x010213,      0,  64 * 1024,  16, 0) },
-+ 	{ "s25sl016a",  INFO(0x010214,      0,  64 * 1024,  32, 0) },
-+ 	{ "s25sl032a",  INFO(0x010215,      0,  64 * 1024,  64, 0) },
-+ 	{ "s25sl064a",  INFO(0x010216,      0,  64 * 1024, 128, 0) },
-+-	{ "s25fl008k",  INFO(0xef4014,      0,  64 * 1024,  16, SECT_4K) },
-+-	{ "s25fl016k",  INFO(0xef4015,      0,  64 * 1024,  32, SECT_4K) },
-++	{ "s25fl004k",  INFO(0xef4013,      0,  64 * 1024,   8, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-++	{ "s25fl008k",  INFO(0xef4014,      0,  64 * 1024,  16, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-++	{ "s25fl016k",  INFO(0xef4015,      0,  64 * 1024,  32, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-+ 	{ "s25fl064k",  INFO(0xef4017,      0,  64 * 1024, 128, SECT_4K) },
-++	{ "s25fl132k",  INFO(0x014016,      0,  64 * 1024,  64, SECT_4K) },
-++	{ "s25fl164k",  INFO(0x014017,      0,  64 * 1024, 128, SECT_4K) },
-++	{ "s25fl204k",  INFO(0x014013,      0,  64 * 1024,   8, SECT_4K | SPI_NOR_DUAL_READ) },
-+ 
-+ 	/* SST -- large erase sizes are "overlays", "sectors" are 4K */
-+ 	{ "sst25vf040b", INFO(0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE) },
-+@@ -576,7 +779,10 @@ static const struct spi_device_id spi_no
-+ 	{ "sst25wf512",  INFO(0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE) },
-+ 	{ "sst25wf010",  INFO(0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE) },
-+ 	{ "sst25wf020",  INFO(0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE) },
-++	{ "sst25wf020a", INFO(0x621612, 0, 64 * 1024,  4, SECT_4K) },
-++	{ "sst25wf040b", INFO(0x621613, 0, 64 * 1024,  8, SECT_4K) },
-+ 	{ "sst25wf040",  INFO(0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE) },
-++	{ "sst25wf080",  INFO(0xbf2505, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) },
-+ 
-+ 	/* ST Microelectronics -- newer production may have feature updates */
-+ 	{ "m25p05",  INFO(0x202010,  0,  32 * 1024,   2, 0) },
-+@@ -588,7 +794,6 @@ static const struct spi_device_id spi_no
-+ 	{ "m25p32",  INFO(0x202016,  0,  64 * 1024,  64, 0) },
-+ 	{ "m25p64",  INFO(0x202017,  0,  64 * 1024, 128, 0) },
-+ 	{ "m25p128", INFO(0x202018,  0, 256 * 1024,  64, 0) },
-+-	{ "n25q032", INFO(0x20ba16,  0,  64 * 1024,  64, 0) },
-+ 
-+ 	{ "m25p05-nonjedec",  INFO(0, 0,  32 * 1024,   2, 0) },
-+ 	{ "m25p10-nonjedec",  INFO(0, 0,  32 * 1024,   4, 0) },
-+@@ -616,6 +821,7 @@ static const struct spi_device_id spi_no
-+ 	{ "m25px80",    INFO(0x207114,  0, 64 * 1024, 16, 0) },
-+ 
-+ 	/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
-++	{ "w25x05", INFO(0xef3010, 0, 64 * 1024,  1,  SECT_4K) },
-+ 	{ "w25x10", INFO(0xef3011, 0, 64 * 1024,  2,  SECT_4K) },
-+ 	{ "w25x20", INFO(0xef3012, 0, 64 * 1024,  4,  SECT_4K) },
-+ 	{ "w25x40", INFO(0xef3013, 0, 64 * 1024,  8,  SECT_4K) },
-+@@ -623,9 +829,11 @@ static const struct spi_device_id spi_no
-+ 	{ "w25x16", INFO(0xef3015, 0, 64 * 1024,  32, SECT_4K) },
-+ 	{ "w25x32", INFO(0xef3016, 0, 64 * 1024,  64, SECT_4K) },
-+ 	{ "w25q32", INFO(0xef4016, 0, 64 * 1024,  64, SECT_4K) },
-+-	{ "w25q32dw", INFO(0xef6016, 0, 64 * 1024,  64, SECT_4K) },
-++	{ "w25q32dw", INFO(0xef6016, 0, 64 * 1024,  64, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-+ 	{ "w25x64", INFO(0xef3017, 0, 64 * 1024, 128, SECT_4K) },
-+ 	{ "w25q64", INFO(0xef4017, 0, 64 * 1024, 128, SECT_4K) },
-++	{ "w25q64dw", INFO(0xef6017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-++	{ "w25q128fw", INFO(0xef6018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-+ 	{ "w25q80", INFO(0xef5014, 0, 64 * 1024,  16, SECT_4K) },
-+ 	{ "w25q80bl", INFO(0xef4014, 0, 64 * 1024,  16, SECT_4K) },
-+ 	{ "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
-+@@ -640,35 +848,27 @@ static const struct spi_device_id spi_no
-+ 	{ },
-+ };
-+ 
-+-static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
-++static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
-+ {
-+ 	int			tmp;
-+-	u8			id[5];
-+-	u32			jedec;
-+-	u16                     ext_jedec;
-+-	struct flash_info	*info;
-++	u8			id[SPI_NOR_MAX_ID_LEN];
-++	const struct flash_info	*info;
-+ 
-+-	tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, 5);
-++	tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN);
-+ 	if (tmp < 0) {
-+ 		dev_dbg(nor->dev, " error %d reading JEDEC ID\n", tmp);
-+ 		return ERR_PTR(tmp);
-+ 	}
-+-	jedec = id[0];
-+-	jedec = jedec << 8;
-+-	jedec |= id[1];
-+-	jedec = jedec << 8;
-+-	jedec |= id[2];
-+-
-+-	ext_jedec = id[3] << 8 | id[4];
-+ 
-+ 	for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
-+-		info = (void *)spi_nor_ids[tmp].driver_data;
-+-		if (info->jedec_id == jedec) {
-+-			if (info->ext_id == 0 || info->ext_id == ext_jedec)
-++		info = &spi_nor_ids[tmp];
-++		if (info->id_len) {
-++			if (!memcmp(info->id, id, info->id_len))
-+ 				return &spi_nor_ids[tmp];
-+ 		}
-+ 	}
-+-	dev_err(nor->dev, "unrecognized JEDEC id %06x\n", jedec);
-++	dev_err(nor->dev, "unrecognized JEDEC id bytes: %02x, %2x, %2x\n",
-++		id[0], id[1], id[2]);
-+ 	return ERR_PTR(-ENODEV);
-+ }
-+ 
-+@@ -703,11 +903,6 @@ static int sst_write(struct mtd_info *mt
-+ 	if (ret)
-+ 		return ret;
-+ 
-+-	/* Wait until finished previous write command. */
-+-	ret = wait_till_ready(nor);
-+-	if (ret)
-+-		goto time_out;
-+-
-+ 	write_enable(nor);
-+ 
-+ 	nor->sst_write_second = false;
-+@@ -719,7 +914,7 @@ static int sst_write(struct mtd_info *mt
-+ 
-+ 		/* write one byte. */
-+ 		nor->write(nor, to, 1, retlen, buf);
-+-		ret = wait_till_ready(nor);
-++		ret = spi_nor_wait_till_ready(nor);
-+ 		if (ret)
-+ 			goto time_out;
-+ 	}
-+@@ -731,7 +926,7 @@ static int sst_write(struct mtd_info *mt
-+ 
-+ 		/* write two bytes. */
-+ 		nor->write(nor, to, 2, retlen, buf + actual);
-+-		ret = wait_till_ready(nor);
-++		ret = spi_nor_wait_till_ready(nor);
-+ 		if (ret)
-+ 			goto time_out;
-+ 		to += 2;
-+@@ -740,7 +935,7 @@ static int sst_write(struct mtd_info *mt
-+ 	nor->sst_write_second = false;
-+ 
-+ 	write_disable(nor);
-+-	ret = wait_till_ready(nor);
-++	ret = spi_nor_wait_till_ready(nor);
-+ 	if (ret)
-+ 		goto time_out;
-+ 
-+@@ -751,7 +946,7 @@ static int sst_write(struct mtd_info *mt
-+ 		nor->program_opcode = SPINOR_OP_BP;
-+ 		nor->write(nor, to, 1, retlen, buf + actual);
-+ 
-+-		ret = wait_till_ready(nor);
-++		ret = spi_nor_wait_till_ready(nor);
-+ 		if (ret)
-+ 			goto time_out;
-+ 		write_disable(nor);
-+@@ -779,11 +974,6 @@ static int spi_nor_write(struct mtd_info
-+ 	if (ret)
-+ 		return ret;
-+ 
-+-	/* Wait until finished previous write command. */
-+-	ret = wait_till_ready(nor);
-+-	if (ret)
-+-		goto write_err;
-+-
-+ 	write_enable(nor);
-+ 
-+ 	page_offset = to & (nor->page_size - 1);
-+@@ -802,16 +992,20 @@ static int spi_nor_write(struct mtd_info
-+ 			if (page_size > nor->page_size)
-+ 				page_size = nor->page_size;
-+ 
-+-			wait_till_ready(nor);
-++			ret = spi_nor_wait_till_ready(nor);
-++			if (ret)
-++				goto write_err;
-++
-+ 			write_enable(nor);
-+ 
-+ 			nor->write(nor, to + i, page_size, retlen, buf + i);
-+ 		}
-+ 	}
-+ 
-++	ret = spi_nor_wait_till_ready(nor);
-+ write_err:
-+ 	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE);
-+-	return 0;
-++	return ret;
-+ }
-+ 
-+ static int macronix_quad_enable(struct spi_nor *nor)
-+@@ -821,10 +1015,9 @@ static int macronix_quad_enable(struct s
-+ 	val = read_sr(nor);
-+ 	write_enable(nor);
-+ 
-+-	nor->cmd_buf[0] = val | SR_QUAD_EN_MX;
-+-	nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 1, 0);
-++	write_sr(nor, val | SR_QUAD_EN_MX);
-+ 
-+-	if (wait_till_ready(nor))
-++	if (spi_nor_wait_till_ready(nor))
-+ 		return 1;
-+ 
-+ 	ret = read_sr(nor);
-+@@ -847,7 +1040,7 @@ static int write_sr_cr(struct spi_nor *n
-+ 	nor->cmd_buf[0] = val & 0xff;
-+ 	nor->cmd_buf[1] = (val >> 8);
-+ 
-+-	return nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 2, 0);
-++	return nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 2);
-+ }
-+ 
-+ static int spansion_quad_enable(struct spi_nor *nor)
-+@@ -874,18 +1067,20 @@ static int spansion_quad_enable(struct s
-+ 	return 0;
-+ }
-+ 
-+-static int set_quad_mode(struct spi_nor *nor, u32 jedec_id)
-++static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info)
-+ {
-+ 	int status;
-+ 
-+-	switch (JEDEC_MFR(jedec_id)) {
-+-	case CFI_MFR_MACRONIX:
-++	switch (JEDEC_MFR(info)) {
-++	case SNOR_MFR_MACRONIX:
-+ 		status = macronix_quad_enable(nor);
-+ 		if (status) {
-+ 			dev_err(nor->dev, "Macronix quad-read not enabled\n");
-+ 			return -EINVAL;
-+ 		}
-+ 		return status;
-++	case SNOR_MFR_MICRON:
-++		return 0;
-+ 	default:
-+ 		status = spansion_quad_enable(nor);
-+ 		if (status) {
-+@@ -904,21 +1099,15 @@ static int spi_nor_check(struct spi_nor
-+ 		return -EINVAL;
-+ 	}
-+ 
-+-	if (!nor->read_id)
-+-		nor->read_id = spi_nor_read_id;
-+-	if (!nor->wait_till_ready)
-+-		nor->wait_till_ready = spi_nor_wait_till_ready;
-+-
-+ 	return 0;
-+ }
-+ 
-+ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
-+ {
-+-	const struct spi_device_id	*id = NULL;
-+-	struct flash_info		*info;
-++	const struct flash_info *info = NULL;
-+ 	struct device *dev = nor->dev;
-+-	struct mtd_info *mtd = nor->mtd;
-+-	struct device_node *np = dev->of_node;
-++	struct mtd_info *mtd = &nor->mtd;
-++	struct device_node *np = nor->flash_node;
-+ 	int ret;
-+ 	int i;
-+ 
-+@@ -926,19 +1115,25 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	if (ret)
-+ 		return ret;
-+ 
-+-	id = spi_nor_match_id(name);
-+-	if (!id)
-++	if (name)
-++		info = spi_nor_match_id(name);
-++	/* Try to auto-detect if chip name wasn't specified or not found */
-++	if (!info)
-++		info = spi_nor_read_id(nor);
-++	if (IS_ERR_OR_NULL(info))
-+ 		return -ENOENT;
-+ 
-+-	info = (void *)id->driver_data;
-+-
-+-	if (info->jedec_id) {
-+-		const struct spi_device_id *jid;
-++	/*
-++	 * If caller has specified name of flash model that can normally be
-++	 * detected using JEDEC, let's verify it.
-++	 */
-++	if (name && info->id_len) {
-++		const struct flash_info *jinfo;
-+ 
-+-		jid = nor->read_id(nor);
-+-		if (IS_ERR(jid)) {
-+-			return PTR_ERR(jid);
-+-		} else if (jid != id) {
-++		jinfo = spi_nor_read_id(nor);
-++		if (IS_ERR(jinfo)) {
-++			return PTR_ERR(jinfo);
-++		} else if (jinfo != info) {
-+ 			/*
-+ 			 * JEDEC knows better, so overwrite platform ID. We
-+ 			 * can't trust partitions any longer, but we'll let
-+@@ -947,28 +1142,28 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 			 * information, even if it's not 100% accurate.
-+ 			 */
-+ 			dev_warn(dev, "found %s, expected %s\n",
-+-				 jid->name, id->name);
-+-			id = jid;
-+-			info = (void *)jid->driver_data;
-++				 jinfo->name, info->name);
-++			info = jinfo;
-+ 		}
-+ 	}
-+ 
-+ 	mutex_init(&nor->lock);
-+ 
-+ 	/*
-+-	 * Atmel, SST and Intel/Numonyx serial nor tend to power
-+-	 * up with the software protection bits set
-++	 * Atmel, SST, Intel/Numonyx, and others serial NOR tend to power up
-++	 * with the software protection bits set
-+ 	 */
-+ 
-+-	if (JEDEC_MFR(info->jedec_id) == CFI_MFR_ATMEL ||
-+-	    JEDEC_MFR(info->jedec_id) == CFI_MFR_INTEL ||
-+-	    JEDEC_MFR(info->jedec_id) == CFI_MFR_SST) {
-++	if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
-++	    JEDEC_MFR(info) == SNOR_MFR_INTEL ||
-++	    JEDEC_MFR(info) == SNOR_MFR_SST) {
-+ 		write_enable(nor);
-+ 		write_sr(nor, 0);
-+ 	}
-+ 
-+ 	if (!mtd->name)
-+ 		mtd->name = dev_name(dev);
-++	mtd->priv = nor;
-+ 	mtd->type = MTD_NORFLASH;
-+ 	mtd->writesize = 1;
-+ 	mtd->flags = MTD_CAP_NORFLASH;
-+@@ -976,10 +1171,17 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	mtd->_erase = spi_nor_erase;
-+ 	mtd->_read = spi_nor_read;
-+ 
-+-	/* nor protection support for STmicro chips */
-+-	if (JEDEC_MFR(info->jedec_id) == CFI_MFR_ST) {
-++	/* NOR protection support for STmicro/Micron chips and similar */
-++	if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
-++		nor->flash_lock = stm_lock;
-++		nor->flash_unlock = stm_unlock;
-++		nor->flash_is_locked = stm_is_locked;
-++	}
-++
-++	if (nor->flash_lock && nor->flash_unlock && nor->flash_is_locked) {
-+ 		mtd->_lock = spi_nor_lock;
-+ 		mtd->_unlock = spi_nor_unlock;
-++		mtd->_is_locked = spi_nor_is_locked;
-+ 	}
-+ 
-+ 	/* sst nor chips use AAI word program */
-+@@ -988,9 +1190,8 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	else
-+ 		mtd->_write = spi_nor_write;
-+ 
-+-	if ((info->flags & USE_FSR) &&
-+-	    nor->wait_till_ready == spi_nor_wait_till_ready)
-+-		nor->wait_till_ready = spi_nor_wait_till_fsr_ready;
-++	if (info->flags & USE_FSR)
-++		nor->flags |= SNOR_F_USE_FSR;
-+ 
-+ #ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS
-+ 	/* prefer "small sector" erase if possible */
-+@@ -1031,7 +1232,7 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 
-+ 	/* Quad/Dual-read mode takes precedence over fast/normal */
-+ 	if (mode == SPI_NOR_QUAD && info->flags & SPI_NOR_QUAD_READ) {
-+-		ret = set_quad_mode(nor, info->jedec_id);
-++		ret = set_quad_mode(nor, info);
-+ 		if (ret) {
-+ 			dev_err(dev, "quad mode not supported\n");
-+ 			return ret;
-+@@ -1067,7 +1268,7 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	else if (mtd->size > 0x1000000) {
-+ 		/* enable 4-byte addressing if the device exceeds 16MiB */
-+ 		nor->addr_width = 4;
-+-		if (JEDEC_MFR(info->jedec_id) == CFI_MFR_AMD) {
-++		if (JEDEC_MFR(info) == SNOR_MFR_SPANSION) {
-+ 			/* Dedicated 4-byte command set */
-+ 			switch (nor->flash_read) {
-+ 			case SPI_NOR_QUAD:
-+@@ -1088,14 +1289,14 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 			nor->erase_opcode = SPINOR_OP_SE_4B;
-+ 			mtd->erasesize = info->sector_size;
-+ 		} else
-+-			set_4byte(nor, info->jedec_id, 1);
-++			set_4byte(nor, info, 1);
-+ 	} else {
-+ 		nor->addr_width = 3;
-+ 	}
-+ 
-+ 	nor->read_dummy = spi_nor_read_dummy_cycles(nor);
-+ 
-+-	dev_info(dev, "%s (%lld Kbytes)\n", id->name,
-++	dev_info(dev, "%s (%lld Kbytes)\n", info->name,
-+ 			(long long)mtd->size >> 10);
-+ 
-+ 	dev_dbg(dev,
-+@@ -1118,11 +1319,11 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ }
-+ EXPORT_SYMBOL_GPL(spi_nor_scan);
-+ 
-+-static const struct spi_device_id *spi_nor_match_id(const char *name)
-++static const struct flash_info *spi_nor_match_id(const char *name)
-+ {
-+-	const struct spi_device_id *id = spi_nor_ids;
-++	const struct flash_info *id = spi_nor_ids;
-+ 
-+-	while (id->name[0]) {
-++	while (id->name) {
-+ 		if (!strcmp(name, id->name))
-+ 			return id;
-+ 		id++;
-+--- a/include/linux/mtd/spi-nor.h
-++++ b/include/linux/mtd/spi-nor.h
-+@@ -10,6 +10,23 @@
-+ #ifndef __LINUX_MTD_SPI_NOR_H
-+ #define __LINUX_MTD_SPI_NOR_H
-+ 
-++#include <linux/bitops.h>
-++#include <linux/mtd/cfi.h>
-++
-++/*
-++ * Manufacturer IDs
-++ *
-++ * The first byte returned from the flash after sending opcode SPINOR_OP_RDID.
-++ * Sometimes these are the same as CFI IDs, but sometimes they aren't.
-++ */
-++#define SNOR_MFR_ATMEL		CFI_MFR_ATMEL
-++#define SNOR_MFR_INTEL		CFI_MFR_INTEL
-++#define SNOR_MFR_MICRON		CFI_MFR_ST /* ST Micro <--> Micron */
-++#define SNOR_MFR_MACRONIX	CFI_MFR_MACRONIX
-++#define SNOR_MFR_SPANSION	CFI_MFR_AMD
-++#define SNOR_MFR_SST		CFI_MFR_SST
-++#define SNOR_MFR_WINBOND	0xef /* Also used by some Spansion */
-++
-+ /*
-+  * Note on opcode nomenclature: some opcodes have a format like
-+  * SPINOR_OP_FUNCTION{4,}_x_y_z. The numbers x, y, and z stand for the number
-+@@ -56,22 +73,29 @@
-+ /* Used for Spansion flashes only. */
-+ #define SPINOR_OP_BRWR		0x17	/* Bank register write */
-+ 
-++/* Used for Micron flashes only. */
-++#define SPINOR_OP_RD_EVCR      0x65    /* Read EVCR register */
-++#define SPINOR_OP_WD_EVCR      0x61    /* Write EVCR register */
-++
-+ /* Status Register bits. */
-+-#define SR_WIP			1	/* Write in progress */
-+-#define SR_WEL			2	/* Write enable latch */
-++#define SR_WIP			BIT(0)	/* Write in progress */
-++#define SR_WEL			BIT(1)	/* Write enable latch */
-+ /* meaning of other SR_* bits may differ between vendors */
-+-#define SR_BP0			4	/* Block protect 0 */
-+-#define SR_BP1			8	/* Block protect 1 */
-+-#define SR_BP2			0x10	/* Block protect 2 */
-+-#define SR_SRWD			0x80	/* SR write protect */
-++#define SR_BP0			BIT(2)	/* Block protect 0 */
-++#define SR_BP1			BIT(3)	/* Block protect 1 */
-++#define SR_BP2			BIT(4)	/* Block protect 2 */
-++#define SR_SRWD			BIT(7)	/* SR write protect */
-++
-++#define SR_QUAD_EN_MX		BIT(6)	/* Macronix Quad I/O */
-+ 
-+-#define SR_QUAD_EN_MX		0x40	/* Macronix Quad I/O */
-++/* Enhanced Volatile Configuration Register bits */
-++#define EVCR_QUAD_EN_MICRON	BIT(7)	/* Micron Quad I/O */
-+ 
-+ /* Flag Status Register bits */
-+-#define FSR_READY		0x80
-++#define FSR_READY		BIT(7)
-+ 
-+ /* Configuration Register bits. */
-+-#define CR_QUAD_EN_SPAN		0x2	/* Spansion Quad I/O */
-++#define CR_QUAD_EN_SPAN		BIT(1)	/* Spansion Quad I/O */
-+ 
-+ enum read_mode {
-+ 	SPI_NOR_NORMAL = 0,
-+@@ -80,33 +104,6 @@ enum read_mode {
-+ 	SPI_NOR_QUAD,
-+ };
-+ 
-+-/**
-+- * struct spi_nor_xfer_cfg - Structure for defining a Serial Flash transfer
-+- * @wren:		command for "Write Enable", or 0x00 for not required
-+- * @cmd:		command for operation
-+- * @cmd_pins:		number of pins to send @cmd (1, 2, 4)
-+- * @addr:		address for operation
-+- * @addr_pins:		number of pins to send @addr (1, 2, 4)
-+- * @addr_width:		number of address bytes
-+- *			(3,4, or 0 for address not required)
-+- * @mode:		mode data
-+- * @mode_pins:		number of pins to send @mode (1, 2, 4)
-+- * @mode_cycles:	number of mode cycles (0 for mode not required)
-+- * @dummy_cycles:	number of dummy cycles (0 for dummy not required)
-+- */
-+-struct spi_nor_xfer_cfg {
-+-	u8		wren;
-+-	u8		cmd;
-+-	u8		cmd_pins;
-+-	u32		addr;
-+-	u8		addr_pins;
-+-	u8		addr_width;
-+-	u8		mode;
-+-	u8		mode_pins;
-+-	u8		mode_cycles;
-+-	u8		dummy_cycles;
-+-};
-+-
-+ #define SPI_NOR_MAX_CMD_SIZE	8
-+ enum spi_nor_ops {
-+ 	SPI_NOR_OPS_READ = 0,
-+@@ -116,11 +113,18 @@ enum spi_nor_ops {
-+ 	SPI_NOR_OPS_UNLOCK,
-+ };
-+ 
-++enum spi_nor_option_flags {
-++	SNOR_F_USE_FSR		= BIT(0),
-++};
-++
-++struct mtd_info;
-++
-+ /**
-+  * struct spi_nor - Structure for defining a the SPI NOR layer
-+  * @mtd:		point to a mtd_info structure
-+  * @lock:		the lock for the read/write/erase/lock/unlock operations
-+  * @dev:		point to a spi device, or a spi nor controller device.
-++ * @flash_node:		point to a device node describing this flash instance.
-+  * @page_size:		the page size of the SPI NOR
-+  * @addr_width:		number of address bytes
-+  * @erase_opcode:	the opcode for erasing a sector
-+@@ -129,29 +133,29 @@ enum spi_nor_ops {
-+  * @program_opcode:	the program opcode
-+  * @flash_read:		the mode of the read
-+  * @sst_write_second:	used by the SST write operation
-+- * @cfg:		used by the read_xfer/write_xfer
-++ * @flags:		flag options for the current SPI-NOR (SNOR_F_*)
-+  * @cmd_buf:		used by the write_reg
-+  * @prepare:		[OPTIONAL] do some preparations for the
-+  *			read/write/erase/lock/unlock operations
-+  * @unprepare:		[OPTIONAL] do some post work after the
-+  *			read/write/erase/lock/unlock operations
-+- * @read_xfer:		[OPTIONAL] the read fundamental primitive
-+- * @write_xfer:		[OPTIONAL] the writefundamental primitive
-+  * @read_reg:		[DRIVER-SPECIFIC] read out the register
-+  * @write_reg:		[DRIVER-SPECIFIC] write data to the register
-+- * @read_id:		[REPLACEABLE] read out the ID data, and find
-+- *			the proper spi_device_id
-+- * @wait_till_ready:	[REPLACEABLE] wait till the NOR becomes ready
-+  * @read:		[DRIVER-SPECIFIC] read data from the SPI NOR
-+  * @write:		[DRIVER-SPECIFIC] write data to the SPI NOR
-+  * @erase:		[DRIVER-SPECIFIC] erase a sector of the SPI NOR
-+  *			at the offset @offs
-++ * @flash_lock:		[FLASH-SPECIFIC] lock a region of the SPI NOR
-++ * @flash_unlock:	[FLASH-SPECIFIC] unlock a region of the SPI NOR
-++ * @flash_is_locked:	[FLASH-SPECIFIC] check if a region of the SPI NOR is
-++ *			completely locked
-+  * @priv:		the private data
-+  */
-+ struct spi_nor {
-+-	struct mtd_info		*mtd;
-++	struct mtd_info		mtd;
-+ 	struct mutex		lock;
-+ 	struct device		*dev;
-++	struct device_node	*flash_node;
-+ 	u32			page_size;
-+ 	u8			addr_width;
-+ 	u8			erase_opcode;
-+@@ -160,20 +164,13 @@ struct spi_nor {
-+ 	u8			program_opcode;
-+ 	enum read_mode		flash_read;
-+ 	bool			sst_write_second;
-+-	struct spi_nor_xfer_cfg	cfg;
-++	u32			flags;
-+ 	u8			cmd_buf[SPI_NOR_MAX_CMD_SIZE];
-+ 
-+ 	int (*prepare)(struct spi_nor *nor, enum spi_nor_ops ops);
-+ 	void (*unprepare)(struct spi_nor *nor, enum spi_nor_ops ops);
-+-	int (*read_xfer)(struct spi_nor *nor, struct spi_nor_xfer_cfg *cfg,
-+-			 u8 *buf, size_t len);
-+-	int (*write_xfer)(struct spi_nor *nor, struct spi_nor_xfer_cfg *cfg,
-+-			  u8 *buf, size_t len);
-+ 	int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
-+-	int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len,
-+-			int write_enable);
-+-	const struct spi_device_id *(*read_id)(struct spi_nor *nor);
-+-	int (*wait_till_ready)(struct spi_nor *nor);
-++	int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
-+ 
-+ 	int (*read)(struct spi_nor *nor, loff_t from,
-+ 			size_t len, size_t *retlen, u_char *read_buf);
-+@@ -181,6 +178,10 @@ struct spi_nor {
-+ 			size_t len, size_t *retlen, const u_char *write_buf);
-+ 	int (*erase)(struct spi_nor *nor, loff_t offs);
-+ 
-++	int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
-++	int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
-++	int (*flash_is_locked)(struct spi_nor *nor, loff_t ofs, uint64_t len);
-++
-+ 	void *priv;
-+ };
-+ 
-diff --git a/target/linux/generic/patches-3.18/462-m25p80-mx-disable-software-protection.patch b/target/linux/generic/patches-3.18/462-m25p80-mx-disable-software-protection.patch
-index fef483a67d0f7c3f25a105f5f1d0faef4dfd1a38..eb99609fe29b136a2283ef347af6b1db97ad4978 100644
---- a/target/linux/generic/patches-3.18/462-m25p80-mx-disable-software-protection.patch
-+++ b/target/linux/generic/patches-3.18/462-m25p80-mx-disable-software-protection.patch
-@@ -1,10 +1,14 @@
-+Disable software protection bits for Macronix flashes.
-+
-+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-+
- --- a/drivers/mtd/spi-nor/spi-nor.c
- +++ b/drivers/mtd/spi-nor/spi-nor.c
--@@ -963,6 +963,7 @@ int spi_nor_scan(struct spi_nor *nor, co
-+@@ -1164,6 +1164,7 @@ int spi_nor_scan(struct spi_nor *nor, co
-  
-- 	if (JEDEC_MFR(info->jedec_id) == CFI_MFR_ATMEL ||
-- 	    JEDEC_MFR(info->jedec_id) == CFI_MFR_INTEL ||
--+	    JEDEC_MFR(info->jedec_id) == CFI_MFR_MACRONIX ||
-- 	    JEDEC_MFR(info->jedec_id) == CFI_MFR_SST) {
-+ 	if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
-+ 	    JEDEC_MFR(info) == SNOR_MFR_INTEL ||
-++	    JEDEC_MFR(info) == SNOR_MFR_MACRONIX ||
-+ 	    JEDEC_MFR(info) == SNOR_MFR_SST) {
-  		write_enable(nor);
-  		write_sr(nor, 0);
-diff --git a/target/linux/generic/patches-3.18/472-mtd-m25p80-add-support-for-Winbond-W25X05-flash.patch b/target/linux/generic/patches-3.18/472-mtd-m25p80-add-support-for-Winbond-W25X05-flash.patch
-deleted file mode 100644
-index dca6895c1448a302f829bcfdde4842f0a000061d..0000000000000000000000000000000000000000
---- a/target/linux/generic/patches-3.18/472-mtd-m25p80-add-support-for-Winbond-W25X05-flash.patch
-+++ /dev/null
-@@ -1,20 +0,0 @@
--From eef9dfc4e821408af1af13aa0cc707fc496fb7c6 Mon Sep 17 00:00:00 2001
--From: Gabor Juhos <juhosg@openwrt.org>
--Date: Wed, 11 Dec 2013 19:05:59 +0100
--Subject: [PATCH] m25p80: add support for the Winbond W25X05 flash
--
--Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
-----
-- drivers/mtd/devices/m25p80.c |    1 +
-- 1 file changed, 1 insertion(+)
--
----- a/drivers/mtd/spi-nor/spi-nor.c
--+++ b/drivers/mtd/spi-nor/spi-nor.c
--@@ -617,6 +617,7 @@ static const struct spi_device_id spi_no
-- 	{ "m25px80",    INFO(0x207114,  0, 64 * 1024, 16, 0) },
-- 
-- 	/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
--+	{ "w25x05", INFO(0xef3010, 0, 64 * 1024,  1,  SECT_4K) },
-- 	{ "w25x10", INFO(0xef3011, 0, 64 * 1024,  2,  SECT_4K) },
-- 	{ "w25x20", INFO(0xef3012, 0, 64 * 1024,  4,  SECT_4K) },
-- 	{ "w25x40", INFO(0xef3013, 0, 64 * 1024,  8,  SECT_4K) },
-diff --git a/target/linux/generic/patches-3.18/473-mtd-spi-nor-add-support-for-the-Macronix-MX25L512E-S.patch b/target/linux/generic/patches-3.18/473-mtd-spi-nor-add-support-for-the-Macronix-MX25L512E-S.patch
-deleted file mode 100644
-index 9ba7a4ab2f701440e78da0f9a2e2845f68652267..0000000000000000000000000000000000000000
---- a/target/linux/generic/patches-3.18/473-mtd-spi-nor-add-support-for-the-Macronix-MX25L512E-S.patch
-+++ /dev/null
-@@ -1,21 +0,0 @@
--From 0d7388de0911c1a4fc4a8a3898ef9d0ab818ca08 Mon Sep 17 00:00:00 2001
--From: Gabor Juhos <juhosg@openwrt.org>
--Date: Tue, 7 Apr 2015 18:35:15 +0200
--Subject: [PATCH] mtd: spi-nor: add support for the Macronix MX25L512E SPI
-- flash chip
--
--Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
-----
-- drivers/mtd/spi-nor/spi-nor.c |    1 +
-- 1 file changed, 1 insertion(+)
--
----- a/drivers/mtd/spi-nor/spi-nor.c
--+++ b/drivers/mtd/spi-nor/spi-nor.c
--@@ -518,6 +518,7 @@ static const struct spi_device_id spi_no
-- 	{ "640s33b",  INFO(0x898913, 0, 64 * 1024, 128, 0) },
-- 
-- 	/* Macronix */
--+	{ "mx25l512e",   INFO(0xc22010, 0, 64 * 1024,   1, SECT_4K) },
-- 	{ "mx25l2005a",  INFO(0xc22012, 0, 64 * 1024,   4, SECT_4K) },
-- 	{ "mx25l4005a",  INFO(0xc22013, 0, 64 * 1024,   8, SECT_4K) },
-- 	{ "mx25l8005",   INFO(0xc22014, 0, 64 * 1024,  16, 0) },
-diff --git a/target/linux/generic/patches-3.18/474-mtd-spi-nor-add-support-for-the-ISSI-SI25CD512-SPI-f.patch b/target/linux/generic/patches-3.18/474-mtd-spi-nor-add-support-for-the-ISSI-SI25CD512-SPI-f.patch
-deleted file mode 100644
-index b06ac73fae3fac808067b8643ac939adc56d35cb..0000000000000000000000000000000000000000
---- a/target/linux/generic/patches-3.18/474-mtd-spi-nor-add-support-for-the-ISSI-SI25CD512-SPI-f.patch
-+++ /dev/null
-@@ -1,22 +0,0 @@
--From 34e2b403040a2f9d3ba071d95a7f42457e2950f9 Mon Sep 17 00:00:00 2001
--From: Gabor Juhos <juhosg@openwrt.org>
--Date: Tue, 7 Apr 2015 18:35:15 +0200
--Subject: [PATCH] mtd: spi-nor: add support for the ISSI SI25CD512 SPI flash
--
--Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
-----
-- drivers/mtd/spi-nor/spi-nor.c |    3 +++
-- 1 file changed, 3 insertions(+)
--
----- a/drivers/mtd/spi-nor/spi-nor.c
--+++ b/drivers/mtd/spi-nor/spi-nor.c
--@@ -517,6 +517,9 @@ static const struct spi_device_id spi_no
-- 	{ "320s33b",  INFO(0x898912, 0, 64 * 1024,  64, 0) },
-- 	{ "640s33b",  INFO(0x898913, 0, 64 * 1024, 128, 0) },
-- 
--+	/* ISSI */
--+	{ "is25cd512", INFO(0x7f9d20, 0, 32 * 1024,   2, SECT_4K) },
--+
-- 	/* Macronix */
-- 	{ "mx25l512e",   INFO(0xc22010, 0, 64 * 1024,   1, SECT_4K) },
-- 	{ "mx25l2005a",  INFO(0xc22012, 0, 64 * 1024,   4, SECT_4K) },
-diff --git a/target/linux/lantiq/patches-3.18/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch b/target/linux/lantiq/patches-3.18/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
-deleted file mode 100644
-index 203eb9495efe583abc1e7adc21f9c6d0e61e4e29..0000000000000000000000000000000000000000
---- a/target/linux/lantiq/patches-3.18/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
-+++ /dev/null
-@@ -1,44 +0,0 @@
--From 4400e1f593ea40a51912128adb4f53d59e62cad8 Mon Sep 17 00:00:00 2001
--From: John Crispin <blogic@openwrt.org>
--Date: Wed, 10 Sep 2014 22:40:18 +0200
--Subject: [PATCH 22/36] MTD: m25p80: allow loading mtd name from OF
--
--In accordance with the physmap flash we should honour the linux,mtd-name
--property when deciding what name the mtd device has.
--
--Signed-off-by: Thomas Langer <thomas.langer@lantiq.com>
--Signed-off-by: John Crispin <blogic@openwrt.org>
-----
-- drivers/mtd/devices/m25p80.c |    6 ++++++
-- 1 file changed, 6 insertions(+)
--
----- a/drivers/mtd/devices/m25p80.c
--+++ b/drivers/mtd/devices/m25p80.c
--@@ -19,6 +19,7 @@
-- #include <linux/errno.h>
-- #include <linux/module.h>
-- #include <linux/device.h>
--+#include <linux/of.h>
-- 
-- #include <linux/mtd/mtd.h>
-- #include <linux/mtd/partitions.h>
--@@ -198,6 +199,10 @@ static int m25p_probe(struct spi_device
-- 	enum read_mode mode = SPI_NOR_NORMAL;
-- 	char *flash_name = NULL;
-- 	int ret;
--+	const char __maybe_unused	*of_mtd_name = NULL;
--+
--+	of_property_read_string(spi->dev.of_node,
--+		"linux,mtd-name", &of_mtd_name);
-- 
-- 	data = dev_get_platdata(&spi->dev);
-- 
--@@ -229,6 +234,8 @@ static int m25p_probe(struct spi_device
-- 
-- 	if (data && data->name)
-- 		flash->mtd.name = data->name;
--+	else if (of_mtd_name)
--+		flash->mtd.name = of_mtd_name;
-- 
-- 	/* For some (historical?) reason many platforms provide two different
-- 	 * names in flash_platform_data: "name" and "type". Quite often name is
-diff --git a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts
-index 2beb39cf1f2b22d99207b2298bd550a71c8d7666..21f823d57ca1b7b072e060dd0460ffd4b251ec77 100644
---- a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts
-+++ b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts
-@@ -37,7 +37,7 @@
- 			flash@0 {
- 				#address-cells = <1>;
- 				#size-cells = <1>;
--				compatible = "spansion,s25fl129p1";
-+				compatible = "jedec,spi-nor";
- 				reg = <0>;
- 				spi-max-frequency = <25000000>;
- 
-diff --git a/target/linux/ramips/patches-3.18/0044-mtd-add-chunked-read-io-to-m25p80.patch b/target/linux/ramips/patches-3.18/0044-mtd-add-chunked-read-io-to-m25p80.patch
-index 1716e1cc499ede404c509a40370ff6fdeec0f1dc..8dc181afb84e4932b73b4a7a45daadb0da78ca20 100644
---- a/target/linux/ramips/patches-3.18/0044-mtd-add-chunked-read-io-to-m25p80.patch
-+++ b/target/linux/ramips/patches-3.18/0044-mtd-add-chunked-read-io-to-m25p80.patch
-@@ -1,33 +1,18 @@
----- a/drivers/mtd/devices/m25p80.c
--+++ b/drivers/mtd/devices/m25p80.c
--@@ -19,6 +19,7 @@
-- #include <linux/errno.h>
-- #include <linux/module.h>
-- #include <linux/device.h>
--+#include <linux/of.h>
-- 
-- #include <linux/mtd/mtd.h>
-- #include <linux/mtd/partitions.h>
--@@ -32,6 +33,7 @@ struct m25p {
-- 	struct spi_device	*spi;
-- 	struct spi_nor		spi_nor;
-- 	struct mtd_info		mtd;
--+	u16			chunk_size;
-- 	u8			command[MAX_CMD_SIZE];
-- };
-- 
--@@ -157,6 +159,61 @@ static int m25p80_read(struct spi_nor *n
-- 	return 0;
-+--- a/drivers/mtd/spi-nor/spi-nor.c
-++++ b/drivers/mtd/spi-nor/spi-nor.c
-+@@ -1016,6 +1016,66 @@ write_err:
-+ 	return ret;
-  }
-  
--+static void m25p80_chunked_write(struct spi_nor *nor, loff_t _from, size_t _len,
--+			size_t *_retlen, const u_char *_buf)
-++static int spi_nor_chunked_write(struct mtd_info *mtd, loff_t _to, size_t _len,
-++				 size_t *_retlen, const u_char *_buf)
- +{
--+	struct m25p *flash = nor->priv;
-++	struct spi_nor *nor = mtd_to_spi_nor(mtd);
- +	int chunk_size;
- +	int retlen = 0;
-++	int ret;
- +
--+	chunk_size = flash->chunk_size;
-++	chunk_size = nor->chunk_size;
- +	if (!chunk_size)
- +		chunk_size = _len;
- +
-@@ -37,35 +22,39 @@
- +	while (retlen < _len) {
- +		size_t len = min_t(int, chunk_size, _len - retlen);
- +		const u_char *buf = _buf + retlen;
--+		loff_t from = _from + retlen;
--+
--+		nor->wait_till_ready(nor);
--+		nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0, 0);
-++		loff_t to = _to + retlen;
- +
--+		m25p80_write(nor, from, len, &retlen, buf);
-++		if (nor->flags & SNOR_F_SST)
-++			ret = sst_write(mtd, to, len, &retlen, buf);
-++		else
-++			ret = spi_nor_write(mtd, to, len, &retlen, buf);
-++		if (ret)
-++			return ret;
- +	}
-++
- +	*_retlen += retlen;
-++	return 0;
- +}
- +
--+static int m25p80_chunked_read(struct spi_nor *nor, loff_t _from, size_t _len,
--+			size_t *_retlen, u_char *_buf)
-++static int spi_nor_chunked_read(struct mtd_info *mtd, loff_t _from, size_t _len,
-++				size_t *_retlen, u_char *_buf)
- +{
--+	struct m25p *flash = nor->priv;
-++	struct spi_nor *nor = mtd_to_spi_nor(mtd);
- +	int chunk_size;
-++	int ret;
- +
--+	chunk_size = flash->chunk_size;
-++	chunk_size = nor->chunk_size;
- +	if (!chunk_size)
- +		chunk_size = _len;
- +
- +	*_retlen = 0;
--+
- +	while (*_retlen < _len) {
- +		size_t len = min_t(int, chunk_size, _len - *_retlen);
- +		u_char *buf = _buf + *_retlen;
- +		loff_t from = _from + *_retlen;
- +		int retlen = 0;
--+		int ret = m25p80_read(nor, from, len, &retlen, buf);
- +
-++		ret = spi_nor_read(mtd, from, len, &retlen, buf);
- +		if (ret)
- +			return ret;
- +
-@@ -75,29 +64,60 @@
- +	return 0;
- +}
- +
-- static int m25p80_erase(struct spi_nor *nor, loff_t offset)
-+ static int macronix_quad_enable(struct spi_nor *nor)
-  {
-- 	struct m25p *flash = nor->priv;
--@@ -197,6 +254,7 @@ static int m25p_probe(struct spi_device
-- 	struct spi_nor *nor;
-- 	enum read_mode mode = SPI_NOR_NORMAL;
-- 	char *flash_name = NULL;
--+	u32 val;
-- 	int ret;
-- 
-- 	data = dev_get_platdata(&spi->dev);
--@@ -244,6 +302,14 @@ static int m25p_probe(struct spi_device
-- 	if (ret)
-- 		return ret;
-+ 	int ret, val;
-+@@ -1197,10 +1257,12 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	}
-  
--+	if (spi->dev.of_node &&
--+	    !of_property_read_u32(spi->dev.of_node, "m25p,chunked-io", &val)) {
--+		dev_warn(&spi->dev, "using chunked io\n");
--+		nor->read = m25p80_chunked_read;
--+		nor->write = m25p80_chunked_write;
--+		flash->chunk_size = val;
-+ 	/* sst nor chips use AAI word program */
-+-	if (info->flags & SST_WRITE)
-++	if (info->flags & SST_WRITE) {
-+ 		mtd->_write = sst_write;
-+-	else
-++		nor->flags |= SNOR_F_SST;
-++	} else {
-+ 		mtd->_write = spi_nor_write;
- +	}
-+ 
-+ 	if (info->flags & USE_FSR)
-+ 		nor->flags |= SNOR_F_USE_FSR;
-+@@ -1228,11 +1290,20 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	mtd->writebufsize = nor->page_size;
-+ 
-+ 	if (np) {
-++		u32 val;
- +
-- 	ppdata.of_node = spi->dev.of_node;
-+ 		/* If we were instantiated by DT, use it */
-+ 		if (of_property_read_bool(np, "m25p,fast-read"))
-+ 			nor->flash_read = SPI_NOR_FAST;
-+ 		else
-+ 			nor->flash_read = SPI_NOR_NORMAL;
-++
-++		if (!of_property_read_u32(np, "m25p,chunked-io", &val)) {
-++			dev_info(dev, "using chunked io (size=%d)\n", val);
-++			mtd->_read = spi_nor_chunked_read;
-++			mtd->_write = spi_nor_chunked_write;
-++			nor->chunk_size = val;
-++		}
-+ 	} else {
-+ 		/* If we weren't instantiated by DT, default to fast-read */
-+ 		nor->flash_read = SPI_NOR_FAST;
-+--- a/include/linux/mtd/spi-nor.h
-++++ b/include/linux/mtd/spi-nor.h
-+@@ -115,6 +115,7 @@ enum spi_nor_ops {
-+ 
-+ enum spi_nor_option_flags {
-+ 	SNOR_F_USE_FSR		= BIT(0),
-++	SNOR_F_SST		= BIT(1),
-+ };
-  
-- 	return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
-+ struct mtd_info;
-+@@ -157,6 +158,7 @@ struct spi_nor {
-+ 	struct device		*dev;
-+ 	struct device_node	*flash_node;
-+ 	u32			page_size;
-++	u16			chunk_size;
-+ 	u8			addr_width;
-+ 	u8			erase_opcode;
-+ 	u8			read_opcode;

+ 0 - 115
patches/openwrt/0030-kernel-mtd-spi-nor-wait-until-status-register-writes-are-ready.patch

@@ -1,115 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sat, 7 May 2016 00:17:55 +0200
-Subject: kernel: mtd: spi-nor: wait until status register writes are ready
-
-diff --git a/target/linux/generic/patches-3.18/094-0001-mtd-spi-nor-wait-until-lock-unlock-operations-are-re.patch b/target/linux/generic/patches-3.18/094-0001-mtd-spi-nor-wait-until-lock-unlock-operations-are-re.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..2c2e5f32259416f0cc7f342e420ffbd32c139d97
---- /dev/null
-+++ b/target/linux/generic/patches-3.18/094-0001-mtd-spi-nor-wait-until-lock-unlock-operations-are-re.patch
-@@ -0,0 +1,66 @@
-+From 32321e950d8a237d7e8f3a9b76220007dfa87544 Mon Sep 17 00:00:00 2001
-+Message-Id: <32321e950d8a237d7e8f3a9b76220007dfa87544.1462572686.git.mschiffer@universe-factory.net>
-+From: =?UTF-8?q?Ezequiel=20Garc=C3=ADa?= <ezequiel@vanguardiasur.com.ar>
-+Date: Mon, 28 Dec 2015 17:54:51 -0300
-+Subject: [PATCH] mtd: spi-nor: wait until lock/unlock operations are ready
-+
-+On Micron and Numonyx devices, the status register write command
-+(WRSR), raises a work-in-progress bit (WIP) on the status register.
-+The datasheets for these devices specify that while the status
-+register write is in progress, the status register WIP bit can still
-+be read to check the end of the operation.
-+
-+This commit adds a wait_till_ready call on lock/unlock operations,
-+which is required for Micron and Numonyx but should be harmless for
-+others. This is needed to prevent applications from issuing erase or
-+program operations before the unlock operation is completed.
-+
-+Reported-by: Stas Sergeev <stsp@list.ru>
-+Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
-+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-+---
-+ drivers/mtd/spi-nor/spi-nor.c | 12 ++++++++++--
-+ 1 file changed, 10 insertions(+), 2 deletions(-)
-+
-+--- a/drivers/mtd/spi-nor/spi-nor.c
-++++ b/drivers/mtd/spi-nor/spi-nor.c
-+@@ -462,6 +462,7 @@ static int stm_lock(struct spi_nor *nor,
-+ 	u8 status_old, status_new;
-+ 	u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
-+ 	u8 shift = ffs(mask) - 1, pow, val;
-++	int ret;
-+ 
-+ 	status_old = read_sr(nor);
-+ 
-+@@ -498,7 +499,10 @@ static int stm_lock(struct spi_nor *nor,
-+ 		return -EINVAL;
-+ 
-+ 	write_enable(nor);
-+-	return write_sr(nor, status_new);
-++	ret = write_sr(nor, status_new);
-++	if (ret)
-++		return ret;
-++	return spi_nor_wait_till_ready(nor);
-+ }
-+ 
-+ /*
-+@@ -512,6 +516,7 @@ static int stm_unlock(struct spi_nor *no
-+ 	uint8_t status_old, status_new;
-+ 	u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
-+ 	u8 shift = ffs(mask) - 1, pow, val;
-++	int ret;
-+ 
-+ 	status_old = read_sr(nor);
-+ 
-+@@ -546,7 +551,10 @@ static int stm_unlock(struct spi_nor *no
-+ 		return -EINVAL;
-+ 
-+ 	write_enable(nor);
-+-	return write_sr(nor, status_new);
-++	ret = write_sr(nor, status_new);
-++	if (ret)
-++		return ret;
-++	return spi_nor_wait_till_ready(nor);
-+ }
-+ 
-+ /*
-diff --git a/target/linux/generic/patches-3.18/094-0002-mtd-spi-nor-wait-for-SR_WIP-to-clear-on-initial-unlo.patch b/target/linux/generic/patches-3.18/094-0002-mtd-spi-nor-wait-for-SR_WIP-to-clear-on-initial-unlo.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..a0573d5aea939c965cb44b2e72a2b7d498b0a5cd
---- /dev/null
-+++ b/target/linux/generic/patches-3.18/094-0002-mtd-spi-nor-wait-for-SR_WIP-to-clear-on-initial-unlo.patch
-@@ -0,0 +1,33 @@
-+From edf891ef9ab773363f8e58022a26d7d31604aed6 Mon Sep 17 00:00:00 2001
-+Message-Id: <edf891ef9ab773363f8e58022a26d7d31604aed6.1462572703.git.mschiffer@universe-factory.net>
-+From: Brian Norris <computersforpeace@gmail.com>
-+Date: Fri, 29 Jan 2016 11:25:30 -0800
-+Subject: [PATCH] mtd: spi-nor: wait for SR_WIP to clear on initial unlock
-+
-+Fixup a piece leftover by commit 32321e950d8a ("mtd: spi-nor: wait until
-+lock/unlock operations are ready"). That commit made us wait for the WIP
-+bit to settle after lock/unlock operations, but it missed the open-coded
-+"unlock" that happens at probe() time.
-+
-+We should probably have this code utilize the unlock() routines in the
-+future, to avoid duplication, but unfortunately, flash which need to be
-+unlocked don't all have a proper ->flash_unlock() callback.
-+
-+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-+Cc: Stas Sergeev <stsp@users.sourceforge.net>
-+Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
-+Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
-+---
-+ drivers/mtd/spi-nor/spi-nor.c | 1 +
-+ 1 file changed, 1 insertion(+)
-+
-+--- a/drivers/mtd/spi-nor/spi-nor.c
-++++ b/drivers/mtd/spi-nor/spi-nor.c
-+@@ -1167,6 +1167,7 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	    JEDEC_MFR(info) == SNOR_MFR_SST) {
-+ 		write_enable(nor);
-+ 		write_sr(nor, 0);
-++		spi_nor_wait_till_ready(nor);
-+ 	}
-+ 
-+ 	if (!mtd->name)

+ 0 - 56
patches/openwrt/0031-kernel-mtd-spi-nor-unlock-Winbond-flashs.patch

@@ -1,56 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sat, 7 May 2016 00:29:06 +0200
-Subject: kernel: mtd: spi-nor: unlock Winbond flashs
-
-diff --git a/target/linux/generic/patches-3.18/463-Revert-mtd-spi-nor-fix-Spansion-regressions-aliased-.patch b/target/linux/generic/patches-3.18/463-Revert-mtd-spi-nor-fix-Spansion-regressions-aliased-.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..4682b7a77b160a0814012d26f0edf1a7bfaf5312
---- /dev/null
-+++ b/target/linux/generic/patches-3.18/463-Revert-mtd-spi-nor-fix-Spansion-regressions-aliased-.patch
-@@ -0,0 +1,46 @@
-+From 20bbd73b6b04677a73933830363ab3178adc2ce9 Mon Sep 17 00:00:00 2001
-+Message-Id: <20bbd73b6b04677a73933830363ab3178adc2ce9.1462573588.git.mschiffer@universe-factory.net>
-+From: Matthias Schiffer <mschiffer@universe-factory.net>
-+Date: Sat, 7 May 2016 00:26:23 +0200
-+Subject: [PATCH] Revert "mtd: spi-nor: fix Spansion regressions (aliased with
-+ Winbond)"
-+
-+This reverts commit 67b9bcd36906e12a15ffec19463afbbd6a41660e.
-+---
-+ drivers/mtd/spi-nor/spi-nor.c | 6 ++++--
-+ include/linux/mtd/spi-nor.h   | 2 +-
-+ 2 files changed, 5 insertions(+), 3 deletions(-)
-+
-+--- a/drivers/mtd/spi-nor/spi-nor.c
-++++ b/drivers/mtd/spi-nor/spi-nor.c
-+@@ -1165,7 +1165,8 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
-+ 	    JEDEC_MFR(info) == SNOR_MFR_INTEL ||
-+ 	    JEDEC_MFR(info) == SNOR_MFR_MACRONIX ||
-+-	    JEDEC_MFR(info) == SNOR_MFR_SST) {
-++	    JEDEC_MFR(info) == SNOR_MFR_SST ||
-++	    JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
-+ 		write_enable(nor);
-+ 		write_sr(nor, 0);
-+ 		spi_nor_wait_till_ready(nor);
-+@@ -1182,7 +1183,8 @@ int spi_nor_scan(struct spi_nor *nor, co
-+ 	mtd->_read = spi_nor_read;
-+ 
-+ 	/* NOR protection support for STmicro/Micron chips and similar */
-+-	if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
-++	if (JEDEC_MFR(info) == SNOR_MFR_MICRON ||
-++	    JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
-+ 		nor->flash_lock = stm_lock;
-+ 		nor->flash_unlock = stm_unlock;
-+ 		nor->flash_is_locked = stm_is_locked;
-+--- a/include/linux/mtd/spi-nor.h
-++++ b/include/linux/mtd/spi-nor.h
-+@@ -25,7 +25,7 @@
-+ #define SNOR_MFR_MACRONIX	CFI_MFR_MACRONIX
-+ #define SNOR_MFR_SPANSION	CFI_MFR_AMD
-+ #define SNOR_MFR_SST		CFI_MFR_SST
-+-#define SNOR_MFR_WINBOND	0xef /* Also used by some Spansion */
-++#define SNOR_MFR_WINBOND	0xef
-+ 
-+ /*
-+  * Note on opcode nomenclature: some opcodes have a format like

+ 0 - 46
patches/openwrt/0032-ath79-dev-eth-fix-QCA9561-set-phy-interface-mode-and-mask.patch

@@ -1,46 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 20:59:44 +0200
-Subject: ath79: dev-eth: fix QCA9561 set phy interface mode and mask
-
-QCA9563 and QCA9561 are two series of Qualcomm SoC Dragonfly. The only different
-is QCA9563 w/o internal switch. It has one GMAC with SGMII interface. But they
-have the same device ID(0x1150). So they share the same codes.
-
-Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
-
-Backport of OpenWrt r46971
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-index ff94e2ec3733b9473c4c3191cb47bd4ba8ac784d..31d24388d274b92e01642ad6d7f59d22f80dc2a6 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-@@ -633,7 +633,6 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
- 		case ATH79_SOC_AR9330:
- 		case ATH79_SOC_AR9331:
- 		case ATH79_SOC_QCA9533:
--		case ATH79_SOC_QCA9561:
- 		case ATH79_SOC_TP9343:
- 			pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
- 			break;
-@@ -667,6 +666,11 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
- 			}
- 			break;
- 
-+		case ATH79_SOC_QCA9561:
-+			if (!pdata->phy_if_mode)
-+				pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
-+			break;
-+
- 		default:
- 			BUG();
- 		}
-@@ -1035,7 +1039,8 @@ void __init ath79_register_eth(unsigned int id)
- 					   AR933X_RESET_GE0_MDIO;
- 			pdata->set_speed = ath79_set_speed_dummy;
- 
--			pdata->phy_mask = BIT(4);
-+			if (!pdata->phy_mask)
-+				pdata->phy_mask = BIT(4);
- 		} else {
- 			pdata->reset_bit = AR933X_RESET_GE1_MAC |
- 					   AR933X_RESET_GE1_MDIO;

+ 0 - 33
patches/openwrt/0033-ar71xx-use-correct-PLL-configuration-register-bitmask-for-QCA956x-SoC.patch

@@ -1,33 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 22:58:50 +0200
-Subject: ar71xx: use correct PLL configuration register bitmask for QCA956x SoC.
-
-Incorrect value causes clock inaccuracy as huge as 1/60.
-
-Signed-off-by: Dmitry Ivanov <dima@ubnt.com>
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-
-Backport of OpenWrt r47363
-
-diff --git a/target/linux/ar71xx/patches-3.18/735-MIPS-ath79-add-support-for-QCA956x-SoC.patch b/target/linux/ar71xx/patches-3.18/735-MIPS-ath79-add-support-for-QCA956x-SoC.patch
-index 0da81426ca7b1b1db46e869745f0ed00496bef78..2bb4286e5d805ff3c47486a1f091d2b5e6d78373 100644
---- a/target/linux/ar71xx/patches-3.18/735-MIPS-ath79-add-support-for-QCA956x-SoC.patch
-+++ b/target/linux/ar71xx/patches-3.18/735-MIPS-ath79-add-support-for-QCA956x-SoC.patch
-@@ -529,7 +529,7 @@
- +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT		0
- +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK		0x1f
- +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT		5
--+#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK		0x3fff
-++#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK		0x1fff
- +#define QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT		18
- +#define QCA956X_PLL_CPU_CONFIG1_NINT_MASK		0x1ff
- +
-@@ -541,7 +541,7 @@
- +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT		0
- +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK		0x1f
- +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT		5
--+#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK		0x3fff
-++#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK		0x1fff
- +#define QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT		18
- +#define QCA956X_PLL_DDR_CONFIG1_NINT_MASK		0x1ff
- +

+ 0 - 415
patches/openwrt/0034-ar71xx-update-QCA956x-support.patch

@@ -1,415 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 22:18:40 +0200
-Subject: ar71xx: update QCA956x support
-
-- separate qca956x and tp9343 (they use different IDs)
-- rename qca9561->qca956x for consistency
-- add missing bits (device reset, gpio output select)
-- fix wmac setup
-
-Signed-off-by: Roman Yeryomin <roman@advem.lv>
-
-Backport of OpenWrt r47981
-
-diff --git a/target/linux/ar71xx/patches-3.18/735-MIPS-ath79-add-support-for-QCA956x-SoC.patch b/target/linux/ar71xx/patches-3.18/735-MIPS-ath79-add-support-for-QCA956x-SoC.patch
-index 2bb4286e5d805ff3c47486a1f091d2b5e6d78373..61b897690a03fd46d2ea95451a09598b272266f9 100644
---- a/target/linux/ar71xx/patches-3.18/735-MIPS-ath79-add-support-for-QCA956x-SoC.patch
-+++ b/target/linux/ar71xx/patches-3.18/735-MIPS-ath79-add-support-for-QCA956x-SoC.patch
-@@ -105,7 +105,7 @@
-  		qca953x_clocks_init();
-  	else if (soc_is_qca955x())
-  		qca955x_clocks_init();
--+	else if (soc_is_qca956x())
-++	else if (soc_is_qca956x() || soc_is_tp9343())
- +		qca956x_clocks_init();
-  	else
-  		BUG();
-@@ -116,7 +116,7 @@
-  		reg = QCA953X_RESET_REG_RESET_MODULE;
-  	else if (soc_is_qca955x())
-  		reg = QCA955X_RESET_REG_RESET_MODULE;
--+	else if (soc_is_qca956x())
-++	else if (soc_is_qca956x() || soc_is_tp9343())
- +		reg = QCA956X_RESET_REG_RESET_MODULE;
-  	else
-  		panic("Reset register not defined for this SOC");
-@@ -125,20 +125,30 @@
-  		reg = QCA953X_RESET_REG_RESET_MODULE;
-  	else if (soc_is_qca955x())
-  		reg = QCA955X_RESET_REG_RESET_MODULE;
--+	else if (soc_is_qca956x())
-++	else if (soc_is_qca956x() || soc_is_tp9343())
- +		reg = QCA956X_RESET_REG_RESET_MODULE;
-  	else
-  		panic("Reset register not defined for this SOC");
-  
-+@@ -133,6 +137,8 @@ u32 ath79_device_reset_get(u32 mask)
-+ 		reg = AR933X_RESET_REG_RESET_MODULE;
-+ 	else if (soc_is_ar934x())
-+ 		reg = AR934X_RESET_REG_RESET_MODULE;
-++	else if (soc_is_qca956x() || soc_is_tp9343())
-++		reg = QCA956X_RESET_REG_RESET_MODULE;
-+ 	else
-+ 		BUG();
-+ 
- --- a/arch/mips/ath79/dev-common.c
- +++ b/arch/mips/ath79/dev-common.c
--@@ -94,7 +94,8 @@ void __init ath79_register_uart(void)
-+@@ -94,7 +94,9 @@ void __init ath79_register_uart(void)
-  	    soc_is_ar913x() ||
-  	    soc_is_ar934x() ||
-  	    soc_is_qca953x() ||
- -	    soc_is_qca955x()) {
- +	    soc_is_qca955x() ||
--+	    soc_is_qca956x()) {
-++	    soc_is_qca956x() ||
-++	    soc_is_tp9343()) {
-  		ath79_uart_data[0].uartclk = uart_clk_rate;
-  		platform_device_register(&ath79_uart_device);
-  	} else if (soc_is_ar933x()) {
-@@ -168,14 +178,14 @@
-  		qca953x_usb_setup();
-  	else if (soc_is_qca955x())
-  		qca955x_usb_setup();
--+	else if (soc_is_qca9561())
-++	else if (soc_is_qca956x())
- +		qca956x_usb_setup();
-  	else
-  		BUG();
-  }
- --- a/arch/mips/ath79/dev-wmac.c
- +++ b/arch/mips/ath79/dev-wmac.c
--@@ -189,6 +189,24 @@ static void qca955x_wmac_setup(void)
-+@@ -189,6 +189,26 @@ static void qca955x_wmac_setup(void)
-  		ath79_wmac_data.is_clk_25mhz = true;
-  }
-  
-@@ -195,16 +205,18 @@
- +		ath79_wmac_data.is_clk_25mhz = false;
- +	else
- +		ath79_wmac_data.is_clk_25mhz = true;
-++
-++	ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
- +}
- +
-  static bool __init
-  ar93xx_wmac_otp_read_word(void __iomem *base, int addr, u32 *data)
-  {
--@@ -392,6 +410,8 @@ void __init ath79_register_wmac(u8 *cal_
-+@@ -392,6 +412,8 @@ void __init ath79_register_wmac(u8 *cal_
-  		qca953x_wmac_setup();
-  	else if (soc_is_qca955x())
-  		qca955x_wmac_setup();
--+	else if (soc_is_qca956x())
-++	else if (soc_is_qca956x() || soc_is_tp9343())
- +		qca956x_wmac_setup();
-  	else
-  		BUG();
-@@ -216,27 +228,38 @@
-  	case REV_ID_MAJOR_QCA9556:
-  	case REV_ID_MAJOR_QCA9558:
- +	case REV_ID_MAJOR_TP9343:
--+	case REV_ID_MAJOR_QCA9561:
-++	case REV_ID_MAJOR_QCA956X:
-  		_prom_putchar = prom_putchar_ar71xx;
-  		break;
-  
- --- a/arch/mips/ath79/gpio.c
- +++ b/arch/mips/ath79/gpio.c
--@@ -148,7 +148,8 @@ static void __iomem *ath79_gpio_get_func
-+@@ -148,7 +148,10 @@ static void __iomem *ath79_gpio_get_func
-  	    soc_is_ar913x() ||
-  	    soc_is_ar933x())
-  		reg = AR71XX_GPIO_REG_FUNC;
- -	else if (soc_is_ar934x() || soc_is_qca953x())
- +	else if (soc_is_ar934x() ||
--+		 soc_is_qca953x() || soc_is_qca956x())
-++		 soc_is_qca953x() ||
-++		 soc_is_qca956x() ||
-++		 soc_is_tp9343())
-  		reg = AR934X_GPIO_REG_FUNC;
-  	else
-  		BUG();
--@@ -228,12 +229,15 @@ void __init ath79_gpio_init(void)
-+@@ -187,7 +190,7 @@ void __init ath79_gpio_output_select(uns
-+ 	unsigned int reg;
-+ 	u32 t, s;
-+ 
-+-	BUG_ON(!soc_is_ar934x() && !soc_is_qca953x());
-++	BUG_ON(!soc_is_ar934x() && !soc_is_qca953x() && !soc_is_qca956x());
-+ 
-+ 	if (gpio >= AR934X_GPIO_COUNT)
-+ 		return;
-+@@ -228,12 +231,15 @@ void __init ath79_gpio_init(void)
-  		ath79_gpio_count = QCA953X_GPIO_COUNT;
-  	else if (soc_is_qca955x())
-  		ath79_gpio_count = QCA955X_GPIO_COUNT;
--+	else if (soc_is_qca956x())
-++	else if (soc_is_qca956x() || soc_is_tp9343())
- +		ath79_gpio_count = QCA956X_GPIO_COUNT;
-  	else
-  		BUG();
-@@ -245,23 +268,24 @@
-  	ath79_gpio_chip.ngpio = ath79_gpio_count;
- -	if (soc_is_ar934x() || soc_is_qca953x() || soc_is_qca955x()) {
- +	if (soc_is_ar934x() || soc_is_qca953x() || soc_is_qca955x() ||
--+	    soc_is_qca956x()) {
-++	    soc_is_qca956x() || soc_is_tp9343()) {
-  		ath79_gpio_chip.direction_input = ar934x_gpio_direction_input;
-  		ath79_gpio_chip.direction_output = ar934x_gpio_direction_output;
-  	}
- --- a/arch/mips/ath79/irq.c
- +++ b/arch/mips/ath79/irq.c
--@@ -107,7 +107,8 @@ static void __init ath79_misc_irq_init(v
-+@@ -107,7 +107,9 @@ static void __init ath79_misc_irq_init(v
-  		 soc_is_ar933x() ||
-  		 soc_is_ar934x() ||
-  		 soc_is_qca953x() ||
- -		 soc_is_qca955x())
- +		 soc_is_qca955x() ||
--+		 soc_is_qca956x())
-++		 soc_is_qca956x() ||
-++		 soc_is_tp9343())
-  		ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
-  	else
-  		BUG();
--@@ -268,6 +269,97 @@ static void qca955x_irq_init(void)
-+@@ -268,6 +270,97 @@ static void qca955x_irq_init(void)
-  	irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
-  }
-  
-@@ -359,21 +383,21 @@
-  asmlinkage void plat_irq_dispatch(void)
-  {
-  	unsigned long pending;
--@@ -397,6 +489,9 @@ void __init arch_init_irq(void)
-+@@ -397,6 +490,9 @@ void __init arch_init_irq(void)
-  	} else if (soc_is_qca955x()) {
-  		ath79_ip2_handler = ath79_default_ip2_handler;
-  		ath79_ip3_handler = ath79_default_ip3_handler;
--+	} else if (soc_is_qca956x()) {
-++	} else if (soc_is_qca956x() || soc_is_tp9343()) {
- +		ath79_ip2_handler = ath79_default_ip2_handler;
- +		ath79_ip3_handler = ath79_default_ip3_handler;
-  	} else {
-  		BUG();
-  	}
--@@ -411,4 +506,6 @@ void __init arch_init_irq(void)
-+@@ -411,4 +507,6 @@ void __init arch_init_irq(void)
-  		qca953x_irq_init();
-  	else if (soc_is_qca955x())
-  		qca955x_irq_init();
--+	else if (soc_is_qca956x())
-++	else if (soc_is_qca956x() || soc_is_tp9343())
- +		qca956x_irq_init();
-  }
- --- a/arch/mips/ath79/Kconfig
-@@ -428,7 +452,7 @@
-  		} else if (soc_is_qca955x()) {
-  			ath79_pci_irq_map = qca955x_pci_irq_map;
-  			ath79_pci_nr_irqs = ARRAY_SIZE(qca955x_pci_irq_map);
--+		} else if (soc_is_qca9561()) {
-++		} else if (soc_is_qca956x()) {
- +			ath79_pci_irq_map = qca956x_pci_irq_map;
- +			ath79_pci_nr_irqs = ARRAY_SIZE(qca956x_pci_irq_map);
-  		} else {
-@@ -438,7 +462,7 @@
-  						 QCA955X_PCI_MEM_SIZE,
-  						 1,
-  						 ATH79_IP3_IRQ(2));
--+	} else if (soc_is_qca9561()) {
-++	} else if (soc_is_qca956x()) {
- +		pdev = ath79_register_pci_ar724x(0,
- +						 QCA956X_PCI_CFG_BASE1,
- +						 QCA956X_PCI_CTRL_BASE1,
-@@ -456,15 +480,15 @@
-  		rev = id & QCA955X_REV_ID_REVISION_MASK;
-  		break;
-  
--+	case REV_ID_MAJOR_TP9343:
--+		ath79_soc = ATH79_SOC_TP9343;
--+		chip = "9343";
-++	case REV_ID_MAJOR_QCA956X:
-++		ath79_soc = ATH79_SOC_QCA956X;
-++		chip = "956X";
- +		rev = id & QCA956X_REV_ID_REVISION_MASK;
- +		break;
- +
--+	case REV_ID_MAJOR_QCA9561:
--+		ath79_soc = ATH79_SOC_QCA9561;
--+		chip = "9561";
-++	case REV_ID_MAJOR_TP9343:
-++		ath79_soc = ATH79_SOC_TP9343;
-++		chip = "9343";
- +		rev = id & QCA956X_REV_ID_REVISION_MASK;
- +		break;
- +
-@@ -476,7 +500,7 @@
-  		ath79_soc_rev = rev;
-  
- -	if (soc_is_qca953x() || soc_is_qca955x())
--+	if (soc_is_qca953x() || soc_is_qca955x() || soc_is_qca9561())
-++	if (soc_is_qca953x() || soc_is_qca955x() || soc_is_qca956x())
-  		sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s ver %u rev %u",
-  			chip, ver, rev);
- +	else if (soc_is_tp9343())
-@@ -511,7 +535,21 @@
-  #define AR9300_OTP_BASE		0x14000
-  #define AR9300_OTP_STATUS	0x15f18
-  #define AR9300_OTP_STATUS_TYPE		0x7
--@@ -375,6 +392,49 @@
-+@@ -152,6 +169,13 @@
-+ #define AR9300_OTP_READ_DATA	0x15f1c
-+ 
-+ /*
-++ * Hidden Registers
-++ */
-++#define QCA956X_DAM_RESET_OFFSET	0xb90001bc
-++#define QCA956X_DAM_RESET_SIZE		0x4
-++#define QCA956X_INLINE_CHKSUM_ENG	BIT(27)
-++
-++/*
-+  * DDR_CTRL block
-+  */
-+ #define AR71XX_DDR_REG_PCI_WIN0		0x7c
-+@@ -375,6 +399,49 @@
-  #define QCA955X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL		BIT(21)
-  #define QCA955X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL		BIT(24)
-  
-@@ -561,7 +599,7 @@
-  /*
-   * USB_CONFIG block
-   */
--@@ -422,6 +482,11 @@
-+@@ -422,6 +489,11 @@
-  #define QCA955X_RESET_REG_BOOTSTRAP		0xb0
-  #define QCA955X_RESET_REG_EXT_INT_STATUS	0xac
-  
-@@ -573,7 +611,7 @@
-  #define MISC_INT_ETHSW			BIT(12)
-  #define MISC_INT_TIMER4			BIT(10)
-  #define MISC_INT_TIMER3			BIT(9)
--@@ -596,6 +661,8 @@
-+@@ -596,6 +668,8 @@
-  
-  #define QCA955X_BOOTSTRAP_REF_CLK_40	BIT(4)
-  
-@@ -582,7 +620,7 @@
-  #define AR934X_PCIE_WMAC_INT_WMAC_MISC		BIT(0)
-  #define AR934X_PCIE_WMAC_INT_WMAC_TX		BIT(1)
-  #define AR934X_PCIE_WMAC_INT_WMAC_RXLP		BIT(2)
--@@ -663,6 +730,37 @@
-+@@ -663,6 +737,37 @@
-  	 QCA955X_EXT_INT_PCIE_RC2_INT1 | QCA955X_EXT_INT_PCIE_RC2_INT2 | \
-  	 QCA955X_EXT_INT_PCIE_RC2_INT3)
-  
-@@ -620,16 +658,16 @@
-  #define REV_ID_MAJOR_MASK		0xfff0
-  #define REV_ID_MAJOR_AR71XX		0x00a0
-  #define REV_ID_MAJOR_AR913X		0x00b0
--@@ -678,6 +776,8 @@
-+@@ -678,6 +783,8 @@
-  #define REV_ID_MAJOR_QCA9533_V2		0x0160
-  #define REV_ID_MAJOR_QCA9556		0x0130
-  #define REV_ID_MAJOR_QCA9558		0x1130
- +#define REV_ID_MAJOR_TP9343		0x0150
--+#define REV_ID_MAJOR_QCA9561		0x1150
-++#define REV_ID_MAJOR_QCA956X		0x1150
-  
-  #define AR71XX_REV_ID_MINOR_MASK	0x3
-  #define AR71XX_REV_ID_MINOR_AR7130	0x0
--@@ -702,6 +802,8 @@
-+@@ -702,6 +809,8 @@
-  
-  #define QCA955X_REV_ID_REVISION_MASK	0xf
-  
-@@ -638,7 +676,7 @@
-  /*
-   * SPI block
-   */
--@@ -774,6 +876,19 @@
-+@@ -766,6 +875,19 @@
-  #define QCA953X_GPIO_OUT_MUX_LED_LINK4		44
-  #define QCA953X_GPIO_OUT_MUX_LED_LINK5		45
-  
-@@ -658,7 +696,7 @@
-  #define AR71XX_GPIO_COUNT		16
-  #define AR7240_GPIO_COUNT		18
-  #define AR7241_GPIO_COUNT		20
--@@ -782,6 +897,7 @@
-+@@ -774,6 +896,7 @@
-  #define AR934X_GPIO_COUNT		23
-  #define QCA953X_GPIO_COUNT		18
-  #define QCA955X_GPIO_COUNT		24
-@@ -673,11 +711,11 @@
-  	ATH79_SOC_QCA9556,
-  	ATH79_SOC_QCA9558,
- +	ATH79_SOC_TP9343,
--+	ATH79_SOC_QCA9561,
-++	ATH79_SOC_QCA956X,
-  };
-  
-  extern enum ath79_soc_type ath79_soc;
--@@ -126,6 +128,21 @@ static inline int soc_is_qca955x(void)
-+@@ -126,6 +128,26 @@ static inline int soc_is_qca955x(void)
-  	return soc_is_qca9556() || soc_is_qca9558();
-  }
-  
-@@ -685,15 +723,20 @@
- +{
- +	return ath79_soc == ATH79_SOC_TP9343;
- +}
--+ 
-++
- +static inline int soc_is_qca9561(void)
- +{
--+	return ath79_soc == ATH79_SOC_QCA9561;
-++	return ath79_soc == ATH79_SOC_QCA956X;
-++}
-++
-++static inline int soc_is_qca9563(void)
-++{
-++	return ath79_soc == ATH79_SOC_QCA956X;
- +}
- +
- +static inline int soc_is_qca956x(void)
- +{
--+	return soc_is_tp9343() || soc_is_qca9561();
-++	return soc_is_qca9561() || soc_is_qca9563();
- +}
- +
-  extern void __iomem *ath79_ddr_base;
-diff --git a/target/linux/ar71xx/patches-3.18/739-MIPS-ath79-add-gpio-func-register-for-QCA955x-SoC.patch b/target/linux/ar71xx/patches-3.18/739-MIPS-ath79-add-gpio-func-register-for-QCA955x-SoC.patch
-index a36b8c319f7d08fe5daab867a10edca4dfcd4706..44c9c6281e683792af37b6f9b32357b2a4ec2fd4 100644
---- a/target/linux/ar71xx/patches-3.18/739-MIPS-ath79-add-gpio-func-register-for-QCA955x-SoC.patch
-+++ b/target/linux/ar71xx/patches-3.18/739-MIPS-ath79-add-gpio-func-register-for-QCA955x-SoC.patch
-@@ -9,8 +9,8 @@
- +	    soc_is_qca955x())
-  		reg = AR71XX_GPIO_REG_FUNC;
-  	else if (soc_is_ar934x() ||
-- 		 soc_is_qca953x() || soc_is_qca956x())
--@@ -185,15 +186,27 @@ void __init ath79_gpio_output_select(uns
-+ 		 soc_is_qca953x() ||
-+@@ -187,15 +188,30 @@ void __init ath79_gpio_output_select(uns
-  {
-  	void __iomem *base = ath79_gpio_base;
-  	unsigned long flags;
-@@ -19,7 +19,7 @@
- +	unsigned long gpio_count;
-  	u32 t, s;
-  
---	BUG_ON(!soc_is_ar934x() && !soc_is_qca953x());
-+-	BUG_ON(!soc_is_ar934x() && !soc_is_qca953x() && !soc_is_qca956x());
- +	if (soc_is_ar934x()) {
- +		gpio_count = AR934X_GPIO_COUNT;
- +		reg_base = AR934X_GPIO_REG_OUT_FUNC0;
-@@ -29,6 +29,9 @@
- +	} else if (soc_is_qca955x()) {
- +		gpio_count = QCA955X_GPIO_COUNT;
- +		reg_base = QCA955X_GPIO_REG_OUT_FUNC0;
-++	} else if (soc_is_qca956x()) {
-++		gpio_count = QCA956X_GPIO_COUNT;
-++		reg_base = QCA956X_GPIO_REG_OUT_FUNC0;
- +	} else {
- +		BUG();
- +	}

+ 0 - 176
patches/openwrt/0035-ar71xx-fold-patch-622-MIPS-ath79-add-support-for-QCA956x-ethernet.patch-into-files.patch

@@ -1,176 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 21:00:16 +0200
-Subject: ar71xx: fold patch 622-MIPS-ath79-add-support-for-QCA956x-ethernet.patch into files/
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-
-Backport of OpenWrt r48650
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-index 31d24388d274b92e01642ad6d7f59d22f80dc2a6..2efb9c70ff31f5c11bcdff6c6326743e4d5b5a11 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-@@ -198,7 +198,6 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
- 	case ATH79_SOC_AR9330:
- 	case ATH79_SOC_AR9331:
- 	case ATH79_SOC_QCA9533:
--	case ATH79_SOC_QCA9561:
- 	case ATH79_SOC_TP9343:
- 		mdio_dev = &ath79_mdio1_device;
- 		mdio_data = &ath79_mdio1_data;
-@@ -209,6 +208,7 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
- 	case ATH79_SOC_AR9344:
- 	case ATH79_SOC_QCA9556:
- 	case ATH79_SOC_QCA9558:
-+	case ATH79_SOC_QCA956X:
- 		if (id == 0) {
- 			mdio_dev = &ath79_mdio0_device;
- 			mdio_data = &ath79_mdio0_data;
-@@ -258,7 +258,6 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
- 		break;
- 
- 	case ATH79_SOC_QCA9533:
--	case ATH79_SOC_QCA9561:
- 	case ATH79_SOC_TP9343:
- 		mdio_data->builtin_switch = 1;
- 		break;
-@@ -268,6 +267,11 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
- 		mdio_data->is_ar934x = 1;
- 		break;
- 
-+	case ATH79_SOC_QCA956X:
-+		if (id == 1)
-+			mdio_data->builtin_switch = 1;
-+		break;
-+
- 	default:
- 		break;
- 	}
-@@ -387,6 +391,16 @@ static void qca955x_set_speed_sgmii(int speed)
- 	iounmap(base);
- }
- 
-+static void qca956x_set_speed_sgmii(int speed)
-+{
-+	void __iomem *base;
-+	u32 val = ath79_get_eth_pll(0, speed);
-+
-+	base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
-+	__raw_writel(val, base + QCA955X_PLL_ETH_SGMII_CONTROL_REG);
-+	iounmap(base);
-+}
-+
- static void ath79_set_speed_dummy(int speed)
- {
- }
-@@ -517,6 +531,10 @@ struct ag71xx_switch_platform_data ath79_switch_data;
- #define AR934X_PLL_VAL_100	0x00000101
- #define AR934X_PLL_VAL_10	0x00001616
- 
-+#define QCA956X_PLL_VAL_1000	0x03000000
-+#define QCA956X_PLL_VAL_100	0x00000101
-+#define QCA956X_PLL_VAL_10	0x00001919
-+
- static void __init ath79_init_eth_pll_data(unsigned int id)
- {
- 	struct ath79_eth_pll_data *pll_data;
-@@ -575,13 +593,18 @@ static void __init ath79_init_eth_pll_data(unsigned int id)
- 	case ATH79_SOC_QCA9533:
- 	case ATH79_SOC_QCA9556:
- 	case ATH79_SOC_QCA9558:
--	case ATH79_SOC_QCA9561:
- 	case ATH79_SOC_TP9343:
- 		pll_10 = AR934X_PLL_VAL_10;
- 		pll_100 = AR934X_PLL_VAL_100;
- 		pll_1000 = AR934X_PLL_VAL_1000;
- 		break;
- 
-+	case ATH79_SOC_QCA956X:
-+		pll_10 = QCA956X_PLL_VAL_10;
-+		pll_100 = QCA956X_PLL_VAL_100;
-+		pll_1000 = QCA956X_PLL_VAL_1000;
-+		break;
-+
- 	default:
- 		BUG();
- 	}
-@@ -656,6 +679,7 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
- 
- 		case ATH79_SOC_QCA9556:
- 		case ATH79_SOC_QCA9558:
-+		case ATH79_SOC_QCA956X:
- 			switch (pdata->phy_if_mode) {
- 			case PHY_INTERFACE_MODE_MII:
- 			case PHY_INTERFACE_MODE_RGMII:
-@@ -666,11 +690,6 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
- 			}
- 			break;
- 
--		case ATH79_SOC_QCA9561:
--			if (!pdata->phy_if_mode)
--				pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
--			break;
--
- 		default:
- 			BUG();
- 		}
-@@ -699,7 +718,7 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
- 		case ATH79_SOC_AR7241:
- 		case ATH79_SOC_AR9330:
- 		case ATH79_SOC_AR9331:
--		case ATH79_SOC_QCA9561:
-+		case ATH79_SOC_QCA956X:
- 		case ATH79_SOC_TP9343:
- 			pdata->phy_if_mode = PHY_INTERFACE_MODE_GMII;
- 			break;
-@@ -1032,7 +1051,6 @@ void __init ath79_register_eth(unsigned int id)
- 			pdata->fifo_cfg3 = 0x01f00140;
- 		break;
- 
--	case ATH79_SOC_QCA9561:
- 	case ATH79_SOC_TP9343:
- 		if (id == 0) {
- 			pdata->reset_bit = AR933X_RESET_GE0_MAC |
-@@ -1100,6 +1118,34 @@ void __init ath79_register_eth(unsigned int id)
- 			pdata->fifo_cfg3 = 0x01f00140;
- 		break;
- 
-+	case ATH79_SOC_QCA956X:
-+		if (id == 0) {
-+			pdata->reset_bit = QCA955X_RESET_GE0_MAC |
-+					   QCA955X_RESET_GE0_MDIO;
-+			if (pdata->phy_if_mode == PHY_INTERFACE_MODE_SGMII)
-+				pdata->set_speed = qca956x_set_speed_sgmii;
-+			else
-+				/* FIXME */
-+				pdata->set_speed = ath79_set_speed_dummy;
-+		} else {
-+			pdata->reset_bit = QCA955X_RESET_GE1_MAC |
-+					   QCA955X_RESET_GE1_MDIO;
-+			/* FIXME */
-+			pdata->set_speed = ath79_set_speed_dummy;
-+		}
-+
-+		pdata->ddr_flush = ath79_ddr_no_flush;
-+		pdata->has_gbit = 1;
-+		pdata->is_ar724x = 1;
-+
-+		if (!pdata->fifo_cfg1)
-+			pdata->fifo_cfg1 = 0x0010ffff;
-+		if (!pdata->fifo_cfg2)
-+			pdata->fifo_cfg2 = 0x015500aa;
-+		if (!pdata->fifo_cfg3)
-+			pdata->fifo_cfg3 = 0x01f00140;
-+		break;
-+
- 	default:
- 		BUG();
- 	}
-@@ -1140,7 +1186,6 @@ void __init ath79_register_eth(unsigned int id)
- 		case ATH79_SOC_AR9330:
- 		case ATH79_SOC_AR9331:
- 		case ATH79_SOC_QCA9533:
--		case ATH79_SOC_QCA9561:
- 		case ATH79_SOC_TP9343:
- 			pdata->mii_bus_dev = &ath79_mdio1_device.dev;
- 			break;

+ 0 - 22
patches/openwrt/0036-ar71xx-fix-MDIO-bus-probe-on-QCA956x.patch

@@ -1,22 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 21:00:41 +0200
-Subject: ar71xx: fix MDIO bus probe on QCA956x
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-
-Backport of OpenWrt r48651
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-index 2efb9c70ff31f5c11bcdff6c6326743e4d5b5a11..12a376e1322ae14dd714297ed5f8319ae09eeb64 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-@@ -183,7 +183,8 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
- 	    ath79_soc == ATH79_SOC_AR9342 ||
- 	    ath79_soc == ATH79_SOC_AR9344 ||
- 	    ath79_soc == ATH79_SOC_QCA9556 ||
--	    ath79_soc == ATH79_SOC_QCA9558)
-+	    ath79_soc == ATH79_SOC_QCA9558 ||
-+	    ath79_soc == ATH79_SOC_QCA956X)
- 		max_id = 1;
- 	else
- 		max_id = 0;

+ 0 - 64
patches/openwrt/0037-ar71xx-fix-qca956x-ethernet-initialization.patch

@@ -1,64 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 21:01:19 +0200
-Subject: ar71xx: fix qca956x ethernet initialization
-
-Complete internal switch initialization for QCA956X.
-Set default mdio device if the interface mode of GE0 is not SGMII (fix ticket #21520).
-
-Signed-off-by: Weijie Gao <hackpascal@gmail.com>
-
-Backport of OpenWrt r48937
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-index 12a376e1322ae14dd714297ed5f8319ae09eeb64..b43c80a3762ddebe46d8443660714922165a2287 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
-@@ -271,6 +271,7 @@ void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
- 	case ATH79_SOC_QCA956X:
- 		if (id == 1)
- 			mdio_data->builtin_switch = 1;
-+		mdio_data->is_ar934x = 1;
- 		break;
- 
- 	default:
-@@ -1123,16 +1124,25 @@ void __init ath79_register_eth(unsigned int id)
- 		if (id == 0) {
- 			pdata->reset_bit = QCA955X_RESET_GE0_MAC |
- 					   QCA955X_RESET_GE0_MDIO;
-+
- 			if (pdata->phy_if_mode == PHY_INTERFACE_MODE_SGMII)
- 				pdata->set_speed = qca956x_set_speed_sgmii;
- 			else
--				/* FIXME */
--				pdata->set_speed = ath79_set_speed_dummy;
-+				pdata->set_speed = ath79_set_speed_ge0;
- 		} else {
- 			pdata->reset_bit = QCA955X_RESET_GE1_MAC |
- 					   QCA955X_RESET_GE1_MDIO;
--			/* FIXME */
-+
- 			pdata->set_speed = ath79_set_speed_dummy;
-+
-+			pdata->switch_data = &ath79_switch_data;
-+
-+			pdata->speed = SPEED_1000;
-+			pdata->duplex = DUPLEX_FULL;
-+
-+			/* reset the built-in switch */
-+			ath79_device_reset_set(AR934X_RESET_ETH_SWITCH);
-+			ath79_device_reset_clear(AR934X_RESET_ETH_SWITCH);
- 		}
- 
- 		pdata->ddr_flush = ath79_ddr_no_flush;
-@@ -1196,6 +1206,11 @@ void __init ath79_register_eth(unsigned int id)
- 			/* don't assign any MDIO device by default */
- 			break;
- 
-+		case ATH79_SOC_QCA956X:
-+			if (pdata->phy_if_mode != PHY_INTERFACE_MODE_SGMII)
-+				pdata->mii_bus_dev = &ath79_mdio1_device.dev;
-+			break;
-+
- 		default:
- 			pdata->mii_bus_dev = &ath79_mdio0_device.dev;
- 			break;

+ 0 - 562
patches/openwrt/0038-ar71xx-Support-for-Ubiquiti-UniFi-AP-AC-LITE.patch

@@ -1,562 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 20:47:26 +0200
-Subject: ar71xx: Support for Ubiquiti UniFi AP AC LITE
-
-Add support for the Ubiquiti UniFi AP AC LITE
-Signed-off-by: P.Wassi <p.wassi at gmx.at>
-
-Backport of OpenWrt r48711
-
-diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
-index 486879f512cd28f1b80e828809359b55956fbcc3..3adc449b23e9c590d57cdd914b6c8d990a50e0b0 100644
---- a/target/linux/ar71xx/base-files/etc/diag.sh
-+++ b/target/linux/ar71xx/base-files/etc/diag.sh
-@@ -309,7 +309,8 @@ get_status_led() {
- 	unifi)
- 		status_led="ubnt:green:dome"
- 		;;
--	uap-pro)
-+	uap-pro | \
-+	unifiac)
- 		status_led="ubnt:white:dome"
- 		;;
- 	unifi-outdoor-plus)
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index 032c671341fd526c7e4e32cb9cba42217165cf5c..a79376a8cff56b144268130a24a930ff2bee95cd 100755
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -369,6 +369,7 @@ tl-wa901nd-v3 |\
- tl-wa901nd-v4 |\
- tl-wr703n |\
- tube2h |\
-+unifiac |\
- wndap360 |\
- mynet-rext |\
- wp543)
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index 6c106179bfa0c01308a03678aef1b7cf4caaf05b..ecf584d30ecae7a0e2601bed38c6cfad42cab124 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -902,6 +902,9 @@ ar71xx_board_detect() {
- 	*UniFi)
- 		name="unifi"
- 		;;
-+	*"UniFi-AC")
-+		name="unifiac"
-+		;;
- 	*"UniFi AP Pro")
- 		name="uap-pro"
- 		;;
-diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index 024e4930949c927efd36c3ac67cd351dcaa4bf7b..fff1c3c912cee678ea88e225958b28ceb4c4b742 100755
---- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-@@ -252,6 +252,7 @@ platform_check_image() {
- 	wlae-ag300n | \
- 	nbg460n_550n_550nh | \
- 	unifi | \
-+	unifiac | \
- 	unifi-outdoor | \
- 	carambola2 | \
- 	weio )
-diff --git a/target/linux/ar71xx/config-3.18 b/target/linux/ar71xx/config-3.18
-index e0d52d9fcbad980f7220dd1f93388359e52dc8f9..a068cc5768aed6f29a67de27d24f00dc57e0695a 100644
---- a/target/linux/ar71xx/config-3.18
-+++ b/target/linux/ar71xx/config-3.18
-@@ -141,6 +141,7 @@ CONFIG_ATH79_MACH_TL_WR941ND=y
- CONFIG_ATH79_MACH_TL_WR941ND_V6=y
- CONFIG_ATH79_MACH_TUBE2H=y
- CONFIG_ATH79_MACH_UBNT=y
-+CONFIG_ATH79_MACH_UBNT_UNIFIAC=y
- CONFIG_ATH79_MACH_UBNT_XM=y
- CONFIG_ATH79_MACH_WEIO=y
- CONFIG_ATH79_MACH_WHR_HP_G300N=y
-@@ -324,7 +325,7 @@ CONFIG_SOC_AR933X=y
- CONFIG_SOC_AR934X=y
- CONFIG_SOC_QCA953X=y
- CONFIG_SOC_QCA955X=y
--# CONFIG_SOC_QCA956X is not set
-+CONFIG_SOC_QCA956X=y
- CONFIG_SPI=y
- CONFIG_SPI_AP83=y
- CONFIG_SPI_ATH79=y
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-new file mode 100644
-index 0000000000000000000000000000000000000000..3617ca7d5fc0fff00fce9741b5d9169fac8c83c8
---- /dev/null
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-@@ -0,0 +1,109 @@
-+/*
-+ *  Ubiquiti UniFi AC (LITE) board support
-+ *
-+ *  Copyright (C) 2015-2016 P. Wassi <p.wassi at gmx.at>
-+ *
-+ *  Derived from: mach-ubnt-xm.c
-+ *
-+ *  This program is free software; you can redistribute it and/or modify it
-+ *  under the terms of the GNU General Public License version 2 as published
-+ *  by the Free Software Foundation.
-+ */
-+
-+#include <linux/init.h>
-+#include <linux/pci.h>
-+#include <linux/platform_device.h>
-+#include <linux/ath9k_platform.h>
-+#include <linux/etherdevice.h>
-+
-+#include <asm/mach-ath79/ath79.h>
-+#include <asm/mach-ath79/irq.h>
-+#include <asm/mach-ath79/ar71xx_regs.h>
-+
-+#include <linux/platform_data/phy-at803x.h>
-+
-+#include "common.h"
-+#include "dev-ap9x-pci.h"
-+#include "dev-eth.h"
-+#include "dev-gpio-buttons.h"
-+#include "dev-leds-gpio.h"
-+#include "dev-m25p80.h"
-+#include "dev-wmac.h"
-+#include "machtypes.h"
-+
-+
-+#define UNIFIAC_KEYS_POLL_INTERVAL	20
-+#define UNIFIAC_KEYS_DEBOUNCE_INTERVAL	(3 * UNIFIAC_KEYS_POLL_INTERVAL)
-+
-+#define UNIFIAC_GPIO_LED_WHITE		7
-+#define UNIFIAC_GPIO_LED_BLUE		8
-+
-+#define UNIFIAC_GPIO_BTN_RESET		2
-+
-+#define UNIFIAC_MAC0_OFFSET             0x0000
-+#define UNIFIAC_WMAC_CALDATA_OFFSET     0x1000
-+#define UNIFIAC_PCI_CALDATA_OFFSET      0x5000
-+
-+
-+static struct flash_platform_data ubnt_unifiac_flash_data = {
-+	/* mx25l12805d and mx25l12835f have the same JEDEC ID */
-+	.type = "mx25l12805d",
-+};
-+
-+static struct gpio_led ubnt_unifiac_leds_gpio[] __initdata = {
-+	{
-+		.name		= "ubnt:white:dome",
-+		.gpio		= UNIFIAC_GPIO_LED_WHITE,
-+		.active_low	= 0,
-+	}, {
-+		.name		= "ubnt:blue:dome",
-+		.gpio		= UNIFIAC_GPIO_LED_BLUE,
-+		.active_low	= 0,
-+	}
-+};
-+
-+static struct gpio_keys_button ubnt_unifiac_gpio_keys[] __initdata = {
-+	{
-+		.desc			= "reset",
-+		.type			= EV_KEY,
-+		.code			= KEY_RESTART,
-+		.debounce_interval	= UNIFIAC_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio			= UNIFIAC_GPIO_BTN_RESET,
-+		.active_low		= 1,
-+	}
-+};
-+
-+static void __init ubnt_unifiac_setup(void)
-+{
-+	u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
-+
-+	ath79_register_m25p80(&ubnt_unifiac_flash_data);
-+
-+
-+	ath79_init_mac(ath79_eth0_data.mac_addr,
-+		       eeprom + UNIFIAC_MAC0_OFFSET, 0);
-+
-+	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
-+	ath79_eth0_data.phy_mask = BIT(4);
-+	ath79_eth0_pll_data.pll_10 = 0x00001313;
-+
-+	ath79_register_mdio(0, ~BIT(4));
-+	ath79_register_eth(0);
-+
-+
-+	ath79_register_wmac(eeprom + UNIFIAC_WMAC_CALDATA_OFFSET, NULL);
-+
-+
-+	ap91_pci_init(eeprom + UNIFIAC_PCI_CALDATA_OFFSET, NULL);
-+
-+
-+	ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifiac_leds_gpio),
-+				 ubnt_unifiac_leds_gpio);
-+
-+	ath79_register_gpio_keys_polled(-1, UNIFIAC_KEYS_POLL_INTERVAL,
-+                                        ARRAY_SIZE(ubnt_unifiac_gpio_keys),
-+                                        ubnt_unifiac_gpio_keys);
-+}
-+
-+MIPS_MACHINE(ATH79_MACH_UBNT_UNIFIAC, "UBNT-UF-AC", "Ubiquiti UniFi-AC",
-+	     ubnt_unifiac_setup);
-diff --git a/target/linux/ar71xx/generic/profiles/ubnt.mk b/target/linux/ar71xx/generic/profiles/ubnt.mk
-index d8e24d0032d75231d27be8207fe55294fd108282..94eff18318264de85ea459e94280c88726404888 100644
---- a/target/linux/ar71xx/generic/profiles/ubnt.mk
-+++ b/target/linux/ar71xx/generic/profiles/ubnt.mk
-@@ -38,6 +38,17 @@ endef
- 
- $(eval $(call Profile,UBNTUNIFI))
- 
-+define Profile/UBNTUNIFIAC
-+	NAME:=Ubiquiti UniFi AP AC
-+	PACKAGES:=kmod-ath10k ath10k-firmware-qca988x
-+endef
-+
-+define Profile/UBNTUNIFIAC/Description
-+	Package set optimized for the Ubiquiti UniFi AP AC.
-+endef
-+
-+$(eval $(call Profile,UBNTUNIFIAC))
-+
- define Profile/UBNTUNIFIOUTDOOR
- 	NAME:=Ubiquiti UniFiAP Outdoor
- 	PACKAGES:=
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 0783381baeddef2064df8faff89c49c2bed6a28b..aaaf89ac1a369431cf9bc15c13e774ba6826bbf3 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -740,6 +740,16 @@ define Device/oolite
- endef
- TARGET_DEVICES += oolite
- 
-+define Device/ubnt-unifiac
-+  DEVICE_PROFILE := UBNT UBNTUNIFIAC
-+  IMAGE_SIZE := 7744k
-+  MTDPARTS = spi0.0:384k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),7744k(ubnt-airos)ro,128k(bs)ro,256k(cfg)ro,64k(EEPROM)ro
-+  IMAGES := sysupgrade.bin
-+  IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
-+  BOARDNAME := UBNT-UF-AC
-+endef
-+TARGET_DEVICES += ubnt-unifiac
-+
- rootfs_type=$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
- 
- # $(1): rootfs type.
-diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default
-index b8a7bf13f2582b0b458d17f5e4b266a6e110faa1..2b1fe2491c7a00449453efdc4969015ec1b28291 100644
---- a/target/linux/ar71xx/mikrotik/config-default
-+++ b/target/linux/ar71xx/mikrotik/config-default
-@@ -97,6 +97,7 @@ CONFIG_ATH79_MACH_RBSXTLITE=y
- # CONFIG_ATH79_MACH_TUBE2H is not set
- # CONFIG_ATH79_MACH_UBNT is not set
- # CONFIG_ATH79_MACH_UBNT_XM is not set
-+# CONFIG_ATH79_MACH_UBNT_UNIFIAC is not set
- # CONFIG_ATH79_MACH_WHR_HP_G300N is not set
- # CONFIG_ATH79_MACH_WLAE_AG300N is not set
- # CONFIG_ATH79_MACH_WLR8100 is not set
-diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default
-index 626d676c621b90feb31a88e7b8c2daa587a8f603..f62cf1a4399718b2f4e94a974d26ddaf8d46a8ec 100644
---- a/target/linux/ar71xx/nand/config-default
-+++ b/target/linux/ar71xx/nand/config-default
-@@ -59,6 +59,7 @@
- # CONFIG_ATH79_MACH_TL_WR941ND is not set
- # CONFIG_ATH79_MACH_UBNT is not set
- # CONFIG_ATH79_MACH_UBNT_XM is not set
-+# CONFIG_ATH79_MACH_UBNT_UNIFIAC is not set
- # CONFIG_ATH79_MACH_WHR_HP_G300N is not set
- # CONFIG_ATH79_MACH_WLAE_AG300N is not set
- # CONFIG_ATH79_MACH_WNDAP360 is not set
-diff --git a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-index 76aeb94412e6f44b9a81fc44858e9c4540a08845..27dc73ffa239979a799bbede72440907e9d0e187 100644
---- a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-+++ b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-@@ -1,6 +1,6 @@
- --- a/arch/mips/ath79/machtypes.h
- +++ b/arch/mips/ath79/machtypes.h
--@@ -16,22 +16,200 @@
-+@@ -16,22 +16,201 @@
-  
-  enum ath79_mach_type {
-  	ATH79_MACH_GENERIC = 0,
-@@ -165,6 +165,7 @@
- +	ATH79_MACH_UBNT_RS,		/* Ubiquiti RouterStation */
-  	ATH79_MACH_UBNT_UAP_PRO,	/* Ubiquiti UniFi AP Pro */
-  	ATH79_MACH_UBNT_UNIFI, 		/* Ubiquiti Unifi */
-++	ATH79_MACH_UBNT_UNIFIAC,	/* Ubiquiti Unifi AC */
-  	ATH79_MACH_UBNT_UNIFI_OUTDOOR,	/* Ubiquiti UnifiAP Outdoor */
- +	ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, /* Ubiquiti UnifiAP Outdoor+ */
-  	ATH79_MACH_UBNT_XM,		/* Ubiquiti Networks XM board rev 1.0 */
-@@ -1098,10 +1099,7 @@
- +	select ATH79_DEV_M25P80
- +	select ATH79_DEV_USB
- +	select ATH79_DEV_WMAC
-- 
---config ATH79_MACH_AP136
---	bool "Atheros AP136/AP135 reference board"
---	select SOC_QCA955X
-++
- +config ATH79_MACH_TL_WA7210N_V2
- +       bool "TP-LINK TL-WA7210N v2 support"
- +       select SOC_AR724X
-@@ -1116,19 +1114,12 @@
- +	bool "TP-LINK TL-WA830RE v2 support"
- +	select SOC_AR934X
- +	select ATH79_DEV_ETH
-- 	select ATH79_DEV_GPIO_BUTTONS
-- 	select ATH79_DEV_LEDS_GPIO
---	select ATH79_DEV_NFC
---	select ATH79_DEV_SPI
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
- +	select ATH79_DEV_M25P80
-- 	select ATH79_DEV_USB
-- 	select ATH79_DEV_WMAC
---	help
---	  Say 'Y' here if you want your kernel to support the
---	  Atheros AP136 or AP135 reference boards.
-- 
---config ATH79_MACH_AP81
---	bool "Atheros AP81 reference board"
-++	select ATH79_DEV_USB
-++	select ATH79_DEV_WMAC
-++
- +config ATH79_MACH_TL_WA901ND
- +	bool "TP-LINK TL-WA901ND/TL-WA7510N support"
- +	select SOC_AR724X
-@@ -1140,11 +1131,11 @@
- +
- +config ATH79_MACH_TL_WA901ND_V2
- +	bool "TP-LINK TL-WA901ND v2 support"
-- 	select SOC_AR913X
-- 	select ATH79_DEV_ETH
-- 	select ATH79_DEV_GPIO_BUTTONS
-- 	select ATH79_DEV_LEDS_GPIO
-- 	select ATH79_DEV_M25P80
-++	select SOC_AR913X
-++	select ATH79_DEV_ETH
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
-++	select ATH79_DEV_M25P80
- +	select ATH79_DEV_WMAC
- +
- +config ATH79_MACH_TL_WDR3500
-@@ -1155,34 +1146,13 @@
- +	select ATH79_DEV_GPIO_BUTTONS
- +	select ATH79_DEV_LEDS_GPIO
- +	select ATH79_DEV_M25P80
-- 	select ATH79_DEV_USB
-- 	select ATH79_DEV_WMAC
---	help
---	  Say 'Y' here if you want your kernel to support the
---	  Atheros AP81 reference board.
-- 
---config ATH79_MACH_DB120
---	bool "Atheros DB120 reference board"
-++	select ATH79_DEV_USB
-++	select ATH79_DEV_WMAC
-++
- +config ATH79_MACH_TL_WDR4300
- +	bool "TP-LINK TL-WDR3600/4300/4310 board support"
-- 	select SOC_AR934X
-- 	select ATH79_DEV_AP9X_PCI if PCI
-- 	select ATH79_DEV_ETH
-- 	select ATH79_DEV_GPIO_BUTTONS
-- 	select ATH79_DEV_LEDS_GPIO
-- 	select ATH79_DEV_M25P80
---	select ATH79_DEV_NFC
-- 	select ATH79_DEV_USB
-- 	select ATH79_DEV_WMAC
---	help
---	  Say 'Y' here if you want your kernel to support the
---	  Atheros DB120 reference board.
-- 
---config ATH79_MACH_PB44
---	bool "Atheros PB44 reference board"
--+config ATH79_MACH_TL_WR703N
--+	bool "TP-LINK TL-WR703N/TL-WR710N/TL-MR10U support"
--+	select SOC_AR933X
-++	select SOC_AR934X
-++	select ATH79_DEV_AP9X_PCI if PCI
- +	select ATH79_DEV_ETH
- +	select ATH79_DEV_GPIO_BUTTONS
- +	select ATH79_DEV_LEDS_GPIO
-@@ -1190,8 +1160,8 @@
- +	select ATH79_DEV_USB
- +	select ATH79_DEV_WMAC
- +
--+config ATH79_MACH_TL_WR720N_V3
--+	bool "TP-LINK TL-WR720N v3/v4 support"
-++config ATH79_MACH_TL_WR703N
-++	bool "TP-LINK TL-WR703N/TL-WR710N/TL-MR10U support"
- +	select SOC_AR933X
- +	select ATH79_DEV_ETH
- +	select ATH79_DEV_GPIO_BUTTONS
-@@ -1199,7 +1169,28 @@
- +	select ATH79_DEV_M25P80
- +	select ATH79_DEV_USB
- +	select ATH79_DEV_WMAC
--+
-+ 
-+-config ATH79_MACH_AP136
-+-	bool "Atheros AP136/AP135 reference board"
-+-	select SOC_QCA955X
-++config ATH79_MACH_TL_WR720N_V3
-++	bool "TP-LINK TL-WR720N v3/v4 support"
-++	select SOC_AR933X
-++	select ATH79_DEV_ETH
-+ 	select ATH79_DEV_GPIO_BUTTONS
-+ 	select ATH79_DEV_LEDS_GPIO
-+-	select ATH79_DEV_NFC
-+-	select ATH79_DEV_SPI
-++	select ATH79_DEV_M25P80
-+ 	select ATH79_DEV_USB
-+ 	select ATH79_DEV_WMAC
-+-	help
-+-	  Say 'Y' here if you want your kernel to support the
-+-	  Atheros AP136 or AP135 reference boards.
-+ 
-+-config ATH79_MACH_AP81
-+-	bool "Atheros AP81 reference board"
-+-	select SOC_AR913X
- +config ATH79_MACH_TL_WR741ND
- +	bool "TP-LINK TL-WR741ND support"
- +	select SOC_AR724X
-@@ -1212,21 +1203,25 @@
- +config ATH79_MACH_TL_WR741ND_V4
- +	bool "TP-LINK TL-WR741ND v4/TL-MR3220 v2 support"
- +	select SOC_AR933X
--+	select ATH79_DEV_ETH
--+	select ATH79_DEV_GPIO_BUTTONS
--+	select ATH79_DEV_LEDS_GPIO
--+	select ATH79_DEV_M25P80
--+	select ATH79_DEV_USB
--+	select ATH79_DEV_WMAC
--+
--+config ATH79_MACH_TL_WR841N_V1
--+	bool "TP-LINK TL-WR841N v1 support"
-- 	select SOC_AR71XX
--+	select ATH79_DEV_DSA
-  	select ATH79_DEV_ETH
-  	select ATH79_DEV_GPIO_BUTTONS
-  	select ATH79_DEV_LEDS_GPIO
---	select ATH79_DEV_SPI
-+ 	select ATH79_DEV_M25P80
-+ 	select ATH79_DEV_USB
-+ 	select ATH79_DEV_WMAC
-+-	help
-+-	  Say 'Y' here if you want your kernel to support the
-+-	  Atheros AP81 reference board.
-+ 
-+-config ATH79_MACH_DB120
-+-	bool "Atheros DB120 reference board"
-++config ATH79_MACH_TL_WR841N_V1
-++	bool "TP-LINK TL-WR841N v1 support"
-++	select SOC_AR71XX
-++	select ATH79_DEV_DSA
-++	select ATH79_DEV_ETH
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
- +	select ATH79_DEV_M25P80
- +
- +config ATH79_MACH_TL_WR841N_V8
-@@ -1269,15 +1264,21 @@
- +
- +config ATH79_MACH_TL_WR1041N_V2
- +	bool "TP-LINK TL-WR1041N v2 support"
--+	select SOC_AR934X
--+	select ATH79_DEV_AP9X_PCI if PCI
--+	select ATH79_DEV_ETH
--+	select ATH79_DEV_GPIO_BUTTONS
--+	select ATH79_DEV_LEDS_GPIO
--+	select ATH79_DEV_M25P80
--+	select ATH79_DEV_USB
--+	select ATH79_DEV_WMAC
--+
-+ 	select SOC_AR934X
-+ 	select ATH79_DEV_AP9X_PCI if PCI
-+ 	select ATH79_DEV_ETH
-+ 	select ATH79_DEV_GPIO_BUTTONS
-+ 	select ATH79_DEV_LEDS_GPIO
-+ 	select ATH79_DEV_M25P80
-+-	select ATH79_DEV_NFC
-+ 	select ATH79_DEV_USB
-+ 	select ATH79_DEV_WMAC
-+-	help
-+-	  Say 'Y' here if you want your kernel to support the
-+-	  Atheros DB120 reference board.
-+ 
-+-config ATH79_MACH_PB44
-+-	bool "Atheros PB44 reference board"
- +config ATH79_MACH_TL_WR1043ND
- +	bool "TP-LINK TL-WR1043ND support"
- +	select SOC_AR913X
-@@ -1320,11 +1321,12 @@
- +
- +config ATH79_MACH_TEW_673GRU
- +	bool "TRENDnet TEW-673GRU support"
--+	select SOC_AR71XX
-+ 	select SOC_AR71XX
- +	select ATH79_DEV_AP9X_PCI if PCI
--+	select ATH79_DEV_ETH
--+	select ATH79_DEV_GPIO_BUTTONS
--+	select ATH79_DEV_LEDS_GPIO
-+ 	select ATH79_DEV_ETH
-+ 	select ATH79_DEV_GPIO_BUTTONS
-+ 	select ATH79_DEV_LEDS_GPIO
-+-	select ATH79_DEV_SPI
- +	select ATH79_DEV_M25P80
- +	select ATH79_DEV_USB
- +	select ATH79_NVRAM
-@@ -1362,10 +1364,20 @@
-  
-  config ATH79_MACH_UBNT_XM
-  	bool "Ubiquiti Networks XM/UniFi boards"
--@@ -83,6 +1144,106 @@ config ATH79_MACH_UBNT_XM
-+@@ -83,6 +1144,116 @@ config ATH79_MACH_UBNT_XM
-  	  Say 'Y' here if you want your kernel to support the
-  	  Ubiquiti Networks XM (rev 1.0) board.
-  
-++config ATH79_MACH_UBNT_UNIFIAC
-++	bool "Ubiquiti UniFi AC (LITE) support"
-++	select SOC_QCA956X
-++	select ATH79_DEV_AP9X_PCI if PCI
-++	select ATH79_DEV_ETH
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
-++	select ATH79_DEV_M25P80
-++	select ATH79_DEV_WMAC
-++
- +config ATH79_MACH_WEIO
- +	bool "WeIO board"
- +	select SOC_AR933X
-@@ -1469,7 +1481,7 @@
-  endmenu
-  
-  config SOC_AR71XX
--@@ -124,7 +1285,10 @@ config ATH79_DEV_DSA
-+@@ -124,7 +1295,10 @@ config ATH79_DEV_DSA
-  config ATH79_DEV_ETH
-  	def_bool n
-  
-@@ -1481,7 +1493,7 @@
-  	def_bool n
-  
-  config ATH79_DEV_GPIO_BUTTONS
--@@ -154,6 +1318,11 @@ config ATH79_PCI_ATH9K_FIXUP
-+@@ -154,6 +1328,11 @@ config ATH79_PCI_ATH9K_FIXUP
-  	def_bool n
-  
-  config ATH79_ROUTERBOOT
-@@ -1495,7 +1507,7 @@
-  endif
- --- a/arch/mips/ath79/Makefile
- +++ b/arch/mips/ath79/Makefile
--@@ -38,9 +38,128 @@ obj-$(CONFIG_ATH79_ROUTERBOOT)		+= route
-+@@ -38,9 +38,129 @@ obj-$(CONFIG_ATH79_ROUTERBOOT)		+= route
-  #
-  # Machines
-  #
-@@ -1597,6 +1609,7 @@
- +obj-$(CONFIG_ATH79_MACH_TL_WR720N_V3)	+= mach-tl-wr720n-v3.o
- +obj-$(CONFIG_ATH79_MACH_TUBE2H)		+= mach-tube2h.o
- +obj-$(CONFIG_ATH79_MACH_UBNT)		+= mach-ubnt.o
-++obj-$(CONFIG_ATH79_MACH_UBNT_UNIFIAC)	+= mach-ubnt-unifiac.o
-  obj-$(CONFIG_ATH79_MACH_UBNT_XM)	+= mach-ubnt-xm.o
- +obj-$(CONFIG_ATH79_MACH_WEIO)		+= mach-weio.o
- +obj-$(CONFIG_ATH79_MACH_WHR_HP_G300N)	+= mach-whr-hp-g300n.o

+ 0 - 21
patches/openwrt/0039-ar71xx-Fix-eth0-support-for-Ubiquiti-UniFi-AP-AC.patch

@@ -1,21 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 21:02:55 +0200
-Subject: ar71xx: Fix eth0 support for Ubiquiti UniFi AP AC
-
-Fix eth0 support for the Ubiquiti UniFi AP AC
-Signed-off-by: Paul Wassi <p.wassi at gmx.at>
-
-Backport of OpenWrt r49277
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-index 3617ca7d5fc0fff00fce9741b5d9169fac8c83c8..072cf12a31a0921a8e9b90689864f5d981cd2c32 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-@@ -84,6 +84,7 @@ static void __init ubnt_unifiac_setup(void)
- 		       eeprom + UNIFIAC_MAC0_OFFSET, 0);
- 
- 	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
-+	ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
- 	ath79_eth0_data.phy_mask = BIT(4);
- 	ath79_eth0_pll_data.pll_10 = 0x00001313;
- 

+ 0 - 193
patches/openwrt/0040-ar71xx-Rename-unifiac-to-unifiac-lite.patch

@@ -1,193 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 21:24:44 +0200
-Subject: ar71xx: Rename unifiac to unifiac-lite
-
-To avoid confusion with different unifiac devices, rename existing target
-"unifiac" to "unifiac-lite", before "unifiac-pro" is introduced.
-
-Signed-off-by: P.Wassi <p.wassi at gmx.at>
-
-Backport of LEDE c855e70491fbd5d432915c4cbeb3b80f3a117e30
-
-diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
-index 3adc449b23e9c590d57cdd914b6c8d990a50e0b0..924c1163e26eb84b71e4734b95221104674bfe3e 100644
---- a/target/linux/ar71xx/base-files/etc/diag.sh
-+++ b/target/linux/ar71xx/base-files/etc/diag.sh
-@@ -310,7 +310,7 @@ get_status_led() {
- 		status_led="ubnt:green:dome"
- 		;;
- 	uap-pro | \
--	unifiac)
-+	unifiac-lite)
- 		status_led="ubnt:white:dome"
- 		;;
- 	unifi-outdoor-plus)
-diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
-index ab7d93c693f8422bbb518c6accd4ffed169398cd..7777734ae3899840c1c47e7b24373b4bceee0adc 100644
---- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
-+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
-@@ -81,7 +81,7 @@ case "$FIRMWARE" in
- 		ath10kcal_extract "ART" 20480 2116
- 		ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
- 		;;
--	unifiac)
-+	unifiac-lite)
- 		ath10kcal_extract "EEPROM" 20480 2116
- 		;;
- 	esac
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index a79376a8cff56b144268130a24a930ff2bee95cd..20070426fd033e4ff2e904f9247deed9eb48c3c3 100755
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -369,7 +369,7 @@ tl-wa901nd-v3 |\
- tl-wa901nd-v4 |\
- tl-wr703n |\
- tube2h |\
--unifiac |\
-+unifiac-lite |\
- wndap360 |\
- mynet-rext |\
- wp543)
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index ecf584d30ecae7a0e2601bed38c6cfad42cab124..6bc0b868423ef68fb83147c13b00163b29cf2aec 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -902,8 +902,8 @@ ar71xx_board_detect() {
- 	*UniFi)
- 		name="unifi"
- 		;;
--	*"UniFi-AC")
--		name="unifiac"
-+	*"UniFi-AC-LITE")
-+		name="unifiac-lite"
- 		;;
- 	*"UniFi AP Pro")
- 		name="uap-pro"
-diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index fff1c3c912cee678ea88e225958b28ceb4c4b742..90f961f3f0aaf3c76a0a8022258fbf5404165ca8 100755
---- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-@@ -252,7 +252,7 @@ platform_check_image() {
- 	wlae-ag300n | \
- 	nbg460n_550n_550nh | \
- 	unifi | \
--	unifiac | \
-+	unifiac-lite | \
- 	unifi-outdoor | \
- 	carambola2 | \
- 	weio )
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-index 072cf12a31a0921a8e9b90689864f5d981cd2c32..31cbe30d3ff9b323cb336c62d6fe0d7a0c67ba42 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-@@ -73,7 +73,7 @@ static struct gpio_keys_button ubnt_unifiac_gpio_keys[] __initdata = {
- 	}
- };
- 
--static void __init ubnt_unifiac_setup(void)
-+static void __init ubnt_unifiac_lite_setup(void)
- {
- 	u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
- 
-@@ -81,7 +81,7 @@ static void __init ubnt_unifiac_setup(void)
- 
- 
- 	ath79_init_mac(ath79_eth0_data.mac_addr,
--		       eeprom + UNIFIAC_MAC0_OFFSET, 0);
-+	               eeprom + UNIFIAC_MAC0_OFFSET, 0);
- 
- 	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
- 	ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
-@@ -99,12 +99,12 @@ static void __init ubnt_unifiac_setup(void)
- 
- 
- 	ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifiac_leds_gpio),
--				 ubnt_unifiac_leds_gpio);
-+	                         ubnt_unifiac_leds_gpio);
- 
- 	ath79_register_gpio_keys_polled(-1, UNIFIAC_KEYS_POLL_INTERVAL,
--                                        ARRAY_SIZE(ubnt_unifiac_gpio_keys),
--                                        ubnt_unifiac_gpio_keys);
-+	                                ARRAY_SIZE(ubnt_unifiac_gpio_keys),
-+	                                ubnt_unifiac_gpio_keys);
- }
- 
--MIPS_MACHINE(ATH79_MACH_UBNT_UNIFIAC, "UBNT-UF-AC", "Ubiquiti UniFi-AC",
--	     ubnt_unifiac_setup);
-+MIPS_MACHINE(ATH79_MACH_UBNT_UNIFIAC_LITE, "UBNT-UF-AC-LITE", "Ubiquiti UniFi-AC-LITE",
-+	     ubnt_unifiac_lite_setup);
-diff --git a/target/linux/ar71xx/generic/profiles/ubnt.mk b/target/linux/ar71xx/generic/profiles/ubnt.mk
-index 94eff18318264de85ea459e94280c88726404888..eac02406bbbffebbcb20962929fb8254edba520e 100644
---- a/target/linux/ar71xx/generic/profiles/ubnt.mk
-+++ b/target/linux/ar71xx/generic/profiles/ubnt.mk
-@@ -38,16 +38,16 @@ endef
- 
- $(eval $(call Profile,UBNTUNIFI))
- 
--define Profile/UBNTUNIFIAC
--	NAME:=Ubiquiti UniFi AP AC
-+define Profile/UBNTUNIFIACLITE
-+	NAME:=Ubiquiti UniFi AP AC LITE/LR
- 	PACKAGES:=kmod-ath10k ath10k-firmware-qca988x
- endef
- 
--define Profile/UBNTUNIFIAC/Description
--	Package set optimized for the Ubiquiti UniFi AP AC.
-+define Profile/UBNTUNIFIACLITE/Description
-+	Package set optimized for the Ubiquiti UniFi AP AC LITE/LR.
- endef
- 
--$(eval $(call Profile,UBNTUNIFIAC))
-+$(eval $(call Profile,UBNTUNIFIACLITE))
- 
- define Profile/UBNTUNIFIOUTDOOR
- 	NAME:=Ubiquiti UniFiAP Outdoor
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index aaaf89ac1a369431cf9bc15c13e774ba6826bbf3..42ffc69ca3f9b1cffa542fc2d06ead2ef224d6b2 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -741,14 +741,19 @@ endef
- TARGET_DEVICES += oolite
- 
- define Device/ubnt-unifiac
--  DEVICE_PROFILE := UBNT UBNTUNIFIAC
-+  DEVICE_PROFILE := UBNT
-   IMAGE_SIZE := 7744k
-   MTDPARTS = spi0.0:384k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),7744k(ubnt-airos)ro,128k(bs)ro,256k(cfg)ro,64k(EEPROM)ro
-   IMAGES := sysupgrade.bin
-   IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
--  BOARDNAME := UBNT-UF-AC
- endef
--TARGET_DEVICES += ubnt-unifiac
-+
-+define Device/ubnt-unifiac-lite
-+  $(Device/ubnt-unifiac)
-+  DEVICE_PROFILE := UBNT UBNTUNIFIACLITE
-+  BOARDNAME := UBNT-UF-AC-LITE
-+endef
-+TARGET_DEVICES += ubnt-unifiac-lite
- 
- rootfs_type=$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
- 
-diff --git a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-index 27dc73ffa239979a799bbede72440907e9d0e187..9a28f58f67d5f98fcd4aa83dc09698705e2dfa3e 100644
---- a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-+++ b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-@@ -165,7 +165,7 @@
- +	ATH79_MACH_UBNT_RS,		/* Ubiquiti RouterStation */
-  	ATH79_MACH_UBNT_UAP_PRO,	/* Ubiquiti UniFi AP Pro */
-  	ATH79_MACH_UBNT_UNIFI, 		/* Ubiquiti Unifi */
--+	ATH79_MACH_UBNT_UNIFIAC,	/* Ubiquiti Unifi AC */
-++	ATH79_MACH_UBNT_UNIFIAC_LITE,	/* Ubiquiti Unifi AC LITE/LR */
-  	ATH79_MACH_UBNT_UNIFI_OUTDOOR,	/* Ubiquiti UnifiAP Outdoor */
- +	ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, /* Ubiquiti UnifiAP Outdoor+ */
-  	ATH79_MACH_UBNT_XM,		/* Ubiquiti Networks XM board rev 1.0 */
-@@ -1369,7 +1369,7 @@
-  	  Ubiquiti Networks XM (rev 1.0) board.
-  
- +config ATH79_MACH_UBNT_UNIFIAC
--+	bool "Ubiquiti UniFi AC (LITE) support"
-++	bool "Ubiquiti UniFi AC (LITE/LR) support"
- +	select SOC_QCA956X
- +	select ATH79_DEV_AP9X_PCI if PCI
- +	select ATH79_DEV_ETH

+ 0 - 274
patches/openwrt/0041-ar71xx-Add-support-for-Ubiquiti-UniFi-AP-AC-PRO.patch

@@ -1,274 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 13 May 2016 21:34:05 +0200
-Subject: ar71xx: Add support for Ubiquiti UniFi AP AC PRO
-
-Add support for the Ubiquiti UniFi AP AC PRO
-Signed-off-by: P.Wassi <p.wassi at gmx.at>
-
-Backport of LEDE 8307c2fe686ded345c80318359d5b6679e581fa2
-
-diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
-index 924c1163e26eb84b71e4734b95221104674bfe3e..cb92349cab833179a87a195b94e2539cc5ce3e79 100644
---- a/target/linux/ar71xx/base-files/etc/diag.sh
-+++ b/target/linux/ar71xx/base-files/etc/diag.sh
-@@ -310,7 +310,8 @@ get_status_led() {
- 		status_led="ubnt:green:dome"
- 		;;
- 	uap-pro | \
--	unifiac-lite)
-+	unifiac-lite | \
-+	unifiac-pro)
- 		status_led="ubnt:white:dome"
- 		;;
- 	unifi-outdoor-plus)
-diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
-index 7777734ae3899840c1c47e7b24373b4bceee0adc..5eb20bb26521258599898125d42f6b73b9c81f94 100644
---- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
-+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
-@@ -81,7 +81,8 @@ case "$FIRMWARE" in
- 		ath10kcal_extract "ART" 20480 2116
- 		ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
- 		;;
--	unifiac-lite)
-+	unifiac-lite | \
-+	unifiac-pro)
- 		ath10kcal_extract "EEPROM" 20480 2116
- 		;;
- 	esac
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index 20070426fd033e4ff2e904f9247deed9eb48c3c3..b59844eac49a1269edb88890d89b0b4d8a7121d0 100755
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -401,6 +401,13 @@ wpj344)
- 	ucidef_add_switch_vlan "switch0" "2" "0t 2"
- 	;;
- 
-+unifiac-pro)
-+	ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
-+	ucidef_add_switch "switch0" "1" "1"
-+	ucidef_add_switch_vlan "switch0" "1" "0t 2"
-+	ucidef_add_switch_vlan "switch0" "2" "0t 3"
-+	;;
-+
- wpj531)
- 	ucidef_set_interfaces_lan_wan "eth0" "eth1"
- 	;;
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index 6bc0b868423ef68fb83147c13b00163b29cf2aec..aded7ad117ffa1c1347c6f457c210d60b8e4df58 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -905,6 +905,9 @@ ar71xx_board_detect() {
- 	*"UniFi-AC-LITE")
- 		name="unifiac-lite"
- 		;;
-+	*"UniFi-AC-PRO")
-+		name="unifiac-pro"
-+		;;
- 	*"UniFi AP Pro")
- 		name="uap-pro"
- 		;;
-diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index 90f961f3f0aaf3c76a0a8022258fbf5404165ca8..0228f14774d5873a52f19b60ed84389c7be86e51 100755
---- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-@@ -253,6 +253,7 @@ platform_check_image() {
- 	nbg460n_550n_550nh | \
- 	unifi | \
- 	unifiac-lite | \
-+	unifiac-pro | \
- 	unifi-outdoor | \
- 	carambola2 | \
- 	weio )
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-index 31cbe30d3ff9b323cb336c62d6fe0d7a0c67ba42..9194bc1c0799d83fca3f6fe76b2602d72e5f4ef8 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c
-@@ -21,6 +21,7 @@
- #include <asm/mach-ath79/ar71xx_regs.h>
- 
- #include <linux/platform_data/phy-at803x.h>
-+#include <linux/ar8216_platform.h>
- 
- #include "common.h"
- #include "dev-ap9x-pci.h"
-@@ -29,6 +30,7 @@
- #include "dev-leds-gpio.h"
- #include "dev-m25p80.h"
- #include "dev-wmac.h"
-+#include "dev-usb.h"
- #include "machtypes.h"
- 
- 
-@@ -108,3 +110,70 @@ static void __init ubnt_unifiac_lite_setup(void)
- 
- MIPS_MACHINE(ATH79_MACH_UBNT_UNIFIAC_LITE, "UBNT-UF-AC-LITE", "Ubiquiti UniFi-AC-LITE",
- 	     ubnt_unifiac_lite_setup);
-+
-+static struct ar8327_pad_cfg ubnt_unifiac_pro_ar8327_pad0_cfg = {
-+	.mode = AR8327_PAD_MAC_SGMII,
-+	.sgmii_delay_en = true,
-+};
-+
-+static struct ar8327_platform_data ubnt_unifiac_pro_ar8327_data = {
-+	.pad0_cfg = &ubnt_unifiac_pro_ar8327_pad0_cfg,
-+	.port0_cfg = {
-+		.force_link = 1,
-+		.speed = AR8327_PORT_SPEED_1000,
-+		.duplex = 1,
-+		.txpause = 1,
-+		.rxpause = 1,
-+	},
-+};
-+
-+
-+static struct mdio_board_info ubnt_unifiac_pro_mdio0_info[] = {
-+	{
-+		.bus_id = "ag71xx-mdio.0",
-+		.phy_addr = 0,
-+		.platform_data = &ubnt_unifiac_pro_ar8327_data,
-+	},
-+};
-+
-+static void __init ubnt_unifiac_pro_setup(void)
-+{
-+	u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
-+
-+	ath79_register_m25p80(&ubnt_unifiac_flash_data);
-+
-+
-+	ath79_init_mac(ath79_eth0_data.mac_addr,
-+	               eeprom + UNIFIAC_MAC0_OFFSET, 0);
-+
-+	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
-+	ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
-+	ath79_eth0_data.phy_mask = BIT(0);
-+
-+	mdiobus_register_board_info(ubnt_unifiac_pro_mdio0_info,
-+	                            ARRAY_SIZE(ubnt_unifiac_pro_mdio0_info));
-+
-+	ath79_register_mdio(0, 0x00);
-+	ath79_register_eth(0);
-+
-+
-+	ath79_register_usb();
-+
-+
-+	ath79_register_wmac(eeprom + UNIFIAC_WMAC_CALDATA_OFFSET, NULL);
-+
-+
-+	ap91_pci_init(eeprom + UNIFIAC_PCI_CALDATA_OFFSET, NULL);
-+
-+
-+	ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifiac_leds_gpio),
-+	                         ubnt_unifiac_leds_gpio);
-+
-+	ath79_register_gpio_keys_polled(-1, UNIFIAC_KEYS_POLL_INTERVAL,
-+	                                ARRAY_SIZE(ubnt_unifiac_gpio_keys),
-+	                                ubnt_unifiac_gpio_keys);
-+}
-+
-+
-+MIPS_MACHINE(ATH79_MACH_UBNT_UNIFIAC_PRO, "UBNT-UF-AC-PRO", "Ubiquiti UniFi-AC-PRO",
-+	     ubnt_unifiac_pro_setup);
-diff --git a/target/linux/ar71xx/generic/profiles/ubnt.mk b/target/linux/ar71xx/generic/profiles/ubnt.mk
-index eac02406bbbffebbcb20962929fb8254edba520e..69b83985bd6623c0d6732399d3e2cc8c0af9f9f1 100644
---- a/target/linux/ar71xx/generic/profiles/ubnt.mk
-+++ b/target/linux/ar71xx/generic/profiles/ubnt.mk
-@@ -49,6 +49,17 @@ endef
- 
- $(eval $(call Profile,UBNTUNIFIACLITE))
- 
-+define Profile/UBNTUNIFIACPRO
-+	NAME:=Ubiquiti UniFi AP AC PRO
-+	PACKAGES:=kmod-ath10k ath10k-firmware-qca988x kmod-usb-core kmod-usb-ohci kmod-usb2
-+endef
-+
-+define Profile/UBNTUNIFIACPRO/Description
-+	Package set optimized for the Ubiquiti UniFi AP AC PRO.
-+endef
-+
-+$(eval $(call Profile,UBNTUNIFIACPRO))
-+
- define Profile/UBNTUNIFIOUTDOOR
- 	NAME:=Ubiquiti UniFiAP Outdoor
- 	PACKAGES:=
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 42ffc69ca3f9b1cffa542fc2d06ead2ef224d6b2..7c648f26e10c49000b848e9b300701b388410c04 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -753,7 +753,13 @@ define Device/ubnt-unifiac-lite
-   DEVICE_PROFILE := UBNT UBNTUNIFIACLITE
-   BOARDNAME := UBNT-UF-AC-LITE
- endef
--TARGET_DEVICES += ubnt-unifiac-lite
-+
-+define Device/ubnt-unifiac-pro
-+  $(Device/ubnt-unifiac)
-+  DEVICE_PROFILE := UBNT UBNTUNIFIACPRO
-+  BOARDNAME := UBNT-UF-AC-PRO
-+endef
-+TARGET_DEVICES += ubnt-unifiac-lite ubnt-unifiac-pro
- 
- rootfs_type=$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
- 
-diff --git a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-index 9a28f58f67d5f98fcd4aa83dc09698705e2dfa3e..debde6e6a552e71b551d8c01ba06af03013407bf 100644
---- a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-+++ b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-@@ -1,6 +1,6 @@
- --- a/arch/mips/ath79/machtypes.h
- +++ b/arch/mips/ath79/machtypes.h
--@@ -16,22 +16,201 @@
-+@@ -16,22 +16,202 @@
-  
-  enum ath79_mach_type {
-  	ATH79_MACH_GENERIC = 0,
-@@ -166,6 +166,7 @@
-  	ATH79_MACH_UBNT_UAP_PRO,	/* Ubiquiti UniFi AP Pro */
-  	ATH79_MACH_UBNT_UNIFI, 		/* Ubiquiti Unifi */
- +	ATH79_MACH_UBNT_UNIFIAC_LITE,	/* Ubiquiti Unifi AC LITE/LR */
-++	ATH79_MACH_UBNT_UNIFIAC_PRO,	/* Ubiquiti Unifi AC PRO */
-  	ATH79_MACH_UBNT_UNIFI_OUTDOOR,	/* Ubiquiti UnifiAP Outdoor */
- +	ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, /* Ubiquiti UnifiAP Outdoor+ */
-  	ATH79_MACH_UBNT_XM,		/* Ubiquiti Networks XM board rev 1.0 */
-@@ -1364,12 +1365,12 @@
-  
-  config ATH79_MACH_UBNT_XM
-  	bool "Ubiquiti Networks XM/UniFi boards"
--@@ -83,6 +1144,116 @@ config ATH79_MACH_UBNT_XM
-+@@ -83,6 +1144,117 @@ config ATH79_MACH_UBNT_XM
-  	  Say 'Y' here if you want your kernel to support the
-  	  Ubiquiti Networks XM (rev 1.0) board.
-  
- +config ATH79_MACH_UBNT_UNIFIAC
--+	bool "Ubiquiti UniFi AC (LITE/LR) support"
-++	bool "Ubiquiti UniFi AC (LITE/LR/PRO) support"
- +	select SOC_QCA956X
- +	select ATH79_DEV_AP9X_PCI if PCI
- +	select ATH79_DEV_ETH
-@@ -1377,6 +1378,7 @@
- +	select ATH79_DEV_LEDS_GPIO
- +	select ATH79_DEV_M25P80
- +	select ATH79_DEV_WMAC
-++	select ATH79_DEV_USB
- +
- +config ATH79_MACH_WEIO
- +	bool "WeIO board"
-@@ -1481,7 +1483,7 @@
-  endmenu
-  
-  config SOC_AR71XX
--@@ -124,7 +1295,10 @@ config ATH79_DEV_DSA
-+@@ -124,7 +1296,10 @@ config ATH79_DEV_DSA
-  config ATH79_DEV_ETH
-  	def_bool n
-  
-@@ -1493,7 +1495,7 @@
-  	def_bool n
-  
-  config ATH79_DEV_GPIO_BUTTONS
--@@ -154,6 +1328,11 @@ config ATH79_PCI_ATH9K_FIXUP
-+@@ -154,6 +1329,11 @@ config ATH79_PCI_ATH9K_FIXUP
-  	def_bool n
-  
-  config ATH79_ROUTERBOOT

+ 0 - 395
patches/openwrt/0043-ath9k-add-HSR-tuner-support-for-UniFi-Outdoor-Plus.patch

@@ -1,395 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 3 Sep 2015 23:50:51 +0200
-Subject: ath9k: add HSR tuner support for UniFi Outdoor Plus
-
-Patch-by: Stefan Rompf <stefan@loplof.de>
-
-diff --git a/package/kernel/mac80211/patches/931-ubnt-uap-plus-hsr.patch b/package/kernel/mac80211/patches/931-ubnt-uap-plus-hsr.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..8e09fee938951ab3636d23b5fe4dee3ab0e11c7a
---- /dev/null
-+++ b/package/kernel/mac80211/patches/931-ubnt-uap-plus-hsr.patch
-@@ -0,0 +1,349 @@
-+--- a/drivers/net/wireless/ath/ath9k/channel.c
-++++ b/drivers/net/wireless/ath/ath9k/channel.c
-+@@ -15,6 +15,8 @@
-+  */
-+ 
-+ #include "ath9k.h"
-++#include <linux/ath9k_platform.h>
-++#include "hsr.h"
-+ 
-+ /* Set/change channels.  If the channel is really being changed, it's done
-+  * by reseting the chip.  To accomplish this we must first cleanup any pending
-+@@ -22,6 +24,7 @@
-+  */
-+ static int ath_set_channel(struct ath_softc *sc)
-+ {
-++	struct ath9k_platform_data *pdata = sc->dev->platform_data;
-+ 	struct ath_hw *ah = sc->sc_ah;
-+ 	struct ath_common *common = ath9k_hw_common(ah);
-+ 	struct ieee80211_hw *hw = sc->hw;
-+@@ -41,6 +44,11 @@ static int ath_set_channel(struct ath_so
-+ 	ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
-+ 		chan->center_freq, chandef->width);
-+ 
-++	if (pdata && pdata->ubnt_hsr) {
-++		hsr_enable(ah, chandef->width, chan->center_freq);
-++		hsr_status(ah);
-++	}
-++
-+ 	/* update survey stats for the old channel before switching */
-+ 	spin_lock_bh(&common->cc_lock);
-+ 	ath_update_survey_stats(sc);
-+--- /dev/null
-++++ b/drivers/net/wireless/ath/ath9k/hsr.c
-+@@ -0,0 +1,223 @@
-++/*
-++ *
-++ * The MIT License (MIT)
-++ *
-++ * Copyright (c) 2015 Kirill Berezin
-++ *
-++ * Permission is hereby granted, free of charge, to any person obtaining a copy
-++ * of this software and associated documentation files (the "Software"), to deal
-++ * in the Software without restriction, including without limitation the rights
-++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-++ * copies of the Software, and to permit persons to whom the Software is
-++ * furnished to do so, subject to the following conditions:
-++ *
-++ * The above copyright notice and this permission notice shall be included in all
-++ * copies or substantial portions of the Software.
-++ *
-++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-++ * SOFTWARE.
-++ *
-++ */
-++
-++#include <linux/io.h>
-++#include <linux/slab.h>
-++#include <linux/module.h>
-++#include <linux/time.h>
-++#include <linux/bitops.h>
-++#include <linux/etherdevice.h>
-++#include <linux/rtnetlink.h>
-++#include <asm/unaligned.h>
-++
-++#include "hw.h"
-++#include "ath9k.h"
-++
-++#define HSR_GPIO_CSN 8
-++#define HSR_GPIO_CLK 6
-++#define HSR_GPIO_DOUT 7
-++#define HSR_GPIO_DIN 5
-++
-++/* delays are in useconds */
-++#define HSR_DELAY_HALF_TICK 100
-++#define HSR_DELAY_PRE_WRITE 75
-++#define HSR_DELAY_FINAL 20000
-++#define HSR_DELAY_TRAILING 200
-++
-++
-++void hsr_init(struct ath_hw* ah) {
-++	ath9k_hw_gpio_request_in(ah, HSR_GPIO_DIN, NULL);
-++	ath9k_hw_gpio_request_out(ah, HSR_GPIO_CSN, NULL,
-++				  AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-++	ath9k_hw_gpio_request_out(ah, HSR_GPIO_CLK, NULL,
-++				  AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-++	ath9k_hw_gpio_request_out(ah, HSR_GPIO_DOUT, NULL,
-++				  AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-++
-++	ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1);
-++	ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
-++	ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, 0);
-++
-++	udelay(HSR_DELAY_TRAILING);
-++}
-++
-++static u32 hsr_write_byte(struct ath_hw* ah, int delay, u32 value){
-++	struct ath_common *common = ath9k_hw_common(ah);
-++	int i;
-++	u32 rval = 0;
-++
-++	udelay(delay);
-++
-++	ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
-++	udelay(HSR_DELAY_HALF_TICK);
-++
-++	ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 0);
-++	udelay(HSR_DELAY_HALF_TICK);
-++
-++	for( i = 0; i < 8; ++i) {
-++		rval = rval << 1;
-++
-++		// pattern is left to right, that is 7-th bit runs first
-++		ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, (value >> (7 - i)) & 0x1);
-++		udelay(HSR_DELAY_HALF_TICK);
-++
-++		ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 1);
-++		udelay(HSR_DELAY_HALF_TICK);
-++
-++		rval |= ath9k_hw_gpio_get(ah, HSR_GPIO_DIN);
-++
-++		ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
-++		udelay(HSR_DELAY_HALF_TICK);
-++	}
-++
-++	ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1);
-++	udelay(HSR_DELAY_HALF_TICK);
-++
-++	ath_dbg(common, CONFIG, "hsr_write_byte: write byte %d return value is %d %c\n",
-++		value, rval, rval > 32 ? rval : '-');
-++
-++	return rval & 0xff;
-++}
-++
-++static int hsr_write_a_chain(struct ath_hw* ah, char* chain, int items) {
-++	int i = 0;
-++	int status = 0;
-++
-++	// a preamble
-++	hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-++	status = hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-++
-++	// clear HSR's reply buffer
-++	if (status) {
-++		int loop = 0;
-++		for ( loop = 0; (loop < 42) && status; ++loop) {
-++			status = hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-++		}
-++		if ( loop >= 42) {
-++			ATH_DBG_WARN(1, "hsr_write_a_chain: can't clear an output buffer after a 42 cycles.\n");
-++			return -1;
-++		}
-++	}
-++
-++	for ( i =0; (i < items) && ( 0 != chain[i]); ++i) {
-++		hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, (u32)chain[i]);
-++	}
-++
-++	hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-++	mdelay(HSR_DELAY_FINAL / 1000);
-++
-++	// reply
-++	memset(chain, 0, items);
-++
-++	hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-++	udelay(HSR_DELAY_TRAILING);
-++
-++	for ( i = 0; i < (items - 1); ++i) {
-++		u32 ret;
-++		if ( 0 != (ret = hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0))) {
-++			chain[i] = (char)ret;
-++		} else {
-++			break;
-++		}
-++		udelay(HSR_DELAY_TRAILING);
-++	}
-++
-++	return (1 < i) ? simple_strtol(chain + 1, NULL, 10) : 0;
-++}
-++
-++int hsr_disable(struct ath_hw* ah) {
-++	char cmd[10] = {'b', '4', '0', 0, 0, 0, 0, 0, 0, 0};
-++	int  ret;
-++
-++	ret = hsr_write_a_chain(ah, cmd, sizeof(cmd));
-++	if ( (ret > 0) && (*cmd == 'B')) {
-++		return 0;
-++	}
-++
-++	return -1;
-++}
-++
-++int hsr_enable(struct ath_hw* ah, int bw, int fq) {
-++	char cmd[10];
-++	int ret;
-++
-++	/* Bandwidth argument is 0 sometimes. Assume default 802.11bgn
-++	   20MHz on invalid values */
-++	if ( (bw != 5) && (bw != 10) && (bw != 20) && (bw != 40)) {
-++		bw = 20;
-++	}
-++
-++	memset(cmd, 0, sizeof(cmd));
-++	*cmd = 'b'; // 98
-++	snprintf(cmd + 1, 3, "%02d", bw);
-++
-++	ret = hsr_write_a_chain(ah, cmd, sizeof(cmd));
-++	if ( (*cmd != 'B') || (ret != bw)) {
-++		ATH_DBG_WARN(1, "hsr_enable: failed changing bandwidth -> set (%d,%d) reply (%d, %d) \n", 'b', bw, *cmd, ret);
-++		return -1;
-++	}
-++
-++	memset(cmd, 0, sizeof(cmd));
-++	*cmd = 'x'; // 120
-++	ret = hsr_write_a_chain(ah, cmd, sizeof(cmd));
-++	if ( *cmd != 'X') {
-++		ATH_DBG_WARN(1, "hsr_enable: failed 'x' command -> reply (%d, %d) \n", *cmd, ret);
-++		return -1;
-++	}
-++
-++	memset(cmd, 0, sizeof(cmd));
-++	*cmd = 'm'; // 109
-++	ret = hsr_write_a_chain(ah, cmd, sizeof(cmd));
-++	if ( *cmd != 'M') {
-++		ATH_DBG_WARN(1, "hsr_enable: failed 'm' command -> reply (%d, %d) \n", *cmd, ret);
-++		return  -1;
-++	}
-++
-++	memset(cmd, 0, sizeof(cmd));
-++	*cmd = 'f'; // 102
-++	snprintf(cmd + 1, 6, "%05d", fq);
-++	ret = hsr_write_a_chain(ah, cmd, sizeof(cmd));
-++	if ( (*cmd != 'F') && (ret != fq)) {
-++		ATH_DBG_WARN(1, "hsr_enable: failed set frequency -> reply (%d, %d) \n", *cmd, ret);
-++		return -1;
-++	}
-++
-++	return 0;
-++}
-++
-++int hsr_status(struct ath_hw* ah) {
-++	char cmd[10] = {'s', 0, 0, 0, 0, 0, 0, 0, 0, 0}; // 115
-++	int ret;
-++
-++	ret = hsr_write_a_chain(ah, cmd, sizeof(cmd));
-++	if ( (*cmd != 'S')) {
-++		ATH_DBG_WARN(1, "hsr_status: returned %d,%d \n", *cmd, ret);
-++		return -1;
-++	}
-++
-++	return 0;
-++}
-++
-+--- /dev/null
-++++ b/drivers/net/wireless/ath/ath9k/hsr.h
-+@@ -0,0 +1,33 @@
-++/*
-++ * The MIT License (MIT)
-++ *
-++ * Copyright (c) 2015 Kirill Berezin
-++ *
-++ * Permission is hereby granted, free of charge, to any person obtaining a copy
-++ * of this software and associated documentation files (the "Software"), to deal
-++ * in the Software without restriction, including without limitation the rights
-++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-++ * copies of the Software, and to permit persons to whom the Software is
-++ * furnished to do so, subject to the following conditions:
-++ *
-++ * The above copyright notice and this permission notice shall be included in all
-++ * copies or substantial portions of the Software.
-++ *
-++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-++ * SOFTWARE.
-++ */
-++
-++#ifndef HSR_H_
-++#define HSR_H_
-++
-++void hsr_init(struct ath_hw* ah);
-++int hsr_disable(struct ath_hw* ah);
-++int hsr_enable(struct ath_hw* ah, int bw, int fq);
-++int hsr_status(struct ath_hw* ah);
-++
-++#endif /* HSR_H_ */
-+--- a/drivers/net/wireless/ath/ath9k/main.c
-++++ b/drivers/net/wireless/ath/ath9k/main.c
-+@@ -16,8 +16,10 @@
-+ 
-+ #include <linux/nl80211.h>
-+ #include <linux/delay.h>
-++#include <linux/ath9k_platform.h>
-+ #include "ath9k.h"
-+ #include "btcoex.h"
-++#include "hsr.h"
-+ 
-+ u8 ath9k_parse_mpdudensity(u8 mpdudensity)
-+ {
-+@@ -652,6 +654,7 @@ void ath_reset_work(struct work_struct *
-+ static int ath9k_start(struct ieee80211_hw *hw)
-+ {
-+ 	struct ath_softc *sc = hw->priv;
-++	struct ath9k_platform_data *pdata = sc->dev->platform_data;
-+ 	struct ath_hw *ah = sc->sc_ah;
-+ 	struct ath_common *common = ath9k_hw_common(ah);
-+ 	struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan;
-+@@ -727,6 +730,11 @@ static int ath9k_start(struct ieee80211_
-+ 		ath9k_hw_set_gpio(ah, ah->led_pin,
-+ 				  (ah->config.led_active_high) ? 1 : 0);
-+ 
-++	if (pdata && pdata->ubnt_hsr) {
-++		hsr_init(ah);
-++		hsr_disable(ah);
-++	}
-++
-+ 	/*
-+ 	 * Reset key cache to sane defaults (all entries cleared) instead of
-+ 	 * semi-random values after suspend/resume.
-+--- a/drivers/net/wireless/ath/ath9k/Makefile
-++++ b/drivers/net/wireless/ath/ath9k/Makefile
-+@@ -6,7 +6,8 @@ ath9k-y +=	beacon.o \
-+ 		xmit.o \
-+ 		link.o \
-+ 		antenna.o \
-+-		channel.o
-++		channel.o \
-++		hsr.o
-+ 
-+ ath9k-$(CPTCFG_ATH9K_BTCOEX_SUPPORT) += mci.o
-+ ath9k-$(CPTCFG_ATH9K_PCI) += pci.o
-+--- a/include/linux/ath9k_platform.h
-++++ b/include/linux/ath9k_platform.h
-+@@ -54,6 +54,8 @@ struct ath9k_platform_data {
-+ 	unsigned num_btns;
-+ 	const struct gpio_keys_button *btns;
-+ 	unsigned btn_poll_interval;
-++
-++	bool ubnt_hsr;
-+ };
-+ 
-+ #endif /* _LINUX_ATH9K_PLATFORM_H */
-diff --git a/target/linux/ar71xx/patches-3.18/608-MIPS-ath79-ubnt-xm-add-more-boards.patch b/target/linux/ar71xx/patches-3.18/608-MIPS-ath79-ubnt-xm-add-more-boards.patch
-index 78035131db93f3e465585d7e96bfae9e88783d28..d865ed29ac268b6b49644c0841be6dfeace75038 100644
---- a/target/linux/ar71xx/patches-3.18/608-MIPS-ath79-ubnt-xm-add-more-boards.patch
-+++ b/target/linux/ar71xx/patches-3.18/608-MIPS-ath79-ubnt-xm-add-more-boards.patch
-@@ -254,6 +254,7 @@
- +	ath79_register_eth(0);
- +	ath79_register_eth(1);
- +
-++	ap9x_pci_get_wmac_data(0)->ubnt_hsr = true;
- +	ap91_pci_init(ee, NULL);
- +
- +	ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_plus_leds_gpio),
-diff --git a/target/linux/generic/patches-3.18/150-ath9k_ubnt_hsr_filter.patch b/target/linux/generic/patches-3.18/150-ath9k_ubnt_hsr_filter.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..b8844f1341f9a8a478730ef6ac440833b84b3e98
---- /dev/null
-+++ b/target/linux/generic/patches-3.18/150-ath9k_ubnt_hsr_filter.patch
-@@ -0,0 +1,16 @@
-+Flag that this platform is an Ubiquiti UniFi Outdoor Plus
-+containing a RF filter in ath9k's receive path.
-+
-+Signed-off-by: Stefan Rompf <stefan@loplof.de>
-+
-+--- a/include/linux/ath9k_platform.h
-++++ b/include/linux/ath9k_platform.h
-+@@ -54,6 +54,8 @@ struct ath9k_platform_data {
-+ 	unsigned num_btns;
-+ 	const struct gpio_keys_button *btns;
-+ 	unsigned btn_poll_interval;
-++
-++	bool ubnt_hsr;
-+ };
-+ 
-+ #endif /* _LINUX_ATH9K_PLATFORM_H */

+ 0 - 41
patches/openwrt/0044-ar71xx-Send-power-to-USB-port-on-WNR2200.patch

@@ -1,41 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 29 May 2016 11:37:08 +0200
-Subject: ar71xx: Send power to USB port on WNR2200
-
-This patch fixes ticket #15267 by enabling power on the
-WNR2200's USB port. At present, the USB port on the WNR2200
-is non-functional due to it not receiving power.
-
-This patch defines an additional GPIO pin, but none of the
-current GPIO definitions have been modified.
-
-Signed-off-by: Riley Baird <BM-2cVqnDuYbAU5do2DfJTrN7ZbAJ246S4XiX@bitmessage.ch>
-
-Backport of r47236
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-index 0087cac62087786d45bd5c8b68b2ec2ce3b5715e..5d23f21763cd9f4ddafc97f79ff47e819a18f2a6 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-@@ -36,7 +36,7 @@
- #define WNR2200_GPIO_LED_LAN4_GREEN	16
- #define WNR2200_GPIO_LED_PWR_AMBER	21
- #define WNR2200_GPIO_LED_PWR_GREEN	22
--
-+#define WNR2200_GPIO_USB_5V		4
- #define WNR2200_GPIO_USB_POWER		24
- 
- #define WNR2200_KEYS_POLL_INTERVAL	20 /* msecs */
-@@ -128,9 +128,9 @@ static void __init wnr2200_setup(void)
- 					wnr2200_leds_gpio);
- 
- 	/* enable power for the USB port */
--	gpio_request_one(WNR2200_GPIO_USB_POWER,
--			GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
--			"USB power");
-+	ap9x_pci_setup_wmac_gpio(0,
-+		BIT(WNR2200_GPIO_USB_5V),
-+		BIT(WNR2200_GPIO_USB_5V));
- 
- 	ath79_register_usb();
- }

+ 0 - 86
patches/openwrt/0045-ar71xx-WNR2200-fix-for-random-WLAN-MAC.patch

@@ -1,86 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 29 May 2016 11:45:14 +0200
-Subject: ar71xx: WNR2200: fix for random WLAN MAC
-
-Fix for invalid/random/duplicate WLAN MAC address in WNR2200.
-Permanent platform MAC is calculated and assigned during system startup.
-WLAN MAC follows wired Ethernet interface addresses.
-
-Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
-
-Backport of r49100
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-index 5d23f21763cd9f4ddafc97f79ff47e819a18f2a6..37ffc4c56be33be96c43078117d7b123679378b3 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-@@ -12,6 +12,7 @@
- 
- #include <linux/mtd/mtd.h>
- #include <linux/mtd/partitions.h>
-+#include <linux/kernel.h> /* for max() macro */
- 
- #include <asm/mach-ath79/ath79.h>
- 
-@@ -45,6 +46,7 @@
- #define WNR2200_MAC0_OFFSET		0
- #define WNR2200_MAC1_OFFSET		6
- #define WNR2200_PCIE_CALDATA_OFFSET	0x1000
-+#define WNR2200_WMAC_OFFSET		0x108c	/* wireless MAC is inside ART */
- 
- static struct gpio_led wnr2200_leds_gpio[] __initdata = {
- 	{
-@@ -102,9 +104,40 @@ static struct gpio_led wnr2200_leds_gpio[] __initdata = {
- 	}
- };
- 
-+/*
-+ * For WNR2200 ART flash area used for WLAN MAC is usually empty (0xff)
-+ * so ath9k driver uses random MAC instead each time module is loaded.
-+ * OpenWrt's original fix was to copy eth1 address to WLAN interface.
-+ * New solution does not duplicate hardware addresses and is taken from
-+ * WNR2000v3 code. It assigns permanent WLAN MAC equal to ethN's MAC
-+ * plus 1, so network interfaces get sequential addresses.
-+ * If ART wireless MAC address field has been filled by user, use it.
-+ */
-+static void __init wnr2200_get_wmac(u8 *wmac_gen_addr, int mac0_art_offset,
-+				    int mac1_art_offset, int wmac_art_offset)
-+{
-+	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
-+	u8 *eth0_mac_addr = (u8 *) (art + mac0_art_offset);
-+	u8 *eth1_mac_addr = (u8 *) (art + mac1_art_offset);
-+	u8 *wlan_mac_addr = (u8 *) (art + wmac_art_offset);
-+
-+	/* only 0xff if all bits are set - address is invalid, empty area */
-+	if ((wlan_mac_addr[0] & wlan_mac_addr[1] & wlan_mac_addr[2] &
-+	     wlan_mac_addr[3] & wlan_mac_addr[4] & wlan_mac_addr[5]) == 0xff) {
-+		memcpy(wmac_gen_addr, eth0_mac_addr, 5);
-+		wmac_gen_addr[5] = max(eth0_mac_addr[5], eth1_mac_addr[5]) + 1;
-+
-+		/* Avoid potential conflict in case max(0xff,0x00)+1==0x00 */
-+		if (!wmac_gen_addr[5])
-+			wmac_gen_addr[5] = 1;
-+	} else
-+		memcpy(wmac_gen_addr, wlan_mac_addr, 6);
-+}
-+
- static void __init wnr2200_setup(void)
- {
- 	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
-+	u8 wlan_mac_addr[6];
- 
- 	ath79_register_mdio(0, 0x0);
- 
-@@ -121,8 +154,10 @@ static void __init wnr2200_setup(void)
- 	ath79_register_eth(1);
- 
- 	ath79_register_m25p80(NULL);
--	ap91_pci_init(art + WNR2200_PCIE_CALDATA_OFFSET,
--		      art + WNR2200_MAC1_OFFSET);
-+
-+	wnr2200_get_wmac(wlan_mac_addr, WNR2200_MAC0_OFFSET,
-+			 WNR2200_MAC1_OFFSET, WNR2200_WMAC_OFFSET);
-+	ap91_pci_init(art + WNR2200_PCIE_CALDATA_OFFSET, wlan_mac_addr);
- 
- 	ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2200_leds_gpio),
- 					wnr2200_leds_gpio);

+ 0 - 251
patches/openwrt/0046-ar71xx-WNR2200-enable-control-of-all-LEDs-and-buttons.patch

@@ -1,251 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 29 May 2016 11:50:03 +0200
-Subject: ar71xx: WNR2200: enable control of all LEDs and buttons
-
-This patch provides full GPIO support for WNR2200 (LEDs and buttons).
-It exposes all LEDs to operating system, including Ethernet ones.
-
-Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
-
-Backport of r49101
-
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-index f4d523418c8d59e3c96dbe3d68eedd8d85e33546..b8677960249c1e05703570fdf2be4197bde5cac5 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-@@ -600,6 +600,21 @@ wnr2000-v4)
- 	ucidef_set_led_usbdev "usb" "USB" "netgear:amber:status" "1-1"
- 	;;
- 
-+wnr2200)
-+	ucidef_set_led_netdev "wan-amber" "WAN (amber)" "netgear:amber:wan" "eth0"
-+	ucidef_set_led_default "wan-green" "WAN (green)" "netgear:green:wan" "0"
-+	ucidef_set_led_netdev "wlan" "WLAN" "netgear:blue:wlan" "wlan0"
-+	ucidef_set_led_switch "lan1green" "LAN1 (green)" "netgear:green:lan1" "switch0" "0x02" "0x04"
-+	ucidef_set_led_switch "lan2green" "LAN2 (green)" "netgear:green:lan2" "switch0" "0x04" "0x04"
-+	ucidef_set_led_switch "lan3green" "LAN3 (green)" "netgear:green:lan3" "switch0" "0x08" "0x04"
-+	ucidef_set_led_switch "lan4green" "LAN4 (green)" "netgear:green:lan4" "switch0" "0x10" "0x04"
-+	ucidef_set_led_switch "lan1amber" "LAN1 (amber)" "netgear:amber:lan1" "switch0" "0x02" "0x02"
-+	ucidef_set_led_switch "lan2amber" "LAN2 (amber)" "netgear:amber:lan2" "switch0" "0x04" "0x02"
-+	ucidef_set_led_switch "lan3amber" "LAN3 (amber)" "netgear:amber:lan3" "switch0" "0x08" "0x02"
-+	ucidef_set_led_switch "lan4amber" "LAN4 (amber)" "netgear:amber:lan4" "switch0" "0x10" "0x02"
-+	ucidef_set_led_usbdev "usb" "USB" "netgear:green:usb" "1-1"
-+	;;
-+
- wpn824n)
- 	ucidef_set_led_netdev "wan-amber" "WAN (amber)" "netgear:amber:wan" "eth0"
- 	ucidef_set_led_wlan "wlan" "WLAN" "netgear:blue:wlan" "phy0tpt"
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-index 37ffc4c56be33be96c43078117d7b123679378b3..258d254cf4abfc01a4d859f3f464b2a25aeec165 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
-@@ -15,6 +15,8 @@
- #include <linux/kernel.h> /* for max() macro */
- 
- #include <asm/mach-ath79/ath79.h>
-+#include <asm/mach-ath79/ar71xx_regs.h> /* needed to disable switch LEDs */
-+#include "common.h" /* needed to disable switch LEDs */
- 
- #include "dev-ap9x-pci.h"
- #include "dev-eth.h"
-@@ -24,21 +26,28 @@
- #include "dev-usb.h"
- #include "machtypes.h"
- 
-+/* WNR2200 - connected through AR7241 */
- #define WNR2200_GPIO_LED_LAN2_AMBER	0
- #define WNR2200_GPIO_LED_LAN4_AMBER	1
--#define WNR2200_GPIO_LED_WPS		5
--#define WNR2200_GPIO_LED_WAN_GREEN	7
--#define WNR2200_GPIO_LED_USB		8
-+#define WNR2200_GPIO_LED_LAN1_AMBER	6 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
-+#define WNR2200_GPIO_LED_WPS_GREEN	7 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
-+#define WNR2200_GPIO_LED_USB_GREEN	8 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
- #define WNR2200_GPIO_LED_LAN3_AMBER	11
- #define WNR2200_GPIO_LED_WAN_AMBER	12
--#define WNR2200_GPIO_LED_LAN1_GREEN	13
--#define WNR2200_GPIO_LED_LAN2_GREEN	14
--#define WNR2200_GPIO_LED_LAN3_GREEN	15
--#define WNR2200_GPIO_LED_LAN4_GREEN	16
--#define WNR2200_GPIO_LED_PWR_AMBER	21
--#define WNR2200_GPIO_LED_PWR_GREEN	22
--#define WNR2200_GPIO_USB_5V		4
--#define WNR2200_GPIO_USB_POWER		24
-+#define WNR2200_GPIO_LED_LAN1_GREEN	13 /* AR724X_..._ETH_SWITCH_LED0 */
-+#define WNR2200_GPIO_LED_LAN2_GREEN	14 /* AR724X_..._ETH_SWITCH_LED1 */
-+#define WNR2200_GPIO_LED_LAN3_GREEN	15 /* AR724X_..._ETH_SWITCH_LED2 */
-+#define WNR2200_GPIO_LED_LAN4_GREEN	16 /* AR724X_..._ETH_SWITCH_LED3 */
-+#define WNR2200_GPIO_LED_WAN_GREEN	17 /* AR724X_..._ETH_SWITCH_LED4 */
-+
-+/* WNR2200 - connected through AR9287 */
-+#define WNR2200_GPIO_WMAC_LED_WLAN_BLUE		0
-+#define WNR2200_GPIO_WMAC_LED_TEST_AMBER	1
-+#define WNR2200_GPIO_WMAC_LED_POWER_GREEN	2
-+#define WNR2200_GPIO_WMAC_BTN_RFKILL		3
-+#define WNR2200_GPIO_WMAC_USB_5V		4
-+#define WNR2200_GPIO_WMAC_BTN_WPS		5
-+#define WNR2200_GPIO_WMAC_BTN_RESET		6
- 
- #define WNR2200_KEYS_POLL_INTERVAL	20 /* msecs */
- #define WNR2200_KEYS_DEBOUNCE_INTERVAL	(3 * WNR2200_KEYS_POLL_INTERVAL)
-@@ -50,30 +59,22 @@
- 
- static struct gpio_led wnr2200_leds_gpio[] __initdata = {
- 	{
--		.name		= "netgear:amber:lan2",
--		.gpio		= WNR2200_GPIO_LED_LAN2_AMBER,
--		.active_low	= 1,
--	}, {
--		.name		= "netgear:amber:lan4",
--		.gpio		= WNR2200_GPIO_LED_LAN4_AMBER,
--		.active_low	= 1,
--	}, {
--		.name		= "netgear:green:wps",
--		.gpio		= WNR2200_GPIO_LED_WPS,
--		.active_low	= 1,
--	}, {
--		.name		= "netgear:green:wan",
--		.gpio		= WNR2200_GPIO_LED_WAN_GREEN,
-+		.name		= "netgear:amber:lan1",
-+		.gpio		= WNR2200_GPIO_LED_LAN1_AMBER,
- 		.active_low	= 1,
- 	}, {
--		.name		= "netgear:green:usb",
--		.gpio		= WNR2200_GPIO_LED_USB,
-+		.name		= "netgear:amber:lan2",
-+		.gpio		= WNR2200_GPIO_LED_LAN2_AMBER,
- 		.active_low	= 1,
- 	}, {
- 		.name		= "netgear:amber:lan3",
- 		.gpio		= WNR2200_GPIO_LED_LAN3_AMBER,
- 		.active_low	= 1,
- 	}, {
-+		.name		= "netgear:amber:lan4",
-+		.gpio		= WNR2200_GPIO_LED_LAN4_AMBER,
-+		.active_low	= 1,
-+	}, {
- 		.name		= "netgear:amber:wan",
- 		.gpio		= WNR2200_GPIO_LED_WAN_AMBER,
- 		.active_low	= 1,
-@@ -94,12 +95,56 @@ static struct gpio_led wnr2200_leds_gpio[] __initdata = {
- 		.gpio		= WNR2200_GPIO_LED_LAN4_GREEN,
- 		.active_low	= 1,
- 	}, {
--		.name		= "netgear:amber:power",
--		.gpio		= WNR2200_GPIO_LED_PWR_AMBER,
-+		.name		= "netgear:green:usb",
-+		.gpio		= WNR2200_GPIO_LED_USB_GREEN,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "netgear:green:wan",
-+		.gpio		= WNR2200_GPIO_LED_WAN_GREEN,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "netgear:green:wps",
-+		.gpio		= WNR2200_GPIO_LED_WPS_GREEN,
-+		.active_low	= 1,
-+	}
-+};
-+
-+static const char *wnr2200_wmac_led_name = "netgear:blue:wlan";
-+
-+static struct gpio_led wnr2200_wmac_leds_gpio[] = {
-+	{
-+		.name		= "netgear:amber:test",
-+		.gpio		= WNR2200_GPIO_WMAC_LED_TEST_AMBER,
- 		.active_low	= 1,
- 	}, {
- 		.name		= "netgear:green:power",
--		.gpio		= WNR2200_GPIO_LED_PWR_GREEN,
-+		.gpio		= WNR2200_GPIO_WMAC_LED_POWER_GREEN,
-+		.active_low	= 1,
-+		.default_state	= LEDS_GPIO_DEFSTATE_ON,
-+	}
-+};
-+
-+static struct gpio_keys_button wnr2200_wmac_keys_gpio[] = {
-+	{
-+		.desc		= "reset",
-+		.type		= EV_KEY,
-+		.code		= KEY_RESTART,
-+		.debounce_interval = WNR2200_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio		= WNR2200_GPIO_WMAC_BTN_RESET,
-+		.active_low	= 1,
-+	}, {
-+		.desc		= "rfkill",
-+		.type		= EV_KEY,
-+		.code		= KEY_RFKILL,
-+		.debounce_interval = WNR2200_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio		= WNR2200_GPIO_WMAC_BTN_RFKILL,
-+		.active_low	= 1,
-+	}, {
-+		.desc		= "wps",
-+		.type		= EV_KEY,
-+		.code		= KEY_WPS_BUTTON,
-+		.debounce_interval = WNR2200_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio		= WNR2200_GPIO_WMAC_BTN_WPS,
- 		.active_low	= 1,
- 	}
- };
-@@ -139,14 +184,32 @@ static void __init wnr2200_setup(void)
- 	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
- 	u8 wlan_mac_addr[6];
- 
-+	/*
-+	 * Disable JTAG to use all AR724X GPIO LEDs. Disable CLKs.
-+	 * Allow OS to control all link LEDs.
-+	 */
-+	ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
-+				  AR724X_GPIO_FUNC_UART_EN,
-+				  AR724X_GPIO_FUNC_CLK_OBS1_EN |
-+				  AR724X_GPIO_FUNC_CLK_OBS2_EN |
-+				  AR724X_GPIO_FUNC_CLK_OBS3_EN |
-+				  AR724X_GPIO_FUNC_CLK_OBS4_EN |
-+				  AR724X_GPIO_FUNC_CLK_OBS5_EN |
-+				  AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
-+				  AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
-+				  AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
-+				  AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
-+				  AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
-+				  AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
-+
- 	ath79_register_mdio(0, 0x0);
- 
--	ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2200_MAC0_OFFSET, 0);
-+	ath79_init_mac(ath79_eth0_data.mac_addr, art + WNR2200_MAC0_OFFSET, 0);
- 	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
- 	ath79_eth0_data.speed = SPEED_100;
- 	ath79_eth0_data.duplex = DUPLEX_FULL;
- 
--	ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2200_MAC1_OFFSET, 0);
-+	ath79_init_mac(ath79_eth1_data.mac_addr, art + WNR2200_MAC1_OFFSET, 0);
- 	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
- 	ath79_eth1_data.phy_mask = 0x10;
- 
-@@ -160,12 +223,22 @@ static void __init wnr2200_setup(void)
- 	ap91_pci_init(art + WNR2200_PCIE_CALDATA_OFFSET, wlan_mac_addr);
- 
- 	ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2200_leds_gpio),
--					wnr2200_leds_gpio);
-+				 wnr2200_leds_gpio);
-+
-+	ap9x_pci_setup_wmac_led_pin(0, WNR2200_GPIO_WMAC_LED_WLAN_BLUE);
-+	ap9x_pci_setup_wmac_led_name(0, wnr2200_wmac_led_name);
-+
-+	ap9x_pci_setup_wmac_leds(0, wnr2200_wmac_leds_gpio,
-+				 ARRAY_SIZE(wnr2200_wmac_leds_gpio));
-+
-+	/* All 3 buttons are connected to wireless chip */
-+	ap9x_pci_setup_wmac_btns(0, wnr2200_wmac_keys_gpio,
-+				 ARRAY_SIZE(wnr2200_wmac_keys_gpio),
-+				 WNR2200_KEYS_POLL_INTERVAL);
- 
- 	/* enable power for the USB port */
--	ap9x_pci_setup_wmac_gpio(0,
--		BIT(WNR2200_GPIO_USB_5V),
--		BIT(WNR2200_GPIO_USB_5V));
-+	ap9x_pci_setup_wmac_gpio(0, BIT(WNR2200_GPIO_WMAC_USB_5V),
-+				 BIT(WNR2200_GPIO_WMAC_USB_5V));
- 
- 	ath79_register_usb();
- }

+ 0 - 326
patches/openwrt/0047-ar71xx-add-GL-AR150-support.patch

@@ -1,326 +0,0 @@
-From: Jan Niehusmann <jan@gondor.com>
-Date: Wed, 15 Jun 2016 14:57:47 +0200
-Subject: ar71xx: add GL-AR150 support
-
-patch from https://github.com/domino-team/OpenWrt-patches
-
-https://raw.githubusercontent.com/domino-team/OpenWrt-patches/master/AR150%2C%20AR300%2C%20Domino%20-%20CC1505/000-gl-ar150-cc.patch
-
-(and fixed indentation in target/linux/ar71xx/base-files/lib/ar71xx.sh)
-
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-index b8677960249c1e05703570fdf2be4197bde5cac5..d81358d6bf9103ffeb2929b06d3ab01efffe931c 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-@@ -188,6 +188,10 @@ dlan-pro-1200-ac)
- 	ucidef_set_led_trigger_gpio "plcr" "dLAN" "devolo:error:dlan" "16" "0"
- 	;;
- 
-+gl-ar150)
-+	ucidef_set_led_wlan "wlan" "WLAN" "gl_ar150:wlan" "phy0tpt"
-+	;;
-+
- gl-inet)
- 	ucidef_set_led_netdev "lan" "LAN" "gl-connect:green:lan" "eth1"
- 	ucidef_set_led_wlan "wlan" "WLAN" "gl-connect:red:wlan" "phy0tpt"
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index b59844eac49a1269edb88890d89b0b4d8a7121d0..ac3deb8aa2ed4717e2bd682cb4ffd7d32c50134f 100755
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -383,6 +383,7 @@ dir-505-a1)
- alfa-ap96 |\
- alfa-nx |\
- ap83 |\
-+gl-ar150 |\
- gl-inet |\
- jwap003 |\
- pb42 |\
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index aded7ad117ffa1c1347c6f457c210d60b8e4df58..f242980b3e401f2e9de2b8abe7e984b24a71db5a 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -503,6 +503,9 @@ ar71xx_board_detect() {
- 		name="gl-inet"
- 		gl_inet_board_detect
- 		;;
-+	*"GL AR150")
-+		name="gl-ar150"
-+		;;
- 	*"EnGenius EPG5000")
- 		name="epg5000"
- 		;;
-diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index 0228f14774d5873a52f19b60ed84389c7be86e51..d816f211891d6a259930f2781574504ea62b4e16 100755
---- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-@@ -216,6 +216,7 @@ platform_check_image() {
- 	dlan-pro-500-wp | \
- 	dlan-pro-1200-ac | \
- 	dragino2 | \
-+	gl-ar150 | \
- 	epg5000 | \
- 	esr1750 | \
- 	esr900 | \
-diff --git a/target/linux/ar71xx/config-3.18 b/target/linux/ar71xx/config-3.18
-index a068cc5768aed6f29a67de27d24f00dc57e0695a..d4d92738d0ab010e1d43ebed0baef34fd9bc3f9d 100644
---- a/target/linux/ar71xx/config-3.18
-+++ b/target/linux/ar71xx/config-3.18
-@@ -70,6 +70,7 @@ CONFIG_ATH79_MACH_ESR1750=y
- CONFIG_ATH79_MACH_ESR900=y
- CONFIG_ATH79_MACH_EW_DORIN=y
- CONFIG_ATH79_MACH_F9K1115V2=y
-+CONFIG_ATH79_MACH_GL_AR150=y
- CONFIG_ATH79_MACH_GL_INET=y
- CONFIG_ATH79_MACH_GS_MINIBOX_V1=y
- CONFIG_ATH79_MACH_GS_OOLITE=y
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar150.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar150.c
-new file mode 100644
-index 0000000000000000000000000000000000000000..310182cc8e9c22e2bfcb168996d4f01d117dc103
---- /dev/null
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar150.c
-@@ -0,0 +1,125 @@
-+/*
-+ *  GL_ar150 board support
-+ *
-+ *  Copyright (C) 2011 dongyuqi <729650915@qq.com>
-+ *  Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
-+ *  Copyright (C) 2013 alzhao <alzhao@gmail.com>
-+ *  Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
-+ *
-+ *  This program is free software; you can redistribute it and/or modify it
-+ *  under the terms of the GNU General Public License version 2 as published
-+ *  by the Free Software Foundation.
-+*/
-+
-+#include <linux/gpio.h>
-+
-+#include <asm/mach-ath79/ath79.h>
-+
-+#include "dev-eth.h"
-+#include "dev-gpio-buttons.h"
-+#include "dev-leds-gpio.h"
-+#include "dev-m25p80.h"
-+#include "dev-usb.h"
-+#include "dev-wmac.h"
-+#include "machtypes.h"
-+
-+#define GL_AR150_GPIO_LED_WLAN		   0
-+#define GL_AR150_GPIO_LED_LAN		   13
-+#define GL_AR150_GPIO_LED_WAN		   15 
-+
-+#define GL_AR150_GPIO_BIN_USB         6
-+#define GL_AR150_GPIO_BTN_MANUAL      7
-+#define GL_AR150_GPIO_BTN_AUTO	   	   8
-+#define GL_AR150_GPIO_BTN_RESET	   11
-+
-+#define GL_AR150_KEYS_POLL_INTERVAL   20	/* msecs */
-+#define GL_AR150_KEYS_DEBOUNCE_INTERVAL	(3 * GL_AR150_KEYS_POLL_INTERVAL)
-+
-+#define GL_AR150_MAC0_OFFSET	0x0000
-+#define GL_AR150_MAC1_OFFSET	0x0000
-+#define GL_AR150_CALDATA_OFFSET	0x1000
-+#define GL_AR150_WMAC_MAC_OFFSET	0x0000
-+
-+static struct gpio_led gl_ar150_leds_gpio[] __initdata = {
-+	{
-+		.name = "gl_ar150:wlan",
-+		.gpio = GL_AR150_GPIO_LED_WLAN,
-+		.active_low = 0,
-+	},
-+	{
-+		.name = "gl_ar150:lan",
-+		.gpio = GL_AR150_GPIO_LED_LAN,
-+		.active_low = 0,
-+	},
-+	{
-+		.name = "gl_ar150:wan",
-+		.gpio = GL_AR150_GPIO_LED_WAN,
-+		.active_low = 0,
-+ 		.default_state = 1,
-+	},
-+};
-+
-+static struct gpio_keys_button gl_ar150_gpio_keys[] __initdata = {
-+	{
-+		.desc = "BTN_7",
-+		.type = EV_KEY,
-+		.code = BTN_7,
-+		.debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio = GL_AR150_GPIO_BTN_MANUAL,
-+		.active_low = 0,
-+	},
-+	{
-+		.desc = "BTN_8",
-+		.type = EV_KEY,
-+		.code = BTN_8,
-+		.debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio = GL_AR150_GPIO_BTN_AUTO,
-+		.active_low = 0,
-+	},
-+	{
-+		.desc = "reset",
-+		.type = EV_KEY,
-+		.code = KEY_RESTART,
-+		.debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio = GL_AR150_GPIO_BTN_RESET,
-+		.active_low = 0,
-+	},
-+};
-+
-+static void __init gl_ar150_setup(void)
-+{
-+
-+	/* ART base address */
-+	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
-+
-+	/* disable PHY_SWAP and PHY_ADDR_SWAP bits */
-+	ath79_setup_ar933x_phy4_switch(false, false);
-+
-+	/* register flash. */
-+	ath79_register_m25p80(NULL);
-+
-+	/* register gpio LEDs and keys */
-+	ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar150_leds_gpio),
-+				 gl_ar150_leds_gpio);
-+	ath79_register_gpio_keys_polled(-1, GL_AR150_KEYS_POLL_INTERVAL,
-+					ARRAY_SIZE(gl_ar150_gpio_keys),
-+					gl_ar150_gpio_keys);
-+
-+	/* enable usb */
-+	gpio_request_one(GL_AR150_GPIO_BIN_USB,
-+				 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
-+	 			 "USB power");
-+	ath79_register_usb();
-+	
-+	/* register eth0 as WAN, eth1 as LAN */
-+	ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR150_MAC0_OFFSET, 0);
-+	ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR150_MAC1_OFFSET, 0);
-+	ath79_register_mdio(0, 0x0);
-+	ath79_register_eth(0);
-+	ath79_register_eth(1);
-+
-+	/* register wireless mac with cal data */
-+	ath79_register_wmac(art + GL_AR150_CALDATA_OFFSET, art + GL_AR150_WMAC_MAC_OFFSET);
-+}
-+
-+MIPS_MACHINE(ATH79_MACH_GL_AR150, "GL-AR150", "GL AR150",gl_ar150_setup);
-diff --git a/target/linux/ar71xx/generic/profiles/gl-connect.mk b/target/linux/ar71xx/generic/profiles/gl-connect.mk
-deleted file mode 100644
-index e9377dbbfa042f790f15817313c24b2700617f37..0000000000000000000000000000000000000000
---- a/target/linux/ar71xx/generic/profiles/gl-connect.mk
-+++ /dev/null
-@@ -1,17 +0,0 @@
--#
--# Copyright (C) 2014 OpenWrt.org
--#
--# This is free software, licensed under the GNU General Public License v2.
--# See /LICENSE for more information.
--#
--
--define Profile/GLINET
--	NAME:=GL.iNet
--	PACKAGES:=kmod-usb-core kmod-usb2
--endef
--
--define Profile/GLINET/Description
--	Package set optimized for the GL-Connect GL.iNet v1.
--endef
--
--$(eval $(call Profile,GLINET))
-diff --git a/target/linux/ar71xx/generic/profiles/gli.mk b/target/linux/ar71xx/generic/profiles/gli.mk
-new file mode 100644
-index 0000000000000000000000000000000000000000..a6ad661666a168a591319e74ef211277f8617fca
---- /dev/null
-+++ b/target/linux/ar71xx/generic/profiles/gli.mk
-@@ -0,0 +1,27 @@
-+#
-+# Copyright (C) 2013 OpenWrt.org
-+#
-+# This is free software, licensed under the GNU General Public License v2.
-+# See /LICENSE for more information.
-+#
-+define Profile/GLINET
-+	NAME:=GL.iNet 6416
-+	PACKAGES:=kmod-usb-core kmod-usb2
-+endef
-+
-+define Profile/GLINET/Description
-+	Package set optimized for the GL-Connect GL.iNet v1.
-+endef
-+
-+$(eval $(call Profile,GLINET))
-+
-+define Profile/GL-AR150
-+	NAME:=GL AR150
-+	PACKAGES:=kmod-usb-core kmod-usb2
-+endef
-+
-+define Profile/GL-AR150/Description
-+	Configuration of GL AR150.
-+endef
-+
-+$(eval $(call Profile,GL-AR150))
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 7c648f26e10c49000b848e9b300701b388410c04..05eea0b16c362ba5f70c9f435dbe312087b319c2 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -144,6 +144,14 @@ define Device/weio
- endef
- TARGET_DEVICES += weio
- 
-+define Device/gl-ar150
-+  BOARDNAME = GL-AR150
-+  IMAGE_SIZE = 16000k
-+  CONSOLE = ttyATH0,115200
-+  MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,16000k(firmware),64k(art)ro
-+endef
-+TARGET_DEVICES += gl-ar150
-+
- define Device/wndr3700
-   BOARDNAME = WNDR3700
-   NETGEAR_KERNEL_MAGIC = 0x33373030
-diff --git a/target/linux/ar71xx/patches-3.18/911-MIPS-ath79-add-gl_ar150.patch b/target/linux/ar71xx/patches-3.18/911-MIPS-ath79-add-gl_ar150.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..31db5816caf5dc8076ceec349884cf9a47b2fc68
---- /dev/null
-+++ b/target/linux/ar71xx/patches-3.18/911-MIPS-ath79-add-gl_ar150.patch
-@@ -0,0 +1,39 @@
-+--- a/arch/mips/ath79/Kconfig
-++++ b/arch/mips/ath79/Kconfig
-+@@ -533,6 +533,16 @@ config ATH79_MACH_GL_INET
-+ 	select ATH79_DEV_USB
-+ 	select ATH79_DEV_WMAC
-+ 
-++config ATH79_MACH_GL_AR150
-++   bool "GL AR150 support"
-++   select SOC_AR933X
-++   select ATH79_DEV_ETH
-++   select ATH79_DEV_GPIO_BUTTONS
-++   select ATH79_DEV_LEDS_GPIO
-++   select ATH79_DEV_M25P80
-++   select ATH79_DEV_USB
-++   select ATH79_DEV_WMAC
-++
-+ config ATH79_MACH_EAP300V2
-+ 	bool "EnGenius EAP300 v2 support"
-+ 	select SOC_AR934X
-+--- a/arch/mips/ath79/Makefile
-++++ b/arch/mips/ath79/Makefile
-+@@ -78,6 +78,7 @@ obj-$(CONFIG_ATH79_MACH_EL_MINI)	+= mach
-+ obj-$(CONFIG_ATH79_MACH_EPG5000)	+= mach-epg5000.o
-+ obj-$(CONFIG_ATH79_MACH_ESR1750)	+= mach-esr1750.o
-+ obj-$(CONFIG_ATH79_MACH_F9K1115V2)	+= mach-f9k1115v2.o
-++obj-$(CONFIG_ATH79_MACH_GL_AR150)	+= mach-gl-ar150.o
-+ obj-$(CONFIG_ATH79_MACH_GL_INET)	+= mach-gl-inet.o
-+ obj-$(CONFIG_ATH79_MACH_GS_MINIBOX_V1)	+= mach-gs-minibox-v1.o
-+ obj-$(CONFIG_ATH79_MACH_GS_OOLITE)	+= mach-gs-oolite.o
-+--- a/arch/mips/ath79/machtypes.h
-++++ b/arch/mips/ath79/machtypes.h
-+@@ -67,6 +67,7 @@ enum ath79_mach_type {
-+ 	ATH79_MACH_ESR1750,		/* EnGenius ESR1750 */
-+ 	ATH79_MACH_EPG5000,		/* EnGenius EPG5000 */
-+ 	ATH79_MACH_F9K1115V2,		/* Belkin AC1750DB */
-++	ATH79_MACH_GL_AR150,	/* GL-AR150 support */
-+ 	ATH79_MACH_GL_INET,		/* GL-CONNECT GL-INET */
-+ 	ATH79_MACH_GS_MINIBOX_V1,	/* Gainstrong MiniBox V1.0 */
-+ 	ATH79_MACH_GS_OOLITE,           /* GS OOLITE V1.0 */

+ 0 - 48
patches/openwrt/0048-build-don-t-add-j-for-parallel-builds-with-Make-4.2.patch

@@ -1,48 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Wed, 15 Jun 2016 19:31:34 +0200
-Subject: build: don't add -j for parallel builds with Make 4.2+
-
-Make usually passes -j and jobserver arguments as part of MAKEFLAGS. LEDE
-removes MAKEFLAGS to have better control of the build, and re-adds the
-jobserver arguments with -j to the Make commandline where desired.
-
-Make 4.2+ behave differently with these arguments passed on the commandline
-than in MAKEFLAGS: -j will override the jobserver argument and the job
-count will be unlimited.
-
-Moving the flags to MAKEFLAGS will need many packages to be changed and
-tested; therefore, we opt for a less invasive change for now and just
-remove -j for Make 4.2+, as the jobserver argument alone is enough to
-enable parallel builds for these Make versions.
-
-Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of LEDE 6fb212f2933bbbdf2935124205717c9d0ca72b32
-
-diff --git a/include/host-build.mk b/include/host-build.mk
-index e2b5f2f8d1882207e11697df3df1302076adfaa3..44401b866a4d637648bb093470a5e66b4a3e38fc 100644
---- a/include/host-build.mk
-+++ b/include/host-build.mk
-@@ -10,7 +10,7 @@ HOST_INSTALL_DIR ?= $(HOST_BUILD_DIR)/host-install
- HOST_BUILD_PARALLEL ?=
- 
- ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),)
--  HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) -j)
-+  HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j))
- else
-   HOST_MAKE_J:=-j$(CONFIG_PKG_BUILD_JOBS)
- endif
-diff --git a/include/package.mk b/include/package.mk
-index c69d92819779dd0ee92381620accd73ef2b80de6..a99cdc6990280d7ef83223861cd9f224c6eebc33 100644
---- a/include/package.mk
-+++ b/include/package.mk
-@@ -23,7 +23,7 @@ PKG_RELRO_PARTIAL ?= 1
- PKG_RELRO_FULL ?= 1
- 
- ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),)
--  MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) -j)
-+  MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j))
- else
-   MAKE_J:=-j$(CONFIG_PKG_BUILD_JOBS)
- endif

+ 0 - 30
patches/openwrt/0049-tools-cmake-fix-parallel-build-with-Make-4.2.patch

@@ -1,30 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Wed, 15 Jun 2016 19:31:49 +0200
-Subject: tools/cmake: fix parallel build with Make 4.2+
-
-Avoid using the --parallel argument to the CMake bootstrap, as that doesn't
-allow us to remove the -j argument. Instead, pass the HOST_JOBS arguments
-in MAKEFLAGS.
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of LEDE 96db10752483cb07f822686482b44be6c21fbb5f
-
-diff --git a/tools/cmake/Makefile b/tools/cmake/Makefile
-index 08e2b028150dd4f496e3a8ebccf27bd49b6937c2..6c211def540a6a41012349d5979b919481e1bcec 100644
---- a/tools/cmake/Makefile
-+++ b/tools/cmake/Makefile
-@@ -18,10 +18,11 @@ HOST_CONFIGURE_PARALLEL:=1
- 
- include $(INCLUDE_DIR)/host-build.mk
- 
-+HOST_CONFIGURE_CMD := MAKEFLAGS="$(HOST_JOBS)" $(BASH) ./configure
-+
- HOST_CONFIGURE_VARS :=
- 
- HOST_CONFIGURE_ARGS := \
--	--prefix=$(STAGING_DIR_HOST) \
--	$(if $(MAKE_JOBSERVER),--parallel="$(MAKE_JOBSERVER)")
-+	--prefix=$(STAGING_DIR_HOST)
- 
- $(eval $(call HostBuild))

+ 0 - 143
patches/openwrt/0050-linux-make-IPv6-builtin-if-selected-saves-30KB.patch

@@ -1,143 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 16 Jun 2016 00:51:07 +0200
-Subject: linux: make IPv6 builtin if selected (saves >30KB)
-
-Signed-off-by: Steven Barth <steven@midlink.org>
-
-Backport of OpenWrt r46834
-
-kmod-ipv6 is added to the PROVIDES of the kernel package, so we don't have
-to adjust all packages depending on kmod-ipv6.
-
-diff --git a/config/Config-build.in b/config/Config-build.in
-index 4674d8403539a3b209d709342ab71a6e6ff79de2..cd50290f812f73bc6886a789a456956fa4fb1e42 100644
---- a/config/Config-build.in
-+++ b/config/Config-build.in
-@@ -83,7 +83,7 @@ menu "Global build settings"
- 		prompt "Enable IPv6 support in packages"
- 		default y
- 		help
--		  Enable IPv6 support in packages (passes --enable-ipv6 to configure scripts).
-+		  Enables IPv6 support in kernel (builtin) and packages.
- 
- 	config PKG_BUILD_PARALLEL
- 		bool
-diff --git a/package/kernel/linux/Makefile b/package/kernel/linux/Makefile
-index 45ca9faa923eb1a1db97d94d0406a46223c59a8f..b06c49a92fd396e8edcb0ca7a7a94b74b05a87e0 100644
---- a/package/kernel/linux/Makefile
-+++ b/package/kernel/linux/Makefile
-@@ -49,6 +49,7 @@ define Package/kernel
-   TITLE:=Virtual kernel package
-   VERSION:=$(LINUX_VERSION)-$(LINUX_RELEASE)-$(LINUX_VERMAGIC)
-   URL:=http://www.kernel.org/
-+  PROVIDES:=$(if $(CONFIG_IPV6),kmod-ipv6)
- endef
- 
- define Package/kernel/install
-diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk
-index cea8e47a65b5283640a17ed6c311bd87c70373b2..8a2760d8a4a429f206eba41a8c83432e5b6ddab7 100644
---- a/package/kernel/linux/modules/netsupport.mk
-+++ b/package/kernel/linux/modules/netsupport.mk
-@@ -439,7 +439,7 @@ $(eval $(call KernelPackage,iptunnel4))
- define KernelPackage/iptunnel6
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
-   TITLE:=IPv6 tunneling
--  DEPENDS:= +kmod-ipv6
-+  DEPENDS:=@IPV6
-   KCONFIG:= \
- 	CONFIG_INET6_TUNNEL
-   FILES:=$(LINUX_DIR)/net/ipv6/tunnel6.ko
-@@ -456,15 +456,16 @@ $(eval $(call KernelPackage,iptunnel6))
- define KernelPackage/ipv6
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
-   TITLE:=IPv6 support
-+  DEPENDS:=@IPV6
-+  HIDDEN:=1
-+  DEFAULT:=y
-   KCONFIG:= \
--	CONFIG_IPV6 \
-+	CONFIG_IPV6=y \
- 	CONFIG_IPV6_PRIVACY=y \
- 	CONFIG_IPV6_MULTIPLE_TABLES=y \
- 	CONFIG_IPV6_MROUTE=y \
- 	CONFIG_IPV6_PIMSM_V2=n \
- 	CONFIG_IPV6_SUBTREES=y
--  FILES:=$(LINUX_DIR)/net/ipv6/ipv6.ko
--  AUTOLOAD:=$(call AutoLoad,20,ipv6)
- endef
- 
- define KernelPackage/ipv6/description
-@@ -476,7 +477,7 @@ $(eval $(call KernelPackage,ipv6))
- 
- define KernelPackage/sit
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
--  DEPENDS:=+kmod-ipv6 +kmod-iptunnel +kmod-iptunnel4
-+  DEPENDS:=@IPV6 +kmod-iptunnel +kmod-iptunnel4
-   TITLE:=IPv6-in-IPv4 tunnel
-   KCONFIG:=CONFIG_IPV6_SIT \
- 	CONFIG_IPV6_SIT_6RD=y
-@@ -494,7 +495,7 @@ $(eval $(call KernelPackage,sit))
- define KernelPackage/ip6-tunnel
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
-   TITLE:=IP-in-IPv6 tunnelling
--  DEPENDS:= +kmod-ipv6 +kmod-iptunnel6
-+  DEPENDS:=@IPV6 +kmod-iptunnel6
-   KCONFIG:= CONFIG_IPV6_TUNNEL
-   FILES:=$(LINUX_DIR)/net/ipv6/ip6_tunnel.ko
-   AUTOLOAD:=$(call AutoLoad,32,ip6_tunnel)
-@@ -510,7 +511,7 @@ $(eval $(call KernelPackage,ip6-tunnel))
- define KernelPackage/gre
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
-   TITLE:=GRE support
--  DEPENDS:=+PACKAGE_kmod-ipv6:kmod-ipv6 +kmod-iptunnel
-+  DEPENDS:=+kmod-iptunnel
-   KCONFIG:=CONFIG_NET_IPGRE CONFIG_NET_IPGRE_DEMUX
-   FILES:=$(LINUX_DIR)/net/ipv4/ip_gre.ko $(LINUX_DIR)/net/ipv4/gre.ko
-   AUTOLOAD:=$(call AutoLoad,39,gre ip_gre)
-@@ -526,7 +527,7 @@ $(eval $(call KernelPackage,gre))
- define KernelPackage/gre6
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
-   TITLE:=GRE support over IPV6
--  DEPENDS:=+kmod-ipv6 +kmod-iptunnel +kmod-ip6-tunnel
-+  DEPENDS:=@IPV6 +kmod-iptunnel +kmod-ip6-tunnel
-   KCONFIG:=CONFIG_IPV6_GRE
-   FILES:=$(LINUX_DIR)/net/ipv6/ip6_gre.ko
-   AUTOLOAD:=$(call AutoLoad,39,ip6_gre)
-@@ -862,7 +863,6 @@ define KernelPackage/l2tp
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
-   TITLE:=Layer Two Tunneling Protocol (L2TP)
-   DEPENDS:= \
--	+IPV6:kmod-ipv6 \
- 	+kmod-udptunnel4 \
- 	+IPV6:kmod-udptunnel6
-   KCONFIG:=CONFIG_L2TP \
-@@ -898,7 +898,7 @@ $(eval $(call KernelPackage,l2tp-eth))
- define KernelPackage/l2tp-ip
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
-   TITLE:=L2TP IP encapsulation for L2TPv3
--  DEPENDS:=+kmod-l2tp +IPV6:kmod-ipv6
-+  DEPENDS:=+kmod-l2tp
-   KCONFIG:=CONFIG_L2TP_IP
-   FILES:= \
- 	$(LINUX_DIR)/net/l2tp/l2tp_ip.ko \
-@@ -930,7 +930,7 @@ define KernelPackage/sctp
-      CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5=y
-   FILES:= $(LINUX_DIR)/net/sctp/sctp.ko
-   AUTOLOAD:= $(call AutoLoad,32,sctp)
--  DEPENDS:=+kmod-lib-crc32c +kmod-crypto-md5 +kmod-crypto-hmac +IPV6:kmod-ipv6
-+  DEPENDS:=+kmod-lib-crc32c +kmod-crypto-md5 +kmod-crypto-hmac
- endef
- 
- define KernelPackage/sctp/description
-diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile
-index 19a8df9009da7fee967b84f65248470db3b34150..8fd51fe8748082b072710b718300a706832b25be 100644
---- a/package/network/services/dnsmasq/Makefile
-+++ b/package/network/services/dnsmasq/Makefile
-@@ -52,7 +52,6 @@ define Package/dnsmasq-full
- $(call Package/dnsmasq/Default)
-   TITLE += (with DNSSEC, DHCPv6, Auth DNS, IPset enabled by default)
-   DEPENDS:=+PACKAGE_dnsmasq_full_dnssec:libnettle \
--	+PACKAGE_dnsmasq_full_dhcpv6:kmod-ipv6 \
- 	+PACKAGE_dnsmasq_full_ipset:kmod-ipt-ipset
-   VARIANT:=full
- endef

+ 0 - 21
patches/openwrt/0051-package-ipkg.mk-fix-Provides-for-packages-with-multiple-PROVIDES-entries.patch

@@ -1,21 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 16 Jun 2016 04:28:44 +0200
-Subject: package-ipkg.mk: fix Provides for packages with multiple PROVIDES entries
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of LEDE 3ee6c17cd14ec1fed0b0491542c499c03fc6d211
-
-diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
-index eb4c874047e8a9e24a4d77b13f7ba66e1221cbb5..1830d644c36fa3dad342d3283529a18b8d70a377 100644
---- a/include/package-ipkg.mk
-+++ b/include/package-ipkg.mk
-@@ -154,7 +154,7 @@ Package: $(1)
- Version: $(VERSION)
- $$(call addfield,Depends,$$(Package/$(1)/DEPENDS)
- )$$(call addfield,Conflicts,$$(call mergelist,$(CONFLICTS))
--)$$(call addfield,Provides,$(PROVIDES)
-+)$$(call addfield,Provides,$$(call mergelist,$(PROVIDES))
- )$$(call addfield,Source,$(SOURCE)
- )$$(call addfield,License,$$(PKG_LICENSE)
- )$$(call addfield,LicenseFiles,$$(PKG_LICENSE_FILES)

+ 0 - 154
patches/openwrt/0052-kernel-remove-packaging-of-kmod-crypto-core-and-kmod-crypto-arc4.patch

@@ -1,154 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 16 Jun 2016 03:42:03 +0200
-Subject: kernel: remove packaging of kmod-crypto-core and kmod-crypto-arc4
-
-Everything except for blkcipher was already built-in, so make blkcipher
-built-in as well.
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-
-Backport of OpenWrt r46820
-
-The packages kmod-crypto-{core,arc4} are added to kernel PROVIDES to
-satisfy dependencies of CC packages.
-
-diff --git a/package/kernel/linux/Makefile b/package/kernel/linux/Makefile
-index b06c49a92fd396e8edcb0ca7a7a94b74b05a87e0..19bcbd582ba06cb8cdb9ee869c50a67dbfd470bb 100644
---- a/package/kernel/linux/Makefile
-+++ b/package/kernel/linux/Makefile
-@@ -49,7 +49,7 @@ define Package/kernel
-   TITLE:=Virtual kernel package
-   VERSION:=$(LINUX_VERSION)-$(LINUX_RELEASE)-$(LINUX_VERMAGIC)
-   URL:=http://www.kernel.org/
--  PROVIDES:=$(if $(CONFIG_IPV6),kmod-ipv6)
-+  PROVIDES:=kmod-crypto-core kmod-crypto-arc4 $(if $(CONFIG_IPV6),kmod-ipv6)
- endef
- 
- define Package/kernel/install
-diff --git a/package/kernel/linux/modules/crypto.mk b/package/kernel/linux/modules/crypto.mk
-index c8e0fbb04397c9b1fa7ebde3579f663b5d756e1b..926dab0e3379efbc92aeac865b02673928c18644 100644
---- a/package/kernel/linux/modules/crypto.mk
-+++ b/package/kernel/linux/modules/crypto.mk
-@@ -15,24 +15,9 @@ crypto_confvar=CONFIG_CRYPTO_$(word 1,$(subst =,$(space),$(1)))
- crypto_file=$(LINUX_DIR)/crypto/$(word 2,$(subst =,$(space),$(1))).ko
- crypto_name=$(if $(findstring y,$($(call crypto_confvar,$(1)))),,$(word 2,$(subst =,$(space),$(1))))
- 
--define KernelPackage/crypto-core
--  SUBMENU:=$(CRYPTO_MENU)
--  TITLE:=Core CryptoAPI modules
--  KCONFIG:= \
--	CONFIG_CRYPTO=y \
--	CONFIG_CRYPTO_HW=y \
--	CONFIG_CRYPTO_BLKCIPHER \
--	CONFIG_CRYPTO_ALGAPI \
--	$(foreach mod,$(CRYPTO_MODULES),$(call crypto_confvar,$(mod)))
--  FILES:=$(foreach mod,$(CRYPTO_MODULES),$(call crypto_file,$(mod)))
--endef
--
--$(eval $(call KernelPackage,crypto-core))
--
--
- define AddDepends/crypto
-   SUBMENU:=$(CRYPTO_MENU)
--  DEPENDS+=+kmod-crypto-core $(1)
-+  DEPENDS+= $(1)
- endef
- 
- define KernelPackage/crypto-aead
-@@ -272,17 +257,6 @@ endif
- $(eval $(call KernelPackage,crypto-aes))
- 
- 
--define KernelPackage/crypto-arc4
--  TITLE:=ARC4 (RC4) cipher CryptoAPI module
--  KCONFIG:=CONFIG_CRYPTO_ARC4
--  FILES:=$(LINUX_DIR)/crypto/arc4.ko
--  AUTOLOAD:=$(call AutoLoad,09,arc4)
--  $(call AddDepends/crypto)
--endef
--
--$(eval $(call KernelPackage,crypto-arc4))
--
--
- define KernelPackage/crypto-authenc
-   TITLE:=Combined mode wrapper for IPsec
-   DEPENDS:=+kmod-crypto-manager
-diff --git a/package/kernel/linux/modules/fs.mk b/package/kernel/linux/modules/fs.mk
-index fa182375ea8b0224753141620bd168328194ddf4..cc87a45961d04d93badce575530495f994deee86 100644
---- a/package/kernel/linux/modules/fs.mk
-+++ b/package/kernel/linux/modules/fs.mk
-@@ -91,7 +91,6 @@ define KernelPackage/fs-cifs
-   AUTOLOAD:=$(call AutoLoad,30,cifs)
-   $(call AddDepends/nls)
-   DEPENDS+= \
--    +kmod-crypto-arc4 \
-     +kmod-crypto-hmac \
-     +kmod-crypto-md5 \
-     +kmod-crypto-md4 \
-diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk
-index 8a2760d8a4a429f206eba41a8c83432e5b6ddab7..ab76946d2ab30e748ea5bc69c24051dbfc411036 100644
---- a/package/kernel/linux/modules/netsupport.mk
-+++ b/package/kernel/linux/modules/netsupport.mk
-@@ -714,7 +714,7 @@ $(eval $(call KernelPackage,ipoa))
- define KernelPackage/mppe
-   SUBMENU:=$(NETWORK_SUPPORT_MENU)
-   TITLE:=Microsoft PPP compression/encryption
--  DEPENDS:=kmod-ppp +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-sha1 +kmod-crypto-ecb
-+  DEPENDS:=kmod-ppp +kmod-crypto-sha1 +kmod-crypto-ecb
-   KCONFIG:= \
- 	CONFIG_PPP_MPPE_MPPC \
- 	CONFIG_PPP_MPPE
-@@ -998,7 +998,7 @@ define KernelPackage/rxrpc
- 	$(LINUX_DIR)/net/rxrpc/af-rxrpc.ko \
- 	$(LINUX_DIR)/net/rxrpc/rxkad.ko
-   AUTOLOAD:=$(call AutoLoad,30,rxkad af-rxrpc)
--  DEPENDS:=+kmod-crypto-core +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt
-+  DEPENDS:= +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt
- endef
- 
- define KernelPackage/rxrpc/description
-diff --git a/target/linux/generic/config-3.18 b/target/linux/generic/config-3.18
-index 6038692b7e81334e4864d30453f734f4fe829aa0..a0dc3c9b607abe32c1ca021b7fad293a8f742ec1 100644
---- a/target/linux/generic/config-3.18
-+++ b/target/linux/generic/config-3.18
-@@ -700,9 +700,10 @@ CONFIG_CRYPTO_ALGAPI=y
- CONFIG_CRYPTO_ALGAPI2=y
- # CONFIG_CRYPTO_ANSI_CPRNG is not set
- # CONFIG_CRYPTO_ANUBIS is not set
--# CONFIG_CRYPTO_ARC4 is not set
-+CONFIG_CRYPTO_ARC4=y
- # CONFIG_CRYPTO_AUTHENC is not set
--# CONFIG_CRYPTO_BLKCIPHER is not set
-+CONFIG_CRYPTO_BLKCIPHER=y
-+CONFIG_CRYPTO_BLKCIPHER2=y
- # CONFIG_CRYPTO_BLOWFISH is not set
- # CONFIG_CRYPTO_CAMELLIA is not set
- # CONFIG_CRYPTO_CAST5 is not set
-diff --git a/target/linux/omap/config-3.18 b/target/linux/omap/config-3.18
-index a06a350a37c035c66ec8d6242f28379e7992685e..d5003c275b2b2a167d4614f5e33269941a02173e 100644
---- a/target/linux/omap/config-3.18
-+++ b/target/linux/omap/config-3.18
-@@ -114,9 +114,6 @@ CONFIG_CPU_V7=y
- CONFIG_CRC16=y
- CONFIG_CRYPTO_AEAD=m
- CONFIG_CRYPTO_AEAD2=m
--CONFIG_CRYPTO_ARC4=m
--CONFIG_CRYPTO_BLKCIPHER=m
--CONFIG_CRYPTO_BLKCIPHER2=m
- CONFIG_CRYPTO_CCM=m
- CONFIG_CRYPTO_CRC32C=y
- CONFIG_CRYPTO_CTR=m
-diff --git a/target/linux/sunxi/config-3.18 b/target/linux/sunxi/config-3.18
-index ddc3f7acb82064fb3be16f5111b0c4344b01c362..57651bbd65ebc61b14d45aefaaf20e5b8d59e27a 100644
---- a/target/linux/sunxi/config-3.18
-+++ b/target/linux/sunxi/config-3.18
-@@ -110,9 +110,6 @@ CONFIG_CPU_TLB_V7=y
- CONFIG_CPU_V7=y
- CONFIG_CRC16=y
- CONFIG_CRC_T10DIF=y
--CONFIG_CRYPTO_ARC4=y
--CONFIG_CRYPTO_BLKCIPHER=y
--CONFIG_CRYPTO_BLKCIPHER2=y
- CONFIG_CRYPTO_CRC32C=y
- CONFIG_CRYPTO_CRCT10DIF=y
- CONFIG_CRYPTO_DES=y

+ 0 - 24
patches/openwrt/0053-x86-stop-relying-on-hexdump-for-image-build-signature.patch

@@ -1,24 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 3 Jul 2016 19:15:49 +0200
-Subject: x86: stop relying on hexdump for image build signature
-
-Use perl to generate random number instead.
-See https://github.com/freifunk-gluon/gluon/issues/811
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
-
-Backport of LEDE d5ee23ee275fcd6550b0051de59706cc928cdac8
-
-diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
-index e7e02f15fbb3d1638b26982e7ddff305464e6851..6f64eba398e34093308b766839e69780512a4ca8 100644
---- a/target/linux/x86/image/Makefile
-+++ b/target/linux/x86/image/Makefile
-@@ -40,7 +40,7 @@ ifneq ($(GRUB_TERMINALS),)
-   GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
- endif
- 
--SIGNATURE:=$(shell dd if=/dev/urandom bs=4 count=1 2>/dev/null | hexdump -v -e '"%08x"')
-+SIGNATURE:=$(shell perl -e 'printf("%08x", rand(0xFFFFFFFF))')
- ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
- ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(SIGNATURE)-02)
- 

+ 0 - 34
patches/openwrt/0054-mt76-fix-build-with-kernel-3.18.patch

@@ -1,34 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 30 Jun 2016 21:52:02 +0200
-Subject: mt76: fix build with kernel 3.18
-
-diff --git a/package/kernel/mac80211/patches/945-netdev_alloc_frag.patch b/package/kernel/mac80211/patches/945-netdev_alloc_frag.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..ea389cd85cb15c7ecb20a1e0c934fcf8b58c0eda
---- /dev/null
-+++ b/package/kernel/mac80211/patches/945-netdev_alloc_frag.patch
-@@ -0,0 +1,11 @@
-+--- a/backport-include/linux/netdevice.h
-++++ b/backport-include/linux/netdevice.h
-+@@ -233,7 +233,7 @@ static inline void backport_unregister_n
-+ #endif
-+ 
-+ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-+-#define napi_alloc_frag(fragsz) netdev_alloc_frag(fragsz)
-++#define napi_alloc_frag netdev_alloc_frag
-+ #endif
-+ 
-+ /*
-diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile
-index bd851e61910c9a57ca45a570855ca22329c9ae4b..989ba0c2e8d10f6e7bb8fbd31e7181efff19be7c 100644
---- a/package/kernel/mt76/Makefile
-+++ b/package/kernel/mt76/Makefile
-@@ -24,7 +24,7 @@ include $(INCLUDE_DIR)/package.mk
- define KernelPackage/mt76
-   SUBMENU:=Wireless Drivers
-   TITLE:=MediaTek MT76x2/MT7603 wireless driver
--  DEPENDS:=+kmod-mac80211 +@DRIVER_11N_SUPPORT @PCI_SUPPORT @!LINUX_3_18
-+  DEPENDS:=+kmod-mac80211 +@DRIVER_11N_SUPPORT @PCI_SUPPORT
-   FILES:=\
- 	$(PKG_BUILD_DIR)/mt76.ko \
- 	$(PKG_BUILD_DIR)/mt76x2e.ko \

+ 0 - 41
patches/openwrt/0055-ramips-Support-LEDs-on-D-Link-DIR-860L-B1.patch

@@ -1,41 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 30 Jun 2016 15:34:32 +0200
-Subject: ramips: Support LEDs on D-Link DIR-860L B1
-
-Adds the required gpio definitions.
-
-Signed-off-by: Johannes Wienke <languitar@semipol.de>
-
-Backport of OpenWrt r48715
-
-diff --git a/target/linux/ramips/dts/DIR-860L-B1.dts b/target/linux/ramips/dts/DIR-860L-B1.dts
-index 23ec1140bc89fa06aa2920bc43efc8bb7465fb42..2582b3d4182d3a0fcee6e6ea6f97ab8007edf3a2 100644
---- a/target/linux/ramips/dts/DIR-860L-B1.dts
-+++ b/target/linux/ramips/dts/DIR-860L-B1.dts
-@@ -97,6 +97,26 @@
- 
- 	gpio-leds {
- 		compatible = "gpio-leds";
-+
-+		power {
-+			label = "d-link:orange:power";
-+			gpios = <&gpio0 13 1>;
-+		};
-+
-+		power2 {
-+			label = "d-link:green:power";
-+			gpios = <&gpio0 15 1>;
-+		};
-+
-+		net {
-+			label = "d-link:orange:net";
-+			gpios = <&gpio0 14 1>;
-+		};
-+
-+		net2 {
-+			label = "d-link:green:net";
-+			gpios = <&gpio0 16 1>;
-+		};
- 	};
- 
- 	gpio-keys-polled {

+ 0 - 56
patches/openwrt/0056-ramips-add-button-support-and-make-LEDs-known-to-userspace-for-DIR-860L-B1.patch

@@ -1,56 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 30 Jun 2016 15:18:03 +0200
-Subject: ramips: add button support and make LEDs known to userspace for DIR-860L B1
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds
-index 5327d006299ed94c645542f687e20962c83e842d..5fb28a52f7632bf09e7f62ff77dcd7254a2ebcc2 100755
---- a/target/linux/ramips/base-files/etc/board.d/01_leds
-+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
-@@ -114,6 +114,9 @@ case $board in
- 	esr-9753)
- 		set_wifi_led "rt2800pci-phy0::radio"
- 		;;
-+	dir-860l-b1)
-+		ucidef_set_led_netdev "wan" "wan" "d-link:green:net" "eth0.2"
-+		;;
- 	ex2700)
- 		ucidef_set_led_default "power_r" "POWER (red)" "ex2700:red:power" "0"
- 		set_wifi_led "ex2700:green:router"
-diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh
-index 6474ebdde354b51648fcafd426e3256f0b6fe8b4..37360a417cb24eaedef24766510db7146c92e3cb 100644
---- a/target/linux/ramips/base-files/etc/diag.sh
-+++ b/target/linux/ramips/base-files/etc/diag.sh
-@@ -54,6 +54,9 @@ get_status_led() {
- 	dir-645)
- 		status_led="d-link:green:wps"
- 		;;
-+	dir-860l-b1)
-+		status_led="d-link:green:power"
-+		;;
- 	dap-1350)
- 		status_led="d-link:blue:power"
- 		;;
-diff --git a/target/linux/ramips/dts/DIR-860L-B1.dts b/target/linux/ramips/dts/DIR-860L-B1.dts
-index 2582b3d4182d3a0fcee6e6ea6f97ab8007edf3a2..c0bcc86216cf4bd343b688aa7e717b5c45775c50 100644
---- a/target/linux/ramips/dts/DIR-860L-B1.dts
-+++ b/target/linux/ramips/dts/DIR-860L-B1.dts
-@@ -124,5 +124,17 @@
- 		#address-cells = <1>;
- 		#size-cells = <0>;
- 		poll-interval = <20>;
-+
-+		reset {
-+			label = "reset";
-+			gpios = <&gpio0 7 1>;
-+			linux,code = <0x198>;
-+		};
-+
-+		wps {
-+			label = "wps";
-+			gpios = <&gpio0 18 1>;
-+			linux,code = <0x211>;
-+		};
- 	};
- };

+ 0 - 22
patches/openwrt/0057-ramips-set-correct-LAN-WAN-MAC-addresses-on-DIR-860L-B1.patch

@@ -1,22 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 30 Jun 2016 16:16:30 +0200
-Subject: ramips: set correct LAN/WAN MAC addresses on DIR-860L B1
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
-index a78912dbc9b5ecdc8a9fb0c583c1e47fdb579015..4e6e507625adf8c706e2311ee121769cadb2aeaf 100755
---- a/target/linux/ramips/base-files/etc/board.d/02_network
-+++ b/target/linux/ramips/base-files/etc/board.d/02_network
-@@ -346,6 +346,11 @@ ramips_setup_macs()
- 		wan_mac=$(mtd_get_mac_ascii nvram wanmac)
- 		;;
- 
-+	dir-860l-b1)
-+		lan_mac=$(mtd_get_mac_ascii factory lanmac)
-+		wan_mac=$(mtd_get_mac_ascii factory wanmac)
-+		;;
-+
- 	e1700)
- 		wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
- 		;;

+ 0 - 323
patches/openwrt/0058-ar71xx-add-support-for-TP-LINK-TL-WR842N-ND-v3.patch

@@ -1,323 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 3 Jul 2016 22:14:18 +0200
-Subject: ar71xx: add support for TP-LINK TL-WR842N/ND v3
-
-- CPU QCA9531-BL3A
-- RAM: 64MB
-- flash: 16MB
-- USB
-
-AP143 platform, similar to tl-wr841n v10/v11, but with USB
-
-Signed-off-by: Cezary Jackiewicz <cezary@eko.one.pl>
-
-Backport of LEDE 0b45bec22c59cc6e6b2fa71dc9a88386c5587132
-
-diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
-index cb92349cab833179a87a195b94e2539cc5ce3e79..2c5d6af8f4e2c5ce71adc0b63d32b8506e01b6a2 100644
---- a/target/linux/ar71xx/base-files/etc/diag.sh
-+++ b/target/linux/ar71xx/base-files/etc/diag.sh
-@@ -280,6 +280,7 @@ get_status_led() {
- 	tl-wr841n-v11 | \
- 	tl-wa830re-v2 | \
- 	tl-wr842n-v2 | \
-+	tl-wr842n-v3 | \
- 	tl-wr941nd | \
- 	tl-wr941nd-v5)
- 		status_led="tp-link:green:system"
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-index d81358d6bf9103ffeb2929b06d3ab01efffe931c..14aa7bc5e56c0d7be435ba3a1803416075eccb58 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-@@ -523,6 +523,16 @@ tl-wr842n-v2)
- 	ucidef_set_led_usbdev "usb" "USB" "tp-link:green:3g" "1-1"
- 	;;
- 
-+tl-wr842n-v3)
-+	ucidef_set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
-+	ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x10"
-+	ucidef_set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x08"
-+	ucidef_set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x04"
-+	ucidef_set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x02"
-+	ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
-+	ucidef_set_led_usbdev "usb" "USB" "tp-link:green:3g" "1-1"
-+	;;
-+
- tl-wa801nd-v2 | \
- tl-wa901nd-v3)
- 	ucidef_set_led_netdev "lan" "LAN" "tp-link:green:lan" "eth0"
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index ac3deb8aa2ed4717e2bd682cb4ffd7d32c50134f..ca9c5771d72681557f4139c0e58f4d7a656bd741 100755
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -449,6 +449,7 @@ tl-wr741nd-v4 |\
- tl-wr841n-v7 |\
- tl-wr841n-v9 |\
- tl-wr841n-v11 |\
-+tl-wr842n-v3 |\
- whr-g301n |\
- whr-hp-g300n |\
- whr-hp-gn |\
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index f242980b3e401f2e9de2b8abe7e984b24a71db5a..fcd0bc35227de9b6a02c10c1bebf2413bdc555bf 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -869,6 +869,9 @@ ar71xx_board_detect() {
- 	*"TL-WR842N/ND v2")
- 		name="tl-wr842n-v2"
- 		;;
-+	*"TL-WR842N/ND v3")
-+		name="tl-wr842n-v3"
-+		;;
- 	*TL-WR941ND)
- 		name="tl-wr941nd"
- 		;;
-diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index d816f211891d6a259930f2781574504ea62b4e16..53284df5e2da19d8012361e9560244af898d3c2c 100755
---- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-@@ -367,6 +367,7 @@ platform_check_image() {
- 	tl-wr841n-v9 | \
- 	tl-wr841n-v11 | \
- 	tl-wr842n-v2 | \
-+	tl-wr842n-v3 | \
- 	tl-wr941nd | \
- 	tl-wr941nd-v5 | \
- 	tl-wr941nd-v6 | \
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c
-index 004f71961396cd33cfd381aca386706104a7b757..ebaed15a49113133f59f069325898a00f5612fef 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c
-@@ -1,9 +1,16 @@
- /*
-+<<<<<<< HEAD
-  *  TP-LINK TL-WR841N/ND v9/v11
-  *
-  *  Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
-  *  Copyright (C) 2016 Cezary Jackiewicz <cezary@eko.one.pl>
-  *  Copyright (C) 2016 Stijn Segers <francesco.borromini@gmail.com>
-+=======
-+ *  TP-LINK TL-WR841N/ND v9/TL-WR842N/ND v3
-+ *
-+ *  Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
-+ *  Copyright (C) 2016 Cezary Jackiewicz <cezary@eko.one.pl>
-+>>>>>>> ar71xx: add support for TP-LINK TL-WR842N/ND v3
-  *
-  *  This program is free software; you can redistribute it and/or modify it
-  *  under the terms of the GNU General Public License version 2 as published
-@@ -49,6 +56,20 @@
- #define TL_WR841NV11_GPIO_BTN_RESET	12
- #define TL_WR841NV11_GPIO_BTN_WIFI	17
- 
-+#define TL_WR842NV3_GPIO_LED_SYSTEM	2
-+#define TL_WR842NV3_GPIO_LED_WLAN	3
-+#define TL_WR842NV3_GPIO_LED_WAN_RED	4
-+#define TL_WR842NV3_GPIO_LED_WAN_GREEN	11
-+#define TL_WR842NV3_GPIO_LED_LAN1	12
-+#define TL_WR842NV3_GPIO_LED_LAN2	13
-+#define TL_WR842NV3_GPIO_LED_LAN3	14
-+#define TL_WR842NV3_GPIO_LED_LAN4	15
-+#define TL_WR842NV3_GPIO_LED_3G		16
-+#define TL_WR842NV3_GPIO_LED_WPS	17
-+
-+#define TL_WR842NV3_GPIO_BTN_RESET	1
-+#define TL_WR842NV3_GPIO_BTN_WIFI	0
-+
- #define TL_WR841NV9_KEYS_POLL_INTERVAL	20	/* msecs */
- #define TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV9_KEYS_POLL_INTERVAL)
- 
-@@ -151,6 +172,68 @@ static struct gpio_led tl_wr841n_v11_leds_gpio[] __initdata = {
- 	},
- };
- 
-+static struct gpio_led tl_wr842n_v3_leds_gpio[] __initdata = {
-+	{
-+		.name		= "tp-link:green:lan1",
-+		.gpio		= TL_WR842NV3_GPIO_LED_LAN1,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:lan2",
-+		.gpio		= TL_WR842NV3_GPIO_LED_LAN2,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:lan3",
-+		.gpio		= TL_WR842NV3_GPIO_LED_LAN3,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:lan4",
-+		.gpio		= TL_WR842NV3_GPIO_LED_LAN4,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:wan",
-+		.gpio		= TL_WR842NV3_GPIO_LED_WAN_GREEN,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:red:wan",
-+		.gpio		= TL_WR842NV3_GPIO_LED_WAN_RED,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:wlan",
-+		.gpio		= TL_WR842NV3_GPIO_LED_WLAN,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:system",
-+		.gpio		= TL_WR842NV3_GPIO_LED_SYSTEM,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:3g",
-+		.gpio		= TL_WR842NV3_GPIO_LED_3G,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:wps",
-+		.gpio		= TL_WR842NV3_GPIO_LED_WPS,
-+		.active_low	= 1,
-+	},
-+};
-+
-+static struct gpio_keys_button tl_wr842n_v3_gpio_keys[] __initdata = {
-+	{
-+		.desc		= "Reset button",
-+		.type		= EV_KEY,
-+		.code		= KEY_RESTART,
-+		.debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio		= TL_WR842NV3_GPIO_BTN_RESET,
-+		.active_low	= 1,
-+	}, {
-+		.desc		= "WIFI button",
-+		.type		= EV_KEY,
-+		.code		= KEY_RFKILL,
-+		.debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio		= TL_WR842NV3_GPIO_BTN_WIFI,
-+		.active_low	= 1,
-+	}
-+};
-+
- static void __init tl_ap143_setup(void)
- {
- 	u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
-@@ -212,3 +295,20 @@ static void __init tl_wr841n_v11_setup(void)
- 
- MIPS_MACHINE(ATH79_MACH_TL_WR841N_V11, "TL-WR841N-v11", "TP-LINK TL-WR841N/ND v11",
- 	     tl_wr841n_v11_setup);
-+
-+static void __init tl_wr842n_v3_setup(void)
-+{
-+	tl_ap143_setup();
-+
-+	ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr842n_v3_leds_gpio),
-+				 tl_wr842n_v3_leds_gpio);
-+
-+	ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL,
-+					ARRAY_SIZE(tl_wr842n_v3_gpio_keys),
-+					tl_wr842n_v3_gpio_keys);
-+
-+	ath79_register_usb();
-+}
-+
-+MIPS_MACHINE(ATH79_MACH_TL_WR842N_V3, "TL-WR842N-v3", "TP-LINK TL-WR842N/ND v3",
-+	     tl_wr842n_v3_setup);
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 05eea0b16c362ba5f70c9f435dbe312087b319c2..d66bd25fe01544224a69e3f35f020f2e4130c8b3 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -607,6 +607,13 @@ define Device/tl-wr842n-v2
-     TPLINK_HWID := 0x8420002
- endef
- 
-+define Device/tl-wr842n-v3
-+    $(Device/tplink-16mlzma)
-+    BOARDNAME := TL-WR842N-v3
-+    DEVICE_PROFILE := TLWR842
-+    TPLINK_HWID := 0x08420003
-+endef
-+
- define Device/tl-wr843nd-v1
-     $(Device/tplink-4mlzma)
-     BOARDNAME := TL-WR841N-v8
-@@ -620,7 +627,7 @@ define Device/tl-wr847n-v8
-     DEVICE_PROFILE := TLWR841
-     TPLINK_HWID := 0x08470008
- endef
--TARGET_DEVICES += tl-wr841n-v8 tl-wr841n-v9 tl-wr841n-v10 tl-wr841n-v11 tl-wr842n-v2 tl-wr843nd-v1 tl-wr847n-v8
-+TARGET_DEVICES += tl-wr841n-v8 tl-wr841n-v9 tl-wr841n-v10 tl-wr841n-v11 tl-wr842n-v2 tl-wr842n-v3 tl-wr843nd-v1 tl-wr847n-v8
- 
- define Device/tl-wr941nd-v5
-     $(Device/tplink-4mlzma)
-diff --git a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-index debde6e6a552e71b551d8c01ba06af03013407bf..d4b417bfb78606ddb84076ad8c927952e65118c2 100644
---- a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-+++ b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-@@ -1,6 +1,6 @@
- --- a/arch/mips/ath79/machtypes.h
- +++ b/arch/mips/ath79/machtypes.h
--@@ -16,22 +16,202 @@
-+@@ -16,22 +16,203 @@
-  
-  enum ath79_mach_type {
-  	ATH79_MACH_GENERIC = 0,
-@@ -148,6 +148,7 @@
- +	ATH79_MACH_TL_WR841N_V9,	/* TP-LINK TL-WR841N/ND v9 */
- +	ATH79_MACH_TL_WR841N_V11,	/* TP-LINK TL-WR841N/ND v11 */
- +	ATH79_MACH_TL_WR842N_V2,	/* TP-LINK TL-WR842N/ND v2 */
-++	ATH79_MACH_TL_WR842N_V3,	/* TP-LINK TL-WR842N/ND v3 */
- +	ATH79_MACH_TL_WR941ND,		/* TP-LINK TL-WR941ND */
- +	ATH79_MACH_TL_WR941ND_V5,	/* TP-LINK TL-WR941ND v5 */
- +	ATH79_MACH_TL_WR941ND_V6,	/* TP-LINK TL-WR941ND v6 */
-@@ -285,7 +286,7 @@
-  config ATH79_MACH_AP121
-  	bool "Atheros AP121 reference board"
-  	select SOC_AR933X
--@@ -11,62 +84,1050 @@ config ATH79_MACH_AP121
-+@@ -11,62 +84,1051 @@ config ATH79_MACH_AP121
-  	select ATH79_DEV_M25P80
-  	select ATH79_DEV_USB
-  	select ATH79_DEV_WMAC
-@@ -1236,13 +1237,14 @@
- +	select ATH79_DEV_WMAC
- +
- +config ATH79_MACH_TL_WR841N_V9
--+       bool "TP-LINK TL-WR841N/ND v9 support"
--+       select SOC_QCA953X
--+       select ATH79_DEV_ETH
--+       select ATH79_DEV_GPIO_BUTTONS
--+       select ATH79_DEV_LEDS_GPIO
--+       select ATH79_DEV_M25P80
--+       select ATH79_DEV_WMAC
-++	bool "TP-LINK TL-WR841N/ND v9/TL-WR842N/ND v3 support"
-++	select SOC_QCA953X
-++	select ATH79_DEV_ETH
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
-++	select ATH79_DEV_M25P80
-++	select ATH79_DEV_USB
-++	select ATH79_DEV_WMAC
- +
- +config ATH79_MACH_TL_WR941ND
- +	bool "TP-LINK TL-WR941ND support"
-@@ -1365,7 +1367,7 @@
-  
-  config ATH79_MACH_UBNT_XM
-  	bool "Ubiquiti Networks XM/UniFi boards"
--@@ -83,6 +1144,117 @@ config ATH79_MACH_UBNT_XM
-+@@ -83,6 +1145,117 @@ config ATH79_MACH_UBNT_XM
-  	  Say 'Y' here if you want your kernel to support the
-  	  Ubiquiti Networks XM (rev 1.0) board.
-  
-@@ -1483,7 +1485,7 @@
-  endmenu
-  
-  config SOC_AR71XX
--@@ -124,7 +1296,10 @@ config ATH79_DEV_DSA
-+@@ -124,7 +1297,10 @@ config ATH79_DEV_DSA
-  config ATH79_DEV_ETH
-  	def_bool n
-  
-@@ -1495,7 +1497,7 @@
-  	def_bool n
-  
-  config ATH79_DEV_GPIO_BUTTONS
--@@ -154,6 +1329,11 @@ config ATH79_PCI_ATH9K_FIXUP
-+@@ -154,6 +1330,11 @@ config ATH79_PCI_ATH9K_FIXUP
-  	def_bool n
-  
-  config ATH79_ROUTERBOOT

+ 0 - 18
patches/openwrt/0059-x86-generic-enable-CONFIG_SATA_VIA.patch

@@ -1,18 +0,0 @@
-From: Florian Klink <flokli@flokli.de>
-Date: Mon, 18 Jul 2016 13:53:25 +0200
-Subject: x86/generic: enable CONFIG_SATA_VIA
-
-This enables support for VIA SATA.
-
-diff --git a/target/linux/x86/generic/config-default b/target/linux/x86/generic/config-default
-index 9e963bf725b222dc94792dc8760f6f747cfffb78..4fc513154bd566319d77e6e42622ef362baeb094 100644
---- a/target/linux/x86/generic/config-default
-+++ b/target/linux/x86/generic/config-default
-@@ -174,6 +174,7 @@ CONFIG_PNP_DEBUG_MESSAGES=y
- CONFIG_RAS=y
- # CONFIG_SAMSUNG_Q10 is not set
- CONFIG_SATA_AHCI=y
-+CONFIG_SATA_VIA=y
- # CONFIG_SCx200_ACB is not set
- # CONFIG_SERIAL_8250_FINTEK is not set
- CONFIG_SERIAL_8250_PNP=y

+ 0 - 45
patches/openwrt/0060-libpcap-fix-dependency-of-install-shared-so-make-target.patch

@@ -1,45 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 21 Jul 2016 17:45:26 +0200
-Subject: libpcap: fix dependency of install-shared-so make target
-
-There seems to be a situation in which a rebuild of libpcap.so is triggered
-in the install step of the libpcap Makefile. libpcap.so is the wrong
-target, leading to the build failure reported in [1].
-
-Fix the dependency of install-shared-so to $(SHAREDLIB) so the build can
-succeed in this case.
-
-[1] https://dev.openwrt.org/ticket/19894
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of LEDE b82c8ddf8c15e91d6eecfd6d237606a4ce1f756f
-
-diff --git a/package/libs/libpcap/patches/100-debian_shared_lib.patch b/package/libs/libpcap/patches/100-debian_shared_lib.patch
-index b294e51576f9b9f363fa0143bd0945f03f9d13cd..f8df7f3636cb62845930843a4b208fe4e91a54f2 100644
---- a/package/libs/libpcap/patches/100-debian_shared_lib.patch
-+++ b/package/libs/libpcap/patches/100-debian_shared_lib.patch
-@@ -97,7 +97,7 @@ build a shared library.
-  
- +grammar_pic.o: grammar.c
- +	@rm -f $@
--+	$(CC) -fPIC $(FULL_CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c 
-++	$(CC) -fPIC $(FULL_CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
- +
-  version.o: version.c
-  	$(CC) $(FULL_CFLAGS) -c version.c
-@@ -118,8 +118,12 @@ build a shared library.
-  #
-  # Generate the pcap-config script.
-  #
--@@ -618,11 +652,9 @@ install-shared: install-shared-$(DYEXT)
-- install-shared-so: libpcap.so
-+@@ -615,14 +649,12 @@ install: install-shared install-archive
-+ 		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
-+ 
-+ install-shared: install-shared-$(DYEXT)
-+-install-shared-so: libpcap.so
-++install-shared-so: $(SHAREDLIB)
-  	[ -d $(DESTDIR)$(libdir) ] || \
-  	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
- -	VER=`cat $(srcdir)/VERSION`; \

+ 0 - 38
patches/openwrt/0061-ar71xx-add-revision-detection-for-D-Link-DIR-505-A1-A2.patch

@@ -1,38 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 28 Jul 2016 15:43:25 +0200
-Subject: ar71xx: add revision detection for D-Link DIR-505 A1/A2
-
-The A1 image also works on the A2, correctly set AR71XX_MODEL in this case.
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of LEDE 500a67a167a256002f8ab05171f49dfb86b03260
-
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index fcd0bc35227de9b6a02c10c1bebf2413bdc555bf..20250e96fdcc1783f9b6818c340425206c67016f 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -107,6 +107,15 @@ cybertan_get_hw_magic() {
- 	dd bs=8 count=1 skip=0 if=$part 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
- }
- 
-+dir505_board_detect() {
-+	local dev=$(find_mtd_part 'mac')
-+	[ -z "$dev" ] && return
-+
-+	# The revision is stored at the beginning of the "mac" partition
-+	local rev="$(LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}' $dev)"
-+	AR71XX_MODEL="D-Link DIR-505 rev. $rev"
-+}
-+
- tplink_get_hwid() {
- 	local part
- 
-@@ -453,6 +462,7 @@ ar71xx_board_detect() {
- 		;;
- 	*"DIR-505 rev. A1")
- 		name="dir-505-a1"
-+		dir505_board_detect
- 		;;
- 	*"DIR-600 rev. A1")
- 		name="dir-600-a1"

+ 0 - 28
patches/openwrt/0062-ar71xx-don-t-use-D-Link-DIR-505-status-LED-as-ethernet-indicator.patch

@@ -1,28 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 28 Jul 2016 15:59:04 +0200
-Subject: ar71xx: don't use D-Link DIR-505 status LED as ethernet indicator
-
-The stock firmware uses the single LED as status indicator only. Using the
-same LED both for status and as ethernet indicator is uncommon, and has
-been confusing users who were using the device as a WLAN mesh node (so the
-LED was just off, as no ethernet was connected).
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-Backport of LEDE adbbfb7ff900c489e6be34b2ec2834172dff7943
-
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-index 14aa7bc5e56c0d7be435ba3a1803416075eccb58..3d240fb076bf40b07e7f0b5974d7b5fd4435a044 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-@@ -139,10 +139,6 @@ dhp-1565-a1)
- 	ucidef_set_led_switch "wan" "WAN" "d-link:green:planet" "switch0" "0x20"
- 	;;
- 
--dir-505-a1)
--	ucidef_set_led_netdev "lan" "LAN" "d-link:green:power" "eth1"
--	;;
--
- dir-600-a1|\
- dir-615-e1|\
- dir-615-e4)

+ 0 - 35
patches/openwrt/0063-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch

@@ -1,35 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 9 Jun 2016 04:39:08 +0200
-Subject: ar71xx/cpe510: enable LNA for CPE210/220/510/520
-
-The LNA improves the rx path. Within a simple test setup
-it improved the signal from -60dbm to -40dbm.
-
-Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-
-Backport of LEDE 94e23bf7409d6cc4c9efb55ed32aba8e5a497966
-
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-index 8bf5c0f6226cbba10da10af4798b67b76db94e2b..5cb052a84aee451b9fbd449910acfde80dcf8aa7 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-@@ -30,6 +30,9 @@
- #define CPE510_GPIO_LED_L3	15
- #define CPE510_GPIO_LED_L4	16
- 
-+#define CPE510_GPIO_EXTERNAL_LNA0	18
-+#define CPE510_GPIO_EXTERNAL_LNA1	19
-+
- #define CPE510_GPIO_BTN_RESET	4
- 
- #define CPE510_KEYS_POLL_INTERVAL	20 /* msecs */
-@@ -93,6 +96,9 @@ static void __init cpe510_setup(void)
- 					ARRAY_SIZE(cpe510_gpio_keys),
- 					cpe510_gpio_keys);
- 
-+	ath79_wmac_set_ext_lna_gpio(0, CPE510_GPIO_EXTERNAL_LNA0);
-+	ath79_wmac_set_ext_lna_gpio(1, CPE510_GPIO_EXTERNAL_LNA1);
-+
- 	ath79_register_m25p80(NULL);
- 
- 	ath79_register_mdio(1, 0);

+ 0 - 169
patches/openwrt/0064-ar71xx-cpe510-split-profile-into-2-profiles-cpe210-and-cpe510.patch

@@ -1,169 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 9 Jun 2016 04:55:37 +0200
-Subject: ar71xx/cpe510: split profile into 2 profiles cpe210 and cpe510
-
-Split profile into 2GHz and 5GHz. The 5GHz devices are
-quite "special". The 2 GHz works perfect.
-
-Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-
-Backport of LEDE c5ff273d85f69981e5b126eeaed3dee5b4061fb4
-
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches b/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-index b41f27554b1e3eac19c22af59731771631a1135b..0f7a41589384755ff596d4355ad9fbf1e1087d91 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_gpio-switches
-@@ -15,6 +15,7 @@ nanostation-m)
- nanostation-m-xw)
- 	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "2"
- 	;;
-+cpe210|\
- cpe510)
- 	ucidef_set_gpio_switch "poe_passthrough" "PoE Passthrough" "20"
- 	;;
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-index 3d240fb076bf40b07e7f0b5974d7b5fd4435a044..f1266d88f1b6a441e58b0a008ca915a4b5958928 100644
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
-@@ -78,6 +78,7 @@ carambola2)
- 	ucidef_set_led_wlan "wlan" "WLAN" "carambola2:green:wlan" "phy0tpt"
- 	;;
- 
-+cpe210|\
- cpe510)
- 	ucidef_set_led_switch "lan0" "LAN0" "tp-link:green:lan0" "switch0" "0x20"
- 	ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x10"
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index ca9c5771d72681557f4139c0e58f4d7a656bd741..6c3ecf54dccd111231d93e539346f7839252794c 100755
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -72,6 +72,7 @@ bsb)
- 	ucidef_set_interface_wlan
- 	;;
- 
-+cpe210|\
- cpe510)
- 	ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
- 	ucidef_add_switch "switch0" "1" "1"
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index 20250e96fdcc1783f9b6818c340425206c67016f..0d8ccd21c3f552b7ae7aff6905a08ff6a4fdadf7 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -447,7 +447,11 @@ ar71xx_board_detect() {
- 	*CAP4200AG)
- 		name="cap4200ag"
- 		;;
--	*"CPE210/220/510/520")
-+	*"CPE210/220")
-+		name="cpe210"
-+		tplink_pharos_board_detect
-+		;;
-+	*"CPE510/520")
- 		name="cpe510"
- 		tplink_pharos_board_detect
- 		;;
-diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-index 53284df5e2da19d8012361e9560244af898d3c2c..4003b21df26917a521ed96db82a970a82cdbc2cb 100755
---- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
-@@ -265,6 +265,7 @@ platform_check_image() {
- 		return 0
- 		;;
- 
-+	cpe210|\
- 	cpe510)
- 		tplink_pharos_check_image "$1" && return 0
- 		return 1
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-index 5cb052a84aee451b9fbd449910acfde80dcf8aa7..74daf434e611d1f9d05f7d7516ae918d334b32b7 100644
---- a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c
-@@ -78,12 +78,8 @@ static struct gpio_keys_button cpe510_gpio_keys[] __initdata = {
- 	}
- };
- 
--
--static void __init cpe510_setup(void)
-+static void __init cpe_setup(u8 *mac)
- {
--	u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
--	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
--
- 	/* Disable JTAG, enabling GPIOs 0-3 */
- 	/* Configure OBS4 line, for GPIO 4*/
- 	ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
-@@ -105,9 +101,31 @@ static void __init cpe510_setup(void)
- 	ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
- 	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
- 	ath79_register_eth(1);
-+}
-+
-+
-+static void __init cpe210_setup(void)
-+{
-+	u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
-+	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
-+
-+	cpe_setup(mac);
- 
- 	ath79_register_wmac(ee, mac);
- }
- 
--MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE210/220/510/520",
-+static void __init cpe510_setup(void)
-+{
-+	u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
-+	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
-+
-+	cpe_setup(mac);
-+
-+	ath79_register_wmac(ee, mac);
-+}
-+
-+MIPS_MACHINE(ATH79_MACH_CPE210, "CPE210", "TP-LINK CPE210/220",
-+	     cpe210_setup);
-+
-+MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE510/520",
- 	     cpe510_setup);
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index d66bd25fe01544224a69e3f35f020f2e4130c8b3..75083f9b698ba8a438256209a34369eb626a3b3d 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -2111,7 +2111,8 @@ $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V2,tl-wr1043nd-v2,TL-WR10
- $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V3,tl-wr1043nd-v3,TL-WR1043ND-v2,ttyS0,115200,0x10430003,1,8M))
- $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR2543,tl-wr2543-v1,TL-WR2543N,ttyS0,115200,0x25430001,1,8Mlzma,-v 3.13.99))
- 
--$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510,cpe210-220-510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
-+$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE210_220,cpe210-220,CPE210,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
-+$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510_520,cpe510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
- 
- $(eval $(call SingleProfile,UAPPRO,64k,UAPPRO,ubnt-uap-pro,UAP-PRO,ttyS0,115200,BZ,BZ,ar934x))
- $(eval $(call SingleProfile,UAPPRO,64k,UBNTUNIFIOUTDOORPLUS,ubnt-unifi-outdoor-plus,UBNT-UOP,ttyS0,115200,BZ,BZ,ar7240))
-@@ -2175,6 +2176,7 @@ $(eval $(call MultiProfile,TLWR842,TLWR842V1))
- $(eval $(call MultiProfile,TLWR941,TLWR941NV2 TLWR941NV3 TLWR941NV4))
- $(eval $(call MultiProfile,TLWR1043,TLWR1043V1 TLWR1043V2 TLWR1043V3))
- $(eval $(call MultiProfile,TLWDR4300,TLWDR3500V1 TLWDR3600V1 TLWDR4300V1 TLWDR4300V1IL TLWDR4310V1 MW4530RV1))
-+$(eval $(call MultiProfile,CPE510,CPE210_220 CPE510_520))
- $(eval $(call MultiProfile,TUBE2H,TUBE2H8M TUBE2H16M))
- $(eval $(call MultiProfile,UBNT,UBNTAIRROUTER UBNTRS UBNTRSPRO UBNTLSSR71 UBNTBULLETM UBNTROCKETM UBNTROCKETMXW UBNTNANOM UBNTNANOMXW UBNTLOCOXW UBNTUNIFI UBNTUNIFIOUTDOOR UBNTUNIFIOUTDOORPLUS UAPPRO UBNTAIRGW))
- $(eval $(call MultiProfile,WNR612V2,REALWNR612V2 N150R))
-diff --git a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-index d4b417bfb78606ddb84076ad8c927952e65118c2..c83ac2e89324deda3135aab84e8c4f4112ea728d 100644
---- a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-+++ b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-@@ -1,6 +1,6 @@
- --- a/arch/mips/ath79/machtypes.h
- +++ b/arch/mips/ath79/machtypes.h
--@@ -16,22 +16,203 @@
-+@@ -16,22 +16,204 @@
-  
-  enum ath79_mach_type {
-  	ATH79_MACH_GENERIC = 0,
-@@ -26,6 +26,7 @@
- +	ATH79_MACH_BHU_BXU2000N2_A1,	/* BHU BXU2000n-2 A1 */
- +	ATH79_MACH_CAP4200AG,		/* Senao CAP4200AG */
- +	ATH79_MACH_CARAMBOLA2,		/* 8devices Carambola2 */
-++	ATH79_MACH_CPE210,		/* TP-LINK CPE210 */
- +	ATH79_MACH_CPE510,		/* TP-LINK CPE510 */
-  	ATH79_MACH_DB120,		/* Atheros DB120 reference board */
-  	ATH79_MACH_PB44,		/* Atheros PB44 reference board */

+ 0 - 555
patches/openwrt/0065-firmware-utils-backport-tplink-safeloader-from-LEDE-05abcf518d5e2b7d6526fd7a87a88a268030694a.patch

@@ -1,555 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Wed, 21 Dec 2016 19:22:56 +0100
-Subject: firmware-utils: backport tplink-safeloader from LEDE 05abcf518d5e2b7d6526fd7a87a88a268030694a
-
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-
-diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
-index 77a894b237281f6211dd1123ead4b5b0f2f58370..016c118787f3b5332b76f65c85930065a569d6b8 100644
---- a/tools/firmware-utils/src/tplink-safeloader.c
-+++ b/tools/firmware-utils/src/tplink-safeloader.c
-@@ -53,6 +53,8 @@
- #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
- 
- 
-+#define MAX_PARTITIONS	32
-+
- /** An image partition table entry */
- struct image_partition_entry {
- 	const char *name;
-@@ -67,6 +69,16 @@ struct flash_partition_entry {
- 	uint32_t size;
- };
- 
-+/** Firmware layout description */
-+struct device_info {
-+	const char *id;
-+	const char *vendor;
-+	const char *support_list;
-+	char support_trail;
-+	const struct flash_partition_entry partitions[MAX_PARTITIONS+1];
-+	const char *first_sysupgrade_partition;
-+	const char *last_sysupgrade_partition;
-+};
- 
- /** The content of the soft-version structure */
- struct __attribute__((__packed__)) soft_version {
-@@ -102,45 +114,225 @@ static const uint8_t md5_salt[16] = {
- };
- 
- 
--/** Vendor information for CPE210/220/510/520 */
--static const char cpe510_vendor[] = "CPE510(TP-LINK|UN|N300-5):1.0\r\n";
--
--
--/**
--    The flash partition table for CPE210/220/510/520;
--    it is the same as the one used by the stock images.
--*/
--static const struct flash_partition_entry cpe510_partitions[] = {
--	{"fs-uboot", 0x00000, 0x20000},
--	{"partition-table", 0x20000, 0x02000},
--	{"default-mac", 0x30000, 0x00020},
--	{"product-info", 0x31100, 0x00100},
--	{"signature", 0x32000, 0x00400},
--	{"os-image", 0x40000, 0x170000},
--	{"soft-version", 0x1b0000, 0x00100},
--	{"support-list", 0x1b1000, 0x00400},
--	{"file-system", 0x1c0000, 0x600000},
--	{"user-config", 0x7c0000, 0x10000},
--	{"default-config", 0x7d0000, 0x10000},
--	{"log", 0x7e0000, 0x10000},
--	{"radio", 0x7f0000, 0x10000},
--	{NULL, 0, 0}
-+/** Firmware layout table */
-+static struct device_info boards[] = {
-+	/** Firmware layout for the CPE210/220 */
-+	{
-+		.id	= "CPE210",
-+		.vendor	= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
-+		.support_list =
-+			"SupportList:\r\n"
-+			"CPE210(TP-LINK|UN|N300-2):1.0\r\n"
-+			"CPE210(TP-LINK|UN|N300-2):1.1\r\n"
-+			"CPE210(TP-LINK|US|N300-2):1.1\r\n"
-+			"CPE210(TP-LINK|EU|N300-2):1.1\r\n"
-+			"CPE220(TP-LINK|UN|N300-2):1.1\r\n"
-+			"CPE220(TP-LINK|US|N300-2):1.1\r\n"
-+			"CPE220(TP-LINK|EU|N300-2):1.1\r\n",
-+		.support_trail = '\xff',
-+
-+		.partitions = {
-+			{"fs-uboot", 0x00000, 0x20000},
-+			{"partition-table", 0x20000, 0x02000},
-+			{"default-mac", 0x30000, 0x00020},
-+			{"product-info", 0x31100, 0x00100},
-+			{"signature", 0x32000, 0x00400},
-+			{"os-image", 0x40000, 0x170000},
-+			{"soft-version", 0x1b0000, 0x00100},
-+			{"support-list", 0x1b1000, 0x00400},
-+			{"file-system", 0x1c0000, 0x600000},
-+			{"user-config", 0x7c0000, 0x10000},
-+			{"default-config", 0x7d0000, 0x10000},
-+			{"log", 0x7e0000, 0x10000},
-+			{"radio", 0x7f0000, 0x10000},
-+			{NULL, 0, 0}
-+		},
-+
-+		.first_sysupgrade_partition = "os-image",
-+		.last_sysupgrade_partition = "file-system",
-+	},
-+
-+	/** Firmware layout for the CPE510/520 */
-+	{
-+		.id	= "CPE510",
-+		.vendor	= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
-+		.support_list =
-+			"SupportList:\r\n"
-+			"CPE510(TP-LINK|UN|N300-5):1.0\r\n"
-+			"CPE510(TP-LINK|UN|N300-5):1.1\r\n"
-+			"CPE510(TP-LINK|UN|N300-5):1.1\r\n"
-+			"CPE510(TP-LINK|US|N300-5):1.1\r\n"
-+			"CPE510(TP-LINK|EU|N300-5):1.1\r\n"
-+			"CPE520(TP-LINK|UN|N300-5):1.1\r\n"
-+			"CPE520(TP-LINK|US|N300-5):1.1\r\n"
-+			"CPE520(TP-LINK|EU|N300-5):1.1\r\n",
-+		.support_trail = '\xff',
-+
-+		.partitions = {
-+			{"fs-uboot", 0x00000, 0x20000},
-+			{"partition-table", 0x20000, 0x02000},
-+			{"default-mac", 0x30000, 0x00020},
-+			{"product-info", 0x31100, 0x00100},
-+			{"signature", 0x32000, 0x00400},
-+			{"os-image", 0x40000, 0x170000},
-+			{"soft-version", 0x1b0000, 0x00100},
-+			{"support-list", 0x1b1000, 0x00400},
-+			{"file-system", 0x1c0000, 0x600000},
-+			{"user-config", 0x7c0000, 0x10000},
-+			{"default-config", 0x7d0000, 0x10000},
-+			{"log", 0x7e0000, 0x10000},
-+			{"radio", 0x7f0000, 0x10000},
-+			{NULL, 0, 0}
-+		},
-+
-+		.first_sysupgrade_partition = "os-image",
-+		.last_sysupgrade_partition = "file-system",
-+	},
-+
-+	/** Firmware layout for the C2600 */
-+	{
-+		.id = "C2600",
-+		.vendor = "",
-+		.support_list =
-+			"SupportList:\r\n"
-+			"{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n",
-+		.support_trail = '\x00',
-+
-+		.partitions = {
-+			{"SBL1", 0x00000, 0x20000},
-+			{"MIBIB", 0x20000, 0x20000},
-+			{"SBL2", 0x40000, 0x20000},
-+			{"SBL3", 0x60000, 0x30000},
-+			{"DDRCONFIG", 0x90000, 0x10000},
-+			{"SSD", 0xa0000, 0x10000},
-+			{"TZ", 0xb0000, 0x30000},
-+			{"RPM", 0xe0000, 0x20000},
-+			{"fs-uboot", 0x100000, 0x70000},
-+			{"uboot-env", 0x170000, 0x40000},
-+			{"radio", 0x1b0000, 0x40000},
-+			{"os-image", 0x1f0000, 0x200000},
-+			{"file-system", 0x3f0000, 0x1b00000},
-+			{"default-mac", 0x1ef0000, 0x00200},
-+			{"pin", 0x1ef0200, 0x00200},
-+			{"product-info", 0x1ef0400, 0x0fc00},
-+			{"partition-table", 0x1f00000, 0x10000},
-+			{"soft-version", 0x1f10000, 0x10000},
-+			{"support-list", 0x1f20000, 0x10000},
-+			{"profile", 0x1f30000, 0x10000},
-+			{"default-config", 0x1f40000, 0x10000},
-+			{"user-config", 0x1f50000, 0x40000},
-+			{"qos-db", 0x1f90000, 0x40000},
-+			{"usb-config", 0x1fd0000, 0x10000},
-+			{"log", 0x1fe0000, 0x20000},
-+			{NULL, 0, 0}
-+		},
-+
-+		.first_sysupgrade_partition = "os-image",
-+		.last_sysupgrade_partition = "file-system"
-+	},
-+
-+	/** Firmware layout for the C9 */
-+	{
-+		.id = "ARCHERC9",
-+		.vendor = "",
-+		.support_list =
-+			"SupportList:\n"
-+			"{product_name:ArcherC9,"
-+			"product_ver:1.0.0,"
-+			"special_id:00000000}\n",
-+		.support_trail = '\x00',
-+
-+		.partitions = {
-+			{"fs-uboot", 0x00000, 0x40000},
-+			{"os-image", 0x40000, 0x200000},
-+			{"file-system", 0x240000, 0xc00000},
-+			{"default-mac", 0xe40000, 0x00200},
-+			{"pin", 0xe40200, 0x00200},
-+			{"product-info", 0xe40400, 0x00200},
-+			{"partition-table", 0xe50000, 0x10000},
-+			{"soft-version", 0xe60000, 0x00200},
-+			{"support-list", 0xe61000, 0x0f000},
-+			{"profile", 0xe70000, 0x10000},
-+			{"default-config", 0xe80000, 0x10000},
-+			{"user-config", 0xe90000, 0x50000},
-+			{"log", 0xee0000, 0x100000},
-+			{"radio_bk", 0xfe0000, 0x10000},
-+			{"radio", 0xff0000, 0x10000},
-+			{NULL, 0, 0}
-+		},
-+
-+		.first_sysupgrade_partition = "os-image",
-+		.last_sysupgrade_partition = "file-system"
-+	},
-+
-+	/** Firmware layout for the EAP120 */
-+	{
-+		.id     = "EAP120",
-+		.vendor = "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
-+		.support_list =
-+			"SupportList:\r\n"
-+			"EAP120(TP-LINK|UN|N300-2):1.0\r\n",
-+		.support_trail = '\xff',
-+
-+		.partitions = {
-+			{"fs-uboot", 0x00000, 0x20000},
-+			{"partition-table", 0x20000, 0x02000},
-+			{"default-mac", 0x30000, 0x00020},
-+			{"support-list", 0x31000, 0x00100},
-+			{"product-info", 0x31100, 0x00100},
-+			{"soft-version", 0x32000, 0x00100},
-+			{"os-image", 0x40000, 0x180000},
-+			{"file-system", 0x1c0000, 0x600000},
-+			{"user-config", 0x7c0000, 0x10000},
-+			{"backup-config", 0x7d0000, 0x10000},
-+			{"log", 0x7e0000, 0x10000},
-+			{"radio", 0x7f0000, 0x10000},
-+			{NULL, 0, 0}
-+		},
-+
-+		.first_sysupgrade_partition = "os-image",
-+		.last_sysupgrade_partition = "file-system"
-+	},
-+
-+	/** Firmware layout for the TL-WR1043 v4 */
-+	{
-+		.id     = "TLWR1043NDV4",
-+		.vendor = "",
-+		.support_list =
-+			"SupportList:\n"
-+			"{product_name:TL-WR1043ND,product_ver:4.0.0,special_id:45550000}\n",
-+		.support_trail = '\x00',
-+
-+		/**
-+		    We use a bigger os-image partition than the stock images (and thus
-+		    smaller file-system), as our kernel doesn't fit in the stock firmware's
-+		    1MB os-image.
-+		*/
-+		.partitions = {
-+			{"fs-uboot", 0x00000, 0x20000},
-+			{"os-image", 0x20000, 0x180000},
-+			{"file-system", 0x1a0000, 0xdb0000},
-+			{"default-mac", 0xf50000, 0x00200},
-+			{"pin", 0xf50200, 0x00200},
-+			{"product-info", 0xf50400, 0x0fc00},
-+			{"soft-version", 0xf60000, 0x0b000},
-+			{"support-list", 0xf6b000, 0x04000},
-+			{"profile", 0xf70000, 0x04000},
-+			{"default-config", 0xf74000, 0x0b000},
-+			{"user-config", 0xf80000, 0x40000},
-+			{"partition-table", 0xfc0000, 0x10000},
-+			{"log", 0xfd0000, 0x20000},
-+			{"radio", 0xff0000, 0x10000},
-+			{NULL, 0, 0}
-+		},
-+
-+		.first_sysupgrade_partition = "os-image",
-+		.last_sysupgrade_partition = "file-system"
-+	},
-+
-+	{}
- };
- 
--/**
--   The support list for CPE210/220/510/520
--*/
--static const char cpe510_support_list[] =
--	"SupportList:\r\n"
--	"CPE510(TP-LINK|UN|N300-5):1.0\r\n"
--	"CPE510(TP-LINK|UN|N300-5):1.1\r\n"
--	"CPE520(TP-LINK|UN|N300-5):1.0\r\n"
--	"CPE520(TP-LINK|UN|N300-5):1.1\r\n"
--	"CPE210(TP-LINK|UN|N300-2):1.0\r\n"
--	"CPE210(TP-LINK|UN|N300-2):1.1\r\n"
--	"CPE220(TP-LINK|UN|N300-2):1.0\r\n"
--	"CPE220(TP-LINK|UN|N300-2):1.1\r\n";
--
- #define error(_ret, _errno, _str, ...)				\
- 	do {							\
- 		fprintf(stderr, _str ": %s\n", ## __VA_ARGS__,	\
-@@ -240,14 +432,14 @@ static struct image_partition_entry make_soft_version(uint32_t rev) {
- }
- 
- /** Generates the support-list partition */
--static struct image_partition_entry make_support_list(const char *support_list) {
--	size_t len = strlen(support_list);
-+static struct image_partition_entry make_support_list(const struct device_info *info) {
-+	size_t len = strlen(info->support_list);
- 	struct image_partition_entry entry = alloc_image_partition("support-list", len + 9);
- 
- 	put32(entry.data, len);
- 	memset(entry.data+4, 0, 4);
--	memcpy(entry.data+8, support_list, len);
--	entry.data[len+8] = '\xff';
-+	memcpy(entry.data+8, info->support_list, len);
-+	entry.data[len+8] = info->support_trail;
- 
- 	return entry;
- }
-@@ -313,12 +505,22 @@ static struct image_partition_entry read_file(const char *part_name, const char
- 
-    I think partition-table must be the first partition in the firmware image.
- */
--static void put_partitions(uint8_t *buffer, const struct image_partition_entry *parts) {
--	size_t i;
-+static void put_partitions(uint8_t *buffer, const struct flash_partition_entry *flash_parts, const struct image_partition_entry *parts) {
-+	size_t i, j;
- 	char *image_pt = (char *)buffer, *end = image_pt + 0x800;
- 
- 	size_t base = 0x800;
- 	for (i = 0; parts[i].name; i++) {
-+		for (j = 0; flash_parts[j].name; j++) {
-+			if (!strcmp(flash_parts[j].name, parts[i].name)) {
-+				if (parts[i].size > flash_parts[j].size)
-+					error(1, 0, "%s partition too big (more than %u bytes)", flash_parts[j].name, (unsigned)flash_parts[j].size);
-+				break;
-+			}
-+		}
-+
-+		assert(flash_parts[j].name);
-+
- 		memcpy(buffer + base, parts[i].data, parts[i].size);
- 
- 		size_t len = end-image_pt;
-@@ -331,10 +533,6 @@ static void put_partitions(uint8_t *buffer, const struct image_partition_entry *
- 
- 		base += parts[i].size;
- 	}
--
--	image_pt++;
--
--	memset(image_pt, 0xff, end-image_pt);
- }
- 
- /** Generates and writes the image MD5 checksum */
-@@ -363,7 +561,7 @@ static void put_md5(uint8_t *md5, uint8_t *buffer, unsigned int len) {
-      1014-1813    Image partition table (2048 bytes, padded with 0xff)
-      1814-xxxx    Firmware partitions
- */
--static void * generate_factory_image(const char *vendor, const struct image_partition_entry *parts, size_t *len) {
-+static void * generate_factory_image(const struct device_info *info, const struct image_partition_entry *parts, size_t *len) {
- 	*len = 0x1814;
- 
- 	size_t i;
-@@ -374,14 +572,16 @@ static void * generate_factory_image(const char *vendor, const struct image_part
- 	if (!image)
- 		error(1, errno, "malloc");
- 
-+	memset(image, 0xff, *len);
- 	put32(image, *len);
- 
--	size_t vendor_len = strlen(vendor);
--	put32(image+0x14, vendor_len);
--	memcpy(image+0x18, vendor, vendor_len);
--	memset(image+0x18+vendor_len, 0xff, 4092-vendor_len);
-+	if (info->vendor) {
-+		size_t vendor_len = strlen(info->vendor);
-+		put32(image+0x14, vendor_len);
-+		memcpy(image+0x18, info->vendor, vendor_len);
-+	}
- 
--	put_partitions(image + 0x1014, parts);
-+	put_partitions(image + 0x1014, info->partitions, parts);
- 	put_md5(image+0x04, image+0x14, *len-0x14);
- 
- 	return image;
-@@ -394,33 +594,39 @@ static void * generate_factory_image(const char *vendor, const struct image_part
-    should be generalized when TP-LINK starts building its safeloader into hardware with
-    different flash layouts.
- */
--static void * generate_sysupgrade_image(const struct flash_partition_entry *flash_parts, const struct image_partition_entry *image_parts, size_t *len) {
--	const struct flash_partition_entry *flash_os_image = &flash_parts[5];
--	const struct flash_partition_entry *flash_soft_version = &flash_parts[6];
--	const struct flash_partition_entry *flash_support_list = &flash_parts[7];
--	const struct flash_partition_entry *flash_file_system = &flash_parts[8];
--
--	const struct image_partition_entry *image_os_image = &image_parts[3];
--	const struct image_partition_entry *image_soft_version = &image_parts[1];
--	const struct image_partition_entry *image_support_list = &image_parts[2];
--	const struct image_partition_entry *image_file_system = &image_parts[4];
--
--	assert(strcmp(flash_os_image->name, "os-image") == 0);
--	assert(strcmp(flash_soft_version->name, "soft-version") == 0);
--	assert(strcmp(flash_support_list->name, "support-list") == 0);
--	assert(strcmp(flash_file_system->name, "file-system") == 0);
--
--	assert(strcmp(image_os_image->name, "os-image") == 0);
--	assert(strcmp(image_soft_version->name, "soft-version") == 0);
--	assert(strcmp(image_support_list->name, "support-list") == 0);
--	assert(strcmp(image_file_system->name, "file-system") == 0);
--
--	if (image_os_image->size > flash_os_image->size)
--		error(1, 0, "kernel image too big (more than %u bytes)", (unsigned)flash_os_image->size);
--	if (image_file_system->size > flash_file_system->size)
--		error(1, 0, "rootfs image too big (more than %u bytes)", (unsigned)flash_file_system->size);
--
--	*len = flash_file_system->base - flash_os_image->base + image_file_system->size;
-+static void * generate_sysupgrade_image(const struct device_info *info, const struct image_partition_entry *image_parts, size_t *len) {
-+	size_t i, j;
-+	size_t flash_first_partition_index = 0;
-+	size_t flash_last_partition_index = 0;
-+	const struct flash_partition_entry *flash_first_partition = NULL;
-+	const struct flash_partition_entry *flash_last_partition = NULL;
-+	const struct image_partition_entry *image_last_partition = NULL;
-+
-+	/** Find first and last partitions */
-+	for (i = 0; info->partitions[i].name; i++) {
-+		if (!strcmp(info->partitions[i].name, info->first_sysupgrade_partition)) {
-+			flash_first_partition = &info->partitions[i];
-+			flash_first_partition_index = i;
-+		} else if (!strcmp(info->partitions[i].name, info->last_sysupgrade_partition)) {
-+			flash_last_partition = &info->partitions[i];
-+			flash_last_partition_index = i;
-+		}
-+	}
-+
-+	assert(flash_first_partition && flash_last_partition);
-+	assert(flash_first_partition_index < flash_last_partition_index);
-+
-+	/** Find last partition from image to calculate needed size */
-+	for (i = 0; image_parts[i].name; i++) {
-+		if (!strcmp(image_parts[i].name, info->last_sysupgrade_partition)) {
-+			image_last_partition = &image_parts[i];
-+			break;
-+		}
-+	}
-+
-+	assert(image_last_partition);
-+
-+	*len = flash_last_partition->base - flash_first_partition->base + image_last_partition->size;
- 
- 	uint8_t *image = malloc(*len);
- 	if (!image)
-@@ -428,31 +634,44 @@ static void * generate_sysupgrade_image(const struct flash_partition_entry *flas
- 
- 	memset(image, 0xff, *len);
- 
--	memcpy(image, image_os_image->data, image_os_image->size);
--	memcpy(image + flash_soft_version->base - flash_os_image->base, image_soft_version->data, image_soft_version->size);
--	memcpy(image + flash_support_list->base - flash_os_image->base, image_support_list->data, image_support_list->size);
--	memcpy(image + flash_file_system->base - flash_os_image->base, image_file_system->data, image_file_system->size);
-+	for (i = flash_first_partition_index; i <= flash_last_partition_index; i++) {
-+		for (j = 0; image_parts[j].name; j++) {
-+			if (!strcmp(info->partitions[i].name, image_parts[j].name)) {
-+				if (image_parts[j].size > info->partitions[i].size)
-+					error(1, 0, "%s partition too big (more than %u bytes)", info->partitions[i].name, (unsigned)info->partitions[i].size);
-+				memcpy(image + info->partitions[i].base - flash_first_partition->base, image_parts[j].data, image_parts[j].size);
-+				break;
-+			}
-+
-+			assert(image_parts[j].name);
-+		}
-+	}
- 
- 	return image;
- }
- 
--
--/** Generates an image for CPE210/220/510/520 and writes it to a file */
--static void do_cpe510(const char *output, const char *kernel_image, const char *rootfs_image, uint32_t rev, bool add_jffs2_eof, bool sysupgrade) {
-+/** Generates an image according to a given layout and writes it to a file */
-+static void build_image(const char *output,
-+		const char *kernel_image,
-+		const char *rootfs_image,
-+		uint32_t rev,
-+		bool add_jffs2_eof,
-+		bool sysupgrade,
-+		const struct device_info *info) {
- 	struct image_partition_entry parts[6] = {};
- 
--	parts[0] = make_partition_table(cpe510_partitions);
-+	parts[0] = make_partition_table(info->partitions);
- 	parts[1] = make_soft_version(rev);
--	parts[2] = make_support_list(cpe510_support_list);
-+	parts[2] = make_support_list(info);
- 	parts[3] = read_file("os-image", kernel_image, false);
- 	parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
- 
- 	size_t len;
- 	void *image;
- 	if (sysupgrade)
--		image = generate_sysupgrade_image(cpe510_partitions, parts, &len);
-+		image = generate_sysupgrade_image(info, parts, &len);
- 	else
--		image = generate_factory_image(cpe510_vendor, parts, &len);
-+		image = generate_factory_image(info, parts, &len);
- 
- 	FILE *file = fopen(output, "wb");
- 	if (!file)
-@@ -470,7 +689,6 @@ static void do_cpe510(const char *output, const char *kernel_image, const char *
- 		free_image_partition(parts[i]);
- }
- 
--
- /** Usage output */
- static void usage(const char *argv0) {
- 	fprintf(stderr,
-@@ -490,10 +708,22 @@ static void usage(const char *argv0) {
- };
- 
- 
-+static const struct device_info *find_board(const char *id)
-+{
-+	struct device_info *board = NULL;
-+
-+	for (board = boards; board->id != NULL; board++)
-+		if (strcasecmp(id, board->id) == 0)
-+			return board;
-+
-+	return NULL;
-+}
-+
- int main(int argc, char *argv[]) {
- 	const char *board = NULL, *kernel_image = NULL, *rootfs_image = NULL, *output = NULL;
- 	bool add_jffs2_eof = false, sysupgrade = false;
- 	unsigned rev = 0;
-+	const struct device_info *info;
- 
- 	while (true) {
- 		int c;
-@@ -550,10 +780,12 @@ int main(int argc, char *argv[]) {
- 	if (!output)
- 		error(1, 0, "no output filename has been specified");
- 
--	if (strcmp(board, "CPE510") == 0)
--		do_cpe510(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade);
--	else
-+	info = find_board(board);
-+
-+	if (info == NULL)
- 		error(1, 0, "unsupported board %s", board);
- 
-+	build_image(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade, info);
-+
- 	return 0;
- }

+ 0 - 26
patches/openwrt/0066-ar71xx-split-CPE210-from-CPE510-profile.patch

@@ -1,26 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 9 Jun 2016 05:03:35 +0200
-Subject: ar71xx: split CPE210 from CPE510 profile
-
-The CPE210 was still described for the OEM upgrade as compatible,
-even the wireless configuration isn't compatible anymore between
-both series (2ghz and 5ghz).
-Update the CPE210 image profile to use the new profile.
-
-Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-
-Backport of LEDE 824147960569f2c1cd22140c9074c62c3df911a5
-
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 75083f9b698ba8a438256209a34369eb626a3b3d..bb2bb94e04ee8f59db62907ace49952061b411dc 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -2111,7 +2111,7 @@ $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V2,tl-wr1043nd-v2,TL-WR10
- $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V3,tl-wr1043nd-v3,TL-WR1043ND-v2,ttyS0,115200,0x10430003,1,8M))
- $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR2543,tl-wr2543-v1,TL-WR2543N,ttyS0,115200,0x25430001,1,8Mlzma,-v 3.13.99))
- 
--$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE210_220,cpe210-220,CPE210,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
-+$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE210_220,cpe210-220,CPE210,ttyS0,115200,$$(cpe510_mtdlayout),CPE210))
- $(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510_520,cpe510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
- 
- $(eval $(call SingleProfile,UAPPRO,64k,UAPPRO,ubnt-uap-pro,UAP-PRO,ttyS0,115200,BZ,BZ,ar934x))

+ 0 - 437
patches/openwrt/0067-dropbear-update-to-LEDE-277f85c21ae0ede4e15e66cbd801b9fb502531df.patch

@@ -1,437 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Mon, 22 Aug 2016 19:14:52 +0200
-Subject: dropbear: update to LEDE 277f85c21ae0ede4e15e66cbd801b9fb502531df
-
-Includes a few security updates and enables Curve25519 support.
-
-The patches 600-allow-blank-root-password.patch and
-610-skip-default-keys-in-custom-runs.patch are left out for now to avoid
-allowing password-less root login.
-
-diff --git a/package/network/services/dropbear/Config.in b/package/network/services/dropbear/Config.in
-index e2a761034fa64225439db4a18030dee75fb0775c..7c2edd79f23708f9ef01c6a62a54073b0c7a33ed 100644
---- a/package/network/services/dropbear/Config.in
-+++ b/package/network/services/dropbear/Config.in
-@@ -1,6 +1,15 @@
- menu "Configuration"
- 	depends on PACKAGE_dropbear
- 
-+config DROPBEAR_CURVE25519
-+	bool "Curve25519 support"
-+	default y
-+	help
-+		This enables the following key exchange algorithm:
-+		  curve25519-sha256@libssh.org
-+
-+		Increases binary size by about 13 kB uncompressed (MIPS).
-+
- config DROPBEAR_ECC
- 	bool "Elliptic curve cryptography (ECC)"
- 	default n
-@@ -12,7 +21,6 @@ config DROPBEAR_ECC
- 		  ecdh-sha2-nistp256
- 		  ecdh-sha2-nistp384
- 		  ecdh-sha2-nistp521
--		  curve25519-sha256@libssh.org
- 
- 		Public key algorithms:
- 		  ecdsa-sha2-nistp256
-@@ -22,6 +30,21 @@ config DROPBEAR_ECC
- 		Does not generate ECC host keys by default (ECC key exchange will not be used,
- 		only ECC public key auth).
- 
--		Increases binary size by about 36 kB (MIPS).
-+		Increases binary size by about 23 kB (MIPS).
-+
-+config DROPBEAR_UTMP
-+	bool "Utmp support"
-+	default n
-+	depends on BUSYBOX_CONFIG_FEATURE_UTMP
-+	help
-+		This enables dropbear utmp support, the file /var/run/utmp is used to
-+		track who is currently logged in.
-+
-+config DROPBEAR_PUTUTLINE
-+	bool "Pututline support"
-+	default n
-+	depends on DROPBEAR_UTMP
-+	help
-+		Dropbear will use pututline() to write the utmp structure into the utmp file.
- 
- endmenu
-diff --git a/package/network/services/dropbear/Makefile b/package/network/services/dropbear/Makefile
-index 35958d332cd0c9796ba50c433b13a3e24cd4441c..36bcb4ab7b6c57460cd15da1bcc130af62e32bc6 100644
---- a/package/network/services/dropbear/Makefile
-+++ b/package/network/services/dropbear/Makefile
-@@ -1,5 +1,5 @@
- #
--# Copyright (C) 2006-2014 OpenWrt.org
-+# Copyright (C) 2006-2016 OpenWrt.org
- #
- # This is free software, licensed under the GNU General Public License v2.
- # See /LICENSE for more information.
-@@ -8,14 +8,14 @@
- include $(TOPDIR)/rules.mk
- 
- PKG_NAME:=dropbear
--PKG_VERSION:=2015.67
-+PKG_VERSION:=2016.74
- PKG_RELEASE:=1
- 
- PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
- PKG_SOURCE_URL:= \
- 	http://matt.ucc.asn.au/dropbear/releases/ \
- 	https://dropbear.nl/mirror/releases/
--PKG_MD5SUM:=e967e320344cd4bfebe321e3ab8514d6
-+PKG_MD5SUM:=9ad0172731e0f16623937804643b5bd8
- 
- PKG_LICENSE:=MIT
- PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
-@@ -23,10 +23,14 @@ PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
- PKG_BUILD_PARALLEL:=1
- PKG_USE_MIPS16:=0
- 
--PKG_CONFIG_DEPENDS:=CONFIG_DROPBEAR_ECC
-+PKG_CONFIG_DEPENDS:=CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_CURVE25519
- 
- include $(INCLUDE_DIR)/package.mk
- 
-+ifneq ($(DUMP),1)
-+  STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) echo $(CONFIG_TARGET_INIT_PATH) | md5s)
-+endif
-+
- define Package/dropbear/Default
-   URL:=http://matt.ucc.asn.au/dropbear/
- endef
-@@ -48,7 +52,6 @@ endef
- 
- define Package/dropbear/conffiles
- /etc/dropbear/dropbear_rsa_host_key
--/etc/dropbear/dropbear_dss_host_key 
- /etc/config/dropbear 
- endef
- 
-@@ -65,25 +68,35 @@ CONFIGURE_ARGS += \
- 	--enable-syslog \
- 	$(if $(CONFIG_SHADOW_PASSWORDS),,--disable-shadow) \
- 	--disable-lastlog \
--	--disable-utmp \
- 	--disable-utmpx \
-+	$(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
- 	--disable-wtmp \
- 	--disable-wtmpx \
- 	--disable-loginfunc \
--	--disable-pututline \
-+	$(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
- 	--disable-pututxline \
- 	--disable-zlib \
- 	--enable-bundled-libtom
- 
--TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections
-+TARGET_CFLAGS += -DDEFAULT_PATH=\\\"$(CONFIG_TARGET_INIT_PATH)\\\" -DARGTYPE=3 -ffunction-sections -fdata-sections
- TARGET_LDFLAGS += -Wl,--gc-sections
- 
- define Build/Configure
- 	$(Build/Configure/Default)
- 
-+	$(SED) 's,^#define DEFAULT_PATH .*$$$$,#define DEFAULT_PATH "$(CONFIG_TARGET_INIT_PATH)",g' \
-+		$(PKG_BUILD_DIR)/options.h
-+
-+	awk 'BEGIN { rc = 1 } \
-+	     /'DROPBEAR_CURVE25519'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_CURVE25519),,// )#define 'DROPBEAR_CURVE25519'"; rc = 0 } \
-+	     { print } \
-+	     END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \
-+	     >$(PKG_BUILD_DIR)/options.h.new && \
-+	mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h
-+
- 	# Enforce that all replacements are made, otherwise options.h has changed
- 	# format and this logic is broken.
--	for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH DROPBEAR_CURVE25519; do \
-+	for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH; do \
- 	  awk 'BEGIN { rc = 1 } \
- 	       /'$$$$OPTION'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_ECC),,// )#define '$$$$OPTION'"; rc = 0 } \
- 	       { print } \
-@@ -91,6 +104,9 @@ define Build/Configure
- 	       >$(PKG_BUILD_DIR)/options.h.new && \
- 	  mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h || exit 1; \
- 	done
-+
-+	# Enforce rebuild of svr-chansession.c
-+	rm -f $(PKG_BUILD_DIR)/svr-chansession.o
- endef
- 
- define Build/Compile
-@@ -118,7 +134,6 @@ define Package/dropbear/install
- 	$(INSTALL_DIR) $(1)/usr/lib/opkg/info
- 	$(INSTALL_DIR) $(1)/etc/dropbear
- 	touch $(1)/etc/dropbear/dropbear_rsa_host_key
--	touch $(1)/etc/dropbear/dropbear_dss_host_key
- endef
- 
- define Package/dropbearconvert/install
-diff --git a/package/network/services/dropbear/files/dropbear.init b/package/network/services/dropbear/files/dropbear.init
-index 6de0142728dfa127652ecceef1d25080069d800a..1653efbdb38b1037c3630595b903c839887a4e52 100755
---- a/package/network/services/dropbear/files/dropbear.init
-+++ b/package/network/services/dropbear/files/dropbear.init
-@@ -37,7 +37,6 @@ validate_section_dropbear()
- 		'RootPasswordAuth:bool:1' \
- 		'RootLogin:bool:1' \
- 		'rsakeyfile:file' \
--		'dsskeyfile:file' \
- 		'BannerFile:file' \
- 		'Port:list(port):22' \
- 		'SSHKeepAlive:uinteger:300' \
-@@ -49,7 +48,7 @@ dropbear_instance()
- {
- 	local PasswordAuth enable Interface GatewayPorts \
- 		RootPasswordAuth RootLogin rsakeyfile \
--		dsskeyfile BannerFile Port SSHKeepAlive IdleTimeout \
-+		BannerFile Port SSHKeepAlive IdleTimeout \
- 		mdns ipaddrs
- 
- 	validate_section_dropbear "${1}" || {
-@@ -75,18 +74,18 @@ dropbear_instance()
- 	[ "${RootPasswordAuth}" -eq 0 ] && procd_append_param command -g
- 	[ "${RootLogin}" -eq 0 ] && procd_append_param command -w
- 	[ -n "${rsakeyfile}" ] && procd_append_param command -r "${rsakeyfile}"
--	[ -n "${dsskeyfile}" ] && procd_append_param command -d "${dsskeyfile}"
- 	[ -n "${BannerFile}" ] && procd_append_param command -b "${BannerFile}"
- 	append_ports "${ipaddrs}" "${Port}"
- 	[ "${IdleTimeout}" -ne 0 ] && procd_append_param command -I "${IdleTimeout}"
- 	[ "${SSHKeepAlive}" -ne 0 ] && procd_append_param command -K "${SSHKeepAlive}"
- 	[ "${mdns}" -ne 0 ] && procd_add_mdns "ssh" "tcp" "$Port" "daemon=dropbear"
-+	procd_set_param respawn
- 	procd_close_instance
- }
- 
- keygen()
- {
--	for keytype in rsa dss; do
-+	for keytype in rsa; do
- 		# check for keys
- 		key=dropbear/dropbear_${keytype}_host_key
- 		[ -f /tmp/$key -o -s /etc/$key ] || {
-@@ -107,10 +106,15 @@ keygen()
- 	chmod 0700 /etc/dropbear
- }
- 
-+load_interfaces()
-+{
-+	config_get interface "$1" Interface
-+	interfaces=" ${interface} ${interfaces}"
-+}
-+
- start_service()
- {
--	[ -s /etc/dropbear/dropbear_rsa_host_key -a \
--	  -s /etc/dropbear/dropbear_dss_host_key ] || keygen
-+	[ -s /etc/dropbear/dropbear_rsa_host_key ] || keygen
- 
- 	. /lib/functions.sh
- 	. /lib/functions/network.sh
-@@ -121,7 +125,19 @@ start_service()
- 
- service_triggers()
- {
--	procd_add_reload_trigger "dropbear"
-+	local interfaces
-+
-+	procd_add_config_trigger "config.change" "dropbear" /etc/init.d/dropbear reload
-+
-+	config_load "${NAME}"
-+	config_foreach load_interfaces dropbear
-+
-+	[ -n "${interfaces}" ] & {
-+		for n in $interfaces ; do
-+			procd_add_interface_trigger "interface.*" $n /etc/init.d/dropbear reload
-+		done
-+	}
-+
- 	procd_add_validation validate_section_dropbear
- }
- 
-diff --git a/package/network/services/dropbear/patches/100-pubkey_path.patch b/package/network/services/dropbear/patches/100-pubkey_path.patch
-index 456874b730272f157bd3f4b2e9f65e14eda49b0b..41fdc1adab96cf9efffa8593000336c504fdf6fb 100644
---- a/package/network/services/dropbear/patches/100-pubkey_path.patch
-+++ b/package/network/services/dropbear/patches/100-pubkey_path.patch
-@@ -1,6 +1,6 @@
- --- a/svr-authpubkey.c
- +++ b/svr-authpubkey.c
--@@ -208,17 +208,21 @@ static int checkpubkey(unsigned char* al
-+@@ -218,17 +218,21 @@ static int checkpubkey(char* algo, unsig
-  		goto out;
-  	}
-  
-@@ -33,7 +33,7 @@
-  	if (authfile == NULL) {
-  		goto out;
-  	}
--@@ -371,26 +375,35 @@ static int checkpubkeyperms() {
-+@@ -381,26 +385,35 @@ static int checkpubkeyperms() {
-  		goto out;
-  	}
-  
-diff --git a/package/network/services/dropbear/patches/110-change_user.patch b/package/network/services/dropbear/patches/110-change_user.patch
-index 7982af631539e351d3d46f50541115f9311612db..4b5c1cb51bb16a7229c03b6298796769e5752f6b 100644
---- a/package/network/services/dropbear/patches/110-change_user.patch
-+++ b/package/network/services/dropbear/patches/110-change_user.patch
-@@ -1,6 +1,6 @@
- --- a/svr-chansession.c
- +++ b/svr-chansession.c
--@@ -920,12 +920,12 @@ static void execchild(void *user_data) {
-+@@ -922,12 +922,12 @@ static void execchild(void *user_data) {
-  	/* We can only change uid/gid as root ... */
-  	if (getuid() == 0) {
-  
-diff --git a/package/network/services/dropbear/patches/120-openwrt_options.patch b/package/network/services/dropbear/patches/120-openwrt_options.patch
-index 48dae73b1f7bcb052172f0a8d22d06203c80f993..f16aaf001eee11811be81fa1db399cf117e66595 100644
---- a/package/network/services/dropbear/patches/120-openwrt_options.patch
-+++ b/package/network/services/dropbear/patches/120-openwrt_options.patch
-@@ -18,7 +18,28 @@
-  
-  /* Whether to support "-c" and "-m" flags to choose ciphers/MACs at runtime */
-  #define ENABLE_USER_ALGO_LIST
--@@ -126,9 +126,9 @@ much traffic. */
-+@@ -91,16 +91,16 @@ much traffic. */
-+  * Including multiple keysize variants the same cipher 
-+  * (eg AES256 as well as AES128) will result in a minimal size increase.*/
-+ #define DROPBEAR_AES128
-+-#define DROPBEAR_3DES
-++/*#define DROPBEAR_3DES*/
-+ #define DROPBEAR_AES256
-+ /* Compiling in Blowfish will add ~6kB to runtime heap memory usage */
-+ /*#define DROPBEAR_BLOWFISH*/
-+-#define DROPBEAR_TWOFISH256
-+-#define DROPBEAR_TWOFISH128
-++/*#define DROPBEAR_TWOFISH256*/
-++/*#define DROPBEAR_TWOFISH128*/
-+ 
-+ /* Enable CBC mode for ciphers. This has security issues though
-+  * is the most compatible with older SSH implementations */
-+-#define DROPBEAR_ENABLE_CBC_MODE
-++/*#define DROPBEAR_ENABLE_CBC_MODE*/
-+ 
-+ /* Enable "Counter Mode" for ciphers. This is more secure than normal
-+  * CBC mode against certain attacks. It is recommended for security
-+@@ -131,9 +131,9 @@ If you test it please contact the Dropbe
-   * If you disable MD5, Dropbear will fall back to SHA1 fingerprints,
-   * which are not the standard form. */
-  #define DROPBEAR_SHA1_HMAC
-@@ -31,7 +52,16 @@
-  #define DROPBEAR_MD5_HMAC
-  
-  /* You can also disable integrity. Don't bother disabling this if you're
--@@ -184,7 +184,7 @@ much traffic. */
-+@@ -146,7 +146,7 @@ If you test it please contact the Dropbe
-+  * Removing either of these won't save very much space.
-+  * SSH2 RFC Draft requires dss, recommends rsa */
-+ #define DROPBEAR_RSA
-+-#define DROPBEAR_DSS
-++/*#define DROPBEAR_DSS*/
-+ /* ECDSA is significantly faster than RSA or DSS. Compiling in ECC
-+  * code (either ECDSA or ECDH) increases binary size - around 30kB
-+  * on x86-64 */
-+@@ -194,7 +194,7 @@ If you test it please contact the Dropbe
-  
-  /* Whether to print the message of the day (MOTD). This doesn't add much code
-   * size */
-@@ -40,7 +70,7 @@
-  
-  /* The MOTD file path */
-  #ifndef MOTD_FILENAME
--@@ -226,7 +226,7 @@ much traffic. */
-+@@ -242,7 +242,7 @@ Homedir is prepended unless path begins
-   * note that it will be provided for all "hidden" client-interactive
-   * style prompts - if you want something more sophisticated, use 
-   * SSH_ASKPASS instead. Comment out this var to remove this functionality.*/
-diff --git a/package/network/services/dropbear/patches/130-ssh_ignore_o_and_x_args.patch b/package/network/services/dropbear/patches/130-ssh_ignore_o_and_x_args.patch
-deleted file mode 100644
-index edb29093aece5423554ccd406e34b41466c25511..0000000000000000000000000000000000000000
---- a/package/network/services/dropbear/patches/130-ssh_ignore_o_and_x_args.patch
-+++ /dev/null
-@@ -1,21 +0,0 @@
----- a/cli-runopts.c
--+++ b/cli-runopts.c
--@@ -315,6 +315,10 @@ void cli_getopts(int argc, char ** argv)
-- 					debug_trace = 1;
-- 					break;
-- #endif
--+				case 'o':
--+					next = &dummy;
--+				case 'x':
--+					break;
-- 				case 'F':
-- 				case 'e':
-- #ifndef ENABLE_USER_ALGO_LIST
--@@ -332,7 +336,6 @@ void cli_getopts(int argc, char ** argv)
-- 					print_version();
-- 					exit(EXIT_SUCCESS);
-- 					break;
---				case 'o':
-- 				case 'b':
-- 					next = &dummy;
-- 				default:
-diff --git a/package/network/services/dropbear/patches/130-ssh_ignore_x_args.patch b/package/network/services/dropbear/patches/130-ssh_ignore_x_args.patch
-new file mode 100644
-index 0000000000000000000000000000000000000000..ab09c2f3dc3a253fd18acae8d7d3b4b0f668e3dd
---- /dev/null
-+++ b/package/network/services/dropbear/patches/130-ssh_ignore_x_args.patch
-@@ -0,0 +1,11 @@
-+--- a/cli-runopts.c
-++++ b/cli-runopts.c
-+@@ -296,6 +296,8 @@ void cli_getopts(int argc, char ** argv)
-+ 					debug_trace = 1;
-+ 					break;
-+ #endif
-++				case 'x':
-++					break;
-+ 				case 'F':
-+ 				case 'e':
-+ #ifndef ENABLE_USER_ALGO_LIST
-diff --git a/package/network/services/dropbear/patches/140-disable_assert.patch b/package/network/services/dropbear/patches/140-disable_assert.patch
-index 0717228ef3de0576967b3824ca9709f95a326f61..78b54acfa0f52a4abbae497ed57a04cca7368c41 100644
---- a/package/network/services/dropbear/patches/140-disable_assert.patch
-+++ b/package/network/services/dropbear/patches/140-disable_assert.patch
-@@ -1,6 +1,6 @@
- --- a/dbutil.h
- +++ b/dbutil.h
--@@ -101,7 +101,11 @@ int m_str_to_uint(const char* str, unsig
-+@@ -78,7 +78,11 @@ int m_str_to_uint(const char* str, unsig
-  #define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
-  
-  /* Dropbear assertion */
-diff --git a/package/network/services/dropbear/patches/150-dbconvert_standalone.patch b/package/network/services/dropbear/patches/150-dbconvert_standalone.patch
-index 367dc2c68122f382273464fc7bf570fde18386ab..ccc2cb792598de77b4db6aa7b7b46e8eb7bf93a5 100644
---- a/package/network/services/dropbear/patches/150-dbconvert_standalone.patch
-+++ b/package/network/services/dropbear/patches/150-dbconvert_standalone.patch
-@@ -1,8 +1,8 @@
- --- a/options.h
- +++ b/options.h
- @@ -5,6 +5,11 @@
-- #ifndef _OPTIONS_H_
-- #define _OPTIONS_H_
-+ #ifndef DROPBEAR_OPTIONS_H_
-+ #define DROPBEAR_OPTIONS_H_
-  
- +#if !defined(DROPBEAR_CLIENT) && !defined(DROPBEAR_SERVER)
- +#define DROPBEAR_SERVER
-diff --git a/package/network/services/dropbear/patches/500-set-default-path.patch b/package/network/services/dropbear/patches/500-set-default-path.patch
-index e2add9415fd4e7884a007ce7337ee8026bcc62a7..da6b9ae0ce0ae6a270f8c7bc6152cf09efbee15d 100644
---- a/package/network/services/dropbear/patches/500-set-default-path.patch
-+++ b/package/network/services/dropbear/patches/500-set-default-path.patch
-@@ -1,11 +1,12 @@
- --- a/options.h
- +++ b/options.h
--@@ -336,7 +336,7 @@ be overridden at runtime with -I. 0 disa
-+@@ -352,7 +352,9 @@ be overridden at runtime with -I. 0 disa
-  #define DEFAULT_IDLE_TIMEOUT 0
-  
-  /* The default path. This will often get replaced by the shell */
---#define DEFAULT_PATH "/usr/bin:/bin"
--+#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin"
-++#ifndef DEFAULT_PATH
-+ #define DEFAULT_PATH "/usr/bin:/bin"
-++#endif
-  
-  /* Some other defines (that mostly should be left alone) are defined
-   * in sysoptions.h */

+ 0 - 567
patches/openwrt/0068-ar71xx-Added-support-for-TL-WA801NDv3.patch

@@ -1,567 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Mon, 22 Aug 2016 23:55:22 +0200
-Subject: ar71xx: Added support for TL-WA801NDv3
-
-Signed-off-by: Tiziano Bacocco <tizbac2@gmail.com>
-
-Backport of OpenWrt r48705
-
-diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-index 6c3ecf54dccd111231d93e539346f7839252794c..027a671215e5acd70cee06620c6648506ad6be47 100755
---- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
-@@ -377,6 +377,7 @@ wp543)
- 	ucidef_set_interface_lan "eth0"
- 	;;
- 
-+tl-wa801nd-v3 |\
- dir-505-a1)
- 	ucidef_set_interface_lan "eth1"
- 	;;
-diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-index 0d8ccd21c3f552b7ae7aff6905a08ff6a4fdadf7..5928439f3ae253fc15eeb2ac30451ff467411e88 100755
---- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
-+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
-@@ -838,6 +838,9 @@ ar71xx_board_detect() {
- 	*"TL-WA801ND v2")
- 		name="tl-wa801nd-v2"
- 		;;
-+	*"TL-WA801ND v3")
-+		name="tl-wa801nd-v3"
-+		;;
- 	*TL-WA901ND)
- 		name="tl-wa901nd"
- 		;;
-diff --git a/target/linux/ar71xx/config-3.18 b/target/linux/ar71xx/config-3.18
-index d4d92738d0ab010e1d43ebed0baef34fd9bc3f9d..d7cbe2e79af31a0ff88d946323e237f3215620a0 100644
---- a/target/linux/ar71xx/config-3.18
-+++ b/target/linux/ar71xx/config-3.18
-@@ -120,6 +120,7 @@ CONFIG_ATH79_MACH_TL_MR3020=y
- CONFIG_ATH79_MACH_TL_MR3X20=y
- CONFIG_ATH79_MACH_TL_WA701ND_V2=y
- CONFIG_ATH79_MACH_TL_WA7210N_V2=y
-+CONFIG_ATH79_MACH_TL_WA801ND_V3=y
- CONFIG_ATH79_MACH_TL_WA830RE_V2=y
- CONFIG_ATH79_MACH_TL_WA901ND=y
- CONFIG_ATH79_MACH_TL_WA901ND_V2=y
-diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa801nd-v3.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa801nd-v3.c
-new file mode 100644
-index 0000000000000000000000000000000000000000..39cdb10ee340650bc69e4f6054b06a4ae7421e57
---- /dev/null
-+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa801nd-v3.c
-@@ -0,0 +1,136 @@
-+/*
-+ *  TP-LINK TL-WA801ND v3 adapted from TP-LINK TL-WR841N/ND v9
-+ *
-+ *  Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
-+ *  Copyright (C) 2016 Tiziano Bacocco <tizbac2@gmail.com>
-+ *
-+ *  This program is free software; you can redistribute it and/or modify it
-+ *  under the terms of the GNU General Public License version 2 as published
-+ *  by the Free Software Foundation.
-+ */
-+
-+#include <linux/gpio.h>
-+#include <linux/platform_device.h>
-+
-+#include <asm/mach-ath79/ath79.h>
-+#include <asm/mach-ath79/ar71xx_regs.h>
-+
-+#include "common.h"
-+#include "dev-eth.h"
-+#include "dev-gpio-buttons.h"
-+#include "dev-leds-gpio.h"
-+#include "dev-m25p80.h"
-+#include "dev-wmac.h"
-+#include "machtypes.h"
-+
-+#define TL_WA801NDV3_GPIO_LED_WLAN	12
-+#define TL_WA801NDV3_GPIO_LED_QSS	13
-+#define TL_WA801NDV3_GPIO_LED_SECURITY_RED 11
-+#define TL_WA801NDV3_GPIO_LED_SECURITY_GREEN 15
-+#define TL_WA801NDV3_GPIO_LED_LAN 3
-+
-+#define TL_WA801NDV3_GPIO_BTN_RESET	2
-+#define TL_WA801NDV3_GPIO_BTN_WIFI	1
-+
-+#define TL_WA801NDV3_KEYS_POLL_INTERVAL	20	/* msecs */
-+#define TL_WA801NDV3_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA801NDV3_KEYS_POLL_INTERVAL)
-+
-+static const char *tl_wa801n_v3_part_probes[] = {
-+	"tp-link",
-+	NULL,
-+};
-+
-+static struct flash_platform_data tl_wa801n_v3_flash_data = {
-+	.part_probes	= tl_wa801n_v3_part_probes,
-+};
-+
-+static struct gpio_led tl_wa801n_v3_leds_gpio[] __initdata = {
-+  {
-+		.name		= "tp-link:green:qss",
-+		.gpio		= TL_WA801NDV3_GPIO_LED_QSS,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:lan",
-+		.gpio		= TL_WA801NDV3_GPIO_LED_LAN,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:green:wlan",
-+		.gpio		= TL_WA801NDV3_GPIO_LED_WLAN,
-+		.active_low	= 1,
-+	}, {
-+		.name		= "tp-link:red:security",
-+		.gpio		= TL_WA801NDV3_GPIO_LED_SECURITY_RED,
-+		.active_low	= 0,
-+	}, {
-+		.name		= "tp-link:green:security",
-+		.gpio		= TL_WA801NDV3_GPIO_LED_SECURITY_GREEN,
-+		.active_low	= 0,
-+	}
-+
-+};
-+
-+static struct gpio_keys_button tl_wa801n_v3_gpio_keys[] __initdata = {
-+	{
-+		.desc		= "Reset button",
-+		.type		= EV_KEY,
-+		.code		= KEY_RESTART,
-+		.debounce_interval = TL_WA801NDV3_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio		= TL_WA801NDV3_GPIO_BTN_RESET,
-+		.active_low	= 1,
-+	}, {
-+		.desc		= "WIFI button",
-+		.type		= EV_KEY,
-+		.code		= KEY_RFKILL,
-+		.debounce_interval = TL_WA801NDV3_KEYS_DEBOUNCE_INTERVAL,
-+		.gpio		= TL_WA801NDV3_GPIO_BTN_WIFI,
-+		.active_low	= 1,
-+	}
-+};
-+
-+
-+static void __init tl_ap143_setup(void)
-+{
-+	u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
-+	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
-+	u8 tmpmac[ETH_ALEN];
-+
-+	ath79_register_m25p80(&tl_wa801n_v3_flash_data);
-+
-+	ath79_setup_ar933x_phy4_switch(false, false);
-+
-+	ath79_register_mdio(0, 0x0);
-+
-+	/* LAN */
-+	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
-+	ath79_eth1_data.duplex = DUPLEX_FULL;
-+	ath79_switch_data.phy_poll_mask |= BIT(4);
-+	ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
-+	ath79_register_eth(1);
-+
-+	/* WAN */
-+	ath79_switch_data.phy4_mii_en = 1;
-+	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
-+	ath79_eth0_data.duplex = DUPLEX_FULL;
-+	ath79_eth0_data.speed = SPEED_100;
-+	ath79_eth0_data.phy_mask = BIT(4);
-+	ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
-+	ath79_register_eth(0);
-+
-+	ath79_init_mac(tmpmac, mac, 0);
-+	ath79_register_wmac(ee, tmpmac);
-+}
-+
-+static void __init tl_wa801n_v3_setup(void)
-+{
-+	tl_ap143_setup();
-+
-+	ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801n_v3_leds_gpio),
-+				 tl_wa801n_v3_leds_gpio);
-+
-+	ath79_register_gpio_keys_polled(1, TL_WA801NDV3_KEYS_POLL_INTERVAL,
-+					ARRAY_SIZE(tl_wa801n_v3_gpio_keys),
-+					tl_wa801n_v3_gpio_keys);
-+}
-+
-+MIPS_MACHINE(ATH79_MACH_TL_WA801ND_V3, "TL-WA801ND-v3", "TP-LINK TL-WA801ND v3",
-+	     tl_wa801n_v3_setup);
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index bb2bb94e04ee8f59db62907ace49952061b411dc..868a5021acb49878359497c90509de07faa3ca49 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -691,6 +691,13 @@ define Device/tl-wa801nd-v2
-     TPLINK_HWID := 0x08010002
- endef
- 
-+define Device/tl-wa801nd-v3
-+    $(Device/tplink-4mlzma)
-+    BOARDNAME := TL-WA801ND-v3
-+    DEVICE_PROFILE := TLWA801
-+    TPLINK_HWID := 0x08010003
-+endef
-+
- define Device/tl-wa830re-v2
-     $(Device/tplink-4mlzma)
-     BOARDNAME := TL-WA830RE-v2
-@@ -711,7 +718,7 @@ define Device/tl-wa860re-v1
-     DEVICE_PROFILE := TLWA860
-     TPLINK_HWID := 0x08600001
- endef
--TARGET_DEVICES += tl-wa801nd-v2 tl-wa830re-v2 tl-wa850re-v1 tl-wa860re-v1
-+TARGET_DEVICES += tl-wa801nd-v2 tl-wa801nd-v3 tl-wa830re-v2 tl-wa850re-v1 tl-wa860re-v1
- 
- define Device/tl-wa901nd-v3
-     $(Device/tplink-4mlzma)
-diff --git a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-index c83ac2e89324deda3135aab84e8c4f4112ea728d..d23f0cf33e50da891e7135861f1defda047ff2c8 100644
---- a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-+++ b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
-@@ -1,6 +1,6 @@
- --- a/arch/mips/ath79/machtypes.h
- +++ b/arch/mips/ath79/machtypes.h
--@@ -16,22 +16,204 @@
-+@@ -16,22 +16,205 @@
-  
-  enum ath79_mach_type {
-  	ATH79_MACH_GENERIC = 0,
-@@ -127,6 +127,7 @@
- +	ATH79_MACH_TL_WA850RE,		/* TP-LINK TL-WA850RE */
- +	ATH79_MACH_TL_WA860RE,		/* TP-LINK TL-WA860RE */
- +	ATH79_MACH_TL_WA801ND_V2,	/* TP-LINK TL-WA801ND v2 */
-++	ATH79_MACH_TL_WA801ND_V3,	/* TP-LINK TL-WA801ND v3 */
- +	ATH79_MACH_TL_WA830RE_V2,	/* TP-LINK TL-WA830RE v2 */
- +	ATH79_MACH_TL_WA901ND,		/* TP-LINK TL-WA901ND */
- +	ATH79_MACH_TL_WA901ND_V2,	/* TP-LINK TL-WA901ND v2 */
-@@ -287,17 +288,10 @@
-  config ATH79_MACH_AP121
-  	bool "Atheros AP121 reference board"
-  	select SOC_AR933X
--@@ -11,62 +84,1051 @@ config ATH79_MACH_AP121
-- 	select ATH79_DEV_M25P80
-- 	select ATH79_DEV_USB
-- 	select ATH79_DEV_WMAC
---	help
---	  Say 'Y' here if you want your kernel to support the
---	  Atheros AP121 reference board.
--+	help
--+	  Say 'Y' here if you want your kernel to support the
--+	  Atheros AP121 reference board.
--+
-+@@ -15,13 +88,25 @@ config ATH79_MACH_AP121
-+ 	  Say 'Y' here if you want your kernel to support the
-+ 	  Atheros AP121 reference board.
-+ 
- +config ATH79_MACH_AP132
- +	bool "Atheros AP132 reference board"
- +	select SOC_QCA955X
-@@ -310,32 +304,21 @@
- +	  Say 'Y' here if you want your kernel to support the
- +	  Atheros AP132 reference boards.
- +
--+config ATH79_MACH_AP136
--+	bool "Atheros AP136/AP135 reference board"
--+	select SOC_QCA955X
--+	select ATH79_DEV_GPIO_BUTTONS
--+	select ATH79_DEV_LEDS_GPIO
--+	select ATH79_DEV_NFC
--+	select ATH79_DEV_M25P80
--+	select ATH79_DEV_USB
--+	select ATH79_DEV_WMAC
--+	help
--+	  Say 'Y' here if you want your kernel to support the
--+	  Atheros AP136 or AP135 reference boards.
--+
--+config ATH79_MACH_AP81
--+	bool "Atheros AP81 reference board"
--+	select SOC_AR913X
--+	select ATH79_DEV_ETH
--+	select ATH79_DEV_GPIO_BUTTONS
--+	select ATH79_DEV_LEDS_GPIO
-+ config ATH79_MACH_AP136
-+ 	bool "Atheros AP136/AP135 reference board"
-+ 	select SOC_QCA955X
-+ 	select ATH79_DEV_GPIO_BUTTONS
-+ 	select ATH79_DEV_LEDS_GPIO
-+ 	select ATH79_DEV_NFC
-+-	select ATH79_DEV_SPI
- +	select ATH79_DEV_M25P80
--+	select ATH79_DEV_USB
--+	select ATH79_DEV_WMAC
--+	help
--+	  Say 'Y' here if you want your kernel to support the
--+	  Atheros AP81 reference board.
--+
-+ 	select ATH79_DEV_USB
-+ 	select ATH79_DEV_WMAC
-+ 	help
-+@@ -41,6 +126,24 @@ config ATH79_MACH_AP81
-+ 	  Say 'Y' here if you want your kernel to support the
-+ 	  Atheros AP81 reference board.
-+ 
- +config ATH79_MACH_AP83
- +	bool "Atheros AP83 board support"
- +	select SOC_AR913X
-@@ -354,21 +337,13 @@
- +	select ATH79_DEV_M25P80
- +	select ATH79_DEV_USB
- +
--+config ATH79_MACH_DB120
--+	bool "Atheros DB120 reference board"
--+	select SOC_AR934X
--+	select ATH79_DEV_AP9X_PCI if PCI
--+	select ATH79_DEV_ETH
--+	select ATH79_DEV_GPIO_BUTTONS
--+	select ATH79_DEV_LEDS_GPIO
--+	select ATH79_DEV_M25P80
--+	select ATH79_DEV_NFC
--+	select ATH79_DEV_USB
--+	select ATH79_DEV_WMAC
--+	help
--+	  Say 'Y' here if you want your kernel to support the
--+	  Atheros DB120 reference board.
--+
-+ config ATH79_MACH_DB120
-+ 	bool "Atheros DB120 reference board"
-+ 	select SOC_AR934X
-+@@ -56,6 +159,13 @@ config ATH79_MACH_DB120
-+ 	  Say 'Y' here if you want your kernel to support the
-+ 	  Atheros DB120 reference board.
-+ 
- +config ATH79_MACH_PB42
- +	bool "Atheros PB42 board support"
- +	select SOC_AR71XX
-@@ -376,18 +351,13 @@
- +	select ATH79_DEV_GPIO_BUTTONS
- +	select ATH79_DEV_M25P80
- +
--+config ATH79_MACH_PB44
--+	bool "Atheros PB44 reference board"
--+	select SOC_AR71XX
--+	select ATH79_DEV_ETH
--+	select ATH79_DEV_GPIO_BUTTONS
--+	select ATH79_DEV_LEDS_GPIO
--+	select ATH79_DEV_SPI
--+	select ATH79_DEV_USB
--+	help
--+	  Say 'Y' here if you want your kernel to support the
--+	  Atheros PB44 reference board.
--+
-+ config ATH79_MACH_PB44
-+ 	bool "Atheros PB44 reference board"
-+ 	select SOC_AR71XX
-+@@ -68,6 +178,967 @@ config ATH79_MACH_PB44
-+ 	  Say 'Y' here if you want your kernel to support the
-+ 	  Atheros PB44 reference board.
-+ 
- +config ATH79_MACH_PB92
- +	bool "Atheros PB92 board support"
- +	select SOC_AR724X
-@@ -1113,6 +1083,15 @@
- +       select ATH79_DEV_M25P80
- +       select ATH79_DEV_WMAC
- +
-++config ATH79_MACH_TL_WA801ND_V3
-++	bool "TP-LINK TL-WA801ND v3 support"
-++	select SOC_QCA953X
-++	select ATH79_DEV_ETH
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
-++	select ATH79_DEV_M25P80
-++	select ATH79_DEV_WMAC
-++
- +config ATH79_MACH_TL_WA830RE_V2
- +	bool "TP-LINK TL-WA830RE v2 support"
- +	select SOC_AR934X
-@@ -1172,28 +1151,17 @@
- +	select ATH79_DEV_M25P80
- +	select ATH79_DEV_USB
- +	select ATH79_DEV_WMAC
-- 
---config ATH79_MACH_AP136
---	bool "Atheros AP136/AP135 reference board"
---	select SOC_QCA955X
-++
- +config ATH79_MACH_TL_WR720N_V3
- +	bool "TP-LINK TL-WR720N v3/v4 support"
- +	select SOC_AR933X
- +	select ATH79_DEV_ETH
-- 	select ATH79_DEV_GPIO_BUTTONS
-- 	select ATH79_DEV_LEDS_GPIO
---	select ATH79_DEV_NFC
---	select ATH79_DEV_SPI
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
- +	select ATH79_DEV_M25P80
-- 	select ATH79_DEV_USB
-- 	select ATH79_DEV_WMAC
---	help
---	  Say 'Y' here if you want your kernel to support the
---	  Atheros AP136 or AP135 reference boards.
-- 
---config ATH79_MACH_AP81
---	bool "Atheros AP81 reference board"
---	select SOC_AR913X
-++	select ATH79_DEV_USB
-++	select ATH79_DEV_WMAC
-++
- +config ATH79_MACH_TL_WR741ND
- +	bool "TP-LINK TL-WR741ND support"
- +	select SOC_AR724X
-@@ -1206,18 +1174,13 @@
- +config ATH79_MACH_TL_WR741ND_V4
- +	bool "TP-LINK TL-WR741ND v4/TL-MR3220 v2 support"
- +	select SOC_AR933X
-- 	select ATH79_DEV_ETH
-- 	select ATH79_DEV_GPIO_BUTTONS
-- 	select ATH79_DEV_LEDS_GPIO
-- 	select ATH79_DEV_M25P80
-- 	select ATH79_DEV_USB
-- 	select ATH79_DEV_WMAC
---	help
---	  Say 'Y' here if you want your kernel to support the
---	  Atheros AP81 reference board.
-- 
---config ATH79_MACH_DB120
---	bool "Atheros DB120 reference board"
-++	select ATH79_DEV_ETH
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
-++	select ATH79_DEV_M25P80
-++	select ATH79_DEV_USB
-++	select ATH79_DEV_WMAC
-++
- +config ATH79_MACH_TL_WR841N_V1
- +	bool "TP-LINK TL-WR841N v1 support"
- +	select SOC_AR71XX
-@@ -1268,21 +1231,15 @@
- +
- +config ATH79_MACH_TL_WR1041N_V2
- +	bool "TP-LINK TL-WR1041N v2 support"
-- 	select SOC_AR934X
-- 	select ATH79_DEV_AP9X_PCI if PCI
-- 	select ATH79_DEV_ETH
-- 	select ATH79_DEV_GPIO_BUTTONS
-- 	select ATH79_DEV_LEDS_GPIO
-- 	select ATH79_DEV_M25P80
---	select ATH79_DEV_NFC
-- 	select ATH79_DEV_USB
-- 	select ATH79_DEV_WMAC
---	help
---	  Say 'Y' here if you want your kernel to support the
---	  Atheros DB120 reference board.
-- 
---config ATH79_MACH_PB44
---	bool "Atheros PB44 reference board"
-++	select SOC_AR934X
-++	select ATH79_DEV_AP9X_PCI if PCI
-++	select ATH79_DEV_ETH
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
-++	select ATH79_DEV_M25P80
-++	select ATH79_DEV_USB
-++	select ATH79_DEV_WMAC
-++
- +config ATH79_MACH_TL_WR1043ND
- +	bool "TP-LINK TL-WR1043ND support"
- +	select SOC_AR913X
-@@ -1325,12 +1282,11 @@
- +
- +config ATH79_MACH_TEW_673GRU
- +	bool "TRENDnet TEW-673GRU support"
-- 	select SOC_AR71XX
-++	select SOC_AR71XX
- +	select ATH79_DEV_AP9X_PCI if PCI
-- 	select ATH79_DEV_ETH
-- 	select ATH79_DEV_GPIO_BUTTONS
-- 	select ATH79_DEV_LEDS_GPIO
---	select ATH79_DEV_SPI
-++	select ATH79_DEV_ETH
-++	select ATH79_DEV_GPIO_BUTTONS
-++	select ATH79_DEV_LEDS_GPIO
- +	select ATH79_DEV_M25P80
- +	select ATH79_DEV_USB
- +	select ATH79_NVRAM
-@@ -1361,14 +1317,12 @@
- +	select ATH79_DEV_GPIO_BUTTONS
- +	select ATH79_DEV_LEDS_GPIO
- +	select ATH79_DEV_M25P80
-- 	select ATH79_DEV_USB
---	help
---	  Say 'Y' here if you want your kernel to support the
---	  Atheros PB44 reference board.
-- 
-++	select ATH79_DEV_USB
-++
-  config ATH79_MACH_UBNT_XM
-  	bool "Ubiquiti Networks XM/UniFi boards"
--@@ -83,6 +1145,117 @@ config ATH79_MACH_UBNT_XM
-+ 	select SOC_AR724X
-+@@ -83,6 +1154,117 @@ config ATH79_MACH_UBNT_XM
-  	  Say 'Y' here if you want your kernel to support the
-  	  Ubiquiti Networks XM (rev 1.0) board.
-  
-@@ -1486,7 +1440,7 @@
-  endmenu
-  
-  config SOC_AR71XX
--@@ -124,7 +1297,10 @@ config ATH79_DEV_DSA
-+@@ -124,7 +1306,10 @@ config ATH79_DEV_DSA
-  config ATH79_DEV_ETH
-  	def_bool n
-  
-@@ -1498,7 +1452,7 @@
-  	def_bool n
-  
-  config ATH79_DEV_GPIO_BUTTONS
--@@ -154,6 +1330,11 @@ config ATH79_PCI_ATH9K_FIXUP
-+@@ -154,6 +1339,11 @@ config ATH79_PCI_ATH9K_FIXUP
-  	def_bool n
-  
-  config ATH79_ROUTERBOOT
-@@ -1512,7 +1466,7 @@
-  endif
- --- a/arch/mips/ath79/Makefile
- +++ b/arch/mips/ath79/Makefile
--@@ -38,9 +38,129 @@ obj-$(CONFIG_ATH79_ROUTERBOOT)		+= route
-+@@ -38,9 +38,130 @@ obj-$(CONFIG_ATH79_ROUTERBOOT)		+= route
-  #
-  # Machines
-  #
-@@ -1595,6 +1549,7 @@
- +obj-$(CONFIG_ATH79_MACH_TL_WA701ND_V2)	+= mach-tl-wa701nd-v2.o
- +obj-$(CONFIG_ATH79_MACH_TL_WA7210N_V2)	+= mach-tl-wa7210n-v2.o
- +obj-$(CONFIG_ATH79_MACH_TL_WA830RE_V2)	+= mach-tl-wa830re-v2.o
-++obj-$(CONFIG_ATH79_MACH_TL_WA801ND_V3)	+= mach-tl-wa801nd-v3.o
- +obj-$(CONFIG_ATH79_MACH_TL_WA901ND)	+= mach-tl-wa901nd.o
- +obj-$(CONFIG_ATH79_MACH_TL_WA901ND_V2)	+= mach-tl-wa901nd-v2.o
- +obj-$(CONFIG_ATH79_MACH_TL_WDR3500)     += mach-tl-wdr3500.o
-diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c
-index 6df869d59a6138d4c0dd1fbec5337a71c31eccd3..9785a3f232ed4457e77aee249c0da86b4e99c532 100644
---- a/tools/firmware-utils/src/mktplinkfw.c
-+++ b/tools/firmware-utils/src/mktplinkfw.c
-@@ -50,6 +50,7 @@
- #define HWID_TL_WA830RE_V1	0x08300010
- #define HWID_TL_WA830RE_V2	0x08300002
- #define HWID_TL_WA801ND_V2	0x08010002
-+#define HWID_TL_WA801ND_V3	0x08010003
- #define HWID_TL_WA901ND_V1	0x09010001
- #define HWID_TL_WA901ND_V2	0x09010002
- #define HWID_TL_WA901ND_V4	0x09010004
-@@ -296,6 +297,11 @@ static struct board_info boards[] = {
- 		.hw_id          = HWID_TL_WA801ND_V2,
- 		.hw_rev         = 1,
- 		.layout_id	= "4Mlzma",
-+	},{
-+		.id							= "TL-WA801NDv3",
-+		.hw_id          = HWID_TL_WA801ND_V3,
-+		.hw_rev         = 1,
-+		.layout_id  = "4Mlzma",
- 	}, {
- 		.id		= "TL-WA901NDv1",
- 		.hw_id		= HWID_TL_WA901ND_V1,
-@@ -1207,4 +1213,3 @@ int main(int argc, char *argv[])
-  out:
- 	return ret;
- }
--

+ 0 - 856
patches/openwrt/0069-firmware-utils-mktplinkfw-backport-from-LEDE-a4fc62bc0ea4010ddbfbd738453c9db70988a57c.patch

@@ -1,856 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 28 Aug 2016 20:20:35 +0200
-Subject: firmware-utils: mktplinkfw: backport from LEDE a4fc62bc0ea4010ddbfbd738453c9db70988a57c
-
-diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
-index 03978456636ad50fc8128c0a5a51845135301a3d..aee8e87a1c0839f3220686e97cd8458516fc17cf 100644
---- a/tools/firmware-utils/Makefile
-+++ b/tools/firmware-utils/Makefile
-@@ -40,7 +40,7 @@ define Host/Compile
- 	$(call cc,encode_crc)
- 	$(call cc,nand_ecc)
- 	$(call cc,mkplanexfw sha1)
--	$(call cc,mktplinkfw md5)
-+	$(call cc,mktplinkfw md5, -Wall)
- 	$(call cc,mktplinkfw2 md5)
- 	$(call cc,tplink-safeloader md5, -Wall)
- 	$(call cc,pc1crypt)
-diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c
-index 9785a3f232ed4457e77aee249c0da86b4e99c532..34e6546a2d7db72748146ef233830c2e8de9ce97 100644
---- a/tools/firmware-utils/src/mktplinkfw.c
-+++ b/tools/firmware-utils/src/mktplinkfw.c
-@@ -28,53 +28,10 @@
- #include "md5.h"
- 
- #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
-+#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
- 
- #define HEADER_VERSION_V1	0x01000000
--#define HWID_ANTMINER_S1	0x04440101
--#define HWID_ANTMINER_S3	0x04440301
--#define HWID_GL_INET_V1		0x08000001
--#define HWID_GS_OOLITE_V1	0x3C000101
--#define HWID_ONION_OMEGA	0x04700001
--#define HWID_TL_MR10U_V1	0x00100101
--#define HWID_TL_MR13U_V1	0x00130101
--#define HWID_TL_MR3020_V1	0x30200001
--#define HWID_TL_MR3220_V1	0x32200001
--#define HWID_TL_MR3220_V2	0x32200002
--#define HWID_TL_MR3420_V1	0x34200001
--#define HWID_TL_MR3420_V2	0x34200002
--#define HWID_TL_WA701N_V1	0x07010001
--#define HWID_TL_WA701N_V2	0x07010002
--#define HWID_TL_WA7210N_V2	0x72100002
--#define HWID_TL_WA7510N_V1	0x75100001
--#define HWID_TL_WA801ND_V1	0x08010001
--#define HWID_TL_WA830RE_V1	0x08300010
--#define HWID_TL_WA830RE_V2	0x08300002
--#define HWID_TL_WA801ND_V2	0x08010002
--#define HWID_TL_WA801ND_V3	0x08010003
--#define HWID_TL_WA901ND_V1	0x09010001
--#define HWID_TL_WA901ND_V2	0x09010002
--#define HWID_TL_WA901ND_V4	0x09010004
--#define HWID_TL_WDR4300_V1_IL	0x43008001
--#define HWID_TL_WDR4900_V1	0x49000001
--#define HWID_TL_WR703N_V1	0x07030101
--#define HWID_TL_WR720N_V3	0x07200103
--#define HWID_TL_WR720N_V4	0x07200104
--#define HWID_TL_WR741ND_V1	0x07410001
--#define HWID_TL_WR741ND_V4	0x07410004
--#define HWID_TL_WR740N_V1	0x07400001
--#define HWID_TL_WR740N_V3	0x07400003
--#define HWID_TL_WR743ND_V1	0x07430001
--#define HWID_TL_WR743ND_V2	0x07430002
--#define HWID_TL_WR841N_V1_5	0x08410002
--#define HWID_TL_WR841ND_V3	0x08410003
--#define HWID_TL_WR841ND_V5	0x08410005
--#define HWID_TL_WR841ND_V7	0x08410007
--#define HWID_TL_WR941ND_V2	0x09410002
--#define HWID_TL_WR941ND_V4	0x09410004
--#define HWID_TL_WR1043ND_V1	0x10430001
--#define HWID_TL_WR1043ND_V2	0x10430002
--#define HWID_TL_WR1041N_V2	0x10410002
--#define HWID_TL_WR2543N_V1	0x25430001
-+#define HEADER_VERSION_V2	0x02000000
- 
- #define MD5SUM_LEN	16
- 
-@@ -89,7 +46,7 @@ struct fw_header {
- 	char		fw_version[36];
- 	uint32_t	hw_id;		/* hardware id */
- 	uint32_t	hw_rev;		/* hardware revision */
--	uint32_t	unk1;
-+	uint32_t	region_code;	/* region code */
- 	uint8_t		md5sum1[MD5SUM_LEN];
- 	uint32_t	unk2;
- 	uint8_t		md5sum2[MD5SUM_LEN];
-@@ -106,7 +63,10 @@ struct fw_header {
- 	uint16_t	ver_hi;
- 	uint16_t	ver_mid;
- 	uint16_t	ver_lo;
--	uint8_t		pad[354];
-+	uint8_t		pad[130];
-+	char		region_str1[32];
-+	char		region_str2[32];
-+	uint8_t		pad2[160];
- } __attribute__ ((packed));
- 
- struct flash_layout {
-@@ -117,13 +77,12 @@ struct flash_layout {
- 	uint32_t	rootfs_ofs;
- };
- 
--struct board_info {
--	char		*id;
--	uint32_t	hw_id;
--	uint32_t	hw_rev;
--	char		*layout_id;
-+struct fw_region {
-+	char		name[4];
-+	uint32_t	code;
- };
- 
-+
- /*
-  * Globals
-  */
-@@ -132,15 +91,17 @@ static char *progname;
- static char *vendor = "TP-LINK Technologies";
- static char *version = "ver. 1.0";
- static char *fw_ver = "0.0.0";
-+static uint32_t hdr_ver = HEADER_VERSION_V1;
- 
--static char *board_id;
--static struct board_info *board;
- static char *layout_id;
- static struct flash_layout *layout;
- static char *opt_hw_id;
- static uint32_t hw_id;
- static char *opt_hw_rev;
- static uint32_t hw_rev;
-+static uint32_t opt_hdr_ver = 1;
-+static char *country;
-+static const struct fw_region *region;
- static int fw_ver_lo;
- static int fw_ver_mid;
- static int fw_ver_hi;
-@@ -163,12 +124,12 @@ static uint32_t reserved_space;
- static struct file_info inspect_info;
- static int extract = 0;
- 
--char md5salt_normal[MD5SUM_LEN] = {
-+static const char md5salt_normal[MD5SUM_LEN] = {
- 	0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb,
- 	0xdd, 0xf9, 0xe7, 0xf4, 0x0e, 0xae, 0x47, 0x38,
- };
- 
--char md5salt_boot[MD5SUM_LEN] = {
-+static const char md5salt_boot[MD5SUM_LEN] = {
- 	0x8c, 0xef, 0x33, 0x5b, 0xd5, 0xc5, 0xce, 0xfa,
- 	0xa7, 0x9c, 0x28, 0xda, 0xb2, 0xe9, 0x0f, 0x42,
- };
-@@ -213,7 +174,7 @@ static struct flash_layout layouts[] = {
- 	}, {
- 		.id		= "16Mppc",
- 		.fw_max_len	= 0xf80000,
--		.kernel_la	= 0x00000000,
-+		.kernel_la	= 0x00000000 ,
- 		.kernel_ep	= 0xc0000000,
- 		.rootfs_ofs	= 0x2a0000,
- 	}, {
-@@ -221,235 +182,10 @@ static struct flash_layout layouts[] = {
- 	}
- };
- 
--static struct board_info boards[] = {
--	{
--		.id		= "TL-MR10Uv1",
--		.hw_id		= HWID_TL_MR10U_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-MR13Uv1",
--		.hw_id		= HWID_TL_MR13U_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-MR3020v1",
--		.hw_id		= HWID_TL_MR3020_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-MR3220v1",
--		.hw_id		= HWID_TL_MR3220_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-MR3220v2",
--		.hw_id		= HWID_TL_MR3220_V2,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-MR3420v1",
--		.hw_id		= HWID_TL_MR3420_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-MR3420v2",
--		.hw_id		= HWID_TL_MR3420_V2,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-WA701Nv1",
--		.hw_id		= HWID_TL_WA701N_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WA701Nv2",
--		.hw_id		= HWID_TL_WA701N_V2,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-WA7210N",
--		.hw_id		= HWID_TL_WA7210N_V2,
--		.hw_rev		= 2,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-WA7510N",
--		.hw_id		= HWID_TL_WA7510N_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WA801NDv1",
--		.hw_id		= HWID_TL_WA801ND_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WA830REv1",
--		.hw_id		= HWID_TL_WA830RE_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WA830REv2",
--		.hw_id		= HWID_TL_WA830RE_V2,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id             = "TL-WA801NDv2",
--		.hw_id          = HWID_TL_WA801ND_V2,
--		.hw_rev         = 1,
--		.layout_id	= "4Mlzma",
--	},{
--		.id							= "TL-WA801NDv3",
--		.hw_id          = HWID_TL_WA801ND_V3,
--		.hw_rev         = 1,
--		.layout_id  = "4Mlzma",
--	}, {
--		.id		= "TL-WA901NDv1",
--		.hw_id		= HWID_TL_WA901ND_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id             = "TL-WA901NDv2",
--		.hw_id          = HWID_TL_WA901ND_V2,
--		.hw_rev         = 1,
--		.layout_id	= "4M",
--	}, {
--		.id             = "TL-WA901NDv4",
--		.hw_id          = HWID_TL_WA901ND_V4,
--		.hw_rev         = 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id             = "TL-WDR4300v1",
--		.hw_id          = HWID_TL_WDR4300_V1_IL,
--		.hw_rev         = 1,
--		.layout_id	= "8Mlzma",
--	}, {
--		.id             = "TL-WDR4900v1",
--		.hw_id          = HWID_TL_WDR4900_V1,
--		.hw_rev         = 1,
--		.layout_id	= "16Mppc",
--	}, {
--		.id		= "TL-WR741NDv1",
--		.hw_id		= HWID_TL_WR741ND_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR741NDv4",
--		.hw_id		= HWID_TL_WR741ND_V4,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-WR740Nv1",
--		.hw_id		= HWID_TL_WR740N_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR740Nv3",
--		.hw_id		= HWID_TL_WR740N_V3,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR743NDv1",
--		.hw_id		= HWID_TL_WR743ND_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR743NDv2",
--		.hw_id		= HWID_TL_WR743ND_V2,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-WR841Nv1.5",
--		.hw_id		= HWID_TL_WR841N_V1_5,
--		.hw_rev		= 2,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR841NDv3",
--		.hw_id		= HWID_TL_WR841ND_V3,
--		.hw_rev		= 3,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR841NDv5",
--		.hw_id		= HWID_TL_WR841ND_V5,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR841NDv7",
--		.hw_id		= HWID_TL_WR841ND_V7,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR941NDv2",
--		.hw_id		= HWID_TL_WR941ND_V2,
--		.hw_rev		= 2,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR941NDv4",
--		.hw_id		= HWID_TL_WR941ND_V4,
--		.hw_rev		= 1,
--		.layout_id	= "4M",
--	}, {
--		.id		= "TL-WR1041Nv2",
--		.hw_id		= HWID_TL_WR1041N_V2,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-WR1043NDv1",
--		.hw_id		= HWID_TL_WR1043ND_V1,
--		.hw_rev		= 1,
--		.layout_id	= "8M",
--	}, {
--		.id		= "TL-WR1043NDv2",
--		.hw_id		= HWID_TL_WR1043ND_V2,
--		.hw_rev		= 1,
--		.layout_id	= "8Mlzma",
--	}, {
--		.id		= "TL-WR2543Nv1",
--		.hw_id		= HWID_TL_WR2543N_V1,
--		.hw_rev		= 1,
--		.layout_id	= "8Mlzma",
--	}, {
--		.id		= "TL-WR703Nv1",
--		.hw_id		= HWID_TL_WR703N_V1,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-WR720Nv3",
--		.hw_id		= HWID_TL_WR720N_V3,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "TL-WR720Nv4",
--		.hw_id		= HWID_TL_WR720N_V4,
--		.hw_rev		= 1,
--		.layout_id	= "4Mlzma",
--	}, {
--		.id		= "GL-INETv1",
--		.hw_id		= HWID_GL_INET_V1,
--		.hw_rev		= 1,
--		.layout_id	= "8Mlzma",
--	}, {
--		.id		= "GS-OOLITEv1",
--		.hw_id		= HWID_GS_OOLITE_V1,
--		.hw_rev		= 1,
--		.layout_id	= "16Mlzma",
--	}, {
--		.id		= "ONION-OMEGA",
--		.hw_id		= HWID_ONION_OMEGA,
--		.hw_rev		= 1,
--		.layout_id	= "16Mlzma",
--	}, {
--		.id		= "ANTMINER-S1",
--		.hw_id		= HWID_ANTMINER_S1,
--		.hw_rev		= 1,
--		.layout_id	= "8Mlzma",
--	}, {
--		.id		= "ANTMINER-S3",
--		.hw_id		= HWID_ANTMINER_S3,
--		.hw_rev		= 1,
--		.layout_id	= "8Mlzma",
--	}, {
--		/* terminating entry */
--	}
-+static const struct fw_region regions[] = {
-+	/* Default region (universal) uses code 0 as well */
-+	{"US", 1},
-+	{"EU", 0},
- };
- 
- /*
-@@ -464,7 +200,7 @@ static struct board_info boards[] = {
- #define ERRS(fmt, ...) do { \
- 	int save = errno; \
- 	fflush(0); \
--	fprintf(stderr, "[%s] *** error: " fmt "\n", \
-+	fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
- 			progname, ## __VA_ARGS__, strerror(save)); \
- } while (0)
- 
-@@ -472,35 +208,7 @@ static struct board_info boards[] = {
- 	fprintf(stderr, "[%s] " fmt "\n", progname, ## __VA_ARGS__ ); \
- } while (0)
- 
--static struct board_info *find_board(char *id)
--{
--	struct board_info *ret;
--	struct board_info *board;
--
--	ret = NULL;
--	for (board = boards; board->id != NULL; board++){
--		if (strcasecmp(id, board->id) == 0) {
--			ret = board;
--			break;
--		}
--	};
--
--	return ret;
--}
--
--static struct board_info *find_board_by_hwid(uint32_t hw_id)
--{
--	struct board_info *board;
--
--	for (board = boards; board->id != NULL; board++) {
--		if (hw_id == board->hw_id)
--			return board;
--	};
--
--	return NULL;
--}
--
--static struct flash_layout *find_layout(char *id)
-+static struct flash_layout *find_layout(const char *id)
- {
- 	struct flash_layout *ret;
- 	struct flash_layout *l;
-@@ -516,21 +224,29 @@ static struct flash_layout *find_layout(char *id)
- 	return ret;
- }
- 
-+static const struct fw_region * find_region(const char *country) {
-+	size_t i;
-+
-+	for (i = 0; i < ARRAY_SIZE(regions); i++) {
-+		if (strcasecmp(regions[i].name, country) == 0)
-+			return &regions[i];
-+	}
-+
-+	return NULL;
-+}
-+
- static void usage(int status)
- {
--	FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
--	struct board_info *board;
--
--	fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
--	fprintf(stream,
-+	fprintf(stderr, "Usage: %s [OPTIONS...]\n", progname);
-+	fprintf(stderr,
- "\n"
- "Options:\n"
--"  -B <board>      create image for the board specified with <board>\n"
- "  -c              use combined kernel image\n"
- "  -E <ep>         overwrite kernel entry point with <ep> (hexval prefixed with 0x)\n"
- "  -L <la>         overwrite kernel load address with <la> (hexval prefixed with 0x)\n"
- "  -H <hwid>       use hardware id specified with <hwid>\n"
- "  -W <hwrev>      use hardware revision specified with <hwrev>\n"
-+"  -C <country>    set region code to <country>\n"
- "  -F <id>         use flash layout specified with <id>\n"
- "  -k <file>       read kernel image from the file <file>\n"
- "  -r <file>       read rootfs image from the file <file>\n"
-@@ -543,6 +259,7 @@ static void usage(int status)
- "  -N <vendor>     set image vendor to <vendor>\n"
- "  -V <version>    set image version to <version>\n"
- "  -v <version>    set firmware version to <version>\n"
-+"  -m <version>    set header version to <version>\n"
- "  -i <file>       inspect given firmware file <file>\n"
- "  -x              extract kernel and rootfs while inspecting (requires -i)\n"
- "  -X <size>       reserve <size> bytes in the firmware image (hexval prefixed with 0x)\n"
-@@ -552,7 +269,7 @@ static void usage(int status)
- 	exit(status);
- }
- 
--static int get_md5(char *data, int size, char *md5)
-+static void get_md5(const char *data, int size, uint8_t *md5)
- {
- 	MD5_CTX ctx;
- 
-@@ -579,7 +296,7 @@ static int get_file_stat(struct file_info *fdata)
- 	return 0;
- }
- 
--static int read_to_buf(struct file_info *fdata, char *buf)
-+static int read_to_buf(const struct file_info *fdata, char *buf)
- {
- 	FILE *f;
- 	int ret = EXIT_FAILURE;
-@@ -608,6 +325,7 @@ static int read_to_buf(struct file_info *fdata, char *buf)
- static int check_options(void)
- {
- 	int ret;
-+	int exceed_bytes;
- 
- 	if (inspect_info.file_name) {
- 		ret = get_file_stat(&inspect_info);
-@@ -620,33 +338,28 @@ static int check_options(void)
- 		return -1;
- 	}
- 
--	if (board_id == NULL && opt_hw_id == NULL) {
--		ERR("either board or hardware id must be specified");
-+	if (opt_hw_id == NULL) {
-+		ERR("hardware id not specified");
- 		return -1;
- 	}
-+	hw_id = strtoul(opt_hw_id, NULL, 0);
- 
--	if (board_id) {
--		board = find_board(board_id);
--		if (board == NULL) {
--			ERR("unknown/unsupported board id \"%s\"", board_id);
--			return -1;
--		}
--		if (layout_id == NULL)
--			layout_id = board->layout_id;
-+	if (layout_id == NULL) {
-+		ERR("flash layout is not specified");
-+		return -1;
-+	}
- 
--		hw_id = board->hw_id;
--		hw_rev = board->hw_rev;
--	} else {
--		if (layout_id == NULL) {
--			ERR("flash layout is not specified");
-+	if (opt_hw_rev)
-+		hw_rev = strtoul(opt_hw_rev, NULL, 0);
-+	else
-+		hw_rev = 1;
-+
-+	if (country) {
-+		region = find_region(country);
-+		if (!region) {
-+			ERR("unknown region code \"%s\"", country);
- 			return -1;
- 		}
--		hw_id = strtoul(opt_hw_id, NULL, 0);
--
--		if (opt_hw_rev)
--			hw_rev = strtoul(opt_hw_rev, NULL, 0);
--		else
--			hw_rev = 1;
- 	}
- 
- 	layout = find_layout(layout_id);
-@@ -681,10 +394,10 @@ static int check_options(void)
- 	kernel_len = kernel_info.file_size;
- 
- 	if (combined) {
--		if (kernel_info.file_size >
--		    fw_max_len - sizeof(struct fw_header)) {
-+		exceed_bytes = kernel_info.file_size - (fw_max_len - sizeof(struct fw_header));
-+		if (exceed_bytes > 0) {
- 			if (!ignore_size) {
--				ERR("kernel image is too big");
-+				ERR("kernel image is too big by %i bytes", exceed_bytes);
- 				return -1;
- 			}
- 			layout->fw_max_len = sizeof(struct fw_header) +
-@@ -708,21 +421,21 @@ static int check_options(void)
- 
- 			DBG("kernel length aligned to %u", kernel_len);
- 
--			if (kernel_len + rootfs_info.file_size >
--			    fw_max_len - sizeof(struct fw_header)) {
--				ERR("images are too big");
-+			exceed_bytes = kernel_len + rootfs_info.file_size - (fw_max_len - sizeof(struct fw_header));
-+			if (exceed_bytes > 0) {
-+				ERR("images are too big by %i bytes", exceed_bytes);
- 				return -1;
- 			}
- 		} else {
--			if (kernel_info.file_size >
--			    rootfs_ofs - sizeof(struct fw_header)) {
--				ERR("kernel image is too big");
-+			exceed_bytes = kernel_info.file_size - (rootfs_ofs - sizeof(struct fw_header));
-+			if (exceed_bytes > 0) {
-+				ERR("kernel image is too big by %i bytes", exceed_bytes);
- 				return -1;
- 			}
- 
--			if (rootfs_info.file_size >
--			    (fw_max_len - rootfs_ofs)) {
--				ERR("rootfs image is too big");
-+			exceed_bytes = rootfs_info.file_size - (fw_max_len - rootfs_ofs);
-+			if (exceed_bytes > 0) {
-+				ERR("rootfs image is too big by %i bytes", exceed_bytes);
- 				return -1;
- 			}
- 		}
-@@ -739,6 +452,15 @@ static int check_options(void)
- 		return -1;
- 	}
- 
-+	if (opt_hdr_ver == 1) {
-+		hdr_ver = HEADER_VERSION_V1;
-+	} else if (opt_hdr_ver == 2) {
-+		hdr_ver = HEADER_VERSION_V2;
-+	} else {
-+		ERR("invalid header version '%u'", opt_hdr_ver);
-+		return -1;
-+	}
-+
- 	return 0;
- }
- 
-@@ -748,7 +470,7 @@ static void fill_header(char *buf, int len)
- 
- 	memset(hdr, 0, sizeof(struct fw_header));
- 
--	hdr->version = htonl(HEADER_VERSION_V1);
-+	hdr->version = htonl(hdr_ver);
- 	strncpy(hdr->vendor_name, vendor, sizeof(hdr->vendor_name));
- 	strncpy(hdr->fw_version, version, sizeof(hdr->fw_version));
- 	hdr->hw_id = htonl(hw_id);
-@@ -773,6 +495,18 @@ static void fill_header(char *buf, int len)
- 	hdr->ver_mid = htons(fw_ver_mid);
- 	hdr->ver_lo = htons(fw_ver_lo);
- 
-+	if (region) {
-+		hdr->region_code = htonl(region->code);
-+		snprintf(
-+			hdr->region_str1, sizeof(hdr->region_str1), "00000000;%02X%02X%02X%02X;",
-+			region->name[0], region->name[1], region->name[2], region->name[3]
-+		);
-+		snprintf(
-+			hdr->region_str2, sizeof(hdr->region_str2), "%02X%02X%02X%02X",
-+			region->name[0], region->name[1], region->name[2], region->name[3]
-+		);
-+	}
-+
- 	get_md5(buf, len, hdr->md5sum1);
- }
- 
-@@ -810,7 +544,7 @@ static int pad_jffs2(char *buf, int currlen)
- 	return len;
- }
- 
--static int write_fw(char *data, int len)
-+static int write_fw(const char *data, int len)
- {
- 	FILE *f;
- 	int ret = EXIT_FAILURE;
-@@ -902,61 +636,22 @@ static int build_fw(void)
- }
- 
- /* Helper functions to inspect_fw() representing different output formats */
--static inline void inspect_fw_pstr(char *label, char *str)
-+static inline void inspect_fw_pstr(const char *label, const char *str)
- {
- 	printf("%-23s: %s\n", label, str);
- }
- 
--static inline void inspect_fw_phex(char *label, uint32_t val)
-+static inline void inspect_fw_phex(const char *label, uint32_t val)
- {
- 	printf("%-23s: 0x%08x\n", label, val);
- }
- 
--static inline void inspect_fw_phexpost(char *label,
--                                       uint32_t val, char *post)
--{
--	printf("%-23s: 0x%08x (%s)\n", label, val, post);
--}
--
--static inline void inspect_fw_phexdef(char *label,
--                                      uint32_t val, uint32_t defval)
--{
--	printf("%-23s: 0x%08x                  ", label, val);
--
--	if (val == defval)
--		printf("(== OpenWrt default)\n");
--	else
--		printf("(OpenWrt default: 0x%08x)\n", defval);
--}
--
--static inline void inspect_fw_phexexp(char *label,
--                                      uint32_t val, uint32_t expval)
--{
--	printf("%-23s: 0x%08x ", label, val);
--
--	if (val == expval)
--		printf("(ok)\n");
--	else
--		printf("(expected: 0x%08x)\n", expval);
--}
--
--static inline void inspect_fw_phexdec(char *label, uint32_t val)
-+static inline void inspect_fw_phexdec(const char *label, uint32_t val)
- {
- 	printf("%-23s: 0x%08x / %8u bytes\n", label, val, val);
- }
- 
--static inline void inspect_fw_phexdecdef(char *label,
--                                         uint32_t val, uint32_t defval)
--{
--	printf("%-23s: 0x%08x / %8u bytes ", label, val, val);
--
--	if (val == defval)
--		printf("(== OpenWrt default)\n");
--	else
--		printf("(OpenWrt default: 0x%08x)\n", defval);
--}
--
--static inline void inspect_fw_pmd5sum(char *label, uint8_t *val, char *text)
-+static inline void inspect_fw_pmd5sum(const char *label, const uint8_t *val, const char *text)
- {
- 	int i;
- 
-@@ -971,7 +666,6 @@ static int inspect_fw(void)
- 	char *buf;
- 	struct fw_header *hdr;
- 	uint8_t md5sum[MD5SUM_LEN];
--	struct board_info *board;
- 	int ret = EXIT_FAILURE;
- 
- 	buf = malloc(inspect_info.file_size);
-@@ -988,16 +682,14 @@ static int inspect_fw(void)
- 	inspect_fw_pstr("File name", inspect_info.file_name);
- 	inspect_fw_phexdec("File size", inspect_info.file_size);
- 
--	if (ntohl(hdr->version) != HEADER_VERSION_V1) {
--		ERR("file does not seem to have V1 header!\n");
-+	if ((ntohl(hdr->version) != HEADER_VERSION_V1) &&
-+	    (ntohl(hdr->version) != HEADER_VERSION_V2)) {
-+		ERR("file does not seem to have V1/V2 header!\n");
- 		goto out_free_buf;
- 	}
- 
- 	inspect_fw_phexdec("Version 1 Header size", sizeof(struct fw_header));
- 
--	if (ntohl(hdr->unk1) != 0)
--		inspect_fw_phexdec("Unknown value 1", hdr->unk1);
--
- 	memcpy(md5sum, hdr->md5sum1, sizeof(md5sum));
- 	if (ntohl(hdr->boot_len) == 0)
- 		memcpy(hdr->md5sum1, md5salt_normal, sizeof(md5sum));
-@@ -1022,19 +714,9 @@ static int inspect_fw(void)
- 
- 	inspect_fw_pstr("Vendor name", hdr->vendor_name);
- 	inspect_fw_pstr("Firmware version", hdr->fw_version);
--	board = find_board_by_hwid(ntohl(hdr->hw_id));
--	if (board) {
--		layout = find_layout(board->layout_id);
--		inspect_fw_phexpost("Hardware ID",
--		                    ntohl(hdr->hw_id), board->id);
--		inspect_fw_phexexp("Hardware Revision",
--		                   ntohl(hdr->hw_rev), board->hw_rev);
--	} else {
--		inspect_fw_phexpost("Hardware ID",
--		                    ntohl(hdr->hw_id), "unknown");
--		inspect_fw_phex("Hardware Revision",
--		                ntohl(hdr->hw_rev));
--	}
-+	inspect_fw_phex("Hardware ID", ntohl(hdr->hw_id));
-+	inspect_fw_phex("Hardware Revision", ntohl(hdr->hw_rev));
-+	inspect_fw_phex("Region code", ntohl(hdr->region_code));
- 
- 	printf("\n");
- 
-@@ -1042,24 +724,12 @@ static int inspect_fw(void)
- 	                   ntohl(hdr->kernel_ofs));
- 	inspect_fw_phexdec("Kernel data length",
- 	                   ntohl(hdr->kernel_len));
--	if (board) {
--		inspect_fw_phexdef("Kernel load address",
--		                   ntohl(hdr->kernel_la),
--		                   layout ? layout->kernel_la : 0xffffffff);
--		inspect_fw_phexdef("Kernel entry point",
--		                   ntohl(hdr->kernel_ep),
--		                   layout ? layout->kernel_ep : 0xffffffff);
--		inspect_fw_phexdecdef("Rootfs data offset",
--		                      ntohl(hdr->rootfs_ofs),
--		                      layout ? layout->rootfs_ofs : 0xffffffff);
--	} else {
--		inspect_fw_phex("Kernel load address",
--		                ntohl(hdr->kernel_la));
--		inspect_fw_phex("Kernel entry point",
--		                ntohl(hdr->kernel_ep));
--		inspect_fw_phexdec("Rootfs data offset",
--		                   ntohl(hdr->rootfs_ofs));
--	}
-+	inspect_fw_phex("Kernel load address",
-+	                ntohl(hdr->kernel_la));
-+	inspect_fw_phex("Kernel entry point",
-+	                ntohl(hdr->kernel_ep));
-+	inspect_fw_phexdec("Rootfs data offset",
-+	                   ntohl(hdr->rootfs_ofs));
- 	inspect_fw_phexdec("Rootfs data length",
- 	                   ntohl(hdr->rootfs_len));
- 	inspect_fw_phexdec("Boot loader data offset",
-@@ -1115,16 +785,13 @@ static int inspect_fw(void)
- int main(int argc, char *argv[])
- {
- 	int ret = EXIT_FAILURE;
--	int err;
--
--	FILE *outfile;
- 
- 	progname = basename(argv[0]);
- 
- 	while ( 1 ) {
- 		int c;
- 
--		c = getopt(argc, argv, "a:B:H:E:F:L:V:N:W:ci:k:r:R:o:xX:hsSjv:");
-+		c = getopt(argc, argv, "a:H:E:F:L:m:V:N:W:C:ci:k:r:R:o:xX:hsSjv:");
- 		if (c == -1)
- 			break;
- 
-@@ -1132,9 +799,6 @@ int main(int argc, char *argv[])
- 		case 'a':
- 			sscanf(optarg, "0x%x", &rootfs_align);
- 			break;
--		case 'B':
--			board_id = optarg;
--			break;
- 		case 'H':
- 			opt_hw_id = optarg;
- 			break;
-@@ -1147,9 +811,15 @@ int main(int argc, char *argv[])
- 		case 'W':
- 			opt_hw_rev = optarg;
- 			break;
-+		case 'C':
-+			country = optarg;
-+			break;
- 		case 'L':
- 			sscanf(optarg, "0x%x", &kernel_la);
- 			break;
-+		case 'm':
-+			sscanf(optarg, "%u", &opt_hdr_ver);
-+			break;
- 		case 'V':
- 			version = optarg;
- 			break;

+ 0 - 38
patches/openwrt/0070-ar71xx-backport-support-for-new-TP-Link-region-codes.patch

@@ -1,38 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Sun, 28 Aug 2016 20:38:58 +0200
-Subject: ar71xx: backport support for new TP-Link region codes
-
-Generate flashable images for the Archer C7 v2 with current stock firmware
-again.
-
-diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
-index 868a5021acb49878359497c90509de07faa3ca49..95f6d46d15b43faabb0bbf9301476d3ea5bee470 100644
---- a/target/linux/ar71xx/image/Makefile
-+++ b/target/linux/ar71xx/image/Makefile
-@@ -58,13 +58,14 @@ define Build/mktplinkfw
- 		-o $@.new \
- 		-j -X 0x40000 \
- 		-a $(call rootfs_align,$(FILESYSTEM)) \
--		$(if $(findstring sysupgrade,$1),-s) && mv $@.new $@ || rm -f $@
-+		$(wordlist 2,$(words $(1)),$(1)) \
-+		$(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv $@.new $@ || rm -f $@
- endef
- 
- # -c combined image
- define Build/mktplinkfw-initramfs
- 	$(STAGING_DIR_HOST)/bin/mktplinkfw \
--		-H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) \
-+		-H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) $(1) \
- 		-k $@ \
- 		-o $@.new \
- 		-s -S \
-@@ -300,6 +301,9 @@ define Device/archer-c7-v2
-     BOARDNAME := ARCHER-C7
-     DEVICE_PROFILE := ARCHERC7
-     TPLINK_HWID := 0xc7000002
-+    IMAGES := sysupgrade.bin factory.bin factory-us.bin factory-eu.bin
-+    IMAGE/factory-us.bin := append-rootfs | mktplinkfw factory -C US
-+    IMAGE/factory-eu.bin := append-rootfs | mktplinkfw factory -C EU
- endef
- TARGET_DEVICES += archer-c5 archer-c7-v1 archer-c7-v2
- 

+ 0 - 68
patches/openwrt/0071-ath10k-firmware-add-ath10k-firmware-qca988x-11s.patch

@@ -1,68 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Fri, 9 Sep 2016 01:54:44 +0200
-Subject: ath10k-firmware: add ath10k-firmware-qca988x-11s
-
-diff --git a/package/firmware/ath10k-firmware/Makefile b/package/firmware/ath10k-firmware/Makefile
-index 624da6a1ed43ea37bbb3409b3dbe4b3af01263b5..3a4f0c59eb89a32f78f0104d2420b921d6660ddc 100644
---- a/package/firmware/ath10k-firmware/Makefile
-+++ b/package/firmware/ath10k-firmware/Makefile
-@@ -8,7 +8,7 @@
- include $(TOPDIR)/rules.mk
- 
- PKG_NAME:=ath10k-firmware
--PKG_SOURCE_VERSION:=b00eb8d30fbebb6a5047ccacefa8c37e072fca9c
-+PKG_SOURCE_VERSION:=307cb46b06661ebd3186723b5002de769c7add83
- PKG_VERSION:=2014-11-13-$(PKG_SOURCE_VERSION)
- PKG_RELEASE:=1
- 
-@@ -104,6 +104,11 @@ $(Package/ath10k-firmware-default)
-   TITLE:=ath10k firmware for QCA99x0 devices
- endef
- 
-+define Package/ath10k-firmware-qca988x-11s
-+$(Package/ath10k-firmware-default)
-+  TITLE:=ath10k firmware for QCA988x devices (with 11s support)
-+endef
-+
- define Package/ath10k-firmware-qca988x-ct
- $(Package/ath10k-firmware-default)
-   TITLE:=ath10k CT 10.1 firmware for QCA988x devices
-@@ -188,17 +193,27 @@ endef
- define Package/ath10k-firmware-qca988x/install
- 	$(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA988X/hw2.0
- 	$(INSTALL_DATA) \
--		$(PKG_BUILD_DIR)/QCA988X/board.bin \
-+		$(PKG_BUILD_DIR)/QCA988X/hw2.0/board.bin \
- 		$(1)/lib/firmware/ath10k/QCA988X/hw2.0/
- 	$(INSTALL_DATA) \
- 		$(DL_DIR)/$(QCA988X_FIRMWARE_FILE) \
- 		$(1)/lib/firmware/ath10k/QCA988X/hw2.0/firmware-5.bin
- endef
- 
-+define Package/ath10k-firmware-qca988x-11s/install
-+	$(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA988X/hw2.0
-+	$(INSTALL_DATA) \
-+		$(PKG_BUILD_DIR)/QCA988X/hw2.0/board.bin \
-+		$(1)/lib/firmware/ath10k/QCA988X/hw2.0/
-+	$(INSTALL_DATA) \
-+		$(PKG_BUILD_DIR)/QCA988X/hw2.0/10.2.4.70/firmware-5.bin_10.2.4.70.54 \
-+		$(1)/lib/firmware/ath10k/QCA988X/hw2.0/firmware-5.bin
-+endef
-+
- define Package/ath10k-firmware-qca988x-ct/install
- 	$(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA988X/hw2.0
- 	$(INSTALL_DATA) \
--		$(PKG_BUILD_DIR)/QCA988X/board.bin \
-+		$(PKG_BUILD_DIR)/QCA988X/hw2.0/board.bin \
- 		$(1)/lib/firmware/ath10k/QCA988X/hw2.0/
- 	$(INSTALL_DATA) \
- 		$(DL_DIR)/$(QCA988X_FIRMWARE_FILE_CT) \
-@@ -268,6 +283,8 @@ $(eval $(call BuildPackage,ath10k-firmware-qca99x0))
- $(eval $(call BuildPackage,ath10k-firmware-qca6174))
- $(eval $(call BuildPackage,ath10k-firmware-qca9984))
- 
-+$(eval $(call BuildPackage,ath10k-firmware-qca988x-11s))
-+
- $(eval $(call BuildPackage,ath10k-firmware-qca988x-ct))
- $(eval $(call BuildPackage,ath10k-firmware-qca99x0-ct))
- $(eval $(call BuildPackage,ath10k-firmware-qca9984-ct))

+ 0 - 124
patches/openwrt/0072-ath9k-revert-temperature-compensation-support-patch-FS-111.patch

@@ -1,124 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Tue, 11 Oct 2016 02:54:27 +0200
-Subject: ath9k: revert temperature compensation support patch (FS#111)
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
-
-Backport of LEDE 3e4d0e3e77dcf9b2116e5ed53f30e2bf53b1c6b7
-
-diff --git a/package/kernel/mac80211/patches/328-ath9k_hw-implement-temperature-compensation-support-.patch b/package/kernel/mac80211/patches/328-ath9k_hw-implement-temperature-compensation-support-.patch
-deleted file mode 100644
-index cff32ad47cb0b905d9cfa4eb021258b644b2a47a..0000000000000000000000000000000000000000
---- a/package/kernel/mac80211/patches/328-ath9k_hw-implement-temperature-compensation-support-.patch
-+++ /dev/null
-@@ -1,97 +0,0 @@
--From: Felix Fietkau <nbd@nbd.name>
--Date: Mon, 11 Jul 2016 11:35:55 +0200
--Subject: [PATCH] ath9k_hw: implement temperature compensation support for
-- AR9003+
--
--Signed-off-by: Felix Fietkau <nbd@nbd.name>
-----
--
----- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
--+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
--@@ -33,6 +33,7 @@ struct coeff {
-- 
-- enum ar9003_cal_types {
-- 	IQ_MISMATCH_CAL = BIT(0),
--+	TEMP_COMP_CAL = BIT(1),
-- };
-- 
-- static void ar9003_hw_setup_calibration(struct ath_hw *ah,
--@@ -58,6 +59,12 @@ static void ar9003_hw_setup_calibration(
-- 		/* Kick-off cal */
-- 		REG_SET_BIT(ah, AR_PHY_TIMING4, AR_PHY_TIMING4_DO_CAL);
-- 		break;
--+	case TEMP_COMP_CAL:
--+		ath_dbg(common, CALIBRATE,
--+			"starting Temperature Compensation Calibration\n");
--+		REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_LOCAL);
--+		REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_START);
--+		break;
-- 	default:
-- 		ath_err(common, "Invalid calibration type\n");
-- 		break;
--@@ -86,7 +93,8 @@ static bool ar9003_hw_per_calibration(st
-- 		/*
-- 		* Accumulate cal measures for active chains
-- 		*/
---		cur_caldata->calCollect(ah);
--+		if (cur_caldata->calCollect)
--+			cur_caldata->calCollect(ah);
-- 		ah->cal_samples++;
-- 
-- 		if (ah->cal_samples >= cur_caldata->calNumSamples) {
--@@ -99,7 +107,8 @@ static bool ar9003_hw_per_calibration(st
-- 			/*
-- 			* Process accumulated data
-- 			*/
---			cur_caldata->calPostProc(ah, numChains);
--+			if (cur_caldata->calPostProc)
--+				cur_caldata->calPostProc(ah, numChains);
-- 
-- 			/* Calibration has finished. */
-- 			caldata->CalValid |= cur_caldata->calType;
--@@ -314,9 +323,16 @@ static const struct ath9k_percal_data iq
-- 	ar9003_hw_iqcalibrate
-- };
-- 
--+static const struct ath9k_percal_data temp_cal_single_sample = {
--+	TEMP_COMP_CAL,
--+	MIN_CAL_SAMPLES,
--+	PER_MAX_LOG_COUNT,
--+};
--+
-- static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
-- {
-- 	ah->iq_caldata.calData = &iq_cal_single_sample;
--+	ah->temp_caldata.calData = &temp_cal_single_sample;
-- 
-- 	if (AR_SREV_9300_20_OR_LATER(ah)) {
-- 		ah->enabled_cals |= TX_IQ_CAL;
--@@ -324,7 +340,7 @@ static void ar9003_hw_init_cal_settings(
-- 			ah->enabled_cals |= TX_IQ_ON_AGC_CAL;
-- 	}
-- 
---	ah->supp_cals = IQ_MISMATCH_CAL;
--+	ah->supp_cals = IQ_MISMATCH_CAL | TEMP_COMP_CAL;
-- }
-- 
-- #define OFF_UPPER_LT 24
--@@ -1383,6 +1399,9 @@ static void ar9003_hw_init_cal_common(st
-- 	INIT_CAL(&ah->iq_caldata);
-- 	INSERT_CAL(ah, &ah->iq_caldata);
-- 
--+	INIT_CAL(&ah->temp_caldata);
--+	INSERT_CAL(ah, &ah->temp_caldata);
--+
-- 	/* Initialize current pointer to first element in list */
-- 	ah->cal_list_curr = ah->cal_list;
-- 
----- a/drivers/net/wireless/ath/ath9k/hw.h
--+++ b/drivers/net/wireless/ath/ath9k/hw.h
--@@ -830,6 +830,7 @@ struct ath_hw {
-- 	/* Calibration */
-- 	u32 supp_cals;
-- 	struct ath9k_cal_list iq_caldata;
--+	struct ath9k_cal_list temp_caldata;
-- 	struct ath9k_cal_list adcgain_caldata;
-- 	struct ath9k_cal_list adcdc_caldata;
-- 	struct ath9k_cal_list *cal_list;
-diff --git a/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch b/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch
-index 461564350feb43410e5c702a8a67514cdfaa3961..6edef0975431165285a7b937442b5d89b362c807 100644
---- a/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch
-+++ b/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch
-@@ -84,7 +84,7 @@
-  	bool reset_power_on;
-  	bool htc_reset_init;
-  
--@@ -1068,6 +1076,7 @@ void ath9k_hw_check_nav(struct ath_hw *a
-+@@ -1067,6 +1075,7 @@ void ath9k_hw_check_nav(struct ath_hw *a
-  bool ath9k_hw_check_alive(struct ath_hw *ah);
-  
-  bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);

+ 0 - 885
patches/openwrt/0073-ath9k-remove-intermediate-queueing-patch-until-it-is-fixed-properly.patch

@@ -1,885 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Thu, 13 Oct 2016 10:01:19 +0200
-Subject: ath9k: remove intermediate queueing patch until it is fixed properly
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
-
-Backport of LEDE 04a69843198f2252992812e35ac05016db4a1a94
-
-diff --git a/package/kernel/mac80211/patches/320-ath9k-Switch-to-using-mac80211-intermediate-software.patch b/package/kernel/mac80211/patches/320-ath9k-Switch-to-using-mac80211-intermediate-software.patch
-deleted file mode 100644
-index f8b8f86e03ba0786ef410db31d6de2ab691430bd..0000000000000000000000000000000000000000
---- a/package/kernel/mac80211/patches/320-ath9k-Switch-to-using-mac80211-intermediate-software.patch
-+++ /dev/null
-@@ -1,871 +0,0 @@
--From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
--Date: Wed, 6 Jul 2016 21:34:17 +0200
--Subject: [PATCH] ath9k: Switch to using mac80211 intermediate software queues.
--MIME-Version: 1.0
--Content-Type: text/plain; charset=UTF-8
--Content-Transfer-Encoding: 8bit
--
--This switches ath9k over to using the mac80211 intermediate software
--queueing mechanism for data packets. It removes the queueing inside the
--driver, except for the retry queue, and instead pulls from mac80211 when
--a packet is needed. The retry queue is used to store a packet that was
--pulled but can't be sent immediately.
--
--The old code path in ath_tx_start that would queue packets has been
--removed completely, as has the qlen limit tunables (since there's no
--longer a queue in the driver to limit).
--
--Based on Tim's original patch set, but reworked quite thoroughly.
--
--Cc: Tim Shepard <shep@alum.mit.edu>
--Cc: Felix Fietkau <nbd@nbd.name>
--Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
-----
--
----- a/drivers/net/wireless/ath/ath9k/ath9k.h
--+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
--@@ -91,7 +91,6 @@ int ath_descdma_setup(struct ath_softc *
-- #define ATH_RXBUF               512
-- #define ATH_TXBUF               512
-- #define ATH_TXBUF_RESERVE       5
---#define ATH_MAX_QDEPTH          (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE)
-- #define ATH_TXMAXTRY            13
-- #define ATH_MAX_SW_RETRIES      30
-- 
--@@ -145,7 +144,9 @@ int ath_descdma_setup(struct ath_softc *
-- #define BAW_WITHIN(_start, _bawsz, _seqno) \
-- 	((((_seqno) - (_start)) & 4095) < (_bawsz))
-- 
---#define ATH_AN_2_TID(_an, _tidno)  (&(_an)->tid[(_tidno)])
--+#define ATH_STA_2_TID(_sta, _tidno) ((struct ath_atx_tid *)(_sta)->txq[_tidno]->drv_priv)
--+#define ATH_VIF_2_TID(_vif) ((struct ath_atx_tid *)(_vif)->txq->drv_priv)
--+#define ATH_AN_2_TID(_an, _tidno) ((_an)->sta ? ATH_STA_2_TID((_an)->sta, _tidno) : ATH_VIF_2_TID((_an)->vif))
-- 
-- #define IS_HT_RATE(rate)   (rate & 0x80)
-- #define IS_CCK_RATE(rate)  ((rate >= 0x18) && (rate <= 0x1e))
--@@ -164,7 +165,6 @@ struct ath_txq {
-- 	spinlock_t axq_lock;
-- 	u32 axq_depth;
-- 	u32 axq_ampdu_depth;
---	bool stopped;
-- 	bool axq_tx_inprogress;
-- 	struct list_head txq_fifo[ATH_TXFIFO_DEPTH];
-- 	u8 txq_headidx;
--@@ -232,7 +232,6 @@ struct ath_buf {
-- 
-- struct ath_atx_tid {
-- 	struct list_head list;
---	struct sk_buff_head buf_q;
-- 	struct sk_buff_head retry_q;
-- 	struct ath_node *an;
-- 	struct ath_txq *txq;
--@@ -247,13 +246,13 @@ struct ath_atx_tid {
-- 	s8 bar_index;
-- 	bool active;
-- 	bool clear_ps_filter;
--+	bool has_queued;
-- };
-- 
-- struct ath_node {
-- 	struct ath_softc *sc;
-- 	struct ieee80211_sta *sta; /* station struct we're part of */
-- 	struct ieee80211_vif *vif; /* interface with which we're associated */
---	struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
-- 
-- 	u16 maxampdu;
-- 	u8 mpdudensity;
--@@ -276,7 +275,6 @@ struct ath_tx_control {
-- 	struct ath_node *an;
-- 	struct ieee80211_sta *sta;
-- 	u8 paprd;
---	bool force_channel;
-- };
-- 
-- 
--@@ -293,7 +291,6 @@ struct ath_tx {
-- 	struct ath_descdma txdma;
-- 	struct ath_txq *txq_map[IEEE80211_NUM_ACS];
-- 	struct ath_txq *uapsdq;
---	u32 txq_max_pending[IEEE80211_NUM_ACS];
-- 	u16 max_aggr_framelen[IEEE80211_NUM_ACS][4][32];
-- };
-- 
--@@ -585,6 +582,7 @@ void ath9k_release_buffered_frames(struc
-- 				   u16 tids, int nframes,
-- 				   enum ieee80211_frame_release_type reason,
-- 				   bool more_data);
--+void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue);
-- 
-- /********/
-- /* VIFs */
----- a/drivers/net/wireless/ath/ath9k/channel.c
--+++ b/drivers/net/wireless/ath/ath9k/channel.c
--@@ -1007,7 +1007,6 @@ static void ath_scan_send_probe(struct a
-- 		goto error;
-- 
-- 	txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
---	txctl.force_channel = true;
-- 	if (ath_tx_start(sc->hw, skb, &txctl))
-- 		goto error;
-- 
--@@ -1130,7 +1129,6 @@ ath_chanctx_send_vif_ps_frame(struct ath
-- 	memset(&txctl, 0, sizeof(txctl));
-- 	txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
-- 	txctl.sta = sta;
---	txctl.force_channel = true;
-- 	if (ath_tx_start(sc->hw, skb, &txctl)) {
-- 		ieee80211_free_txskb(sc->hw, skb);
-- 		return false;
----- a/drivers/net/wireless/ath/ath9k/debug.c
--+++ b/drivers/net/wireless/ath/ath9k/debug.c
--@@ -600,7 +600,6 @@ static int read_file_xmit(struct seq_fil
-- 	PR("MPDUs XRetried:  ", xretries);
-- 	PR("Aggregates:      ", a_aggr);
-- 	PR("AMPDUs Queued HW:", a_queued_hw);
---	PR("AMPDUs Queued SW:", a_queued_sw);
-- 	PR("AMPDUs Completed:", a_completed);
-- 	PR("AMPDUs Retried:  ", a_retries);
-- 	PR("AMPDUs XRetried: ", a_xretries);
--@@ -629,8 +628,7 @@ static void print_queue(struct ath_softc
-- 	seq_printf(file, "%s: %d ", "qnum", txq->axq_qnum);
-- 	seq_printf(file, "%s: %2d ", "qdepth", txq->axq_depth);
-- 	seq_printf(file, "%s: %2d ", "ampdu-depth", txq->axq_ampdu_depth);
---	seq_printf(file, "%s: %3d ", "pending", txq->pending_frames);
---	seq_printf(file, "%s: %d\n", "stopped", txq->stopped);
--+	seq_printf(file, "%s: %3d\n", "pending", txq->pending_frames);
-- 
-- 	ath_txq_unlock(sc, txq);
-- }
--@@ -1208,7 +1206,6 @@ static const char ath9k_gstrings_stats[]
-- 	AMKSTR(d_tx_mpdu_xretries),
-- 	AMKSTR(d_tx_aggregates),
-- 	AMKSTR(d_tx_ampdus_queued_hw),
---	AMKSTR(d_tx_ampdus_queued_sw),
-- 	AMKSTR(d_tx_ampdus_completed),
-- 	AMKSTR(d_tx_ampdu_retries),
-- 	AMKSTR(d_tx_ampdu_xretries),
--@@ -1288,7 +1285,6 @@ void ath9k_get_et_stats(struct ieee80211
-- 	AWDATA(xretries);
-- 	AWDATA(a_aggr);
-- 	AWDATA(a_queued_hw);
---	AWDATA(a_queued_sw);
-- 	AWDATA(a_completed);
-- 	AWDATA(a_retries);
-- 	AWDATA(a_xretries);
--@@ -1346,14 +1342,6 @@ int ath9k_init_debug(struct ath_hw *ah)
-- 				    read_file_xmit);
-- 	debugfs_create_devm_seqfile(sc->dev, "queues", sc->debug.debugfs_phy,
-- 				    read_file_queues);
---	debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
---			   &sc->tx.txq_max_pending[IEEE80211_AC_BK]);
---	debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
---			   &sc->tx.txq_max_pending[IEEE80211_AC_BE]);
---	debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
---			   &sc->tx.txq_max_pending[IEEE80211_AC_VI]);
---	debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
---			   &sc->tx.txq_max_pending[IEEE80211_AC_VO]);
-- 	debugfs_create_devm_seqfile(sc->dev, "misc", sc->debug.debugfs_phy,
-- 				    read_file_misc);
-- 	debugfs_create_devm_seqfile(sc->dev, "reset", sc->debug.debugfs_phy,
----- a/drivers/net/wireless/ath/ath9k/debug.h
--+++ b/drivers/net/wireless/ath/ath9k/debug.h
--@@ -147,7 +147,6 @@ struct ath_interrupt_stats {
--  * @completed: Total MPDUs (non-aggr) completed
--  * @a_aggr: Total no. of aggregates queued
--  * @a_queued_hw: Total AMPDUs queued to hardware
--- * @a_queued_sw: Total AMPDUs queued to software queues
--  * @a_completed: Total AMPDUs completed
--  * @a_retries: No. of AMPDUs retried (SW)
--  * @a_xretries: No. of AMPDUs dropped due to xretries
--@@ -174,7 +173,6 @@ struct ath_tx_stats {
-- 	u32 xretries;
-- 	u32 a_aggr;
-- 	u32 a_queued_hw;
---	u32 a_queued_sw;
-- 	u32 a_completed;
-- 	u32 a_retries;
-- 	u32 a_xretries;
----- a/drivers/net/wireless/ath/ath9k/debug_sta.c
--+++ b/drivers/net/wireless/ath/ath9k/debug_sta.c
--@@ -52,8 +52,8 @@ static ssize_t read_file_node_aggr(struc
-- 			 "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
-- 			 "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
-- 
---	for (tidno = 0, tid = &an->tid[tidno];
---	     tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
--+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
--+		tid = ATH_STA_2_TID(an->sta, tidno);
-- 		txq = tid->txq;
-- 		ath_txq_lock(sc, txq);
-- 		if (tid->active) {
----- a/drivers/net/wireless/ath/ath9k/init.c
--+++ b/drivers/net/wireless/ath/ath9k/init.c
--@@ -358,7 +358,6 @@ static int ath9k_init_queues(struct ath_
-- 	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
-- 		sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i);
-- 		sc->tx.txq_map[i]->mac80211_qnum = i;
---		sc->tx.txq_max_pending[i] = ATH_MAX_QDEPTH;
-- 	}
-- 	return 0;
-- }
--@@ -873,6 +872,7 @@ static void ath9k_set_hw_capab(struct at
-- 	hw->max_rate_tries = 10;
-- 	hw->sta_data_size = sizeof(struct ath_node);
-- 	hw->vif_data_size = sizeof(struct ath_vif);
--+	hw->txq_data_size = sizeof(struct ath_atx_tid);
-- 	hw->extra_tx_headroom = 4;
-- 
-- 	hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1;
----- a/drivers/net/wireless/ath/ath9k/main.c
--+++ b/drivers/net/wireless/ath/ath9k/main.c
--@@ -2695,4 +2695,5 @@ struct ieee80211_ops ath9k_ops = {
-- 	.sw_scan_start	    = ath9k_sw_scan_start,
-- 	.sw_scan_complete   = ath9k_sw_scan_complete,
-- 	.get_txpower        = ath9k_get_txpower,
--+	.wake_tx_queue      = ath9k_wake_tx_queue,
-- };
----- a/drivers/net/wireless/ath/ath9k/xmit.c
--+++ b/drivers/net/wireless/ath/ath9k/xmit.c
--@@ -65,6 +65,8 @@ static struct ath_buf *ath_tx_setup_buff
-- 					   struct ath_txq *txq,
-- 					   struct ath_atx_tid *tid,
-- 					   struct sk_buff *skb);
--+static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb,
--+			  struct ath_tx_control *txctl);
-- 
-- enum {
-- 	MCS_HT20,
--@@ -118,6 +120,26 @@ static void ath_tx_queue_tid(struct ath_
-- 		list_add_tail(&tid->list, list);
-- }
-- 
--+void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue)
--+{
--+	struct ath_softc *sc = hw->priv;
--+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
--+	struct ath_atx_tid *tid = (struct ath_atx_tid *) queue->drv_priv;
--+	struct ath_txq *txq = tid->txq;
--+
--+	ath_dbg(common, QUEUE, "Waking TX queue: %pM (%d)\n",
--+		queue->sta ? queue->sta->addr : queue->vif->addr,
--+		tid->tidno);
--+
--+	ath_txq_lock(sc, txq);
--+
--+	tid->has_queued = true;
--+	ath_tx_queue_tid(sc, txq, tid);
--+	ath_txq_schedule(sc, txq);
--+
--+	ath_txq_unlock(sc, txq);
--+}
--+
-- static struct ath_frame_info *get_frame_info(struct sk_buff *skb)
-- {
-- 	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
--@@ -160,7 +182,6 @@ static void ath_set_rates(struct ieee802
-- static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
-- 			     struct sk_buff *skb)
-- {
---	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-- 	struct ath_frame_info *fi = get_frame_info(skb);
-- 	int q = fi->txq;
-- 
--@@ -171,14 +192,6 @@ static void ath_txq_skb_done(struct ath_
-- 	if (WARN_ON(--txq->pending_frames < 0))
-- 		txq->pending_frames = 0;
-- 
---	if (txq->stopped &&
---	    txq->pending_frames < sc->tx.txq_max_pending[q]) {
---		if (ath9k_is_chanctx_enabled())
---			ieee80211_wake_queue(sc->hw, info->hw_queue);
---		else
---			ieee80211_wake_queue(sc->hw, q);
---		txq->stopped = false;
---	}
-- }
-- 
-- static struct ath_atx_tid *
--@@ -188,9 +201,47 @@ ath_get_skb_tid(struct ath_softc *sc, st
-- 	return ATH_AN_2_TID(an, tidno);
-- }
-- 
--+static struct sk_buff *
--+ath_tid_pull(struct ath_atx_tid *tid)
--+{
--+	struct ath_softc *sc = tid->an->sc;
--+	struct ieee80211_hw *hw = sc->hw;
--+	struct ath_tx_control txctl = {
--+		.txq = tid->txq,
--+		.sta = tid->an->sta,
--+	};
--+	struct sk_buff *skb;
--+	struct ath_frame_info *fi;
--+	int q;
--+
--+	if (!tid->has_queued)
--+		return NULL;
--+
--+	skb = ieee80211_tx_dequeue(hw, container_of((void*)tid, struct ieee80211_txq, drv_priv));
--+	if (!skb) {
--+		tid->has_queued = false;
--+		return NULL;
--+	}
--+
--+	if (ath_tx_prepare(hw, skb, &txctl)) {
--+		ieee80211_free_txskb(hw, skb);
--+		return NULL;
--+	}
--+
--+	q = skb_get_queue_mapping(skb);
--+	if (tid->txq == sc->tx.txq_map[q]) {
--+		fi = get_frame_info(skb);
--+		fi->txq = q;
--+		++tid->txq->pending_frames;
--+	}
--+
--+	return skb;
--+ }
--+
--+
-- static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
-- {
---	return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
--+	return !skb_queue_empty(&tid->retry_q) || tid->has_queued;
-- }
-- 
-- static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
--@@ -199,46 +250,11 @@ static struct sk_buff *ath_tid_dequeue(s
-- 
-- 	skb = __skb_dequeue(&tid->retry_q);
-- 	if (!skb)
---		skb = __skb_dequeue(&tid->buf_q);
--+		skb = ath_tid_pull(tid);
-- 
-- 	return skb;
-- }
-- 
---/*
--- * ath_tx_tid_change_state:
--- * - clears a-mpdu flag of previous session
--- * - force sequence number allocation to fix next BlockAck Window
--- */
---static void
---ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
---{
---	struct ath_txq *txq = tid->txq;
---	struct ieee80211_tx_info *tx_info;
---	struct sk_buff *skb, *tskb;
---	struct ath_buf *bf;
---	struct ath_frame_info *fi;
---
---	skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
---		fi = get_frame_info(skb);
---		bf = fi->bf;
---
---		tx_info = IEEE80211_SKB_CB(skb);
---		tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
---
---		if (bf)
---			continue;
---
---		bf = ath_tx_setup_buffer(sc, txq, tid, skb);
---		if (!bf) {
---			__skb_unlink(skb, &tid->buf_q);
---			ath_txq_skb_done(sc, txq, skb);
---			ieee80211_free_txskb(sc->hw, skb);
---			continue;
---		}
---	}
---
---}
---
-- static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
-- {
-- 	struct ath_txq *txq = tid->txq;
--@@ -873,20 +889,16 @@ static int ath_compute_num_delims(struct
-- 
-- static struct ath_buf *
-- ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
---			struct ath_atx_tid *tid, struct sk_buff_head **q)
--+			struct ath_atx_tid *tid)
-- {
-- 	struct ieee80211_tx_info *tx_info;
-- 	struct ath_frame_info *fi;
---	struct sk_buff *skb;
--+	struct sk_buff *skb, *first_skb = NULL;
-- 	struct ath_buf *bf;
-- 	u16 seqno;
-- 
-- 	while (1) {
---		*q = &tid->retry_q;
---		if (skb_queue_empty(*q))
---			*q = &tid->buf_q;
---
---		skb = skb_peek(*q);
--+		skb = ath_tid_dequeue(tid);
-- 		if (!skb)
-- 			break;
-- 
--@@ -898,7 +910,6 @@ ath_tx_get_tid_subframe(struct ath_softc
-- 			bf->bf_state.stale = false;
-- 
-- 		if (!bf) {
---			__skb_unlink(skb, *q);
-- 			ath_txq_skb_done(sc, txq, skb);
-- 			ieee80211_free_txskb(sc->hw, skb);
-- 			continue;
--@@ -927,8 +938,19 @@ ath_tx_get_tid_subframe(struct ath_softc
-- 		seqno = bf->bf_state.seqno;
-- 
-- 		/* do not step over block-ack window */
---		if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno))
--+		if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
--+			__skb_queue_tail(&tid->retry_q, skb);
--+
--+			/* If there are other skbs in the retry q, they are
--+			 * probably within the BAW, so loop immediately to get
--+			 * one of them. Otherwise the queue can get stuck. */
--+			if (!skb_queue_is_first(&tid->retry_q, skb) && skb != first_skb) {
--+				if(!first_skb) /* infinite loop prevention */
--+					first_skb = skb;
--+				continue;
--+			}
-- 			break;
--+		}
-- 
-- 		if (tid->bar_index > ATH_BA_INDEX(tid->seq_start, seqno)) {
-- 			struct ath_tx_status ts = {};
--@@ -936,7 +958,6 @@ ath_tx_get_tid_subframe(struct ath_softc
-- 
-- 			INIT_LIST_HEAD(&bf_head);
-- 			list_add(&bf->list, &bf_head);
---			__skb_unlink(skb, *q);
-- 			ath_tx_update_baw(sc, tid, seqno);
-- 			ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
-- 			continue;
--@@ -948,11 +969,10 @@ ath_tx_get_tid_subframe(struct ath_softc
-- 	return NULL;
-- }
-- 
---static bool
--+static int
-- ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
-- 		 struct ath_atx_tid *tid, struct list_head *bf_q,
---		 struct ath_buf *bf_first, struct sk_buff_head *tid_q,
---		 int *aggr_len)
--+		 struct ath_buf *bf_first)
-- {
-- #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
-- 	struct ath_buf *bf = bf_first, *bf_prev = NULL;
--@@ -962,12 +982,13 @@ ath_tx_form_aggr(struct ath_softc *sc, s
-- 	struct ieee80211_tx_info *tx_info;
-- 	struct ath_frame_info *fi;
-- 	struct sk_buff *skb;
---	bool closed = false;
--+
-- 
-- 	bf = bf_first;
-- 	aggr_limit = ath_lookup_rate(sc, bf, tid);
-- 
---	do {
--+	while (bf)
--+	{
-- 		skb = bf->bf_mpdu;
-- 		fi = get_frame_info(skb);
-- 
--@@ -976,12 +997,12 @@ ath_tx_form_aggr(struct ath_softc *sc, s
-- 		if (nframes) {
-- 			if (aggr_limit < al + bpad + al_delta ||
-- 			    ath_lookup_legacy(bf) || nframes >= h_baw)
---				break;
--+				goto stop;
-- 
-- 			tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
-- 			if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
-- 			    !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
---				break;
--+				goto stop;
-- 		}
-- 
-- 		/* add padding for previous frame to aggregation length */
--@@ -1003,20 +1024,18 @@ ath_tx_form_aggr(struct ath_softc *sc, s
-- 			ath_tx_addto_baw(sc, tid, bf);
-- 		bf->bf_state.ndelim = ndelim;
-- 
---		__skb_unlink(skb, tid_q);
-- 		list_add_tail(&bf->list, bf_q);
-- 		if (bf_prev)
-- 			bf_prev->bf_next = bf;
-- 
-- 		bf_prev = bf;
-- 
---		bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
---		if (!bf) {
---			closed = true;
---			break;
---		}
---	} while (ath_tid_has_buffered(tid));
---
--+		bf = ath_tx_get_tid_subframe(sc, txq, tid);
--+	}
--+	goto finish;
--+stop:
--+	__skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
--+finish:
-- 	bf = bf_first;
-- 	bf->bf_lastbf = bf_prev;
-- 
--@@ -1027,9 +1046,7 @@ ath_tx_form_aggr(struct ath_softc *sc, s
-- 		TX_STAT_INC(txq->axq_qnum, a_aggr);
-- 	}
-- 
---	*aggr_len = al;
---
---	return closed;
--+	return al;
-- #undef PADBYTES
-- }
-- 
--@@ -1406,18 +1423,15 @@ static void ath_tx_fill_desc(struct ath_
-- static void
-- ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
-- 		  struct ath_atx_tid *tid, struct list_head *bf_q,
---		  struct ath_buf *bf_first, struct sk_buff_head *tid_q)
--+		  struct ath_buf *bf_first)
-- {
-- 	struct ath_buf *bf = bf_first, *bf_prev = NULL;
---	struct sk_buff *skb;
-- 	int nframes = 0;
-- 
-- 	do {
-- 		struct ieee80211_tx_info *tx_info;
---		skb = bf->bf_mpdu;
-- 
-- 		nframes++;
---		__skb_unlink(skb, tid_q);
-- 		list_add_tail(&bf->list, bf_q);
-- 		if (bf_prev)
-- 			bf_prev->bf_next = bf;
--@@ -1426,13 +1440,15 @@ ath_tx_form_burst(struct ath_softc *sc,
-- 		if (nframes >= 2)
-- 			break;
-- 
---		bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
--+		bf = ath_tx_get_tid_subframe(sc, txq, tid);
-- 		if (!bf)
-- 			break;
-- 
-- 		tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
---		if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
--+		if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
--+			__skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
-- 			break;
--+		}
-- 
-- 		ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
-- 	} while (1);
--@@ -1443,34 +1459,33 @@ static bool ath_tx_sched_aggr(struct ath
-- {
-- 	struct ath_buf *bf;
-- 	struct ieee80211_tx_info *tx_info;
---	struct sk_buff_head *tid_q;
-- 	struct list_head bf_q;
-- 	int aggr_len = 0;
---	bool aggr, last = true;
--+	bool aggr;
-- 
-- 	if (!ath_tid_has_buffered(tid))
-- 		return false;
-- 
-- 	INIT_LIST_HEAD(&bf_q);
-- 
---	bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
--+	bf = ath_tx_get_tid_subframe(sc, txq, tid);
-- 	if (!bf)
-- 		return false;
-- 
-- 	tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
-- 	aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
-- 	if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
---		(!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
--+	    (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
--+		__skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
-- 		*stop = true;
-- 		return false;
-- 	}
-- 
-- 	ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
-- 	if (aggr)
---		last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
---					tid_q, &aggr_len);
--+		aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf);
-- 	else
---		ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
--+		ath_tx_form_burst(sc, txq, tid, &bf_q, bf);
-- 
-- 	if (list_empty(&bf_q))
-- 		return false;
--@@ -1513,9 +1528,6 @@ int ath_tx_aggr_start(struct ath_softc *
-- 		an->mpdudensity = density;
-- 	}
-- 
---	/* force sequence number allocation for pending frames */
---	ath_tx_tid_change_state(sc, txtid);
---
-- 	txtid->active = true;
-- 	*ssn = txtid->seq_start = txtid->seq_next;
-- 	txtid->bar_index = -1;
--@@ -1540,7 +1552,6 @@ void ath_tx_aggr_stop(struct ath_softc *
-- 	ath_txq_lock(sc, txq);
-- 	txtid->active = false;
-- 	ath_tx_flush_tid(sc, txtid);
---	ath_tx_tid_change_state(sc, txtid);
-- 	ath_txq_unlock_complete(sc, txq);
-- }
-- 
--@@ -1550,14 +1561,12 @@ void ath_tx_aggr_sleep(struct ieee80211_
-- 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-- 	struct ath_atx_tid *tid;
-- 	struct ath_txq *txq;
---	bool buffered;
-- 	int tidno;
-- 
-- 	ath_dbg(common, XMIT, "%s called\n", __func__);
-- 
---	for (tidno = 0, tid = &an->tid[tidno];
---	     tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
---
--+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
--+		tid = ATH_AN_2_TID(an, tidno);
-- 		txq = tid->txq;
-- 
-- 		ath_txq_lock(sc, txq);
--@@ -1567,13 +1576,12 @@ void ath_tx_aggr_sleep(struct ieee80211_
-- 			continue;
-- 		}
-- 
---		buffered = ath_tid_has_buffered(tid);
--+		if (!skb_queue_empty(&tid->retry_q))
--+			ieee80211_sta_set_buffered(sta, tid->tidno, true);
-- 
-- 		list_del_init(&tid->list);
-- 
-- 		ath_txq_unlock(sc, txq);
---
---		ieee80211_sta_set_buffered(sta, tidno, buffered);
-- 	}
-- }
-- 
--@@ -1586,19 +1594,16 @@ void ath_tx_aggr_wakeup(struct ath_softc
-- 
-- 	ath_dbg(common, XMIT, "%s called\n", __func__);
-- 
---	for (tidno = 0, tid = &an->tid[tidno];
---	     tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
---
--+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
--+		tid = ATH_AN_2_TID(an, tidno);
-- 		txq = tid->txq;
-- 
-- 		ath_txq_lock(sc, txq);
-- 		tid->clear_ps_filter = true;
---
-- 		if (ath_tid_has_buffered(tid)) {
-- 			ath_tx_queue_tid(sc, txq, tid);
-- 			ath_txq_schedule(sc, txq);
-- 		}
---
-- 		ath_txq_unlock_complete(sc, txq);
-- 	}
-- }
--@@ -1621,11 +1626,6 @@ void ath_tx_aggr_resume(struct ath_softc
-- 
-- 	tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
-- 
---	if (ath_tid_has_buffered(tid)) {
---		ath_tx_queue_tid(sc, txq, tid);
---		ath_txq_schedule(sc, txq);
---	}
---
-- 	ath_txq_unlock_complete(sc, txq);
-- }
-- 
--@@ -1641,7 +1641,6 @@ void ath9k_release_buffered_frames(struc
-- 	struct ieee80211_tx_info *info;
-- 	struct list_head bf_q;
-- 	struct ath_buf *bf_tail = NULL, *bf;
---	struct sk_buff_head *tid_q;
-- 	int sent = 0;
-- 	int i;
-- 
--@@ -1656,11 +1655,10 @@ void ath9k_release_buffered_frames(struc
-- 
-- 		ath_txq_lock(sc, tid->txq);
-- 		while (nframes > 0) {
---			bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
--+			bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid);
-- 			if (!bf)
-- 				break;
-- 
---			__skb_unlink(bf->bf_mpdu, tid_q);
-- 			list_add_tail(&bf->list, &bf_q);
-- 			ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
-- 			if (bf_isampdu(bf)) {
--@@ -1675,7 +1673,7 @@ void ath9k_release_buffered_frames(struc
-- 			sent++;
-- 			TX_STAT_INC(txq->axq_qnum, a_queued_hw);
-- 
---			if (an->sta && !ath_tid_has_buffered(tid))
--+			if (an->sta && skb_queue_empty(&tid->retry_q))
-- 				ieee80211_sta_set_buffered(an->sta, i, false);
-- 		}
-- 		ath_txq_unlock_complete(sc, tid->txq);
--@@ -1902,13 +1900,7 @@ bool ath_drain_all_txq(struct ath_softc
-- 		if (!ATH_TXQ_SETUP(sc, i))
-- 			continue;
-- 
---		/*
---		 * The caller will resume queues with ieee80211_wake_queues.
---		 * Mark the queue as not stopped to prevent ath_tx_complete
---		 * from waking the queue too early.
---		 */
-- 		txq = &sc->tx.txq[i];
---		txq->stopped = false;
-- 		ath_draintxq(sc, txq);
-- 	}
-- 
--@@ -2308,15 +2300,12 @@ int ath_tx_start(struct ieee80211_hw *hw
-- 	struct ath_txq *txq = txctl->txq;
-- 	struct ath_atx_tid *tid = NULL;
-- 	struct ath_buf *bf;
---	bool queue, ps_resp;
--+	bool ps_resp;
-- 	int q, ret;
-- 
-- 	if (vif)
-- 		avp = (void *)vif->drv_priv;
-- 
---	if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN)
---		txctl->force_channel = true;
---
-- 	ps_resp = !!(info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE);
-- 
-- 	ret = ath_tx_prepare(hw, skb, txctl);
--@@ -2331,63 +2320,13 @@ int ath_tx_start(struct ieee80211_hw *hw
-- 
-- 	q = skb_get_queue_mapping(skb);
-- 
--+	if (ps_resp)
--+		txq = sc->tx.uapsdq;
--+
-- 	ath_txq_lock(sc, txq);
-- 	if (txq == sc->tx.txq_map[q]) {
-- 		fi->txq = q;
---		if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
---		    !txq->stopped) {
---			if (ath9k_is_chanctx_enabled())
---				ieee80211_stop_queue(sc->hw, info->hw_queue);
---			else
---				ieee80211_stop_queue(sc->hw, q);
---			txq->stopped = true;
---		}
---	}
---
---	queue = ieee80211_is_data_present(hdr->frame_control);
---
---	/* If chanctx, queue all null frames while NOA could be there */
---	if (ath9k_is_chanctx_enabled() &&
---	    ieee80211_is_nullfunc(hdr->frame_control) &&
---	    !txctl->force_channel)
---		queue = true;
---
---	/* Force queueing of all frames that belong to a virtual interface on
---	 * a different channel context, to ensure that they are sent on the
---	 * correct channel.
---	 */
---	if (((avp && avp->chanctx != sc->cur_chan) ||
---	     sc->cur_chan->stopped) && !txctl->force_channel) {
---		if (!txctl->an)
---			txctl->an = &avp->mcast_node;
---		queue = true;
---		ps_resp = false;
---	}
---
---	if (txctl->an && queue)
---		tid = ath_get_skb_tid(sc, txctl->an, skb);
---
---	if (ps_resp) {
---		ath_txq_unlock(sc, txq);
---		txq = sc->tx.uapsdq;
---		ath_txq_lock(sc, txq);
---	} else if (txctl->an && queue) {
---		WARN_ON(tid->txq != txctl->txq);
---
---		if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
---			tid->clear_ps_filter = true;
---
---		/*
---		 * Add this frame to software queue for scheduling later
---		 * for aggregation.
---		 */
---		TX_STAT_INC(txq->axq_qnum, a_queued_sw);
---		__skb_queue_tail(&tid->buf_q, skb);
---		if (!txctl->an->sleeping)
---			ath_tx_queue_tid(sc, txq, tid);
---
---		ath_txq_schedule(sc, txq);
---		goto out;
--+		++txq->pending_frames;
-- 	}
-- 
-- 	bf = ath_tx_setup_buffer(sc, txq, tid, skb);
--@@ -2871,9 +2810,8 @@ void ath_tx_node_init(struct ath_softc *
-- 	struct ath_atx_tid *tid;
-- 	int tidno, acno;
-- 
---	for (tidno = 0, tid = &an->tid[tidno];
---	     tidno < IEEE80211_NUM_TIDS;
---	     tidno++, tid++) {
--+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
--+		tid = ATH_AN_2_TID(an, tidno);
-- 		tid->an        = an;
-- 		tid->tidno     = tidno;
-- 		tid->seq_start = tid->seq_next = 0;
--@@ -2881,11 +2819,14 @@ void ath_tx_node_init(struct ath_softc *
-- 		tid->baw_head  = tid->baw_tail = 0;
-- 		tid->active	   = false;
-- 		tid->clear_ps_filter = true;
---		__skb_queue_head_init(&tid->buf_q);
--+		tid->has_queued  = false;
-- 		__skb_queue_head_init(&tid->retry_q);
-- 		INIT_LIST_HEAD(&tid->list);
-- 		acno = TID_TO_WME_AC(tidno);
-- 		tid->txq = sc->tx.txq_map[acno];
--+
--+		if (!an->sta)
--+			break; /* just one multicast ath_atx_tid */
-- 	}
-- }
-- 
--@@ -2895,9 +2836,8 @@ void ath_tx_node_cleanup(struct ath_soft
-- 	struct ath_txq *txq;
-- 	int tidno;
-- 
---	for (tidno = 0, tid = &an->tid[tidno];
---	     tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
---
--+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
--+		tid = ATH_AN_2_TID(an, tidno);
-- 		txq = tid->txq;
-- 
-- 		ath_txq_lock(sc, txq);
--@@ -2909,6 +2849,9 @@ void ath_tx_node_cleanup(struct ath_soft
-- 		tid->active = false;
-- 
-- 		ath_txq_unlock(sc, txq);
--+
--+		if (!an->sta)
--+			break; /* just one multicast ath_atx_tid */
-- 	}
-- }
-- 

Some files were not shown because too many files changed in this diff