This makes the ar71xx target compile with kernel 4.9.

Signed-off-by: Hauke Mehrtens <ha...@hauke-m.de>
---
 target/linux/ar71xx/config-4.9                     |  24 +++--
 .../linux/ar71xx/files/arch/mips/ath79/mach-c60.c  |  56 ++++++++++
 .../ar71xx/files/arch/mips/ath79/mach-rb2011.c     |  58 +++++++++++
 .../ar71xx/files/arch/mips/ath79/mach-rb922.c      |  58 +++++++++++
 .../ar71xx/files/arch/mips/ath79/mach-rb95x.c      |  56 ++++++++++
 .../ar71xx/files/arch/mips/ath79/mach-rbsxtlite.c  |  58 +++++++++++
 .../ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c   |   4 +
 .../linux/ar71xx/files/drivers/mtd/cybertan_part.c |   5 +
 .../ar71xx/files/drivers/mtd/nand/ar934x_nfc.c     |  62 ++++++++++-
 .../ar71xx/files/drivers/mtd/nand/rb4xx_nand.c     |  56 ++++++++++
 .../ar71xx/files/drivers/mtd/nand/rb750_nand.c     |  56 ++++++++++
 .../ar71xx/files/drivers/mtd/nand/rb91x_nand.c     |  56 ++++++++++
 target/linux/ar71xx/files/drivers/mtd/tplinkpart.c |  13 +++
 .../linux/ar71xx/files/drivers/net/dsa/mv88e6063.c | 104 ++++++++-----------
 .../net/ethernet/atheros/ag71xx/ag71xx_mdio.c      |   4 +
 .../net/ethernet/atheros/ag71xx/ag71xx_phy.c       |  28 ++++-
 .../ar71xx/files/drivers/spi/spi-rb4xx-cpld.c      |   5 +
 target/linux/ar71xx/mikrotik/config-default        |   2 +-
 target/linux/ar71xx/nand/config-default            |   2 +-
 .../002-add_back_gpio_function_select.patch        |   8 +-
 .../004-register_gpio_driver_earlier.patch         |   4 +-
 ...make-ath79_ddr_ctrl_init-compatible-for-n.patch |  31 ------
 ...PS-ath79-do-AR724x-PCIe-root-complex-init.patch |   2 +-
 .../patches-4.9/203-MIPS-ath79-fix-restart.patch   |   4 +-
 .../310-lib-add-rle-decompression.patch            |   2 +-
 .../403-mtd_fix_cfi_cmdset_0002_status_check.patch |  14 +--
 .../patches-4.9/404-mtd-cybertan-trx-parser.patch  |  10 +-
 .../405-mtd-tp-link-partition-parser.patch         |   6 +-
 ...low-to-pass-probe-types-via-platform-data.patch |  23 +++--
 .../patches-4.9/409-mtd-rb4xx_nand_driver.patch    |   6 +-
 .../patches-4.9/410-mtd-rb750-nand-driver.patch    |   2 +-
 .../411-mtd-cfi_cmdset_0002-force-word-write.patch |   6 +-
 ...412-mtd-m25p80-zero-partition-parser-data.patch |  10 --
 .../patches-4.9/413-mtd-ar934x-nand-driver.patch   |   2 +-
 .../patches-4.9/414-mtd-rb91x-nand-driver.patch    |   2 +-
 .../patches-4.9/423-dsa-add-88e6063-driver.patch   |  14 +--
 .../430-drivers-link-spi-before-mtd.patch          |   4 +-
 .../patches-4.9/432-spi-rb4xx-spi-driver.patch     |   6 +-
 .../patches-4.9/433-spi-rb4xx-cpld-driver.patch    |   4 +-
 .../patches-4.9/435-spi-vsc7385_driver.patch       |   6 +-
 .../440-leds-wndr3700-usb-led-driver.patch         |   8 +-
 .../patches-4.9/441-leds-rb750-led-driver.patch    |   4 +-
 .../450-gpio-nxp-74hc153-gpio-chip-driver.patch    |   4 +-
 ...io-74x164-improve-platform-device-support.patch |  66 ++++++------
 .../452-gpio-add-gpio-latch-driver.patch           |   4 +-
 .../460-m25p80-spi-read-flash-check.patch          |  15 ---
 .../490-usb-ehci-add-quirks-for-qca-socs.patch     |   6 +-
 .../ar71xx/patches-4.9/500-MIPS-fw-myloader.patch  |   4 +-
 ...504-MIPS-ath79-add-ath79_device_reset_get.patch |   5 +-
 ...MIPS-ath79-add-ath79_gpio_function_select.patch |   2 +-
 ...09-MIPS-ath79-process-board-kernel-option.patch |   4 +-
 .../602-MIPS-ath79-add-openwrt-stuff.patch         |   6 +-
 .../patches-4.9/611-MIPS-ath79-wdt-timeout.patch   |   2 +-
 ...20-MIPS-ath79-add-support-for-QCA953x-SoC.patch |  40 +++----
 ...21-MIPS-ath79-add-support-for-QCA956x-SoC.patch |  48 ++++-----
 .../630-MIPS-ath79-fix-chained-irq-disable.patch   |  26 +++--
 .../632-MIPS-ath79-gpio-enable-set-direction.patch |   2 +-
 ...MIPS-ath79-ar724x-clock-calculation-fixes.patch |  22 ----
 .../700-MIPS-ath79-add-openwrt-Kconfig.patch       |   6 +-
 .../818-MIPS-ath79-add-nu801-led-driver.patch      |   4 +-
 .../820-MIPS-ath79-add_gpio_function2_setup.patch  |   2 +-
 ...-add-support-for-boot-console-with-arbitr.patch |  76 --------------
 .../900-mdio_bitbang_ignore_ta_value.patch         |   9 ++
 ...tbang-prevent-rescheduling-during-command.patch |   6 +-
 .../902-at803x-add-reset-gpio-pdata.patch          |  10 +-
 .../patches-4.9/910-unaligned_access_hacks.patch   | 115 +++++++--------------
 .../ar71xx/patches-4.9/930-chipidea-pullup.patch   |   6 +-
 67 files changed, 883 insertions(+), 492 deletions(-)
 delete mode 100644 
target/linux/ar71xx/patches-4.9/101-MIPS-ath79-make-ath79_ddr_ctrl_init-compatible-for-n.patch
 delete mode 100644 
target/linux/ar71xx/patches-4.9/412-mtd-m25p80-zero-partition-parser-data.patch
 delete mode 100644 
target/linux/ar71xx/patches-4.9/460-m25p80-spi-read-flash-check.patch
 delete mode 100644 
target/linux/ar71xx/patches-4.9/634-MIPS-ath79-ar724x-clock-calculation-fixes.patch
 delete mode 100644 
target/linux/ar71xx/patches-4.9/821-serial-core-add-support-for-boot-console-with-arbitr.patch

diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
index 0e77560414..c5b89088f1 100644
--- a/target/linux/ar71xx/config-4.9
+++ b/target/linux/ar71xx/config-4.9
@@ -7,7 +7,6 @@ CONFIG_AR8216_PHY_LEDS=y
 CONFIG_ARCH_BINFMT_ELF_STATE=y
 CONFIG_ARCH_CLOCKSOURCE_DATA=y
 CONFIG_ARCH_DISCARD_MEMBLOCK=y
-CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
 CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
 # CONFIG_ARCH_HAS_GCOV_PROFILE_ALL is not set
 CONFIG_ARCH_HAS_RESET_CONTROLLER=y
@@ -15,7 +14,6 @@ CONFIG_ARCH_HAS_RESET_CONTROLLER=y
 CONFIG_ARCH_HIBERNATION_POSSIBLE=y
 CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
 CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y
-CONFIG_ARCH_REQUIRE_GPIOLIB=y
 CONFIG_ARCH_SUPPORTS_UPROBES=y
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
 CONFIG_ARCH_USE_BUILTIN_BSWAP=y
@@ -256,7 +254,7 @@ CONFIG_ATH79_NVRAM=y
 CONFIG_ATH79_PCI_ATH9K_FIXUP=y
 # CONFIG_ATH79_ROUTERBOOT is not set
 CONFIG_ATH79_WDT=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_BLK_MQ_PCI=y
 CONFIG_CEVT_R4K=y
 CONFIG_CLKDEV_LOOKUP=y
 CONFIG_CLONE_BACKWARDS=y
@@ -267,6 +265,7 @@ CONFIG_COMMON_CLK=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_CPU_GENERIC_DUMP_TLB=y
 CONFIG_CPU_HAS_PREFETCH=y
+CONFIG_CPU_HAS_RIXI=y
 CONFIG_CPU_HAS_SYNC=y
 CONFIG_CPU_MIPS32=y
 CONFIG_CPU_MIPS32_R2=y
@@ -284,6 +283,7 @@ CONFIG_DMA_NONCOHERENT=y
 CONFIG_DTC=y
 CONFIG_EARLY_PRINTK=y
 CONFIG_ETHERNET_PACKET_MANGLE=y
+CONFIG_FIXED_PHY=y
 CONFIG_GENERIC_ATOMIC64=y
 CONFIG_GENERIC_CLOCKEVENTS=y
 CONFIG_GENERIC_CMOS_UPDATE=y
@@ -297,11 +297,13 @@ CONFIG_GENERIC_TIME_VSYSCALL=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIOLIB_IRQCHIP=y
 CONFIG_GPIO_74X164=y
-CONFIG_GPIO_DEVRES=y
+CONFIG_GPIO_ATH79=y
+CONFIG_GPIO_GENERIC=y
 # CONFIG_GPIO_LATCH is not set
 CONFIG_GPIO_NXP_74HC153=y
 CONFIG_GPIO_PCF857X=y
 CONFIG_GPIO_SYSFS=y
+CONFIG_HANDLE_DOMAIN_IRQ=y
 CONFIG_HARDWARE_WATCHPOINTS=y
 CONFIG_HAS_DMA=y
 CONFIG_HAS_IOMEM=y
@@ -313,7 +315,7 @@ CONFIG_HAVE_ARCH_KGDB=y
 CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
 CONFIG_HAVE_ARCH_TRACEHOOK=y
 # CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
-CONFIG_HAVE_BPF_JIT=y
+CONFIG_HAVE_CBPF_JIT=y
 CONFIG_HAVE_CC_STACKPROTECTOR=y
 CONFIG_HAVE_CLK=y
 CONFIG_HAVE_CLK_PREPARE=y
@@ -322,7 +324,6 @@ CONFIG_HAVE_C_RECORDMCOUNT=y
 CONFIG_HAVE_DEBUG_KMEMLEAK=y
 CONFIG_HAVE_DEBUG_STACKOVERFLOW=y
 CONFIG_HAVE_DMA_API_DEBUG=y
-CONFIG_HAVE_DMA_ATTRS=y
 CONFIG_HAVE_DMA_CONTIGUOUS=y
 CONFIG_HAVE_DYNAMIC_FTRACE=y
 CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
@@ -340,6 +341,7 @@ CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
 CONFIG_HAVE_NET_DSA=y
 CONFIG_HAVE_OPROFILE=y
 CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
 CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
 CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
 CONFIG_HW_HAS_PCI=y
@@ -352,13 +354,13 @@ CONFIG_IMAGE_CMDLINE_HACK=y
 CONFIG_INITRAMFS_ROOT_GID=0
 CONFIG_INITRAMFS_ROOT_UID=0
 CONFIG_INITRAMFS_SOURCE="../../root"
+CONFIG_INTEL_XWAY_PHY=y
 CONFIG_IP17XX_PHY=y
 CONFIG_IRQCHIP=y
 CONFIG_IRQ_DOMAIN=y
 CONFIG_IRQ_FORCED_THREADING=y
 CONFIG_IRQ_MIPS_CPU=y
 CONFIG_IRQ_WORK=y
-CONFIG_LANTIQ_PHY=y
 CONFIG_LEDS_GPIO=y
 # CONFIG_LEDS_WNDR3700_USB is not set
 CONFIG_LIBFDT=y
@@ -368,7 +370,10 @@ CONFIG_MDIO_BOARDINFO=y
 CONFIG_MDIO_GPIO=y
 CONFIG_MICREL_PHY=y
 CONFIG_MIPS=y
+CONFIG_MIPS_ASID_BITS=8
+CONFIG_MIPS_ASID_SHIFT=0
 CONFIG_MIPS_CLOCK_VSYSCALL=y
+# CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND is not set
 # CONFIG_MIPS_CMDLINE_DTB_EXTEND is not set
 CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER=y
 # CONFIG_MIPS_CMDLINE_FROM_DTB is not set
@@ -421,7 +426,6 @@ CONFIG_OF_FLATTREE=y
 CONFIG_OF_GPIO=y
 CONFIG_OF_IRQ=y
 CONFIG_OF_MDIO=y
-CONFIG_OF_MTD=y
 CONFIG_OF_NET=y
 CONFIG_OF_PCI=y
 CONFIG_OF_PCI_IRQ=y
@@ -429,6 +433,7 @@ CONFIG_PCI=y
 CONFIG_PCI_AR724X=y
 CONFIG_PCI_DISABLE_COMMON_QUIRKS=y
 CONFIG_PCI_DOMAINS=y
+CONFIG_PCI_DRIVERS_LEGACY=y
 CONFIG_PERF_USE_VMALLOC=y
 CONFIG_PGTABLE_LEVELS=2
 CONFIG_PHYLIB=y
@@ -465,6 +470,7 @@ CONFIG_SPI_MASTER=y
 CONFIG_SRCU=y
 CONFIG_SWCONFIG=y
 CONFIG_SWCONFIG_LEDS=y
+CONFIG_SWPHY=y
 CONFIG_SYSCTL_EXCEPTION_TRACE=y
 CONFIG_SYS_HAS_CPU_MIPS32_R2=y
 CONFIG_SYS_HAS_EARLY_PRINTK=y
@@ -473,7 +479,7 @@ CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
 CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
 CONFIG_SYS_SUPPORTS_MIPS16=y
 CONFIG_SYS_SUPPORTS_ZBOOT=y
+CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM=y
 CONFIG_TICK_CPU_ACCOUNTING=y
 CONFIG_USB_SUPPORT=y
 CONFIG_USE_OF=y
-CONFIG_ZONE_DMA_FLAG=0
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-c60.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-c60.c
index e78e311d2e..7b01af515b 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-c60.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-c60.c
@@ -22,6 +22,7 @@
 #include <linux/platform/ar934x_nfc.h>
 #include <linux/ar8216_platform.h>
 #include <linux/ath9k_platform.h>
+#include <linux/version.h>
 
 #include <asm/mach-ath79/ar71xx_regs.h>
 
@@ -119,6 +120,7 @@ static struct mdio_board_info c60_mdio0_info[] = {
        },
 };
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 static struct nand_ecclayout c60_nand_ecclayout = {
        .eccbytes       = 7,
        .eccpos         = { 4, 8, 9, 10, 13, 14, 15 },
@@ -126,13 +128,67 @@ static struct nand_ecclayout c60_nand_ecclayout = {
        .oobfree        = { { 0, 3 }, { 6, 2 }, { 11, 2 }, }
 };
 
+#else
+
+static int c60_ooblayout_ecc(struct mtd_info *mtd, int section,
+                            struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 4;
+               oobregion->length = 1;
+               return 0;
+       case 1:
+               oobregion->offset = 8;
+               oobregion->length = 3;
+               return 0;
+       case 2:
+               oobregion->offset = 13;
+               oobregion->length = 3;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static int c60_ooblayout_free(struct mtd_info *mtd, int section,
+                             struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 0;
+               oobregion->length = 3;
+               return 0;
+       case 1:
+               oobregion->offset = 6;
+               oobregion->length = 2;
+               return 0;
+       case 2:
+               oobregion->offset = 11;
+               oobregion->length = 2;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops c60_nand_ecclayout_ops = {
+       .ecc = c60_ooblayout_ecc,
+       .free = c60_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static int c60_nand_scan_fixup(struct mtd_info *mtd)
 {
        struct nand_chip *chip = mtd->priv;
 
        chip->ecc.size = 512;
        chip->ecc.strength = 4;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
        chip->ecc.layout = &c60_nand_ecclayout;
+#else
+       mtd_set_ooblayout(mtd, &c60_nand_ecclayout_ops);
+#endif
        return 0;
 }
 
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c
index 6e498395bd..9100a5977a 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c
@@ -23,6 +23,7 @@
 #include <linux/spi/flash.h>
 #include <linux/routerboot.h>
 #include <linux/gpio.h>
+#include <linux/version.h>
 
 #include <asm/prom.h>
 #include <asm/mach-ath79/ath79.h>
@@ -188,6 +189,7 @@ static void rb2011_nand_select_chip(int chip_no)
        ndelay(500);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 static struct nand_ecclayout rb2011_nand_ecclayout = {
        .eccbytes       = 6,
        .eccpos         = { 8, 9, 10, 13, 14, 15 },
@@ -195,16 +197,72 @@ static struct nand_ecclayout rb2011_nand_ecclayout = {
        .oobfree        = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
 };
 
+#else
+
+static int rb2011_ooblayout_ecc(struct mtd_info *mtd, int section,
+                               struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 8;
+               oobregion->length = 3;
+               return 0;
+       case 1:
+               oobregion->offset = 13;
+               oobregion->length = 3;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static int rb2011_ooblayout_free(struct mtd_info *mtd, int section,
+                                struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 0;
+               oobregion->length = 4;
+               return 0;
+       case 1:
+               oobregion->offset = 4;
+               oobregion->length = 1;
+               return 0;
+       case 2:
+               oobregion->offset = 6;
+               oobregion->length = 2;
+               return 0;
+       case 3:
+               oobregion->offset = 11;
+               oobregion->length = 2;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops rb2011_nand_ecclayout_ops = {
+       .ecc = rb2011_ooblayout_ecc,
+       .free = rb2011_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static int rb2011_nand_scan_fixup(struct mtd_info *mtd)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
        struct nand_chip *chip = mtd->priv;
+#endif
 
        if (mtd->writesize == 512) {
                /*
                 * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
                 * will not be able to find the kernel that we load.
                 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                chip->ecc.layout = &rb2011_nand_ecclayout;
+#else
+               mtd_set_ooblayout(mtd, &rb2011_nand_ecclayout_ops);
+#endif
        }
 
        return 0;
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c
index 0c5373c365..577fb0eee0 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c
@@ -20,6 +20,7 @@
 #include <linux/routerboot.h>
 #include <linux/gpio.h>
 #include <linux/platform_data/phy-at803x.h>
+#include <linux/version.h>
 
 #include <asm/prom.h>
 #include <asm/mach-ath79/ath79.h>
@@ -132,6 +133,7 @@ static void rb922gs_nand_select_chip(int chip_no)
        ndelay(500);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 static struct nand_ecclayout rb922gs_nand_ecclayout = {
        .eccbytes       = 6,
        .eccpos         = { 8, 9, 10, 13, 14, 15 },
@@ -139,16 +141,72 @@ static struct nand_ecclayout rb922gs_nand_ecclayout = {
        .oobfree        = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
 };
 
+#else
+
+static int rb922gs_ooblayout_ecc(struct mtd_info *mtd, int section,
+                                struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 8;
+               oobregion->length = 3;
+               return 0;
+       case 1:
+               oobregion->offset = 13;
+               oobregion->length = 3;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static int rb922gs_ooblayout_free(struct mtd_info *mtd, int section,
+                                 struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 0;
+               oobregion->length = 4;
+               return 0;
+       case 1:
+               oobregion->offset = 4;
+               oobregion->length = 1;
+               return 0;
+       case 2:
+               oobregion->offset = 6;
+               oobregion->length = 2;
+               return 0;
+       case 3:
+               oobregion->offset = 11;
+               oobregion->length = 2;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops rb922gs_nand_ecclayout_ops = {
+       .ecc = rb922gs_ooblayout_ecc,
+       .free = rb922gs_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static int rb922gs_nand_scan_fixup(struct mtd_info *mtd)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
        struct nand_chip *chip = mtd->priv;
+#endif
 
        if (mtd->writesize == 512) {
                /*
                 * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
                 * will not be able to find the kernel that we load.
                 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                chip->ecc.layout = &rb922gs_nand_ecclayout;
+#else
+               mtd_set_ooblayout(mtd, &rb922gs_nand_ecclayout_ops);
+#endif
        }
 
        return 0;
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb95x.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb95x.c
index e940d6cc11..9eaeaa7f9d 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb95x.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb95x.c
@@ -24,6 +24,7 @@
 #include <linux/spi/flash.h>
 #include <linux/routerboot.h>
 #include <linux/gpio.h>
+#include <linux/version.h>
 
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
@@ -146,6 +147,7 @@ static void rb95x_nand_select_chip(int chip_no)
        ndelay(500);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 static struct nand_ecclayout rb95x_nand_ecclayout = {
        .eccbytes       = 6,
        .eccpos         = { 8, 9, 10, 13, 14, 15 },
@@ -153,6 +155,56 @@ static struct nand_ecclayout rb95x_nand_ecclayout = {
        .oobfree        = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
 };
 
+#else
+
+static int rb95x_ooblayout_ecc(struct mtd_info *mtd, int section,
+                              struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 8;
+               oobregion->length = 3;
+               return 0;
+       case 1:
+               oobregion->offset = 13;
+               oobregion->length = 3;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static int rb95x_ooblayout_free(struct mtd_info *mtd, int section,
+                               struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 0;
+               oobregion->length = 4;
+               return 0;
+       case 1:
+               oobregion->offset = 4;
+               oobregion->length = 1;
+               return 0;
+       case 2:
+               oobregion->offset = 6;
+               oobregion->length = 2;
+               return 0;
+       case 3:
+               oobregion->offset = 11;
+               oobregion->length = 2;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops rb95x_nand_ecclayout_ops = {
+       .ecc = rb95x_ooblayout_ecc,
+       .free = rb95x_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static int rb95x_nand_scan_fixup(struct mtd_info *mtd)
 {
        struct nand_chip *chip = mtd->priv;
@@ -162,7 +214,11 @@ static int rb95x_nand_scan_fixup(struct mtd_info *mtd)
                 * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
                 * will not be able to find the kernel that we load.
                 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                chip->ecc.layout = &rb95x_nand_ecclayout;
+#else
+               mtd_set_ooblayout(mtd, &rb95x_nand_ecclayout_ops);
+#endif
        }
 
        chip->options = NAND_NO_SUBPAGE_WRITE;
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rbsxtlite.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-rbsxtlite.c
index 62063e06a2..d2edfc9c71 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-rbsxtlite.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rbsxtlite.c
@@ -24,6 +24,7 @@
 #include <linux/rle.h>
 #include <linux/routerboot.h>
 #include <linux/gpio.h>
+#include <linux/version.h>
 
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
@@ -163,6 +164,7 @@ static void rbsxtlite_nand_select_chip(int chip_no)
        ndelay(500);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 static struct nand_ecclayout rbsxtlite_nand_ecclayout = {
        .eccbytes       = 6,
        .eccpos  = { 8, 9, 10, 13, 14, 15 },
@@ -170,16 +172,72 @@ static struct nand_ecclayout rbsxtlite_nand_ecclayout = {
        .oobfree        = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
 };
 
+#else
+
+static int rbsxtlite_ooblayout_ecc(struct mtd_info *mtd, int section,
+                                  struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 8;
+               oobregion->length = 3;
+               return 0;
+       case 1:
+               oobregion->offset = 13;
+               oobregion->length = 3;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static int rbsxtlite_ooblayout_free(struct mtd_info *mtd, int section,
+                                   struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 0;
+               oobregion->length = 4;
+               return 0;
+       case 1:
+               oobregion->offset = 4;
+               oobregion->length = 1;
+               return 0;
+       case 2:
+               oobregion->offset = 6;
+               oobregion->length = 2;
+               return 0;
+       case 3:
+               oobregion->offset = 11;
+               oobregion->length = 2;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops rbsxtlite_nand_ecclayout_ops = {
+       .ecc = rbsxtlite_ooblayout_ecc,
+       .free = rbsxtlite_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static int rbsxtlite_nand_scan_fixup(struct mtd_info *mtd)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
        struct nand_chip *chip = mtd->priv;
+#endif
 
        if (mtd->writesize == 512) {
                /*
                * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
                * will not be able to find the kernel that we load.
                */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                chip->ecc.layout = &rbsxtlite_nand_ecclayout;
+#else
+               mtd_set_ooblayout(mtd, &rbsxtlite_nand_ecclayout_ops);
+#endif
        }
 
        return 0;
diff --git a/target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c 
b/target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c
index 8c01efe4a0..1355e3ff6e 100644
--- a/target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c
+++ b/target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c
@@ -168,7 +168,11 @@ static int nxp_74hc153_probe(struct platform_device *pdev)
        gc->base = pdata->gpio_base;
        gc->ngpio = NXP_74HC153_NUM_GPIOS;
        gc->label = dev_name(nxp->parent);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
        gc->dev = nxp->parent;
+#else
+       gc->parent = nxp->parent;
+#endif
        gc->owner = THIS_MODULE;
 
        err = gpiochip_add(&nxp->gpio_chip);
diff --git a/target/linux/ar71xx/files/drivers/mtd/cybertan_part.c 
b/target/linux/ar71xx/files/drivers/mtd/cybertan_part.c
index 391411f8de..4d33c19b7e 100644
--- a/target/linux/ar71xx/files/drivers/mtd/cybertan_part.c
+++ b/target/linux/ar71xx/files/drivers/mtd/cybertan_part.c
@@ -28,6 +28,7 @@
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/version.h>
 
 struct cybertan_header {
        char    magic[4];
@@ -82,7 +83,11 @@ struct firmware_header {
 #define NVRAM_LEN      0x10000
 
 static int cybertan_parse_partitions(struct mtd_info *master,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
                                     struct mtd_partition **pparts,
+#else
+                                    const struct mtd_partition **pparts,
+#endif
                                     struct mtd_part_parser_data *data)
 {
        struct firmware_header *header;
diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c 
b/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c
index a47fc0468e..4b67fd63b6 100644
--- a/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c
+++ b/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c
@@ -18,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
+#include <linux/version.h>
 
 #include <linux/platform/ar934x_nfc.h>
 
@@ -1241,6 +1242,7 @@ ar934x_nfc_init_tail(struct mtd_info *mtd)
        return err;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 static struct nand_ecclayout ar934x_nfc_oob_64_hwecc = {
        .eccbytes = 28,
        .eccpos = {
@@ -1261,14 +1263,54 @@ static struct nand_ecclayout ar934x_nfc_oob_64_hwecc = {
        },
 };
 
+#else
+
+static int ar934x_nfc_ooblayout_ecc(struct mtd_info *mtd, int section,
+                                   struct mtd_oob_region *oobregion)
+{
+       if (section)
+               return -ERANGE;
+
+       oobregion->offset = 20;
+       oobregion->length = 28;
+
+       return 0;
+}
+
+static int ar934x_nfc_ooblayout_free(struct mtd_info *mtd, int section,
+                                    struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 4;
+               oobregion->length = 16;
+               return 0;
+       case 1:
+               oobregion->offset = 48;
+               oobregion->length = 16;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops ar934x_nfc_ecclayout_ops = {
+       .ecc = ar934x_nfc_ooblayout_ecc,
+       .free = ar934x_nfc_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static int
 ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc)
 {
        struct nand_chip *nand = &nfc->nand_chip;
        u32 ecc_cap;
        u32 ecc_thres;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+       struct mtd_oob_region oobregion;
+#endif
 
-       if (!config_enabled(CONFIG_MTD_NAND_AR934X_HW_ECC)) {
+       if (!IS_ENABLED(CONFIG_MTD_NAND_AR934X_HW_ECC)) {
                dev_err(nfc->parent, "hardware ECC support is disabled\n");
                return -EINVAL;
        }
@@ -1284,7 +1326,11 @@ ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc)
                nand->ecc.size = 512;
                nand->ecc.bytes = 7;
                nand->ecc.strength = 4;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                nand->ecc.layout = &ar934x_nfc_oob_64_hwecc;
+#else
+               mtd_set_ooblayout(&nfc->mtd, &ar934x_nfc_ecclayout_ops);
+#endif
                break;
 
        default:
@@ -1294,7 +1340,11 @@ ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc)
                return -EINVAL;
        }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
        BUG_ON(!nand->ecc.layout);
+#else
+       BUG_ON(!nfc->mtd.ooblayout->ecc);
+#endif
 
        switch (nand->ecc.strength) {
        case 4:
@@ -1309,7 +1359,12 @@ ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc)
        }
 
        nfc->ecc_thres = ecc_thres;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
        nfc->ecc_oob_pos = nand->ecc.layout->eccpos[0];
+#else
+       nfc->mtd.ooblayout->ecc(&nfc->mtd, 0, &oobregion);
+       nfc->ecc_oob_pos = oobregion.offset;
+#endif
 
        nfc->ecc_ctrl_reg = ecc_cap << AR934X_NFC_ECC_CTRL_ECC_CAP_S;
        nfc->ecc_ctrl_reg |= ecc_thres << AR934X_NFC_ECC_CTRL_ERR_THRES_S;
@@ -1432,7 +1487,12 @@ ar934x_nfc_probe(struct platform_device *pdev)
                break;
 
        case AR934X_NFC_ECC_SOFT_BCH:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                nand->ecc.mode = NAND_ECC_SOFT_BCH;
+#else
+               nand->ecc.mode = NAND_ECC_SOFT;
+               nand->ecc.algo = NAND_ECC_BCH;
+#endif
                break;
 
        case AR934X_NFC_ECC_HW:
diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c 
b/target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c
index 96ec5dd1e5..b397575f77 100644
--- a/target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c
+++ b/target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c
@@ -23,6 +23,7 @@
 #include <linux/io.h>
 #include <linux/gpio.h>
 #include <linux/slab.h>
+#include <linux/version.h>
 
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/rb4xx_cpld.h>
@@ -41,6 +42,7 @@ struct rb4xx_nand_info {
        struct mtd_info         mtd;
 };
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 /*
  * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
  * will not be able to find the kernel that we load.
@@ -52,6 +54,56 @@ static struct nand_ecclayout rb4xx_nand_ecclayout = {
        .oobfree        = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
 };
 
+#else
+
+static int rb4xx_ooblayout_ecc(struct mtd_info *mtd, int section,
+                              struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 8;
+               oobregion->length = 3;
+               return 0;
+       case 1:
+               oobregion->offset = 13;
+               oobregion->length = 3;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static int rb4xx_ooblayout_free(struct mtd_info *mtd, int section,
+                               struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 0;
+               oobregion->length = 4;
+               return 0;
+       case 1:
+               oobregion->offset = 4;
+               oobregion->length = 1;
+               return 0;
+       case 2:
+               oobregion->offset = 6;
+               oobregion->length = 2;
+               return 0;
+       case 3:
+               oobregion->offset = 11;
+               oobregion->length = 2;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops rb4xx_nand_ecclayout_ops = {
+       .ecc = rb4xx_ooblayout_ecc,
+       .free = rb4xx_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static struct mtd_partition rb4xx_nand_partitions[] = {
        {
                .name   = "booter",
@@ -229,7 +281,11 @@ static int rb4xx_nand_probe(struct platform_device *pdev)
        }
 
        if (info->mtd.writesize == 512)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                info->chip.ecc.layout = &rb4xx_nand_ecclayout;
+#else
+               mtd_set_ooblayout(&info->mtd, &rb4xx_nand_ecclayout_ops);
+#endif
 
        ret = nand_scan_tail(&info->mtd);
        if (ret) {
diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c 
b/target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c
index 0604c5a235..f8a6722cba 100644
--- a/target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c
+++ b/target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/version.h>
 
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/ath79.h>
@@ -49,6 +50,7 @@ static inline struct rb750_nand_info *mtd_to_rbinfo(struct 
mtd_info *mtd)
        return container_of(mtd, struct rb750_nand_info, mtd);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 /*
  * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
  * will not be able to find the kernel that we load.
@@ -60,6 +62,56 @@ static struct nand_ecclayout rb750_nand_ecclayout = {
        .oobfree        = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
 };
 
+#else
+
+static int rb750_ooblayout_ecc(struct mtd_info *mtd, int section,
+                              struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 8;
+               oobregion->length = 3;
+               return 0;
+       case 1:
+               oobregion->offset = 13;
+               oobregion->length = 3;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static int rb750_ooblayout_free(struct mtd_info *mtd, int section,
+                               struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 0;
+               oobregion->length = 4;
+               return 0;
+       case 1:
+               oobregion->offset = 4;
+               oobregion->length = 1;
+               return 0;
+       case 2:
+               oobregion->offset = 6;
+               oobregion->length = 2;
+               return 0;
+       case 3:
+               oobregion->offset = 11;
+               oobregion->length = 2;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops rb750_nand_ecclayout_ops = {
+       .ecc = rb750_ooblayout_ecc,
+       .free = rb750_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static struct mtd_partition rb750_nand_partitions[] = {
        {
                .name   = "booter",
@@ -292,7 +344,11 @@ static int rb750_nand_probe(struct platform_device *pdev)
        }
 
        if (info->mtd.writesize == 512)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                info->chip.ecc.layout = &rb750_nand_ecclayout;
+#else
+               mtd_set_ooblayout(&info->mtd, &rb750_nand_ecclayout_ops);
+#endif
 
        ret = nand_scan_tail(&info->mtd);
        if (ret) {
diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c 
b/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c
index 1308e18ba6..15b1816ae1 100644
--- a/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c
+++ b/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/platform_data/rb91x_nand.h>
+#include <linux/version.h>
 
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/ath79.h>
@@ -56,6 +57,7 @@ static inline struct rb91x_nand_info *mtd_to_rbinfo(struct 
mtd_info *mtd)
        return container_of(mtd, struct rb91x_nand_info, mtd);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
 /*
  * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
  * will not be able to find the kernel that we load.
@@ -67,6 +69,56 @@ static struct nand_ecclayout rb91x_nand_ecclayout = {
        .oobfree        = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
 };
 
+#else
+
+static int rb91x_ooblayout_ecc(struct mtd_info *mtd, int section,
+                              struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 8;
+               oobregion->length = 3;
+               return 0;
+       case 1:
+               oobregion->offset = 13;
+               oobregion->length = 3;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static int rb91x_ooblayout_free(struct mtd_info *mtd, int section,
+                               struct mtd_oob_region *oobregion)
+{
+       switch (section) {
+       case 0:
+               oobregion->offset = 0;
+               oobregion->length = 4;
+               return 0;
+       case 1:
+               oobregion->offset = 4;
+               oobregion->length = 1;
+               return 0;
+       case 2:
+               oobregion->offset = 6;
+               oobregion->length = 2;
+               return 0;
+       case 3:
+               oobregion->offset = 11;
+               oobregion->length = 2;
+               return 0;
+       default:
+               return -ERANGE;
+       }
+}
+
+static const struct mtd_ooblayout_ops rb91x_nand_ecclayout_ops = {
+       .ecc = rb91x_ooblayout_ecc,
+       .free = rb91x_ooblayout_free,
+};
+#endif /* < 4.6 */
+
 static struct mtd_partition rb91x_nand_partitions[] = {
        {
                .name   = "booter",
@@ -334,7 +386,11 @@ static int rb91x_nand_probe(struct platform_device *pdev)
                return ret;
 
        if (rbni->mtd.writesize == 512)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
                rbni->chip.ecc.layout = &rb91x_nand_ecclayout;
+#else
+               mtd_set_ooblayout(&rbni->mtd, &rb91x_nand_ecclayout_ops);
+#endif
 
        ret = nand_scan_tail(&rbni->mtd);
        if (ret)
diff --git a/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c 
b/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c
index ac1efa1c22..1b94163b83 100644
--- a/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c
+++ b/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c
@@ -15,6 +15,7 @@
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/version.h>
 
 #define TPLINK_NUM_PARTS       5
 #define TPLINK_HEADER_V1       0x01000000
@@ -109,7 +110,11 @@ static int tplink_check_rootfs_magic(struct mtd_info *mtd, 
size_t offset)
 }
 
 static int tplink_parse_partitions_offset(struct mtd_info *master,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
                                   struct mtd_partition **pparts,
+#else
+                                  const struct mtd_partition **pparts,
+#endif
                                   struct mtd_part_parser_data *data,
                                   size_t offset)
 {
@@ -181,7 +186,11 @@ err:
 }
 
 static int tplink_parse_partitions(struct mtd_info *master,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
                                   struct mtd_partition **pparts,
+#else
+                                  const struct mtd_partition **pparts,
+#endif
                                   struct mtd_part_parser_data *data)
 {
        return tplink_parse_partitions_offset(master, pparts, data,
@@ -189,7 +198,11 @@ static int tplink_parse_partitions(struct mtd_info *master,
 }
 
 static int tplink_parse_64k_partitions(struct mtd_info *master,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
                                   struct mtd_partition **pparts,
+#else
+                                  const struct mtd_partition **pparts,
+#endif
                                   struct mtd_part_parser_data *data)
 {
        return tplink_parse_partitions_offset(master, pparts, data,
diff --git a/target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c 
b/target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c
index b9e9af35b8..5b6da713f4 100644
--- a/target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c
+++ b/target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c
@@ -17,6 +17,7 @@
 #include <linux/netdevice.h>
 #include <linux/phy.h>
 #include <net/dsa.h>
+#include <linux/version.h>
 
 #define REG_BASE               0x10
 #define REG_PHY(p)             (REG_BASE + (p))
@@ -26,11 +27,12 @@
 
 static int reg_read(struct dsa_switch *ds, int addr, int reg)
 {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
-       return mdiobus_read(ds->master_mii_bus, addr, reg);
-#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
        struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);
        return mdiobus_read(bus, addr, reg);
+#else
+       struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->dev);
+       return mdiobus_read(bus, addr, reg);
 #endif
 }
 
@@ -47,14 +49,22 @@ static int reg_read(struct dsa_switch *ds, int addr, int 
reg)
 
 static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
 {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
-       return mdiobus_write(ds->master_mii_bus, addr, reg, val);
-#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
        struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);
        return mdiobus_write(bus, addr, reg, val);
+#else
+       struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->dev);
+       return mdiobus_write(bus, addr, reg, val);
 #endif
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0)
+static enum dsa_tag_protocol mv88e6063_get_tag_protocol(struct dsa_switch *ds)
+{
+       return DSA_TAG_PROTO_TRAILER;
+}
+#endif
+
 #define REG_WRITE(addr, reg, val)                              \
        ({                                                      \
                int __ret;                                      \
@@ -64,16 +74,20 @@ static int reg_write(struct dsa_switch *ds, int addr, int 
reg, u16 val)
                        return __ret;                           \
        })
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
-static char *mv88e6063_probe(struct mii_bus *bus, int sw_addr)
-{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
+static char *mv88e6063_drv_probe(struct device *host_dev, int sw_addr)
 #else
-static char *mv88e6063_probe(struct device *host_dev, int sw_addr)
+static const char *mv88e6063_drv_probe(struct device *dsa_dev,
+                                      struct device *host_dev, int sw_addr,
+                                      void **_priv)
+#endif
 {
        struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
-#endif
        int ret;
 
+       if (!bus)
+               return NULL;
+
        ret = mdiobus_read(bus, REG_PORT(0), 0x03);
        if (ret >= 0) {
                ret &= 0xfff0;
@@ -163,7 +177,11 @@ static int mv88e6063_setup_port(struct dsa_switch *ds, int 
p)
        REG_WRITE(addr, 0x06,
                        ((p & 0xf) << 12) |
                         (dsa_is_cpu_port(ds, p) ?
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
                                ds->phys_port_mask :
+#else
+                               ds->enabled_port_mask :
+#endif
                                (1 << ds->dst->cpu_port)));
 
        /*
@@ -240,72 +258,32 @@ mv88e6063_phy_write(struct dsa_switch *ds, int port, int 
regnum, u16 val)
        return reg_write(ds, addr, regnum, val);
 }
 
-static void mv88e6063_poll_link(struct dsa_switch *ds)
-{
-       int i;
-
-       for (i = 0; i < DSA_MAX_PORTS; i++) {
-               struct net_device *dev;
-               int uninitialized_var(port_status);
-               int link;
-               int speed;
-               int duplex;
-               int fc;
-
-               dev = ds->ports[i];
-               if (dev == NULL)
-                       continue;
-
-               link = 0;
-               if (dev->flags & IFF_UP) {
-                       port_status = reg_read(ds, REG_PORT(i), 0x00);
-                       if (port_status < 0)
-                               continue;
-
-                       link = !!(port_status & 0x1000);
-               }
-
-               if (!link) {
-                       if (netif_carrier_ok(dev)) {
-                               printk(KERN_INFO "%s: link down\n", dev->name);
-                               netif_carrier_off(dev);
-                       }
-                       continue;
-               }
-
-               speed = (port_status & 0x0100) ? 100 : 10;
-               duplex = (port_status & 0x0200) ? 1 : 0;
-               fc = ((port_status & 0xc000) == 0xc000) ? 1 : 0;
-
-               if (!netif_carrier_ok(dev)) {
-                       printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, "
-                                        "flow control %sabled\n", dev->name,
-                                        speed, duplex ? "full" : "half",
-                                        fc ? "en" : "dis");
-                       netif_carrier_on(dev);
-               }
-       }
-}
-
-static struct dsa_switch_driver mv88e6063_switch_driver = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
+static struct dsa_switch_driver mv88e6063_switch_ops = {
+#else
+static struct dsa_switch_ops mv88e6063_switch_ops = {
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
        .tag_protocol   = htons(ETH_P_TRAILER),
-       .probe          = mv88e6063_probe,
+#else
+       .get_tag_protocol = mv88e6063_get_tag_protocol,
+#endif
+       .probe          = mv88e6063_drv_probe,
        .setup          = mv88e6063_setup,
        .set_addr       = mv88e6063_set_addr,
        .phy_read       = mv88e6063_phy_read,
        .phy_write      = mv88e6063_phy_write,
-       .poll_link      = mv88e6063_poll_link,
 };
 
 static int __init mv88e6063_init(void)
 {
-       register_switch_driver(&mv88e6063_switch_driver);
+       register_switch_driver(&mv88e6063_switch_ops);
        return 0;
 }
 module_init(mv88e6063_init);
 
 static void __exit mv88e6063_cleanup(void)
 {
-       unregister_switch_driver(&mv88e6063_switch_driver);
+       unregister_switch_driver(&mv88e6063_switch_ops);
 }
 module_exit(mv88e6063_cleanup);
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
index b63a4b7f9d..2915476569 100644
--- 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
+++ 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
@@ -254,7 +254,11 @@ static int ag71xx_mdio_probe(struct platform_device *pdev)
        am->mii_bus->read = ag71xx_mdio_read;
        am->mii_bus->write = ag71xx_mdio_write;
        am->mii_bus->reset = ag71xx_mdio_reset;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
        am->mii_bus->irq = am->mii_irq;
+#else
+       memcpy(am->mii_bus->irq, am->mii_irq, sizeof(am->mii_bus->irq));
+#endif
        am->mii_bus->priv = am;
        am->mii_bus->parent = &pdev->dev;
        snprintf(am->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(&pdev->dev));
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
index 9de77e924b..12fa2e301b 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
@@ -112,6 +112,7 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
                if (!(pdata->phy_mask & (1 << phy_addr)))
                        continue;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
                if (ag->mii_bus->phy_map[phy_addr] == NULL)
                        continue;
 
@@ -122,6 +123,18 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
 
                if (phydev == NULL)
                        phydev = ag->mii_bus->phy_map[phy_addr];
+#else
+               if (ag->mii_bus->mdio_map[phy_addr] == NULL)
+                       continue;
+
+               DBG("%s: PHY found at %s, uid=%08x\n",
+                       dev_name(dev),
+                       dev_name(&ag->mii_bus->mdio_map[phy_addr]->dev),
+                       ag->mii_bus->mdio_map[phy_addr]->phy_id);
+
+               if (phydev == NULL)
+                       phydev = mdiobus_get_phy(ag->mii_bus, phy_addr);
+#endif
        }
 
        if (!phydev) {
@@ -130,13 +143,21 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
                return -ENODEV;
        }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
        ag->phy_dev = phy_connect(ag->dev, dev_name(&phydev->dev),
+#else
+       ag->phy_dev = phy_connect(ag->dev, phydev_name(phydev),
+#endif
                                  &ag71xx_phy_link_adjust,
                                  pdata->phy_if_mode);
 
        if (IS_ERR(ag->phy_dev)) {
                dev_err(dev, "could not connect to PHY at %s\n",
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
                           dev_name(&phydev->dev));
+#else
+                          phydev_name(phydev));
+#endif
                return PTR_ERR(ag->phy_dev);
        }
 
@@ -149,7 +170,12 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
        phydev->advertising = phydev->supported;
 
        dev_info(dev, "connected to PHY at %s [uid=%08x, driver=%s]\n",
-                   dev_name(&phydev->dev), phydev->phy_id, phydev->drv->name);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
+                   dev_name(&phydev->dev),
+#else
+                   phydev_name(phydev),
+#endif
+                   phydev->phy_id, phydev->drv->name);
 
        ag->link = 0;
        ag->speed = 0;
diff --git a/target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c 
b/target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c
index 0534c7c374..18af83b67c 100644
--- a/target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c
+++ b/target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c
@@ -21,6 +21,7 @@
 #include <linux/spi/spi.h>
 #include <linux/gpio.h>
 #include <linux/slab.h>
+#include <linux/version.h>
 
 #include <asm/mach-ath79/rb4xx_cpld.h>
 
@@ -246,7 +247,11 @@ static int rb4xx_cpld_gpio_init(struct rb4xx_cpld *cpld, 
unsigned int base)
        cpld->chip.base = base;
        cpld->chip.ngpio = CPLD_NUM_GPIOS;
        cpld->chip.can_sleep = 1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
        cpld->chip.dev = &cpld->spi->dev;
+#else
+       cpld->chip.parent = &cpld->spi->dev;
+#endif
        cpld->chip.owner = THIS_MODULE;
 
        err = gpiochip_add(&cpld->chip);
diff --git a/target/linux/ar71xx/mikrotik/config-default 
b/target/linux/ar71xx/mikrotik/config-default
index 3ff5379cc4..e333166e93 100644
--- a/target/linux/ar71xx/mikrotik/config-default
+++ b/target/linux/ar71xx/mikrotik/config-default
@@ -215,7 +215,7 @@ CONFIG_ATH79_ROUTERBOOT=y
 CONFIG_CRC16=y
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_GPIO_LATCH=y
-# CONFIG_LANTIQ_PHY is not set
+# CONFIG_INTEL_XWAY_PHY is not set
 CONFIG_LEDS_RB750=y
 CONFIG_LZO_DECOMPRESS=y
 # CONFIG_MTD_CFI is not set
diff --git a/target/linux/ar71xx/nand/config-default 
b/target/linux/ar71xx/nand/config-default
index ec9d550f22..fc243c5008 100644
--- a/target/linux/ar71xx/nand/config-default
+++ b/target/linux/ar71xx/nand/config-default
@@ -212,8 +212,8 @@ CONFIG_BCH=y
 CONFIG_CRC16=y
 CONFIG_CRYPTO_DEFLATE=y
 CONFIG_CRYPTO_LZO=y
+# CONFIG_INTEL_XWAY_PHY is not set
 # CONFIG_IP17XX_PHY is not set
-# CONFIG_LANTIQ_PHY is not set
 CONFIG_LEDS_NU801=y
 CONFIG_LZO_COMPRESS=y
 CONFIG_LZO_DECOMPRESS=y
diff --git 
a/target/linux/ar71xx/patches-4.9/002-add_back_gpio_function_select.patch 
b/target/linux/ar71xx/patches-4.9/002-add_back_gpio_function_select.patch
index 73cfeb5506..5b26a640eb 100644
--- a/target/linux/ar71xx/patches-4.9/002-add_back_gpio_function_select.patch
+++ b/target/linux/ar71xx/patches-4.9/002-add_back_gpio_function_select.patch
@@ -62,8 +62,8 @@
 +}
 --- a/arch/mips/include/asm/mach-ath79/ath79.h
 +++ b/arch/mips/include/asm/mach-ath79/ath79.h
-@@ -117,6 +117,7 @@ static inline int soc_is_qca955x(void)
- 
+@@ -118,6 +118,7 @@ static inline int soc_is_qca955x(void)
+ void ath79_ddr_wb_flush(unsigned int reg);
  void ath79_ddr_set_pci_windows(void);
  
 +extern void __iomem *ath79_gpio_base;
@@ -80,9 +80,9 @@
  }
 --- a/arch/mips/ath79/common.h
 +++ b/arch/mips/ath79/common.h
-@@ -25,6 +25,9 @@ unsigned long ath79_get_sys_clk_rate(con
+@@ -24,6 +24,9 @@ unsigned long ath79_get_sys_clk_rate(con
+ 
  void ath79_ddr_ctrl_init(void);
- void ath79_ddr_wb_flush(unsigned int reg);
  
 +void ath79_gpio_function_enable(u32 mask);
 +void ath79_gpio_function_disable(u32 mask);
diff --git 
a/target/linux/ar71xx/patches-4.9/004-register_gpio_driver_earlier.patch 
b/target/linux/ar71xx/patches-4.9/004-register_gpio_driver_earlier.patch
index 0c07cb18c7..e6e972b7ef 100644
--- a/target/linux/ar71xx/patches-4.9/004-register_gpio_driver_earlier.patch
+++ b/target/linux/ar71xx/patches-4.9/004-register_gpio_driver_earlier.patch
@@ -3,8 +3,8 @@ from mach files succeed.
 
 --- a/drivers/gpio/gpio-ath79.c
 +++ b/drivers/gpio/gpio-ath79.c
-@@ -202,4 +202,8 @@ static struct platform_driver ath79_gpio
-       .probe = ath79_gpio_probe,
+@@ -322,4 +322,8 @@ static struct platform_driver ath79_gpio
+       .remove = ath79_gpio_remove,
  };
  
 -module_platform_driver(ath79_gpio_driver);
diff --git 
a/target/linux/ar71xx/patches-4.9/101-MIPS-ath79-make-ath79_ddr_ctrl_init-compatible-for-n.patch
 
b/target/linux/ar71xx/patches-4.9/101-MIPS-ath79-make-ath79_ddr_ctrl_init-compatible-for-n.patch
deleted file mode 100644
index 09e6617b90..0000000000
--- 
a/target/linux/ar71xx/patches-4.9/101-MIPS-ath79-make-ath79_ddr_ctrl_init-compatible-for-n.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From: Felix Fietkau <n...@nbd.name>
-Date: Sat, 14 May 2016 20:20:04 +0200
-Subject: [PATCH] MIPS: ath79: make ath79_ddr_ctrl_init() compatible for newer
- SoCs
-
-AR913x, AR724x and AR933x are the only SoCs where the
-ath79_ddr_wb_flush_base starts at 0x7c, all newer SoCs use 0x9c
-Invert the logic to make the code compatible with AR95xx
-
-Signed-off-by: Felix Fietkau <n...@nbd.name>
----
-
---- a/arch/mips/ath79/common.c
-+++ b/arch/mips/ath79/common.c
-@@ -46,12 +46,12 @@ void ath79_ddr_ctrl_init(void)
- {
-       ath79_ddr_base = ioremap_nocache(AR71XX_DDR_CTRL_BASE,
-                                        AR71XX_DDR_CTRL_SIZE);
--      if (soc_is_ar71xx() || soc_is_ar934x()) {
--              ath79_ddr_wb_flush_base = ath79_ddr_base + 0x9c;
--              ath79_ddr_pci_win_base = ath79_ddr_base + 0x7c;
--      } else {
-+      if (soc_is_ar913x() || soc_is_ar724x() || soc_is_ar933x()) {
-               ath79_ddr_wb_flush_base = ath79_ddr_base + 0x7c;
-               ath79_ddr_pci_win_base = 0;
-+      } else {
-+              ath79_ddr_wb_flush_base = ath79_ddr_base + 0x9c;
-+              ath79_ddr_pci_win_base = ath79_ddr_base + 0x7c;
-       }
- }
- EXPORT_SYMBOL_GPL(ath79_ddr_ctrl_init);
diff --git 
a/target/linux/ar71xx/patches-4.9/106-02-MIPS-ath79-do-AR724x-PCIe-root-complex-init.patch
 
b/target/linux/ar71xx/patches-4.9/106-02-MIPS-ath79-do-AR724x-PCIe-root-complex-init.patch
index d3948b8353..3af99bf3b5 100644
--- 
a/target/linux/ar71xx/patches-4.9/106-02-MIPS-ath79-do-AR724x-PCIe-root-complex-init.patch
+++ 
b/target/linux/ar71xx/patches-4.9/106-02-MIPS-ath79-do-AR724x-PCIe-root-complex-init.patch
@@ -43,7 +43,7 @@ Signed-off-by: Mathias Kresin <d...@kresin.me>
 @@ -12,14 +12,18 @@
  #include <linux/irq.h>
  #include <linux/pci.h>
- #include <linux/module.h>
+ #include <linux/init.h>
 +#include <linux/delay.h>
  #include <linux/platform_device.h>
  #include <asm/mach-ath79/ath79.h>
diff --git a/target/linux/ar71xx/patches-4.9/203-MIPS-ath79-fix-restart.patch 
b/target/linux/ar71xx/patches-4.9/203-MIPS-ath79-fix-restart.patch
index 77773ea920..48f4d95e74 100644
--- a/target/linux/ar71xx/patches-4.9/203-MIPS-ath79-fix-restart.patch
+++ b/target/linux/ar71xx/patches-4.9/203-MIPS-ath79-fix-restart.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/ath79/setup.c
 +++ b/arch/mips/ath79/setup.c
-@@ -44,6 +44,7 @@ static char ath79_sys_type[ATH79_SYS_TYP
+@@ -40,6 +40,7 @@ static char ath79_sys_type[ATH79_SYS_TYP
  
  static void ath79_restart(char *command)
  {
@@ -10,7 +10,7 @@
                if (cpu_wait)
 --- a/arch/mips/include/asm/mach-ath79/ath79.h
 +++ b/arch/mips/include/asm/mach-ath79/ath79.h
-@@ -134,6 +134,7 @@ static inline u32 ath79_pll_rr(unsigned
+@@ -135,6 +135,7 @@ static inline u32 ath79_pll_rr(unsigned
  static inline void ath79_reset_wr(unsigned reg, u32 val)
  {
        __raw_writel(val, ath79_reset_base + reg);
diff --git 
a/target/linux/ar71xx/patches-4.9/310-lib-add-rle-decompression.patch 
b/target/linux/ar71xx/patches-4.9/310-lib-add-rle-decompression.patch
index f5466db176..d8480125a9 100644
--- a/target/linux/ar71xx/patches-4.9/310-lib-add-rle-decompression.patch
+++ b/target/linux/ar71xx/patches-4.9/310-lib-add-rle-decompression.patch
@@ -12,7 +12,7 @@
  # ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)
 --- a/lib/Makefile
 +++ b/lib/Makefile
-@@ -110,6 +110,7 @@ obj-$(CONFIG_XZ_DEC) += xz/
+@@ -120,6 +120,7 @@ obj-$(CONFIG_XZ_DEC) += xz/
  obj-$(CONFIG_RAID6_PQ) += raid6/
  obj-$(CONFIG_LZMA_COMPRESS) += lzma/
  obj-$(CONFIG_LZMA_DECOMPRESS) += lzma/
diff --git 
a/target/linux/ar71xx/patches-4.9/403-mtd_fix_cfi_cmdset_0002_status_check.patch
 
b/target/linux/ar71xx/patches-4.9/403-mtd_fix_cfi_cmdset_0002_status_check.patch
index 1ccce4ecec..415d835ee3 100644
--- 
a/target/linux/ar71xx/patches-4.9/403-mtd_fix_cfi_cmdset_0002_status_check.patch
+++ 
b/target/linux/ar71xx/patches-4.9/403-mtd_fix_cfi_cmdset_0002_status_check.patch
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
-@@ -1632,8 +1632,8 @@ static int __xipram do_write_oneword(str
+@@ -1630,8 +1630,8 @@ static int __xipram do_write_oneword(str
                        break;
                }
  
@@ -11,7 +11,7 @@
  
                /* Latency issues. Drop the lock, wait a while and retry */
                UDELAY(map, chip, adr, 1);
-@@ -1649,6 +1649,8 @@ static int __xipram do_write_oneword(str
+@@ -1647,6 +1647,8 @@ static int __xipram do_write_oneword(str
  
                ret = -EIO;
        }
@@ -20,7 +20,7 @@
        xip_enable(map, chip, adr);
   op_done:
        if (mode == FL_OTP_WRITE)
-@@ -2227,7 +2229,6 @@ static int cfi_amdstd_panic_write(struct
+@@ -2225,7 +2227,6 @@ static int cfi_amdstd_panic_write(struct
        return 0;
  }
  
@@ -28,7 +28,7 @@
  /*
   * Handle devices with one erase region, that only implement
   * the chip erase command.
-@@ -2291,8 +2292,8 @@ static int __xipram do_erase_chip(struct
+@@ -2289,8 +2290,8 @@ static int __xipram do_erase_chip(struct
                        chip->erase_suspended = 0;
                }
  
@@ -39,7 +39,7 @@
  
                if (time_after(jiffies, timeo)) {
                        printk(KERN_WARNING "MTD %s(): software timeout\n",
-@@ -2312,6 +2313,7 @@ static int __xipram do_erase_chip(struct
+@@ -2310,6 +2311,7 @@ static int __xipram do_erase_chip(struct
                ret = -EIO;
        }
  
@@ -47,7 +47,7 @@
        chip->state = FL_READY;
        xip_enable(map, chip, adr);
        DISABLE_VPP(map);
-@@ -2380,9 +2382,9 @@ static int __xipram do_erase_oneblock(st
+@@ -2378,9 +2380,9 @@ static int __xipram do_erase_oneblock(st
                        chip->erase_suspended = 0;
                }
  
@@ -59,7 +59,7 @@
                }
  
                if (time_after(jiffies, timeo)) {
-@@ -2404,6 +2406,7 @@ static int __xipram do_erase_oneblock(st
+@@ -2402,6 +2404,7 @@ static int __xipram do_erase_oneblock(st
                ret = -EIO;
        }
  
diff --git a/target/linux/ar71xx/patches-4.9/404-mtd-cybertan-trx-parser.patch 
b/target/linux/ar71xx/patches-4.9/404-mtd-cybertan-trx-parser.patch
index 3f67c4c5da..6c2322e07f 100644
--- a/target/linux/ar71xx/patches-4.9/404-mtd-cybertan-trx-parser.patch
+++ b/target/linux/ar71xx/patches-4.9/404-mtd-cybertan-trx-parser.patch
@@ -1,8 +1,8 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -174,6 +174,12 @@ config MTD_BCM47XX_PARTS
-         This provides partitions parser for devices based on BCM47xx
-         boards.
+@@ -178,6 +178,12 @@ menu "Partition parsers"
+ source "drivers/mtd/parsers/Kconfig"
+ endmenu
  
 +config MTD_CYBERTAN_PARTS
 +      tristate "Cybertan partitioning support"
@@ -15,10 +15,10 @@
        depends on ADM5120 || ATH25 || ATH79
 --- a/drivers/mtd/Makefile
 +++ b/drivers/mtd/Makefile
-@@ -16,6 +16,7 @@ obj-$(CONFIG_MTD_AR7_PARTS)  += ar7part.o
- obj-$(CONFIG_MTD_BCM63XX_PARTS)       += bcm63xxpart.o
+@@ -17,6 +17,7 @@ obj-$(CONFIG_MTD_BCM63XX_PARTS)      += bcm63
  obj-$(CONFIG_MTD_BCM47XX_PARTS)       += bcm47xxpart.o
  obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o
+ obj-y                         += parsers/
 +obj-$(CONFIG_MTD_CYBERTAN_PARTS) += cybertan_part.o
  
  # 'Users' - code which presents functionality to userspace.
diff --git 
a/target/linux/ar71xx/patches-4.9/405-mtd-tp-link-partition-parser.patch 
b/target/linux/ar71xx/patches-4.9/405-mtd-tp-link-partition-parser.patch
index 9d0d1db168..a53d9501ec 100644
--- a/target/linux/ar71xx/patches-4.9/405-mtd-tp-link-partition-parser.patch
+++ b/target/linux/ar71xx/patches-4.9/405-mtd-tp-link-partition-parser.patch
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -196,6 +196,12 @@ config MTD_MYLOADER_PARTS
+@@ -200,6 +200,12 @@ config MTD_MYLOADER_PARTS
          You will still need the parsing functions to be called by the driver
          for your particular device. It won't happen automatically.
  
@@ -15,10 +15,10 @@
  #
 --- a/drivers/mtd/Makefile
 +++ b/drivers/mtd/Makefile
-@@ -16,6 +16,7 @@ obj-$(CONFIG_MTD_AR7_PARTS)  += ar7part.o
- obj-$(CONFIG_MTD_BCM63XX_PARTS)       += bcm63xxpart.o
+@@ -17,6 +17,7 @@ obj-$(CONFIG_MTD_BCM63XX_PARTS)      += bcm63
  obj-$(CONFIG_MTD_BCM47XX_PARTS)       += bcm47xxpart.o
  obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o
+ obj-y                         += parsers/
 +obj-$(CONFIG_MTD_TPLINK_PARTS)        += tplinkpart.o
  obj-$(CONFIG_MTD_CYBERTAN_PARTS) += cybertan_part.o
  
diff --git 
a/target/linux/ar71xx/patches-4.9/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
 
b/target/linux/ar71xx/patches-4.9/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
index 04acdb6d9e..4fa957e70b 100644
--- 
a/target/linux/ar71xx/patches-4.9/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
+++ 
b/target/linux/ar71xx/patches-4.9/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
@@ -1,16 +1,27 @@
 --- a/drivers/mtd/devices/m25p80.c
 +++ b/drivers/mtd/devices/m25p80.c
-@@ -251,7 +251,9 @@ static int m25p_probe(struct spi_device
+@@ -192,6 +192,7 @@ static ssize_t m25p80_read(struct spi_no
+  */
+ static int m25p_probe(struct spi_device *spi)
+ {
++      struct mtd_part_parser_data     ppdata = {0,};
+       struct flash_platform_data      *data;
+       struct m25p *flash;
+       struct spi_nor *nor;
+@@ -244,8 +245,11 @@ static int m25p_probe(struct spi_device
+       if (ret)
+               return ret;
  
-       ppdata.of_node = spi->dev.of_node;
- 
--      return mtd_device_parse_register(&nor->mtd, NULL, &ppdata,
+-      return mtd_device_register(&nor->mtd, data ? data->parts : NULL,
+-                                 data ? data->nr_parts : 0);
 +      return mtd_device_parse_register(&nor->mtd,
 +                      data ? data->part_probes : NULL,
 +                      &ppdata,
-                       data ? data->parts : NULL,
-                       data ? data->nr_parts : 0);
++                      data ? data->parts : NULL,
++                      data ? data->nr_parts : 0);
  }
+ 
+ 
 --- a/include/linux/spi/flash.h
 +++ b/include/linux/spi/flash.h
 @@ -24,6 +24,7 @@ struct flash_platform_data {
diff --git a/target/linux/ar71xx/patches-4.9/409-mtd-rb4xx_nand_driver.patch 
b/target/linux/ar71xx/patches-4.9/409-mtd-rb4xx_nand_driver.patch
index 4039aa185a..93d34b8826 100644
--- a/target/linux/ar71xx/patches-4.9/409-mtd-rb4xx_nand_driver.patch
+++ b/target/linux/ar71xx/patches-4.9/409-mtd-rb4xx_nand_driver.patch
@@ -1,8 +1,8 @@
 --- a/drivers/mtd/nand/Kconfig
 +++ b/drivers/mtd/nand/Kconfig
-@@ -546,4 +546,8 @@ config MTD_NAND_HISI504
-       help
-         Enables support for NAND controller on Hisilicon SoC Hip04.
+@@ -569,4 +569,8 @@ config MTD_NAND_MTK
+         Enables support for NAND controller on MTK SoCs.
+         This controller is found on mt27xx, mt81xx, mt65xx SoCs.
  
 +config MTD_NAND_RB4XX
 +      tristate "NAND flash driver for RouterBoard 4xx series"
diff --git a/target/linux/ar71xx/patches-4.9/410-mtd-rb750-nand-driver.patch 
b/target/linux/ar71xx/patches-4.9/410-mtd-rb750-nand-driver.patch
index c67d1776f1..9ea879c8e4 100644
--- a/target/linux/ar71xx/patches-4.9/410-mtd-rb750-nand-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/410-mtd-rb750-nand-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/nand/Kconfig
 +++ b/drivers/mtd/nand/Kconfig
-@@ -550,4 +550,8 @@ config MTD_NAND_RB4XX
+@@ -573,4 +573,8 @@ config MTD_NAND_RB4XX
        tristate "NAND flash driver for RouterBoard 4xx series"
        depends on MTD_NAND && ATH79_MACH_RB4XX
  
diff --git 
a/target/linux/ar71xx/patches-4.9/411-mtd-cfi_cmdset_0002-force-word-write.patch
 
b/target/linux/ar71xx/patches-4.9/411-mtd-cfi_cmdset_0002-force-word-write.patch
index 39c5478182..7f5b2f55ac 100644
--- 
a/target/linux/ar71xx/patches-4.9/411-mtd-cfi_cmdset_0002-force-word-write.patch
+++ 
b/target/linux/ar71xx/patches-4.9/411-mtd-cfi_cmdset_0002-force-word-write.patch
@@ -35,7 +35,7 @@
  
  /* Atmel chips don't use the same PRI format as AMD chips */
  static void fixup_convert_atmel_pri(struct mtd_info *mtd)
-@@ -1791,6 +1795,7 @@ static int cfi_amdstd_write_words(struct
+@@ -1789,6 +1793,7 @@ static int cfi_amdstd_write_words(struct
  /*
   * FIXME: interleaved mode not tested, and probably not supported!
   */
@@ -43,7 +43,7 @@
  static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
                                    unsigned long adr, const u_char *buf,
                                    int len)
-@@ -1919,7 +1924,6 @@ static int __xipram do_write_buffer(stru
+@@ -1917,7 +1922,6 @@ static int __xipram do_write_buffer(stru
        return ret;
  }
  
@@ -51,7 +51,7 @@
  static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t 
len,
                                    size_t *retlen, const u_char *buf)
  {
-@@ -1994,6 +1998,7 @@ static int cfi_amdstd_write_buffers(stru
+@@ -1992,6 +1996,7 @@ static int cfi_amdstd_write_buffers(stru
  
        return 0;
  }
diff --git 
a/target/linux/ar71xx/patches-4.9/412-mtd-m25p80-zero-partition-parser-data.patch
 
b/target/linux/ar71xx/patches-4.9/412-mtd-m25p80-zero-partition-parser-data.patch
deleted file mode 100644
index 866920a249..0000000000
--- 
a/target/linux/ar71xx/patches-4.9/412-mtd-m25p80-zero-partition-parser-data.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/drivers/mtd/devices/m25p80.c
-+++ b/drivers/mtd/devices/m25p80.c
-@@ -249,6 +249,7 @@ static int m25p_probe(struct spi_device
-       if (ret)
-               return ret;
- 
-+      memset(&ppdata, '\0', sizeof(ppdata));
-       ppdata.of_node = spi->dev.of_node;
- 
-       return mtd_device_parse_register(&nor->mtd,
diff --git a/target/linux/ar71xx/patches-4.9/413-mtd-ar934x-nand-driver.patch 
b/target/linux/ar71xx/patches-4.9/413-mtd-ar934x-nand-driver.patch
index cfcd07a193..9f9c339e6b 100644
--- a/target/linux/ar71xx/patches-4.9/413-mtd-ar934x-nand-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/413-mtd-ar934x-nand-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/nand/Kconfig
 +++ b/drivers/mtd/nand/Kconfig
-@@ -554,4 +554,12 @@ config MTD_NAND_RB750
+@@ -577,4 +577,12 @@ config MTD_NAND_RB750
        tristate "NAND flash driver for the RouterBoard 750"
        depends on MTD_NAND && ATH79_MACH_RB750
  
diff --git a/target/linux/ar71xx/patches-4.9/414-mtd-rb91x-nand-driver.patch 
b/target/linux/ar71xx/patches-4.9/414-mtd-rb91x-nand-driver.patch
index 8b7582dce1..d1b61f096d 100644
--- a/target/linux/ar71xx/patches-4.9/414-mtd-rb91x-nand-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/414-mtd-rb91x-nand-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/nand/Kconfig
 +++ b/drivers/mtd/nand/Kconfig
-@@ -554,6 +554,10 @@ config MTD_NAND_RB750
+@@ -577,6 +577,10 @@ config MTD_NAND_RB750
        tristate "NAND flash driver for the RouterBoard 750"
        depends on MTD_NAND && ATH79_MACH_RB750
  
diff --git a/target/linux/ar71xx/patches-4.9/423-dsa-add-88e6063-driver.patch 
b/target/linux/ar71xx/patches-4.9/423-dsa-add-88e6063-driver.patch
index 1348cd9b04..1df93e9965 100644
--- a/target/linux/ar71xx/patches-4.9/423-dsa-add-88e6063-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/423-dsa-add-88e6063-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/dsa/Kconfig
 +++ b/drivers/net/dsa/Kconfig
-@@ -13,6 +13,13 @@ config NET_DSA_MV88E6060
+@@ -9,6 +9,13 @@ config NET_DSA_MV88E6060
          This enables support for the Marvell 88E6060 ethernet switch
          chip.
  
@@ -11,14 +11,14 @@
 +        This enables support for the Marvell 88E6063 ethernet switch
 +        chip
 +
- config NET_DSA_MV88E6XXX_NEED_PPU
-       bool
-       default n
+ config NET_DSA_BCM_SF2
+       tristate "Broadcom Starfighter 2 Ethernet switch support"
+       depends on HAS_IOMEM && NET_DSA
 --- a/drivers/net/dsa/Makefile
 +++ b/drivers/net/dsa/Makefile
 @@ -1,4 +1,5 @@
  obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
 +obj-$(CONFIG_NET_DSA_MV88E6063) += mv88e6063.o
- obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx_drv.o
- mv88e6xxx_drv-y += mv88e6xxx.o
- ifdef CONFIG_NET_DSA_MV88E6123_61_65
+ obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm_sf2.o
+ obj-$(CONFIG_NET_DSA_QCA8K)   += qca8k.o
+ 
diff --git 
a/target/linux/ar71xx/patches-4.9/430-drivers-link-spi-before-mtd.patch 
b/target/linux/ar71xx/patches-4.9/430-drivers-link-spi-before-mtd.patch
index e1adfb0183..a862454597 100644
--- a/target/linux/ar71xx/patches-4.9/430-drivers-link-spi-before-mtd.patch
+++ b/target/linux/ar71xx/patches-4.9/430-drivers-link-spi-before-mtd.patch
@@ -1,6 +1,6 @@
 --- a/drivers/Makefile
 +++ b/drivers/Makefile
-@@ -74,8 +74,8 @@ obj-$(CONFIG_SCSI)           += scsi/
+@@ -77,8 +77,8 @@ obj-$(CONFIG_SCSI)           += scsi/
  obj-y                         += nvme/
  obj-$(CONFIG_ATA)             += ata/
  obj-$(CONFIG_TARGET_CORE)     += target/
@@ -8,5 +8,5 @@
  obj-$(CONFIG_SPI)             += spi/
 +obj-$(CONFIG_MTD)             += mtd/
  obj-$(CONFIG_SPMI)            += spmi/
- obj-y                         += hsi/
+ obj-$(CONFIG_HSI)             += hsi/
  obj-y                         += net/
diff --git a/target/linux/ar71xx/patches-4.9/432-spi-rb4xx-spi-driver.patch 
b/target/linux/ar71xx/patches-4.9/432-spi-rb4xx-spi-driver.patch
index 7d99c43b95..e896d0bdf4 100644
--- a/target/linux/ar71xx/patches-4.9/432-spi-rb4xx-spi-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/432-spi-rb4xx-spi-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/spi/Kconfig
 +++ b/drivers/spi/Kconfig
-@@ -477,6 +477,12 @@ config SPI_QUP
+@@ -533,6 +533,12 @@ config SPI_QUP
          This driver can also be built as a module.  If so, the module
          will be called spi_qup.
  
@@ -15,8 +15,8 @@
        depends on ARCH_S3C24XX
 --- a/drivers/spi/Makefile
 +++ b/drivers/spi/Makefile
-@@ -66,6 +66,7 @@ spi-pxa2xx-platform-objs             := spi-pxa2xx.
- spi-pxa2xx-platform-$(CONFIG_SPI_PXA2XX_DMA)  += spi-pxa2xx-dma.o
+@@ -72,6 +72,7 @@ obj-$(CONFIG_SPI_PPC4xx)             += spi-ppc4xx.
+ spi-pxa2xx-platform-objs              := spi-pxa2xx.o spi-pxa2xx-dma.o
  obj-$(CONFIG_SPI_PXA2XX)              += spi-pxa2xx-platform.o
  obj-$(CONFIG_SPI_PXA2XX_PCI)          += spi-pxa2xx-pci.o
 +obj-$(CONFIG_SPI_RB4XX)                       += spi-rb4xx.o
diff --git a/target/linux/ar71xx/patches-4.9/433-spi-rb4xx-cpld-driver.patch 
b/target/linux/ar71xx/patches-4.9/433-spi-rb4xx-cpld-driver.patch
index 0932c729f9..c44acab32e 100644
--- a/target/linux/ar71xx/patches-4.9/433-spi-rb4xx-cpld-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/433-spi-rb4xx-cpld-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/spi/Kconfig
 +++ b/drivers/spi/Kconfig
-@@ -713,6 +713,13 @@ config SPI_TLE62X0
+@@ -761,6 +761,13 @@ config SPI_TLE62X0
          sysfs interface, with each line presented as a kind of GPIO
          exposing both switch control and diagnostic feedback.
  
@@ -16,7 +16,7 @@
  #
 --- a/drivers/spi/Makefile
 +++ b/drivers/spi/Makefile
-@@ -67,6 +67,7 @@ spi-pxa2xx-platform-$(CONFIG_SPI_PXA2XX_
+@@ -73,6 +73,7 @@ spi-pxa2xx-platform-objs             := spi-pxa2xx.
  obj-$(CONFIG_SPI_PXA2XX)              += spi-pxa2xx-platform.o
  obj-$(CONFIG_SPI_PXA2XX_PCI)          += spi-pxa2xx-pci.o
  obj-$(CONFIG_SPI_RB4XX)                       += spi-rb4xx.o
diff --git a/target/linux/ar71xx/patches-4.9/435-spi-vsc7385_driver.patch 
b/target/linux/ar71xx/patches-4.9/435-spi-vsc7385_driver.patch
index 880c088c56..f9f1f7a1e5 100644
--- a/target/linux/ar71xx/patches-4.9/435-spi-vsc7385_driver.patch
+++ b/target/linux/ar71xx/patches-4.9/435-spi-vsc7385_driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/spi/Kconfig
 +++ b/drivers/spi/Kconfig
-@@ -720,6 +720,11 @@ config SPI_RB4XX_CPLD
+@@ -768,6 +768,11 @@ config SPI_RB4XX_CPLD
          SPI driver for the Xilinx CPLD chip present on the
          MikroTik RB4xx boards.
  
@@ -14,8 +14,8 @@
  #
 --- a/drivers/spi/Makefile
 +++ b/drivers/spi/Makefile
-@@ -91,6 +91,7 @@ obj-$(CONFIG_SPI_TEGRA20_SLINK)              += spi-
- obj-$(CONFIG_SPI_TLE62X0)             += spi-tle62x0.o
+@@ -99,6 +99,7 @@ spi-thunderx-objs                    := spi-cavium.o spi-
+ obj-$(CONFIG_SPI_THUNDERX)            += spi-thunderx.o
  obj-$(CONFIG_SPI_TOPCLIFF_PCH)                += spi-topcliff-pch.o
  obj-$(CONFIG_SPI_TXX9)                        += spi-txx9.o
 +obj-$(CONFIG_SPI_VSC7385)             += spi-vsc7385.o
diff --git 
a/target/linux/ar71xx/patches-4.9/440-leds-wndr3700-usb-led-driver.patch 
b/target/linux/ar71xx/patches-4.9/440-leds-wndr3700-usb-led-driver.patch
index 3ef0d1b0d4..0bf5b1a7d9 100644
--- a/target/linux/ar71xx/patches-4.9/440-leds-wndr3700-usb-led-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/440-leds-wndr3700-usb-led-driver.patch
@@ -1,8 +1,8 @@
 --- a/drivers/leds/Kconfig
 +++ b/drivers/leds/Kconfig
-@@ -605,6 +605,13 @@ config LEDS_VERSATILE
-         This option enabled support for the LEDs on the ARM Versatile
-         and RealView boards. Say Y to enabled these.
+@@ -659,6 +659,13 @@ config LEDS_MLXCPLD
+         This option enabled support for the LEDs on the Mellanox
+         boards. Say Y to enabled these.
  
 +config LEDS_WNDR3700_USB
 +      tristate "NETGEAR WNDR3700 USB LED driver"
@@ -16,7 +16,7 @@
  
 --- a/drivers/leds/Makefile
 +++ b/drivers/leds/Makefile
-@@ -47,6 +47,7 @@ obj-$(CONFIG_LEDS_DA9052)            += leds-da905
+@@ -48,6 +48,7 @@ obj-$(CONFIG_LEDS_DA9052)            += leds-da905
  obj-$(CONFIG_LEDS_WM831X_STATUS)      += leds-wm831x-status.o
  obj-$(CONFIG_LEDS_WM8350)             += leds-wm8350.o
  obj-$(CONFIG_LEDS_PWM)                        += leds-pwm.o
diff --git a/target/linux/ar71xx/patches-4.9/441-leds-rb750-led-driver.patch 
b/target/linux/ar71xx/patches-4.9/441-leds-rb750-led-driver.patch
index fc2d02b8ff..777a0df917 100644
--- a/target/linux/ar71xx/patches-4.9/441-leds-rb750-led-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/441-leds-rb750-led-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/leds/Kconfig
 +++ b/drivers/leds/Kconfig
-@@ -612,6 +612,10 @@ config LEDS_WNDR3700_USB
+@@ -666,6 +666,10 @@ config LEDS_WNDR3700_USB
          This option enables support for the USB LED found on the
          NETGEAR WNDR3700 board.
  
@@ -13,7 +13,7 @@
  
 --- a/drivers/leds/Makefile
 +++ b/drivers/leds/Makefile
-@@ -54,6 +54,7 @@ obj-$(CONFIG_LEDS_LT3593)            += leds-lt359
+@@ -55,6 +55,7 @@ obj-$(CONFIG_LEDS_LT3593)            += leds-lt359
  obj-$(CONFIG_LEDS_ADP5520)            += leds-adp5520.o
  obj-$(CONFIG_LEDS_DELL_NETBOOKS)      += dell-led.o
  obj-$(CONFIG_LEDS_MC13783)            += leds-mc13783.o
diff --git 
a/target/linux/ar71xx/patches-4.9/450-gpio-nxp-74hc153-gpio-chip-driver.patch 
b/target/linux/ar71xx/patches-4.9/450-gpio-nxp-74hc153-gpio-chip-driver.patch
index 8bccd12fac..41cf75a558 100644
--- 
a/target/linux/ar71xx/patches-4.9/450-gpio-nxp-74hc153-gpio-chip-driver.patch
+++ 
b/target/linux/ar71xx/patches-4.9/450-gpio-nxp-74hc153-gpio-chip-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/gpio/Kconfig
 +++ b/drivers/gpio/Kconfig
-@@ -1040,4 +1040,12 @@ config GPIO_VIPERBOARD
+@@ -1211,4 +1211,12 @@ config GPIO_VIPERBOARD
  
  endmenu
  
@@ -15,7 +15,7 @@
  endif
 --- a/drivers/gpio/Makefile
 +++ b/drivers/gpio/Makefile
-@@ -69,6 +69,7 @@ obj-$(CONFIG_GPIO_MSIC)              += gpio-msic.o
+@@ -83,6 +83,7 @@ obj-$(CONFIG_GPIO_MSIC)              += gpio-msic.o
  obj-$(CONFIG_GPIO_MVEBU)        += gpio-mvebu.o
  obj-$(CONFIG_GPIO_MXC)                += gpio-mxc.o
  obj-$(CONFIG_GPIO_MXS)                += gpio-mxs.o
diff --git 
a/target/linux/ar71xx/patches-4.9/451-gpio-74x164-improve-platform-device-support.patch
 
b/target/linux/ar71xx/patches-4.9/451-gpio-74x164-improve-platform-device-support.patch
index 0f7faf280f..d9cfa888fb 100644
--- 
a/target/linux/ar71xx/patches-4.9/451-gpio-74x164-improve-platform-device-support.patch
+++ 
b/target/linux/ar71xx/patches-4.9/451-gpio-74x164-improve-platform-device-support.patch
@@ -8,17 +8,15 @@
  #include <linux/gpio.h>
  #include <linux/of_gpio.h>
  #include <linux/slab.h>
-@@ -107,8 +108,18 @@ static int gen_74x164_direction_output(s
+@@ -103,9 +104,16 @@ static int gen_74x164_direction_output(s
  static int gen_74x164_probe(struct spi_device *spi)
  {
        struct gen_74x164_chip *chip;
-+      struct gen_74x164_chip_platform_data *pdata;
-+      struct device_node *np;
++      struct gen_74x164_chip_platform_data *pdata = spi->dev.platform_data;
++      struct device_node *np = spi->dev.of_node;
+       u32 nregs;
        int ret;
  
-+      pdata = spi->dev.platform_data;
-+      np = spi->dev.of_node;
-+
 +      if (!np && !pdata) {
 +              dev_err(&spi->dev, "No configuration data available.\n");
 +              return -EINVAL;
@@ -27,47 +25,57 @@
        /*
         * bits_per_word cannot be configured in platform data
         */
-@@ -130,18 +141,28 @@ static int gen_74x164_probe(struct spi_d
-       chip->gpio_chip.set = gen_74x164_set_value;
-       chip->gpio_chip.base = -1;
+@@ -115,17 +123,23 @@ static int gen_74x164_probe(struct spi_d
+       if (ret < 0)
+               return ret;
  
 -      if (of_property_read_u32(spi->dev.of_node, "registers-number",
--                               &chip->registers)) {
+-                               &nregs)) {
 -              dev_err(&spi->dev,
 -                      "Missing registers-number property in the DT.\n");
 -              return -EINVAL;
+-      }
 +      if (np) {
-+              if (of_property_read_u32(spi->dev.of_node, "registers-number", 
&chip->registers)) {
-+                      dev_err(&spi->dev, "Missing registers-number property 
in the DT.\n");
-+                      ret = -EINVAL;
-+                      goto exit_destroy;
++              if (of_property_read_u32(np, "registers-number", &nregs)) {
++                      dev_err(&spi->dev,
++                              "Missing registers-number property in the 
DT.\n");
++                      return -EINVAL;
 +              }
 +      } else if (pdata) {
-+              chip->gpio_chip.base = pdata->base;
-+              chip->registers = pdata->num_registers;
-       }
++              nregs = pdata->num_registers;
++      }
  
-+      if (!chip->registers)
-+              chip->registers = 1;
-+
-       chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers;
-       chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL);
-       if (!chip->buffer)
+       chip = devm_kzalloc(&spi->dev, sizeof(*chip) + nregs, GFP_KERNEL);
+       if (!chip)
                return -ENOMEM;
  
 +      if (pdata && pdata->init_data)
 +              memcpy(chip->buffer, pdata->init_data, chip->registers);
++      
+       spi_set_drvdata(spi, chip);
+ 
+       chip->gpio_chip.label = spi->modalias;
+@@ -133,7 +147,11 @@ static int gen_74x164_probe(struct spi_d
+       chip->gpio_chip.get = gen_74x164_get_value;
+       chip->gpio_chip.set = gen_74x164_set_value;
+       chip->gpio_chip.set_multiple = gen_74x164_set_multiple;
+-      chip->gpio_chip.base = -1;
++      if (np)
++              chip->gpio_chip.base = -1;
++      else if (pdata)
++              chip->gpio_chip.base = pdata->base;
 +
-       chip->gpio_chip.can_sleep = true;
-       chip->gpio_chip.dev = &spi->dev;
-       chip->gpio_chip.owner = THIS_MODULE;
-@@ -174,16 +195,18 @@ static int gen_74x164_remove(struct spi_
+ 
+       chip->registers = nregs;
+       chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers;
+@@ -170,17 +188,19 @@ static int gen_74x164_remove(struct spi_
        return 0;
  }
  
 +#ifdef CONFIG_OF
  static const struct of_device_id gen_74x164_dt_ids[] = {
        { .compatible = "fairchild,74hc595" },
+       { .compatible = "nxp,74lvc594" },
        {},
  };
  MODULE_DEVICE_TABLE(of, gen_74x164_dt_ids);
@@ -99,11 +107,11 @@
 +#endif
 --- a/drivers/gpio/Kconfig
 +++ b/drivers/gpio/Kconfig
-@@ -991,7 +991,6 @@ menu "SPI GPIO expanders"
+@@ -1154,7 +1154,6 @@ menu "SPI GPIO expanders"
  
  config GPIO_74X164
        tristate "74x164 serial-in/parallel-out 8-bits shift register"
--      depends on OF
+-      depends on OF_GPIO
        help
          Driver for 74x164 compatible serial-in/parallel-out 8-outputs
          shift registers. This driver can be used to provide access
diff --git 
a/target/linux/ar71xx/patches-4.9/452-gpio-add-gpio-latch-driver.patch 
b/target/linux/ar71xx/patches-4.9/452-gpio-add-gpio-latch-driver.patch
index c545252b38..5ddf6de928 100644
--- a/target/linux/ar71xx/patches-4.9/452-gpio-add-gpio-latch-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/452-gpio-add-gpio-latch-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/gpio/Kconfig
 +++ b/drivers/gpio/Kconfig
-@@ -1047,4 +1047,9 @@ config GPIO_NXP_74HC153
+@@ -1218,4 +1218,9 @@ config GPIO_NXP_74HC153
          Platform driver for NXP 74HC153 Dual 4-input Multiplexer. This
          provides a GPIO interface supporting input mode only.
  
@@ -12,7 +12,7 @@
  endif
 --- a/drivers/gpio/Makefile
 +++ b/drivers/gpio/Makefile
-@@ -47,6 +47,7 @@ obj-$(CONFIG_GPIO_JANZ_TTL)  += gpio-janz
+@@ -56,6 +56,7 @@ obj-$(CONFIG_GPIO_JANZ_TTL)  += gpio-janz
  obj-$(CONFIG_GPIO_KEMPLD)     += gpio-kempld.o
  obj-$(CONFIG_ARCH_KS8695)     += gpio-ks8695.o
  obj-$(CONFIG_GPIO_INTEL_MID)  += gpio-intel-mid.o
diff --git 
a/target/linux/ar71xx/patches-4.9/460-m25p80-spi-read-flash-check.patch 
b/target/linux/ar71xx/patches-4.9/460-m25p80-spi-read-flash-check.patch
deleted file mode 100644
index a34b38398d..0000000000
--- a/target/linux/ar71xx/patches-4.9/460-m25p80-spi-read-flash-check.patch
+++ /dev/null
@@ -1,15 +0,0 @@
---- a/drivers/mtd/devices/m25p80.c
-+++ b/drivers/mtd/devices/m25p80.c
-@@ -149,8 +149,10 @@ static int m25p80_read(struct spi_nor *n
-               msg.data_nbits = m25p80_rx_nbits(nor);
- 
-               ret = spi_flash_read(spi, &msg);
--              *retlen = msg.retlen;
--              return ret;
-+              if (!ret) {
-+                      *retlen = msg.retlen;
-+                      return 0;
-+              }
-       }
- 
-       spi_message_init(&m);
diff --git 
a/target/linux/ar71xx/patches-4.9/490-usb-ehci-add-quirks-for-qca-socs.patch 
b/target/linux/ar71xx/patches-4.9/490-usb-ehci-add-quirks-for-qca-socs.patch
index d74ef1c83d..8a05adb050 100644
--- a/target/linux/ar71xx/patches-4.9/490-usb-ehci-add-quirks-for-qca-socs.patch
+++ b/target/linux/ar71xx/patches-4.9/490-usb-ehci-add-quirks-for-qca-socs.patch
@@ -40,7 +40,7 @@
        retval = ehci_handshake(ehci, &ehci->regs->command,
 --- a/drivers/usb/host/ehci.h
 +++ b/drivers/usb/host/ehci.h
-@@ -228,6 +228,10 @@ struct ehci_hcd {                 /* one per controlle
+@@ -231,6 +231,10 @@ struct ehci_hcd {                 /* one per controlle
        unsigned                need_oc_pp_cycle:1; /* MPC834X port power */
        unsigned                imx28_write_fix:1; /* For Freescale i.MX28 */
        unsigned                ignore_oc:1;
@@ -72,7 +72,7 @@
  #endif /* __USB_CORE_EHCI_PDRIVER_H */
 --- a/drivers/usb/host/ehci-platform.c
 +++ b/drivers/usb/host/ehci-platform.c
-@@ -51,6 +51,14 @@ struct ehci_platform_priv {
+@@ -52,6 +52,14 @@ struct ehci_platform_priv {
  
  static const char hcd_name[] = "ehci-platform";
  
@@ -87,7 +87,7 @@
  static int ehci_platform_reset(struct usb_hcd *hcd)
  {
        struct platform_device *pdev = to_platform_device(hcd->self.controller);
-@@ -256,6 +264,13 @@ static int ehci_platform_probe(struct pl
+@@ -261,6 +269,13 @@ static int ehci_platform_probe(struct pl
                priv->reset_on_resume = true;
        if (pdata->ignore_oc)
                ehci->ignore_oc = 1;
diff --git a/target/linux/ar71xx/patches-4.9/500-MIPS-fw-myloader.patch 
b/target/linux/ar71xx/patches-4.9/500-MIPS-fw-myloader.patch
index 811a234a2c..bcb19372ef 100644
--- a/target/linux/ar71xx/patches-4.9/500-MIPS-fw-myloader.patch
+++ b/target/linux/ar71xx/patches-4.9/500-MIPS-fw-myloader.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/Makefile
 +++ b/arch/mips/Makefile
-@@ -218,6 +218,7 @@ endif
+@@ -213,6 +213,7 @@ cflags-$(toolchain-virt)           += -DTOOLCHAIN
  #
  libs-$(CONFIG_FW_ARC)         += arch/mips/fw/arc/
  libs-$(CONFIG_FW_CFE)         += arch/mips/fw/cfe/
@@ -10,7 +10,7 @@
  
 --- a/arch/mips/Kconfig
 +++ b/arch/mips/Kconfig
-@@ -1118,6 +1118,9 @@ config MIPS_MSC
+@@ -1144,6 +1144,9 @@ config MIPS_MSC
  config MIPS_NILE4
        bool
  
diff --git 
a/target/linux/ar71xx/patches-4.9/504-MIPS-ath79-add-ath79_device_reset_get.patch
 
b/target/linux/ar71xx/patches-4.9/504-MIPS-ath79-add-ath79_device_reset_get.patch
index 4f79136abe..c0e96b2729 100644
--- 
a/target/linux/ar71xx/patches-4.9/504-MIPS-ath79-add-ath79_device_reset_get.patch
+++ 
b/target/linux/ar71xx/patches-4.9/504-MIPS-ath79-add-ath79_device_reset_get.patch
@@ -1,12 +1,13 @@
 --- a/arch/mips/include/asm/mach-ath79/ath79.h
 +++ b/arch/mips/include/asm/mach-ath79/ath79.h
-@@ -144,5 +144,6 @@ static inline u32 ath79_reset_rr(unsigne
+@@ -145,6 +145,7 @@ static inline u32 ath79_reset_rr(unsigne
  
  void ath79_device_reset_set(u32 mask);
  void ath79_device_reset_clear(u32 mask);
 +u32 ath79_device_reset_get(u32 mask);
  
- #endif /* __ASM_MACH_ATH79_H */
+ void ath79_cpu_irq_init(unsigned irq_wb_chan2, unsigned irq_wb_chan3);
+ void ath79_misc_irq_init(void __iomem *regs, int irq,
 --- a/arch/mips/ath79/common.c
 +++ b/arch/mips/ath79/common.c
 @@ -142,3 +142,29 @@ void ath79_device_reset_clear(u32 mask)
diff --git 
a/target/linux/ar71xx/patches-4.9/505-MIPS-ath79-add-ath79_gpio_function_select.patch
 
b/target/linux/ar71xx/patches-4.9/505-MIPS-ath79-add-ath79_gpio_function_select.patch
index 3adb088d52..278e781539 100644
--- 
a/target/linux/ar71xx/patches-4.9/505-MIPS-ath79-add-ath79_gpio_function_select.patch
+++ 
b/target/linux/ar71xx/patches-4.9/505-MIPS-ath79-add-ath79_gpio_function_select.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/ath79/common.h
 +++ b/arch/mips/ath79/common.h
-@@ -28,6 +28,7 @@ void ath79_ddr_wb_flush(unsigned int reg
+@@ -27,6 +27,7 @@ void ath79_ddr_ctrl_init(void);
  void ath79_gpio_function_enable(u32 mask);
  void ath79_gpio_function_disable(u32 mask);
  void ath79_gpio_function_setup(u32 set, u32 clear);
diff --git 
a/target/linux/ar71xx/patches-4.9/509-MIPS-ath79-process-board-kernel-option.patch
 
b/target/linux/ar71xx/patches-4.9/509-MIPS-ath79-process-board-kernel-option.patch
index 40bd8522ab..3091ab69b6 100644
--- 
a/target/linux/ar71xx/patches-4.9/509-MIPS-ath79-process-board-kernel-option.patch
+++ 
b/target/linux/ar71xx/patches-4.9/509-MIPS-ath79-process-board-kernel-option.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/ath79/setup.c
 +++ b/arch/mips/ath79/setup.c
-@@ -253,6 +253,8 @@ void __init plat_time_init(void)
+@@ -283,6 +283,8 @@ void __init plat_time_init(void)
        mips_hpt_frequency = cpu_clk_rate / 2;
  }
  
@@ -8,4 +8,4 @@
 +
  static int __init ath79_setup(void)
  {
-       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+       if  (mips_machtype == ATH79_MACH_GENERIC_OF)
diff --git 
a/target/linux/ar71xx/patches-4.9/602-MIPS-ath79-add-openwrt-stuff.patch 
b/target/linux/ar71xx/patches-4.9/602-MIPS-ath79-add-openwrt-stuff.patch
index 9959a39651..cbd69e337b 100644
--- a/target/linux/ar71xx/patches-4.9/602-MIPS-ath79-add-openwrt-stuff.patch
+++ b/target/linux/ar71xx/patches-4.9/602-MIPS-ath79-add-openwrt-stuff.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/ath79/Kconfig
 +++ b/arch/mips/ath79/Kconfig
-@@ -110,6 +110,20 @@ config SOC_QCA955X
+@@ -98,6 +98,20 @@ config SOC_QCA955X
        select PCI_AR724X if PCI
        def_bool n
  
@@ -21,7 +21,7 @@
  config PCI_AR724X
        def_bool n
  
-@@ -119,6 +133,10 @@ config ATH79_DEV_GPIO_BUTTONS
+@@ -107,6 +121,10 @@ config ATH79_DEV_GPIO_BUTTONS
  config ATH79_DEV_LEDS_GPIO
        def_bool n
  
@@ -32,7 +32,7 @@
  config ATH79_DEV_SPI
        def_bool n
  
-@@ -129,4 +147,14 @@ config ATH79_DEV_WMAC
+@@ -117,4 +135,14 @@ config ATH79_DEV_WMAC
        depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA955X)
        def_bool n
  
diff --git a/target/linux/ar71xx/patches-4.9/611-MIPS-ath79-wdt-timeout.patch 
b/target/linux/ar71xx/patches-4.9/611-MIPS-ath79-wdt-timeout.patch
index 7a70ac3f87..0927d5a977 100644
--- a/target/linux/ar71xx/patches-4.9/611-MIPS-ath79-wdt-timeout.patch
+++ b/target/linux/ar71xx/patches-4.9/611-MIPS-ath79-wdt-timeout.patch
@@ -6,7 +6,7 @@ Signed-off-by: John Crispin <blo...@openwrt.org>
 
 --- a/drivers/watchdog/ath79_wdt.c
 +++ b/drivers/watchdog/ath79_wdt.c
-@@ -114,10 +114,14 @@ static inline void ath79_wdt_disable(voi
+@@ -115,10 +115,14 @@ static inline void ath79_wdt_disable(voi
  
  static int ath79_wdt_set_timeout(int val)
  {
diff --git 
a/target/linux/ar71xx/patches-4.9/620-MIPS-ath79-add-support-for-QCA953x-SoC.patch
 
b/target/linux/ar71xx/patches-4.9/620-MIPS-ath79-add-support-for-QCA953x-SoC.patch
index 5cfb4e78d7..869fdd6dd0 100644
--- 
a/target/linux/ar71xx/patches-4.9/620-MIPS-ath79-add-support-for-QCA953x-SoC.patch
+++ 
b/target/linux/ar71xx/patches-4.9/620-MIPS-ath79-add-support-for-QCA953x-SoC.patch
@@ -22,7 +22,7 @@ meaning of the bits CPUCLK_FROM_CPUPLL and DDRCLK_FROM_DDRPLL 
is reversed.
 
 --- a/arch/mips/ath79/Kconfig
 +++ b/arch/mips/ath79/Kconfig
-@@ -116,6 +116,10 @@ config SOC_AR934X
+@@ -104,6 +104,10 @@ config SOC_AR934X
        select PCI_AR724X if PCI
        def_bool n
  
@@ -33,7 +33,7 @@ meaning of the bits CPUCLK_FROM_CPUPLL and DDRCLK_FROM_DDRPLL 
is reversed.
  config SOC_QCA955X
        select HW_HAS_PCI
        select PCI_AR724X if PCI
-@@ -155,7 +159,7 @@ config ATH79_DEV_USB
+@@ -143,7 +147,7 @@ config ATH79_DEV_USB
        def_bool n
  
  config ATH79_DEV_WMAC
@@ -44,7 +44,7 @@ meaning of the bits CPUCLK_FROM_CPUPLL and DDRCLK_FROM_DDRPLL 
is reversed.
  config ATH79_NVRAM
 --- a/arch/mips/ath79/clock.c
 +++ b/arch/mips/ath79/clock.c
-@@ -354,6 +354,91 @@ static void __init ar934x_clocks_init(vo
+@@ -356,6 +356,91 @@ static void __init ar934x_clocks_init(vo
        iounmap(dpll_base);
  }
  
@@ -316,15 +316,7 @@ meaning of the bits CPUCLK_FROM_CPUPLL and 
DDRCLK_FROM_DDRPLL is reversed.
                return;
 --- a/arch/mips/ath79/irq.c
 +++ b/arch/mips/ath79/irq.c
-@@ -105,6 +105,7 @@ static void __init ath79_misc_irq_init(v
-       else if (soc_is_ar724x() ||
-                soc_is_ar933x() ||
-                soc_is_ar934x() ||
-+               soc_is_qca953x() ||
-                soc_is_qca955x())
-               ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
-       else
-@@ -148,6 +149,34 @@ static void ar934x_ip2_irq_init(void)
+@@ -56,6 +56,34 @@ static void ar934x_ip2_irq_init(void)
        irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
  }
  
@@ -359,16 +351,24 @@ meaning of the bits CPUCLK_FROM_CPUPLL and 
DDRCLK_FROM_DDRPLL is reversed.
  static void qca955x_ip2_irq_dispatch(struct irq_desc *desc)
  {
        u32 status;
-@@ -362,7 +391,7 @@ void __init arch_init_irq(void)
+@@ -143,7 +171,7 @@ void __init arch_init_irq(void)
            soc_is_ar913x() || soc_is_ar933x()) {
-               irq_wb_chan[2] = 3;
-               irq_wb_chan[3] = 2;
+               irq_wb_chan2 = 3;
+               irq_wb_chan3 = 2;
 -      } else if (soc_is_ar934x()) {
 +      } else if (soc_is_ar934x() || soc_is_qca953x()) {
-               irq_wb_chan[3] = 2;
+               irq_wb_chan3 = 2;
        }
  
-@@ -371,6 +400,8 @@ void __init arch_init_irq(void)
+@@ -154,6 +182,7 @@ void __init arch_init_irq(void)
+       else if (soc_is_ar724x() ||
+                soc_is_ar933x() ||
+                soc_is_ar934x() ||
++               soc_is_qca953x() ||
+                soc_is_qca955x())
+               misc_is_ar71xx = false;
+       else
+@@ -164,6 +193,8 @@ void __init arch_init_irq(void)
  
        if (soc_is_ar934x())
                ar934x_ip2_irq_init();
@@ -379,7 +379,7 @@ meaning of the bits CPUCLK_FROM_CPUPLL and 
DDRCLK_FROM_DDRPLL is reversed.
  }
 --- a/arch/mips/ath79/setup.c
 +++ b/arch/mips/ath79/setup.c
-@@ -64,6 +64,7 @@ static void __init ath79_detect_sys_type
+@@ -60,6 +60,7 @@ static void __init ath79_detect_sys_type
        u32 major;
        u32 minor;
        u32 rev = 0;
@@ -387,7 +387,7 @@ meaning of the bits CPUCLK_FROM_CPUPLL and 
DDRCLK_FROM_DDRPLL is reversed.
  
        id = ath79_reset_rr(AR71XX_RESET_REG_REV_ID);
        major = id & REV_ID_MAJOR_MASK;
-@@ -156,6 +157,17 @@ static void __init ath79_detect_sys_type
+@@ -152,6 +153,17 @@ static void __init ath79_detect_sys_type
                rev = id & AR934X_REV_ID_REVISION_MASK;
                break;
  
@@ -405,7 +405,7 @@ meaning of the bits CPUCLK_FROM_CPUPLL and 
DDRCLK_FROM_DDRPLL is reversed.
        case REV_ID_MAJOR_QCA9556:
                ath79_soc = ATH79_SOC_QCA9556;
                chip = "9556";
-@@ -172,11 +184,12 @@ static void __init ath79_detect_sys_type
+@@ -168,11 +180,12 @@ static void __init ath79_detect_sys_type
                panic("ath79: unknown SoC, id:0x%08x", id);
        }
  
diff --git 
a/target/linux/ar71xx/patches-4.9/621-MIPS-ath79-add-support-for-QCA956x-SoC.patch
 
b/target/linux/ar71xx/patches-4.9/621-MIPS-ath79-add-support-for-QCA956x-SoC.patch
index a381851ccf..dafac99190 100644
--- 
a/target/linux/ar71xx/patches-4.9/621-MIPS-ath79-add-support-for-QCA956x-SoC.patch
+++ 
b/target/linux/ar71xx/patches-4.9/621-MIPS-ath79-add-support-for-QCA956x-SoC.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/ath79/Kconfig
 +++ b/arch/mips/ath79/Kconfig
-@@ -125,6 +125,12 @@ config SOC_QCA955X
+@@ -113,6 +113,12 @@ config SOC_QCA955X
        select PCI_AR724X if PCI
        def_bool n
  
@@ -13,7 +13,7 @@
  config ATH79_DEV_M25P80
        select ATH79_DEV_SPI
        def_bool n
-@@ -159,7 +165,7 @@ config ATH79_DEV_USB
+@@ -147,7 +153,7 @@ config ATH79_DEV_USB
        def_bool n
  
  config ATH79_DEV_WMAC
@@ -24,7 +24,7 @@
  config ATH79_NVRAM
 --- a/arch/mips/ath79/clock.c
 +++ b/arch/mips/ath79/clock.c
-@@ -524,6 +524,100 @@ static void __init qca955x_clocks_init(v
+@@ -526,6 +526,100 @@ static void __init qca955x_clocks_init(v
        clk_add_alias("uart", NULL, "ref", NULL);
  }
  
@@ -133,7 +133,7 @@
 +              qca956x_clocks_init();
        else
                BUG();
- 
+ }
 --- a/arch/mips/ath79/common.c
 +++ b/arch/mips/ath79/common.c
 @@ -107,6 +107,8 @@ void ath79_device_reset_set(u32 mask)
@@ -291,20 +291,9 @@
                return;
 --- a/arch/mips/ath79/irq.c
 +++ b/arch/mips/ath79/irq.c
-@@ -106,7 +106,9 @@ static void __init ath79_misc_irq_init(v
-                soc_is_ar933x() ||
-                soc_is_ar934x() ||
-                soc_is_qca953x() ||
--               soc_is_qca955x())
-+               soc_is_qca955x() ||
-+               soc_is_qca956x() ||
-+               soc_is_tp9343())
-               ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
-       else
-               BUG();
-@@ -263,6 +265,87 @@ static unsigned irq_wb_chan[8] = {
-       -1, -1, -1, -1, -1, -1, -1, -1,
- };
+@@ -156,6 +156,87 @@ static void qca955x_irq_init(void)
+       irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
+ }
  
 +static void qca956x_ip2_irq_dispatch(struct irq_desc *desc)
 +{
@@ -387,10 +376,21 @@
 +      late_time_init = &qca956x_enable_timer_cb;
 +}
 +
- asmlinkage void plat_irq_dispatch(void)
+ void __init arch_init_irq(void)
  {
-       unsigned long pending;
-@@ -404,4 +487,6 @@ void __init arch_init_irq(void)
+       unsigned irq_wb_chan2 = -1;
+@@ -183,7 +264,9 @@ void __init arch_init_irq(void)
+                soc_is_ar933x() ||
+                soc_is_ar934x() ||
+                soc_is_qca953x() ||
+-               soc_is_qca955x())
++               soc_is_qca955x() ||
++               soc_is_qca956x() ||
++               soc_is_tp9343())
+               misc_is_ar71xx = false;
+       else
+               BUG();
+@@ -197,4 +280,6 @@ void __init arch_init_irq(void)
                qca953x_irq_init();
        else if (soc_is_qca955x())
                qca955x_irq_init();
@@ -449,7 +449,7 @@
                return -ENODEV;
 --- a/arch/mips/ath79/setup.c
 +++ b/arch/mips/ath79/setup.c
-@@ -180,6 +180,18 @@ static void __init ath79_detect_sys_type
+@@ -176,6 +176,18 @@ static void __init ath79_detect_sys_type
                rev = id & QCA955X_REV_ID_REVISION_MASK;
                break;
  
@@ -468,7 +468,7 @@
        default:
                panic("ath79: unknown SoC, id:0x%08x", id);
        }
-@@ -187,9 +199,12 @@ static void __init ath79_detect_sys_type
+@@ -183,9 +195,12 @@ static void __init ath79_detect_sys_type
        if (ver == 1)
                ath79_soc_rev = rev;
  
@@ -712,6 +712,6 @@
 +      return soc_is_qca9561() || soc_is_qca9563();
 +}
 +
+ void ath79_ddr_wb_flush(unsigned int reg);
  void ath79_ddr_set_pci_windows(void);
  
- extern void __iomem *ath79_gpio_base;
diff --git 
a/target/linux/ar71xx/patches-4.9/630-MIPS-ath79-fix-chained-irq-disable.patch 
b/target/linux/ar71xx/patches-4.9/630-MIPS-ath79-fix-chained-irq-disable.patch
index 63b91ddc0e..2b92b88d03 100644
--- 
a/target/linux/ar71xx/patches-4.9/630-MIPS-ath79-fix-chained-irq-disable.patch
+++ 
b/target/linux/ar71xx/patches-4.9/630-MIPS-ath79-fix-chained-irq-disable.patch
@@ -1,16 +1,16 @@
 --- a/arch/mips/ath79/irq.c
 +++ b/arch/mips/ath79/irq.c
-@@ -26,6 +26,9 @@
- #include "common.h"
+@@ -27,6 +27,9 @@
  #include "machtypes.h"
  
+ 
 +static struct irq_chip ip2_chip;
 +static struct irq_chip ip3_chip;
 +
- static void ath79_misc_irq_handler(struct irq_desc *desc)
+ static void ar934x_ip2_irq_dispatch(struct irq_desc *desc)
  {
-       void __iomem *base = ath79_reset_base;
-@@ -145,8 +148,7 @@ static void ar934x_ip2_irq_init(void)
+       u32 status;
+@@ -50,8 +53,7 @@ static void ar934x_ip2_irq_init(void)
  
        for (i = ATH79_IP2_IRQ_BASE;
             i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
@@ -20,7 +20,7 @@
  
        irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
  }
-@@ -174,7 +176,7 @@ static void qca953x_irq_init(void)
+@@ -79,7 +81,7 @@ static void qca953x_irq_init(void)
  
        for (i = ATH79_IP2_IRQ_BASE;
             i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
@@ -29,7 +29,7 @@
  
        irq_set_chained_handler(ATH79_CPU_IRQ(2), qca953x_ip2_irq_dispatch);
  }
-@@ -238,15 +240,13 @@ static void qca955x_irq_init(void)
+@@ -143,15 +145,13 @@ static void qca955x_irq_init(void)
  
        for (i = ATH79_IP2_IRQ_BASE;
             i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
@@ -47,7 +47,7 @@
  
        irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
  }
-@@ -331,13 +331,13 @@ static void qca956x_irq_init(void)
+@@ -222,13 +222,13 @@ static void qca956x_irq_init(void)
  
        for (i = ATH79_IP2_IRQ_BASE;
             i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
@@ -63,9 +63,9 @@
  
        irq_set_chained_handler(ATH79_CPU_IRQ(3), qca956x_ip3_irq_dispatch);
  
-@@ -463,8 +463,36 @@ IRQCHIP_DECLARE(ar79_cpu_intc, "qca,ar71
- 
- #endif
+@@ -237,12 +237,40 @@ static void qca956x_irq_init(void)
+       late_time_init = &qca956x_enable_timer_cb;
+ }
  
 +static void ath79_ip2_disable(struct irq_data *data)
 +{
@@ -89,6 +89,10 @@
 +
  void __init arch_init_irq(void)
  {
+       unsigned irq_wb_chan2 = -1;
+       unsigned irq_wb_chan3 = -1;
+       bool misc_is_ar71xx;
+ 
 +      ip2_chip = dummy_irq_chip;
 +      ip2_chip.irq_disable = ath79_ip2_disable;
 +      ip2_chip.irq_enable = ath79_ip2_enable;
diff --git 
a/target/linux/ar71xx/patches-4.9/632-MIPS-ath79-gpio-enable-set-direction.patch
 
b/target/linux/ar71xx/patches-4.9/632-MIPS-ath79-gpio-enable-set-direction.patch
index 0a6be75088..4cf36325e1 100644
--- 
a/target/linux/ar71xx/patches-4.9/632-MIPS-ath79-gpio-enable-set-direction.patch
+++ 
b/target/linux/ar71xx/patches-4.9/632-MIPS-ath79-gpio-enable-set-direction.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/ath79/common.h
 +++ b/arch/mips/ath79/common.h
-@@ -29,6 +29,7 @@ void ath79_gpio_function_enable(u32 mask
+@@ -28,6 +28,7 @@ void ath79_gpio_function_enable(u32 mask
  void ath79_gpio_function_disable(u32 mask);
  void ath79_gpio_function_setup(u32 set, u32 clear);
  void ath79_gpio_output_select(unsigned gpio, u8 val);
diff --git 
a/target/linux/ar71xx/patches-4.9/634-MIPS-ath79-ar724x-clock-calculation-fixes.patch
 
b/target/linux/ar71xx/patches-4.9/634-MIPS-ath79-ar724x-clock-calculation-fixes.patch
deleted file mode 100644
index 90149ef187..0000000000
--- 
a/target/linux/ar71xx/patches-4.9/634-MIPS-ath79-ar724x-clock-calculation-fixes.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/arch/mips/ath79/clock.c
-+++ b/arch/mips/ath79/clock.c
-@@ -26,7 +26,7 @@
- #include "common.h"
- 
- #define AR71XX_BASE_FREQ      40000000
--#define AR724X_BASE_FREQ      5000000
-+#define AR724X_BASE_FREQ      40000000
- #define AR913X_BASE_FREQ      5000000
- 
- static struct clk *clks[3];
-@@ -103,8 +103,8 @@ static void __init ar724x_clocks_init(vo
-       div = ((pll >> AR724X_PLL_FB_SHIFT) & AR724X_PLL_FB_MASK);
-       freq = div * ref_rate;
- 
--      div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK);
--      freq *= div;
-+      div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK) * 2;
-+      freq /= div;
- 
-       cpu_rate = freq;
- 
diff --git 
a/target/linux/ar71xx/patches-4.9/700-MIPS-ath79-add-openwrt-Kconfig.patch 
b/target/linux/ar71xx/patches-4.9/700-MIPS-ath79-add-openwrt-Kconfig.patch
index 23162053ca..5d4b180003 100644
--- a/target/linux/ar71xx/patches-4.9/700-MIPS-ath79-add-openwrt-Kconfig.patch
+++ b/target/linux/ar71xx/patches-4.9/700-MIPS-ath79-add-openwrt-Kconfig.patch
@@ -1,8 +1,8 @@
 --- a/arch/mips/ath79/Kconfig
 +++ b/arch/mips/ath79/Kconfig
-@@ -94,6 +94,8 @@ choice
-               select SOC_AR913X
- endchoice
+@@ -82,6 +82,8 @@ config ATH79_MACH_UBNT_XM
+         Say 'Y' here if you want your kernel to support the
+         Ubiquiti Networks XM (rev 1.0) board.
  
 +source "arch/mips/ath79/Kconfig.openwrt"
 +
diff --git 
a/target/linux/ar71xx/patches-4.9/818-MIPS-ath79-add-nu801-led-driver.patch 
b/target/linux/ar71xx/patches-4.9/818-MIPS-ath79-add-nu801-led-driver.patch
index 420bbff185..337447e2bf 100644
--- a/target/linux/ar71xx/patches-4.9/818-MIPS-ath79-add-nu801-led-driver.patch
+++ b/target/linux/ar71xx/patches-4.9/818-MIPS-ath79-add-nu801-led-driver.patch
@@ -1,6 +1,6 @@
 --- a/drivers/leds/Kconfig
 +++ b/drivers/leds/Kconfig
-@@ -568,6 +568,13 @@ config LEDS_SEAD3
+@@ -606,6 +606,13 @@ config LEDS_IS31FL32XX
  
  comment "LED driver for blink(1) USB RGB LED is under Special HID drivers 
(HID_THINGM)"
  
@@ -16,7 +16,7 @@
        depends on LEDS_CLASS
 --- a/drivers/leds/Makefile
 +++ b/drivers/leds/Makefile
-@@ -55,6 +55,7 @@ obj-$(CONFIG_LEDS_ADP5520)           += leds-adp5
+@@ -56,6 +56,7 @@ obj-$(CONFIG_LEDS_ADP5520)           += leds-adp5
  obj-$(CONFIG_LEDS_DELL_NETBOOKS)      += dell-led.o
  obj-$(CONFIG_LEDS_MC13783)            += leds-mc13783.o
  obj-$(CONFIG_LEDS_RB750)              += leds-rb750.o
diff --git 
a/target/linux/ar71xx/patches-4.9/820-MIPS-ath79-add_gpio_function2_setup.patch 
b/target/linux/ar71xx/patches-4.9/820-MIPS-ath79-add_gpio_function2_setup.patch
index a773e57dec..afa7b69b43 100644
--- 
a/target/linux/ar71xx/patches-4.9/820-MIPS-ath79-add_gpio_function2_setup.patch
+++ 
b/target/linux/ar71xx/patches-4.9/820-MIPS-ath79-add_gpio_function2_setup.patch
@@ -4,7 +4,7 @@ functions on the Arduino Yun.
 
 --- a/arch/mips/ath79/common.h
 +++ b/arch/mips/ath79/common.h
-@@ -30,6 +30,7 @@ void ath79_ddr_wb_flush(unsigned int reg
+@@ -29,6 +29,7 @@ void ath79_ddr_ctrl_init(void);
  void ath79_gpio_function_enable(u32 mask);
  void ath79_gpio_function_disable(u32 mask);
  void ath79_gpio_function_setup(u32 set, u32 clear);
diff --git 
a/target/linux/ar71xx/patches-4.9/821-serial-core-add-support-for-boot-console-with-arbitr.patch
 
b/target/linux/ar71xx/patches-4.9/821-serial-core-add-support-for-boot-console-with-arbitr.patch
deleted file mode 100644
index 9d6e7bca05..0000000000
--- 
a/target/linux/ar71xx/patches-4.9/821-serial-core-add-support-for-boot-console-with-arbitr.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-From 4d3c17975c7814884a721fe693b3adf5c426d759 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <ha...@hauke-m.de>
-Date: Tue, 10 Nov 2015 22:18:39 +0100
-Subject: [RFC] serial: core: add support for boot console with arbitrary
- baud rates
-
-The Arduino Yun uses a baud rate of 250000 by default. The serial is
-going over the Atmel ATmega and is used to connect to this chip.
-Without this patch Linux wants to switch the console to 230400 Baud.
-
-With this patch Linux will use the configured baud rate and not some
-standard one which is near by.
-
-Signed-off-by: Hauke Mehrtens <ha...@hauke-m.de>
----
- drivers/tty/serial/serial_core.c | 13 ++++++++++---
- include/linux/console.h          |  1 +
- 2 files changed, 11 insertions(+), 3 deletions(-)
-
---- a/drivers/tty/serial/serial_core.c
-+++ b/drivers/tty/serial/serial_core.c
-@@ -164,6 +164,8 @@ static int uart_port_startup(struct tty_
-       if (retval == 0) {
-               if (uart_console(uport) && uport->cons->cflag) {
-                       tty->termios.c_cflag = uport->cons->cflag;
-+                      tty->termios.c_ospeed = uport->cons->baud;
-+                      tty->termios.c_ispeed = uport->cons->baud;
-                       uport->cons->cflag = 0;
-               }
-               /*
-@@ -1909,7 +1911,7 @@ static const struct baud_rates baud_rate
-       {   4800, B4800   },
-       {   2400, B2400   },
-       {   1200, B1200   },
--      {      0, B38400  }
-+      {      0, BOTHER  }
- };
- 
- /**
-@@ -1948,10 +1950,13 @@ uart_set_options(struct uart_port *port,
-        * Construct a cflag setting.
-        */
-       for (i = 0; baud_rates[i].rate; i++)
--              if (baud_rates[i].rate <= baud)
-+              if (baud_rates[i].rate == baud)
-                       break;
- 
-       termios.c_cflag |= baud_rates[i].cflag;
-+      if (!baud_rates[i].rate) {
-+              termios.c_ospeed = baud;
-+      }
- 
-       if (bits == 7)
-               termios.c_cflag |= CS7;
-@@ -1981,8 +1986,10 @@ uart_set_options(struct uart_port *port,
-        * Allow the setting of the UART parameters with a NULL console
-        * too:
-        */
--      if (co)
-+      if (co) {
-               co->cflag = termios.c_cflag;
-+              co->baud = baud;
-+      }
- 
-       return 0;
- }
---- a/include/linux/console.h
-+++ b/include/linux/console.h
-@@ -128,6 +128,7 @@ struct console {
-       short   flags;
-       short   index;
-       int     cflag;
-+      int     baud;
-       void    *data;
-       struct   console *next;
- };
diff --git 
a/target/linux/ar71xx/patches-4.9/900-mdio_bitbang_ignore_ta_value.patch 
b/target/linux/ar71xx/patches-4.9/900-mdio_bitbang_ignore_ta_value.patch
index 4536d519f8..8f8f349a66 100644
--- a/target/linux/ar71xx/patches-4.9/900-mdio_bitbang_ignore_ta_value.patch
+++ b/target/linux/ar71xx/patches-4.9/900-mdio_bitbang_ignore_ta_value.patch
@@ -1,5 +1,14 @@
 --- a/drivers/net/phy/mdio-bitbang.c
 +++ b/drivers/net/phy/mdio-bitbang.c
+@@ -155,7 +155,7 @@ static int mdiobb_cmd_addr(struct mdiobb
+ static int mdiobb_read(struct mii_bus *bus, int phy, int reg)
+ {
+       struct mdiobb_ctrl *ctrl = bus->priv;
+-      int ret, i;
++      int ret;
+ 
+       if (reg & MII_ADDR_C45) {
+               reg = mdiobb_cmd_addr(ctrl, phy, reg);
 @@ -165,19 +165,7 @@ static int mdiobb_read(struct mii_bus *b
  
        ctrl->ops->set_mdio_dir(ctrl, 0);
diff --git 
a/target/linux/ar71xx/patches-4.9/901-phy-mdio-bitbang-prevent-rescheduling-during-command.patch
 
b/target/linux/ar71xx/patches-4.9/901-phy-mdio-bitbang-prevent-rescheduling-during-command.patch
index 68f86e0e09..a830346a31 100644
--- 
a/target/linux/ar71xx/patches-4.9/901-phy-mdio-bitbang-prevent-rescheduling-during-command.patch
+++ 
b/target/linux/ar71xx/patches-4.9/901-phy-mdio-bitbang-prevent-rescheduling-during-command.patch
@@ -25,8 +25,8 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org>
 @@ -156,7 +157,9 @@ static int mdiobb_read(struct mii_bus *b
  {
        struct mdiobb_ctrl *ctrl = bus->priv;
-       int ret, i;
-+      long flags;
+       int ret;
++      unsigned long flags;
  
 +      local_irq_save(flags);
        if (reg & MII_ADDR_C45) {
@@ -44,7 +44,7 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org>
  static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
  {
        struct mdiobb_ctrl *ctrl = bus->priv;
-+      long flags;
++      unsigned long flags;
  
 +      local_irq_save(flags);
        if (reg & MII_ADDR_C45) {
diff --git 
a/target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch 
b/target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch
index 2244f882e7..cde588bca0 100644
--- a/target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch
+++ b/target/linux/ar71xx/patches-4.9/902-at803x-add-reset-gpio-pdata.patch
@@ -16,19 +16,19 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
  #endif /* _PHY_AT803X_PDATA_H */
 --- a/drivers/net/phy/at803x.c
 +++ b/drivers/net/phy/at803x.c
-@@ -243,6 +243,7 @@ static int at803x_resume(struct phy_devi
+@@ -264,6 +264,7 @@ static int at803x_resume(struct phy_devi
  
  static int at803x_probe(struct phy_device *phydev)
  {
 +      struct at803x_platform_data *pdata;
-       struct device *dev = &phydev->dev;
+       struct device *dev = &phydev->mdio.dev;
        struct at803x_priv *priv;
        struct gpio_desc *gpiod_reset;
-@@ -255,6 +256,12 @@ static int at803x_probe(struct phy_devic
+@@ -276,6 +277,12 @@ static int at803x_probe(struct phy_devic
            phydev->drv->phy_id != ATH8032_PHY_ID)
                goto does_not_require_reset_workaround;
  
-+      pdata = dev_get_platdata(&phydev->dev);
++      pdata = dev_get_platdata(dev);
 +      if (pdata && pdata->has_reset_gpio) {
 +              devm_gpio_request(dev, pdata->reset_gpio, "reset");
 +              gpio_direction_output(pdata->reset_gpio, 1);
@@ -37,7 +37,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
        gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
        if (IS_ERR(gpiod_reset))
                return PTR_ERR(gpiod_reset);
-@@ -377,15 +384,23 @@ static void at803x_link_change_notify(st
+@@ -407,15 +414,23 @@ static void at803x_link_change_notify(st
         * cannot recover from by software.
         */
        if (phydev->state == PHY_NOLINK) {
diff --git a/target/linux/ar71xx/patches-4.9/910-unaligned_access_hacks.patch 
b/target/linux/ar71xx/patches-4.9/910-unaligned_access_hacks.patch
index 5bedf5dc9e..21ceca156f 100644
--- a/target/linux/ar71xx/patches-4.9/910-unaligned_access_hacks.patch
+++ b/target/linux/ar71xx/patches-4.9/910-unaligned_access_hacks.patch
@@ -49,7 +49,7 @@
 -#define _HAVE_ARCH_IPV6_CSUM
 -static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 -                                        const struct in6_addr *daddr,
--                                        __u32 len, unsigned short proto,
+-                                        __u32 len, __u8 proto,
 -                                        __wsum sum)
 -{
 -      __wsum tmp;
@@ -184,9 +184,9 @@
  }
 --- a/include/uapi/linux/icmp.h
 +++ b/include/uapi/linux/icmp.h
-@@ -80,7 +80,7 @@ struct icmphdr {
-               __be16  mtu;
+@@ -81,7 +81,7 @@ struct icmphdr {
        } frag;
+       __u8    reserved[4];
    } un;
 -};
 +} __attribute__((packed, aligned(2)));
@@ -214,7 +214,7 @@
  #include <linux/uaccess.h>
  #include <linux/ipv6.h>
  #include <linux/icmpv6.h>
-@@ -786,10 +787,10 @@ static void tcp_v6_send_response(const s
+@@ -796,10 +797,10 @@ static void tcp_v6_send_response(const s
        topt = (__be32 *)(t1 + 1);
  
        if (tsecr) {
@@ -241,7 +241,7 @@
   */
 --- a/net/ipv6/datagram.c
 +++ b/net/ipv6/datagram.c
-@@ -433,7 +433,7 @@ int ipv6_recv_error(struct sock *sk, str
+@@ -471,7 +471,7 @@ int ipv6_recv_error(struct sock *sk, str
                                ipv6_iface_scope_id(&sin->sin6_addr,
                                                    IP6CB(skb)->iif);
                } else {
@@ -250,7 +250,7 @@
                                               &sin->sin6_addr);
                        sin->sin6_scope_id = 0;
                }
-@@ -770,12 +770,12 @@ int ip6_datagram_send_ctl(struct net *ne
+@@ -814,12 +814,12 @@ int ip6_datagram_send_ctl(struct net *ne
                        }
  
                        if (fl6->flowlabel&IPV6_FLOWINFO_MASK) {
@@ -267,7 +267,7 @@
                case IPV6_2292HOPOPTS:
 --- a/net/ipv6/ip6_gre.c
 +++ b/net/ipv6/ip6_gre.c
-@@ -395,7 +395,7 @@ static void ip6gre_err(struct sk_buff *s
+@@ -394,7 +394,7 @@ static void ip6gre_err(struct sk_buff *s
                return;
        ipv6h = (const struct ipv6hdr *)skb->data;
        greh = (const struct gre_base_hdr *)(skb->data + offset);
@@ -276,63 +276,20 @@
  
        t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
                                 key, greh->protocol);
-@@ -479,11 +479,11 @@ static int ip6gre_rcv(struct sk_buff *sk
-                       offset += 4;
-               }
-               if (flags&GRE_KEY) {
--                      key = *(__be32 *)(h + offset);
-+                      key = net_hdr_word(h + offset);
-                       offset += 4;
-               }
-               if (flags&GRE_SEQ) {
--                      seqno = ntohl(*(__be32 *)(h + offset));
-+                      seqno = ntohl(net_hdr_word(h + offset));
-                       offset += 4;
-               }
-       }
-@@ -745,7 +745,7 @@ static netdev_tx_t ip6gre_xmit2(struct s
- 
-               if (tunnel->parms.o_flags&GRE_SEQ) {
-                       ++tunnel->o_seqno;
--                      *ptr = htonl(tunnel->o_seqno);
-+                      net_hdr_word(ptr) = htonl(tunnel->o_seqno);
-                       ptr--;
-               }
-               if (tunnel->parms.o_flags&GRE_KEY) {
-@@ -841,7 +841,7 @@ static inline int ip6gre_xmit_ipv6(struc
- 
-       dsfield = ipv6_get_dsfield(ipv6h);
-       if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
--              fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
-+              fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
-       if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
-               fl6.flowlabel |= ip6_flowlabel(ipv6h);
-       if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
---- a/net/ipv6/ip6_tunnel.c
-+++ b/net/ipv6/ip6_tunnel.c
-@@ -1409,7 +1409,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
- 
-       dsfield = ipv6_get_dsfield(ipv6h);
-       if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
--              fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
-+              fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
-       if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
-               fl6.flowlabel |= ip6_flowlabel(ipv6h);
-       if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
 --- a/net/ipv6/exthdrs.c
 +++ b/net/ipv6/exthdrs.c
-@@ -573,7 +573,7 @@ static bool ipv6_hop_jumbo(struct sk_buf
+@@ -574,7 +574,7 @@ static bool ipv6_hop_jumbo(struct sk_buf
                goto drop;
        }
  
 -      pkt_len = ntohl(*(__be32 *)(nh + optoff + 2));
 +      pkt_len = ntohl(net_hdr_word(nh + optoff + 2));
        if (pkt_len <= IPV6_MAXPLEN) {
-               IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
-                                IPSTATS_MIB_INHDRERRORS);
+               __IP6_INC_STATS(net, ipv6_skb_idev(skb),
+                               IPSTATS_MIB_INHDRERRORS);
 --- a/include/linux/types.h
 +++ b/include/linux/types.h
-@@ -232,5 +232,11 @@ typedef void (*call_rcu_func_t)(struct r
+@@ -231,5 +231,11 @@ typedef void (*call_rcu_func_t)(struct r
  /* clocksource cycle base type */
  typedef u64 cycle_t;
  
@@ -346,7 +303,7 @@
  #endif /* _LINUX_TYPES_H */
 --- a/net/ipv4/af_inet.c
 +++ b/net/ipv4/af_inet.c
-@@ -1321,8 +1321,8 @@ static struct sk_buff **inet_gro_receive
+@@ -1318,8 +1318,8 @@ struct sk_buff **inet_gro_receive(struct
        if (unlikely(ip_fast_csum((u8 *)iph, 5)))
                goto out_unlock;
  
@@ -370,7 +327,7 @@
        return neigh_create(&arp_tbl, pkey, dev);
 --- a/net/ipv4/tcp_output.c
 +++ b/net/ipv4/tcp_output.c
-@@ -451,48 +451,53 @@ static void tcp_options_write(__be32 *pt
+@@ -448,48 +448,53 @@ static void tcp_options_write(__be32 *pt
        u16 options = opts->options;    /* mungable copy */
  
        if (unlikely(OPTION_MD5 & options)) {
@@ -447,7 +404,7 @@
        }
  
        if (unlikely(opts->num_sack_blocks)) {
-@@ -500,16 +505,17 @@ static void tcp_options_write(__be32 *pt
+@@ -497,16 +502,17 @@ static void tcp_options_write(__be32 *pt
                        tp->duplicate_sack : tp->selective_acks;
                int this_sack;
  
@@ -471,7 +428,7 @@
                }
  
                tp->rx_opt.dsack = 0;
-@@ -522,13 +528,14 @@ static void tcp_options_write(__be32 *pt
+@@ -519,13 +525,14 @@ static void tcp_options_write(__be32 *pt
  
                if (foc->exp) {
                        len = TCPOLEN_EXP_FASTOPEN_BASE + foc->len;
@@ -491,7 +448,7 @@
                memcpy(p, foc->val, foc->len);
 --- a/net/ipv4/igmp.c
 +++ b/net/ipv4/igmp.c
-@@ -505,7 +505,7 @@ static struct sk_buff *add_grec(struct s
+@@ -509,7 +509,7 @@ static struct sk_buff *add_grec(struct s
                if (!skb)
                        return NULL;
                psrc = (__be32 *)skb_put(skb, sizeof(__be32));
@@ -540,7 +497,7 @@
  #define IGMP_HOST_MEMBERSHIP_REPORT   0x12    /* Ditto */
 --- a/net/core/flow_dissector.c
 +++ b/net/core/flow_dissector.c
-@@ -95,7 +95,7 @@ __be32 __skb_flow_get_ports(const struct
+@@ -84,7 +84,7 @@ __be32 __skb_flow_get_ports(const struct
                ports = __skb_header_pointer(skb, thoff + poff,
                                             sizeof(_ports), data, hlen, 
&_ports);
                if (ports)
@@ -562,7 +519,7 @@
  #define ICMPV6_ROUTER_PREF_LOW                0x3
 --- a/include/net/ndisc.h
 +++ b/include/net/ndisc.h
-@@ -76,7 +76,7 @@ struct ra_msg {
+@@ -87,7 +87,7 @@ struct ra_msg {
          struct icmp6hdr               icmph;
        __be32                  reachable_time;
        __be32                  retrans_timer;
@@ -571,7 +528,7 @@
  
  struct rd_msg {
        struct icmp6hdr icmph;
-@@ -148,10 +148,10 @@ static inline u32 ndisc_hashfn(const voi
+@@ -365,10 +365,10 @@ static inline u32 ndisc_hashfn(const voi
  {
        const u32 *p32 = pkey;
  
@@ -588,7 +545,7 @@
  static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device 
*dev, const void *pkey)
 --- a/net/sched/cls_u32.c
 +++ b/net/sched/cls_u32.c
-@@ -151,7 +151,7 @@ next_knode:
+@@ -159,7 +159,7 @@ next_knode:
                        data = skb_header_pointer(skb, toff, 4, &hdata);
                        if (!data)
                                goto out;
@@ -597,7 +554,7 @@
                                n = rcu_dereference_bh(n->next);
                                goto next_knode;
                        }
-@@ -204,8 +204,8 @@ check_terminal:
+@@ -212,8 +212,8 @@ check_terminal:
                                                  &hdata);
                        if (!data)
                                goto out;
@@ -610,7 +567,7 @@
                        goto next_ht;
 --- a/net/ipv6/ip6_offload.c
 +++ b/net/ipv6/ip6_offload.c
-@@ -225,7 +225,7 @@ static struct sk_buff **ipv6_gro_receive
+@@ -220,7 +220,7 @@ static struct sk_buff **ipv6_gro_receive
                        continue;
  
                iph2 = (struct ipv6hdr *)(p->data + off);
@@ -621,7 +578,7 @@
                 * XXX skbs on the gro_list have all been parsed and pulled
 --- a/include/net/addrconf.h
 +++ b/include/net/addrconf.h
-@@ -45,7 +45,7 @@ struct prefix_info {
+@@ -46,7 +46,7 @@ struct prefix_info {
        __be32                  reserved2;
  
        struct in6_addr         prefix;
@@ -642,9 +599,9 @@
 -      *(__be32 *)iph = to;
 +      net_hdr_word(iph) = to;
        if (skb->ip_summed == CHECKSUM_COMPLETE)
-               skb->csum = csum_add(csum_sub(skb->csum, from), to);
-       return 1;
-@@ -134,7 +134,7 @@ static inline int IP6_ECN_set_ce(struct
+               skb->csum = csum_add(csum_sub(skb->csum, (__force __wsum)from),
+                                    (__force __wsum)to);
+@@ -135,7 +135,7 @@ static inline int IP6_ECN_set_ce(struct
  
  static inline void IP6_ECN_clear(struct ipv6hdr *iph)
  {
@@ -664,7 +621,7 @@
  
  #define       IP6_MF          0x0001
  #define       IP6_OFFSET      0xFFF8
-@@ -417,8 +417,8 @@ static inline void __ipv6_addr_set_half(
+@@ -449,8 +449,8 @@ static inline void __ipv6_addr_set_half(
        }
  #endif
  #endif
@@ -675,7 +632,7 @@
  }
  
  static inline void ipv6_addr_set(struct in6_addr *addr, 
-@@ -477,6 +477,8 @@ static inline bool ipv6_prefix_equal(con
+@@ -509,6 +509,8 @@ static inline bool ipv6_prefix_equal(con
        const __be32 *a1 = addr1->s6_addr32;
        const __be32 *a2 = addr2->s6_addr32;
        unsigned int pdw, pbi;
@@ -684,7 +641,7 @@
  
        /* check complete u32 in prefix */
        pdw = prefixlen >> 5;
-@@ -485,7 +487,9 @@ static inline bool ipv6_prefix_equal(con
+@@ -517,7 +519,9 @@ static inline bool ipv6_prefix_equal(con
  
        /* check incomplete u32 in prefix */
        pbi = prefixlen & 0x1f;
@@ -695,7 +652,7 @@
                return false;
  
        return true;
-@@ -629,13 +633,13 @@ static inline void ipv6_addr_set_v4mappe
+@@ -661,13 +665,13 @@ static inline void ipv6_addr_set_v4mappe
   */
  static inline int __ipv6_addr_diff32(const void *token1, const void *token2, 
int addrlen)
  {
@@ -711,7 +668,7 @@
                if (xb)
                        return i * 32 + 31 - __fls(ntohl(xb));
        }
-@@ -804,17 +808,18 @@ static inline int ip6_default_np_autolab
+@@ -836,17 +840,18 @@ static inline int ip6_default_np_autolab
  static inline void ip6_flow_hdr(struct ipv6hdr *hdr, unsigned int tclass,
                                __be32 flowlabel)
  {
@@ -803,7 +760,7 @@
        for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
 --- a/net/ipv6/ip6_fib.c
 +++ b/net/ipv6/ip6_fib.c
-@@ -138,7 +138,7 @@ static __be32 addr_bit_set(const void *t
+@@ -136,7 +136,7 @@ static __be32 addr_bit_set(const void *t
         * See include/asm-generic/bitops/le.h.
         */
        return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) &
@@ -814,7 +771,7 @@
  static struct fib6_node *node_alloc(void)
 --- a/net/netfilter/nf_conntrack_proto_tcp.c
 +++ b/net/netfilter/nf_conntrack_proto_tcp.c
-@@ -456,7 +456,7 @@ static void tcp_sack(const struct sk_buf
+@@ -452,7 +452,7 @@ static void tcp_sack(const struct sk_buf
  
        /* Fast path for timestamp-only option */
        if (length == TCPOLEN_TSTAMP_ALIGNED
@@ -838,7 +795,7 @@
  
 --- a/net/ipv4/tcp_input.c
 +++ b/net/ipv4/tcp_input.c
-@@ -3818,14 +3818,16 @@ static bool tcp_parse_aligned_timestamp(
+@@ -3886,14 +3886,16 @@ static bool tcp_parse_aligned_timestamp(
  {
        const __be32 *ptr = (const __be32 *)(th + 1);
  
@@ -862,7 +819,7 @@
                return true;
 --- a/include/uapi/linux/if_pppox.h
 +++ b/include/uapi/linux/if_pppox.h
-@@ -47,6 +47,7 @@ struct pppoe_addr {
+@@ -50,6 +50,7 @@ struct pppoe_addr {
   */
  struct pptp_addr {
        __u16           call_id;
@@ -901,7 +858,7 @@
  static inline struct neighbour *___neigh_lookup_noref(
 --- a/include/uapi/linux/netfilter_arp/arp_tables.h
 +++ b/include/uapi/linux/netfilter_arp/arp_tables.h
-@@ -68,7 +68,7 @@ struct arpt_arp {
+@@ -69,7 +69,7 @@ struct arpt_arp {
        __u8 flags;
        /* Inverse flags */
        __u16 invflags;
diff --git a/target/linux/ar71xx/patches-4.9/930-chipidea-pullup.patch 
b/target/linux/ar71xx/patches-4.9/930-chipidea-pullup.patch
index 23b8e86aac..370cbb5314 100644
--- a/target/linux/ar71xx/patches-4.9/930-chipidea-pullup.patch
+++ b/target/linux/ar71xx/patches-4.9/930-chipidea-pullup.patch
@@ -18,7 +18,7 @@
  static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
-@@ -851,7 +851,7 @@ static inline void ci_role_destroy(struc
+@@ -839,7 +839,7 @@ static inline void ci_role_destroy(struc
  {
        ci_hdrc_gadget_destroy(ci);
        ci_hdrc_host_destroy(ci);
@@ -27,7 +27,7 @@
                ci_hdrc_otg_destroy(ci);
  }
  
-@@ -902,6 +902,9 @@ static int ci_hdrc_probe(struct platform
+@@ -890,6 +890,9 @@ static int ci_hdrc_probe(struct platform
        ci->supports_runtime_pm = !!(ci->platdata->flags &
                CI_HDRC_SUPPORTS_RUNTIME_PM);
  
@@ -37,7 +37,7 @@
        ret = hw_device_init(ci, base);
        if (ret < 0) {
                dev_err(dev, "can't initialize hardware\n");
-@@ -967,7 +970,7 @@ static int ci_hdrc_probe(struct platform
+@@ -955,7 +958,7 @@ static int ci_hdrc_probe(struct platform
                goto deinit_phy;
        }
  
-- 
2.11.0


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to