فهرست منبع

kernel: split patches folder up into backport, pending and hack folders

* properly format/comment all patches
* merge debloat patches
* merge Kconfig patches
* merge swconfig patches
* merge hotplug patches
* drop 200-fix_localversion.patch - upstream
* drop 222-arm_zimage_none.patch - unused
* drop 252-mv_cesa_depends.patch - no longer required
* drop 410-mtd-move-forward-declaration-of-struct-mtd_info.patch - unused
* drop 661-fq_codel_keep_dropped_stats.patch - outdated
* drop 702-phy_add_aneg_done_function.patch - upstream
* drop 840-rtc7301.patch - unused
* drop 841-rtc_pt7c4338.patch - upstream
* drop 921-use_preinit_as_init.patch - unused
* drop spio-gpio-old and gpio-mmc - unused

Signed-off-by: John Crispin <[email protected]>
John Crispin 8 سال پیش
والد
کامیت
74d00a8c38
100فایلهای تغییر یافته به همراه2083 افزوده شده و 1105 حذف شده
  1. 1 1
      include/kernel-build.mk
  2. 8 0
      include/quilt.mk
  3. 3 1
      include/target.mk
  4. 10 1
      target/linux/generic/backport-4.9/010-Kbuild-don-t-hardcode-path-to-awk-in-scripts-ld-vers.patch
  5. 16 1
      target/linux/generic/backport-4.9/011-kbuild-export-SUBARCH.patch
  6. 29 2
      target/linux/generic/backport-4.9/020-backport_netfilter_rtcache.patch
  7. 1 1
      target/linux/generic/backport-4.9/021-bridge-multicast-to-unicast.patch
  8. 0 0
      target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch
  9. 0 0
      target/linux/generic/backport-4.9/023-1-smsc95xx-Use-skb_cow_head-to-deal-with-cloned-skbs.patch
  10. 0 0
      target/linux/generic/backport-4.9/023-2-smsc75xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch
  11. 0 0
      target/linux/generic/backport-4.9/023-3-cx82310_eth-use-skb_cow_head-to-deal-with-cloned-skb.patch
  12. 0 0
      target/linux/generic/backport-4.9/023-4-sr9700-use-skb_cow_head-to-deal-with-cloned-skbs.patch
  13. 0 0
      target/linux/generic/backport-4.9/023-5-lan78xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch
  14. 0 0
      target/linux/generic/backport-4.9/023-6-ch9200-use-skb_cow_head-to-deal-with-cloned-skbs.patch
  15. 0 0
      target/linux/generic/backport-4.9/023-7-kaweth-use-skb_cow_head-to-deal-with-cloned-skbs.patch
  16. 0 0
      target/linux/generic/backport-4.9/030-01-ubifs-Drop-softlimit-and-delta-fields-from-struct-ub.patch
  17. 0 0
      target/linux/generic/backport-4.9/030-02-ubifs-Use-dirty_writeback_interval-value-for-wbuf-ti.patch
  18. 0 0
      target/linux/generic/backport-4.9/050-usb-dwc2-Remove-unnecessary-kfree.patch
  19. 0 0
      target/linux/generic/backport-4.9/060-0002-mtd-bcm47xxsflash-use-platform_-set-get-_drvdata.patch
  20. 0 0
      target/linux/generic/backport-4.9/060-0003-mtd-bcm47xxsflash-support-reading-flash-out-of-mappi.patch
  21. 0 0
      target/linux/generic/backport-4.9/060-0004-mtd-bcm47xxpart-move-TRX-parsing-code-to-separated-f.patch
  22. 0 0
      target/linux/generic/backport-4.9/060-0005-mtd-bcm47xxpart-support-layouts-with-multiple-TRX-pa.patch
  23. 0 0
      target/linux/generic/backport-4.9/061-v4.10-0001-mtd-spi-nor-add-Macronix-mx25u25635f-to-list-of-know.patch
  24. 2 2
      target/linux/generic/backport-4.9/061-v4.10-0002-mtd-spi-nor-fix-spansion-quad-enable.patch
  25. 0 0
      target/linux/generic/backport-4.9/061-v4.10-0003-mtd-spi-nor-fix-flags-for-s25fl128s.patch
  26. 0 0
      target/linux/generic/backport-4.9/061-v4.10-0004-mtd-spi-nor-add-support-for-s25fl208k.patch
  27. 0 0
      target/linux/generic/backport-4.9/061-v4.10-0005-mtd-spi-nor-Add-at25df321-spi-nor-flash-support.patch
  28. 0 0
      target/linux/generic/backport-4.9/061-v4.10-0006-mtd-spi-nor-Add-support-for-N25Q016A.patch
  29. 0 0
      target/linux/generic/backport-4.9/061-v4.10-0007-mtd-spi-nor-Add-support-for-mr25h40.patch
  30. 3 3
      target/linux/generic/backport-4.9/062-v4.11-0001-mtd-spi-nor-Add-support-for-S3AN-spi-nor-devices.patch
  31. 0 0
      target/linux/generic/backport-4.9/062-v4.11-0002-mtd-spi-nor-improve-macronix_quad_enable.patch
  32. 0 0
      target/linux/generic/backport-4.9/062-v4.11-0003-mtd-spi-nor-remove-WARN_ONCE-message-in-spi_nor_writ.patch
  33. 1 1
      target/linux/generic/backport-4.9/062-v4.11-0004-mtd-spi-nor-rename-SPINOR_OP_-macros-of-the-4-byte-a.patch
  34. 1 1
      target/linux/generic/backport-4.9/062-v4.11-0005-mtd-spi-nor-add-a-stateless-method-to-support-memory.patch
  35. 0 0
      target/linux/generic/backport-4.9/062-v4.11-0006-mtd-spi-nor-Add-lock-unlock-support-for-f25l32pa.patch
  36. 0 0
      target/linux/generic/backport-4.9/062-v4.11-0007-mtd-spi-nor-Fix-S3AN-addressing-calculation.patch
  37. 0 0
      target/linux/generic/backport-4.9/062-v4.11-0008-mtd-spi-nor-Add-support-for-gd25q16.patch
  38. 0 0
      target/linux/generic/backport-4.9/063-mtd-spi-nor-enable-stateless-4b-op-codes-for-mx25u25.patch
  39. 0 0
      target/linux/generic/backport-4.9/064-v4.11-0001-mtd-introduce-function-max_bad_blocks.patch
  40. 0 0
      target/linux/generic/backport-4.9/064-v4.11-0002-mtd-Add-partition-device-node-to-mtd-partition-devic.patch
  41. 0 0
      target/linux/generic/backport-4.9/065-v4.13-0001-mtd-handle-partitioning-on-devices-with-0-erasesize.patch
  42. 0 0
      target/linux/generic/backport-4.9/065-v4.13-0002-mtd-partitions-factor-out-code-calling-parser.patch
  43. 0 0
      target/linux/generic/backport-4.9/065-v4.13-0003-mtd-partitions-add-helper-for-deleting-partition.patch
  44. 0 0
      target/linux/generic/backport-4.9/065-v4.13-0004-mtd-partitions-remove-sysfs-files-when-deleting-all-.patch
  45. 0 0
      target/linux/generic/backport-4.9/065-v4.13-0005-mtd-partitions-rename-master-to-the-parent-where-app.patch
  46. 0 0
      target/linux/generic/backport-4.9/065-v4.13-0006-mtd-partitions-add-support-for-subpartitions.patch
  47. 0 0
      target/linux/generic/backport-4.9/065-v4.13-0007-mtd-partitions-add-support-for-partition-parsers.patch
  48. 0 0
      target/linux/generic/backport-4.9/065-v4.13-0008-mtd-extract-TRX-parser-out-of-bcm47xxpart-into-a-sep.patch
  49. 0 0
      target/linux/generic/backport-4.9/070-bcma-from-4.11.patch
  50. 0 0
      target/linux/generic/backport-4.9/071-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch
  51. 0 0
      target/linux/generic/backport-4.9/071-v4.10-0002-net-bgmac-drop-struct-bcma_mdio-we-don-t-need-anymor.patch
  52. 0 0
      target/linux/generic/backport-4.9/071-v4.10-0003-net-bgmac-use-PHY-subsystem-for-initializing-PHY.patch
  53. 0 0
      target/linux/generic/backport-4.9/072-bcma-from-4.12.patch
  54. 0 0
      target/linux/generic/backport-4.9/075-v4.10-0001-net-phy-broadcom-Update-Auxiliary-Control-Register-m.patch
  55. 0 0
      target/linux/generic/backport-4.9/075-v4.10-0002-net-phy-broadcom-Add-support-for-BCM54612E.patch
  56. 0 0
      target/linux/generic/backport-4.9/075-v4.10-0003-net-phy-broadcom-add-bcm54xx_auxctl_read.patch
  57. 0 0
      target/linux/generic/backport-4.9/075-v4.10-0004-net-phy-broadcom-Add-BCM54810-PHY-entry.patch
  58. 0 0
      target/linux/generic/backport-4.9/075-v4.10-0005-net-phy-broadcom-Move-bcm54xx_auxctl_-read-write-to-.patch
  59. 0 0
      target/linux/generic/backport-4.9/076-v4.11-0001-net-phy-broadcom-Allow-enabling-or-disabling-of-EEE.patch
  60. 0 0
      target/linux/generic/backport-4.9/076-v4.11-0002-net-phy-broadcom-Add-support-code-for-reading-PHY-co.patch
  61. 0 0
      target/linux/generic/backport-4.9/076-v4.11-0003-net-phy-bcm7xxx-Add-entry-for-BCM7278.patch
  62. 0 0
      target/linux/generic/backport-4.9/076-v4.11-0004-net-phy-bcm7xxx-Implement-EGPHY-workaround-for-7278.patch
  63. 0 0
      target/linux/generic/backport-4.9/076-v4.11-0005-net-phy-broadcom-use-auxctl-reading-helper-in-BCM546.patch
  64. 0 0
      target/linux/generic/backport-4.9/076-v4.11-0006-net-phy-broadcom-add-support-for-BCM54210E.patch
  65. 0 0
      target/linux/generic/backport-4.9/076-v4.11-0007-net-phy-broadcom-rehook-BCM54612E-specific-init.patch
  66. 0 0
      target/linux/generic/backport-4.9/080-0001-leds-core-add-OF-variants-of-LED-registering-functio.patch
  67. 0 0
      target/linux/generic/backport-4.9/080-0002-leds-gpio-use-OF-variant-of-LED-registering-function.patch
  68. 0 0
      target/linux/generic/backport-4.9/081-0001-thermal-bcm2835-add-thermal-driver-for-bcm2835-SoC.patch
  69. 0 0
      target/linux/generic/backport-4.9/081-0002-thermal-broadcom-add-Northstar-thermal-driver.patch
  70. 0 0
      target/linux/generic/backport-4.9/082-0001-usb-core-read-USB-ports-from-DT-in-the-usbport-LED-t.patch
  71. 0 0
      target/linux/generic/backport-4.9/087-regmap-make-LZO-cache-optional.patch
  72. 29 0
      target/linux/generic/hack-4.9/202-reduce_module_size.patch
  73. 33 11
      target/linux/generic/hack-4.9/204-module_strip.patch
  74. 21 4
      target/linux/generic/hack-4.9/207-disable-modorder.patch
  75. 56 29
      target/linux/generic/hack-4.9/210-darwin_scripts_include.patch
  76. 49 0
      target/linux/generic/hack-4.9/211-host_tools_portability.patch
  77. 24 0
      target/linux/generic/hack-4.9/212-byteshift_portability.patch
  78. 29 0
      target/linux/generic/hack-4.9/214-spidev_h_portability.patch
  79. 188 162
      target/linux/generic/hack-4.9/220-gc_sections.patch
  80. 33 11
      target/linux/generic/hack-4.9/221-module_exports.patch
  81. 33 11
      target/linux/generic/hack-4.9/230-openwrt_lzma_options.patch
  82. 14 0
      target/linux/generic/hack-4.9/250-netfilter_depends.patch
  83. 212 0
      target/linux/generic/hack-4.9/251-sound_kconfig.patch
  84. 36 11
      target/linux/generic/hack-4.9/259-regmap_dynamic.patch
  85. 22 1
      target/linux/generic/hack-4.9/260-crypto_test_dependencies.patch
  86. 48 22
      target/linux/generic/hack-4.9/280-rfkill-stubs.patch
  87. 45 0
      target/linux/generic/hack-4.9/301-mips_image_cmdline_hack.patch
  88. 31 0
      target/linux/generic/hack-4.9/321-powerpc_crtsavres_prereq.patch
  89. 770 742
      target/linux/generic/hack-4.9/531-debloat_lzma.patch
  90. 12 2
      target/linux/generic/hack-4.9/640-bridge-only-accept-EAP-locally.patch
  91. 43 25
      target/linux/generic/hack-4.9/641-bridge_port_isolate.patch
  92. 29 0
      target/linux/generic/hack-4.9/651-wireless_mesh_header.patch
  93. 26 0
      target/linux/generic/hack-4.9/660-fq_codel_defaults.patch
  94. 58 31
      target/linux/generic/hack-4.9/661-use_fq_codel_by_default.patch
  95. 16 1
      target/linux/generic/hack-4.9/662-remove_pfifo_fast.patch
  96. 21 0
      target/linux/generic/hack-4.9/700-swconfig_switch_drivers.patch
  97. 0 0
      target/linux/generic/hack-4.9/710-phy-add-mdio_register_board_info.patch
  98. 40 13
      target/linux/generic/hack-4.9/721-phy_packets.patch
  99. 31 15
      target/linux/generic/hack-4.9/773-bgmac-add-srab-switch.patch
  100. 59 0
      target/linux/generic/hack-4.9/835-misc-owl_loader.patch

+ 1 - 1
include/kernel-build.mk

@@ -11,7 +11,7 @@ ifneq ($(DUMP),1)
   all: compile
 endif
 
-KERNEL_FILE_DEPENDS=$(GENERIC_PATCH_DIR) $(PATCH_DIR) $(GENERIC_FILES_DIR) $(FILES_DIR)
+KERNEL_FILE_DEPENDS=$(BACKPORT_PATCH_DIR) $(GENERIC_PATCH_DIR) $(GENERIC_HACK_DIR) $(PATCH_DIR) $(GENERIC_FILES_DIR) $(FILES_DIR)
 STAMP_PREPARED=$(LINUX_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call find_md5,$(KERNEL_FILE_DEPENDS),)))
 STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
 include $(INCLUDE_DIR)/download.mk

+ 8 - 0
include/quilt.mk

@@ -97,7 +97,13 @@ define Kernel/Patch/Default
 	$(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches)
 	$(if $(kernel_files),$(CP) $(kernel_files) $(LINUX_DIR)/)
 	find $(LINUX_DIR)/ -name \*.rej -or -name \*.orig | $(XARGS) rm -f
+	if [ -d $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) ]; then \
+		echo "generic patches directory is present. please move your patches to the pending directory" ; \
+		exit 1; \
+	fi
+	$(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_BACKPORT_DIR),generic-backport/)
 	$(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/)
+	$(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_HACK_DIR),generic-hack/)
 	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/)
 endef
 
@@ -124,7 +130,9 @@ define Quilt/Refresh/Kernel
 		echo "All kernel patches must start with either generic/ or platform/"; \
 		false; \
 	}
+	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_BACKPORT_DIR),generic-backport/)
 	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/)
+	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_HACK_DIR),generic-hack/)
 	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/)
 endef
 

+ 3 - 1
include/target.mk

@@ -104,7 +104,9 @@ ifneq ($(TARGET_BUILD)$(if $(DUMP),,1),)
 endif
 
 GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic
-GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
+GENERIC_BACKPORT_DIR := $(GENERIC_PLATFORM_DIR)/backport$(if $(wildcard $(GENERIC_PLATFORM_DIR)/backport-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
+GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/pending$(if $(wildcard $(GENERIC_PLATFORM_DIR)/pending-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
+GENERIC_HACK_DIR := $(GENERIC_PLATFORM_DIR)/hack$(if $(wildcard $(GENERIC_PLATFORM_DIR)/hack-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
 GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)),"$(dir)")
 
 __config_name_list = $(1)/config-$(KERNEL_PATCHVER) $(1)/config-default

+ 10 - 1
target/linux/generic/patches-4.9/010-Kbuild-don-t-hardcode-path-to-awk-in-scripts-ld-vers.patch → target/linux/generic/backport-4.9/010-Kbuild-don-t-hardcode-path-to-awk-in-scripts-ld-vers.patch

@@ -1,13 +1,19 @@
+From 13b1ecc3401653a355798eb1dee10cc1608202f4 Mon Sep 17 00:00:00 2001
 From: Felix Fietkau <[email protected]>
 Date: Mon, 18 Jan 2016 12:27:49 +0100
-Subject: [PATCH] Kbuild: don't hardcode path to awk in scripts/ld-version.sh
+Subject: [PATCH 33/34] Kbuild: don't hardcode path to awk in
+ scripts/ld-version.sh
 
 On some systems /usr/bin/awk does not exist, or is broken. Find it via
 $PATH instead.
 
 Signed-off-by: Felix Fietkau <[email protected]>
 ---
+ scripts/ld-version.sh | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
 
+diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
+index d135882e2c40..66e6e5ed1b7b 100755
 --- a/scripts/ld-version.sh
 +++ b/scripts/ld-version.sh
 @@ -1,5 +1,6 @@
@@ -23,3 +29,6 @@ Signed-off-by: Felix Fietkau <[email protected]>
  	exit
  	}
 +'
+-- 
+2.11.0
+

+ 16 - 1
target/linux/generic/patches-4.9/011-kbuild-export-SUBARCH.patch → target/linux/generic/backport-4.9/011-kbuild-export-SUBARCH.patch

@@ -1,6 +1,18 @@
+From 173019b66dcc9d68ad9333aa744dad1e369b5aa8 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Sun, 9 Jul 2017 00:26:53 +0200
+Subject: [PATCH 34/34] kernel: add compile fix for linux 4.9 on x86
+
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ Makefile | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index dd0a67d6e392..6e37f6bb669a 100644
 --- a/Makefile
 +++ b/Makefile
-@@ -414,8 +414,8 @@ KERNELRELEASE = $(shell cat include/conf
+@@ -420,8 +420,8 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
  KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
  
  export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
@@ -11,3 +23,6 @@
  export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
  export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
  
+-- 
+2.11.0
+

+ 29 - 2
target/linux/generic/patches-4.9/020-backport_netfilter_rtcache.patch → target/linux/generic/backport-4.9/020-backport_netfilter_rtcache.patch

@@ -1,4 +1,7 @@
-Subject: netfilter: conntrack: cache route for forwarded connections
+From c4d66e57455f5384128753674cc0f9e02db5e1f6 Mon Sep 17 00:00:00 2001
+From: Florian Westphal <[email protected]>
+Date: Sun, 9 Jul 2017 08:58:30 +0200
+Subject: [PATCH] netfilter: conntrack: cache route for forwarded connections
 
 ... to avoid per-packet FIB lookup if possible.
 
@@ -22,7 +25,18 @@ Julian Anastasov suggested to add NETDEV_UNREGISTER handler to
 avoid holding on to dsts of 'frozen' conntracks.
 
 Signed-off-by: Florian Westphal <[email protected]>
+---
+ include/net/netfilter/nf_conntrack_extend.h  |   4 +
+ include/net/netfilter/nf_conntrack_rtcache.h |  34 +++
+ net/netfilter/Kconfig                        |  12 +
+ net/netfilter/Makefile                       |   3 +
+ net/netfilter/nf_conntrack_rtcache.c         | 413 +++++++++++++++++++++++++++
+ 5 files changed, 466 insertions(+)
+ create mode 100644 include/net/netfilter/nf_conntrack_rtcache.h
+ create mode 100644 net/netfilter/nf_conntrack_rtcache.c
 
+diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h
+index 1c3035dda31f..0988c7dfa604 100644
 --- a/include/net/netfilter/nf_conntrack_extend.h
 +++ b/include/net/netfilter/nf_conntrack_extend.h
 @@ -27,6 +27,9 @@ enum nf_ct_ext_id {
@@ -43,6 +57,9 @@ Signed-off-by: Florian Westphal <[email protected]>
  
  /* Extensions: optional stuff which isn't permanently in struct. */
  struct nf_ct_ext {
+diff --git a/include/net/netfilter/nf_conntrack_rtcache.h b/include/net/netfilter/nf_conntrack_rtcache.h
+new file mode 100644
+index 000000000000..e2fb30243354
 --- /dev/null
 +++ b/include/net/netfilter/nf_conntrack_rtcache.h
 @@ -0,0 +1,34 @@
@@ -80,6 +97,8 @@ Signed-off-by: Florian Westphal <[email protected]>
 +{
 +	return rtc->cached_dst[dir].iif;
 +}
+diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
+index e8d56d9a4df2..82af5ba64088 100644
 --- a/net/netfilter/Kconfig
 +++ b/net/netfilter/Kconfig
 @@ -114,6 +114,18 @@ config NF_CONNTRACK_EVENTS
@@ -101,9 +120,11 @@ Signed-off-by: Florian Westphal <[email protected]>
  config NF_CONNTRACK_TIMEOUT
  	bool  'Connection tracking timeout'
  	depends on NETFILTER_ADVANCED
+diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
+index c23c3c84416f..8adef51367f9 100644
 --- a/net/netfilter/Makefile
 +++ b/net/netfilter/Makefile
-@@ -16,6 +16,9 @@ obj-$(CONFIG_NETFILTER_NETLINK_LOG) += n
+@@ -16,6 +16,9 @@ obj-$(CONFIG_NETFILTER_NETLINK_LOG) += nfnetlink_log.o
  # connection tracking
  obj-$(CONFIG_NF_CONNTRACK) += nf_conntrack.o
  
@@ -113,6 +134,9 @@ Signed-off-by: Florian Westphal <[email protected]>
  # SCTP protocol connection tracking
  obj-$(CONFIG_NF_CT_PROTO_DCCP) += nf_conntrack_proto_dccp.o
  obj-$(CONFIG_NF_CT_PROTO_GRE) += nf_conntrack_proto_gre.o
+diff --git a/net/netfilter/nf_conntrack_rtcache.c b/net/netfilter/nf_conntrack_rtcache.c
+new file mode 100644
+index 000000000000..fb073d01960d
 --- /dev/null
 +++ b/net/netfilter/nf_conntrack_rtcache.c
 @@ -0,0 +1,413 @@
@@ -529,3 +553,6 @@ Signed-off-by: Florian Westphal <[email protected]>
 +MODULE_LICENSE("GPL");
 +MODULE_AUTHOR("Florian Westphal <[email protected]>");
 +MODULE_DESCRIPTION("Conntrack route cache extension");
+-- 
+2.11.0
+

+ 1 - 1
target/linux/generic/patches-4.9/021-bridge-multicast-to-unicast.patch → target/linux/generic/backport-4.9/021-bridge-multicast-to-unicast.patch

@@ -106,7 +106,7 @@ Signed-off-by: Linus Lüssing <[email protected]>
  		if (prev == port)
 --- a/net/bridge/br_mdb.c
 +++ b/net/bridge/br_mdb.c
-@@ -532,7 +532,7 @@ static int br_mdb_add_group(struct net_b
+@@ -531,7 +531,7 @@ static int br_mdb_add_group(struct net_b
  			break;
  	}
  

+ 0 - 0
target/linux/generic/patches-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch → target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch


+ 0 - 0
target/linux/generic/patches-4.9/023-1-smsc95xx-Use-skb_cow_head-to-deal-with-cloned-skbs.patch → target/linux/generic/backport-4.9/023-1-smsc95xx-Use-skb_cow_head-to-deal-with-cloned-skbs.patch


+ 0 - 0
target/linux/generic/patches-4.9/023-2-smsc75xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch → target/linux/generic/backport-4.9/023-2-smsc75xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch


+ 0 - 0
target/linux/generic/patches-4.9/023-3-cx82310_eth-use-skb_cow_head-to-deal-with-cloned-skb.patch → target/linux/generic/backport-4.9/023-3-cx82310_eth-use-skb_cow_head-to-deal-with-cloned-skb.patch


+ 0 - 0
target/linux/generic/patches-4.9/023-4-sr9700-use-skb_cow_head-to-deal-with-cloned-skbs.patch → target/linux/generic/backport-4.9/023-4-sr9700-use-skb_cow_head-to-deal-with-cloned-skbs.patch


+ 0 - 0
target/linux/generic/patches-4.9/023-5-lan78xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch → target/linux/generic/backport-4.9/023-5-lan78xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch


+ 0 - 0
target/linux/generic/patches-4.9/023-6-ch9200-use-skb_cow_head-to-deal-with-cloned-skbs.patch → target/linux/generic/backport-4.9/023-6-ch9200-use-skb_cow_head-to-deal-with-cloned-skbs.patch


+ 0 - 0
target/linux/generic/patches-4.9/023-7-kaweth-use-skb_cow_head-to-deal-with-cloned-skbs.patch → target/linux/generic/backport-4.9/023-7-kaweth-use-skb_cow_head-to-deal-with-cloned-skbs.patch


+ 0 - 0
target/linux/generic/patches-4.9/030-01-ubifs-Drop-softlimit-and-delta-fields-from-struct-ub.patch → target/linux/generic/backport-4.9/030-01-ubifs-Drop-softlimit-and-delta-fields-from-struct-ub.patch


+ 0 - 0
target/linux/generic/patches-4.9/030-02-ubifs-Use-dirty_writeback_interval-value-for-wbuf-ti.patch → target/linux/generic/backport-4.9/030-02-ubifs-Use-dirty_writeback_interval-value-for-wbuf-ti.patch


+ 0 - 0
target/linux/generic/patches-4.9/050-usb-dwc2-Remove-unnecessary-kfree.patch → target/linux/generic/backport-4.9/050-usb-dwc2-Remove-unnecessary-kfree.patch


+ 0 - 0
target/linux/generic/patches-4.9/060-0002-mtd-bcm47xxsflash-use-platform_-set-get-_drvdata.patch → target/linux/generic/backport-4.9/060-0002-mtd-bcm47xxsflash-use-platform_-set-get-_drvdata.patch


+ 0 - 0
target/linux/generic/patches-4.9/060-0003-mtd-bcm47xxsflash-support-reading-flash-out-of-mappi.patch → target/linux/generic/backport-4.9/060-0003-mtd-bcm47xxsflash-support-reading-flash-out-of-mappi.patch


+ 0 - 0
target/linux/generic/patches-4.9/060-0004-mtd-bcm47xxpart-move-TRX-parsing-code-to-separated-f.patch → target/linux/generic/backport-4.9/060-0004-mtd-bcm47xxpart-move-TRX-parsing-code-to-separated-f.patch


+ 0 - 0
target/linux/generic/patches-4.9/060-0005-mtd-bcm47xxpart-support-layouts-with-multiple-TRX-pa.patch → target/linux/generic/backport-4.9/060-0005-mtd-bcm47xxpart-support-layouts-with-multiple-TRX-pa.patch


+ 0 - 0
target/linux/generic/patches-4.9/061-v4.10-0001-mtd-spi-nor-add-Macronix-mx25u25635f-to-list-of-know.patch → target/linux/generic/backport-4.9/061-v4.10-0001-mtd-spi-nor-add-Macronix-mx25u25635f-to-list-of-know.patch


+ 2 - 2
target/linux/generic/patches-4.9/061-v4.10-0002-mtd-spi-nor-fix-spansion-quad-enable.patch → target/linux/generic/backport-4.9/061-v4.10-0002-mtd-spi-nor-fix-spansion-quad-enable.patch

@@ -26,8 +26,8 @@ Signed-off-by: Cyrille Pitchen <[email protected]>
 
 --- a/drivers/mtd/spi-nor/spi-nor.c
 +++ b/drivers/mtd/spi-nor/spi-nor.c
-@@ -1263,6 +1263,13 @@ static int spansion_quad_enable(struct s
- 		return ret;
+@@ -1256,6 +1256,13 @@ static int spansion_quad_enable(struct s
+ 		return -EINVAL;
  	}
  
 +	ret = spi_nor_wait_till_ready(nor);

+ 0 - 0
target/linux/generic/patches-4.9/061-v4.10-0003-mtd-spi-nor-fix-flags-for-s25fl128s.patch → target/linux/generic/backport-4.9/061-v4.10-0003-mtd-spi-nor-fix-flags-for-s25fl128s.patch


+ 0 - 0
target/linux/generic/patches-4.9/061-v4.10-0004-mtd-spi-nor-add-support-for-s25fl208k.patch → target/linux/generic/backport-4.9/061-v4.10-0004-mtd-spi-nor-add-support-for-s25fl208k.patch


+ 0 - 0
target/linux/generic/patches-4.9/061-v4.10-0005-mtd-spi-nor-Add-at25df321-spi-nor-flash-support.patch → target/linux/generic/backport-4.9/061-v4.10-0005-mtd-spi-nor-Add-at25df321-spi-nor-flash-support.patch


+ 0 - 0
target/linux/generic/patches-4.9/061-v4.10-0006-mtd-spi-nor-Add-support-for-N25Q016A.patch → target/linux/generic/backport-4.9/061-v4.10-0006-mtd-spi-nor-Add-support-for-N25Q016A.patch


+ 0 - 0
target/linux/generic/patches-4.9/061-v4.10-0007-mtd-spi-nor-Add-support-for-mr25h40.patch → target/linux/generic/backport-4.9/061-v4.10-0007-mtd-spi-nor-Add-support-for-mr25h40.patch


+ 3 - 3
target/linux/generic/patches-4.9/062-v4.11-0001-mtd-spi-nor-Add-support-for-S3AN-spi-nor-devices.patch → target/linux/generic/backport-4.9/062-v4.11-0001-mtd-spi-nor-Add-support-for-S3AN-spi-nor-devices.patch

@@ -206,7 +206,7 @@ Signed-off-by: Cyrille Pitchen <[email protected]>
  		if (ret < 0)
  			goto write_err;
  		written = ret;
-@@ -1319,6 +1408,47 @@ static int spi_nor_check(struct spi_nor
+@@ -1312,6 +1401,47 @@ static int spi_nor_check(struct spi_nor
  	return 0;
  }
  
@@ -254,7 +254,7 @@ Signed-off-by: Cyrille Pitchen <[email protected]>
  int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
  {
  	const struct flash_info *info = NULL;
-@@ -1367,6 +1497,14 @@ int spi_nor_scan(struct spi_nor *nor, co
+@@ -1360,6 +1490,14 @@ int spi_nor_scan(struct spi_nor *nor, co
  	mutex_init(&nor->lock);
  
  	/*
@@ -269,7 +269,7 @@ Signed-off-by: Cyrille Pitchen <[email protected]>
  	 * Atmel, SST, Intel/Numonyx, and others serial NOR tend to power up
  	 * with the software protection bits set
  	 */
-@@ -1524,6 +1662,12 @@ int spi_nor_scan(struct spi_nor *nor, co
+@@ -1517,6 +1655,12 @@ int spi_nor_scan(struct spi_nor *nor, co
  
  	nor->read_dummy = spi_nor_read_dummy_cycles(nor);
  

+ 0 - 0
target/linux/generic/patches-4.9/062-v4.11-0002-mtd-spi-nor-improve-macronix_quad_enable.patch → target/linux/generic/backport-4.9/062-v4.11-0002-mtd-spi-nor-improve-macronix_quad_enable.patch


+ 0 - 0
target/linux/generic/patches-4.9/062-v4.11-0003-mtd-spi-nor-remove-WARN_ONCE-message-in-spi_nor_writ.patch → target/linux/generic/backport-4.9/062-v4.11-0003-mtd-spi-nor-remove-WARN_ONCE-message-in-spi_nor_writ.patch


+ 1 - 1
target/linux/generic/patches-4.9/062-v4.11-0004-mtd-spi-nor-rename-SPINOR_OP_-macros-of-the-4-byte-a.patch → target/linux/generic/backport-4.9/062-v4.11-0004-mtd-spi-nor-rename-SPINOR_OP_-macros-of-the-4-byte-a.patch

@@ -95,7 +95,7 @@ Acked-by: Marek Vasut <[email protected]>
  static struct seq_rw_config stfsm_s25fl_write4_configs[] = {
 --- a/drivers/mtd/spi-nor/spi-nor.c
 +++ b/drivers/mtd/spi-nor/spi-nor.c
-@@ -1632,16 +1632,16 @@ int spi_nor_scan(struct spi_nor *nor, co
+@@ -1625,16 +1625,16 @@ int spi_nor_scan(struct spi_nor *nor, co
  			/* Dedicated 4-byte command set */
  			switch (nor->flash_read) {
  			case SPI_NOR_QUAD:

+ 1 - 1
target/linux/generic/patches-4.9/062-v4.11-0005-mtd-spi-nor-add-a-stateless-method-to-support-memory.patch → target/linux/generic/backport-4.9/062-v4.11-0005-mtd-spi-nor-add-a-stateless-method-to-support-memory.patch

@@ -116,7 +116,7 @@ Acked-by: Marek Vasut <[email protected]>
  /* Enable/disable 4-byte addressing mode. */
  static inline int set_4byte(struct spi_nor *nor, const struct flash_info *info,
  			    int enable)
-@@ -1628,27 +1704,10 @@ int spi_nor_scan(struct spi_nor *nor, co
+@@ -1621,27 +1697,10 @@ 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;

+ 0 - 0
target/linux/generic/patches-4.9/062-v4.11-0006-mtd-spi-nor-Add-lock-unlock-support-for-f25l32pa.patch → target/linux/generic/backport-4.9/062-v4.11-0006-mtd-spi-nor-Add-lock-unlock-support-for-f25l32pa.patch


+ 0 - 0
target/linux/generic/patches-4.9/062-v4.11-0007-mtd-spi-nor-Fix-S3AN-addressing-calculation.patch → target/linux/generic/backport-4.9/062-v4.11-0007-mtd-spi-nor-Fix-S3AN-addressing-calculation.patch


+ 0 - 0
target/linux/generic/patches-4.9/062-v4.11-0008-mtd-spi-nor-Add-support-for-gd25q16.patch → target/linux/generic/backport-4.9/062-v4.11-0008-mtd-spi-nor-Add-support-for-gd25q16.patch


+ 0 - 0
target/linux/generic/patches-4.9/063-mtd-spi-nor-enable-stateless-4b-op-codes-for-mx25u25.patch → target/linux/generic/backport-4.9/063-mtd-spi-nor-enable-stateless-4b-op-codes-for-mx25u25.patch


+ 0 - 0
target/linux/generic/patches-4.9/064-v4.11-0001-mtd-introduce-function-max_bad_blocks.patch → target/linux/generic/backport-4.9/064-v4.11-0001-mtd-introduce-function-max_bad_blocks.patch


+ 0 - 0
target/linux/generic/patches-4.9/064-v4.11-0002-mtd-Add-partition-device-node-to-mtd-partition-devic.patch → target/linux/generic/backport-4.9/064-v4.11-0002-mtd-Add-partition-device-node-to-mtd-partition-devic.patch


+ 0 - 0
target/linux/generic/patches-4.9/065-v4.13-0001-mtd-handle-partitioning-on-devices-with-0-erasesize.patch → target/linux/generic/backport-4.9/065-v4.13-0001-mtd-handle-partitioning-on-devices-with-0-erasesize.patch


+ 0 - 0
target/linux/generic/patches-4.9/065-v4.13-0002-mtd-partitions-factor-out-code-calling-parser.patch → target/linux/generic/backport-4.9/065-v4.13-0002-mtd-partitions-factor-out-code-calling-parser.patch


+ 0 - 0
target/linux/generic/patches-4.9/065-v4.13-0003-mtd-partitions-add-helper-for-deleting-partition.patch → target/linux/generic/backport-4.9/065-v4.13-0003-mtd-partitions-add-helper-for-deleting-partition.patch


+ 0 - 0
target/linux/generic/patches-4.9/065-v4.13-0004-mtd-partitions-remove-sysfs-files-when-deleting-all-.patch → target/linux/generic/backport-4.9/065-v4.13-0004-mtd-partitions-remove-sysfs-files-when-deleting-all-.patch


+ 0 - 0
target/linux/generic/patches-4.9/065-v4.13-0005-mtd-partitions-rename-master-to-the-parent-where-app.patch → target/linux/generic/backport-4.9/065-v4.13-0005-mtd-partitions-rename-master-to-the-parent-where-app.patch


+ 0 - 0
target/linux/generic/patches-4.9/065-v4.13-0006-mtd-partitions-add-support-for-subpartitions.patch → target/linux/generic/backport-4.9/065-v4.13-0006-mtd-partitions-add-support-for-subpartitions.patch


+ 0 - 0
target/linux/generic/patches-4.9/065-v4.13-0007-mtd-partitions-add-support-for-partition-parsers.patch → target/linux/generic/backport-4.9/065-v4.13-0007-mtd-partitions-add-support-for-partition-parsers.patch


+ 0 - 0
target/linux/generic/patches-4.9/065-v4.13-0008-mtd-extract-TRX-parser-out-of-bcm47xxpart-into-a-sep.patch → target/linux/generic/backport-4.9/065-v4.13-0008-mtd-extract-TRX-parser-out-of-bcm47xxpart-into-a-sep.patch


+ 0 - 0
target/linux/generic/patches-4.9/070-bcma-from-4.11.patch → target/linux/generic/backport-4.9/070-bcma-from-4.11.patch


+ 0 - 0
target/linux/generic/patches-4.9/071-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch → target/linux/generic/backport-4.9/071-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch


+ 0 - 0
target/linux/generic/patches-4.9/071-v4.10-0002-net-bgmac-drop-struct-bcma_mdio-we-don-t-need-anymor.patch → target/linux/generic/backport-4.9/071-v4.10-0002-net-bgmac-drop-struct-bcma_mdio-we-don-t-need-anymor.patch


+ 0 - 0
target/linux/generic/patches-4.9/071-v4.10-0003-net-bgmac-use-PHY-subsystem-for-initializing-PHY.patch → target/linux/generic/backport-4.9/071-v4.10-0003-net-bgmac-use-PHY-subsystem-for-initializing-PHY.patch


+ 0 - 0
target/linux/generic/patches-4.9/072-bcma-from-4.12.patch → target/linux/generic/backport-4.9/072-bcma-from-4.12.patch


+ 0 - 0
target/linux/generic/patches-4.9/075-v4.10-0001-net-phy-broadcom-Update-Auxiliary-Control-Register-m.patch → target/linux/generic/backport-4.9/075-v4.10-0001-net-phy-broadcom-Update-Auxiliary-Control-Register-m.patch


+ 0 - 0
target/linux/generic/patches-4.9/075-v4.10-0002-net-phy-broadcom-Add-support-for-BCM54612E.patch → target/linux/generic/backport-4.9/075-v4.10-0002-net-phy-broadcom-Add-support-for-BCM54612E.patch


+ 0 - 0
target/linux/generic/patches-4.9/075-v4.10-0003-net-phy-broadcom-add-bcm54xx_auxctl_read.patch → target/linux/generic/backport-4.9/075-v4.10-0003-net-phy-broadcom-add-bcm54xx_auxctl_read.patch


+ 0 - 0
target/linux/generic/patches-4.9/075-v4.10-0004-net-phy-broadcom-Add-BCM54810-PHY-entry.patch → target/linux/generic/backport-4.9/075-v4.10-0004-net-phy-broadcom-Add-BCM54810-PHY-entry.patch


+ 0 - 0
target/linux/generic/patches-4.9/075-v4.10-0005-net-phy-broadcom-Move-bcm54xx_auxctl_-read-write-to-.patch → target/linux/generic/backport-4.9/075-v4.10-0005-net-phy-broadcom-Move-bcm54xx_auxctl_-read-write-to-.patch


+ 0 - 0
target/linux/generic/patches-4.9/076-v4.11-0001-net-phy-broadcom-Allow-enabling-or-disabling-of-EEE.patch → target/linux/generic/backport-4.9/076-v4.11-0001-net-phy-broadcom-Allow-enabling-or-disabling-of-EEE.patch


+ 0 - 0
target/linux/generic/patches-4.9/076-v4.11-0002-net-phy-broadcom-Add-support-code-for-reading-PHY-co.patch → target/linux/generic/backport-4.9/076-v4.11-0002-net-phy-broadcom-Add-support-code-for-reading-PHY-co.patch


+ 0 - 0
target/linux/generic/patches-4.9/076-v4.11-0003-net-phy-bcm7xxx-Add-entry-for-BCM7278.patch → target/linux/generic/backport-4.9/076-v4.11-0003-net-phy-bcm7xxx-Add-entry-for-BCM7278.patch


+ 0 - 0
target/linux/generic/patches-4.9/076-v4.11-0004-net-phy-bcm7xxx-Implement-EGPHY-workaround-for-7278.patch → target/linux/generic/backport-4.9/076-v4.11-0004-net-phy-bcm7xxx-Implement-EGPHY-workaround-for-7278.patch


+ 0 - 0
target/linux/generic/patches-4.9/076-v4.11-0005-net-phy-broadcom-use-auxctl-reading-helper-in-BCM546.patch → target/linux/generic/backport-4.9/076-v4.11-0005-net-phy-broadcom-use-auxctl-reading-helper-in-BCM546.patch


+ 0 - 0
target/linux/generic/patches-4.9/076-v4.11-0006-net-phy-broadcom-add-support-for-BCM54210E.patch → target/linux/generic/backport-4.9/076-v4.11-0006-net-phy-broadcom-add-support-for-BCM54210E.patch


+ 0 - 0
target/linux/generic/patches-4.9/076-v4.11-0007-net-phy-broadcom-rehook-BCM54612E-specific-init.patch → target/linux/generic/backport-4.9/076-v4.11-0007-net-phy-broadcom-rehook-BCM54612E-specific-init.patch


+ 0 - 0
target/linux/generic/patches-4.9/080-0001-leds-core-add-OF-variants-of-LED-registering-functio.patch → target/linux/generic/backport-4.9/080-0001-leds-core-add-OF-variants-of-LED-registering-functio.patch


+ 0 - 0
target/linux/generic/patches-4.9/080-0002-leds-gpio-use-OF-variant-of-LED-registering-function.patch → target/linux/generic/backport-4.9/080-0002-leds-gpio-use-OF-variant-of-LED-registering-function.patch


+ 0 - 0
target/linux/generic/patches-4.9/081-0001-thermal-bcm2835-add-thermal-driver-for-bcm2835-SoC.patch → target/linux/generic/backport-4.9/081-0001-thermal-bcm2835-add-thermal-driver-for-bcm2835-SoC.patch


+ 0 - 0
target/linux/generic/patches-4.9/081-0002-thermal-broadcom-add-Northstar-thermal-driver.patch → target/linux/generic/backport-4.9/081-0002-thermal-broadcom-add-Northstar-thermal-driver.patch


+ 0 - 0
target/linux/generic/patches-4.9/082-0001-usb-core-read-USB-ports-from-DT-in-the-usbport-LED-t.patch → target/linux/generic/backport-4.9/082-0001-usb-core-read-USB-ports-from-DT-in-the-usbport-LED-t.patch


+ 0 - 0
target/linux/generic/patches-4.4/087-regmap-make-LZO-cache-optional.patch → target/linux/generic/backport-4.9/087-regmap-make-LZO-cache-optional.patch


+ 29 - 0
target/linux/generic/hack-4.9/202-reduce_module_size.patch

@@ -0,0 +1,29 @@
+From fd66884da2f96d2a7ea73f58b1b86251b959a913 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 16:56:19 +0200
+Subject: kernel: strip unnecessary symbol table information from kernel modules
+
+reduces default squashfs size on ar71xx by about 4k
+
+lede-commit: 058d331a39077f159ca8922f1f422a1346d6aa67
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index a40b373eba3a..984eb5907d00 100644
+--- a/Makefile
++++ b/Makefile
+@@ -407,7 +407,7 @@ KBUILD_CFLAGS_KERNEL :=
+ KBUILD_AFLAGS   := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
+ KBUILD_AFLAGS_MODULE  := -DMODULE
+ KBUILD_CFLAGS_MODULE  := -DMODULE
+-KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
++KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds $(if $(CONFIG_PROFILING),,-s)
+ 
+ # Read KERNELRELEASE from include/config/kernel.release (if it exists)
+ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
+-- 
+2.11.0
+

+ 33 - 11
target/linux/generic/patches-4.9/204-module_strip.patch → target/linux/generic/hack-4.9/204-module_strip.patch

@@ -1,8 +1,19 @@
+From a779a482fb9b9f8fcdf8b2519c789b4b9bb5dd05 Mon Sep 17 00:00:00 2001
 From: Felix Fietkau <[email protected]>
-Subject: [PATCH] build: add a hack for removing non-essential module info
+Date: Fri, 7 Jul 2017 16:56:48 +0200
+Subject: build: add a hack for removing non-essential module info
 
 Signed-off-by: Felix Fietkau <[email protected]>
 ---
+ include/linux/module.h      | 13 ++++++++-----
+ include/linux/moduleparam.h | 15 ++++++++++++---
+ init/Kconfig                |  7 +++++++
+ kernel/module.c             |  5 ++++-
+ scripts/mod/modpost.c       | 12 ++++++++++++
+ 5 files changed, 43 insertions(+), 9 deletions(-)
+
+diff --git a/include/linux/module.h b/include/linux/module.h
+index 0c3207d26ac0..08b58474bfd2 100644
 --- a/include/linux/module.h
 +++ b/include/linux/module.h
 @@ -159,6 +159,7 @@ extern void cleanup_module(void);
@@ -29,7 +40,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  /* Creates an alias so file2alias.c can find device table. */
  #define MODULE_DEVICE_TABLE(type, name)					\
  extern const typeof(name) __mod_##type##__##name##_device_table		\
-@@ -234,7 +235,9 @@ extern const typeof(name) __mod_##type##
+@@ -234,7 +235,9 @@ extern const typeof(name) __mod_##type##__##name##_device_table		\
   */
  
  #if defined(MODULE) || !defined(CONFIG_SYSFS)
@@ -40,7 +51,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  #else
  #define MODULE_VERSION(_version)					\
  	static struct module_version_attribute ___modver_attr = {	\
-@@ -256,7 +259,7 @@ extern const typeof(name) __mod_##type##
+@@ -256,7 +259,7 @@ extern const typeof(name) __mod_##type##__##name##_device_table		\
  /* Optional firmware file (or files) needed by the module
   * format is simply firmware file name.  Multiple firmware
   * files require multiple MODULE_FIRMWARE() specifiers */
@@ -49,6 +60,8 @@ Signed-off-by: Felix Fietkau <[email protected]>
  
  struct notifier_block;
  
+diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
+index 52666d90ca94..f0db3592906a 100644
 --- a/include/linux/moduleparam.h
 +++ b/include/linux/moduleparam.h
 @@ -16,6 +16,16 @@
@@ -68,7 +81,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  #ifdef MODULE
  #define __MODULE_INFO(tag, name, info)					  \
  static const char __UNIQUE_ID(name)[]					  \
-@@ -23,8 +33,7 @@ static const char __UNIQUE_ID(name)[]
+@@ -23,8 +33,7 @@ static const char __UNIQUE_ID(name)[]					  \
    = __stringify(tag) "=" info
  #else  /* !MODULE */
  /* This struct is here for syntactic coherency, it is not used */
@@ -78,7 +91,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  #endif
  #define __MODULE_PARM_TYPE(name, _type)					  \
    __MODULE_INFO(parmtype, name##type, #name ":" _type)
-@@ -32,7 +41,7 @@ static const char __UNIQUE_ID(name)[]
+@@ -32,7 +41,7 @@ static const char __UNIQUE_ID(name)[]					  \
  /* One for each parameter, describing how to use it.  Some files do
     multiple of these per line, so can't just use MODULE_INFO. */
  #define MODULE_PARM_DESC(_parm, desc) \
@@ -87,9 +100,11 @@ Signed-off-by: Felix Fietkau <[email protected]>
  
  struct kernel_param;
  
+diff --git a/init/Kconfig b/init/Kconfig
+index 34407f15e6d3..9f2c0cabbc97 100644
 --- a/init/Kconfig
 +++ b/init/Kconfig
-@@ -2106,6 +2106,13 @@ config TRIM_UNUSED_KSYMS
+@@ -2095,6 +2095,13 @@ config TRIM_UNUSED_KSYMS
  
  	  If unsure, or if you need to build out-of-tree modules, say N.
  
@@ -103,9 +118,11 @@ Signed-off-by: Felix Fietkau <[email protected]>
  endif # MODULES
  
  config MODULES_TREE_LOOKUP
+diff --git a/kernel/module.c b/kernel/module.c
+index 0e54d5bf0097..80b5ac4181c6 100644
 --- a/kernel/module.c
 +++ b/kernel/module.c
-@@ -2945,9 +2945,11 @@ static struct module *setup_load_info(st
+@@ -2945,9 +2945,11 @@ static struct module *setup_load_info(struct load_info *info, int flags)
  
  static int check_modinfo(struct module *mod, struct load_info *info, int flags)
  {
@@ -118,7 +135,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  	if (flags & MODULE_INIT_IGNORE_VERMAGIC)
  		modmagic = NULL;
  
-@@ -2968,6 +2970,7 @@ static int check_modinfo(struct module *
+@@ -2968,6 +2970,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
  				mod->name);
  		add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);
  	}
@@ -126,6 +143,8 @@ Signed-off-by: Felix Fietkau <[email protected]>
  
  	if (get_modinfo(info, "staging")) {
  		add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
+diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
+index bd8349759095..80f214adbe44 100644
 --- a/scripts/mod/modpost.c
 +++ b/scripts/mod/modpost.c
 @@ -1964,7 +1964,9 @@ static void read_symbols(char *modname)
@@ -138,7 +157,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  	}
  	if (!is_vmlinux(modname) ||
  	     (is_vmlinux(modname) && vmlinux_section_warnings))
-@@ -2108,7 +2110,9 @@ static void add_header(struct buffer *b,
+@@ -2108,7 +2110,9 @@ static void add_header(struct buffer *b, struct module *mod)
  	buf_printf(b, "#include <linux/vermagic.h>\n");
  	buf_printf(b, "#include <linux/compiler.h>\n");
  	buf_printf(b, "\n");
@@ -148,7 +167,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  	buf_printf(b, "\n");
  	buf_printf(b, "__visible struct module __this_module\n");
  	buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
-@@ -2125,16 +2129,20 @@ static void add_header(struct buffer *b,
+@@ -2125,16 +2129,20 @@ static void add_header(struct buffer *b, struct module *mod)
  
  static void add_intree_flag(struct buffer *b, int is_intree)
  {
@@ -169,7 +188,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  }
  
  /* In kernel, this size is defined in linux/module.h;
-@@ -2238,11 +2246,13 @@ static void add_depends(struct buffer *b
+@@ -2238,11 +2246,13 @@ static void add_depends(struct buffer *b, struct module *mod,
  
  static void add_srcversion(struct buffer *b, struct module *mod)
  {
@@ -193,3 +212,6 @@ Signed-off-by: Felix Fietkau <[email protected]>
  		add_srcversion(&buf, mod);
  
  		sprintf(fname, "%s.mod.c", mod->name);
+-- 
+2.11.0
+

+ 21 - 4
target/linux/generic/patches-4.9/207-disable-modorder.patch → target/linux/generic/hack-4.9/207-disable-modorder.patch

@@ -1,11 +1,23 @@
-Disable modules.order to improve build performance.
-This file is not needed for anything in LEDE
+From c9ef4ab0f54356ee9f91d9676ea0ec123840ddc7 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 16:57:33 +0200
+Subject: kernel: do not build modules.order
 
+It is not needed for anything on the system and skipping this saves some
+build time, especially in cases where there is nothing to do.
+
+lede-commit: afc1675833a7bf5df094f59f7250369520646d04
 Signed-off-by: Felix Fietkau <[email protected]>
 ---
+ Makefile               | 2 --
+ scripts/Makefile.build | 2 +-
+ 2 files changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 984eb5907d00..cce1c68e48ae 100644
 --- a/Makefile
 +++ b/Makefile
-@@ -1196,7 +1196,6 @@ all: modules
+@@ -1193,7 +1193,6 @@ all: modules
  
  PHONY += modules
  modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
@@ -13,7 +25,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
  	@$(kecho) '  Building modules, stage 2.';
  	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
  	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
-@@ -1226,7 +1225,6 @@ _modinst_:
+@@ -1223,7 +1222,6 @@ _modinst_:
  		rm -f $(MODLIB)/build ; \
  		ln -s $(CURDIR) $(MODLIB)/build ; \
  	fi
@@ -21,6 +33,8 @@ Signed-off-by: Felix Fietkau <[email protected]>
  	@cp -f $(objtree)/modules.builtin $(MODLIB)/
  	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
  
+diff --git a/scripts/Makefile.build b/scripts/Makefile.build
+index 7675d11ee65e..108d73273788 100644
 --- a/scripts/Makefile.build
 +++ b/scripts/Makefile.build
 @@ -93,7 +93,7 @@ modorder-target := $(obj)/modules.order
@@ -32,3 +46,6 @@ Signed-off-by: Felix Fietkau <[email protected]>
  	 $(subdir-ym) $(always)
  	@:
  
+-- 
+2.11.0
+

+ 56 - 29
target/linux/generic/patches-4.9/210-darwin_scripts_include.patch → target/linux/generic/hack-4.9/210-darwin_scripts_include.patch

@@ -1,6 +1,23 @@
+From db7c30dcd9a0391bf13b62c9f91e144d762ef43a Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <[email protected]>
+Date: Fri, 7 Jul 2017 17:00:49 +0200
+Subject: Add an OSX specific patch to make the kernel be compiled
+
+lede-commit: 3fc2a24f0422b2f55f9ed43f116db3111f700526
+Signed-off-by: Florian Fainelli <[email protected]>
+---
+ scripts/kconfig/Makefile   |    3 +
+ scripts/mod/elf.h          | 3007 ++++++++++++++++++++++++++++++++++++++++++++
+ scripts/mod/mk_elfconfig.c |    4 +
+ scripts/mod/modpost.h      |    4 +
+ 4 files changed, 3018 insertions(+)
+ create mode 100644 scripts/mod/elf.h
+
+diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
+index 90a091b6ae4d..f9620652e70a 100644
 --- a/scripts/kconfig/Makefile
 +++ b/scripts/kconfig/Makefile
-@@ -163,6 +163,9 @@ check-lxdialog  := $(srctree)/$(src)/lxd
+@@ -163,6 +163,9 @@ check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
  # we really need to do so. (Do not call gcc as part of make mrproper)
  HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
                      -DLOCALE
@@ -10,34 +27,9 @@
  
  # ===========================================================================
  # Shared Makefile for the various kconfig executables:
---- a/scripts/mod/mk_elfconfig.c
-+++ b/scripts/mod/mk_elfconfig.c
-@@ -1,7 +1,11 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-+#ifndef __APPLE__
- #include <elf.h>
-+#else
-+#include "elf.h"
-+#endif
- 
- int
- main(int argc, char **argv)
---- a/scripts/mod/modpost.h
-+++ b/scripts/mod/modpost.h
-@@ -7,7 +7,11 @@
- #include <sys/mman.h>
- #include <fcntl.h>
- #include <unistd.h>
-+#if !(defined(__APPLE__) || defined(__CYGWIN__))
- #include <elf.h>
-+#else
-+#include "elf.h"
-+#endif
- 
- #include "elfconfig.h"
- 
+diff --git a/scripts/mod/elf.h b/scripts/mod/elf.h
+new file mode 100644
+index 000000000000..036a176345eb
 --- /dev/null
 +++ b/scripts/mod/elf.h
 @@ -0,0 +1,3007 @@
@@ -3048,3 +3040,38 @@
 +#define R_TILEGX_NUM		130
 +
 +#endif	/* elf.h */
+diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c
+index a4fd71d71d65..5ec3740ebb3c 100644
+--- a/scripts/mod/mk_elfconfig.c
++++ b/scripts/mod/mk_elfconfig.c
+@@ -1,7 +1,11 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#ifndef __APPLE__
+ #include <elf.h>
++#else
++#include "elf.h"
++#endif
+ 
+ int
+ main(int argc, char **argv)
+diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
+index 6a5e1515123b..237c50d2ec6c 100644
+--- a/scripts/mod/modpost.h
++++ b/scripts/mod/modpost.h
+@@ -7,7 +7,11 @@
+ #include <sys/mman.h>
+ #include <fcntl.h>
+ #include <unistd.h>
++#if !(defined(__APPLE__) || defined(__CYGWIN__))
+ #include <elf.h>
++#else
++#include "elf.h"
++#endif
+ 
+ #include "elfconfig.h"
+ 
+-- 
+2.11.0
+

+ 49 - 0
target/linux/generic/hack-4.9/211-host_tools_portability.patch

@@ -0,0 +1,49 @@
+From 7f698012384ccb1ed10cc758acfd085096fdb307 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:02:03 +0200
+Subject: kernel: fix linux 4.9 host tools portability issues
+
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ tools/build/Build.include       | 2 +-
+ tools/perf/pmu-events/jevents.c | 1 +
+ tools/perf/pmu-events/json.c    | 1 -
+ 3 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tools/build/Build.include b/tools/build/Build.include
+index 1dcb95e76f70..9d6f97a7c1aa 100644
+--- a/tools/build/Build.include
++++ b/tools/build/Build.include
+@@ -95,4 +95,4 @@ cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAG
+ ###
+ ## HOSTCC C flags
+ 
+-host_c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CHOSTFLAGS) -D"BUILD_STR(s)=\#s" $(CHOSTFLAGS_$(basetarget).o) $(CHOSTFLAGS_$(obj))
++host_c_flags = -MD -MF $(depfile) -MT $@ $(CHOSTFLAGS) -D"BUILD_STR(s)=\#s" $(CHOSTFLAGS_$(basetarget).o) $(CHOSTFLAGS_$(obj))
+diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
+index 41611d7f9873..51333bee190c 100644
+--- a/tools/perf/pmu-events/jevents.c
++++ b/tools/perf/pmu-events/jevents.c
+@@ -35,6 +35,7 @@
+ #include <stdlib.h>
+ #include <errno.h>
+ #include <string.h>
++#include <strings.h>
+ #include <ctype.h>
+ #include <unistd.h>
+ #include <stdarg.h>
+diff --git a/tools/perf/pmu-events/json.c b/tools/perf/pmu-events/json.c
+index f67bbb0aa36e..a72c70a97fab 100644
+--- a/tools/perf/pmu-events/json.c
++++ b/tools/perf/pmu-events/json.c
+@@ -38,7 +38,6 @@
+ #include <unistd.h>
+ #include "jsmn.h"
+ #include "json.h"
+-#include <linux/kernel.h>
+ 
+ 
+ static char *mapfile(const char *fn, size_t *size)
+-- 
+2.11.0
+

+ 24 - 0
target/linux/generic/patches-4.9/212-byteshift_portability.patch → target/linux/generic/hack-4.9/212-byteshift_portability.patch

@@ -1,3 +1,19 @@
+From 48232d3d931c95953ce2ddfe7da7bb164aef6a73 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:03:16 +0200
+Subject: linux-3.6: fix portability of some includes files in tools/ used on the host
+
+lede-commit: 6040b1d29ab1f047c5e49b748abcb6a3196add28
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ tools/include/tools/be_byteshift.h |  4 ++++
+ tools/include/tools/le_byteshift.h |  4 ++++
+ tools/include/tools/linux_types.h  | 22 ++++++++++++++++++++++
+ 3 files changed, 30 insertions(+)
+ create mode 100644 tools/include/tools/linux_types.h
+
+diff --git a/tools/include/tools/be_byteshift.h b/tools/include/tools/be_byteshift.h
+index 84c17d836578..ed9932e97bd4 100644
 --- a/tools/include/tools/be_byteshift.h
 +++ b/tools/include/tools/be_byteshift.h
 @@ -1,6 +1,10 @@
@@ -11,6 +27,8 @@
  #include <stdint.h>
  
  static inline uint16_t __get_unaligned_be16(const uint8_t *p)
+diff --git a/tools/include/tools/le_byteshift.h b/tools/include/tools/le_byteshift.h
+index 8fe9f2488ec7..2e387b5226d9 100644
 --- a/tools/include/tools/le_byteshift.h
 +++ b/tools/include/tools/le_byteshift.h
 @@ -1,6 +1,10 @@
@@ -24,6 +42,9 @@
  #include <stdint.h>
  
  static inline uint16_t __get_unaligned_le16(const uint8_t *p)
+diff --git a/tools/include/tools/linux_types.h b/tools/include/tools/linux_types.h
+new file mode 100644
+index 000000000000..f07ef8293ebc
 --- /dev/null
 +++ b/tools/include/tools/linux_types.h
 @@ -0,0 +1,22 @@
@@ -49,3 +70,6 @@
 +typedef uint64_t __le64;
 +
 +#endif
+-- 
+2.11.0
+

+ 29 - 0
target/linux/generic/hack-4.9/214-spidev_h_portability.patch

@@ -0,0 +1,29 @@
+From be9be95ff10e16a5b4ad36f903978d0cc5747024 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:04:08 +0200
+Subject: kernel: fix linux/spi/spidev.h portability issues with musl
+
+Felix will try to get this define included into musl
+
+lede-commit: 795e7cf60de19e7a076a46874fab7bb88b43bbff
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ include/uapi/linux/spi/spidev.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/uapi/linux/spi/spidev.h b/include/uapi/linux/spi/spidev.h
+index dd5f21e75805..e5e8fea8b068 100644
+--- a/include/uapi/linux/spi/spidev.h
++++ b/include/uapi/linux/spi/spidev.h
+@@ -111,7 +111,7 @@ struct spi_ioc_transfer {
+ 
+ /* not all platforms use <asm-generic/ioctl.h> or _IOC_TYPECHECK() ... */
+ #define SPI_MSGSIZE(N) \
+-	((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << _IOC_SIZEBITS)) \
++	((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << 13)) \
+ 		? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
+ #define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)])
+ 
+-- 
+2.11.0
+

+ 188 - 162
target/linux/generic/patches-4.9/220-gc_sections.patch → target/linux/generic/hack-4.9/220-gc_sections.patch

@@ -1,6 +1,7 @@
+From e3d8676f5722b7622685581e06e8f53e6138e3ab Mon Sep 17 00:00:00 2001
 From: Felix Fietkau <[email protected]>
-
-use -ffunction-sections, -fdata-sections and --gc-sections
+Date: Sat, 15 Jul 2017 23:42:36 +0200
+Subject: use -ffunction-sections, -fdata-sections and --gc-sections
 
 In combination with kernel symbol export stripping this significantly reduces
 the kernel image size. Used on both ARM and MIPS architectures.
@@ -9,7 +10,187 @@ Signed-off-by: Felix Fietkau <[email protected]>
 Signed-off-by: Jonas Gorski <[email protected]>
 Signed-off-by: Gabor Juhos <[email protected]>
 ---
+ Makefile                          | 10 +++----
+ arch/arm/Kconfig                  |  1 +
+ arch/arm/boot/compressed/Makefile |  1 +
+ arch/arm/kernel/vmlinux.lds.S     | 26 ++++++++--------
+ arch/mips/Kconfig                 |  1 +
+ arch/mips/kernel/vmlinux.lds.S    |  4 +--
+ include/asm-generic/vmlinux.lds.h | 63 ++++++++++++++++++++-------------------
+ 7 files changed, 55 insertions(+), 51 deletions(-)
 
+diff --git a/Makefile b/Makefile
+index 42435dfa5fc3..66cdf6a59b53 100644
+--- a/Makefile
++++ b/Makefile
+@@ -410,6 +410,11 @@ KBUILD_AFLAGS_MODULE  := -DMODULE
+ KBUILD_CFLAGS_MODULE  := -DMODULE
+ KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds $(if $(CONFIG_PROFILING),,-s)
+ 
++ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
++KBUILD_CFLAGS_KERNEL	+= $(call cc-option,-ffunction-sections,)
++KBUILD_CFLAGS_KERNEL	+= $(call cc-option,-fdata-sections,)
++endif
++
+ # Read KERNELRELEASE from include/config/kernel.release (if it exists)
+ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
+ KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
+@@ -631,11 +636,6 @@ include arch/$(SRCARCH)/Makefile
+ KBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
+ KBUILD_CFLAGS	+= $(call cc-disable-warning,frame-address,)
+ 
+-ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
+-KBUILD_CFLAGS	+= $(call cc-option,-ffunction-sections,)
+-KBUILD_CFLAGS	+= $(call cc-option,-fdata-sections,)
+-endif
+-
+ ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+ KBUILD_CFLAGS	+= -Os $(call cc-disable-warning,maybe-uninitialized,) $(EXTRA_OPTIMIZATION)
+ else
+diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
+index b5d529fdffab..7f69418bf02c 100644
+--- a/arch/arm/Kconfig
++++ b/arch/arm/Kconfig
+@@ -81,6 +81,7 @@ config ARM
+ 	select HAVE_UID16
+ 	select HAVE_VIRT_CPU_ACCOUNTING_GEN
+ 	select IRQ_FORCED_THREADING
++	select LD_DEAD_CODE_DATA_ELIMINATION
+ 	select MODULES_USE_ELF_REL
+ 	select NO_BOOTMEM
+ 	select OF_EARLY_FLATTREE if OF
+diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
+index d50430c40045..6bdeb009a46d 100644
+--- a/arch/arm/boot/compressed/Makefile
++++ b/arch/arm/boot/compressed/Makefile
+@@ -102,6 +102,7 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
+ ORIG_CFLAGS := $(KBUILD_CFLAGS)
+ KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
+ endif
++KBUILD_CFLAGS_KERNEL := $(patsubst -f%-sections,,$(KBUILD_CFLAGS_KERNEL))
+ 
+ # -fstack-protector-strong triggers protection checks in this code,
+ # but it is being used too early to link to meaningful stack_chk logic.
+diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
+index f7f55df0bf7b..e9d70c92d99f 100644
+--- a/arch/arm/kernel/vmlinux.lds.S
++++ b/arch/arm/kernel/vmlinux.lds.S
+@@ -17,7 +17,7 @@
+ #define PROC_INFO							\
+ 	. = ALIGN(4);							\
+ 	VMLINUX_SYMBOL(__proc_info_begin) = .;				\
+-	*(.proc.info.init)						\
++	KEEP(*(.proc.info.init))					\
+ 	VMLINUX_SYMBOL(__proc_info_end) = .;
+ 
+ #define HYPERVISOR_TEXT							\
+@@ -28,11 +28,11 @@
+ #define IDMAP_TEXT							\
+ 	ALIGN_FUNCTION();						\
+ 	VMLINUX_SYMBOL(__idmap_text_start) = .;				\
+-	*(.idmap.text)							\
++	KEEP(*(.idmap.text))						\
+ 	VMLINUX_SYMBOL(__idmap_text_end) = .;				\
+ 	. = ALIGN(PAGE_SIZE);						\
+ 	VMLINUX_SYMBOL(__hyp_idmap_text_start) = .;			\
+-	*(.hyp.idmap.text)						\
++	KEEP(*(.hyp.idmap.text))					\
+ 	VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
+ 
+ #ifdef CONFIG_HOTPLUG_CPU
+@@ -105,7 +105,7 @@ SECTIONS
+ 		_stext = .;		/* Text and read-only data	*/
+ 			IDMAP_TEXT
+ 			__exception_text_start = .;
+-			*(.exception.text)
++			KEEP(*(.exception.text))
+ 			__exception_text_end = .;
+ 			IRQENTRY_TEXT
+ 			SOFTIRQENTRY_TEXT
+@@ -134,7 +134,7 @@ SECTIONS
+ 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
+ 		__start___ex_table = .;
+ #ifdef CONFIG_MMU
+-		*(__ex_table)
++		KEEP(*(__ex_table))
+ #endif
+ 		__stop___ex_table = .;
+ 	}
+@@ -146,12 +146,12 @@ SECTIONS
+ 	. = ALIGN(8);
+ 	.ARM.unwind_idx : {
+ 		__start_unwind_idx = .;
+-		*(.ARM.exidx*)
++		KEEP(*(.ARM.exidx*))
+ 		__stop_unwind_idx = .;
+ 	}
+ 	.ARM.unwind_tab : {
+ 		__start_unwind_tab = .;
+-		*(.ARM.extab*)
++		KEEP(*(.ARM.extab*))
+ 		__stop_unwind_tab = .;
+ 	}
+ #endif
+@@ -171,14 +171,14 @@ SECTIONS
+ 	 */
+ 	__vectors_start = .;
+ 	.vectors 0xffff0000 : AT(__vectors_start) {
+-		*(.vectors)
++		KEEP(*(.vectors))
+ 	}
+ 	. = __vectors_start + SIZEOF(.vectors);
+ 	__vectors_end = .;
+ 
+ 	__stubs_start = .;
+ 	.stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
+-		*(.stubs)
++		KEEP(*(.stubs))
+ 	}
+ 	. = __stubs_start + SIZEOF(.stubs);
+ 	__stubs_end = .;
+@@ -194,24 +194,24 @@ SECTIONS
+ 	}
+ 	.init.arch.info : {
+ 		__arch_info_begin = .;
+-		*(.arch.info.init)
++		KEEP(*(.arch.info.init))
+ 		__arch_info_end = .;
+ 	}
+ 	.init.tagtable : {
+ 		__tagtable_begin = .;
+-		*(.taglist.init)
++		KEEP(*(.taglist.init))
+ 		__tagtable_end = .;
+ 	}
+ #ifdef CONFIG_SMP_ON_UP
+ 	.init.smpalt : {
+ 		__smpalt_begin = .;
+-		*(.alt.smp.init)
++		KEEP(*(.alt.smp.init))
+ 		__smpalt_end = .;
+ 	}
+ #endif
+ 	.init.pv_table : {
+ 		__pv_table_begin = .;
+-		*(.pv_table)
++		KEEP(*(.pv_table))
+ 		__pv_table_end = .;
+ 	}
+ 	.init.data : {
+diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
+index 3a97487b8b81..05e7bfeab2f9 100644
+--- a/arch/mips/Kconfig
++++ b/arch/mips/Kconfig
+@@ -55,6 +55,7 @@ config MIPS
+ 	select CLONE_BACKWARDS
+ 	select HAVE_DEBUG_STACKOVERFLOW
+ 	select HAVE_CC_STACKPROTECTOR
++	select LD_DEAD_CODE_DATA_ELIMINATION
+ 	select CPU_PM if CPU_IDLE
+ 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+ 	select ARCH_BINFMT_ELF_STATE
+diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
+index d5de67591735..de5f682b5597 100644
 --- a/arch/mips/kernel/vmlinux.lds.S
 +++ b/arch/mips/kernel/vmlinux.lds.S
 @@ -71,7 +71,7 @@ SECTIONS
@@ -30,6 +211,8 @@ Signed-off-by: Gabor Juhos <[email protected]>
  		__mips_machines_end = .;
  	}
  
+diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
+index 31e1d639abed..83784d9492b1 100644
 --- a/include/asm-generic/vmlinux.lds.h
 +++ b/include/asm-generic/vmlinux.lds.h
 @@ -114,7 +114,7 @@
@@ -250,163 +433,6 @@ Signed-off-by: Gabor Juhos <[email protected]>
  		VMLINUX_SYMBOL(__setup_end) = .;
  
  #define INIT_CALLS_LEVEL(level)						\
---- a/arch/arm/kernel/vmlinux.lds.S
-+++ b/arch/arm/kernel/vmlinux.lds.S
-@@ -17,7 +17,7 @@
- #define PROC_INFO							\
- 	. = ALIGN(4);							\
- 	VMLINUX_SYMBOL(__proc_info_begin) = .;				\
--	*(.proc.info.init)						\
-+	KEEP(*(.proc.info.init))					\
- 	VMLINUX_SYMBOL(__proc_info_end) = .;
- 
- #define HYPERVISOR_TEXT							\
-@@ -28,11 +28,11 @@
- #define IDMAP_TEXT							\
- 	ALIGN_FUNCTION();						\
- 	VMLINUX_SYMBOL(__idmap_text_start) = .;				\
--	*(.idmap.text)							\
-+	KEEP(*(.idmap.text))						\
- 	VMLINUX_SYMBOL(__idmap_text_end) = .;				\
- 	. = ALIGN(PAGE_SIZE);						\
- 	VMLINUX_SYMBOL(__hyp_idmap_text_start) = .;			\
--	*(.hyp.idmap.text)						\
-+	KEEP(*(.hyp.idmap.text))					\
- 	VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
- 
- #ifdef CONFIG_HOTPLUG_CPU
-@@ -105,7 +105,7 @@ SECTIONS
- 		_stext = .;		/* Text and read-only data	*/
- 			IDMAP_TEXT
- 			__exception_text_start = .;
--			*(.exception.text)
-+			KEEP(*(.exception.text))
- 			__exception_text_end = .;
- 			IRQENTRY_TEXT
- 			SOFTIRQENTRY_TEXT
-@@ -134,7 +134,7 @@ SECTIONS
- 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
- 		__start___ex_table = .;
- #ifdef CONFIG_MMU
--		*(__ex_table)
-+		KEEP(*(__ex_table))
- #endif
- 		__stop___ex_table = .;
- 	}
-@@ -146,12 +146,12 @@ SECTIONS
- 	. = ALIGN(8);
- 	.ARM.unwind_idx : {
- 		__start_unwind_idx = .;
--		*(.ARM.exidx*)
-+		KEEP(*(.ARM.exidx*))
- 		__stop_unwind_idx = .;
- 	}
- 	.ARM.unwind_tab : {
- 		__start_unwind_tab = .;
--		*(.ARM.extab*)
-+		KEEP(*(.ARM.extab*))
- 		__stop_unwind_tab = .;
- 	}
- #endif
-@@ -171,14 +171,14 @@ SECTIONS
- 	 */
- 	__vectors_start = .;
- 	.vectors 0xffff0000 : AT(__vectors_start) {
--		*(.vectors)
-+		KEEP(*(.vectors))
- 	}
- 	. = __vectors_start + SIZEOF(.vectors);
- 	__vectors_end = .;
- 
- 	__stubs_start = .;
- 	.stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
--		*(.stubs)
-+		KEEP(*(.stubs))
- 	}
- 	. = __stubs_start + SIZEOF(.stubs);
- 	__stubs_end = .;
-@@ -194,24 +194,24 @@ SECTIONS
- 	}
- 	.init.arch.info : {
- 		__arch_info_begin = .;
--		*(.arch.info.init)
-+		KEEP(*(.arch.info.init))
- 		__arch_info_end = .;
- 	}
- 	.init.tagtable : {
- 		__tagtable_begin = .;
--		*(.taglist.init)
-+		KEEP(*(.taglist.init))
- 		__tagtable_end = .;
- 	}
- #ifdef CONFIG_SMP_ON_UP
- 	.init.smpalt : {
- 		__smpalt_begin = .;
--		*(.alt.smp.init)
-+		KEEP(*(.alt.smp.init))
- 		__smpalt_end = .;
- 	}
- #endif
- 	.init.pv_table : {
- 		__pv_table_begin = .;
--		*(.pv_table)
-+		KEEP(*(.pv_table))
- 		__pv_table_end = .;
- 	}
- 	.init.data : {
---- a/arch/arm/boot/compressed/Makefile
-+++ b/arch/arm/boot/compressed/Makefile
-@@ -102,6 +102,7 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
- ORIG_CFLAGS := $(KBUILD_CFLAGS)
- KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
- endif
-+KBUILD_CFLAGS_KERNEL := $(patsubst -f%-sections,,$(KBUILD_CFLAGS_KERNEL))
- 
- # -fstack-protector-strong triggers protection checks in this code,
- # but it is being used too early to link to meaningful stack_chk logic.
---- a/arch/arm/Kconfig
-+++ b/arch/arm/Kconfig
-@@ -81,6 +81,7 @@ config ARM
- 	select HAVE_UID16
- 	select HAVE_VIRT_CPU_ACCOUNTING_GEN
- 	select IRQ_FORCED_THREADING
-+	select LD_DEAD_CODE_DATA_ELIMINATION
- 	select MODULES_USE_ELF_REL
- 	select NO_BOOTMEM
- 	select OF_EARLY_FLATTREE if OF
---- a/arch/mips/Kconfig
-+++ b/arch/mips/Kconfig
-@@ -55,6 +55,7 @@ config MIPS
- 	select CLONE_BACKWARDS
- 	select HAVE_DEBUG_STACKOVERFLOW
- 	select HAVE_CC_STACKPROTECTOR
-+	select LD_DEAD_CODE_DATA_ELIMINATION
- 	select CPU_PM if CPU_IDLE
- 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
- 	select ARCH_BINFMT_ELF_STATE
---- a/Makefile
-+++ b/Makefile
-@@ -409,6 +409,11 @@ KBUILD_AFLAGS_MODULE  := -DMODULE
- KBUILD_CFLAGS_MODULE  := -DMODULE
- KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds $(if $(CONFIG_PROFILING),,-s)
- 
-+ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
-+KBUILD_CFLAGS_KERNEL	+= $(call cc-option,-ffunction-sections,)
-+KBUILD_CFLAGS_KERNEL	+= $(call cc-option,-fdata-sections,)
-+endif
-+
- # Read KERNELRELEASE from include/config/kernel.release (if it exists)
- KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
- KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
-@@ -633,11 +638,6 @@ KBUILD_CFLAGS	+= $(call cc-disable-warni
- KBUILD_CFLAGS	+= $(call cc-disable-warning, format-overflow)
- KBUILD_CFLAGS	+= $(call cc-disable-warning, int-in-bool-context)
- 
--ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
--KBUILD_CFLAGS	+= $(call cc-option,-ffunction-sections,)
--KBUILD_CFLAGS	+= $(call cc-option,-fdata-sections,)
--endif
--
- ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
- KBUILD_CFLAGS	+= -Os $(call cc-disable-warning,maybe-uninitialized,) $(EXTRA_OPTIMIZATION)
- else
+-- 
+2.11.0
+

+ 33 - 11
target/linux/generic/patches-4.9/221-module_exports.patch → target/linux/generic/hack-4.9/221-module_exports.patch

@@ -1,3 +1,18 @@
+From b14784e7883390c20ed3ff904892255404a5914b Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:05:53 +0200
+Subject: add an optional config option for stripping all unnecessary symbol exports from the kernel image
+
+lede-commit: bb5a40c64b7c4f4848509fa0a6625055fc9e66cc
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ include/asm-generic/vmlinux.lds.h | 18 +++++++++++++++---
+ include/linux/export.h            |  9 ++++++++-
+ scripts/Makefile.build            |  2 +-
+ 3 files changed, 24 insertions(+), 5 deletions(-)
+
+diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
+index 83784d9492b1..189b5c7a0758 100644
 --- a/include/asm-generic/vmlinux.lds.h
 +++ b/include/asm-generic/vmlinux.lds.h
 @@ -54,6 +54,16 @@
@@ -52,17 +67,8 @@
  	*(.discard)							\
  	*(.discard.*)							\
  	}
---- a/scripts/Makefile.build
-+++ b/scripts/Makefile.build
-@@ -398,7 +398,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(
- # Linker scripts preprocessor (.lds.S -> .lds)
- # ---------------------------------------------------------------------------
- quiet_cmd_cpp_lds_S = LDS     $@
--      cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
-+      cmd_cpp_lds_S = $(CPP) $(EXTRA_LDSFLAGS) $(cpp_flags) -P -C -U$(ARCH) \
- 	                     -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
- 
- $(obj)/%.lds: $(src)/%.lds.S FORCE
+diff --git a/include/linux/export.h b/include/linux/export.h
+index 2a0f61fbc731..889331d9643d 100644
 --- a/include/linux/export.h
 +++ b/include/linux/export.h
 @@ -53,12 +53,19 @@ extern struct module __this_module;
@@ -86,3 +92,19 @@
  	= VMLINUX_SYMBOL_STR(sym);					\
  	static const struct kernel_symbol __ksymtab_##sym		\
  	__used								\
+diff --git a/scripts/Makefile.build b/scripts/Makefile.build
+index 108d73273788..76a0e450123c 100644
+--- a/scripts/Makefile.build
++++ b/scripts/Makefile.build
+@@ -398,7 +398,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(always)
+ # Linker scripts preprocessor (.lds.S -> .lds)
+ # ---------------------------------------------------------------------------
+ quiet_cmd_cpp_lds_S = LDS     $@
+-      cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
++      cmd_cpp_lds_S = $(CPP) $(EXTRA_LDSFLAGS) $(cpp_flags) -P -C -U$(ARCH) \
+ 	                     -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
+ 
+ $(obj)/%.lds: $(src)/%.lds.S FORCE
+-- 
+2.11.0
+

+ 33 - 11
target/linux/generic/patches-4.9/230-openwrt_lzma_options.patch → target/linux/generic/hack-4.9/230-openwrt_lzma_options.patch

@@ -1,6 +1,33 @@
+From b3d00b452467f621317953d9e4c6f9ae8dcfd271 Mon Sep 17 00:00:00 2001
+From: Imre Kaloz <[email protected]>
+Date: Fri, 7 Jul 2017 17:06:55 +0200
+Subject: use the openwrt lzma options for now
+
+lede-commit: 548de949f392049420a6a1feeef118b30ab8ea8c
+Signed-off-by: Imre Kaloz <[email protected]>
+---
+ lib/decompress.c              |  1 +
+ scripts/Makefile.lib          |  2 +-
+ scripts/gen_initramfs_list.sh | 10 +++++-----
+ 3 files changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/lib/decompress.c b/lib/decompress.c
+index 62696dff5730..d91a26e1a1b2 100644
+--- a/lib/decompress.c
++++ b/lib/decompress.c
+@@ -48,6 +48,7 @@ static const struct compress_format compressed_formats[] __initconst = {
+ 	{ {0x1f, 0x9e}, "gzip", gunzip },
+ 	{ {0x42, 0x5a}, "bzip2", bunzip2 },
+ 	{ {0x5d, 0x00}, "lzma", unlzma },
++	{ {0x6d, 0x00}, "lzma-openwrt", unlzma },
+ 	{ {0xfd, 0x37}, "xz", unxz },
+ 	{ {0x89, 0x4c}, "lzo", unlzo },
+ 	{ {0x02, 0x21}, "lz4", unlz4 },
+diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
+index 0a07f9014944..5324c072c598 100644
 --- a/scripts/Makefile.lib
 +++ b/scripts/Makefile.lib
-@@ -344,7 +344,7 @@ cmd_bzip2 = (cat $(filter-out FORCE,$^)
+@@ -344,7 +344,7 @@ cmd_bzip2 = (cat $(filter-out FORCE,$^) | \
  
  quiet_cmd_lzma = LZMA    $@
  cmd_lzma = (cat $(filter-out FORCE,$^) | \
@@ -9,6 +36,8 @@
  	(rm -f $@ ; false)
  
  quiet_cmd_lzo = LZO     $@
+diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
+index 0055b07b03b6..7710113e6a72 100755
 --- a/scripts/gen_initramfs_list.sh
 +++ b/scripts/gen_initramfs_list.sh
 @@ -229,7 +229,7 @@ cpio_list=
@@ -46,13 +75,6 @@
  		|| (rm -f ${output_file} ; false)
  	fi
  	[ -z ${cpio_file} ] && rm ${cpio_tfile}
---- a/lib/decompress.c
-+++ b/lib/decompress.c
-@@ -48,6 +48,7 @@ static const struct compress_format comp
- 	{ {0x1f, 0x9e}, "gzip", gunzip },
- 	{ {0x42, 0x5a}, "bzip2", bunzip2 },
- 	{ {0x5d, 0x00}, "lzma", unlzma },
-+	{ {0x6d, 0x00}, "lzma-openwrt", unlzma },
- 	{ {0xfd, 0x37}, "xz", unxz },
- 	{ {0x89, 0x4c}, "lzo", unlzo },
- 	{ {0x02, 0x21}, "lz4", unlz4 },
+-- 
+2.11.0
+

+ 14 - 0
target/linux/generic/patches-4.9/250-netfilter_depends.patch → target/linux/generic/hack-4.9/250-netfilter_depends.patch

@@ -1,3 +1,14 @@
+From: Felix Fietkau <[email protected]>
+Subject: hack: net: remove bogus netfilter dependencies
+
+lede-commit: 589d2a377dee27d206fc3725325309cf649e4df6
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ net/netfilter/Kconfig | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
+index 82af5ba64088..65fe84db77ec 100644
 --- a/net/netfilter/Kconfig
 +++ b/net/netfilter/Kconfig
 @@ -218,7 +218,6 @@ config NF_CONNTRACK_FTP
@@ -16,3 +27,6 @@
  	default m if NETFILTER_ADVANCED=n
  	---help---
  	  This option adds a `TCPMSS' target, which allows you to alter the
+-- 
+2.11.0
+

+ 212 - 0
target/linux/generic/hack-4.9/251-sound_kconfig.patch

@@ -0,0 +1,212 @@
+From da3c50704f14132f4adf80d48e9a4cd5d46e54c9 Mon Sep 17 00:00:00 2001
+From: John Crispin <[email protected]>
+Date: Fri, 7 Jul 2017 17:09:21 +0200
+Subject: kconfig: owrt specifc dependencies
+
+Signed-off-by: John Crispin <[email protected]>
+---
+ crypto/Kconfig        | 10 +++++-----
+ drivers/bcma/Kconfig  |  1 +
+ drivers/ssb/Kconfig   |  3 ++-
+ lib/Kconfig           |  8 ++++----
+ net/netfilter/Kconfig |  2 +-
+ net/wireless/Kconfig  | 17 ++++++++++-------
+ sound/core/Kconfig    |  4 ++--
+ 7 files changed, 25 insertions(+), 20 deletions(-)
+
+diff --git a/crypto/Kconfig b/crypto/Kconfig
+index 84d71482bf08..e3552d1c1b84 100644
+--- a/crypto/Kconfig
++++ b/crypto/Kconfig
+@@ -32,7 +32,7 @@ config CRYPTO_FIPS
+ 	  this is.
+ 
+ config CRYPTO_ALGAPI
+-	tristate
++	tristate "ALGAPI"
+ 	select CRYPTO_ALGAPI2
+ 	help
+ 	  This option provides the API for cryptographic algorithms.
+@@ -41,7 +41,7 @@ config CRYPTO_ALGAPI2
+ 	tristate
+ 
+ config CRYPTO_AEAD
+-	tristate
++	tristate "AEAD"
+ 	select CRYPTO_AEAD2
+ 	select CRYPTO_ALGAPI
+ 
+@@ -52,7 +52,7 @@ config CRYPTO_AEAD2
+ 	select CRYPTO_RNG2
+ 
+ config CRYPTO_BLKCIPHER
+-	tristate
++	tristate "BLKCIPHER"
+ 	select CRYPTO_BLKCIPHER2
+ 	select CRYPTO_ALGAPI
+ 
+@@ -63,7 +63,7 @@ config CRYPTO_BLKCIPHER2
+ 	select CRYPTO_WORKQUEUE
+ 
+ config CRYPTO_HASH
+-	tristate
++	tristate "HASH"
+ 	select CRYPTO_HASH2
+ 	select CRYPTO_ALGAPI
+ 
+@@ -72,7 +72,7 @@ config CRYPTO_HASH2
+ 	select CRYPTO_ALGAPI2
+ 
+ config CRYPTO_RNG
+-	tristate
++	tristate "RNG"
+ 	select CRYPTO_RNG2
+ 	select CRYPTO_ALGAPI
+ 
+diff --git a/drivers/bcma/Kconfig b/drivers/bcma/Kconfig
+index b5c48a8d485f..6cb52081b9ef 100644
+--- a/drivers/bcma/Kconfig
++++ b/drivers/bcma/Kconfig
+@@ -17,6 +17,7 @@ config BCMA
+ config BCMA_BLOCKIO
+ 	bool
+ 	depends on BCMA
++	default y
+ 
+ config BCMA_HOST_PCI_POSSIBLE
+ 	bool
+diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig
+index d8e4219c2324..a20c168cb7c2 100644
+--- a/drivers/ssb/Kconfig
++++ b/drivers/ssb/Kconfig
+@@ -29,6 +29,7 @@ config SSB_SPROM
+ config SSB_BLOCKIO
+ 	bool
+ 	depends on SSB
++	default y
+ 
+ config SSB_PCIHOST_POSSIBLE
+ 	bool
+@@ -49,7 +50,7 @@ config SSB_PCIHOST
+ config SSB_B43_PCI_BRIDGE
+ 	bool
+ 	depends on SSB_PCIHOST
+-	default n
++	default y
+ 
+ config SSB_PCMCIAHOST_POSSIBLE
+ 	bool
+diff --git a/lib/Kconfig b/lib/Kconfig
+index 260a80e313b9..d1b788fff727 100644
+--- a/lib/Kconfig
++++ b/lib/Kconfig
+@@ -334,16 +334,16 @@ config BCH_CONST_T
+ # Textsearch support is select'ed if needed
+ #
+ config TEXTSEARCH
+-	bool
++	boolean	"Textsearch support"
+ 
+ config TEXTSEARCH_KMP
+-	tristate
++	tristate "Textsearch KMP"
+ 
+ config TEXTSEARCH_BM
+-	tristate
++	tristate "Textsearch BM"
+ 
+ config TEXTSEARCH_FSM
+-	tristate
++	tristate "Textsearch FSM"
+ 
+ config BTREE
+ 	bool
+diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
+index e8d56d9a4df2..0fb924661988 100644
+--- a/net/netfilter/Kconfig
++++ b/net/netfilter/Kconfig
+@@ -10,7 +10,7 @@ config NETFILTER_INGRESS
+ 	  infrastructure.
+ 
+ config NETFILTER_NETLINK
+-	tristate
++	tristate "Netfilter NFNETLINK interface"
+ 
+ config NETFILTER_NETLINK_ACCT
+ tristate "Netfilter NFACCT over NFNETLINK interface"
+diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig
+index 6c606120abfe..bd299de9440c 100644
+--- a/net/wireless/Kconfig
++++ b/net/wireless/Kconfig
+@@ -1,5 +1,5 @@
+ config WIRELESS_EXT
+-	bool
++	bool "Wireless extensions"
+ 
+ config WEXT_CORE
+ 	def_bool y
+@@ -11,10 +11,10 @@ config WEXT_PROC
+ 	depends on WEXT_CORE
+ 
+ config WEXT_SPY
+-	bool
++	bool "WEXT_SPY"
+ 
+ config WEXT_PRIV
+-	bool
++	bool "WEXT_PRIV"
+ 
+ config CFG80211
+ 	tristate "cfg80211 - wireless configuration API"
+@@ -188,7 +188,7 @@ config CFG80211_WEXT_EXPORT
+ 	  wext compatibility symbols to be exported.
+ 
+ config LIB80211
+-	tristate
++	tristate "LIB80211"
+ 	default n
+ 	help
+ 	  This options enables a library of common routines used
+@@ -197,13 +197,16 @@ config LIB80211
+ 	  Drivers should select this themselves if needed.
+ 
+ config LIB80211_CRYPT_WEP
+-	tristate
++	tristate "LIB80211_CRYPT_WEP"
++	select LIB80211
+ 
+ config LIB80211_CRYPT_CCMP
+-	tristate
++	tristate "LIB80211_CRYPT_CCMP"
++	select LIB80211
+ 
+ config LIB80211_CRYPT_TKIP
+-	tristate
++	tristate "LIB80211_CRYPT_TKIP"
++	select LIB80211
+ 
+ config LIB80211_DEBUG
+ 	bool "lib80211 debugging messages"
+diff --git a/sound/core/Kconfig b/sound/core/Kconfig
+index 9749f9e8b45c..9639a67e7e9b 100644
+--- a/sound/core/Kconfig
++++ b/sound/core/Kconfig
+@@ -16,13 +16,13 @@ config SND_DMAENGINE_PCM
+ 	tristate
+ 
+ config SND_HWDEP
+-	tristate
++	tristate "Sound hardware support"
+ 
+ config SND_RAWMIDI
+ 	tristate
+ 
+ config SND_COMPRESS_OFFLOAD
+-	tristate
++	tristate "Compression offloading support"
+ 
+ config SND_JACK
+ 	bool
+-- 
+2.11.0
+

+ 36 - 11
target/linux/generic/patches-4.9/259-regmap_dynamic.patch → target/linux/generic/hack-4.9/259-regmap_dynamic.patch

@@ -1,3 +1,19 @@
+From 811d9e2268a62b830cfe93cd8bc929afcb8b198b Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Sat, 15 Jul 2017 21:12:38 +0200
+Subject: kernel: move regmap bloat out of the kernel image if it is only being used in modules
+
+lede-commit: 96f39119815028073583e4fca3a9c5fe9141e998
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ drivers/base/regmap/Kconfig  | 15 ++++++++++-----
+ drivers/base/regmap/Makefile | 12 ++++++++----
+ drivers/base/regmap/regmap.c |  3 +++
+ include/linux/regmap.h       |  2 +-
+ 4 files changed, 22 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig
+index 48b3fc1ee514..c4cb7592392b 100644
 --- a/drivers/base/regmap/Kconfig
 +++ b/drivers/base/regmap/Kconfig
 @@ -3,9 +3,8 @@
@@ -40,17 +56,8 @@
  config REGMAP_IRQ
 +	select REGMAP
  	bool
---- a/include/linux/regmap.h
-+++ b/include/linux/regmap.h
-@@ -135,7 +135,7 @@ struct reg_sequence {
- 	pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
- })
- 
--#ifdef CONFIG_REGMAP
-+#if IS_ENABLED(CONFIG_REGMAP)
- 
- enum regmap_endian {
- 	/* Unspecified -> 0 -> Backwards compatible default */
+diff --git a/drivers/base/regmap/Makefile b/drivers/base/regmap/Makefile
+index 6271ea9b758a..f23c58a050aa 100644
 --- a/drivers/base/regmap/Makefile
 +++ b/drivers/base/regmap/Makefile
 @@ -1,10 +1,14 @@
@@ -72,6 +79,8 @@
  obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o
  obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
  obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o
+diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
+index ae63bb0875ea..2ac56b4f525e 100644
 --- a/drivers/base/regmap/regmap.c
 +++ b/drivers/base/regmap/regmap.c
 @@ -13,6 +13,7 @@
@@ -88,3 +97,19 @@
  postcore_initcall(regmap_initcall);
 +
 +MODULE_LICENSE("GPL");
+diff --git a/include/linux/regmap.h b/include/linux/regmap.h
+index f6673132431d..95c7db29448b 100644
+--- a/include/linux/regmap.h
++++ b/include/linux/regmap.h
+@@ -135,7 +135,7 @@ struct reg_sequence {
+ 	pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
+ })
+ 
+-#ifdef CONFIG_REGMAP
++#if IS_ENABLED(CONFIG_REGMAP)
+ 
+ enum regmap_endian {
+ 	/* Unspecified -> 0 -> Backwards compatible default */
+-- 
+2.11.0
+

+ 22 - 1
target/linux/generic/patches-4.9/260-crypto_test_dependencies.patch → target/linux/generic/hack-4.9/260-crypto_test_dependencies.patch

@@ -1,3 +1,19 @@
+From fd1799b0bf5efa46dd3e6dfbbf3955564807e508 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:12:51 +0200
+Subject: kernel: prevent cryptomgr from pulling in useless extra dependencies for tests that are not run
+
+Reduces kernel size after LZMA by about 5k on MIPS
+
+lede-commit: 044c316167e076479a344c59905e5b435b84a77f
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ crypto/Kconfig   | 13 ++++++-------
+ crypto/algboss.c |  4 ++++
+ 2 files changed, 10 insertions(+), 7 deletions(-)
+
+diff --git a/crypto/Kconfig b/crypto/Kconfig
+index e3552d1c1b84..17be110ad162 100644
 --- a/crypto/Kconfig
 +++ b/crypto/Kconfig
 @@ -132,12 +132,12 @@ config CRYPTO_MANAGER
@@ -27,9 +43,11 @@
  	help
  	  Disable run-time self tests that normally take place at
  	  algorithm registration.
+diff --git a/crypto/algboss.c b/crypto/algboss.c
+index 6e39d9c05b98..4bde25d62ec7 100644
 --- a/crypto/algboss.c
 +++ b/crypto/algboss.c
-@@ -248,12 +248,16 @@ static int cryptomgr_schedule_test(struc
+@@ -248,12 +248,16 @@ static int cryptomgr_schedule_test(struct crypto_alg *alg)
  	type = alg->cra_flags;
  
  	/* This piece of crap needs to disappear into per-type test hooks. */
@@ -46,3 +64,6 @@
  
  	param->type = type;
  
+-- 
+2.11.0
+

+ 48 - 22
target/linux/generic/patches-4.9/280-rfkill-stubs.patch → target/linux/generic/hack-4.9/280-rfkill-stubs.patch

@@ -1,3 +1,46 @@
+From 236c1acdfef5958010ac9814a9872e0a46fd78ee Mon Sep 17 00:00:00 2001
+From: John Crispin <[email protected]>
+Date: Fri, 7 Jul 2017 17:13:44 +0200
+Subject: rfkill: add fake rfkill support
+
+allow building of modules depending on RFKILL even if RFKILL is not enabled.
+
+Signed-off-by: John Crispin <[email protected]>
+---
+ include/linux/rfkill.h |  2 +-
+ net/Makefile           |  2 +-
+ net/rfkill/Kconfig     | 14 +++++++++-----
+ net/rfkill/Makefile    |  2 +-
+ 4 files changed, 12 insertions(+), 8 deletions(-)
+
+diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
+index e6a0031d1b1f..21cf4dab0b9a 100644
+--- a/include/linux/rfkill.h
++++ b/include/linux/rfkill.h
+@@ -64,7 +64,7 @@ struct rfkill_ops {
+ 	int	(*set_block)(void *data, bool blocked);
+ };
+ 
+-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
++#if defined(CONFIG_RFKILL_FULL) || defined(CONFIG_RFKILL_FULL_MODULE)
+ /**
+  * rfkill_alloc - allocate rfkill structure
+  * @name: name of the struct -- the string is not copied internally
+diff --git a/net/Makefile b/net/Makefile
+index 4cafaa2b4667..6566175e6c0a 100644
+--- a/net/Makefile
++++ b/net/Makefile
+@@ -51,7 +51,7 @@ obj-$(CONFIG_MAC80211)		+= mac80211/
+ obj-$(CONFIG_TIPC)		+= tipc/
+ obj-$(CONFIG_NETLABEL)		+= netlabel/
+ obj-$(CONFIG_IUCV)		+= iucv/
+-obj-$(CONFIG_RFKILL)		+= rfkill/
++obj-$(CONFIG_RFKILL_FULL)	+= rfkill/
+ obj-$(CONFIG_NET_9P)		+= 9p/
+ obj-$(CONFIG_CAIF)		+= caif/
+ ifneq ($(CONFIG_DCB),)
+diff --git a/net/rfkill/Kconfig b/net/rfkill/Kconfig
+index 868f1ad0415a..159b6ebeacd8 100644
 --- a/net/rfkill/Kconfig
 +++ b/net/rfkill/Kconfig
 @@ -1,7 +1,11 @@
@@ -45,6 +88,8 @@
  	depends on GPIOLIB || COMPILE_TEST
  	default n
  	help
+diff --git a/net/rfkill/Makefile b/net/rfkill/Makefile
+index 311768783f4a..dbb01a8645af 100644
 --- a/net/rfkill/Makefile
 +++ b/net/rfkill/Makefile
 @@ -4,6 +4,6 @@
@@ -55,25 +100,6 @@
 +obj-$(CONFIG_RFKILL_FULL)	+= rfkill.o
  obj-$(CONFIG_RFKILL_REGULATOR)	+= rfkill-regulator.o
  obj-$(CONFIG_RFKILL_GPIO)	+= rfkill-gpio.o
---- a/net/Makefile
-+++ b/net/Makefile
-@@ -51,7 +51,7 @@ obj-$(CONFIG_MAC80211)		+= mac80211/
- obj-$(CONFIG_TIPC)		+= tipc/
- obj-$(CONFIG_NETLABEL)		+= netlabel/
- obj-$(CONFIG_IUCV)		+= iucv/
--obj-$(CONFIG_RFKILL)		+= rfkill/
-+obj-$(CONFIG_RFKILL_FULL)	+= rfkill/
- obj-$(CONFIG_NET_9P)		+= 9p/
- obj-$(CONFIG_CAIF)		+= caif/
- ifneq ($(CONFIG_DCB),)
---- a/include/linux/rfkill.h
-+++ b/include/linux/rfkill.h
-@@ -64,7 +64,7 @@ struct rfkill_ops {
- 	int	(*set_block)(void *data, bool blocked);
- };
- 
--#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
-+#if defined(CONFIG_RFKILL_FULL) || defined(CONFIG_RFKILL_FULL_MODULE)
- /**
-  * rfkill_alloc - allocate rfkill structure
-  * @name: name of the struct -- the string is not copied internally
+-- 
+2.11.0
+

+ 45 - 0
target/linux/generic/hack-4.9/301-mips_image_cmdline_hack.patch

@@ -0,0 +1,45 @@
+From: John Crispin <[email protected]>
+Subject: hack: kernel: add generic image_cmdline hack to MIPS targets
+
+lede-commit: d59f5b3a987a48508257a0ddbaeadc7909f9f976
+Signed-off-by: Gabor Juhos <[email protected]>
+---
+ arch/mips/Kconfig       | 4 ++++
+ arch/mips/kernel/head.S | 6 ++++++
+ 2 files changed, 10 insertions(+)
+
+diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
+index 6a56d75f7e8b..03fbb7b46e7f 100644
+--- a/arch/mips/Kconfig
++++ b/arch/mips/Kconfig
+@@ -1149,6 +1149,10 @@ config SYNC_R4K
+ config MIPS_MACHINE
+ 	def_bool n
+ 
++config IMAGE_CMDLINE_HACK
++	bool "OpenWrt specific image command line hack"
++	default n
++
+ config NO_IOPORT_MAP
+ 	def_bool n
+ 
+diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
+index cf052204eb0a..f7327fae5473 100644
+--- a/arch/mips/kernel/head.S
++++ b/arch/mips/kernel/head.S
+@@ -79,6 +79,12 @@ FEXPORT(__kernel_entry)
+ 	j	kernel_entry
+ #endif
+ 
++#ifdef CONFIG_IMAGE_CMDLINE_HACK
++	.ascii	"CMDLINE:"
++EXPORT(__image_cmdline)
++	.fill	0x400
++#endif /* CONFIG_IMAGE_CMDLINE_HACK */
++
+ 	__REF
+ 
+ NESTED(kernel_entry, 16, sp)			# kernel entry point
+-- 
+2.11.0
+

+ 31 - 0
target/linux/generic/hack-4.9/321-powerpc_crtsavres_prereq.patch

@@ -0,0 +1,31 @@
+From 107c0964cb8db7ca28ac5199426414fdab3c274d Mon Sep 17 00:00:00 2001
+From: "Alexandros C. Couloumbis" <[email protected]>
+Date: Fri, 7 Jul 2017 17:14:51 +0200
+Subject: hack: arch: powerpc: drop register save/restore library from modules
+
+Upstream GCC uses a libgcc function for saving/restoring registers. This
+makes the code bigger, and upstream kernels need to carry that function
+for every single kernel module. Our GCC is patched to avoid those
+references, so we can drop the extra bloat for modules.
+
+lede-commit: e8e1084654f50904e6bf77b70b2de3f137d7b3ec
+Signed-off-by: Alexandros C. Couloumbis <[email protected]>
+---
+ arch/powerpc/Makefile | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
+index 617dece67924..1146daa8e4c2 100644
+--- a/arch/powerpc/Makefile
++++ b/arch/powerpc/Makefile
+@@ -179,7 +179,6 @@ else
+ CHECKFLAGS	+= -D__LITTLE_ENDIAN__
+ endif
+ 
+-KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
+ 
+ ifeq ($(CONFIG_476FPE_ERR46),y)
+ 	KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
+-- 
+2.11.0
+

+ 770 - 742
target/linux/generic/patches-4.9/531-debloat_lzma.patch → target/linux/generic/hack-4.9/531-debloat_lzma.patch

@@ -1,3 +1,63 @@
+From 3fd297761ac246c54d7723c57fca95c112b99465 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Sat, 15 Jul 2017 21:15:44 +0200
+Subject: lzma: de-bloat the lzma library used by jffs2
+
+lede-commit: 3fd1dd08fbcbb78b34efefd32c3032e5c99108d6
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ include/linux/lzma/LzFind.h  |  17 ---
+ include/linux/lzma/LzmaDec.h | 101 ---------------
+ include/linux/lzma/LzmaEnc.h |  20 ---
+ lib/lzma/LzFind.c            | 287 ++++---------------------------------------
+ lib/lzma/LzmaDec.c           |  86 +------------
+ lib/lzma/LzmaEnc.c           | 172 ++------------------------
+ 6 files changed, 42 insertions(+), 641 deletions(-)
+
+diff --git a/include/linux/lzma/LzFind.h b/include/linux/lzma/LzFind.h
+index 010c4b92ba33..6d4f8e239028 100644
+--- a/include/linux/lzma/LzFind.h
++++ b/include/linux/lzma/LzFind.h
+@@ -55,11 +55,6 @@ typedef struct _CMatchFinder
+ 
+ #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
+ 
+-int MatchFinder_NeedMove(CMatchFinder *p);
+-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
+-void MatchFinder_MoveBlock(CMatchFinder *p);
+-void MatchFinder_ReadIfRequired(CMatchFinder *p);
+-
+ void MatchFinder_Construct(CMatchFinder *p);
+ 
+ /* Conditions:
+@@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
+     UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+     ISzAlloc *alloc);
+ void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
+-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
+-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
+-
+-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
+-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
+-    UInt32 *distances, UInt32 maxLen);
+ 
+ /*
+ Conditions:
+@@ -102,12 +91,6 @@ typedef struct _IMatchFinder
+ 
+ void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
+ 
+-void MatchFinder_Init(CMatchFinder *p);
+-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
+-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
+-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+-
+ #ifdef __cplusplus
+ }
+ #endif
+diff --git a/include/linux/lzma/LzmaDec.h b/include/linux/lzma/LzmaDec.h
+index bf7f084ba3dd..c90f95e9fbaf 100644
 --- a/include/linux/lzma/LzmaDec.h
 +++ b/include/linux/lzma/LzmaDec.h
 @@ -31,14 +31,6 @@ typedef struct _CLzmaProps
@@ -122,141 +182,8 @@
  /* ---------- One Call Interface ---------- */
  
  /* LzmaDecode
---- a/lib/lzma/LzmaDec.c
-+++ b/lib/lzma/LzmaDec.c
-@@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p,
-   p->needFlush = 0;
- }
- 
--void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
-+static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
- {
-   p->needFlush = 1;
-   p->remainLen = 0;
-@@ -698,7 +698,7 @@ void LzmaDec_InitDicAndState(CLzmaDec *p
-     p->needInitState = 1;
- }
- 
--void LzmaDec_Init(CLzmaDec *p)
-+static void LzmaDec_Init(CLzmaDec *p)
- {
-   p->dicPos = 0;
-   LzmaDec_InitDicAndState(p, True, True);
-@@ -716,7 +716,7 @@ static void LzmaDec_InitStateReal(CLzmaD
-   p->needInitState = 0;
- }
- 
--SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
-+static SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
-     ELzmaFinishMode finishMode, ELzmaStatus *status)
- {
-   SizeT inSize = *srcLen;
-@@ -837,65 +837,13 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si
-   return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
- }
- 
--SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
--{
--  SizeT outSize = *destLen;
--  SizeT inSize = *srcLen;
--  *srcLen = *destLen = 0;
--  for (;;)
--  {
--    SizeT inSizeCur = inSize, outSizeCur, dicPos;
--    ELzmaFinishMode curFinishMode;
--    SRes res;
--    if (p->dicPos == p->dicBufSize)
--      p->dicPos = 0;
--    dicPos = p->dicPos;
--    if (outSize > p->dicBufSize - dicPos)
--    {
--      outSizeCur = p->dicBufSize;
--      curFinishMode = LZMA_FINISH_ANY;
--    }
--    else
--    {
--      outSizeCur = dicPos + outSize;
--      curFinishMode = finishMode;
--    }
--
--    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
--    src += inSizeCur;
--    inSize -= inSizeCur;
--    *srcLen += inSizeCur;
--    outSizeCur = p->dicPos - dicPos;
--    memcpy(dest, p->dic + dicPos, outSizeCur);
--    dest += outSizeCur;
--    outSize -= outSizeCur;
--    *destLen += outSizeCur;
--    if (res != 0)
--      return res;
--    if (outSizeCur == 0 || outSize == 0)
--      return SZ_OK;
--  }
--}
--
--void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
-+static void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
- {
-   alloc->Free(alloc, p->probs);
-   p->probs = 0;
- }
- 
--static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
--{
--  alloc->Free(alloc, p->dic);
--  p->dic = 0;
--}
--
--void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
--{
--  LzmaDec_FreeProbs(p, alloc);
--  LzmaDec_FreeDict(p, alloc);
--}
--
--SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
-+static SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
- {
-   UInt32 dicSize;
-   Byte d;
-@@ -935,7 +883,7 @@ static SRes LzmaDec_AllocateProbs2(CLzma
-   return SZ_OK;
- }
- 
--SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
-+static SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
- {
-   CLzmaProps propNew;
-   RINOK(LzmaProps_Decode(&propNew, props, propsSize));
-@@ -943,28 +891,6 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p,
-   p->prop = propNew;
-   return SZ_OK;
- }
--
--SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
--{
--  CLzmaProps propNew;
--  SizeT dicBufSize;
--  RINOK(LzmaProps_Decode(&propNew, props, propsSize));
--  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
--  dicBufSize = propNew.dicSize;
--  if (p->dic == 0 || dicBufSize != p->dicBufSize)
--  {
--    LzmaDec_FreeDict(p, alloc);
--    p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
--    if (p->dic == 0)
--    {
--      LzmaDec_FreeProbs(p, alloc);
--      return SZ_ERROR_MEM;
--    }
--  }
--  p->dicBufSize = dicBufSize;
--  p->prop = propNew;
--  return SZ_OK;
--}
- 
- SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
-     const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+diff --git a/include/linux/lzma/LzmaEnc.h b/include/linux/lzma/LzmaEnc.h
+index 200d60eb83cd..2986c0460be4 100644
 --- a/include/linux/lzma/LzmaEnc.h
 +++ b/include/linux/lzma/LzmaEnc.h
 @@ -31,9 +31,6 @@ typedef struct _CLzmaEncProps
@@ -269,7 +196,7 @@
  
  /* ---------- CLzmaEncHandle Interface ---------- */
  
-@@ -53,26 +50,9 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *
+@@ -53,26 +50,9 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
  void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
  SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
  SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
@@ -296,729 +223,830 @@
  #ifdef __cplusplus
  }
  #endif
---- a/lib/lzma/LzmaEnc.c
-+++ b/lib/lzma/LzmaEnc.c
-@@ -53,7 +53,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
-   p->writeEndMark = 0;
- }
+diff --git a/lib/lzma/LzFind.c b/lib/lzma/LzFind.c
+index e3ecb05420eb..86251ccedfda 100644
+--- a/lib/lzma/LzFind.c
++++ b/lib/lzma/LzFind.c
+@@ -14,9 +14,15 @@
  
--void LzmaEncProps_Normalize(CLzmaEncProps *p)
-+static void LzmaEncProps_Normalize(CLzmaEncProps *p)
+ #define kStartMaxLen 3
+ 
++#if 0
++#define DIRECT_INPUT	p->directInput
++#else
++#define DIRECT_INPUT	1
++#endif
++
+ static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
  {
-   int level = p->level;
-   if (level < 0) level = 5;
-@@ -76,7 +76,7 @@ void LzmaEncProps_Normalize(CLzmaEncProp
-       #endif
+-  if (!p->directInput)
++  if (!DIRECT_INPUT)
+   {
+     alloc->Free(alloc, p->bufferBase);
+     p->bufferBase = 0;
+@@ -28,7 +34,7 @@ static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
+ static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
+ {
+   UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
+-  if (p->directInput)
++  if (DIRECT_INPUT)
+   {
+     p->blockSize = blockSize;
+     return 1;
+@@ -42,12 +48,12 @@ static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *a
+   return (p->bufferBase != 0);
  }
  
--UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
-+static UInt32 __maybe_unused LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
- {
-   CLzmaEncProps props = *props2;
-   LzmaEncProps_Normalize(&props);
-@@ -93,7 +93,7 @@ UInt32 LzmaEncProps_GetDictSize(const CL
+-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
+-Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
++static Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
++static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
  
- #define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
+-UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
++static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
  
--UInt32 GetPosSlot1(UInt32 pos)
-+static UInt32 GetPosSlot1(UInt32 pos)
+-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
++static void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
  {
-   UInt32 res;
-   BSR2_RET(pos, res);
-@@ -107,7 +107,7 @@ UInt32 GetPosSlot1(UInt32 pos)
- #define kNumLogBits (9 + (int)sizeof(size_t) / 2)
- #define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
+   p->posLimit -= subValue;
+   p->pos -= subValue;
+@@ -58,7 +64,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
+ {
+   if (p->streamEndWasReached || p->result != SZ_OK)
+     return;
+-  if (p->directInput)
++  if (DIRECT_INPUT)
+   {
+     UInt32 curSize = 0xFFFFFFFF - p->streamPos;
+     if (curSize > p->directInputRem)
+@@ -89,7 +95,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
+   }
+ }
  
--void LzmaEnc_FastPosInit(Byte *g_FastPos)
-+static void LzmaEnc_FastPosInit(Byte *g_FastPos)
+-void MatchFinder_MoveBlock(CMatchFinder *p)
++static void MatchFinder_MoveBlock(CMatchFinder *p)
  {
-   int c = 2, slotFast;
-   g_FastPos[0] = 0;
-@@ -339,58 +339,6 @@ typedef struct
-   CSaveState saveState;
- } CLzmaEnc;
+   memmove(p->bufferBase,
+     p->buffer - p->keepSizeBefore,
+@@ -97,22 +103,14 @@ void MatchFinder_MoveBlock(CMatchFinder *p)
+   p->buffer = p->bufferBase + p->keepSizeBefore;
+ }
  
--void LzmaEnc_SaveState(CLzmaEncHandle pp)
--{
--  CLzmaEnc *p = (CLzmaEnc *)pp;
--  CSaveState *dest = &p->saveState;
--  int i;
--  dest->lenEnc = p->lenEnc;
--  dest->repLenEnc = p->repLenEnc;
--  dest->state = p->state;
--
--  for (i = 0; i < kNumStates; i++)
--  {
--    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
--    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
--  }
--  for (i = 0; i < kNumLenToPosStates; i++)
--    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
--  memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
--  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
--  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
--  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
--  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
--  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
--  memcpy(dest->reps, p->reps, sizeof(p->reps));
--  memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
--}
--
--void LzmaEnc_RestoreState(CLzmaEncHandle pp)
+-int MatchFinder_NeedMove(CMatchFinder *p)
++static int MatchFinder_NeedMove(CMatchFinder *p)
+ {
+-  if (p->directInput)
++  if (DIRECT_INPUT)
+     return 0;
+   /* if (p->streamEndWasReached) return 0; */
+   return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
+ }
+ 
+-void MatchFinder_ReadIfRequired(CMatchFinder *p)
 -{
--  CLzmaEnc *dest = (CLzmaEnc *)pp;
--  const CSaveState *p = &dest->saveState;
--  int i;
--  dest->lenEnc = p->lenEnc;
--  dest->repLenEnc = p->repLenEnc;
--  dest->state = p->state;
--
--  for (i = 0; i < kNumStates; i++)
--  {
--    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
--    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
--  }
--  for (i = 0; i < kNumLenToPosStates; i++)
--    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
--  memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
--  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
--  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
--  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
--  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
--  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
--  memcpy(dest->reps, p->reps, sizeof(p->reps));
--  memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb));
+-  if (p->streamEndWasReached)
+-    return;
+-  if (p->keepSizeAfter >= p->streamPos - p->pos)
+-    MatchFinder_ReadBlock(p);
 -}
 -
- SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
+ static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
  {
-   CLzmaEnc *p = (CLzmaEnc *)pp;
-@@ -600,7 +548,7 @@ static void LitEnc_EncodeMatched(CRangeE
-   while (symbol < 0x10000);
+   if (MatchFinder_NeedMove(p))
+@@ -268,7 +266,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
+   p->posLimit = p->pos + limit;
  }
  
--void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
-+static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
+-void MatchFinder_Init(CMatchFinder *p)
++static void MatchFinder_Init(CMatchFinder *p)
  {
    UInt32 i;
-   for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
-@@ -1676,7 +1624,7 @@ static void FillDistancesPrices(CLzmaEnc
-   p->matchPriceCount = 0;
- }
- 
--void LzmaEnc_Construct(CLzmaEnc *p)
-+static void LzmaEnc_Construct(CLzmaEnc *p)
- {
-   RangeEnc_Construct(&p->rc);
-   MatchFinder_Construct(&p->matchFinderBase);
-@@ -1709,7 +1657,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *
-   return p;
- }
- 
--void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
-+static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
- {
-   alloc->Free(alloc, p->litProbs);
-   alloc->Free(alloc, p->saveState.litProbs);
-@@ -1717,7 +1665,7 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAl
-   p->saveState.litProbs = 0;
- }
- 
--void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
-+static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
- {
-   #ifndef _7ZIP_ST
-   MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
-@@ -1947,7 +1895,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, U
-   return SZ_OK;
+   for (i = 0; i < p->hashSizeSum; i++)
+@@ -287,7 +285,7 @@ static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
+   return (p->pos - p->historySize - 1) & kNormalizeMask;
  }
  
--void LzmaEnc_Init(CLzmaEnc *p)
-+static void LzmaEnc_Init(CLzmaEnc *p)
+-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
++static void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
  {
    UInt32 i;
-   p->state = 0;
-@@ -2005,7 +1953,7 @@ void LzmaEnc_Init(CLzmaEnc *p)
-   p->lpMask = (1 << p->lp) - 1;
- }
- 
--void LzmaEnc_InitPrices(CLzmaEnc *p)
-+static void LzmaEnc_InitPrices(CLzmaEnc *p)
- {
-   if (!p->fastMode)
-   {
-@@ -2037,26 +1985,6 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEn
-   return SZ_OK;
+   for (i = 0; i < numItems; i++)
+@@ -319,38 +317,7 @@ static void MatchFinder_CheckLimits(CMatchFinder *p)
+   MatchFinder_SetLimits(p);
  }
  
--static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream,
--    ISzAlloc *alloc, ISzAlloc *allocBig)
--{
--  CLzmaEnc *p = (CLzmaEnc *)pp;
--  p->matchFinderBase.stream = inStream;
--  p->needInit = 1;
--  p->rc.outStream = outStream;
--  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
--}
--
--SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,
--    ISeqInStream *inStream, UInt32 keepWindowSize,
--    ISzAlloc *alloc, ISzAlloc *allocBig)
+-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
+-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
+-    UInt32 *distances, UInt32 maxLen)
 -{
--  CLzmaEnc *p = (CLzmaEnc *)pp;
--  p->matchFinderBase.stream = inStream;
--  p->needInit = 1;
--  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
+-  son[_cyclicBufferPos] = curMatch;
+-  for (;;)
+-  {
+-    UInt32 delta = pos - curMatch;
+-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+-      return distances;
+-    {
+-      const Byte *pb = cur - delta;
+-      curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
+-      if (pb[maxLen] == cur[maxLen] && *pb == *cur)
+-      {
+-        UInt32 len = 0;
+-        while (++len != lenLimit)
+-          if (pb[len] != cur[len])
+-            break;
+-        if (maxLen < len)
+-        {
+-          *distances++ = maxLen = len;
+-          *distances++ = delta - 1;
+-          if (len == lenLimit)
+-            return distances;
+-        }
+-      }
+-    }
+-  }
 -}
 -
- static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
+-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
++static UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
+     UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
+     UInt32 *distances, UInt32 maxLen)
  {
-   p->matchFinderBase.directInput = 1;
-@@ -2064,7 +1992,7 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc
-   p->matchFinderBase.directInputRem = srcLen;
- }
+@@ -460,10 +427,10 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
+   p->buffer++; \
+   if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
  
--SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
-+static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
-     UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
- {
-   CLzmaEnc *p = (CLzmaEnc *)pp;
-@@ -2074,7 +2002,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p
-   return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
- }
+-#define MOVE_POS_RET MOVE_POS return offset;
+-
+ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
  
--void LzmaEnc_Finish(CLzmaEncHandle pp)
-+static void LzmaEnc_Finish(CLzmaEncHandle pp)
- {
-   #ifndef _7ZIP_ST
-   CLzmaEnc *p = (CLzmaEnc *)pp;
-@@ -2107,53 +2035,6 @@ static size_t MyWrite(void *pp, const vo
-   return size;
- }
++#define MOVE_POS_RET MatchFinder_MovePos(p); return offset;
++
+ #define GET_MATCHES_HEADER2(minLen, ret_op) \
+   UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
+   lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
+@@ -479,62 +446,7 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
+   distances + offset, maxLen) - distances); MOVE_POS_RET;
  
+ #define SKIP_FOOTER \
+-  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
 -
--UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
+-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 -{
--  const CLzmaEnc *p = (CLzmaEnc *)pp;
--  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
+-  UInt32 offset;
+-  GET_MATCHES_HEADER(2)
+-  HASH2_CALC;
+-  curMatch = p->hash[hashValue];
+-  p->hash[hashValue] = p->pos;
+-  offset = 0;
+-  GET_MATCHES_FOOTER(offset, 1)
 -}
 -
--const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
+-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 -{
--  const CLzmaEnc *p = (CLzmaEnc *)pp;
--  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
+-  UInt32 offset;
+-  GET_MATCHES_HEADER(3)
+-  HASH_ZIP_CALC;
+-  curMatch = p->hash[hashValue];
+-  p->hash[hashValue] = p->pos;
+-  offset = 0;
+-  GET_MATCHES_FOOTER(offset, 2)
 -}
 -
--SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
--    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
+-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 -{
--  CLzmaEnc *p = (CLzmaEnc *)pp;
--  UInt64 nowPos64;
--  SRes res;
--  CSeqOutStreamBuf outStream;
--
--  outStream.funcTable.Write = MyWrite;
--  outStream.data = dest;
--  outStream.rem = *destLen;
--  outStream.overflow = False;
--
--  p->writeEndMark = False;
--  p->finished = False;
--  p->result = SZ_OK;
+-  UInt32 hash2Value, delta2, maxLen, offset;
+-  GET_MATCHES_HEADER(3)
 -
--  if (reInit)
--    LzmaEnc_Init(p);
--  LzmaEnc_InitPrices(p);
--  nowPos64 = p->nowPos64;
--  RangeEnc_Init(&p->rc);
--  p->rc.outStream = &outStream.funcTable;
+-  HASH3_CALC;
 -
--  res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
+-  delta2 = p->pos - p->hash[hash2Value];
+-  curMatch = p->hash[kFix3HashSize + hashValue];
 -  
--  *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
--  *destLen -= outStream.rem;
--  if (outStream.overflow)
--    return SZ_ERROR_OUTPUT_EOF;
+-  p->hash[hash2Value] =
+-  p->hash[kFix3HashSize + hashValue] = p->pos;
 -
--  return res;
--}
 -
- static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
- {
-   SRes res = SZ_OK;
-@@ -2184,13 +2065,6 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p,
-   return res;
- }
- 
--SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
--    ISzAlloc *alloc, ISzAlloc *allocBig)
--{
--  RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig));
--  return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
+-  maxLen = 2;
+-  offset = 0;
+-  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
+-  {
+-    for (; maxLen != lenLimit; maxLen++)
+-      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
+-        break;
+-    distances[0] = maxLen;
+-    distances[1] = delta2 - 1;
+-    offset = 2;
+-    if (maxLen == lenLimit)
+-    {
+-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
+-      MOVE_POS_RET;
+-    }
+-  }
+-  GET_MATCHES_FOOTER(offset, maxLen)
 -}
--
- SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
++  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MatchFinder_MovePos(p);
+ 
+ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
  {
-   CLzmaEnc *p = (CLzmaEnc *)pp;
-@@ -2247,25 +2121,3 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp
-     return SZ_ERROR_OUTPUT_EOF;
-   return res;
+@@ -583,108 +495,6 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+   GET_MATCHES_FOOTER(offset, maxLen)
  }
+ 
+-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+-{
+-  UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
+-  GET_MATCHES_HEADER(4)
 -
--SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
--    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
--    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
+-  HASH4_CALC;
+-
+-  delta2 = p->pos - p->hash[                hash2Value];
+-  delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
+-  curMatch = p->hash[kFix4HashSize + hashValue];
+-
+-  p->hash[                hash2Value] =
+-  p->hash[kFix3HashSize + hash3Value] =
+-  p->hash[kFix4HashSize + hashValue] = p->pos;
+-
+-  maxLen = 1;
+-  offset = 0;
+-  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
+-  {
+-    distances[0] = maxLen = 2;
+-    distances[1] = delta2 - 1;
+-    offset = 2;
+-  }
+-  if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
+-  {
+-    maxLen = 3;
+-    distances[offset + 1] = delta3 - 1;
+-    offset += 2;
+-    delta2 = delta3;
+-  }
+-  if (offset != 0)
+-  {
+-    for (; maxLen != lenLimit; maxLen++)
+-      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
+-        break;
+-    distances[offset - 2] = maxLen;
+-    if (maxLen == lenLimit)
+-    {
+-      p->son[p->cyclicBufferPos] = curMatch;
+-      MOVE_POS_RET;
+-    }
+-  }
+-  if (maxLen < 3)
+-    maxLen = 3;
+-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
+-    distances + offset, maxLen) - (distances));
+-  MOVE_POS_RET
+-}
+-
+-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 -{
--  CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
--  SRes res;
--  if (p == 0)
--    return SZ_ERROR_MEM;
+-  UInt32 offset;
+-  GET_MATCHES_HEADER(3)
+-  HASH_ZIP_CALC;
+-  curMatch = p->hash[hashValue];
+-  p->hash[hashValue] = p->pos;
+-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
+-    distances, 2) - (distances));
+-  MOVE_POS_RET
+-}
 -
--  res = LzmaEnc_SetProps(p, props);
--  if (res == SZ_OK)
+-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+-{
+-  do
 -  {
--    res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);
--    if (res == SZ_OK)
--      res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,
--          writeEndMark, progress, alloc, allocBig);
+-    SKIP_HEADER(2)
+-    HASH2_CALC;
+-    curMatch = p->hash[hashValue];
+-    p->hash[hashValue] = p->pos;
+-    SKIP_FOOTER
 -  }
+-  while (--num != 0);
+-}
 -
--  LzmaEnc_Destroy(p, alloc, allocBig);
--  return res;
+-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+-{
+-  do
+-  {
+-    SKIP_HEADER(3)
+-    HASH_ZIP_CALC;
+-    curMatch = p->hash[hashValue];
+-    p->hash[hashValue] = p->pos;
+-    SKIP_FOOTER
+-  }
+-  while (--num != 0);
 -}
---- a/include/linux/lzma/LzFind.h
-+++ b/include/linux/lzma/LzFind.h
-@@ -55,11 +55,6 @@ typedef struct _CMatchFinder
- 
- #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
- 
--int MatchFinder_NeedMove(CMatchFinder *p);
--Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
--void MatchFinder_MoveBlock(CMatchFinder *p);
--void MatchFinder_ReadIfRequired(CMatchFinder *p);
 -
- void MatchFinder_Construct(CMatchFinder *p);
- 
- /* Conditions:
-@@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p,
-     UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
-     ISzAlloc *alloc);
- void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
--void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
--void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
+-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+-{
+-  do
+-  {
+-    UInt32 hash2Value;
+-    SKIP_HEADER(3)
+-    HASH3_CALC;
+-    curMatch = p->hash[kFix3HashSize + hashValue];
+-    p->hash[hash2Value] =
+-    p->hash[kFix3HashSize + hashValue] = p->pos;
+-    SKIP_FOOTER
+-  }
+-  while (--num != 0);
+-}
 -
--UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
--    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
--    UInt32 *distances, UInt32 maxLen);
- 
- /*
- Conditions:
-@@ -102,12 +91,6 @@ typedef struct _IMatchFinder
- 
- void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
+ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+ {
+   do
+@@ -701,61 +511,12 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+   while (--num != 0);
+ }
  
--void MatchFinder_Init(CMatchFinder *p);
--UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
--UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
--void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
--void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+-{
+-  do
+-  {
+-    UInt32 hash2Value, hash3Value;
+-    SKIP_HEADER(4)
+-    HASH4_CALC;
+-    curMatch = p->hash[kFix4HashSize + hashValue];
+-    p->hash[                hash2Value] =
+-    p->hash[kFix3HashSize + hash3Value] =
+-    p->hash[kFix4HashSize + hashValue] = p->pos;
+-    p->son[p->cyclicBufferPos] = curMatch;
+-    MOVE_POS
+-  }
+-  while (--num != 0);
+-}
 -
- #ifdef __cplusplus
+-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+-{
+-  do
+-  {
+-    SKIP_HEADER(3)
+-    HASH_ZIP_CALC;
+-    curMatch = p->hash[hashValue];
+-    p->hash[hashValue] = p->pos;
+-    p->son[p->cyclicBufferPos] = curMatch;
+-    MOVE_POS
+-  }
+-  while (--num != 0);
+-}
+-
+ void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
+ {
+   vTable->Init = (Mf_Init_Func)MatchFinder_Init;
+   vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
+   vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
+   vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
+-  if (!p->btMode)
+-  {
+-    vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
+-    vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
+-  }
+-  else if (p->numHashBytes == 2)
+-  {
+-    vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
+-    vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
+-  }
+-  else if (p->numHashBytes == 3)
+-  {
+-    vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
+-    vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
+-  }
+-  else
+-  {
+-    vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
+-    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
+-  }
++  vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
++  vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
+ }
+diff --git a/lib/lzma/LzmaDec.c b/lib/lzma/LzmaDec.c
+index 2036761bf146..7666e3f82067 100644
+--- a/lib/lzma/LzmaDec.c
++++ b/lib/lzma/LzmaDec.c
+@@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
+   p->needFlush = 0;
  }
- #endif
---- a/lib/lzma/LzFind.c
-+++ b/lib/lzma/LzFind.c
-@@ -14,9 +14,15 @@
- 
- #define kStartMaxLen 3
  
-+#if 0
-+#define DIRECT_INPUT	p->directInput
-+#else
-+#define DIRECT_INPUT	1
-+#endif
-+
- static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
+-void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
++static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
  {
--  if (!p->directInput)
-+  if (!DIRECT_INPUT)
-   {
-     alloc->Free(alloc, p->bufferBase);
-     p->bufferBase = 0;
-@@ -28,7 +34,7 @@ static void LzInWindow_Free(CMatchFinder
- static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
+   p->needFlush = 1;
+   p->remainLen = 0;
+@@ -698,7 +698,7 @@ void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
+     p->needInitState = 1;
+ }
+ 
+-void LzmaDec_Init(CLzmaDec *p)
++static void LzmaDec_Init(CLzmaDec *p)
  {
-   UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
--  if (p->directInput)
-+  if (DIRECT_INPUT)
-   {
-     p->blockSize = blockSize;
-     return 1;
-@@ -42,12 +48,12 @@ static int LzInWindow_Create(CMatchFinde
-   return (p->bufferBase != 0);
+   p->dicPos = 0;
+   LzmaDec_InitDicAndState(p, True, True);
+@@ -716,7 +716,7 @@ static void LzmaDec_InitStateReal(CLzmaDec *p)
+   p->needInitState = 0;
  }
  
--Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
--Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
-+static Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
-+static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
+-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
++static SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
+     ELzmaFinishMode finishMode, ELzmaStatus *status)
+ {
+   SizeT inSize = *srcLen;
+@@ -837,65 +837,13 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
+   return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
+ }
  
--UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
-+static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
+-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+-{
+-  SizeT outSize = *destLen;
+-  SizeT inSize = *srcLen;
+-  *srcLen = *destLen = 0;
+-  for (;;)
+-  {
+-    SizeT inSizeCur = inSize, outSizeCur, dicPos;
+-    ELzmaFinishMode curFinishMode;
+-    SRes res;
+-    if (p->dicPos == p->dicBufSize)
+-      p->dicPos = 0;
+-    dicPos = p->dicPos;
+-    if (outSize > p->dicBufSize - dicPos)
+-    {
+-      outSizeCur = p->dicBufSize;
+-      curFinishMode = LZMA_FINISH_ANY;
+-    }
+-    else
+-    {
+-      outSizeCur = dicPos + outSize;
+-      curFinishMode = finishMode;
+-    }
+-
+-    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
+-    src += inSizeCur;
+-    inSize -= inSizeCur;
+-    *srcLen += inSizeCur;
+-    outSizeCur = p->dicPos - dicPos;
+-    memcpy(dest, p->dic + dicPos, outSizeCur);
+-    dest += outSizeCur;
+-    outSize -= outSizeCur;
+-    *destLen += outSizeCur;
+-    if (res != 0)
+-      return res;
+-    if (outSizeCur == 0 || outSize == 0)
+-      return SZ_OK;
+-  }
+-}
+-
+-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
++static void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
+ {
+   alloc->Free(alloc, p->probs);
+   p->probs = 0;
+ }
  
--void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
-+static void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
+-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
+-{
+-  alloc->Free(alloc, p->dic);
+-  p->dic = 0;
+-}
+-
+-void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
+-{
+-  LzmaDec_FreeProbs(p, alloc);
+-  LzmaDec_FreeDict(p, alloc);
+-}
+-
+-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
++static SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
  {
-   p->posLimit -= subValue;
-   p->pos -= subValue;
-@@ -58,7 +64,7 @@ static void MatchFinder_ReadBlock(CMatch
+   UInt32 dicSize;
+   Byte d;
+@@ -935,33 +883,11 @@ static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAl
+   return SZ_OK;
+ }
+ 
+-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+-{
+-  CLzmaProps propNew;
+-  RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+-  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+-  p->prop = propNew;
+-  return SZ_OK;
+-}
+-
+-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
++static SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
  {
-   if (p->streamEndWasReached || p->result != SZ_OK)
-     return;
--  if (p->directInput)
-+  if (DIRECT_INPUT)
-   {
-     UInt32 curSize = 0xFFFFFFFF - p->streamPos;
-     if (curSize > p->directInputRem)
-@@ -89,7 +95,7 @@ static void MatchFinder_ReadBlock(CMatch
-   }
+   CLzmaProps propNew;
+-  SizeT dicBufSize;
+   RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+   RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+-  dicBufSize = propNew.dicSize;
+-  if (p->dic == 0 || dicBufSize != p->dicBufSize)
+-  {
+-    LzmaDec_FreeDict(p, alloc);
+-    p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
+-    if (p->dic == 0)
+-    {
+-      LzmaDec_FreeProbs(p, alloc);
+-      return SZ_ERROR_MEM;
+-    }
+-  }
+-  p->dicBufSize = dicBufSize;
+   p->prop = propNew;
+   return SZ_OK;
+ }
+diff --git a/lib/lzma/LzmaEnc.c b/lib/lzma/LzmaEnc.c
+index 6dadf00dfab2..943965647bad 100644
+--- a/lib/lzma/LzmaEnc.c
++++ b/lib/lzma/LzmaEnc.c
+@@ -53,7 +53,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
+   p->writeEndMark = 0;
  }
  
--void MatchFinder_MoveBlock(CMatchFinder *p)
-+static void MatchFinder_MoveBlock(CMatchFinder *p)
+-void LzmaEncProps_Normalize(CLzmaEncProps *p)
++static void LzmaEncProps_Normalize(CLzmaEncProps *p)
  {
-   memmove(p->bufferBase,
-     p->buffer - p->keepSizeBefore,
-@@ -97,22 +103,14 @@ void MatchFinder_MoveBlock(CMatchFinder
-   p->buffer = p->bufferBase + p->keepSizeBefore;
+   int level = p->level;
+   if (level < 0) level = 5;
+@@ -76,7 +76,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
+       #endif
  }
  
--int MatchFinder_NeedMove(CMatchFinder *p)
-+static int MatchFinder_NeedMove(CMatchFinder *p)
+-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
++static UInt32 __maybe_unused LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
  {
--  if (p->directInput)
-+  if (DIRECT_INPUT)
-     return 0;
-   /* if (p->streamEndWasReached) return 0; */
-   return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
- }
+   CLzmaEncProps props = *props2;
+   LzmaEncProps_Normalize(&props);
+@@ -93,7 +93,7 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
  
--void MatchFinder_ReadIfRequired(CMatchFinder *p)
+ #define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
+ 
+-UInt32 GetPosSlot1(UInt32 pos)
++static UInt32 GetPosSlot1(UInt32 pos)
+ {
+   UInt32 res;
+   BSR2_RET(pos, res);
+@@ -107,7 +107,7 @@ UInt32 GetPosSlot1(UInt32 pos)
+ #define kNumLogBits (9 + (int)sizeof(size_t) / 2)
+ #define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
+ 
+-void LzmaEnc_FastPosInit(Byte *g_FastPos)
++static void LzmaEnc_FastPosInit(Byte *g_FastPos)
+ {
+   int c = 2, slotFast;
+   g_FastPos[0] = 0;
+@@ -339,58 +339,6 @@ typedef struct
+   CSaveState saveState;
+ } CLzmaEnc;
+ 
+-void LzmaEnc_SaveState(CLzmaEncHandle pp)
 -{
--  if (p->streamEndWasReached)
--    return;
--  if (p->keepSizeAfter >= p->streamPos - p->pos)
--    MatchFinder_ReadBlock(p);
+-  CLzmaEnc *p = (CLzmaEnc *)pp;
+-  CSaveState *dest = &p->saveState;
+-  int i;
+-  dest->lenEnc = p->lenEnc;
+-  dest->repLenEnc = p->repLenEnc;
+-  dest->state = p->state;
+-
+-  for (i = 0; i < kNumStates; i++)
+-  {
+-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
+-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
+-  }
+-  for (i = 0; i < kNumLenToPosStates; i++)
+-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
+-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
+-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
+-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
+-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
+-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
+-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
+-  memcpy(dest->reps, p->reps, sizeof(p->reps));
+-  memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
 -}
 -
- static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
+-void LzmaEnc_RestoreState(CLzmaEncHandle pp)
+-{
+-  CLzmaEnc *dest = (CLzmaEnc *)pp;
+-  const CSaveState *p = &dest->saveState;
+-  int i;
+-  dest->lenEnc = p->lenEnc;
+-  dest->repLenEnc = p->repLenEnc;
+-  dest->state = p->state;
+-
+-  for (i = 0; i < kNumStates; i++)
+-  {
+-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
+-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
+-  }
+-  for (i = 0; i < kNumLenToPosStates; i++)
+-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
+-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
+-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
+-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
+-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
+-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
+-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
+-  memcpy(dest->reps, p->reps, sizeof(p->reps));
+-  memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb));
+-}
+-
+ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
  {
-   if (MatchFinder_NeedMove(p))
-@@ -268,7 +266,7 @@ static void MatchFinder_SetLimits(CMatch
-   p->posLimit = p->pos + limit;
+   CLzmaEnc *p = (CLzmaEnc *)pp;
+@@ -600,7 +548,7 @@ static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol,
+   while (symbol < 0x10000);
  }
  
--void MatchFinder_Init(CMatchFinder *p)
-+static void MatchFinder_Init(CMatchFinder *p)
+-void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
++static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
  {
    UInt32 i;
-   for (i = 0; i < p->hashSizeSum; i++)
-@@ -287,7 +285,7 @@ static UInt32 MatchFinder_GetSubValue(CM
-   return (p->pos - p->historySize - 1) & kNormalizeMask;
+   for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
+@@ -1676,7 +1624,7 @@ static void FillDistancesPrices(CLzmaEnc *p)
+   p->matchPriceCount = 0;
  }
  
--void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
-+static void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
+-void LzmaEnc_Construct(CLzmaEnc *p)
++static void LzmaEnc_Construct(CLzmaEnc *p)
  {
-   UInt32 i;
-   for (i = 0; i < numItems; i++)
-@@ -319,38 +317,7 @@ static void MatchFinder_CheckLimits(CMat
-   MatchFinder_SetLimits(p);
+   RangeEnc_Construct(&p->rc);
+   MatchFinder_Construct(&p->matchFinderBase);
+@@ -1709,7 +1657,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
+   return p;
  }
  
--static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
--    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
--    UInt32 *distances, UInt32 maxLen)
--{
--  son[_cyclicBufferPos] = curMatch;
--  for (;;)
--  {
--    UInt32 delta = pos - curMatch;
--    if (cutValue-- == 0 || delta >= _cyclicBufferSize)
--      return distances;
--    {
--      const Byte *pb = cur - delta;
--      curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
--      if (pb[maxLen] == cur[maxLen] && *pb == *cur)
--      {
--        UInt32 len = 0;
--        while (++len != lenLimit)
--          if (pb[len] != cur[len])
--            break;
--        if (maxLen < len)
--        {
--          *distances++ = maxLen = len;
--          *distances++ = delta - 1;
--          if (len == lenLimit)
--            return distances;
--        }
--      }
--    }
--  }
--}
--
--UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
-+static UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
-     UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
-     UInt32 *distances, UInt32 maxLen)
+-void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
++static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
  {
-@@ -460,10 +427,10 @@ static void SkipMatchesSpec(UInt32 lenLi
-   p->buffer++; \
-   if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
- 
--#define MOVE_POS_RET MOVE_POS return offset;
--
- static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
+   alloc->Free(alloc, p->litProbs);
+   alloc->Free(alloc, p->saveState.litProbs);
+@@ -1717,7 +1665,7 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
+   p->saveState.litProbs = 0;
+ }
  
-+#define MOVE_POS_RET MatchFinder_MovePos(p); return offset;
-+
- #define GET_MATCHES_HEADER2(minLen, ret_op) \
-   UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
-   lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
-@@ -479,62 +446,7 @@ static void MatchFinder_MovePos(CMatchFi
-   distances + offset, maxLen) - distances); MOVE_POS_RET;
+-void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
++static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
+ {
+   #ifndef _7ZIP_ST
+   MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
+@@ -1947,7 +1895,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, I
+   return SZ_OK;
+ }
  
- #define SKIP_FOOTER \
--  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
--
--static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
--{
--  UInt32 offset;
--  GET_MATCHES_HEADER(2)
--  HASH2_CALC;
--  curMatch = p->hash[hashValue];
--  p->hash[hashValue] = p->pos;
--  offset = 0;
--  GET_MATCHES_FOOTER(offset, 1)
--}
--
--UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
--{
--  UInt32 offset;
--  GET_MATCHES_HEADER(3)
--  HASH_ZIP_CALC;
--  curMatch = p->hash[hashValue];
--  p->hash[hashValue] = p->pos;
--  offset = 0;
--  GET_MATCHES_FOOTER(offset, 2)
--}
--
--static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
--{
--  UInt32 hash2Value, delta2, maxLen, offset;
--  GET_MATCHES_HEADER(3)
--
--  HASH3_CALC;
--
--  delta2 = p->pos - p->hash[hash2Value];
--  curMatch = p->hash[kFix3HashSize + hashValue];
--  
--  p->hash[hash2Value] =
--  p->hash[kFix3HashSize + hashValue] = p->pos;
--
--
--  maxLen = 2;
--  offset = 0;
--  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
--  {
--    for (; maxLen != lenLimit; maxLen++)
--      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
--        break;
--    distances[0] = maxLen;
--    distances[1] = delta2 - 1;
--    offset = 2;
--    if (maxLen == lenLimit)
--    {
--      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
--      MOVE_POS_RET;
--    }
--  }
--  GET_MATCHES_FOOTER(offset, maxLen)
--}
-+  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MatchFinder_MovePos(p);
+-void LzmaEnc_Init(CLzmaEnc *p)
++static void LzmaEnc_Init(CLzmaEnc *p)
+ {
+   UInt32 i;
+   p->state = 0;
+@@ -2005,7 +1953,7 @@ void LzmaEnc_Init(CLzmaEnc *p)
+   p->lpMask = (1 << p->lp) - 1;
+ }
  
- static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+-void LzmaEnc_InitPrices(CLzmaEnc *p)
++static void LzmaEnc_InitPrices(CLzmaEnc *p)
  {
-@@ -583,108 +495,6 @@ static UInt32 Bt4_MatchFinder_GetMatches
-   GET_MATCHES_FOOTER(offset, maxLen)
+   if (!p->fastMode)
+   {
+@@ -2037,26 +1985,6 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *a
+   return SZ_OK;
  }
  
--static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+-static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream,
+-    ISzAlloc *alloc, ISzAlloc *allocBig)
 -{
--  UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
--  GET_MATCHES_HEADER(4)
--
--  HASH4_CALC;
--
--  delta2 = p->pos - p->hash[                hash2Value];
--  delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
--  curMatch = p->hash[kFix4HashSize + hashValue];
--
--  p->hash[                hash2Value] =
--  p->hash[kFix3HashSize + hash3Value] =
--  p->hash[kFix4HashSize + hashValue] = p->pos;
--
--  maxLen = 1;
--  offset = 0;
--  if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
--  {
--    distances[0] = maxLen = 2;
--    distances[1] = delta2 - 1;
--    offset = 2;
--  }
--  if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
--  {
--    maxLen = 3;
--    distances[offset + 1] = delta3 - 1;
--    offset += 2;
--    delta2 = delta3;
--  }
--  if (offset != 0)
--  {
--    for (; maxLen != lenLimit; maxLen++)
--      if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
--        break;
--    distances[offset - 2] = maxLen;
--    if (maxLen == lenLimit)
--    {
--      p->son[p->cyclicBufferPos] = curMatch;
--      MOVE_POS_RET;
--    }
--  }
--  if (maxLen < 3)
--    maxLen = 3;
--  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
--    distances + offset, maxLen) - (distances));
--  MOVE_POS_RET
+-  CLzmaEnc *p = (CLzmaEnc *)pp;
+-  p->matchFinderBase.stream = inStream;
+-  p->needInit = 1;
+-  p->rc.outStream = outStream;
+-  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
 -}
 -
--UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+-SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,
+-    ISeqInStream *inStream, UInt32 keepWindowSize,
+-    ISzAlloc *alloc, ISzAlloc *allocBig)
 -{
--  UInt32 offset;
--  GET_MATCHES_HEADER(3)
--  HASH_ZIP_CALC;
--  curMatch = p->hash[hashValue];
--  p->hash[hashValue] = p->pos;
--  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
--    distances, 2) - (distances));
--  MOVE_POS_RET
+-  CLzmaEnc *p = (CLzmaEnc *)pp;
+-  p->matchFinderBase.stream = inStream;
+-  p->needInit = 1;
+-  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
 -}
 -
--static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+ static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
+ {
+   p->matchFinderBase.directInput = 1;
+@@ -2064,7 +1992,7 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
+   p->matchFinderBase.directInputRem = srcLen;
+ }
+ 
+-SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
++static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
+     UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+ {
+   CLzmaEnc *p = (CLzmaEnc *)pp;
+@@ -2074,7 +2002,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
+   return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
+ }
+ 
+-void LzmaEnc_Finish(CLzmaEncHandle pp)
++static void LzmaEnc_Finish(CLzmaEncHandle pp)
+ {
+   #ifndef _7ZIP_ST
+   CLzmaEnc *p = (CLzmaEnc *)pp;
+@@ -2107,53 +2035,6 @@ static size_t MyWrite(void *pp, const void *data, size_t size)
+   return size;
+ }
+ 
+-
+-UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
 -{
--  do
--  {
--    SKIP_HEADER(2)
--    HASH2_CALC;
--    curMatch = p->hash[hashValue];
--    p->hash[hashValue] = p->pos;
--    SKIP_FOOTER
--  }
--  while (--num != 0);
+-  const CLzmaEnc *p = (CLzmaEnc *)pp;
+-  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
 -}
 -
--void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+-const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
 -{
--  do
--  {
--    SKIP_HEADER(3)
--    HASH_ZIP_CALC;
--    curMatch = p->hash[hashValue];
--    p->hash[hashValue] = p->pos;
--    SKIP_FOOTER
--  }
--  while (--num != 0);
+-  const CLzmaEnc *p = (CLzmaEnc *)pp;
+-  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
 -}
 -
--static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
+-    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
 -{
--  do
--  {
--    UInt32 hash2Value;
--    SKIP_HEADER(3)
--    HASH3_CALC;
--    curMatch = p->hash[kFix3HashSize + hashValue];
--    p->hash[hash2Value] =
--    p->hash[kFix3HashSize + hashValue] = p->pos;
--    SKIP_FOOTER
--  }
--  while (--num != 0);
+-  CLzmaEnc *p = (CLzmaEnc *)pp;
+-  UInt64 nowPos64;
+-  SRes res;
+-  CSeqOutStreamBuf outStream;
+-
+-  outStream.funcTable.Write = MyWrite;
+-  outStream.data = dest;
+-  outStream.rem = *destLen;
+-  outStream.overflow = False;
+-
+-  p->writeEndMark = False;
+-  p->finished = False;
+-  p->result = SZ_OK;
+-
+-  if (reInit)
+-    LzmaEnc_Init(p);
+-  LzmaEnc_InitPrices(p);
+-  nowPos64 = p->nowPos64;
+-  RangeEnc_Init(&p->rc);
+-  p->rc.outStream = &outStream.funcTable;
+-
+-  res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
+-  
+-  *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
+-  *destLen -= outStream.rem;
+-  if (outStream.overflow)
+-    return SZ_ERROR_OUTPUT_EOF;
+-
+-  return res;
 -}
 -
- static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
  {
-   do
-@@ -701,61 +511,12 @@ static void Bt4_MatchFinder_Skip(CMatchF
-   while (--num != 0);
+   SRes res = SZ_OK;
+@@ -2184,13 +2065,6 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
+   return res;
  }
  
--static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+-SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
+-    ISzAlloc *alloc, ISzAlloc *allocBig)
 -{
--  do
--  {
--    UInt32 hash2Value, hash3Value;
--    SKIP_HEADER(4)
--    HASH4_CALC;
--    curMatch = p->hash[kFix4HashSize + hashValue];
--    p->hash[                hash2Value] =
--    p->hash[kFix3HashSize + hash3Value] =
--    p->hash[kFix4HashSize + hashValue] = p->pos;
--    p->son[p->cyclicBufferPos] = curMatch;
--    MOVE_POS
--  }
--  while (--num != 0);
+-  RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig));
+-  return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
 -}
 -
--void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+ SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
+ {
+   CLzmaEnc *p = (CLzmaEnc *)pp;
+@@ -2247,25 +2121,3 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte
+     return SZ_ERROR_OUTPUT_EOF;
+   return res;
+ }
+-
+-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+-    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
 -{
--  do
--  {
--    SKIP_HEADER(3)
--    HASH_ZIP_CALC;
--    curMatch = p->hash[hashValue];
--    p->hash[hashValue] = p->pos;
--    p->son[p->cyclicBufferPos] = curMatch;
--    MOVE_POS
--  }
--  while (--num != 0);
--}
+-  CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
+-  SRes res;
+-  if (p == 0)
+-    return SZ_ERROR_MEM;
 -
- void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
- {
-   vTable->Init = (Mf_Init_Func)MatchFinder_Init;
-   vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
-   vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
-   vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
--  if (!p->btMode)
--  {
--    vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
--    vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
--  }
--  else if (p->numHashBytes == 2)
--  {
--    vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
--    vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
--  }
--  else if (p->numHashBytes == 3)
--  {
--    vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
--    vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
--  }
--  else
+-  res = LzmaEnc_SetProps(p, props);
+-  if (res == SZ_OK)
 -  {
--    vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
--    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
+-    res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);
+-    if (res == SZ_OK)
+-      res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,
+-          writeEndMark, progress, alloc, allocBig);
 -  }
-+  vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
-+  vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
- }
+-
+-  LzmaEnc_Destroy(p, alloc, allocBig);
+-  return res;
+-}
+-- 
+2.11.0
+

+ 12 - 2
target/linux/generic/patches-4.9/640-bridge-only-accept-EAP-locally.patch → target/linux/generic/hack-4.9/640-bridge-only-accept-EAP-locally.patch

@@ -1,14 +1,21 @@
+From c6905cfdeb31a5c049db3da434b10fa0d3e83569 Mon Sep 17 00:00:00 2001
 From: Felix Fietkau <[email protected]>
-Subject: [PATCH] bridge: only accept EAP locally
+Date: Fri, 7 Jul 2017 17:18:54 +0200
+Subject: bridge: only accept EAP locally
 
 When bridging, do not forward EAP frames to other ports, only deliver
 them locally, regardless of the state.
 
 Signed-off-by: Felix Fietkau <[email protected]>
 ---
+ net/bridge/br_input.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
+index 267b46af407f..48fa08f32c2a 100644
 --- a/net/bridge/br_input.c
 +++ b/net/bridge/br_input.c
-@@ -164,11 +164,14 @@ int br_handle_frame_finish(struct net *n
+@@ -164,11 +164,14 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
  		}
  	}
  
@@ -25,3 +32,6 @@ Signed-off-by: Felix Fietkau <[email protected]>
  	if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
  		br_do_proxy_arp(skb, br, vid, p);
  
+-- 
+2.11.0
+

+ 43 - 25
target/linux/generic/patches-4.9/641-bridge_port_isolate.patch → target/linux/generic/hack-4.9/641-bridge_port_isolate.patch

@@ -1,10 +1,22 @@
+From e988390850731aa1697ed09d47b0932fac1af175 Mon Sep 17 00:00:00 2001
 From: Felix Fietkau <[email protected]>
-Subject: [PATCH] bridge: port isolate
+Date: Fri, 7 Jul 2017 17:20:03 +0200
+Subject: bridge: port isolate
 
 Isolating individual bridge ports
+
+Signed-off-by: Felix Fietkau <[email protected]>
 ---
---- a/include/linux/if_bridge.h
-+++ b/include/linux/if_bridge.h
+ include/linux/if_bridge.h | 1 +
+ net/bridge/br_forward.c   | 5 +++++
+ net/bridge/br_input.c     | 3 +++
+ net/bridge/br_sysfs_if.c  | 2 ++
+ 4 files changed, 11 insertions(+)
+
+Index: linux-4.9.34/include/linux/if_bridge.h
+===================================================================
+--- linux-4.9.34.orig/include/linux/if_bridge.h
++++ linux-4.9.34/include/linux/if_bridge.h
 @@ -47,6 +47,7 @@ struct br_ip_list {
  #define BR_PROXYARP_WIFI	BIT(10)
  #define BR_MCAST_FLOOD		BIT(11)
@@ -13,26 +25,10 @@ Isolating individual bridge ports
  
  #define BR_DEFAULT_AGEING_TIME	(300 * HZ)
  
---- a/net/bridge/br_sysfs_if.c
-+++ b/net/bridge/br_sysfs_if.c
-@@ -172,6 +172,7 @@ BRPORT_ATTR_FLAG(unicast_flood, BR_FLOOD
- BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP);
- BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI);
- BRPORT_ATTR_FLAG(multicast_flood, BR_MCAST_FLOOD);
-+BRPORT_ATTR_FLAG(isolate_mode, BR_ISOLATE_MODE);
- 
- #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
- static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
-@@ -220,6 +221,7 @@ static const struct brport_attribute *br
- 	&brport_attr_proxyarp,
- 	&brport_attr_proxyarp_wifi,
- 	&brport_attr_multicast_flood,
-+	&brport_attr_isolate_mode,
- 	NULL
- };
- 
---- a/net/bridge/br_forward.c
-+++ b/net/bridge/br_forward.c
+Index: linux-4.9.34/net/bridge/br_forward.c
+===================================================================
+--- linux-4.9.34.orig/net/bridge/br_forward.c
++++ linux-4.9.34/net/bridge/br_forward.c
 @@ -141,6 +141,9 @@ static int deliver_clone(const struct ne
  void br_forward(const struct net_bridge_port *to,
  		struct sk_buff *skb, bool local_rcv, bool local_orig)
@@ -52,8 +48,10 @@ Isolating individual bridge ports
  		/* Do not flood unicast traffic to ports that turn it off */
  		if (pkt_type == BR_PKT_UNICAST && !(p->flags & BR_FLOOD))
  			continue;
---- a/net/bridge/br_input.c
-+++ b/net/bridge/br_input.c
+Index: linux-4.9.34/net/bridge/br_input.c
+===================================================================
+--- linux-4.9.34.orig/net/bridge/br_input.c
++++ linux-4.9.34/net/bridge/br_input.c
 @@ -175,6 +175,9 @@ int br_handle_frame_finish(struct net *n
  	if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
  		br_do_proxy_arp(skb, br, vid, p);
@@ -64,3 +62,23 @@ Isolating individual bridge ports
  	switch (pkt_type) {
  	case BR_PKT_MULTICAST:
  		mdst = br_mdb_get(br, skb, vid);
+Index: linux-4.9.34/net/bridge/br_sysfs_if.c
+===================================================================
+--- linux-4.9.34.orig/net/bridge/br_sysfs_if.c
++++ linux-4.9.34/net/bridge/br_sysfs_if.c
+@@ -172,6 +172,7 @@ BRPORT_ATTR_FLAG(unicast_flood, BR_FLOOD
+ BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP);
+ BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI);
+ BRPORT_ATTR_FLAG(multicast_flood, BR_MCAST_FLOOD);
++BRPORT_ATTR_FLAG(isolate_mode, BR_ISOLATE_MODE);
+ 
+ #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
+ static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
+@@ -220,6 +221,7 @@ static const struct brport_attribute *br
+ 	&brport_attr_proxyarp,
+ 	&brport_attr_proxyarp_wifi,
+ 	&brport_attr_multicast_flood,
++	&brport_attr_isolate_mode,
+ 	NULL
+ };
+ 

+ 29 - 0
target/linux/generic/hack-4.9/651-wireless_mesh_header.patch

@@ -0,0 +1,29 @@
+From 6d3bc769657b0ee7c7506dad9911111c4226a7ea Mon Sep 17 00:00:00 2001
+From: Imre Kaloz <[email protected]>
+Date: Fri, 7 Jul 2017 17:21:05 +0200
+Subject: mac80211: increase wireless mesh header size
+
+lede-commit 3d4466cfd8f75f717efdb1f96fdde3c70d865fc1
+Signed-off-by: Imre Kaloz <[email protected]>
+---
+ include/linux/netdevice.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
+index 780e7171f548..6e0f2c79f79a 100644
+--- a/include/linux/netdevice.h
++++ b/include/linux/netdevice.h
+@@ -137,8 +137,8 @@ static inline bool dev_xmit_complete(int rc)
+ 
+ #if defined(CONFIG_HYPERV_NET)
+ # define LL_MAX_HEADER 128
+-#elif defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25)
+-# if defined(CONFIG_MAC80211_MESH)
++#elif defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25) || 1
++# if defined(CONFIG_MAC80211_MESH) || 1
+ #  define LL_MAX_HEADER 128
+ # else
+ #  define LL_MAX_HEADER 96
+-- 
+2.11.0
+

+ 26 - 0
target/linux/generic/hack-4.9/660-fq_codel_defaults.patch

@@ -0,0 +1,26 @@
+From a6ccb238939b25851474a279b20367fd24a0e816 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:21:53 +0200
+Subject:  hack: net: fq_codel: tune defaults for small devices
+
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ net/sched/sch_fq_codel.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
+index a5ea0e9b6be4..4467b95795bf 100644
+--- a/net/sched/sch_fq_codel.c
++++ b/net/sched/sch_fq_codel.c
+@@ -479,7 +479,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)
+ 
+ 	sch->limit = 10*1024;
+ 	q->flows_cnt = 1024;
+-	q->memory_limit = 32 << 20; /* 32 MBytes */
++	q->memory_limit = 4 << 20; /* 4 MBytes */
+ 	q->drop_batch_size = 64;
+ 	q->quantum = psched_mtu(qdisc_dev(sch));
+ 	q->perturbation = prandom_u32();
+-- 
+2.11.0
+

+ 58 - 31
target/linux/generic/patches-4.9/661-use_fq_codel_by_default.patch → target/linux/generic/hack-4.9/661-use_fq_codel_by_default.patch

@@ -1,3 +1,38 @@
+From 1d418f7e88035ed7a94073f6354246c66e9193e9 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:22:58 +0200
+Subject: fq_codel: switch default qdisc from pfifo_fast to fq_codel and remove pfifo_fast
+
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ include/net/sch_generic.h | 3 ++-
+ net/sched/Kconfig         | 3 ++-
+ net/sched/sch_api.c       | 2 +-
+ net/sched/sch_fq_codel.c  | 3 ++-
+ net/sched/sch_generic.c   | 4 ++--
+ 5 files changed, 9 insertions(+), 6 deletions(-)
+
+diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
+index e6aa0a249672..9eeb368d7eea 100644
+--- a/include/net/sch_generic.h
++++ b/include/net/sch_generic.h
+@@ -339,12 +339,13 @@ extern struct Qdisc_ops noop_qdisc_ops;
+ extern struct Qdisc_ops pfifo_fast_ops;
+ extern struct Qdisc_ops mq_qdisc_ops;
+ extern struct Qdisc_ops noqueue_qdisc_ops;
++extern struct Qdisc_ops fq_codel_qdisc_ops;
+ extern const struct Qdisc_ops *default_qdisc_ops;
+ static inline const struct Qdisc_ops *
+ get_default_qdisc_ops(const struct net_device *dev, int ntx)
+ {
+ 	return ntx < dev->real_num_tx_queues ?
+-			default_qdisc_ops : &pfifo_fast_ops;
++			default_qdisc_ops : &fq_codel_qdisc_ops;
+ }
+ 
+ struct Qdisc_class_common {
+diff --git a/net/sched/Kconfig b/net/sched/Kconfig
+index 87956a768d1b..89c6db93cb63 100644
 --- a/net/sched/Kconfig
 +++ b/net/sched/Kconfig
 @@ -3,8 +3,9 @@
@@ -11,9 +46,24 @@
  	---help---
  	  When the kernel has several packets to send out over a network
  	  device, it has to decide which ones to send first, which ones to
+diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
+index 206dc24add3a..9b5cfb6ac64b 100644
+--- a/net/sched/sch_api.c
++++ b/net/sched/sch_api.c
+@@ -1976,7 +1976,7 @@ static int __init pktsched_init(void)
+ 		return err;
+ 	}
+ 
+-	register_qdisc(&pfifo_fast_ops);
++	register_qdisc(&fq_codel_qdisc_ops);
+ 	register_qdisc(&pfifo_qdisc_ops);
+ 	register_qdisc(&bfifo_qdisc_ops);
+ 	register_qdisc(&pfifo_head_drop_qdisc_ops);
+diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
+index 4467b95795bf..2ebbf50658e5 100644
 --- a/net/sched/sch_fq_codel.c
 +++ b/net/sched/sch_fq_codel.c
-@@ -705,7 +705,7 @@ static const struct Qdisc_class_ops fq_c
+@@ -705,7 +705,7 @@ static const struct Qdisc_class_ops fq_codel_class_ops = {
  	.walk		=	fq_codel_walk,
  };
  
@@ -22,7 +72,7 @@
  	.cl_ops		=	&fq_codel_class_ops,
  	.id		=	"fq_codel",
  	.priv_size	=	sizeof(struct fq_codel_sched_data),
-@@ -720,6 +720,7 @@ static struct Qdisc_ops fq_codel_qdisc_o
+@@ -720,6 +720,7 @@ static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = {
  	.dump_stats =	fq_codel_dump_stats,
  	.owner		=	THIS_MODULE,
  };
@@ -30,23 +80,8 @@
  
  static int __init fq_codel_module_init(void)
  {
---- a/include/net/sch_generic.h
-+++ b/include/net/sch_generic.h
-@@ -339,12 +339,13 @@ extern struct Qdisc_ops noop_qdisc_ops;
- extern struct Qdisc_ops pfifo_fast_ops;
- extern struct Qdisc_ops mq_qdisc_ops;
- extern struct Qdisc_ops noqueue_qdisc_ops;
-+extern struct Qdisc_ops fq_codel_qdisc_ops;
- extern const struct Qdisc_ops *default_qdisc_ops;
- static inline const struct Qdisc_ops *
- get_default_qdisc_ops(const struct net_device *dev, int ntx)
- {
- 	return ntx < dev->real_num_tx_queues ?
--			default_qdisc_ops : &pfifo_fast_ops;
-+			default_qdisc_ops : &fq_codel_qdisc_ops;
- }
- 
- struct Qdisc_class_common {
+diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
+index 6cfb6e9038c2..97de97e3c5e2 100644
 --- a/net/sched/sch_generic.c
 +++ b/net/sched/sch_generic.c
 @@ -31,7 +31,7 @@
@@ -58,7 +93,7 @@
  EXPORT_SYMBOL(default_qdisc_ops);
  
  /* Main transmission queue. */
-@@ -759,7 +759,7 @@ static void attach_one_default_qdisc(str
+@@ -759,7 +759,7 @@ static void attach_one_default_qdisc(struct net_device *dev,
  				     void *_unused)
  {
  	struct Qdisc *qdisc;
@@ -67,14 +102,6 @@
  
  	if (dev->priv_flags & IFF_NO_QUEUE)
  		ops = &noqueue_qdisc_ops;
---- a/net/sched/sch_api.c
-+++ b/net/sched/sch_api.c
-@@ -1979,7 +1979,7 @@ static int __init pktsched_init(void)
- 		return err;
- 	}
- 
--	register_qdisc(&pfifo_fast_ops);
-+	register_qdisc(&fq_codel_qdisc_ops);
- 	register_qdisc(&pfifo_qdisc_ops);
- 	register_qdisc(&bfifo_qdisc_ops);
- 	register_qdisc(&pfifo_head_drop_qdisc_ops);
+-- 
+2.11.0
+

+ 16 - 1
target/linux/generic/patches-4.9/662-remove_pfifo_fast.patch → target/linux/generic/hack-4.9/662-remove_pfifo_fast.patch

@@ -1,6 +1,18 @@
+From b531d492d5ef1cf9dba0f4888eb5fd8624a6d762 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:23:42 +0200
+Subject: net: sched: switch default qdisc from pfifo_fast to fq_codel and remove pfifo_fast
+
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ net/sched/sch_generic.c | 140 ------------------------------------------------
+ 1 file changed, 140 deletions(-)
+
+diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
+index 97de97e3c5e2..a62de9e4e897 100644
 --- a/net/sched/sch_generic.c
 +++ b/net/sched/sch_generic.c
-@@ -449,146 +449,6 @@ struct Qdisc_ops noqueue_qdisc_ops __rea
+@@ -449,146 +449,6 @@ struct Qdisc_ops noqueue_qdisc_ops __read_mostly = {
  	.owner		=	THIS_MODULE,
  };
  
@@ -147,3 +159,6 @@
  static struct lock_class_key qdisc_tx_busylock;
  static struct lock_class_key qdisc_running_key;
  
+-- 
+2.11.0
+

+ 21 - 0
target/linux/generic/patches-4.9/700-swconfig_switch_drivers.patch → target/linux/generic/hack-4.9/700-swconfig_switch_drivers.patch

@@ -1,3 +1,17 @@
+From 36e516290611e613aa92996cb4339561452695b4 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:24:23 +0200
+Subject: net: swconfig: adds openwrt switch layer
+
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ drivers/net/phy/Kconfig   | 83 +++++++++++++++++++++++++++++++++++++++++++++++
+ drivers/net/phy/Makefile  | 15 +++++++++
+ include/uapi/linux/Kbuild |  1 +
+ 3 files changed, 99 insertions(+)
+
+diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
+index 2651c8d8de2f..a920adb78fea 100644
 --- a/drivers/net/phy/Kconfig
 +++ b/drivers/net/phy/Kconfig
 @@ -147,6 +147,89 @@ config MDIO_XGENE
@@ -90,6 +104,8 @@
  comment "MII PHY device drivers"
  
  config AMD_PHY
+diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
+index e58667d111e7..542b6be8953a 100644
 --- a/drivers/net/phy/Makefile
 +++ b/drivers/net/phy/Makefile
 @@ -5,6 +5,21 @@ libphy-$(CONFIG_SWPHY)		+= swphy.o
@@ -114,6 +130,8 @@
  obj-$(CONFIG_MDIO_BCM_IPROC)	+= mdio-bcm-iproc.o
  obj-$(CONFIG_MDIO_BCM_UNIMAC)	+= mdio-bcm-unimac.o
  obj-$(CONFIG_MDIO_BITBANG)	+= mdio-bitbang.o
+diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
+index cd2be1c8e9fb..ccdd8d586ab8 100644
 --- a/include/uapi/linux/Kbuild
 +++ b/include/uapi/linux/Kbuild
 @@ -399,6 +399,7 @@ header-y += stddef.h
@@ -124,3 +142,6 @@
  header-y += synclink.h
  header-y += sync_file.h
  header-y += sysctl.h
+-- 
+2.11.0
+

+ 0 - 0
target/linux/generic/patches-4.9/710-phy-add-mdio_register_board_info.patch → target/linux/generic/hack-4.9/710-phy-add-mdio_register_board_info.patch


+ 40 - 13
target/linux/generic/patches-4.9/721-phy_packets.patch → target/linux/generic/hack-4.9/721-phy_packets.patch

@@ -1,5 +1,22 @@
---- a/include/linux/netdevice.h
-+++ b/include/linux/netdevice.h
+From ffe387740bbe88dd88bbe04d6375902708003d6e Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <[email protected]>
+Date: Fri, 7 Jul 2017 17:25:00 +0200
+Subject: net: add packet mangeling patch
+
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+ include/linux/netdevice.h | 11 +++++++++++
+ include/linux/skbuff.h    | 14 ++++----------
+ net/Kconfig               |  6 ++++++
+ net/core/dev.c            | 18 ++++++++++++++----
+ net/core/skbuff.c         | 17 +++++++++++++++++
+ net/ethernet/eth.c        |  6 ++++++
+ 6 files changed, 58 insertions(+), 14 deletions(-)
+
+Index: linux-4.9.34/include/linux/netdevice.h
+===================================================================
+--- linux-4.9.34.orig/include/linux/netdevice.h
++++ linux-4.9.34/include/linux/netdevice.h
 @@ -1398,6 +1398,7 @@ enum netdev_priv_flags {
  	IFF_RXFH_CONFIGURED		= 1<<25,
  	IFF_PHONY_HEADROOM		= 1<<26,
@@ -39,8 +56,10 @@
  /*
   * Cache lines mostly used on receive path (including eth_type_trans())
   */
---- a/include/linux/skbuff.h
-+++ b/include/linux/skbuff.h
+Index: linux-4.9.34/include/linux/skbuff.h
+===================================================================
+--- linux-4.9.34.orig/include/linux/skbuff.h
++++ linux-4.9.34/include/linux/skbuff.h
 @@ -2334,6 +2334,10 @@ static inline int pskb_trim(struct sk_bu
  	return (len < skb->len) ? __pskb_trim(skb, len) : 0;
  }
@@ -69,8 +88,10 @@
  static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
  		unsigned int length)
  {
---- a/net/Kconfig
-+++ b/net/Kconfig
+Index: linux-4.9.34/net/Kconfig
+===================================================================
+--- linux-4.9.34.orig/net/Kconfig
++++ linux-4.9.34/net/Kconfig
 @@ -25,6 +25,12 @@ menuconfig NET
  
  if NET
@@ -84,9 +105,11 @@
  config WANT_COMPAT_NETLINK_MESSAGES
  	bool
  	help
---- a/net/core/dev.c
-+++ b/net/core/dev.c
-@@ -2932,10 +2932,20 @@ static int xmit_one(struct sk_buff *skb,
+Index: linux-4.9.34/net/core/dev.c
+===================================================================
+--- linux-4.9.34.orig/net/core/dev.c
++++ linux-4.9.34/net/core/dev.c
+@@ -2931,10 +2931,20 @@ static int xmit_one(struct sk_buff *skb,
  	if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
  		dev_queue_xmit_nit(skb, dev);
  
@@ -111,8 +134,10 @@
  
  	return rc;
  }
---- a/net/core/skbuff.c
-+++ b/net/core/skbuff.c
+Index: linux-4.9.34/net/core/skbuff.c
+===================================================================
+--- linux-4.9.34.orig/net/core/skbuff.c
++++ linux-4.9.34/net/core/skbuff.c
 @@ -64,6 +64,7 @@
  #include <linux/errqueue.h>
  #include <linux/prefetch.h>
@@ -144,8 +169,10 @@
  void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
  		     int size, unsigned int truesize)
  {
---- a/net/ethernet/eth.c
-+++ b/net/ethernet/eth.c
+Index: linux-4.9.34/net/ethernet/eth.c
+===================================================================
+--- linux-4.9.34.orig/net/ethernet/eth.c
++++ linux-4.9.34/net/ethernet/eth.c
 @@ -171,6 +171,12 @@ __be16 eth_type_trans(struct sk_buff *sk
  	const struct ethhdr *eth;
  

+ 31 - 15
target/linux/generic/patches-4.9/773-bgmac-add-srab-switch.patch → target/linux/generic/hack-4.9/773-bgmac-add-srab-switch.patch

@@ -1,9 +1,33 @@
-Register switch connected to srab
+From 3cb240533ab787899dc7f17aa7d6c5b4810e2e58 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <[email protected]>
+Date: Fri, 7 Jul 2017 17:26:01 +0200
+Subject: bcm53xx: bgmac: use srab switch driver
+
+use the srab switch driver on these SoCs.
 
 Signed-off-by: Hauke Mehrtens <[email protected]>
+---
+ drivers/net/ethernet/broadcom/bgmac-bcma.c |  1 +
+ drivers/net/ethernet/broadcom/bgmac.c      | 24 ++++++++++++++++++++++++
+ drivers/net/ethernet/broadcom/bgmac.h      |  4 ++++
+ 3 files changed, 29 insertions(+)
 
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
+Index: linux-4.9.34/drivers/net/ethernet/broadcom/bgmac-bcma.c
+===================================================================
+--- linux-4.9.34.orig/drivers/net/ethernet/broadcom/bgmac-bcma.c
++++ linux-4.9.34/drivers/net/ethernet/broadcom/bgmac-bcma.c
+@@ -230,6 +230,7 @@ static int bgmac_probe(struct bcma_devic
+ 		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+ 		bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
+ 		bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
++		bgmac->feature_flags |= BGMAC_FEAT_SRAB;
+ 		break;
+ 	case BCMA_CHIP_ID_BCM53573:
+ 		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+Index: linux-4.9.34/drivers/net/ethernet/broadcom/bgmac.c
+===================================================================
+--- linux-4.9.34.orig/drivers/net/ethernet/broadcom/bgmac.c
++++ linux-4.9.34/drivers/net/ethernet/broadcom/bgmac.c
 @@ -11,6 +11,7 @@
  
  #include <linux/bcma/bcma.h>
@@ -56,8 +80,10 @@ Signed-off-by: Hauke Mehrtens <[email protected]>
  	unregister_netdev(bgmac->net_dev);
  	phy_disconnect(bgmac->net_dev->phydev);
  	netif_napi_del(&bgmac->napi);
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
+Index: linux-4.9.34/drivers/net/ethernet/broadcom/bgmac.h
+===================================================================
+--- linux-4.9.34.orig/drivers/net/ethernet/broadcom/bgmac.h
++++ linux-4.9.34/drivers/net/ethernet/broadcom/bgmac.h
 @@ -409,6 +409,7 @@
  #define BGMAC_FEAT_CC4_IF_SW_TYPE	BIT(17)
  #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII	BIT(18)
@@ -76,13 +102,3 @@ Signed-off-by: Hauke Mehrtens <[email protected]>
  };
  
  struct bgmac *bgmac_alloc(struct device *dev);
---- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
-+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
-@@ -230,6 +230,7 @@ static int bgmac_probe(struct bcma_devic
- 		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
- 		bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
- 		bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
-+		bgmac->feature_flags |= BGMAC_FEAT_SRAB;
- 		break;
- 	case BCMA_CHIP_ID_BCM53573:
- 		bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;

+ 59 - 0
target/linux/generic/hack-4.9/835-misc-owl_loader.patch

@@ -0,0 +1,59 @@
+From dd36f935973d91644449bd9749f6062a2bed821b Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <[email protected]>
+Date: Fri, 7 Jul 2017 17:26:46 +0200
+Subject: misc: owl-loader for delayed Atheros ath9k fixup
+
+Some devices (like the Cisco Meraki Z1 Cloud Managed Teleworker Gateway)
+need to be able to initialize the PCIe wifi device. Normally, this is done
+during the early stages of booting linux, because the necessary init code
+is read from the memory mapped SPI and passed to pci_enable_ath9k_fixup.
+However,this isn't possible for devices which have the init code for the
+Atheros chip stored on NAND in an UBI volume. Hence, this module can be
+used to initialze the chip when the user-space is ready to extract the
+init code.
+
+Signed-off-by: Martin Blumenstingl <[email protected]>
+Signed-off-by: Christian Lamparter <[email protected]>
+---
+ drivers/misc/Kconfig  | 12 ++++++++++++
+ drivers/misc/Makefile |  1 +
+ 2 files changed, 13 insertions(+)
+
+diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
+index 64971baf11fa..50d2eaa75d41 100644
+--- a/drivers/misc/Kconfig
++++ b/drivers/misc/Kconfig
+@@ -151,6 +151,18 @@ config SGI_IOC4
+ 	  If you have an SGI Altix with an IOC4-based card say Y.
+ 	  Otherwise say N.
+ 
++config OWL_LOADER
++	tristate "Owl loader for initializing Atheros PCI(e) Wifi chips"
++	depends on PCI
++	---help---
++	This kernel module helps to initialize certain Qualcomm
++	Atheros' PCI(e) Wifi chips, which have the init data
++	(which contains the PCI device ID for example) stored
++	together with the calibration data in the file system.
++
++	This is necessary for devices like the Cisco Meraki Z1, say M.
++	Otherwise say N.
++
+ config TIFM_CORE
+ 	tristate "TI Flash Media interface support"
+ 	depends on PCI
+diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
+index 31983366090a..48c7e74a6e5a 100644
+--- a/drivers/misc/Makefile
++++ b/drivers/misc/Makefile
+@@ -12,6 +12,7 @@ obj-$(CONFIG_ATMEL_TCLIB)	+= atmel_tclib.o
+ obj-$(CONFIG_DUMMY_IRQ)		+= dummy-irq.o
+ obj-$(CONFIG_ICS932S401)	+= ics932s401.o
+ obj-$(CONFIG_LKDTM)		+= lkdtm.o
++obj-$(CONFIG_OWL_LOADER)	+= owl-loader.o
+ obj-$(CONFIG_TIFM_CORE)       	+= tifm_core.o
+ obj-$(CONFIG_TIFM_7XX1)       	+= tifm_7xx1.o
+ obj-$(CONFIG_PHANTOM)		+= phantom.o
+-- 
+2.11.0
+

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است