Merge branch 'master' of git://nbd.name/openwrt
Merge branch 'master' of git://nbd.name/openwrt

file:a/.gitignore -> file:b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@
 *#
 .emacs.desktop*
 TAGS*~
+git-src

file:a/Config-kernel.in (deleted)
--- a/Config-kernel.in
+++ /dev/null
@@ -1,421 +1,1 @@
-config KERNEL_DEBUG_FS
-	bool "Compile the kernel with Debug FileSystem enabled"
-	default y
-	help
-	  debugfs is a virtual file system that kernel developers use to put
-	  debugging files into. Enable this option to be able to read and
-	  write to these files.
 
-config KERNEL_PERF_EVENTS
-	bool
-	default n
-
-config KERNEL_PROFILING
-	bool "Compile the kernel with profiling enabled"
-	default n
-	select KERNEL_PERF_EVENTS
-	help
-	  Enable the extended profiling support mechanisms used by profilers such
-	  as OProfile.
-
-config KERNEL_KALLSYMS
-	bool "Compile the kernel with symbol table information"
-	default y
-	help
-	  This will give you more information in stack traces from kernel oopses
-
-config KERNEL_FTRACE
-	bool "Compile the kernel with tracing support"
-	default n
-
-config KERNEL_FTRACE_SYSCALLS
-	bool "Trace system calls"
-	depends on KERNEL_FTRACE
-	default n
-
-config KERNEL_ENABLE_DEFAULT_TRACERS
-	bool "Trace process context switches and events"
-	depends on KERNEL_FTRACE
-	default n
-
-config KERNEL_DEBUG_KERNEL
-	bool
-	default n
-
-config KERNEL_DEBUG_INFO
-	bool "Compile the kernel with debug information"
-	default y
-	select KERNEL_DEBUG_KERNEL
-	help
-	  This will compile your kernel and modules with debug information.
-
-config KERNEL_DEBUG_LL_UART_NONE
-	bool
-	default n
-	depends on arm
-
-config KERNEL_DEBUG_LL
-	bool
-	default n
-	depends on arm
-	select KERNEL_DEBUG_LL_UART_NONE
-	help
-	  ARM low level debugging
-
-config KERNEL_EARLY_PRINTK
-	bool "Compile the kernel with early printk"
-	default n
-	depends on arm
-	select KERNEL_DEBUG_KERNEL
-	select KERNEL_DEBUG_LL if arm
-	help
-	  Compile the kernel with early printk support.
-	  This is only useful for debugging purposes to send messages
-	  over the serial console in early boot.
-	  Enable this to debug early boot problems.
-
-config KERNEL_AIO
-	bool "Compile the kernel with asynchronous IO support"
-	default n
-
-config KERNEL_DIRECT_IO
-	bool "Compile the kernel with direct IO support"
-	default n
-
-config KERNEL_MAGIC_SYSRQ
-	bool "Compile the kernel with SysRq support"
-	default y
-
-config KERNEL_COREDUMP
-	bool
-
-config KERNEL_ELF_CORE
-	bool "Enable process core dump support"
-	select KERNEL_COREDUMP
-	default y
-
-config KERNEL_PROVE_LOCKING
-	bool "Enable kernel lock checking"
-	select KERNEL_DEBUG_KERNEL
-	default n
-
-config KERNEL_PRINTK_TIME
-	bool "Enable printk timestamps"
-	default y
-
-config KERNEL_RELAY
-	bool
-
-config KERNEL_KEXEC
-	bool "Enable kexec support"
-
-config USE_RFKILL
-	bool "Enable rfkill support"
-	default RFKILL_SUPPORT
-
-#
-# CGROUP support symbols
-#
-
-config KERNEL_CGROUPS
-	bool "Enable kernel cgroups"
-	default n
-
-if KERNEL_CGROUPS
-
-	config KERNEL_CGROUP_DEBUG
-		bool "Example debug cgroup subsystem"
-		default n
-		help
-		  This option enables a simple cgroup subsystem that
-		  exports useful debugging information about the cgroups
-		  framework.
-
-	config KERNEL_FREEZER
-		bool
-		default y if KERNEL_CGROUP_FREEZER
-
-	config KERNEL_CGROUP_FREEZER
-		bool "Freezer cgroup subsystem"
-		default n
-		help
-		  Provides a way to freeze and unfreeze all tasks in a
-		  cgroup.
-
-	config KERNEL_CGROUP_DEVICE
-		bool "Device controller for cgroups"
-		default y
-		help
-		  Provides a cgroup implementing whitelists for devices which
-		  a process in the cgroup can mknod or open.
-
-	config KERNEL_CPUSETS
-		bool "Cpuset support"
-		default n
-		help
-		  This option will let you create and manage CPUSETs which
-		  allow dynamically partitioning a system into sets of CPUs and
-		  Memory Nodes and assigning tasks to run only within those sets.
-		  This is primarily useful on large SMP or NUMA systems.
-
-	config KERNEL_PROC_PID_CPUSET
-		bool "Include legacy /proc/<pid>/cpuset file"
-		default n
-		depends on KERNEL_CPUSETS
-
-	config KERNEL_CGROUP_CPUACCT
-		bool "Simple CPU accounting cgroup subsystem"
-		default n
-		help
-		  Provides a simple Resource Controller for monitoring the
-		  total CPU consumed by the tasks in a cgroup.
-
-	config KERNEL_RESOURCE_COUNTERS
-		bool "Resource counters"
-		default n
-		help
-		  This option enables controller independent resource accounting
-		  infrastructure that works with cgroups.
-
-	config KERNEL_MM_OWNER
-		bool
-		default y if KERNEL_MEMCG
-
-	config KERNEL_MEMCG
-		bool "Memory Resource Controller for Control Groups"
-		default n
-		depends on KERNEL_RESOURCE_COUNTERS
-		help
-		  Provides a memory resource controller that manages both anonymous
-		  memory and page cache. (See Documentation/cgroups/memory.txt)
-
-		  Note that setting this option increases fixed memory overhead
-		  associated with each page of memory in the system. By this,
-		  20(40)bytes/PAGE_SIZE on 32(64)bit system will be occupied by memory
-		  usage tracking struct at boot. Total amount of this is printed out
-		  at boot.
-
-		  Only enable when you're ok with these trade offs and really
-		  sure you need the memory resource controller. Even when you enable
-		  this, you can set "cgroup_disable=memory" at your boot option to
-		  disable memory resource controller and you can avoid overheads.
-		  (and lose benefits of memory resource controller)
-
-		  This config option also selects MM_OWNER config option, which
-		  could in turn add some fork/exit overhead.
-
-	config KERNEL_MEMCG_SWAP
-		bool "Memory Resource Controller Swap Extension"
-		default n
-		depends on KERNEL_MEMCG
-		help
-		  Add swap management feature to memory resource controller. When you
-		  enable this, you can limit mem+swap usage per cgroup. In other words,
-		  when you disable this, memory resource controller has no cares to
-		  usage of swap...a process can exhaust all of the swap. This extension
-		  is useful when you want to avoid exhaustion swap but this itself
-		  adds more overheads and consumes memory for remembering information.
-		  Especially if you use 32bit system or small memory system, please
-		  be careful about enabling this. When memory resource controller
-		  is disabled by boot option, this will be automatically disabled and
-		  there will be no overhead from this. Even when you set this config=y,
-		  if boot option "swapaccount=0" is set, swap will not be accounted.
-		  Now, memory usage of swap_cgroup is 2 bytes per entry. If swap page
-		  size is 4096bytes, 512k per 1Gbytes of swap.
-
-	config KERNEL_MEMCG_SWAP_ENABLED
-		bool "Memory Resource Controller Swap Extension enabled by default"
-		default n
-		depends on KERNEL_MEMCG_SWAP
-		help
-		  Memory Resource Controller Swap Extension comes with its price in
-		  a bigger memory consumption. General purpose distribution kernels
-		  which want to enable the feature but keep it disabled by default
-		  and let the user enable it by swapaccount boot command line
-		  parameter should have this option unselected.
-		  For those who want to have the feature enabled by default should
-		  select this option (if, for some reason, they need to disable it
-		  then swapaccount=0 does the trick).
-
-
-	config KERNEL_MEMCG_KMEM
-		bool "Memory Resource Controller Kernel Memory accounting (EXPERIMENTAL)"
-		default n
-		depends on KERNEL_MEMCG
-		help
-		  The Kernel Memory extension for Memory Resource Controller can limit
-		  the amount of memory used by kernel objects in the system. Those are
-		  fundamentally different from the entities handled by the standard
-		  Memory Controller, which are page-based, and can be swapped. Users of
-		  the kmem extension can use it to guarantee that no group of processes
-		  will ever exhaust kernel resources alone.
-
-	config KERNEL_PERF_EVENTS
-		bool
-		default y if KERNEL_CGROUP_PERF
-
-	config KERNEL_CGROUP_PERF
-		bool "Enable perf_event per-cpu per-container group (cgroup) monitoring"
-		default n
-		help
-		  This option extends the per-cpu mode to restrict monitoring to
-		  threads which belong to the cgroup specified and run on the
-		  designated cpu.
-
-	menuconfig KERNEL_CGROUP_SCHED
-		bool "Group CPU scheduler"
-		default n
-		help
-		  This feature lets CPU scheduler recognize task groups and control CPU
-		  bandwidth allocation to such task groups. It uses cgroups to group
-		  tasks.
-
-	if KERNEL_CGROUP_SCHED
-
-		config KERNEL_FAIR_GROUP_SCHED
-			bool "Group scheduling for SCHED_OTHER"
-			default n
-
-		config KERNEL_CFS_BANDWIDTH
-			bool "CPU bandwidth provisioning for FAIR_GROUP_SCHED"
-			default n
-			depends on KERNEL_FAIR_GROUP_SCHED
-			help
-			  This option allows users to define CPU bandwidth rates (limits) for
-			  tasks running within the fair group scheduler.  Groups with no limit
-			  set are considered to be unconstrained and will run with no
-			  restriction.
-			  See tip/Documentation/scheduler/sched-bwc.txt for more information.
-
-		config KERNEL_RT_GROUP_SCHED
-			bool "Group scheduling for SCHED_RR/FIFO"
-			default n
-			help
-			  This feature lets you explicitly allocate real CPU bandwidth
-			  to task groups. If enabled, it will also make it impossible to
-			  schedule realtime tasks for non-root users until you allocate
-			  realtime bandwidth for them.
-
-	endif
-
-	config KERNEL_BLK_CGROUP
-		bool "Block IO controller"
-		default y
-		help
-		  Generic block IO controller cgroup interface. This is the common
-		  cgroup interface which should be used by various IO controlling
-		  policies.
-
-		  Currently, CFQ IO scheduler uses it to recognize task groups and
-		  control disk bandwidth allocation (proportional time slice allocation)
-		  to such task groups. It is also used by bio throttling logic in
-		  block layer to implement upper limit in IO rates on a device.
-
-		  This option only enables generic Block IO controller infrastructure.
-		  One needs to also enable actual IO controlling logic/policy. For
-		  enabling proportional weight division of disk bandwidth in CFQ, set
-		  CONFIG_CFQ_GROUP_IOSCHED=y; for enabling throttling policy, set
-		  CONFIG_BLK_DEV_THROTTLING=y.
-
-	config KERNEL_DEBUG_BLK_CGROUP
-		bool "Enable Block IO controller debugging"
-		default n
-		depends on KERNEL_BLK_CGROUP
-		help
-		  Enable some debugging help. Currently it exports additional stat
-		  files in a cgroup which can be useful for debugging.
-
-	config KERNEL_NET_CLS_CGROUP
-		bool "Control Group Classifier"
-		default y
-
-	config KERNEL_NETPRIO_CGROUP
-		bool "Network priority cgroup"
-		default y
-
-endif
-
-#
-# Namespace support symbols
-#
-
-config KERNEL_NAMESPACES
-	bool "Enable kernel namespaces"
-	default n
-
-if KERNEL_NAMESPACES
-
-	config KERNEL_UTS_NS
-		bool "UTS namespace"
-		default y
-		help
-		  In this namespace tasks see different info provided
-		  with the uname() system call
-
-	config KERNEL_IPC_NS
-		bool "IPC namespace"
-		default y
-		help
-		  In this namespace tasks work with IPC ids which correspond to
-		  different IPC objects in different namespaces.
-
-	config KERNEL_USER_NS
-		bool "User namespace (EXPERIMENTAL)"
-		default y
-		help
-		  This allows containers, i.e. vservers, to use user namespaces
-		  to provide different user info for different servers.
-
-	config KERNEL_PID_NS
-		bool "PID Namespaces"
-		default y
-		help
-		  Support process id namespaces. This allows having multiple
-		  processes with the same pid as long as they are in different
-		  pid namespaces. This is a building block of containers.
-
-	config KERNEL_NET_NS
-		bool "Network namespace"
-		default y
-		help
-		  Allow user space to create what appear to be multiple instances
-		  of the network stack.
-
-endif
-
-#
-# LXC related symbols
-#
-
-config KERNEL_LXC_MISC
-	bool "Enable miscellaneous LXC related options"
-	default n
-
-if KERNEL_LXC_MISC
-
-	config KERNEL_DEVPTS_MULTIPLE_INSTANCES
-		bool "Support multiple instances of devpts"
-		default y
-		help
-		  Enable support for multiple instances of devpts filesystem.
-		  If you want to have isolated PTY namespaces (eg: in containers),
-		  say Y here. Otherwise, say N. If enabled, each mount of devpts
-		  filesystem with the '-o newinstance' option will create an
-		  independent PTY namespace.
-
-	config KERNEL_POSIX_MQUEUE
-		bool "POSIX Message Queues"
-		default n
-		help
-		  POSIX variant of message queues is a part of IPC. In POSIX message
-		  queues every message has a priority which decides about succession
-		  of receiving it by a process. If you want to compile and run
-		  programs written e.g. for Solaris with use of its POSIX message
-		  queues (functions mq_*) say Y here.
-
-		  POSIX message queues are visible as a filesystem called 'mqueue'
-		  and can be mounted somewhere if you want to do filesystem
-		  operations on message queues.
-
-endif
-

file:a/Config.in -> file:b/Config.in
--- a/Config.in
+++ b/Config.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2006-2013 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -16,528 +16,18 @@
 
 source "target/Config.in"
 
-menu "Target Images"
+source "config/Config-images.in"
 
-	menuconfig TARGET_ROOTFS_INITRAMFS
-		bool "ramdisk"
-		default y if USES_INITRAMFS
-		help
-		  Embed the rootfs into the kernel (initramfs)
+source "config/Config-build.in"
 
-		choice
-			prompt "Compression"
-			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
-			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
-			default TARGET_INITRAMFS_COMPRESSION_NONE
-			depends on TARGET_ROOTFS_INITRAMFS
-			help
-			  Select ramdisk compression.
-
-			config TARGET_INITRAMFS_COMPRESSION_NONE
-				bool "none"
-
-			config TARGET_INITRAMFS_COMPRESSION_GZIP
-				bool "gzip"
-
-			config TARGET_INITRAMFS_COMPRESSION_BZIP2
-				bool "bzip2"
-
-			config TARGET_INITRAMFS_COMPRESSION_LZMA
-				bool "lzma"
-
-			config TARGET_INITRAMFS_COMPRESSION_LZO
-				bool "lzo"
-
-			config TARGET_INITRAMFS_COMPRESSION_LZ4
-				bool "lz4"
-
-			config TARGET_INITRAMFS_COMPRESSION_XZ
-				bool "xz"
-		endchoice
-
-		config EXTERNAL_CPIO
-			string
-			prompt "Use external cpio" if TARGET_ROOTFS_INITRAMFS
-			default ""
-			help
-			  Kernel uses specified external cpio as INITRAMFS_SOURCE
-
-	comment "Root filesystem archives"
-
-	config TARGET_ROOTFS_CPIOGZ
-		bool "cpio.gz"
-		default y if USES_CPIOGZ
-		help
-		  Build a compressed cpio archive of the the root filesystem
-
-	config TARGET_ROOTFS_TARGZ
-		bool "tar.gz"
-		default y if USES_TARGZ
-		help
-		  Build a compressed tar archive of the the root filesystem
-
-	comment "Root filesystem images"
-
-	config TARGET_ROOTFS_EXT4FS
-		bool "ext4"
-		default y if USES_EXT4
-		help
-		  Ext4 file system with some free space for uml images
-
-	config TARGET_ROOTFS_ISO
-		bool "iso"
-		default n
-		depends on TARGET_x86_generic
-		help
-		  Create some bootable ISO image
-
-	config TARGET_ROOTFS_JFFS2
-		bool "jffs2"
-		default y if USES_JFFS2
-		help
-		  Build a jffs2 root filesystem
-
-	config TARGET_ROOTFS_JFFS2_NAND
-		bool "jffs2 for NAND"
-		default y if USES_JFFS2_NAND
-		depends on USES_JFFS2_NAND
-		help
-		  Build a jffs2 root filesystem for NAND flash
-
-	config TARGET_ROOTFS_SQUASHFS
-		bool "squashfs"
-		default y if USES_SQUASHFS
-		help
-		  Build a squashfs-lzma root filesystem
-
-	menuconfig TARGET_ROOTFS_UBIFS
-		bool "ubifs"
-		default y if USES_UBIFS
-		depends on USES_UBIFS
-		help
-		  Build a ubifs root filesystem
-
-		choice
-			prompt "compression"
-			default TARGET_UBIFS_COMPRESSION_NONE
-			depends on TARGET_ROOTFS_UBIFS
-			help
-			  Select compression type
-
-			config TARGET_UBIFS_COMPRESSION_NONE
-				bool "none"
-
-			config TARGET_UBIFS_COMPRESSION_LZO
-				bool "lzo"
-
-			config TARGET_UBIFS_COMPRESSION_ZLIB
-				bool "zlib"
-		endchoice
-
-		config TARGET_UBIFS_FREE_SPACE_FIXUP
-			bool "free space fixup" if TARGET_ROOTFS_UBIFS
-			default y
-			help
-			  The file-system free space has to be fixed up on first mount
-
-		config TARGET_UBIFS_JOURNAL_SIZE
-			string
-			prompt "journal size" if TARGET_ROOTFS_UBIFS
-			default "512KiB"
-
-		config TARGET_UBIFS_SQUASH_UIDS
-			bool "squash uids" if TARGET_ROOTFS_UBIFS
-			default n
-			help
-			  Squash owners making all files owned by root
-
-	comment "Image Options"
-
-	source "target/linux/*/image/Config.in"
-
-	config TARGET_ROOTFS_PARTSIZE
-		int "Root filesystem partition size (in MB)"
-		depends on X86_GRUB_IMAGES || TARGET_ROOTFS_EXT4FS || TARGET_rb532
-		default 48
-		help
-		  Allows you to change the root filesystem partition size
-
-	config TARGET_ROOTFS_MAXINODE
-		int "Maximum number of inodes in root filesystem"
-		depends on TARGET_ROOTFS_EXT4FS
-		default 6000
-		help
-		  Allows you to change the maximum number of inodes in the root filesystem
-
-	config TARGET_ROOTFS_RESERVED_PCT
-		int "Percentage of reserved blocks in root filesystem"
-		depends on TARGET_ROOTFS_EXT4FS
-		default 0
-		help
-		  Allows you to change the percentage of reserved blocks in the root filesystem
-
-	menuconfig TARGET_ROOTFS_INCLUDE_KERNEL
-		bool "Include kernel in root filesystem"
-		depends on TARGET_ROOTFS_UBIFS || TARGET_ROOTFS_EXT4FS
-		default n if USES_UBIFS
-		help
-		  Include the kernel image in the rootfs. Typically the image is placed
-		  below /boot.
-
-		config TARGET_ROOTFS_INCLUDE_UIMAGE
-			bool "include uImage" if TARGET_ROOTFS_INCLUDE_KERNEL
-			default y
-			help
-			  This option might not apply to all targets. Make sure
-			  to check target/linux/<your_target>/image/Makefile to
-			  see if this option will have any effect.
-
-		config TARGET_ROOTFS_INCLUDE_ZIMAGE
-			bool "include zImage" if TARGET_ROOTFS_INCLUDE_KERNEL
-			default y
-			help
-			  This option might not apply to all targets. Make sure
-			  to check target/linux/<your_target>/image/Makefile to
-			  see if this option will have any effect.
-
-		config TARGET_ROOTFS_INCLUDE_FIT
-			bool "include FIT" if TARGET_ROOTFS_INCLUDE_KERNEL
-			default y
-			help
-			  This option might not apply to all targets. Make sure
-			  to check target/linux/<your_target>/image/Makefile to
-			  see if this option will have any effect.
-
-	config TARGET_ROOTFS_INCLUDE_DTB
-		bool "Include DTB in root filesystem"
-		depends on TARGET_ROOTFS_UBIFS || TARGET_ROOTFS_EXT4FS
-		default n if USES_UBIFS
-		help
-		  Include the device tree blob file(s) in the rootfs. Typically the DTBs
-		  are placed below /boot.
-
-endmenu
-
-menu "Global build settings"
-
-	config ALL
-		bool "Select all packages by default"
-		default n
-
-	comment "General build options"
-
-	config DISPLAY_SUPPORT
-		bool "Show packages that require graphics support (local or remote)"
-		default n
-
-	config BUILD_PATENTED
-		default y
-		bool "Compile with support for patented functionality"
-		help
-		  When this option is disabled, software which provides patented functionality will not be built.
-		  In case software provides optional support for patented functionality,
-		  this optional support will get disabled for this package.
-
-	config BUILD_NLS
-		default n
-		bool "Compile with full language support"
-		help
-		  When this option is enabled, packages are built with the full versions of iconv and GNU gettext
-		  instead of the default OpenWrt stubs. If uClibc is used, it is also built with locale support.
-
-	config BUILD_STATIC_TOOLS
-		default n
-		bool "Attempt to link host utilities statically"
-		help
-		  Linking host utilities like sed or firmware-utils statically increases the portability of the
-		  generated ImageBuilder and SDK tarballs, however it may fail on some Linux distributions.
-
-	config SHADOW_PASSWORDS
-		bool
-		prompt "Enable shadow password support"
-		default y
-		help
-		  Enable shadow password support.
-
-	config CLEAN_IPKG
-		bool
-		prompt "Remove ipkg/opkg status data files in final images"
-		default n
-		help
-		  This removes all ipkg/opkg status data files from the target directory before building the root fs
-
-	config COLLECT_KERNEL_DEBUG
-		bool
-		prompt "Collect kernel debug information"
-		select KERNEL_DEBUG_INFO
-		default n
-		help
-		  This collects debugging symbols from the kernel and all compiled modules.
-		  Useful for release builds, so that kernel issues can be debugged offline later.
-
-	comment "Kernel build options"
-
-	source "Config-kernel.in"
-
-	comment "Package build options"
-
-	config DEBUG
-		bool
-		prompt "Compile packages with debugging info"
-		default n
-		help
-		  Adds -g3 to the CFLAGS
-
-	config IPV6
-		bool
-		prompt "Enable IPv6 support in packages"
-		default y
-		help
-		  Enable IPV6 support in packages (passes --enable-ipv6 to configure scripts).
-
-	config PKG_BUILD_PARALLEL
-		bool
-		prompt "Compile certain packages parallelized"
-		default y
-		help
-		  This adds a -jX option to certain packages that are known to
-		  behave well for parallel build. By default the package make processes
-		  use the main jobserver, in which case this option only takes effect
-		  when you add -jX to the make command.
-
-		  If you are unsure, select N.
-
-	config PKG_BUILD_USE_JOBSERVER
-		bool
-		prompt "Use top-level make jobserver for packages"
-		depends on PKG_BUILD_PARALLEL
-		default y
-		help
-		  This passes the main make process jobserver fds to package builds,
-		  enabling full parallelization across different packages
-
-		  Note that disabling this may overcommit CPU resources depending on the
-		  -j level of the main make process, the number of package
-		  submake jobs selected below and the number of actual CPUs present.
-		  Example: If the main make is passed a -j4 and the submake -j
-		  is also set to 4, we may end up with 16 parallel make processes
-		  in the worst case.
-
-
-	config PKG_BUILD_JOBS
-		int
-		prompt "Number of package submake jobs (2-512)"
-		range 2 512
-		default 2
-		depends on PKG_BUILD_PARALLEL && !PKG_BUILD_USE_JOBSERVER
-		help
-		  The number of jobs (-jX) to pass to packages submake.
-
-	config PKG_DEFAULT_PARALLEL
-		bool
-		prompt "Parallelize the default package build rule (May break build)"
-		depends on PKG_BUILD_PARALLEL
-		depends on BROKEN
-		default n
-		help
-		  Always set the default package build rules to parallel build.
-
-		  WARNING: This may break build or kill your cat, as it builds
-		  packages with multiple jobs that are probably not tested in
-		  a parallel build environment.
-
-		  Only say Y, if you don't mind fixing broken packages.
-		  Before reporting build bugs, set this to N and re-run the build.
-
-	comment "Stripping options"
-
-	choice
-		prompt "Binary stripping method"
-		default USE_STRIP   if EXTERNAL_TOOLCHAIN
-		default USE_STRIP   if USE_GLIBC || USE_EGLIBC || USE_MUSL
-		default USE_SSTRIP
-		help
-		  Select the binary stripping method you wish to use.
-
-		config NO_STRIP
-			bool "none"
-			help
-			  This will install unstripped binaries (useful for native compiling/debugging)
-
-		config USE_STRIP
-			bool "strip"
-			help
-			  This will install binaries stripped using strip from binutils
-
-
-		config USE_SSTRIP
-			bool "sstrip"
-			depends on !DEBUG
-			depends on !USE_GLIBC
-			depends on !USE_EGLIBC
-			help
-			  This will install binaries stripped using sstrip
-	endchoice
-
-	config STRIP_ARGS
-		string
-		prompt "Strip arguments"
-		depends on USE_STRIP
-		default "--strip-unneeded --remove-section=.comment --remove-section=.note" if DEBUG
-		default "--strip-all"
-		help
-		  Specifies arguments passed to the strip command when stripping binaries
-
-	config STRIP_KERNEL_EXPORTS
-		bool "Strip unnecessary exports from the kernel image"
-		help
-		  Reduces kernel size by stripping unused kernel exports from the kernel image
-		  Note that this might make the kernel incompatible with any kernel modules that
-		  were not selected at the time the kernel image was created
-
-	config USE_MKLIBS
-		bool "Strip unnecessary functions from libraries"
-		help
-		  Reduces libraries to only those functions that are necessary for using all
-		  selected packages (including those selected as <M>)
-		  Note that this will make the system libraries incompatible with most of the packages
-		  that are not selected during the build process
-
-	choice
-		prompt "Preferred standard C++ library"
-		default USE_LIBSTDCXX if USE_EGLIBC
-		default USE_UCLIBCXX
-		help
-		  Select the preferred standard C++ library for all packages that support this.
-
-		config USE_UCLIBCXX
-			bool "uClibc++"
-
-		config USE_LIBSTDCXX
-			bool "libstdc++"
-	endchoice
-
-endmenu
-
-menuconfig DEVEL
-	bool "Advanced configuration options (for developers)"
-	default n
-
-	config BROKEN
-		bool "Show broken platforms / packages" if DEVEL
-		default n
-
-	config DOWNLOAD_FOLDER
-		string "Download folder" if DEVEL
-		default ""
-
-	config LOCALMIRROR
-		string "Local mirror for source packages" if DEVEL
-		default ""
-
-	config AUTOREBUILD
-		bool "Automatic rebuild of packages" if DEVEL
-		default y
-		help
-		  Automatically rebuild packages when their files change
-
-	config BUILD_SUFFIX
-		string "Build suffix to append to the BUILD_DIR variable" if DEVEL
-		default ""
-		help
-		  Build suffix to append to the BUILD_DIR variable, i.e: build_dir_suffix
-
-	config TARGET_ROOTFS_DIR
-		string "Override the default TARGET_ROOTFS_DIR variable" if DEVEL
-		default ""
-		help
-		  Override the default TARGET_ROOTFS_DIR variable content $(BUILD_DIR) with custom path.
-		  Use this option to re-define the location of the target root file system directory.
-
-	config CCACHE
-		bool "Use ccache" if DEVEL
-		default n
-		help
-		  Compiler cache; see http://ccache.samba.org/
-
-	config EXTERNAL_KERNEL_TREE
-		string "Use external kernel tree" if DEVEL
-		default ""
-
-	config KERNEL_GIT_CLONE_URI
-		string "Enter git repository to clone" if DEVEL
-		default ""
-		help
-		  Enter the full git repository path i.e.:
-		  git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
-		  This will create a git clone of the kernel in your build
-		  directory.
-
-	config KERNEL_GIT_LOCAL_REPOSITORY
-		string "Enter path to local reference repository" if DEVEL
-		default ""
-		help
-		  Enter a full pathname to a local reference git repository.
-		  In this instance, the --refererence option of git clone will
-		  be used thus creating a quick local clone of your repo.
-
-	config BUILD_LOG
-		bool "Enable log files during build process" if DEVEL
-		help
-		  If enabled log files will be written to the ./log directory
-
-	config SRC_TREE_OVERRIDE
-		bool "Enable package source tree override" if DEVEL
-		help
-		  If enabled, you can force a package to use a git tree as source
-		  code instead of the normal tarball. Create a symlink 'git-src'
-		  in the package directory, pointing to the .git tree that you want
-		  to pull the source code from
-
-	config EXTRA_OPTIMIZATION
-		string "Additional compiler options" if DEVEL
-		default "-fno-caller-saves"
-		help
-		  Extra Target-independent optimizations to use when building for the target.
-
-menuconfig TARGET_OPTIONS
-	bool "Target Options"  if DEVEL
-
-	config TARGET_OPTIMIZATION
-		string "Target Optimizations" if TARGET_OPTIONS
-		default DEFAULT_TARGET_OPTIMIZATION
-		help
-		  Optimizations to use when building for the target host.
-
-	config SOFT_FLOAT
-		bool "Use software floating point by default" if TARGET_OPTIONS
-		default y
-		depends on (arm || armeb || powerpc || mipsel || mips || mips64el || mips64) && !HAS_FPU
-		help
-		  If your target CPU does not have a Floating Point Unit (FPU) or a
-		  kernel FPU emulator, but you still wish to support floating point
-		  functions, then everything will need to be compiled with soft floating
-		  point support (-msoft-float).
-
-		  Most people will answer N.
-
-	config USE_MIPS16
-		bool "Build packages with MIPS16 instructions" if TARGET_OPTIONS
-		depends on HAS_MIPS16
-		depends on !GCC_VERSION_4_6
-		default y
-		help
-		  If your target CPU does support the MIPS16 instruction set
-		  and you want to use it for packages, enable this option.
-		  MIPS16 produces smaller binaries thus reducing pressure on
-		  caches and TLB.
-
-		  Most people will answer N.
+source "config/Config-devel.in"
 
 source "toolchain/Config.in"
 
 source "target/imagebuilder/Config.in"
+
 source "target/sdk/Config.in"
+
 source "target/toolchain/Config.in"
 
 source "tmp/.config-package.in"

--- /dev/null
+++ b/config/Config-build.in
@@ -1,1 +1,207 @@
-
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menu "Global build settings"
+
+	config ALL
+		bool "Select all packages by default"
+		default n
+
+	comment "General build options"
+
+	config DISPLAY_SUPPORT
+		bool "Show packages that require graphics support (local or remote)"
+		default n
+
+	config BUILD_PATENTED
+		default y
+		bool "Compile with support for patented functionality"
+		help
+		  When this option is disabled, software which provides patented functionality will not be built.
+		  In case software provides optional support for patented functionality,
+		  this optional support will get disabled for this package.
+
+	config BUILD_NLS
+		default n
+		bool "Compile with full language support"
+		help
+		  When this option is enabled, packages are built with the full versions of iconv and GNU gettext
+		  instead of the default OpenWrt stubs. If uClibc is used, it is also built with locale support.
+
+	config BUILD_STATIC_TOOLS
+		default n
+		bool "Attempt to link host utilities statically"
+		help
+		  Linking host utilities like sed or firmware-utils statically increases the portability of the
+		  generated ImageBuilder and SDK tarballs, however it may fail on some Linux distributions.
+
+	config SHADOW_PASSWORDS
+		bool
+		prompt "Enable shadow password support"
+		default y
+		help
+		  Enable shadow password support.
+
+	config CLEAN_IPKG
+		bool
+		prompt "Remove ipkg/opkg status data files in final images"
+		default n
+		help
+		  This removes all ipkg/opkg status data files from the target directory before building the root fs
+
+	config COLLECT_KERNEL_DEBUG
+		bool
+		prompt "Collect kernel debug information"
+		select KERNEL_DEBUG_INFO
+		default n
+		help
+		  This collects debugging symbols from the kernel and all compiled modules.
+		  Useful for release builds, so that kernel issues can be debugged offline later.
+
+	comment "Kernel build options"
+
+	source "config/Config-kernel.in"
+
+	comment "Package build options"
+
+	config DEBUG
+		bool
+		prompt "Compile packages with debugging info"
+		default n
+		help
+		  Adds -g3 to the CFLAGS
+
+	config IPV6
+		bool
+		prompt "Enable IPv6 support in packages"
+		default y
+		help
+		  Enable IPV6 support in packages (passes --enable-ipv6 to configure scripts).
+
+	config PKG_BUILD_PARALLEL
+		bool
+		prompt "Compile certain packages parallelized"
+		default y
+		help
+		  This adds a -jX option to certain packages that are known to
+		  behave well for parallel build. By default the package make processes
+		  use the main jobserver, in which case this option only takes effect
+		  when you add -jX to the make command.
+
+		  If you are unsure, select N.
+
+	config PKG_BUILD_USE_JOBSERVER
+		bool
+		prompt "Use top-level make jobserver for packages"
+		depends on PKG_BUILD_PARALLEL
+		default y
+		help
+		  This passes the main make process jobserver fds to package builds,
+		  enabling full parallelization across different packages
+
+		  Note that disabling this may overcommit CPU resources depending on the
+		  -j level of the main make process, the number of package
+		  submake jobs selected below and the number of actual CPUs present.
+		  Example: If the main make is passed a -j4 and the submake -j
+		  is also set to 4, we may end up with 16 parallel make processes
+		  in the worst case.
+
+
+	config PKG_BUILD_JOBS
+		int
+		prompt "Number of package submake jobs (2-512)"
+		range 2 512
+		default 2
+		depends on PKG_BUILD_PARALLEL && !PKG_BUILD_USE_JOBSERVER
+		help
+		  The number of jobs (-jX) to pass to packages submake.
+
+	config PKG_DEFAULT_PARALLEL
+		bool
+		prompt "Parallelize the default package build rule (May break build)"
+		depends on PKG_BUILD_PARALLEL
+		depends on BROKEN
+		default n
+		help
+		  Always set the default package build rules to parallel build.
+
+		  WARNING: This may break build or kill your cat, as it builds
+		  packages with multiple jobs that are probably not tested in
+		  a parallel build environment.
+
+		  Only say Y, if you don't mind fixing broken packages.
+		  Before reporting build bugs, set this to N and re-run the build.
+
+	comment "Stripping options"
+
+	choice
+		prompt "Binary stripping method"
+		default USE_STRIP   if EXTERNAL_TOOLCHAIN
+		default USE_STRIP   if USE_GLIBC || USE_EGLIBC || USE_MUSL
+		default USE_SSTRIP
+		help
+		  Select the binary stripping method you wish to use.
+
+		config NO_STRIP
+			bool "none"
+			help
+			  This will install unstripped binaries (useful for native compiling/debugging)
+
+		config USE_STRIP
+			bool "strip"
+			help
+			  This will install binaries stripped using strip from binutils
+
+
+		config USE_SSTRIP
+			bool "sstrip"
+			depends on !DEBUG
+			depends on !USE_GLIBC
+			depends on !USE_EGLIBC
+			help
+			  This will install binaries stripped using sstrip
+	endchoice
+
+	config STRIP_ARGS
+		string
+		prompt "Strip arguments"
+		depends on USE_STRIP
+		default "--strip-unneeded --remove-section=.comment --remove-section=.note" if DEBUG
+		default "--strip-all"
+		help
+		  Specifies arguments passed to the strip command when stripping binaries
+
+	config STRIP_KERNEL_EXPORTS
+		bool "Strip unnecessary exports from the kernel image"
+		help
+		  Reduces kernel size by stripping unused kernel exports from the kernel image
+		  Note that this might make the kernel incompatible with any kernel modules that
+		  were not selected at the time the kernel image was created
+
+	config USE_MKLIBS
+		bool "Strip unnecessary functions from libraries"
+		help
+		  Reduces libraries to only those functions that are necessary for using all
+		  selected packages (including those selected as <M>)
+		  Note that this will make the system libraries incompatible with most of the packages
+		  that are not selected during the build process
+
+	choice
+		prompt "Preferred standard C++ library"
+		default USE_LIBSTDCXX if USE_EGLIBC
+		default USE_UCLIBCXX
+		help
+		  Select the preferred standard C++ library for all packages that support this.
+
+		config USE_UCLIBCXX
+			bool "uClibc++"
+
+		config USE_LIBSTDCXX
+			bool "libstdc++"
+	endchoice
+
+endmenu
+

--- /dev/null
+++ b/config/Config-devel.in
@@ -1,1 +1,91 @@
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
 
+menuconfig DEVEL
+	bool "Advanced configuration options (for developers)"
+	default n
+
+	config BROKEN
+		bool "Show broken platforms / packages" if DEVEL
+		default n
+
+	config BINARY_FOLDER
+		string "Binary folder" if DEVEL
+		default ""
+
+	config DOWNLOAD_FOLDER
+		string "Download folder" if DEVEL
+		default ""
+
+	config LOCALMIRROR
+		string "Local mirror for source packages" if DEVEL
+		default ""
+
+	config AUTOREBUILD
+		bool "Automatic rebuild of packages" if DEVEL
+		default y
+		help
+		  Automatically rebuild packages when their files change
+
+	config BUILD_SUFFIX
+		string "Build suffix to append to the BUILD_DIR variable" if DEVEL
+		default ""
+		help
+		  Build suffix to append to the BUILD_DIR variable, i.e: build_dir_suffix
+
+	config TARGET_ROOTFS_DIR
+		string "Override the default TARGET_ROOTFS_DIR variable" if DEVEL
+		default ""
+		help
+		  Override the default TARGET_ROOTFS_DIR variable content $(BUILD_DIR) with custom path.
+		  Use this option to re-define the location of the target root file system directory.
+
+	config CCACHE
+		bool "Use ccache" if DEVEL
+		default n
+		help
+		  Compiler cache; see http://ccache.samba.org/
+
+	config EXTERNAL_KERNEL_TREE
+		string "Use external kernel tree" if DEVEL
+		default ""
+
+	config KERNEL_GIT_CLONE_URI
+		string "Enter git repository to clone" if DEVEL
+		default ""
+		help
+		  Enter the full git repository path i.e.:
+		  git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+		  This will create a git clone of the kernel in your build
+		  directory.
+
+	config KERNEL_GIT_LOCAL_REPOSITORY
+		string "Enter path to local reference repository" if DEVEL
+		default ""
+		help
+		  Enter a full pathname to a local reference git repository.
+		  In this instance, the --refererence option of git clone will
+		  be used thus creating a quick local clone of your repo.
+
+	config BUILD_LOG
+		bool "Enable log files during build process" if DEVEL
+		help
+		  If enabled log files will be written to the ./log directory
+
+	config SRC_TREE_OVERRIDE
+		bool "Enable package source tree override" if DEVEL
+		help
+		  If enabled, you can force a package to use a git tree as source
+		  code instead of the normal tarball. Create a symlink 'git-src'
+		  in the package directory, pointing to the .git tree that you want
+		  to pull the source code from
+
+	config EXTRA_OPTIMIZATION
+		string "Additional compiler options" if DEVEL
+		default "-fno-caller-saves"
+		help
+		  Extra Target-independent optimizations to use when building for the target.
+

--- /dev/null
+++ b/config/Config-images.in
@@ -1,1 +1,281 @@
-
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menu "Target Images"
+
+	menuconfig TARGET_ROOTFS_INITRAMFS
+		bool "ramdisk"
+		default y if USES_INITRAMFS
+		help
+		  Embed the rootfs into the kernel (initramfs)
+
+		choice
+			prompt "Compression"
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
+			default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
+			default TARGET_INITRAMFS_COMPRESSION_NONE
+			depends on TARGET_ROOTFS_INITRAMFS
+			help
+			  Select ramdisk compression.
+
+			config TARGET_INITRAMFS_COMPRESSION_NONE
+				bool "none"
+
+			config TARGET_INITRAMFS_COMPRESSION_GZIP
+				bool "gzip"
+
+			config TARGET_INITRAMFS_COMPRESSION_BZIP2
+				bool "bzip2"
+
+			config TARGET_INITRAMFS_COMPRESSION_LZMA
+				bool "lzma"
+
+			config TARGET_INITRAMFS_COMPRESSION_LZO
+				bool "lzo"
+
+			config TARGET_INITRAMFS_COMPRESSION_LZ4
+				bool "lz4"
+
+			config TARGET_INITRAMFS_COMPRESSION_XZ
+				bool "xz"
+		endchoice
+
+		config EXTERNAL_CPIO
+			string
+			prompt "Use external cpio" if TARGET_ROOTFS_INITRAMFS
+			default ""
+			help
+			  Kernel uses specified external cpio as INITRAMFS_SOURCE
+
+	comment "Root filesystem archives"
+
+	config TARGET_ROOTFS_CPIOGZ
+		bool "cpio.gz"
+		default y if USES_CPIOGZ
+		help
+		  Build a compressed cpio archive of the the root filesystem
+
+	config TARGET_ROOTFS_TARGZ
+		bool "tar.gz"
+		default y if USES_TARGZ
+		help
+		  Build a compressed tar archive of the the root filesystem
+
+	comment "Root filesystem images"
+
+	config TARGET_ROOTFS_EXT4FS
+		bool "ext4"
+		default y if USES_EXT4
+		help
+		  Ext4 file system with some free space for uml images
+
+	config TARGET_ROOTFS_ISO
+		bool "iso"
+		default n
+		depends on TARGET_x86_generic
+		help
+		  Create some bootable ISO image
+
+	config TARGET_ROOTFS_JFFS2
+		bool "jffs2"
+		default y if USES_JFFS2
+		help
+		  Build a jffs2 root filesystem
+
+	config TARGET_ROOTFS_JFFS2_NAND
+		bool "jffs2 for NAND"
+		default y if USES_JFFS2_NAND
+		depends on USES_JFFS2_NAND
+		help
+		  Build a jffs2 root filesystem for NAND flash
+
+	config TARGET_ROOTFS_SQUASHFS
+		bool "squashfs"
+		default y if USES_SQUASHFS
+		help
+		  Build a squashfs-lzma root filesystem
+
+	menuconfig TARGET_ROOTFS_UBIFS
+		bool "ubifs"
+		default y if USES_UBIFS
+		depends on USES_UBIFS
+		help
+		  Build a ubifs root filesystem
+
+		choice
+			prompt "compression"
+			default TARGET_UBIFS_COMPRESSION_NONE
+			depends on TARGET_ROOTFS_UBIFS
+			help
+			  Select compression type
+
+			config TARGET_UBIFS_COMPRESSION_NONE
+				bool "none"
+
+			config TARGET_UBIFS_COMPRESSION_LZO
+				bool "lzo"
+
+			config TARGET_UBIFS_COMPRESSION_ZLIB
+				bool "zlib"
+		endchoice
+
+		config TARGET_UBIFS_FREE_SPACE_FIXUP
+			bool "free space fixup" if TARGET_ROOTFS_UBIFS
+			default y
+			help
+			  The file-system free space has to be fixed up on first mount
+
+		config TARGET_UBIFS_JOURNAL_SIZE
+			string
+			prompt "journal size" if TARGET_ROOTFS_UBIFS
+			default ""
+
+	config GRUB_IMAGES
+		bool "Build GRUB images (Linux x86 or x86_64 host only)"
+		depends on TARGET_x86_64 || (TARGET_x86 && !(TARGET_x86_olpc || TARGET_x86_rdc))
+		depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_ISO || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS
+		select PACKAGE_grub2
+		default y
+
+	config GRUB_CONSOLE
+		bool "Use Console Terminal (in addition to Serial)"
+		depends on GRUB_IMAGES
+		default n if (TARGET_x86_generic_Soekris45xx || TARGET_x86_generic_Soekris48xx || TARGET_x86_net5501 || TARGET_x86_geos || TARGET_x86_alix2)
+		default y
+
+	config GRUB_SERIAL
+		string "Serial port device"
+		depends on GRUB_IMAGES
+		default "hvc0" if TARGET_x86_xen_domu
+		default "ttyS0" if ! TARGET_x86_xen_domu
+
+	config GRUB_BAUDRATE
+		int "Serial port baud rate"
+		depends on GRUB_IMAGES
+		default 19200 if TARGET_x86_generic_Soekris45xx || TARGET_x86_generic_Soekris48xx || TARGET_x86_net5501
+		default 38400 if TARGET_x86_alix2
+		default 115200 if TARGET_x86_geos || TARGET_x86_kvm_guest
+		default 38400
+
+	config GRUB_BOOTOPTS
+		string "Extra kernel boot options"
+		depends on GRUB_IMAGES
+		default "xencons=hvc" if TARGET_x86_xen_domu
+		help
+		  If you don't know, just leave it blank.
+
+	config GRUB_TIMEOUT
+		string "Seconds to wait before booting the default entry"
+		depends on GRUB_IMAGES
+		default "5"
+		help
+		  If you don't know, 5 seconds is a reasonable default.
+
+	config VDI_IMAGES
+		bool "Build VirtualBox image files (VDI)"
+		depends on TARGET_x86 || TARGET_x86_64
+		select GRUB_IMAGES
+		select TARGET_ROOTFS_EXT4FS
+		select PACKAGE_kmod-e1000
+
+	config VMDK_IMAGES
+		bool "Build VMware image files (VMDK)"
+		depends on TARGET_x86 || TARGET_x86_64
+		select GRUB_IMAGES
+		select TARGET_ROOTFS_EXT4FS
+		select PACKAGE_kmod-e1000
+
+	config TARGET_IMAGES_PAD
+		bool "Pad images to filesystem size (for JFFS2)"
+		depends on OLPC_BOOTSCRIPT_IMAGES || GRUB_IMAGES
+
+	config TARGET_IMAGES_GZIP
+		bool "GZip images"
+		depends on TARGET_IMAGES_PAD || TARGET_ROOTFS_EXT4FS
+		default y
+
+	comment "Image Options"
+
+	source "target/linux/*/image/Config.in"
+
+	config TARGET_KERNEL_PARTSIZE
+		int "Kernel partition size (in MB)"
+		depends on OLPC_BOOTSCRIPT_IMAGES || GRUB_IMAGES
+		default 4
+
+	config TARGET_ROOTFS_PARTSIZE
+		int "Root filesystem partition size (in MB)"
+		depends on GRUB_IMAGES || TARGET_ROOTFS_EXT4FS || TARGET_rb532
+		default 48
+		help
+		  Allows you to change the root filesystem partition size
+
+	config TARGET_ROOTFS_PARTNAME
+		string "Root partition on target device"
+		depends on OLPC_BOOTSCRIPT_IMAGES || GRUB_IMAGES
+		default "/dev/vda2" if TARGET_x86_kvm_guest
+		default "/dev/xvda2" if TARGET_x86_xen_domu
+		default "/dev/sda2" if ! (TARGET_x86_kvm_guest || TARGET_x86_xen_domu)
+		help
+		  The root partition on the final device.  If you don't know,
+		  you probably want the default (/dev/sda2).
+
+	config TARGET_ROOTFS_MAXINODE
+		int "Maximum number of inodes in root filesystem"
+		depends on TARGET_ROOTFS_EXT4FS
+		default 6000
+		help
+		  Allows you to change the maximum number of inodes in the root filesystem
+
+	config TARGET_ROOTFS_RESERVED_PCT
+		int "Percentage of reserved blocks in root filesystem"
+		depends on TARGET_ROOTFS_EXT4FS
+		default 0
+		help
+		  Allows you to change the percentage of reserved blocks in the root filesystem
+
+	menuconfig TARGET_ROOTFS_INCLUDE_KERNEL
+		bool "Include kernel in root filesystem"
+		depends on TARGET_ROOTFS_UBIFS || TARGET_ROOTFS_EXT4FS
+		default n
+		help
+		  Include the kernel image in the rootfs. Typically the image is placed
+		  below /boot.
+
+		config TARGET_ROOTFS_INCLUDE_UIMAGE
+			bool "include uImage" if TARGET_ROOTFS_INCLUDE_KERNEL
+			default y
+			help
+			  This option might not apply to all targets. Make sure
+			  to check target/linux/<your_target>/image/Makefile to
+			  see if this option will have any effect.
+
+		config TARGET_ROOTFS_INCLUDE_ZIMAGE
+			bool "include zImage" if TARGET_ROOTFS_INCLUDE_KERNEL
+			default y
+			help
+			  This option might not apply to all targets. Make sure
+			  to check target/linux/<your_target>/image/Makefile to
+			  see if this option will have any effect.
+
+		config TARGET_ROOTFS_INCLUDE_FIT
+			bool "include FIT" if TARGET_ROOTFS_INCLUDE_KERNEL
+			default y
+			help
+			  This option might not apply to all targets. Make sure
+			  to check target/linux/<your_target>/image/Makefile to
+			  see if this option will have any effect.
+
+	config TARGET_ROOTFS_INCLUDE_DTB
+		bool "Include DTB in root filesystem"
+		depends on USES_DEVICETREE && (TARGET_ROOTFS_UBIFS || TARGET_ROOTFS_EXT4FS)
+		default n
+		help
+		  Include the device tree blob file(s) in the rootfs. Typically the DTBs
+		  are placed below /boot.
+
+endmenu
+

--- /dev/null
+++ b/config/Config-kernel.in
@@ -1,1 +1,439 @@
-
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+config KERNEL_DEBUG_FS
+	bool "Compile the kernel with Debug FileSystem enabled"
+	default y
+	help
+	  debugfs is a virtual file system that kernel developers use to put
+	  debugging files into. Enable this option to be able to read and
+	  write to these files.
+
+config KERNEL_PERF_EVENTS
+	bool
+	default n
+
+config KERNEL_PROFILING
+	bool "Compile the kernel with profiling enabled"
+	default n
+	select KERNEL_PERF_EVENTS
+	help
+	  Enable the extended profiling support mechanisms used by profilers such
+	  as OProfile.
+
+config KERNEL_KALLSYMS
+	bool "Compile the kernel with symbol table information"
+	default y
+	help
+	  This will give you more information in stack traces from kernel oopses
+
+config KERNEL_FTRACE
+	bool "Compile the kernel with tracing support"
+	default n
+
+config KERNEL_FTRACE_SYSCALLS
+	bool "Trace system calls"
+	depends on KERNEL_FTRACE
+	default n
+
+config KERNEL_ENABLE_DEFAULT_TRACERS
+	bool "Trace process context switches and events"
+	depends on KERNEL_FTRACE
+	default n
+
+config KERNEL_DEBUG_KERNEL
+	bool
+	default n
+
+config KERNEL_DEBUG_INFO
+	bool "Compile the kernel with debug information"
+	default y
+	select KERNEL_DEBUG_KERNEL
+	help
+	  This will compile your kernel and modules with debug information.
+
+config KERNEL_DEBUG_LL_UART_NONE
+	bool
+	default n
+	depends on arm
+
+config KERNEL_DEBUG_LL
+	bool
+	default n
+	depends on arm
+	select KERNEL_DEBUG_LL_UART_NONE
+	help
+	  ARM low level debugging
+
+config KERNEL_DYNAMIC_DEBUG 
+	bool "Compile the kernel with dynamic printk"
+	select KERNEL_DEBUG_FS
+	default n
+	help
+	  Compiles debug level messages into the kernel, which would not
+	  otherwise be available at runtime. These messages can then be
+	  enabled/disabled based on various levels of scope - per source file,
+	  function, module, format string, and line number. This mechanism
+	  implicitly compiles in all pr_debug() and dev_dbg() calls, which
+	  enlarges the kernel text size by about 2%.
+
+config KERNEL_EARLY_PRINTK
+	bool "Compile the kernel with early printk"
+	default n
+	depends on arm
+	select KERNEL_DEBUG_KERNEL
+	select KERNEL_DEBUG_LL if arm
+	help
+	  Compile the kernel with early printk support.
+	  This is only useful for debugging purposes to send messages
+	  over the serial console in early boot.
+	  Enable this to debug early boot problems.
+
+config KERNEL_AIO
+	bool "Compile the kernel with asynchronous IO support"
+	default n
+
+config KERNEL_DIRECT_IO
+	bool "Compile the kernel with direct IO support"
+	default n
+
+config KERNEL_MAGIC_SYSRQ
+	bool "Compile the kernel with SysRq support"
+	default y
+
+config KERNEL_COREDUMP
+	bool
+
+config KERNEL_ELF_CORE
+	bool "Enable process core dump support"
+	select KERNEL_COREDUMP
+	default y
+
+config KERNEL_PROVE_LOCKING
+	bool "Enable kernel lock checking"
+	select KERNEL_DEBUG_KERNEL
+	default n
+
+config KERNEL_PRINTK_TIME
+	bool "Enable printk timestamps"
+	default y
+
+config KERNEL_RELAY
+	bool
+
+config KERNEL_KEXEC
+	bool "Enable kexec support"
+
+config USE_RFKILL
+	bool "Enable rfkill support"
+	default RFKILL_SUPPORT
+
+#
+# CGROUP support symbols
+#
+
+config KERNEL_CGROUPS
+	bool "Enable kernel cgroups"
+	default n
+
+if KERNEL_CGROUPS
+
+	config KERNEL_CGROUP_DEBUG
+		bool "Example debug cgroup subsystem"
+		default n
+		help
+		  This option enables a simple cgroup subsystem that
+		  exports useful debugging information about the cgroups
+		  framework.
+
+	config KERNEL_FREEZER
+		bool
+		default y if KERNEL_CGROUP_FREEZER
+
+	config KERNEL_CGROUP_FREEZER
+		bool "Freezer cgroup subsystem"
+		default n
+		help
+		  Provides a way to freeze and unfreeze all tasks in a
+		  cgroup.
+
+	config KERNEL_CGROUP_DEVICE
+		bool "Device controller for cgroups"
+		default y
+		help
+		  Provides a cgroup implementing whitelists for devices which
+		  a process in the cgroup can mknod or open.
+
+	config KERNEL_CPUSETS
+		bool "Cpuset support"
+		default n
+		help
+		  This option will let you create and manage CPUSETs which
+		  allow dynamically partitioning a system into sets of CPUs and
+		  Memory Nodes and assigning tasks to run only within those sets.
+		  This is primarily useful on large SMP or NUMA systems.
+
+	config KERNEL_PROC_PID_CPUSET
+		bool "Include legacy /proc/<pid>/cpuset file"
+		default n
+		depends on KERNEL_CPUSETS
+
+	config KERNEL_CGROUP_CPUACCT
+		bool "Simple CPU accounting cgroup subsystem"
+		default n
+		help
+		  Provides a simple Resource Controller for monitoring the
+		  total CPU consumed by the tasks in a cgroup.
+
+	config KERNEL_RESOURCE_COUNTERS
+		bool "Resource counters"
+		default n
+		help
+		  This option enables controller independent resource accounting
+		  infrastructure that works with cgroups.
+
+	config KERNEL_MM_OWNER
+		bool
+		default y if KERNEL_MEMCG
+
+	config KERNEL_MEMCG
+		bool "Memory Resource Controller for Control Groups"
+		default n
+		depends on KERNEL_RESOURCE_COUNTERS
+		help
+		  Provides a memory resource controller that manages both anonymous
+		  memory and page cache. (See Documentation/cgroups/memory.txt)
+
+		  Note that setting this option increases fixed memory overhead
+		  associated with each page of memory in the system. By this,
+		  20(40)bytes/PAGE_SIZE on 32(64)bit system will be occupied by memory
+		  usage tracking struct at boot. Total amount of this is printed out
+		  at boot.
+
+		  Only enable when you're ok with these trade offs and really
+		  sure you need the memory resource controller. Even when you enable
+		  this, you can set "cgroup_disable=memory" at your boot option to
+		  disable memory resource controller and you can avoid overheads.
+		  (and lose benefits of memory resource controller)
+
+		  This config option also selects MM_OWNER config option, which
+		  could in turn add some fork/exit overhead.
+
+	config KERNEL_MEMCG_SWAP
+		bool "Memory Resource Controller Swap Extension"
+		default n
+		depends on KERNEL_MEMCG
+		help
+		  Add swap management feature to memory resource controller. When you
+		  enable this, you can limit mem+swap usage per cgroup. In other words,
+		  when you disable this, memory resource controller has no cares to
+		  usage of swap...a process can exhaust all of the swap. This extension
+		  is useful when you want to avoid exhaustion swap but this itself
+		  adds more overheads and consumes memory for remembering information.
+		  Especially if you use 32bit system or small memory system, please
+		  be careful about enabling this. When memory resource controller
+		  is disabled by boot option, this will be automatically disabled and
+		  there will be no overhead from this. Even when you set this config=y,
+		  if boot option "swapaccount=0" is set, swap will not be accounted.
+		  Now, memory usage of swap_cgroup is 2 bytes per entry. If swap page
+		  size is 4096bytes, 512k per 1Gbytes of swap.
+
+	config KERNEL_MEMCG_SWAP_ENABLED
+		bool "Memory Resource Controller Swap Extension enabled by default"
+		default n
+		depends on KERNEL_MEMCG_SWAP
+		help
+		  Memory Resource Controller Swap Extension comes with its price in
+		  a bigger memory consumption. General purpose distribution kernels
+		  which want to enable the feature but keep it disabled by default
+		  and let the user enable it by swapaccount boot command line
+		  parameter should have this option unselected.
+		  For those who want to have the feature enabled by default should
+		  select this option (if, for some reason, they need to disable it
+		  then swapaccount=0 does the trick).
+
+
+	config KERNEL_MEMCG_KMEM
+		bool "Memory Resource Controller Kernel Memory accounting (EXPERIMENTAL)"
+		default n
+		depends on KERNEL_MEMCG
+		help
+		  The Kernel Memory extension for Memory Resource Controller can limit
+		  the amount of memory used by kernel objects in the system. Those are
+		  fundamentally different from the entities handled by the standard
+		  Memory Controller, which are page-based, and can be swapped. Users of
+		  the kmem extension can use it to guarantee that no group of processes
+		  will ever exhaust kernel resources alone.
+
+	config KERNEL_PERF_EVENTS
+		bool
+		default y if KERNEL_CGROUP_PERF
+
+	config KERNEL_CGROUP_PERF
+		bool "Enable perf_event per-cpu per-container group (cgroup) monitoring"
+		default n
+		help
+		  This option extends the per-cpu mode to restrict monitoring to
+		  threads which belong to the cgroup specified and run on the
+		  designated cpu.
+
+	menuconfig KERNEL_CGROUP_SCHED
+		bool "Group CPU scheduler"
+		default n
+		help
+		  This feature lets CPU scheduler recognize task groups and control CPU
+		  bandwidth allocation to such task groups. It uses cgroups to group
+		  tasks.
+
+	if KERNEL_CGROUP_SCHED
+
+		config KERNEL_FAIR_GROUP_SCHED
+			bool "Group scheduling for SCHED_OTHER"
+			default n
+
+		config KERNEL_CFS_BANDWIDTH
+			bool "CPU bandwidth provisioning for FAIR_GROUP_SCHED"
+			default n
+			depends on KERNEL_FAIR_GROUP_SCHED
+			help
+			  This option allows users to define CPU bandwidth rates (limits) for
+			  tasks running within the fair group scheduler.  Groups with no limit
+			  set are considered to be unconstrained and will run with no
+			  restriction.
+			  See tip/Documentation/scheduler/sched-bwc.txt for more information.
+
+		config KERNEL_RT_GROUP_SCHED
+			bool "Group scheduling for SCHED_RR/FIFO"
+			default n
+			help
+			  This feature lets you explicitly allocate real CPU bandwidth
+			  to task groups. If enabled, it will also make it impossible to
+			  schedule realtime tasks for non-root users until you allocate
+			  realtime bandwidth for them.
+
+	endif
+
+	config KERNEL_BLK_CGROUP
+		bool "Block IO controller"
+		default y
+		help
+		  Generic block IO controller cgroup interface. This is the common
+		  cgroup interface which should be used by various IO controlling
+		  policies.
+
+		  Currently, CFQ IO scheduler uses it to recognize task groups and
+		  control disk bandwidth allocation (proportional time slice allocation)
+		  to such task groups. It is also used by bio throttling logic in
+		  block layer to implement upper limit in IO rates on a device.
+
+		  This option only enables generic Block IO controller infrastructure.
+		  One needs to also enable actual IO controlling logic/policy. For
+		  enabling proportional weight division of disk bandwidth in CFQ, set
+		  CONFIG_CFQ_GROUP_IOSCHED=y; for enabling throttling policy, set
+		  CONFIG_BLK_DEV_THROTTLING=y.
+
+	config KERNEL_DEBUG_BLK_CGROUP
+		bool "Enable Block IO controller debugging"
+		default n
+		depends on KERNEL_BLK_CGROUP
+		help
+		  Enable some debugging help. Currently it exports additional stat
+		  files in a cgroup which can be useful for debugging.
+
+	config KERNEL_NET_CLS_CGROUP
+		bool "Control Group Classifier"
+		default y
+
+	config KERNEL_NETPRIO_CGROUP
+		bool "Network priority cgroup"
+		default y
+
+endif
+
+#
+# Namespace support symbols
+#
+
+config KERNEL_NAMESPACES
+	bool "Enable kernel namespaces"
+	default n
+
+if KERNEL_NAMESPACES
+
+	config KERNEL_UTS_NS
+		bool "UTS namespace"
+		default y
+		help
+		  In this namespace tasks see different info provided
+		  with the uname() system call
+
+	config KERNEL_IPC_NS
+		bool "IPC namespace"
+		default y
+		help
+		  In this namespace tasks work with IPC ids which correspond to
+		  different IPC objects in different namespaces.
+
+	config KERNEL_USER_NS
+		bool "User namespace (EXPERIMENTAL)"
+		default y
+		help
+		  This allows containers, i.e. vservers, to use user namespaces
+		  to provide different user info for different servers.
+
+	config KERNEL_PID_NS
+		bool "PID Namespaces"
+		default y
+		help
+		  Support process id namespaces. This allows having multiple
+		  processes with the same pid as long as they are in different
+		  pid namespaces. This is a building block of containers.
+
+	config KERNEL_NET_NS
+		bool "Network namespace"
+		default y
+		help
+		  Allow user space to create what appear to be multiple instances
+		  of the network stack.
+
+endif
+
+#
+# LXC related symbols
+#
+
+config KERNEL_LXC_MISC
+	bool "Enable miscellaneous LXC related options"
+	default n
+
+if KERNEL_LXC_MISC
+
+	config KERNEL_DEVPTS_MULTIPLE_INSTANCES
+		bool "Support multiple instances of devpts"
+		default y
+		help
+		  Enable support for multiple instances of devpts filesystem.
+		  If you want to have isolated PTY namespaces (eg: in containers),
+		  say Y here. Otherwise, say N. If enabled, each mount of devpts
+		  filesystem with the '-o newinstance' option will create an
+		  independent PTY namespace.
+
+	config KERNEL_POSIX_MQUEUE
+		bool "POSIX Message Queues"
+		default y
+		help
+		  POSIX variant of message queues is a part of IPC. In POSIX message
+		  queues every message has a priority which decides about succession
+		  of receiving it by a process. If you want to compile and run
+		  programs written e.g. for Solaris with use of its POSIX message
+		  queues (functions mq_*) say Y here.
+
+		  POSIX message queues are visible as a filesystem called 'mqueue'
+		  and can be mounted somewhere if you want to do filesystem
+		  operations on message queues.
+
+endif
+

--- a/feeds.conf.default
+++ b/feeds.conf.default
@@ -1,8 +1,8 @@
 src-git packages git://git.openwrt.org/packages.git
-src-svn xwrt http://x-wrt.googlecode.com/svn/trunk/package
 src-git luci git://nbd.name/luci.git
 src-git routing git://github.com/openwrt-routing/packages.git
 src-git telephony http://feeds.openwrt.nanl.de/openwrt/telephony.git
+#src-svn xwrt http://x-wrt.googlecode.com/svn/trunk/package
 #src-svn phone svn://svn.openwrt.org/openwrt/feeds/phone
 #src-svn efl svn://svn.openwrt.org/openwrt/feeds/efl
 #src-svn xorg svn://svn.openwrt.org/openwrt/feeds/xorg

--- a/include/cmake.mk
+++ b/include/cmake.mk
@@ -24,9 +24,9 @@
     CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
   endif
   CMAKE_C_COMPILER:=$(CCACHE)
-  CMAKE_C_COMPILER_ARG1:=$(filter-out ccache,$(TARGET_CC))
+  CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
   CMAKE_CXX_COMPILER:=$(CCACHE)
-  CMAKE_CXX_COMPILER_ARG1:=$(filter-out ccache,$(TARGET_CXX))
+  CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE)
 endif
 
 define Build/Configure/Default

--- a/include/image.mk
+++ b/include/image.mk
@@ -68,7 +68,7 @@
 endef
 
 define toupper
-	$(shell echo $(1) | tr '[:lower:]' '[:upper:]')
+$(shell echo $(1) | tr '[:lower:]' '[:upper:]')
 endef
 
 # pad to 4k, 8k, 64k, 128k 256k and add jffs2 end-of-filesystem mark
@@ -142,7 +142,7 @@
 			$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--force-compr=none) \
 			$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--force-compr=lzo) \
 			$(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--force-compr=zlib) \
-			--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE) \
+			$(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \
 			--squash-uids \
 			-o $(KDIR)/root.ubifs \
 			-d $(TARGET_DIR)

--- a/include/kernel-build.mk
+++ b/include/kernel-build.mk
@@ -76,9 +76,9 @@
 		xargs $(TARGET_CROSS)nm | \
 		awk '$$$$1 == "U" { print $$$$2 } ' | \
 		sort -u > $(KERNEL_BUILD_DIR)/mod_symtab.txt
-	$(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | grep ' r __ksymtab' | sed -e 's,........ r __ksymtab_,,' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt
-	grep -f $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_include.txt
-	grep -vf $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_exclude.txt
+	$(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | grep -F ' r __ksymtab' | sed -e 's,........ r __ksymtab_,,' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt
+	grep -Ff $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_include.txt
+	grep -Fvf $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_exclude.txt
 	( \
 		echo '#define SYMTAB_KEEP \'; \
 		cat $(KERNEL_BUILD_DIR)/sym_include.txt | \

--- a/include/kernel-defaults.mk
+++ b/include/kernel-defaults.mk
@@ -104,7 +104,7 @@
 	$(SCRIPT_DIR)/kconfig.pl 'm+' '+' $(LINUX_DIR)/.config.target /dev/null $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config
 	$(call Kernel/SetNoInitramfs)
 	rm -rf $(KERNEL_BUILD_DIR)/modules
-	[ -d $(LINUX_DIR)/user_headers ] || $(MAKE) $(KERNEL_MAKEOPTS) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install
+	$(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(MAKE) $(KERNEL_MAKEOPTS) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install
 	$(SH_FUNC) grep '=[ym]' $(LINUX_DIR)/.config | LC_ALL=C sort | md5s > $(LINUX_DIR)/.vermagic
 endef
 
@@ -122,6 +122,11 @@
 # AVR32 uses a non-standard location
 ifeq ($(LINUX_KARCH),avr32)
 IMAGES_DIR:=images
+endif
+
+# AMD64 shares the location with x86
+ifeq ($(LINUX_KARCH),x86_64)
+IMAGES_DIR:=../../x86/boot
 endif
 
 define Kernel/CopyImage

--- a/include/kernel-version.mk
+++ b/include/kernel-version.mk
@@ -17,8 +17,14 @@
 ifeq ($(LINUX_VERSION),3.9.11)
   LINUX_KERNEL_MD5SUM:=edbf88eb7f7d34dbd5d3887726790755
 endif
-ifeq ($(LINUX_VERSION),3.10.18)
-  LINUX_KERNEL_MD5SUM:=e091753da622788cfd662dd67c2f9b48
+ifeq ($(LINUX_VERSION),3.10.32)
+  LINUX_KERNEL_MD5SUM:=58bfaf95f4e23be2d658dab0a7fb9615
+endif
+ifeq ($(LINUX_VERSION),3.12.10)
+  LINUX_KERNEL_MD5SUM:=93325074b7b1d7bb76fb7d4348f0aa7a
+endif
+ifeq ($(LINUX_VERSION),3.13.2)
+  LINUX_KERNEL_MD5SUM:=83386986b4b58507a4f064aa46676f5e
 endif
 
 # disable the md5sum check for unknown kernel versions

--- a/include/package-defaults.mk
+++ b/include/package-defaults.mk
@@ -32,6 +32,7 @@
   else
     VERSION:=$(PKG_RELEASE)
   endif
+  ABI_VERSION:=
   ifneq ($(PKG_FLAGS),)
     PKGFLAGS:=$(PKG_FLAGS)
   else

--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -83,6 +83,9 @@
       ifneq ($(CONFIG_PACKAGE_$(1))$(SDK)$(DEVELOPER),)
         IPKGS += $(1)
         compile: $$(IPKG_$(1)) $(PKG_INFO_DIR)/$(1).provides $(STAGING_DIR_ROOT)/stamp/.$(1)_installed
+        ifneq ($(ABI_VERSION),)
+        compile: $(PKG_INFO_DIR)/$(1).version
+        endif
 
         ifeq ($(CONFIG_PACKAGE_$(1)),y)
           .PHONY: $(PKG_INSTALL_STAMP).$(1)
@@ -124,6 +127,10 @@
 	rm -rf $(STAGING_DIR_ROOT)/tmp-$(1)
 	touch $$@
 
+    $(PKG_INFO_DIR)/$(1).version: $$(IPKG_$(1))
+	echo '$(ABI_VERSION)' | cmp -s - $$@ || \
+		echo '$(ABI_VERSION)' > $$@
+
     $(PKG_INFO_DIR)/$(1).provides: $$(IPKG_$(1))
     $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk
 	@rm -rf $(PACKAGE_DIR)/$(1)_* $$(IDIR_$(1))
@@ -152,8 +159,6 @@
 		[ -z "$$$$DEPENDS" ] || echo "Depends: $$$$DEPENDS"; \
 		$(if $(PROVIDES), echo "Provides: $(PROVIDES)"; ) \
 		echo "Source: $(SOURCE)"; \
-		$(if $(PKG_SOURCE), echo "SourceFile: $(PKG_SOURCE)"; ) \
-		$(if $(PKG_SOURCE_URL), echo "SourceURL: $(PKG_SOURCE_URL)"; ) \
 		$(if $(PKG_LICENSE), echo "License: $(PKG_LICENSE)"; ) \
 		$(if $(PKG_LICENSE_FILES), echo "LicenseFiles: $(PKG_LICENSE_FILES)"; ) \
 		echo "Section: $(SECTION)"; \

--- a/include/package.mk
+++ b/include/package.mk
@@ -38,6 +38,15 @@
 include $(INCLUDE_DIR)/host.mk
 include $(INCLUDE_DIR)/unpack.mk
 include $(INCLUDE_DIR)/depends.mk
+
+find_library_dependencies = $(wildcard $(patsubst %,$(STAGING_DIR)/pkginfo/%.version, \
+	$(filter-out $(BUILD_PACKAGES),$(foreach dep, \
+		$(filter-out @%, $(patsubst +%,%,$(1))), \
+		$(if $(findstring :,$(dep)), \
+			$(word 2,$(subst :,$(space),$(dep))), \
+			$(dep) \
+		) \
+	))))
 
 STAMP_NO_AUTOREBUILD=$(wildcard $(PKG_BUILD_DIR)/.no_autorebuild)
 PREV_STAMP_PREPARED:=$(if $(STAMP_NO_AUTOREBUILD),$(wildcard $(PKG_BUILD_DIR)/.prepared*))
@@ -227,6 +236,9 @@
 endef
 endif
 
+  BUILD_PACKAGES += $(1)
+  $(STAMP_PREPARED): $$(if $(QUILT)$(DUMP),,$(call find_library_dependencies,$(DEPENDS)))
+
   $(foreach FIELD, TITLE CATEGORY SECTION VERSION,
     ifeq ($($(FIELD)),)
       $$(error Package/$(1) is missing the $(FIELD) field)

--- a/include/target.mk
+++ b/include/target.mk
@@ -14,7 +14,7 @@
 # Default packages - the really basic set
 DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd
 # For router targets
-DEFAULT_PACKAGES.router:=dnsmasq iptables ip6tables ppp ppp-mod-pppoe kmod-ipt-nathelper firewall 6relayd odhcp6c
+DEFAULT_PACKAGES.router:=dnsmasq iptables ip6tables ppp ppp-mod-pppoe kmod-ipt-nathelper firewall odhcpd odhcp6c
 DEFAULT_PACKAGES.bootloader:=
 
 ifneq ($(DUMP),)
@@ -76,7 +76,7 @@
 	$(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Description)"; \
 	echo "@@"; \
 	echo;
-  ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
+  ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_))$(1)),y)
     PROFILE=$(1)
   endif
 endef
@@ -167,6 +167,9 @@
     .SILENT: $(TMP_CONFIG)
     .PRECIOUS: $(TMP_CONFIG)
 
+    ifneq ($(CONFIG_OF),)
+      FEATURES += dt
+    endif
     ifneq ($(CONFIG_GENERIC_GPIO)$(CONFIG_GPIOLIB),)
       FEATURES += gpio
     endif
@@ -228,8 +231,11 @@
     CPU_CFLAGS_fa526 = -march=armv4 -mtune=fa526
     CPU_CFLAGS_mpcore = -march=armv6k -mtune=mpcore
     CPU_CFLAGS_xscale = -march=armv5te -mtune=xscale
-    CPU_CFLAGS_vfp = -mfpu=vfp -mfloat-abi=softfp
-    CPU_CFLAGS_vfpv3 = -mfpu=vfpv3-d16 -mfloat-abi=softfp
+    ifeq ($(CONFIG_SOFT_FLOAT),)
+      CPU_CFLAGS_neon = -mfpu=neon
+      CPU_CFLAGS_vfp = -mfpu=vfp
+      CPU_CFLAGS_vfpv3 = -mfpu=vfpv3-d16
+    endif
   endif
   ifeq ($(ARCH),powerpc)
     CPU_CFLAGS_603e:=-mcpu=603e

--- a/include/version.mk
+++ b/include/version.mk
@@ -29,6 +29,30 @@
 VERSION_DIST:=$(call qstrip,$(CONFIG_VERSION_DIST))
 VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),OpenWrt)
 
+
+define taint2sym
+$(CONFIG_$(firstword $(subst :, ,$(subst +,,$(subst -,,$(1))))))
+endef
+
+define taint2name
+$(lastword $(subst :, ,$(1)))
+endef
+
+VERSION_TAINT_SPECS := \
+	-ALL:no-all \
+	-IPV6:no-ipv6 \
+	+USE_EGLIBC:eglibc \
+	+USE_MKLIBS:mklibs \
+	+BUSYBOX_CUSTOM:busybox \
+
+VERSION_TAINTS := $(strip $(foreach taint,$(VERSION_TAINT_SPECS), \
+	$(if $(findstring +,$(taint)), \
+		$(if $(call taint2sym,$(taint)),$(call taint2name,$(taint))), \
+		$(if $(call taint2sym,$(taint)),,$(call taint2name,$(taint))) \
+	)))
+
+PKG_CONFIG_DEPENDS += $(foreach taint,$(VERSION_TAINT_SPECS),$(call taint2sym,$(taint)))
+
 VERSION_SED:=$(SED) 's,%U,$(VERSION_REPO),g' \
 	-e 's,%V,$(VERSION_NUMBER),g' \
 	-e 's,%v,\L$(subst $(space),_,$(VERSION_NUMBER)),g' \
@@ -41,4 +65,5 @@
 	-e 's,%R,$(REVISION),g' \
 	-e 's,%T,$(BOARD),g' \
 	-e 's,%S,$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic),g' \
+	-e 's,%t,$(VERSION_TAINTS),g' \
 

--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -7,11 +7,11 @@
 #
 
 include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/version.mk
 include $(INCLUDE_DIR)/kernel.mk
-include $(INCLUDE_DIR)/version.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=148
+PKG_RELEASE:=151
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 PKG_BUILD_DEPENDS:=opkg/host

--- a/package/base-files/files/bin/ipcalc.sh
+++ b/package/base-files/files/bin/ipcalc.sh
@@ -11,7 +11,7 @@
 }
 
 function ip2int(ip) {
-	for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x]) 
+	for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x])
 	return ret
 }
 
@@ -31,7 +31,11 @@
 	slpos=index(ARGV[1],"/")
 	if (slpos == 0) {
 		ipaddr=ip2int(ARGV[1])
-		netmask=ip2int(ARGV[2])
+		dotpos=index(ARGV[2],".")
+		if (dotpos == 0)
+			netmask=compl32(2**(32-int(ARGV[2]))-1)
+		else
+			netmask=ip2int(ARGV[2])
 	} else {
 		ipaddr=ip2int(substr(ARGV[1],0,slpos-1))
 		netmask=compl32(2**(32-int(substr(ARGV[1],slpos+1)))-1)

--- a/package/base-files/files/etc/config/network
+++ b/package/base-files/files/etc/config/network
@@ -15,7 +15,7 @@
 	option ip6assign 60
 
 config interface wan6
-	option ifname   @wan
+	option ifname	@wan
 	option proto	dhcpv6
 
 config globals globals

--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -3,37 +3,6 @@
 
 START=10
 STOP=98
-
-system_config() {
-	local cfg="$1"
-
-	local hostname conloglevel buffersize timezone zonename
-
-	config_get hostname "$cfg" hostname 'OpenWrt'
-	echo "$hostname" > /proc/sys/kernel/hostname
-
-	config_get conloglevel "$cfg" conloglevel
-	config_get buffersize "$cfg" buffersize
-	[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
-
-	config_get timezone "$cfg" timezone 'UTC'
-	echo "$timezone" > /tmp/TZ
-
-	config_get zonename "$cfg" zonename
-	[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
-
-	# apply timezone to kernel
-	date -k
-}
-
-apply_uci_config() {
-	sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
-}
-
-start() {
-	config_load system
-	config_foreach system_config system
-}
 
 boot() {
 	[ -f /proc/mounts ] || /sbin/mount_root
@@ -50,7 +19,7 @@
 	touch /var/log/lastlog
 	touch /tmp/resolv.conf.auto
 	ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
-	grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug
+	grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug
 	[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
 
 	/sbin/kmodloader
@@ -64,7 +33,7 @@
 	}
 	rm -f /tmp/wireless.tmp
 
-	apply_uci_config
+	sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
 	
 	# temporary hack until configd exists
 	/sbin/reload_config

--- a/package/base-files/files/etc/init.d/sysctl
+++ b/package/base-files/files/etc/init.d/sysctl
@@ -1,5 +1,5 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org 
+# Copyright (C) 2006 OpenWrt.org
 
 START=11
 start() {

--- /dev/null
+++ b/package/base-files/files/etc/init.d/sysfixtime
@@ -1,1 +1,14 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2013-2014 OpenWrt.org
 
+START=00
+
+boot() {
+	local curtime="$(date +%s)"
+	local maxtime="$(find /etc -type f -exec date +%s -r {} \; | sort -nr | head -n1)"
+	[ $curtime -lt $maxtime ] && \
+		date -s @$maxtime && \
+		logger -t sysfixtime -p daemon.notice "Time fixed"
+}
+
+

--- /dev/null
+++ b/package/base-files/files/etc/init.d/system
@@ -1,1 +1,52 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2014 OpenWrt.org
 
+START=10
+USE_PROCD=1
+
+validate_system_section()
+{
+	uci_validate_section system system "${1}" \
+		'hostname:string:OpenWrt' \
+		'conloglevel:uinteger' \
+		'buffersize:uinteger' \
+		'timezone:string:UTC' \
+		'zonename:string'
+
+	return $?
+}
+
+system_config() {
+	local cfg="$1"
+
+	local hostname conloglevel buffersize timezone zonename
+
+	validate_system_section "${1}" || {
+		echo "validation failed"
+		return 1
+	}
+
+	echo "$hostname" > /proc/sys/kernel/hostname
+	[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
+	echo "$timezone" > /tmp/TZ
+	[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
+
+	# apply timezone to kernel
+	date -k
+}
+
+reload_service() {
+	config_load system
+	config_foreach system_config system
+}
+
+service_triggers()
+{
+	procd_add_reload_trigger "system"
+	procd_add_validation validate_system_section
+}
+
+start_service() {
+	reload_service
+}
+

--- a/package/base-files/files/etc/init.d/umount
+++ b/package/base-files/files/etc/init.d/umount
@@ -1,9 +1,9 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org 
+# Copyright (C) 2006 OpenWrt.org
 
 STOP=99
 stop() {
 	sync
-	umount -a -d -r
+	/bin/umount -a -d -r
 }
 

--- a/package/base-files/files/etc/openwrt_release
+++ b/package/base-files/files/etc/openwrt_release
@@ -4,4 +4,5 @@
 DISTRIB_CODENAME="%n"
 DISTRIB_TARGET="%S"
 DISTRIB_DESCRIPTION="%D %N %V"
+DISTRIB_TAINTS="%t"
 

--- a/package/base-files/files/etc/preinit
+++ b/package/base-files/files/etc/preinit
@@ -32,7 +32,7 @@
 boot_hook_init preinit_mount_root
 
 for pi_source_file in /lib/preinit/*; do
-    . $pi_source_file
+	. $pi_source_file
 done
 
 boot_run_hook preinit_essential
@@ -43,4 +43,3 @@
 
 boot_run_hook preinit_main
 
-

--- a/package/base-files/files/etc/shadow
+++ b/package/base-files/files/etc/shadow
@@ -1,4 +1,4 @@
-root:x:0:0:99999:7:::
+root::0:0:99999:7:::
 daemon:*:0:0:99999:7:::
 ftp:*:0:0:99999:7:::
 network:*:0:0:99999:7:::

--- a/package/base-files/files/etc/uci-defaults/11_migrate-sysctl
+++ b/package/base-files/files/etc/uci-defaults/11_migrate-sysctl
@@ -15,4 +15,3 @@
 
 exit 0
 
-

--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -257,7 +257,27 @@
 	mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
 
 	# "canonicalize" mac
-	[ -n "$mac_dirty" ] && echo ${mac_dirty} | tr [A-F] [a-f]
+	[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
+}
+
+mtd_get_blob()
+{
+	local mtdname="$1"
+	local offset="$2"
+	local count="$3"
+	local firmware="$4"
+	local part
+
+	part=$(find_mtd_part "$mtdname")
+	if [ -z "$part" ]; then
+		echo "mtd_get_blob: partition $mtdname not found!" >&2
+		return 1
+	fi
+
+	dd if=$part of=$firmware bs=1 skip=$offset count=$count 2>/dev/null || {
+		echo "mtd_get_blob: failed to extract $firmware from $part" >&2
+		return 1
+	}
 }
 
 mtd_get_mac_binary() {
@@ -308,6 +328,39 @@
 	local mac=$1
 
 	echo -ne \\x${mac//:/\\x}
+}
+
+macaddr_canonicalize()
+{
+	local mac="$1"
+	local canon=""
+
+	[ ${#mac} -gt 17 ] && return
+	[ -n "${mac//[a-fA-F0-9\.: -]/}" ] && return
+
+	for octet in ${mac//[\.:-]/ }; do
+		case "${#octet}" in
+		1)
+			octet="0${octet}"
+			;;
+		2)
+			;;
+		4)
+			octet="${octet:0:2} ${octet:2:2}"
+			;;
+		12)
+			octet="${octet:0:2} ${octet:2:2} ${octet:4:2} ${octet:6:2} ${octet:8:2} ${octet:10:2}"
+			;;
+		*)
+			return
+			;;
+		esac
+		canon=${canon}${canon:+ }${octet}
+	done
+
+	[ ${#canon} -ne 17 ] && return
+
+	printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${canon// / 0x} 2>/dev/null
 }
 
 strtok() { # <string> { <variable> [<separator>] ... }
@@ -515,12 +568,12 @@
 }
 
 pivot() { # <new_root> <old_root>
-	mount -o noatime,move /proc $1/proc && \
+	/bin/mount -o noatime,move /proc $1/proc && \
 	pivot_root $1 $1$2 && {
-		mount -o noatime,move $2/dev /dev
-		mount -o noatime,move $2/tmp /tmp
-		mount -o noatime,move $2/sys /sys 2>&-
-		mount -o noatime,move $2/overlay /overlay 2>&-
+		/bin/mount -o noatime,move $2/dev /dev
+		/bin/mount -o noatime,move $2/tmp /tmp
+		/bin/mount -o noatime,move $2/sys /sys 2>&-
+		/bin/mount -o noatime,move $2/overlay /overlay 2>&-
 		return 0
 	}
 }
@@ -529,16 +582,16 @@
 	root=$1
 	{
 		if grep -q overlay /proc/filesystems; then
-			mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt
+			/bin/mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt
 		elif grep -q mini_fo /proc/filesystems; then
-			mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt
+			/bin/mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt
 		else
-			mount --bind -o noatime / /mnt
-			mount --bind -o noatime,union "$1" /mnt && root=/mnt
+			/bin/mount --bind -o noatime / /mnt
+			/bin/mount --bind -o noatime,union "$1" /mnt && root=/mnt
 		fi
 	} || {
 		[ "$3" = "1" ] && {
-		mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1
+		/bin/mount | grep "on $1 type" 2>&- 1>&- || /bin/mount -o noatime,bind $1 $1
 		dupe $1 $rom
 		}
 	}
@@ -547,7 +600,7 @@
 
 ramoverlay() {
 	mkdir -p /tmp/root
-	mount -t tmpfs -o noatime,mode=0755 root /tmp/root
+	/bin/mount -t tmpfs -o noatime,mode=0755 root /tmp/root
 	fopivot /tmp/root /rom 1
 }
 

--- a/package/base-files/files/lib/functions/network.sh
+++ b/package/base-files/files/lib/functions/network.sh
@@ -174,8 +174,8 @@
 			fi
 		done
 
-		# parse up state, device and physdev
-		for __field in "up" "l3_device" "device"; do
+		# parse up state, proto, device and physdev
+		for __field in "up" "proto" "l3_device" "device"; do
 			if json_get_type __tmp "$__field"; then
 				__network_set_cache "${__key}_${__field}" "$__field"
 			fi
@@ -222,7 +222,7 @@
 # determine first IPv4 address of given logical interface
 # 1: destination variable
 # 2: interface
-network_get_ipaddr()  { __network_ipaddr "$1" "$2" "address4" "%%/*" 0; }
+network_get_ipaddr() { __network_ipaddr "$1" "$2" "address4" "%%/*" 0; }
 
 # determine first IPv6 address of given logical interface
 # 1: destination variable
@@ -232,7 +232,7 @@
 # determine first IPv4 subnet of given logical interface
 # 1: destination variable
 # 2: interface
-network_get_subnet()  { __network_ipaddr "$1" "$2" "address4" "%% *" 0; }
+network_get_subnet() { __network_ipaddr "$1" "$2" "address4" "%% *" 0; }
 
 # determine first IPv6 subnet of given logical interface
 # 1: destination variable
@@ -247,7 +247,7 @@
 # determine all IPv4 addresses of given logical interface
 # 1: destination variable
 # 2: interface
-network_get_ipaddrs()  { __network_ipaddr "$1" "$2" "address4" "%%/*" 1; }
+network_get_ipaddrs() { __network_ipaddr "$1" "$2" "address4" "%%/*" 1; }
 
 # determine all IPv6 addresses of given logical interface
 # 1: destination variable
@@ -257,7 +257,7 @@
 # determine all IPv4 subnets of given logical interface
 # 1: destination variable
 # 2: interface
-network_get_subnets()  { __network_ipaddr "$1" "$2" "address4" "" 1; }
+network_get_subnets() { __network_ipaddr "$1" "$2" "address4" "" 1; }
 
 # determine all IPv6 subnets of given logical interface
 # 1: destination variable
@@ -292,9 +292,9 @@
 # 1: destination variable
 # 2: interface
 # 3: consider inactive gateway if "true" (optional)
-network_get_gateway()  { __network_gateway "$1" "$2" 4 "${3:-0}"; }
-
-# determine  IPv6 gateway of given logical interface
+network_get_gateway() { __network_gateway "$1" "$2" 4 "${3:-0}"; }
+
+# determine IPv6 gateway of given logical interface
 # 1: destination variable
 # 2: interface
 # 3: consider inactive gateway if "true" (optional)
@@ -354,7 +354,7 @@
 # find the logical interface which holds the current IPv4 default route
 # 1: destination variable
 # 2: consider inactive default routes if "true" (optional)
-network_find_wan()  { __network_wan "$1" 4 "${2:-0}"; }
+network_find_wan() { __network_wan "$1" 4 "${2:-0}"; }
 
 # find the logical interface which holds the current IPv6 default route
 # 1: destination variable
@@ -381,15 +381,20 @@
 	__network_device __up "$1" up && [ $__up -eq 1 ]
 }
 
+# determine the protocol of the given logical interface
+# 1: destination variable
+# 2: interface
+network_get_protocol() { __network_device "$1" "$2" proto; }
+
 # determine the layer 3 linux network device of the given logical interface
 # 1: destination variable
 # 2: interface
-network_get_device()  { __network_device "$1" "$2" l3_device; }
+network_get_device() { __network_device "$1" "$2" l3_device; }
 
 # determine the layer 2 linux network device of the given logical interface
 # 1: destination variable
 # 2: interface
-network_get_physdev() { __network_device "$1" "$2" device;    }
+network_get_physdev() { __network_device "$1" "$2" device; }
 
 
 __network_defer()

--- a/package/base-files/files/lib/functions/service.sh
+++ b/package/base-files/files/lib/functions/service.sh
@@ -4,27 +4,27 @@
 # Usage: service ACTION EXEC ARGS...
 #
 # Action:
-#   -C   check if EXEC is alive
-#   -S   start EXEC, passing it ARGS as its arguments
-#   -K   kill EXEC, sending it a TERM signal if not specified otherwise
+#   -C	check if EXEC is alive
+#   -S	start EXEC, passing it ARGS as its arguments
+#   -K	kill EXEC, sending it a TERM signal if not specified otherwise
 #
 # Environment variables exposed:
-#   SERVICE_DAEMONIZE    run EXEC in background
-#   SERVICE_WRITE_PID    create a pid-file and use it for matching
-#   SERVICE_MATCH_EXEC   use EXEC command-line for matching (default)
-#   SERVICE_MATCH_NAME   use EXEC process name for matching
-#   SERVICE_USE_PID      assume EXEC create its own pid-file and use it for matching
-#   SERVICE_NAME         process name to use (default to EXEC file part)
-#   SERVICE_PID_FILE     pid file to use (default to /var/run/$SERVICE_NAME.pid)
-#   SERVICE_SIG          signal to send when using -K
-#   SERVICE_SIG_RELOAD   default signal used when reloading
-#   SERVICE_SIG_STOP     default signal used when stopping
-#   SERVICE_STOP_TIME    time to wait for a process to stop gracefully before killing it
-#   SERVICE_UID          user EXEC should be run as
-#   SERVICE_GID          group EXEC should be run as
+#   SERVICE_DAEMONIZE	run EXEC in background
+#   SERVICE_WRITE_PID	create a pid-file and use it for matching
+#   SERVICE_MATCH_EXEC	use EXEC command-line for matching (default)
+#   SERVICE_MATCH_NAME	use EXEC process name for matching
+#   SERVICE_USE_PID	assume EXEC create its own pid-file and use it for matching
+#   SERVICE_NAME	process name to use (default to EXEC file part)
+#   SERVICE_PID_FILE	pid file to use (default to /var/run/$SERVICE_NAME.pid)
+#   SERVICE_SIG		signal to send when using -K
+#   SERVICE_SIG_RELOAD	default signal used when reloading
+#   SERVICE_SIG_STOP	default signal used when stopping
+#   SERVICE_STOP_TIME	time to wait for a process to stop gracefully before killing it
+#   SERVICE_UID		user EXEC should be run as
+#   SERVICE_GID		group EXEC should be run as
 #
-#   SERVICE_DEBUG        don't do anything, but show what would be done
-#   SERVICE_QUIET        don't print anything
+#   SERVICE_DEBUG	don't do anything, but show what would be done
+#   SERVICE_QUIET	don't print anything
 #
 
 SERVICE_QUIET=1
@@ -125,6 +125,3 @@
 	done
 }
 
-
-
-

--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -234,4 +234,14 @@
 EOF
 }
 
-
+ucidef_add_switch_port() {
+	local device=$1
+	local port=$2
+	uci batch <<EOF
+add network switch_port
+set network.@switch_port[-1].device='$device'
+set network.@switch_port[-1].port='$port'
+EOF
+}
+
+

--- a/package/base-files/files/lib/preinit/10_indicate_failsafe
+++ b/package/base-files/files/lib/preinit/10_indicate_failsafe
@@ -5,15 +5,14 @@
 # commands for emitting messages to network in failsafe mode
 
 indicate_failsafe_led () {
-    set_state failsafe
+	set_state failsafe
 }
 
 indicate_failsafe() {
-    echo "- failsafe -"
-    preinit_net_echo "Entering Failsafe!\n"
-    indicate_failsafe_led
+	echo "- failsafe -"
+	preinit_net_echo "Entering Failsafe!\n"
+	indicate_failsafe_led
 }
 
 boot_hook_add failsafe indicate_failsafe
 
-

--- a/package/base-files/files/lib/preinit/10_indicate_preinit
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -3,49 +3,48 @@
 # Copyright (C) 2010 Vertical Communications
 
 preinit_ip() {
-    # if the preinit interface isn't specified and ifname is set in 
-    # preinit.arch use that interface
-    if [ -z "$pi_ifname" ]; then
-	pi_ifname=$ifname    
-    fi
+	# if the preinit interface isn't specified and ifname is set in
+	# preinit.arch use that interface
+	if [ -z "$pi_ifname" ]; then
+		pi_ifname=$ifname
+	fi
 
-    [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
-	ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
-    }
+	[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+		ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
+	}
 }
 
 preinit_ip_deconfig() {
-    [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
-	ifconfig $pi_ifname 0.0.0.0 down
-    }
+	[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+		ifconfig $pi_ifname 0.0.0.0 down
+	}
 }
 
 preinit_net_echo() {
 	[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
-		{ 
+		{
 			[ "$pi_preinit_net_messages" = "y" ] || {
-    		     		[ "$pi_failsafe_net_message"  = "true" ] && 
-    		         	    [ "$pi_preinit_no_failsafe_netmsg" != "y" ] 
-    		         }
+				[ "$pi_failsafe_net_message" = "true" ] &&
+					[ "$pi_preinit_no_failsafe_netmsg" != "y" ]
+			}
 		} && netmsg $pi_broadcast "$1"
-    	}
+	}
 }
 
 preinit_echo() {
-    preinit_net_echo $1
-    echo $1
+	preinit_net_echo $1
+	echo $1
 }
 
 pi_indicate_led() {
-    set_state preinit
+	set_state preinit
 }
 
 pi_indicate_preinit() {
-    preinit_net_echo "Doing OpenWRT Preinit\n"
-    pi_indicate_led
+	preinit_net_echo "Doing OpenWRT Preinit\n"
+	pi_indicate_led
 }
 
 boot_hook_add preinit_main preinit_ip
 boot_hook_add preinit_main pi_indicate_preinit
 
-

--- a/package/base-files/files/lib/preinit/30_failsafe_wait
+++ b/package/base-files/files/lib/preinit/30_failsafe_wait
@@ -3,87 +3,95 @@
 # Copyright (C) 2010 Vertical Communications
 
 fs_wait_for_key () {
-    local timeout=$3
-    local timer
-    local do_failsafe
-    local keypress_true="$(mktemp)"
-    local keypress_wait="$(mktemp)"
-    local keypress_sec="$(mktemp)"
-    if [ -z "$keypress_wait" ]; then
-	keypress_wait=/tmp/.keypress_wait
-	touch $keypress_wait
-    fi
-    if [ -z "$keypress_true" ]; then
-	keypress_true=/tmp/.keypress_true
-	touch $keypress_true
-    fi
-    if [ -z "$keypress_sec" ]; then
-	keypress_sec=/tmp/.keypress_sec
-	touch $keypress_sec
-    fi
+	local timeout=$3
+	local timer
+	local do_keypress
+	local keypress_true="$(mktemp)"
+	local keypress_wait="$(mktemp)"
+	local keypress_sec="$(mktemp)"
+	if [ -z "$keypress_wait" ]; then
+		keypress_wait=/tmp/.keypress_wait
+		touch $keypress_wait
+	fi
+	if [ -z "$keypress_true" ]; then
+		keypress_true=/tmp/.keypress_true
+		touch $keypress_true
+	fi
+	if [ -z "$keypress_sec" ]; then
+		keypress_sec=/tmp/.keypress_sec
+		touch $keypress_sec
+	fi
 
-    trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
-    trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
+	trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
+	trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
 
-    [ -n "$timeout" ] || timeout=1
-    [ $timeout -ge 1 ] || timeout=1
-    timer=$timeout
-    lock $keypress_wait
-    {
-	while [ $timer -gt 0 ]; do
-            echo "$timer" >$keypress_sec
-	    timer=$(($timer - 1))
-	    sleep 1
-	done
-	lock -u $keypress_wait
+	[ -n "$timeout" ] || timeout=1
+	[ $timeout -ge 1 ] || timeout=1
+	timer=$timeout
+	lock $keypress_wait
+	{
+		while [ $timer -gt 0 ]; do
+			echo "$timer" >$keypress_sec
+			timer=$(($timer - 1))
+			sleep 1
+		done
+		lock -u $keypress_wait
+		rm -f $keypress_wait
+	} &
+
+	echo "Press the [$1] key and hit [enter] $2"
+	echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level"
+	# if we're on the console we wait for input
+	{
+		while [ -r $keypress_wait ]; do
+			timer="$(cat $keypress_sec)"
+
+			[ -n "$timer" ] || timer=1
+			timer="${timer%%\ *}"
+			[ $timer -ge 1 ] || timer=1
+			do_keypress=""
+			{
+				read -t "$timer" do_keypress
+				case "$do_keypress" in
+				$1)
+					echo "true" >$keypress_true
+					;;
+				1 | 2 | 3 | 4)
+					echo "$do_keypress" >/tmp/debug_level
+					;;
+				*)
+					continue;
+					;;
+				esac
+				lock -u $keypress_wait
+				rm -f $keypress_wait
+			}
+		done
+	}
+	lock -w $keypress_wait
+
+	keypressed=1
+	[ "$(cat $keypress_true)" = "true" ] && keypressed=0
+
+	rm -f $keypress_true
 	rm -f $keypress_wait
-    } &
+	rm -f $keypress_sec
 
-    echo "Press the [$1] key and hit [enter] $2"
-    # if we're on the console we wait for input
-    { 
-	while [ -r $keypress_wait ]; do
-	    timer="$(cat $keypress_sec)"
-
-	    [ -n "$timer" ] || timer=1
-	    timer="${timer%%\ *}"
-	    [ $timer -ge 1 ] || timer=1
-	    do_failsafe=""
-	    {
-		read -t "$timer" do_failsafe
-		if [ "$do_failsafe" = "$1" ]; then
-		    echo "true" >$keypress_true
-		    lock -u $keypress_wait
-		    rm -f $keypress_wait
- 		fi
-	    }
-	done
-    }
-    lock -w $keypress_wait
-
-    keypressed=1
-    [ "$(cat $keypress_true)" = "true" ] && keypressed=0
-    
-    rm -f $keypress_true
-    rm -f $keypress_wait
-    rm -f $keypress_sec
-    
-    return $keypressed
+	return $keypressed
 }
 
 failsafe_wait() {
-    FAILSAFE=
-    grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE
-    if [ "$FAILSAFE" != "true" ]; then
-      pi_failsafe_net_message=true
-      preinit_net_echo "Please press button now to enter failsafe"
-      pi_failsafe_net_message=false
-      fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true
-      [ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -"
-      [ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
-    fi
+	FAILSAFE=
+	grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE
+	if [ "$FAILSAFE" != "true" ]; then
+		pi_failsafe_net_message=true
+		preinit_net_echo "Please press button now to enter failsafe"
+		pi_failsafe_net_message=false
+		fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true
+		[ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -"
+		[ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
+	fi
 }
 
 boot_hook_add preinit_main failsafe_wait
 
-

--- a/package/base-files/files/lib/preinit/40_run_failsafe_hook
+++ b/package/base-files/files/lib/preinit/40_run_failsafe_hook
@@ -11,4 +11,3 @@
 
 boot_hook_add preinit_main run_failsafe_hook
 
-

--- a/package/base-files/files/lib/preinit/50_indicate_regular_preinit
+++ b/package/base-files/files/lib/preinit/50_indicate_regular_preinit
@@ -3,10 +3,9 @@
 # Copyright (C) 2010 Vertical Communications
 
 indicate_regular_preinit() {
-    preinit_net_echo "Continuing with Regular Preinit\n"
-    pi_indicate_led
+	preinit_net_echo "Continuing with Regular Preinit\n"
+	pi_indicate_led
 }
 
 boot_hook_add preinit_main indicate_regular_preinit
 
-

--- a/package/base-files/files/lib/preinit/70_initramfs_test
+++ b/package/base-files/files/lib/preinit/70_initramfs_test
@@ -3,13 +3,12 @@
 # Copyright (C) 2010 Vertical Communications
 
 initramfs_test() {
-    if [ -n "$INITRAMFS" ]; then
-	boot_run_hook initramfs
-	preinit_ip_deconfig
-	break
-    fi
+	if [ -n "$INITRAMFS" ]; then
+		boot_run_hook initramfs
+		preinit_ip_deconfig
+		break
+	fi
 }
 
 boot_hook_add preinit_main initramfs_test
 
-

--- a/package/base-files/files/lib/preinit/99_10_failsafe_login
+++ b/package/base-files/files/lib/preinit/99_10_failsafe_login
@@ -3,17 +3,15 @@
 # Copyright (C) 2010 Vertical Communications
 
 failsafe_netlogin () {
-    telnetd -l /bin/login.sh <> /dev/null 2>&1    
+	telnetd -l /bin/login.sh <> /dev/null 2>&1
 }
 
 failsafe_shell() {
-    lock /tmp/.failsafe
-    ash --login
-    echo "Please reboot system when done with failsafe network logins"
+	lock /tmp/.failsafe
+	ash --login
+	echo "Please reboot system when done with failsafe network logins"
 }
-
 
 boot_hook_add failsafe failsafe_netlogin
 boot_hook_add failsafe failsafe_shell
 
-

--- a/package/base-files/files/lib/preinit/99_10_run_init
+++ b/package/base-files/files/lib/preinit/99_10_run_init
@@ -3,9 +3,8 @@
 # Copyright (C) 2010 Vertical Communications
 
 run_init() {
-    preinit_ip_deconfig
+	preinit_ip_deconfig
 }
 
 boot_hook_add preinit_main run_init
 
-

--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -34,26 +34,26 @@
 }
 
 supivot() { # <new_root> <old_root>
-	mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
+	/bin/mount | grep "on $1 type" 2>&- 1>&- || /bin/mount -o bind $1 $1
 	mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \
-	mount -o noatime,move /proc $1/proc && \
+	/bin/mount -o noatime,move /proc $1/proc && \
 	pivot_root $1 $1$2 || {
-        umount -l $1 $1
+		/bin/umount -l $1 $1
 		return 1
 	}
 
-	mount -o noatime,move $2/sys /sys
-	mount -o noatime,move $2/dev /dev
-	mount -o noatime,move $2/tmp /tmp
-	mount -o noatime,move $2/overlay /overlay 2>&-
+	/bin/mount -o noatime,move $2/sys /sys
+	/bin/mount -o noatime,move $2/dev /dev
+	/bin/mount -o noatime,move $2/tmp /tmp
+	/bin/mount -o noatime,move $2/overlay /overlay 2>&-
 	return 0
 }
 
 run_ramfs() { # <command> [...]
-	install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount        \
-		/sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd   \
-		/bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \
-		/bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump          \
+	install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount	\
+		/sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd	\
+		/bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/["	\
+		/bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump		\
 		/bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc
 
 	install_bin /sbin/mtd
@@ -67,12 +67,12 @@
 		exit 1
 	}
 
-	mount -o remount,ro /mnt
-	umount -l /mnt
+	/bin/mount -o remount,ro /mnt
+	/bin/umount -l /mnt
 
 	grep /overlay /proc/mounts > /dev/null && {
-		mount -o noatime,remount,ro /overlay
-		umount -l /overlay
+		/bin/mount -o noatime,remount,ro /overlay
+		/bin/umount -l /overlay
 	}
 
 	# spawn a new shell from ramdisk to reduce the probability of cache issues
@@ -94,7 +94,7 @@
 		local cmdline
 		read cmdline < /proc/$pid/cmdline
 
-		# Skip kernel threads 
+		# Skip kernel threads
 		[ -n "$cmdline" ] || continue
 
 		case "$name" in
@@ -144,7 +144,7 @@
 }
 
 rootfs_type() {
-	mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
+	/bin/mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
 }
 
 get_image() { # <source> [ <command> ]
@@ -188,7 +188,7 @@
 default_do_upgrade() {
 	sync
 	if [ "$SAVE_CONFIG" -eq 1 ]; then
-		get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}"
+		get_image "$1" | mtd $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}"
 	else
 		get_image "$1" | mtd write - "${PART_NAME:-image}"
 	fi

--- a/package/base-files/files/sbin/hotplug-call
+++ b/package/base-files/files/sbin/hotplug-call
@@ -9,6 +9,7 @@
 LOGNAME=root
 USER=root
 export PATH LOGNAME USER
+export DEVICENAME="${DEVPATH##*/}"
 
 [ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && {
 	for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (

--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -4,6 +4,7 @@
 # initialize defaults
 RAMFS_COPY_BIN=""	# extra programs for temporary ramfs root
 RAMFS_COPY_DATA=""	# extra data files
+export MTD_CONFIG_ARGS=""
 export INTERACTIVE=0
 export VERBOSE=1
 export SAVE_CONFIG=1
@@ -19,7 +20,7 @@
 export TEST=0
 
 # parse options
-while [ -n "$1" ]; do 
+while [ -n "$1" ]; do
 	case "$1" in
 		-i) export INTERACTIVE=1;;
 		-d) export DELAY="$2"; shift;;
@@ -209,9 +210,11 @@
 ubus call system upgrade
 touch /tmp/sysupgrade
 
-kill_remaining TERM
-sleep 3
-kill_remaining KILL
+if [ ! -f /tmp/failsafe ] ; then
+	kill_remaining TERM
+	sleep 3
+	kill_remaining KILL
+fi
 
 if [ -n "$(rootfs_type)" ]; then
 	v "Switching to ramdisk..."

--- a/package/base-files/files/sbin/wifi
+++ b/package/base-files/files/sbin/wifi
@@ -2,13 +2,23 @@
 # Copyright (C) 2006 OpenWrt.org
 
 . /lib/functions.sh
+. /usr/share/libubox/jshn.sh
 
 usage() {
 	cat <<EOF
-Usage: $0 [down|detect]
+Usage: $0 [down|detect|reload|status]
 enables (default), disables or detects a wifi configuration.
 EOF
 	exit 1
+}
+
+ubus_wifi_cmd() {
+	local cmd="$1"
+	local dev="$2"
+
+	json_init
+	[ -n "$2" ] && json_add_string device "$2"
+	ubus call network.wireless "$1" "$(json_dump)"
 }
 
 find_net_config() {(
@@ -54,7 +64,7 @@
 	[ "${#key}" -eq 10 -a $hex -eq 1 ] || \
 	[ "${#key}" -eq 26 -a $hex -eq 1 ] || {
 		[ "${key:0:2}" = "s:" ] && key="${key#s:}"
-        	key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')"
+		key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')"
 	}
 	echo "$key"
 }
@@ -81,7 +91,7 @@
 		;;
 		*)
 			hwmode=
-			if [ "${channel:-0}" -gt 0 ]; then 
+			if [ "${channel:-0}" -gt 0 ]; then
 				if [ "${channel:-0}" -gt 14 ]; then
 					hwmode=a
 				else
@@ -95,11 +105,7 @@
 	config_set "$device" hwmode "$hwmode"
 }
 
-wifi_updown() {
-	[ enable = "$1" ] && {
-		wifi_updown disable "$2"
-		scan_wifi
-	}
+_wifi_updown() {
 	for device in ${2:-$DEVICES}; do (
 		config_get disabled "$device" disabled
 		[ 1 == "$disabled" ] && {
@@ -110,10 +116,33 @@
 		if eval "type ${1}_$iftype" 2>/dev/null >/dev/null; then
 			eval "scan_$iftype '$device'"
 			eval "${1}_$iftype '$device'" || echo "$device($iftype): ${1} failed"
-		else
+		elif [ ! -f /lib/netifd/wireless/$iftype.sh ]; then
 			echo "$device($iftype): Interface type not supported"
 		fi
 	); done
+}
+
+wifi_updown() {
+	cmd=down
+	[ enable = "$1" ] && {
+		_wifi_updown disable "$2"
+		ubus_wifi_cmd "$cmd" "$2"
+		scan_wifi
+		cmd=up
+	}
+	ubus_wifi_cmd "$cmd" "$2"
+	_wifi_updown "$@"
+}
+
+wifi_reload_legacy() {
+	_wifi_updown "disable" "$1"
+	scan_wifi
+	_wifi_updown "enable" "$1"
+}
+
+wifi_reload() {
+	ubus call network reload
+	wifi_reload_legacy
 }
 
 wifi_detect() {
@@ -182,7 +211,7 @@
 		case "$TYPE" in
 			wifi-iface)
 				config_get device "$CONFIG_SECTION" device
-				config_get vifs "$device" vifs 
+				config_get vifs "$device" vifs
 				append vifs "$CONFIG_SECTION"
 				config_set "$device" vifs "$vifs"
 			;;
@@ -199,7 +228,10 @@
 case "$1" in
 	down) wifi_updown "disable" "$2";;
 	detect) wifi_detect "$2";;
+	status) ubus_wifi_cmd "status" "$2";;
+	reload) wifi_reload "$2";;
+	reload_legacy) wifi_reload_legacy "$2";;
 	--help|help) usage;;
-	*) wifi_updown "enable" "$2";;
+	*) ubus call network reload; wifi_updown "enable" "$2";;
 esac
 

--- a/package/boot/grub2/Makefile
+++ b/package/boot/grub2/Makefile
@@ -28,7 +28,7 @@
   SECTION:=utils
   TITLE:=GRand Unified Bootloader
   URL:=http://www.gnu.org/software/grub/
-  DEPENDS:=@TARGET_x86
+  DEPENDS:=@TARGET_x86||TARGET_x86_64
 endef
 
 define Package/grub2-editenv
@@ -36,7 +36,7 @@
   SECTION:=utils
   TITLE:=Grub2 Environment editor
   URL:=http://www.gnu.org/software/grub/
-  DEPENDS:=@TARGET_x86
+  DEPENDS:=@TARGET_x86||TARGET_x86_64
 endef
 
 define Package/grub2-editenv/description

--- a/package/boot/kexec-tools/Makefile
+++ b/package/boot/kexec-tools/Makefile
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=kexec-tools
-PKG_VERSION:=2.0.3
+PKG_VERSION:=2.0.4
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
-PKG_MD5SUM:=b3ced2097ce3981abba38ceedc84f939
+PKG_MD5SUM:=05992bc8c0673fc55be7b6d27e48a8db
 
 PKG_FIXUP:=autoreconf
 
@@ -54,7 +54,8 @@
 		--sbindir=/usr/sbin \
 		--libexecdir=/usr/lib \
 		--sysconfdir=/etc \
-		$(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib
+		$(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \
+		--without-lzma
 
 TARGET_CFLAGS += -ffunction-sections -fdata-sections
 TARGET_LDFLAGS += -Wl,--gc-sections

--- a/package/boot/uboot-envtools/Makefile
+++ b/package/boot/uboot-envtools/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2006-2014 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -10,7 +10,7 @@
 PKG_NAME:=uboot-envtools
 PKG_DISTNAME:=u-boot
 PKG_VERSION:=2013.10
-PKG_RELEASE:=1
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:= \
@@ -41,6 +41,7 @@
 	touch $(PKG_BUILD_DIR)/include/config.h
 	$(MAKE) -C $(PKG_BUILD_DIR) \
 		HOSTCC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gcc" \
+		HOSTOPTFLAGS="$(TARGET_CFLAGS)" \
 		HOSTSTRIP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)strip" \
 		env
 endef

--- a/package/boot/uboot-envtools/files/ar71xx
+++ b/package/boot/uboot-envtools/files/ar71xx
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2011-2013 OpenWrt.org
+# Copyright (C) 2011-2014 OpenWrt.org
 #
 
 [ -e /etc/config/ubootenv ] && exit 0
@@ -19,7 +19,8 @@
 hornet-ub | \
 hornet-ub-x2 | \
 mr600 | \
-mr600v2)
+mr600v2 | \
+wndr3700)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
 	;;
 alfa-ap96 | \

--- /dev/null
+++ b/package/boot/uboot-envtools/patches/001-honor_opt_flags.patch
@@ -1,1 +1,13 @@
+--- a/config.mk
++++ b/config.mk
+@@ -62,7 +62,8 @@ PLATFORM_LDFLAGS =
+ 
+ #########################################################################
+ 
+-HOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
++HOSTOPTFLAGS	= -O2 -fomit-frame-pointer
++HOSTCFLAGS	= -Wall -Wstrict-prototypes $(HOSTOPTFLAGS) \
+ 		  $(HOSTCPPFLAGS)
+ HOSTSTRIP	= strip
+ 
 

--- a/package/boot/uboot-kirkwood/Makefile
+++ b/package/boot/uboot-kirkwood/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2010-2012 OpenWrt.org
+# Copyright (C) 2010-2013 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=u-boot
-PKG_VERSION:=2012.10
+PKG_VERSION:=2013.10
 PKG_RELEASE:=1
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
@@ -16,8 +16,10 @@
 PKG_SOURCE_URL:= \
 	http://mirror2.openwrt.org/sources \
 	ftp://ftp.denx.de/pub/u-boot
-PKG_MD5SUM:=8655f63b1e5c4647295ac9ce44660be3
+PKG_MD5SUM:=a076a044b64371edc52f7e562b13f6b2
 PKG_TARGETS:=bin
+
+PKG_BUILD_PARALLEL:=1
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -27,23 +29,49 @@
   IMAGE:=
 endef
 
-define uboot/sheevaplug
-  TITLE:=U-Boot for the SheevaPlug
+define uboot/dockstar
+  TITLE:=U-Boot for Seagate DockStar
 endef
 
-define uboot/dockstar
-  TITLE:=U-Boot for the Seagate DockStar
+define uboot/dockstar_second_stage
+  TITLE:=second stage U-Boot for Seagate DockStar
+endef
+
+define uboot/goflexhome
+  TITLE:=U-Boot for the Seagate GoFlexHome/GoFlexNet
+endef
+
+define uboot/ib62x0
+  TITLE:=U-Boot for RaidSonic ICY BOX NAS6210 and NAS6220
+endef
+
+define uboot/ib62x0_second_stage
+  TITLE:=second stage U-Boot for RaidSonic ICY BOX NAS6210 and NAS6220
 endef
 
 define uboot/iconnect
-  TITLE:=U-Boot for the Iomega iConnect Wireless
+  TITLE:=U-Boot for Iomega iConnect Wireless
 endef
 
-define uboot/ib62x0
-  TITLE:=U-Boot for the RaidSonic ICY BOX NAS6210 and NAS6220
+define uboot/iconnect_second_stage
+  TITLE:=second stage U-Boot for Iomega iConnect Wireless
 endef
 
-UBOOTS:=sheevaplug dockstar iconnect ib62x0
+define uboot/pogo_e02
+  TITLE:=U-Boot for Cloud Engines Pogoplug E02
+endef
+
+define uboot/sheevaplug
+  TITLE:=U-Boot for SheevaPlug
+endef
+
+UBOOTS:= \
+	dockstar dockstar_second_stage \
+	goflexhome \
+	ib62x0 ib62x0_second_stage \
+	iconnect iconnect_second_stage \
+	pogo_e02 \
+	sheevaplug
 
 define Package/uboot/template
 define Package/uboot-kirkwood-$(1)
@@ -69,14 +97,18 @@
 endif
 
 define Build/Configure
-	$(MAKE) -C $(PKG_BUILD_DIR) \
+	+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
 		$(UBOOT_CONFIG)_config
 endef
 
 define Build/Compile
-	$(MAKE) -C $(PKG_BUILD_DIR) \
+	+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
 		u-boot.kwb \
 		CROSS_COMPILE=$(TARGET_CROSS)
+	mkimage -A $(ARCH) -O linux -T kernel -C none \
+		-a 0x600000 -e 0x600000 \
+		-n 'OpenWrt Das U-Boot uImage' \
+		-d $(PKG_BUILD_DIR)/u-boot.bin $(PKG_BUILD_DIR)/u-boot.img
 endef
 
 define Package/uboot/install/default
@@ -85,6 +117,8 @@
 		$(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.bin
 	$(CP) $(PKG_BUILD_DIR)/u-boot.kwb \
 		$(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.kwb
+	$(CP) $(PKG_BUILD_DIR)/u-boot.img \
+		$(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.img
 	$(INSTALL_DIR) $(BIN_DIR)/u-boot-kwboot/
 	$(CP) $(PKG_BUILD_DIR)/tools/kwboot \
 		$(BIN_DIR)/u-boot-kwboot/

--- /dev/null
+++ b/package/boot/uboot-kirkwood/patches/0001-kirkwood-ib62x0-use-device-tree-and-update-config.patch
@@ -1,1 +1,90 @@
+From 2701517a2bbf17544b408738438b0dd17718d4dd Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 14 Nov 2012 23:32:55 +0100
+Subject: [PATCH] kirkwood: ib62x0: use device tree and update config
 
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+CC: Prafulla Wadaskar <prafulla@marvell.com>
+---
+v1->v2:
+
+ * keep CONFIG_MACH_TYPE define for backwards compatibility
+---
+http://patchwork.ozlabs.org/patch/287388/
+Acked-By: Prafulla Wadaskar <prafulla@marvell.com>
+---
+ include/configs/ib62x0.h | 38 +++++++++++++++++++++++---------------
+ 1 file changed, 23 insertions(+), 15 deletions(-)
+
+--- a/include/configs/ib62x0.h
++++ b/include/configs/ib62x0.h
+@@ -28,6 +28,11 @@
+ #define CONFIG_MACH_TYPE	MACH_TYPE_NAS6210
+ 
+ /*
++ * Enable device tree support
++ */
++#define CONFIG_OF_LIBFDT
++
++/*
+  * Compression configuration
+  */
+ #define CONFIG_BZIP2
+@@ -41,6 +46,7 @@
+ #define CONFIG_SYS_MVFS
+ #include <config_cmd_default.h>
+ #define CONFIG_CMD_ENV
++#define CONFIG_CMD_BOOTZ
+ #define CONFIG_CMD_IDE
+ #define CONFIG_CMD_MII
+ #define CONFIG_CMD_NAND
+@@ -66,7 +72,7 @@
+ #define CONFIG_ENV_IS_NOWHERE
+ #endif
+ #define CONFIG_ENV_SIZE		0x20000
+-#define CONFIG_ENV_OFFSET	0x80000
++#define CONFIG_ENV_OFFSET	0xe0000
+ 
+ /*
+  * Default environment variables
+@@ -74,24 +80,26 @@
+ #define CONFIG_BOOTCOMMAND \
+ 	"setenv bootargs ${console} ${mtdparts} ${bootargs_root}; "	\
+ 	"ubi part root; "						\
+-	"ubifsmount ubi:root; "						\
++	"ubifsmount ubi:rootfs; "					\
+ 	"ubifsload 0x800000 ${kernel}; "				\
+-	"ubifsload 0x1100000 ${initrd}; "				\
+-	"bootm 0x800000 0x1100000"
+-
+-#define CONFIG_MTDPARTS				\
+-	"mtdparts=orion_nand:"			\
+-	"0x80000@0x0(uboot),"			\
+-	"0x20000@0x80000(uboot_env),"		\
+-	"-@0xa0000(root)\0"
++	"ubifsload 0x700000 ${fdt}; "					\
++	"ubifsumount; "							\
++	"fdt addr 0x700000; fdt resize; fdt chosen; "			\
++	"bootz 0x800000 - 0x700000"
++
++#define CONFIG_MTDPARTS \
++	"mtdparts=orion_nand:"						\
++	"0xe0000@0x0(uboot),"						\
++	"0x20000@0xe0000(uboot_env),"					\
++	"-@0x100000(root)\0"
+ 
+-#define CONFIG_EXTRA_ENV_SETTINGS					\
++#define CONFIG_EXTRA_ENV_SETTINGS \
+ 	"console=console=ttyS0,115200\0"				\
+ 	"mtdids=nand0=orion_nand\0"					\
+ 	"mtdparts="CONFIG_MTDPARTS					\
+-	"kernel=/boot/uImage\0"						\
+-	"initrd=/boot/uInitrd\0"					\
+-	"bootargs_root=ubi.mtd=2 root=ubi0:root rootfstype=ubifs\0"
++	"kernel=/boot/zImage\0"						\
++	"fdt=/boot/ib62x0.dtb\0"					\
++	"bootargs_root=ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs rw\0"
+ 
+ /*
+  * Ethernet driver configuration
+

--- a/package/boot/uboot-kirkwood/patches/110-dockstar.patch
+++ b/package/boot/uboot-kirkwood/patches/110-dockstar.patch
@@ -1,23 +1,104 @@
 --- a/include/configs/dockstar.h
 +++ b/include/configs/dockstar.h
-@@ -83,22 +83,19 @@
+@@ -15,21 +15,26 @@
+ /*
+  * Version number information
+  */
+-#define CONFIG_IDENT_STRING	"\nSeagate FreeAgent DockStar"
++#define CONFIG_IDENT_STRING	" Seagate FreeAgent DockStar"
+ 
+ /*
+- * High Level Configuration Options (easy to change)
++ * High level configuration options
+  */
+-#define CONFIG_FEROCEON_88FR131	1	/* CPU Core subversion */
+-#define CONFIG_KIRKWOOD		1	/* SOC Family Name */
+-#define CONFIG_KW88F6281	1	/* SOC Name */
+-#define CONFIG_MACH_DOCKSTAR	/* Machine type */
++#define CONFIG_FEROCEON_88FR131		/* CPU Core subversion */
++#define CONFIG_KIRKWOOD			/* SOC Family Name */
++#define CONFIG_KW88F6281		/* SOC Name */
+ #define CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
+ 
+ /*
++ * Machine type
++ */
++#define CONFIG_MACH_DOCKSTAR
++
++/*
+  * Commands configuration
+  */
+-#define CONFIG_SYS_NO_FLASH		/* Declare no flash (NOR/SPI) */
++#define CONFIG_SYS_NO_FLASH		/* declare no flash (NOR/SPI) */
++#define CONFIG_SYS_MVFS
+ #include <config_cmd_default.h>
+ #define CONFIG_CMD_DHCP
+ #define CONFIG_CMD_ENV
+@@ -37,55 +42,58 @@
+ #define CONFIG_CMD_NAND
+ #define CONFIG_CMD_PING
+ #define CONFIG_CMD_USB
++
+ /*
+  * mv-common.h should be defined after CMD configs since it used them
+  * to enable certain macros
+  */
+ #include "mv-common.h"
+ 
+-#undef CONFIG_SYS_PROMPT	/* previously defined in mv-common.h */
+-#define CONFIG_SYS_PROMPT	"DockStar> "	/* Command Prompt */
++#undef CONFIG_SYS_PROMPT
++#define CONFIG_SYS_PROMPT	"dockstar => "
+ 
+ /*
+- *  Environment variables configurations
++ * Environment variables configuration
+  */
+ #ifdef CONFIG_CMD_NAND
+-#define CONFIG_ENV_IS_IN_NAND		1
+-#define CONFIG_ENV_SECT_SIZE		0x20000	/* 128K */
++#define CONFIG_ENV_IS_IN_NAND
++#define CONFIG_ENV_SECT_SIZE	0x20000
+ #else
+-#define CONFIG_ENV_IS_NOWHERE		1	/* if env in SDRAM */
++#define CONFIG_ENV_IS_NOWHERE
+ #endif
+-/*
+- * max 4k env size is enough, but in case of nand
+- * it has to be rounded to sector size
+- */
+-#define CONFIG_ENV_SIZE			0x20000	/* 128k */
+-#define CONFIG_ENV_ADDR			0x60000
+-#define CONFIG_ENV_OFFSET		0x60000	/* env starts here */
++#define CONFIG_ENV_SIZE		0x20000
++#define CONFIG_ENV_OFFSET	0xe0000
+ 
+ /*
   * Default environment variables
   */
  #define CONFIG_BOOTCOMMAND \
--	"setenv bootargs ${console} ${mtdparts} ${bootargs_root}; "	\
+ 	"setenv bootargs ${console} ${mtdparts} ${bootargs_root}; "	\
 -	"ubi part root; " \
--	"ubifsmount root; " \
+-	"ubifsmount ubi:root; " \
 -	"ubifsload 0x800000 ${kernel}; " \
 -	"ubifsload 0x1100000 ${initrd}; " \
 -	"bootm 0x800000 0x1100000"
-+	"${x_bootcmd_kernel}; "					\
-+	"setenv bootargs ${x_bootargs} ${x_bootargs_root}; "	\
-+	"${x_bootcmd_usb}; bootm 0x6400000;"
- 
+-
 -#define CONFIG_MTDPARTS		"mtdparts=orion_nand:1m(uboot),-(root)\0"
++	"ubi part root; "						\
++	"ubifsmount ubi:rootfs; "					\
++	"ubifsload 0x800000 ${kernel}; "				\
++	"ubifsload 0x700000 ${fdt}; "					\
++	"ubifsumount; "							\
++	"fdt addr 0x700000; fdt resize; fdt chosen; "			\
++	"bootz 0x800000 - 0x700000"
++
 +#define CONFIG_MTDPARTS \
-+	"orion_nand:1M(u-boot),1M@1M(second_stage_u-boot),"	\
-+	"3M@2M(kernel),32M@5M(rootfs),219M@37M(data) rw\0"
++	"mtdparts=orion_nand:"				\
++	"0xe0000@0x0(uboot),"				\
++	"0x20000@0xe0000(uboot_env),"			\
++	"0x100000@0x100000(second_stage_uboot),"	\
++	"-@0x200000(root)\0"
  
  #define CONFIG_EXTRA_ENV_SETTINGS \
 -	"console=console=ttyS0,115200\0" \
@@ -26,11 +107,36 @@
 -	"kernel=/boot/uImage\0" \
 -	"initrd=/boot/uInitrd\0" \
 -	"bootargs_root=ubi.mtd=1 root=ubi0:root rootfstype=ubifs ro\0"
-+	"x_bootargs=console=ttyS0,115200 mtdparts="CONFIG_MTDPARTS	\
-+	"x_bootcmd_kernel=nand read 0x6400000 0x200000 0x300000\0"	\
-+	"x_bootargs_root=root=/dev/mtdblock3 rw rootfstype=jffs2\0"	\
-+	"x_bootcmd_usb=usb start\0"
++	"console=console=ttyS0,115200\0"	\
++	"mtdids=nand0=orion_nand\0"		\
++	"mtdparts="CONFIG_MTDPARTS		\
++	"kernel=/boot/zImage\0"			\
++	"fdt=/boot/dockstar.dtb\0"		\
++	"bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0"
  
  /*
-  * Ethernet Driver configuration
+- * Ethernet Driver configuration
++ * Ethernet driver configuration
+  */
+ #ifdef CONFIG_CMD_NET
+ #define CONFIG_MVGBE_PORTS	{1, 0}	/* enable port 0 only */
+@@ -101,7 +109,7 @@
+ #define CONFIG_CMD_UBI
+ #define CONFIG_CMD_UBIFS
+ #define CONFIG_RBTREE
+-#define CONFIG_MTD_DEVICE               /* needed for mtdparts commands */
++#define CONFIG_MTD_DEVICE
+ #define CONFIG_MTD_PARTITIONS
+ #define CONFIG_CMD_MTDPARTS
+ #define CONFIG_LZO
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -190,6 +190,7 @@ Active  arm         arm926ejs      kirkw
+ Active  arm         arm926ejs      kirkwood    Marvell         openrd              openrd_ultimate                      openrd:BOARD_IS_OPENRD_ULTIMATE                                                                                                   -
+ Active  arm         arm926ejs      kirkwood    raidsonic       ib62x0              ib62x0                               -                                                                                                                                 Luka Perkov <luka@openwrt.org>
+ Active  arm         arm926ejs      kirkwood    Seagate         -                   dockstar                             -                                                                                                                                 Eric Cooper <ecc@cmu.edu>
++Active  arm         arm926ejs      kirkwood    Seagate         dockstar            dockstar_second_stage                dockstar:SECOND_STAGE                                                                                                             Luka Perkov <luka@openwrt.org>
+ Active  arm         arm926ejs      kirkwood    Seagate         -                   goflexhome                           -                                                                                                                                 Suriyan Ramasami <suriyan.r@gmail.com>
+ Active  arm         arm926ejs      lpc32xx     timll           devkit3250          devkit3250                           -                                                                                                                                 Vladimir Zapolskiy <vz@mleia.com>
+ Active  arm         arm926ejs      mb86r0x     syteco          jadecpu             jadecpu                              -                                                                                                                                 Matthias Weisser <weisserm@arcor.de>
 

--- /dev/null
+++ b/package/boot/uboot-kirkwood/patches/120-iconnect.patch
@@ -1,1 +1,58 @@
+--- a/include/configs/iconnect.h
++++ b/include/configs/iconnect.h
+@@ -65,30 +65,35 @@
+ #define CONFIG_ENV_IS_NOWHERE
+ #endif
+ #define CONFIG_ENV_SIZE		0x20000
+-#define CONFIG_ENV_OFFSET	0x80000
++#define CONFIG_ENV_OFFSET	0xe0000
+ 
+ /*
+  * Default environment variables
+  */
+ #define CONFIG_BOOTCOMMAND \
+ 	"setenv bootargs ${console} ${mtdparts} ${bootargs_root}; "	\
+-	"ubi part rootfs; "						\
++	"ubi part root; "						\
+ 	"ubifsmount ubi:rootfs; "					\
+ 	"ubifsload 0x800000 ${kernel}; "				\
+-	"bootm 0x800000"
++	"ubifsload 0x700000 ${fdt}; "					\
++	"ubifsumount; "							\
++	"fdt addr 0x700000; fdt resize; fdt chosen; "			\
++	"bootz 0x800000 - 0x700000"
+ 
+ #define CONFIG_MTDPARTS \
+-	"mtdparts=orion_nand:"		\
+-	"0x80000@0x0(uboot),"		\
+-	"0x20000@0x80000(uboot_env),"	\
+-	"-@0xa0000(rootfs)\0"
++	"mtdparts=orion_nand:"				\
++	"0xe0000@0x0(uboot),"				\
++	"0x20000@0xe0000(uboot_env),"			\
++	"0x100000@0x100000(second_stage_uboot),"	\
++	"-@0x200000(root)\0"
+ 
+ #define CONFIG_EXTRA_ENV_SETTINGS \
+ 	"console=console=ttyS0,115200\0"	\
+ 	"mtdids=nand0=orion_nand\0"		\
+ 	"mtdparts="CONFIG_MTDPARTS		\
+-	"kernel=/boot/uImage\0"			\
+-	"bootargs_root=noinitrd ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs\0"
++	"kernel=/boot/zImage\0"			\
++	"fdt=/boot/iconnect.dtb\0"		\
++	"bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0"
+ 
+ /*
+  * Ethernet driver configuration
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -164,6 +164,7 @@ Active  arm         arm926ejs      kirkw
+ Active  arm         arm926ejs      kirkwood    cloudengines    -                   pogo_e02                             -                                                                                                                                 Dave Purdy <david.c.purdy@gmail.com>
+ Active  arm         arm926ejs      kirkwood    d-link          -                   dns325                               -                                                                                                                                 Stefan Herbrechtsmeier <stefan@code.herbrechtsmeier.net>
+ Active  arm         arm926ejs      kirkwood    iomega          -                   iconnect                             -                                                                                                                                 Luka Perkov <luka@openwrt.org>
++Active  arm         arm926ejs      kirkwood    iomega          iconnect            iconnect_second_stage                iconnect:SECOND_STAGE                                                                                                             Luka Perkov <luka@openwrt.org>
+ Active  arm         arm926ejs      kirkwood    karo            tk71                tk71                                 -                                                                                                                                 -
+ Active  arm         arm926ejs      kirkwood    keymile         km_arm              km_kirkwood                          km_kirkwood:KM_KIRKWOOD                                                                                                           Valentin Longchamp <valentin.longchamp@keymile.com>
+ Active  arm         arm926ejs      kirkwood    keymile         km_arm              km_kirkwood_pci                      km_kirkwood:KM_KIRKWOOD_PCI                                                                                                       Valentin Longchamp <valentin.longchamp@keymile.com>
 

--- /dev/null
+++ b/package/boot/uboot-kirkwood/patches/130-ib62x0.patch
@@ -1,1 +1,32 @@
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -190,6 +190,7 @@ Active  arm         arm926ejs      kirkw
+ Active  arm         arm926ejs      kirkwood    Marvell         openrd              openrd_client                        openrd:BOARD_IS_OPENRD_CLIENT                                                                                                     -
+ Active  arm         arm926ejs      kirkwood    Marvell         openrd              openrd_ultimate                      openrd:BOARD_IS_OPENRD_ULTIMATE                                                                                                   -
+ Active  arm         arm926ejs      kirkwood    raidsonic       ib62x0              ib62x0                               -                                                                                                                                 Luka Perkov <luka@openwrt.org>
++Active  arm         arm926ejs      kirkwood    raidsonic       ib62x0              ib62x0_second_stage                  ib62x0:SECOND_STAGE                                                                                                               Luka Perkov <luka@openwrt.org>
+ Active  arm         arm926ejs      kirkwood    Seagate         -                   dockstar                             -                                                                                                                                 Eric Cooper <ecc@cmu.edu>
+ Active  arm         arm926ejs      kirkwood    Seagate         dockstar            dockstar_second_stage                dockstar:SECOND_STAGE                                                                                                             Luka Perkov <luka@openwrt.org>
+ Active  arm         arm926ejs      kirkwood    Seagate         -                   goflexhome                           -                                                                                                                                 Suriyan Ramasami <suriyan.r@gmail.com>
+--- a/include/configs/ib62x0.h
++++ b/include/configs/ib62x0.h
+@@ -91,7 +91,8 @@
+ 	"mtdparts=orion_nand:"						\
+ 	"0xe0000@0x0(uboot),"						\
+ 	"0x20000@0xe0000(uboot_env),"					\
+-	"-@0x100000(root)\0"
++	"0x100000@0x100000(second_stage_uboot),"			\
++	"-@0x200000(root)\0"
+ 
+ #define CONFIG_EXTRA_ENV_SETTINGS \
+ 	"console=console=ttyS0,115200\0"				\
+@@ -99,7 +100,7 @@
+ 	"mtdparts="CONFIG_MTDPARTS					\
+ 	"kernel=/boot/zImage\0"						\
+ 	"fdt=/boot/ib62x0.dtb\0"					\
+-	"bootargs_root=ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs rw\0"
++	"bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0"
+ 
+ /*
+  * Ethernet driver configuration
 

--- /dev/null
+++ b/package/boot/uboot-kirkwood/patches/200-openwrt-config.patch
@@ -1,1 +1,101 @@
+--- a/include/configs/dockstar.h
++++ b/include/configs/dockstar.h
+@@ -114,4 +114,6 @@
+ #define CONFIG_CMD_MTDPARTS
+ #define CONFIG_LZO
+ 
++#include "openwrt-kirkwood-common.h"
++
+ #endif /* _CONFIG_DOCKSTAR_H */
+--- a/include/configs/ib62x0.h
++++ b/include/configs/ib62x0.h
+@@ -144,4 +144,6 @@
+ #define CONFIG_MTD_PARTITIONS
+ #define CONFIG_CMD_MTDPARTS
+ 
++#include "openwrt-kirkwood-common.h"
++
+ #endif /* _CONFIG_IB62x0_H */
+--- a/include/configs/iconnect.h
++++ b/include/configs/iconnect.h
+@@ -117,4 +117,6 @@
+ #define CONFIG_MTD_PARTITIONS
+ #define CONFIG_CMD_MTDPARTS
+ 
++#include "openwrt-kirkwood-common.h"
++
+ #endif /* _CONFIG_ICONNECT_H */
+--- /dev/null
++++ b/include/configs/openwrt-kirkwood-common.h
+@@ -0,0 +1,52 @@
++/*
++ * Copyright (C) 2013 Luka Perkov <luka@openwrt.org>
++ *
++ * SPDX-License-Identifier:	GPL-2.0+
++ */
++
++#ifndef __OPENWRT_KIRKWOOD_COMMON_H
++#define __OPENWRT_KIRKWOOD_COMMON_H
++
++/* Commands */
++#define CONFIG_CMD_BOOTZ
++
++#if defined(CONFIG_CMD_NET)
++#define CONFIG_CMD_DHCP
++#define CONFIG_CMD_PING
++#endif
++
++/* Auto boot */
++#undef CONFIG_BOOTDELAY
++#define CONFIG_BOOTDELAY	3
++
++/* Ethernet */
++#if defined(CONFIG_CMD_NET)
++#define CONFIG_SERVERIP		192.168.1.2
++#define CONFIG_IPADDR		192.168.1.1
++#endif
++
++/* second stage loader */
++#if defined(CONFIG_SECOND_STAGE)
++#undef CONFIG_ENV_IS_IN_NAND
++#undef CONFIG_ENV_SECT_SIZE
++#define CONFIG_ENV_IS_NOWHERE
++#endif
++
++/* Flattened Device Tree */
++#define CONFIG_OF_LIBFDT
++
++/* Flattened uImage Tree */
++#define CONFIG_FIT
++#define CONFIG_FIT_VERBOSE
++
++/* Various */
++#define CONFIG_BZIP2
++#define CONFIG_LZMA
++#define CONFIG_LZO
++
++/* Unnecessary */
++#undef CONFIG_BOOTM_NETBSD
++#undef CONFIG_BOOTM_PLAN9
++#undef CONFIG_BOOTM_RTEMS
++
++#endif /* __OPENWRT_KIRKWOOD_COMMON_H */
+--- a/include/configs/pogo_e02.h
++++ b/include/configs/pogo_e02.h
+@@ -102,4 +102,6 @@
+ #define CONFIG_CMD_MTDPARTS
+ #define CONFIG_LZO
+ 
++#include "openwrt-kirkwood-common.h"
++
+ #endif /* _CONFIG_POGO_E02_H */
+--- a/include/configs/sheevaplug.h
++++ b/include/configs/sheevaplug.h
+@@ -95,4 +95,6 @@
+ #define CONFIG_CMD_MTDPARTS
+ #define CONFIG_LZO
+ 
++#include "openwrt-kirkwood-common.h"
++
+ #endif /* _CONFIG_SHEEVAPLUG_H */
 

--- a/package/boot/uboot-mxs/Makefile
+++ b/package/boot/uboot-mxs/Makefile
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=u-boot
-PKG_VERSION:=2013.07
+PKG_VERSION:=2013.10
 PKG_RELEASE:=1
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
@@ -27,7 +27,7 @@
 endef
 
 define uboot/mx23_olinuxino
-  TITLE:=U-Boot 2013.07 for the Olinuxino i.MX233
+  TITLE:=U-Boot 2013.10 for the Olinuxino i.MX233
 endef
 
 UBOOTS := \

--- a/package/boot/uboot-omap/Makefile
+++ b/package/boot/uboot-omap/Makefile
@@ -53,6 +53,7 @@
   TITLE:=$(2)
   URL:=http://www.denx.de/wiki/U-Boot
   VARIANT:=$(1)
+  HIDDEN:=1
 endef
 endef
 
@@ -70,7 +71,7 @@
 
 define Build/Configure
 	$(MAKE) -C $(PKG_BUILD_DIR) \
-		$(UBOOT_CONFIG)_config
+		USE_PRIVATE_LIBGCC=yes $(UBOOT_CONFIG)_config
 endef
 
 define Build/Compile
@@ -80,8 +81,8 @@
 
 define Package/uboot/install/default
 	$(INSTALL_DIR) $(BIN_DIR)/uboot-$(BOARD)-$(1)
-	$(CP) $(PKG_BUILD_DIR)/u-boot.img $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.img
-	$(CP) $(PKG_BUILD_DIR)/MLO $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-MLO
+	$(CP) $(PKG_BUILD_DIR)/u-boot.img $(BIN_DIR)/uboot-$(BOARD)-$(1)/u-boot.img
+	$(CP) $(PKG_BUILD_DIR)/MLO $(BIN_DIR)/uboot-$(BOARD)-$(1)/MLO
 endef
 
 define Package/uboot/install/template

--- /dev/null
+++ b/package/boot/uboot-omap/patches/001-switch_omap4_ext4.patch
@@ -1,1 +1,12 @@
+--- a/include/configs/omap4_common
++++ b/include/configs/omap4_common.h
+@@ -143,7 +143,7 @@
+ 	"vram=16M\0" \
+ 	"mmcdev=0\0" \
+ 	"mmcroot=/dev/mmcblk0p2 rw\0" \
+-	"mmcrootfstype=ext3 rootwait\0" \
++	"mmcrootfstype=ext4 rootwait\0" \
+ 	"mmcargs=setenv bootargs console=${console} " \
+ 		"vram=${vram} " \
+ 		"root=${mmcroot} " \
 

--- /dev/null
+++ b/package/boot/uboot-omap/patches/002-fix_jffs2.patch
@@ -1,1 +1,35 @@
+Building boards that have JFFS2 support enabled will fail when using
+U-Boot's builtin GCC library, for example like this:
 
+USE_PRIVATE_LIBGCC=yes ./MAKEALL omap3_evm
+...
+fs/jffs2/libjffs2.o: In function `jffs2_1pass_build_lists':
+fs/jffs2/jffs2_1pass.c:1441: undefined reference to `__aeabi_uldivmod'
+
+This is caused by a u64 / u32 division in jffs2_1pass.c; the problem
+can be avoided by using do_div() instead of plain division.
+
+Signed-off-by: Wolfgang Denk <wd@denx.de>
+Reported-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
+Cc: Chris Ruehl <chris.ruehl@gtsys.com.hk>
+
+---
+ fs/jffs2/jffs2_1pass.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
+index c856983..a7dbe79 100644
+--- a/fs/jffs2/jffs2_1pass.c
++++ b/fs/jffs2/jffs2_1pass.c
+@@ -1438,7 +1438,7 @@ jffs2_1pass_build_lists(struct part_info * part)
+ {
+ 	struct b_lists *pL;
+ 	struct jffs2_unknown_node *node;
+-	u32 nr_sectors = part->size/part->sector_size;
++	u32 nr_sectors = do_div(part->size, part->sector_size);
+ 	u32 i;
+ 	u32 counter4 = 0;
+ 	u32 counterF = 0;
+--
+1.8.3.1
+

--- /dev/null
+++ b/package/boot/uboot-sunxi/Makefile
@@ -1,1 +1,122 @@
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
 
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2013.10-rc2-sunxi
+PKG_RELEASE:=1
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://github.com/linux-sunxi/u-boot-sunxi
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=b322f6723d59b9bb88701991c7b8b15867bf3692
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+  TITLE:=
+  CONFIG:=
+  IMAGE:=
+endef
+
+define uboot/A10-OLinuXino-Lime
+  TITLE:=U-Boot 2013.10-rc2 for the A10 OLinuXino LIME
+endef
+
+define uboot/A13-OLinuXino
+  TITLE:=U-Boot 2013.10-rc2 for the A13 OlinuXino
+endef
+
+define uboot/A20-OLinuXino_MICRO
+  TITLE:=U-Boot 2013.10-rc2 for A20 OLinuXino MICRO
+endef
+
+define uboot/Cubieboard
+  TITLE:=U-Boot 2013.10-rc2 for Cubieboard
+endef
+
+define uboot/Cubieboard2
+  TITLE:=U-Boot 2013.10-rc2 for Cubieboard2
+endef
+
+define uboot/Cubietruck
+  TITLE:=U-Boot 2013.10-rc2 for Cubietruck
+endef
+
+define uboot/Hackberry
+  TITLE:=U-Boot 2013.10-rc2 for the Hackbeery
+endef
+
+define uboot/pcDuino
+  TITLE:=U-Boot 2013.10-rc2 for pcDuino
+endef  
+
+UBOOTS:=A10-OLinuXino-Lime A13-OLinuXino A20-OLinuXino_MICRO Cubieboard Cubieboard2 Cubietruck Hackberry pcDuino
+
+define Package/uboot/template
+define Package/uboot-sunxi-$(1)
+  SECTION:=boot
+  CATEGORY:=Boot Loaders
+  DEPENDS:=@TARGET_sunxi
+  TITLE:=$(2)
+  URL:=http://www.denx.de/wiki/U-Boot
+  VARIANT:=$(1)
+  MAINTAINER:=Zoltan HERPAI <wigyori@uid0.hu>
+endef
+endef
+
+define BuildUBootPackage
+	$(eval $(uboot/Default))
+	$(eval $(uboot/$(1)))
+	$(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Configure
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		USE_PRIVATE_LIBGCC=yes $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/default
+	$(INSTALL_DIR) $(BIN_DIR)/uboot-$(BOARD)-$(1)
+	$(CP) $(PKG_BUILD_DIR)/u-boot.bin \
+		$(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.bin
+	$(CP) $(PKG_BUILD_DIR)/spl/sunxi-spl.bin \
+		$(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-spl.bin
+	$(CP) $(PKG_BUILD_DIR)/u-boot-sunxi-with-spl.bin \
+		$(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot-with-spl.bin
+	$(CP) uEnv.txt \
+		$(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-uEnv.txt
+endef
+
+define Package/uboot/install/template
+define Package/uboot-sunxi-$(1)/install
+	$(call Package/uboot/install/default,$(2))
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+	$(eval $(call Package/uboot/install/template,$(u),$(u))) \
+)
+
+$(foreach u,$(UBOOTS), \
+	$(eval $(call BuildUBootPackage,$(u))) \
+	$(eval $(call BuildPackage,uboot-sunxi-$(u))) \
+)
+

--- /dev/null
+++ b/package/boot/uboot-sunxi/patches/001-a10_olinuxino_lime_support.patch
@@ -1,1 +1,62 @@
+diff --git a/board/sunxi/Makefile b/board/sunxi/Makefile
+index 4c85fe9..61dc9ab 100644
+--- a/board/sunxi/Makefile
++++ b/board/sunxi/Makefile
+@@ -31,6 +31,7 @@ LIB	:= $(obj)lib$(BOARD).o
+ 
+ COBJS-y	:= board.o
+ COBJS-$(CONFIG_A10_MID_1GB)	+= dram_sun4i_360_1024_iow16.o
++COBJS-$(CONFIG_A10_OLINUXINO_L)	+= dram_a10_olinuxino_l.o
+ COBJS-$(CONFIG_A10S_OLINUXINO_M)	+= dram_a10s_olinuxino_m.o
+ COBJS-$(CONFIG_A13_OLINUXINO)	+= dram_a13_olinuxino.o
+ COBJS-$(CONFIG_A13_OLINUXINOM)	+= dram_a13_oli_micro.o
+diff --git a/board/sunxi/dram_a10_olinuxino_l.c b/board/sunxi/dram_a10_olinuxino_l.c
+new file mode 100644
+index 0000000..31b6542
+--- /dev/null
++++ b/board/sunxi/dram_a10_olinuxino_l.c
+@@ -0,0 +1,31 @@
++/* this file is generated, don't edit it yourself */
++
++#include <common.h>
++#include <asm/arch/dram.h>
++
++static struct dram_para dram_para = {
++       .clock = 480,
++       .type = 3,
++       .rank_num = 1,
++       .density = 4096,
++       .io_width = 16,
++       .bus_width = 16,
++       .cas = 9,
++       .zq = 123,
++       .odt_en = 0,
++       .size = 512,
++       .tpr0 = 0x42d899b7,
++       .tpr1 = 0xa090,
++       .tpr2 = 0x22a00,
++       .tpr3 = 0,
++       .tpr4 = 0,
++       .tpr5 = 0,
++       .emr1 = 0x4,
++       .emr2 = 0x10,
++       .emr3 = 0,
++};
++
++unsigned long sunxi_dram_init(void)
++{
++       return dramc_init(&dram_para);
++}
+diff --git a/boards.cfg b/boards.cfg
+index 24f6a67..94a2c82 100644
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -404,6 +404,7 @@ Active  arm         armv7          sunxi       -               sunxi
+ Active  arm         armv7          sunxi       -               sunxi               uhost_u1a                            sun4i:UHOST_U1A,SPL,STATUSLED=34                                                                                                  -
+ Active  arm         armv7          sunxi       -               sunxi               wobo-i5                              sun5i:WOBO_I5,SPL,STATUSLED=34                                                                                                    -
+ Active  arm         armv7          sunxi       -               sunxi               xzpad700                             sun5i:XZPAD700,SPL                                                                                                                -
++Active  arm         armv7          sunxi       -               sunxi               A10-OLinuXino-Lime			 sun4i:A10_OLINUXINO_L,SPL,SUNXI_EMAC                                                                                             -
+ Active  arm         armv7          u8500       st-ericsson     snowball            snowball                             -                                                                                                                                 Mathieu Poirier <mathieu.poirier@linaro.org>
+ Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                           -                                                                                                                                 -
+ Active  arm         armv7          vf610       freescale       vf610twr            vf610twr                             vf610twr:IMX_CONFIG=board/freescale/vf610twr/imximage.cfg                                                                         Alison Wang <b18965@freescale.com>
 

--- /dev/null
+++ b/package/boot/uboot-sunxi/patches/002-sun5i-give-pll6-a-sane-value.patch
@@ -1,1 +1,40 @@
+From 75ec90fda763b491e5169dcb6dce8abe3856d946 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Sat, 14 Dec 2013 20:58:57 +0100
+Subject: [PATCH] sun5i: Give PLL6 a sane initial value
 
+The upstream kernel does not override PLL values as set by power-on-reset
+and/or the bootloader if it can avoid doing so.
+
+The power-on-reset value for PLL6 is 2400MHz, which does not actually work,
+the kernel does not know this and 2400 / 48 is 50 MHz, so the kernel happily
+tries to use it as is for mmc.
+
+Set PLL6 to a working frequency so that the kernel can use it. This fixes
+mmc in the upstream kernel not working on sun5i.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+---
+ arch/arm/cpu/armv7/sunxi/clock.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/arch/arm/cpu/armv7/sunxi/clock.c b/arch/arm/cpu/armv7/sunxi/clock.c
+index 57b136d..b9dd608 100644
+--- a/arch/arm/cpu/armv7/sunxi/clock.c
++++ b/arch/arm/cpu/armv7/sunxi/clock.c
+@@ -43,6 +43,11 @@ static void clock_init_safe(void)
+ 	sdelay(200);
+ 	writel(AXI_DIV_1 << 0 | AHB_DIV_2 << 4 | APB0_DIV_1 << 8 |
+ 	       CPU_CLK_SRC_PLL1 << 16, &ccm->cpu_ahb_apb0_cfg);
++#ifdef CONFIG_SUN5I
++	/* Power on reset default for PLL6 is 2400 MHz, which is faster then
++	 * it can reliable do :|  Set it to a 600 MHz instead. */
++	writel(0x21009900, &ccm->pll6_cfg);
++#endif
+ #ifdef CONFIG_SUN7I
+ 	writel(0x1 << 6 | readl(&ccm->ahb_gate0), &ccm->ahb_gate0);
+ 	writel(0x1 << 31 | readl(&ccm->pll6_cfg), &ccm->pll6_cfg);
+-- 
+1.8.5.1
+
+

--- /dev/null
+++ b/package/boot/uboot-sunxi/patches/003-sun5i-tweak-pll6-init-value.patch
@@ -1,1 +1,34 @@
+From 8f70a049daa30be894158411439a36f920f0d11c Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Wed, 15 Jan 2014 20:13:04 +0100
+Subject: [PATCH] sun5i: Tweak pll6 init value
 
+There are multiple ways to get 600 MHz from PLL6, the sun5i ccmu is very
+similar to the sun4i and sun7i ccmu.
+
+This commit changes the PLL6 initialization we do for sun5i to make the PLL6
+reg value match that of sun4i and sun7i. This also makes it closer to the
+sun5i power on default, as we are now only changing the K-factor from 3 to 1.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+---
+ arch/arm/cpu/armv7/sunxi/clock.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm/cpu/armv7/sunxi/clock.c b/arch/arm/cpu/armv7/sunxi/clock.c
+index b9dd608..54b8753 100644
+--- a/arch/arm/cpu/armv7/sunxi/clock.c
++++ b/arch/arm/cpu/armv7/sunxi/clock.c
+@@ -46,7 +46,7 @@ static void clock_init_safe(void)
+ #ifdef CONFIG_SUN5I
+ 	/* Power on reset default for PLL6 is 2400 MHz, which is faster then
+ 	 * it can reliable do :|  Set it to a 600 MHz instead. */
+-	writel(0x21009900, &ccm->pll6_cfg);
++	writel(0x21009911, &ccm->pll6_cfg);
+ #endif
+ #ifdef CONFIG_SUN7I
+ 	writel(0x1 << 6 | readl(&ccm->ahb_gate0), &ccm->ahb_gate0);
+-- 
+1.8.5.1
+
+

--- /dev/null
+++ b/package/boot/uboot-sunxi/patches/004-a10-lime-fixup.patch
@@ -1,1 +1,95 @@
+From eccc92de2d133957fe2c126f18a5a5faef0bb93b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Thu, 9 Jan 2014 23:26:05 +0100
+Subject: [PATCH] sunxi: A10-OLinuXino-Lime support fixup
 
+Fix:
+-code indentation
+-dram timings, the used cas and tpr0 - tpr2 were typical sun5i / sun7i
+ settings, while they should be sun4i settings
+-Properly sort boards.cfg entry
+-Add status led support
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+---
+ board/sunxi/dram_a10_olinuxino_l.c | 40 +++++++++++++++++++-------------------
+ boards.cfg                         |  2 +-
+ 2 files changed, 21 insertions(+), 21 deletions(-)
+
+diff --git a/board/sunxi/dram_a10_olinuxino_l.c b/board/sunxi/dram_a10_olinuxino_l.c
+index 31b6542..24a1bd9 100644
+--- a/board/sunxi/dram_a10_olinuxino_l.c
++++ b/board/sunxi/dram_a10_olinuxino_l.c
+@@ -4,28 +4,28 @@
+ #include <asm/arch/dram.h>
+ 
+ static struct dram_para dram_para = {
+-       .clock = 480,
+-       .type = 3,
+-       .rank_num = 1,
+-       .density = 4096,
+-       .io_width = 16,
+-       .bus_width = 16,
+-       .cas = 9,
+-       .zq = 123,
+-       .odt_en = 0,
+-       .size = 512,
+-       .tpr0 = 0x42d899b7,
+-       .tpr1 = 0xa090,
+-       .tpr2 = 0x22a00,
+-       .tpr3 = 0,
+-       .tpr4 = 0,
+-       .tpr5 = 0,
+-       .emr1 = 0x4,
+-       .emr2 = 0x10,
+-       .emr3 = 0,
++	.clock = 480,
++	.type = 3,
++	.rank_num = 1,
++	.density = 4096,
++	.io_width = 16,
++	.bus_width = 16,
++	.cas = 6,
++	.zq = 123,
++	.odt_en = 0,
++	.size = 512,
++	.tpr0 = 0x30926692,
++	.tpr1 = 0x1090,
++	.tpr2 = 0x1a0c8,
++	.tpr3 = 0,
++	.tpr4 = 0,
++	.tpr5 = 0,
++	.emr1 = 0x4,
++	.emr2 = 0,
++	.emr3 = 0,
+ };
+ 
+ unsigned long sunxi_dram_init(void)
+ {
+-       return dramc_init(&dram_para);
++	return dramc_init(&dram_para);
+ }
+diff --git a/boards.cfg b/boards.cfg
+index eda05de..dfeb07a 100644
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -345,6 +345,7 @@ Active  arm         armv7          s5pc1xx     samsung         goni
+ Active  arm         armv7          s5pc1xx     samsung         smdkc100            smdkc100                             -                                                                                                                                 Minkyu Kang <mk7.kang@samsung.com>
+ Active  arm         armv7          socfpga     altera          socfpga             socfpga_cyclone5                     -                                                                                                                                 -
+ Active  arm         armv7          sunxi       -               sunxi               A10_MID_1GB                          sun4i:A10_MID_1GB,SPL                                                                                                             -
++Active  arm         armv7          sunxi       -               sunxi               A10-OLinuXino-Lime                   sun4i:A10_OLINUXINO_L,STATUSLED=226,SPL,SUNXI_EMAC                                                                                -
+ Active  arm         armv7          sunxi       -               sunxi               A10s-OLinuXino-M                     sun5i:A10S_OLINUXINO_M,STATUSLED=131,AXP152_POWER,CONS_INDEX=1,SPL,SUNXI_EMAC                                                     -
+ Active  arm         armv7          sunxi       -               sunxi               A10s-OLinuXino-M_FEL                 sun5i:A10S_OLINUXINO_M,STATUSLED=131,AXP152_POWER,CONS_INDEX=1,SPL_FEL,SUNXI_EMAC                                                 -
+ Active  arm         armv7          sunxi       -               sunxi               A13-OLinuXino                        sun5i:A13_OLINUXINO,SPL,STATUSLED=201,CONS_INDEX=2                                                                                -
+@@ -415,7 +416,6 @@ Active  arm         armv7          sunxi       -               sunxi
+ Active  arm         armv7          sunxi       -               sunxi               uhost_u1a                            sun4i:UHOST_U1A,SPL,STATUSLED=34                                                                                                  -
+ Active  arm         armv7          sunxi       -               sunxi               wobo-i5                              sun5i:WOBO_I5,SPL,STATUSLED=34                                                                                                    -
+ Active  arm         armv7          sunxi       -               sunxi               xzpad700                             sun5i:XZPAD700,SPL                                                                                                                -
+-Active  arm         armv7          sunxi       -               sunxi               A10-OLinuXino-Lime			 sun4i:A10_OLINUXINO_L,SPL,SUNXI_EMAC                                                                                             -
+ Active  arm         armv7          u8500       st-ericsson     snowball            snowball                             -                                                                                                                                 Mathieu Poirier <mathieu.poirier@linaro.org>
+ Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                           -                                                                                                                                 -
+ Active  arm         armv7          vf610       freescale       vf610twr            vf610twr                             vf610twr:IMX_CONFIG=board/freescale/vf610twr/imximage.cfg                                                                         Alison Wang <b18965@freescale.com>
+-- 
+1.8.5.1
+
+

--- /dev/null
+++ b/package/boot/uboot-sunxi/uEnv.txt
@@ -1,1 +1,6 @@
+fdt_high=ffffffff
+loadkernel=fatload mmc 0 0x46000000 uImage
+loaddtb=fatload mmc 0 0x49000000 dtb
+bootargs=console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootwait
+uenvcmd=run loadkernel && run loaddtb && bootm 0x46000000 - 0x49000000
 

--- a/package/devel/binutils/Makefile
+++ b/package/devel/binutils/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2011 OpenWrt.org
+# Copyright (C) 2006-2013 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -10,10 +10,19 @@
 PKG_NAME:=binutils
 PKG_VERSION:=$(strip $(subst ",, $(CONFIG_BINUTILS_VERSION)))
 #"))
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 
-PKG_SOURCE_URL:=@GNU/binutils
-PKG_SOURCE:=binutils-$(PKG_VERSION).tar.bz2
+ifeq ($(findstring linaro, $(CONFIG_BINUTILS_VERSION)),linaro)
+  PKG_SOURCE_URL:=https://releases.linaro.org/13.12/components/toolchain/binutils-linaro/
+  PKG_REV:=2.24-2013.12
+  PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.xz
+  BINUTILS_DIR:=$(PKG_NAME)-linaro-$(PKG_REV)
+  PKG_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(BINUTILS_DIR)
+  PKG_VERSION:=$(PKG_REV)
+else
+  PKG_SOURCE_URL:=@GNU/binutils
+  PKG_SOURCE:=binutils-$(PKG_VERSION).tar.bz2
+endif
 PKG_MD5SUM:=
 
 PATCH_DIR:=$(TOPDIR)/toolchain/binutils/patches/$(PKG_VERSION)

--- a/package/kernel/acx-mac80211/Makefile
+++ b/package/kernel/acx-mac80211/Makefile
@@ -190,7 +190,7 @@
 		CROSS_COMPILE="$(TARGET_CROSS)" \
 		SUBDIRS="$(PKG_BUILD_DIR)" \
 		$(PKG_EXTRA_KCONFIG) \
-		EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS) -DCONFIG_ACX_MAC80211_VERSION=\"KERNEL_VERSION(3,10,0)\"" \
+		EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS) -DCONFIG_ACX_MAC80211_VERSION=\"KERNEL_VERSION(3,14,0)\"" \
 		LINUXINCLUDE="-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi -I$(STAGING_DIR)/usr/include/mac80211-backport \
 			-I$(STAGING_DIR)/usr/include/mac80211/uapi -I$(STAGING_DIR)/usr/include/mac80211 \
 			-I$(LINUX_DIR)/include -I$(LINUX_DIR)/include/$(LINUX_UAPI_DIR) \

--- a/package/kernel/acx-mac80211/patches/001-pci-mem-Fix-3.8-build.patch
+++ b/package/kernel/acx-mac80211/patches/001-pci-mem-Fix-3.8-build.patch
@@ -12,11 +12,9 @@
  pci.c | 26 +++++++++++++++++++++++++-
  2 files changed, 37 insertions(+), 2 deletions(-)
 
-diff --git a/mem.c b/mem.c
-index 87e01f1..f1ff7e2 100644
 --- a/mem.c
 +++ b/mem.c
-@@ -2216,7 +2216,11 @@ int acx100mem_ioctl_set_phy_amp_bias(struct ieee80211_hw *hw,
+@@ -2216,7 +2216,11 @@ int acx100mem_ioctl_set_phy_amp_bias(str
   * ==================================================
   */
  
@@ -28,7 +26,7 @@
  {
  	acx_device_t *adev = NULL;
  	const char *chip_name;
-@@ -2392,7 +2396,11 @@ static int __devinit acxmem_probe(struct platform_device *pdev)
+@@ -2392,7 +2396,11 @@ static int __devinit acxmem_probe(struct
   * pdev - ptr to PCI device structure containing info about pci
   * configuration
   */
@@ -40,7 +38,7 @@
  {
  	struct ieee80211_hw *hw = (struct ieee80211_hw *)
  		platform_get_drvdata(pdev);
-@@ -2594,8 +2602,11 @@ static struct platform_driver acxmem_driver = {
+@@ -2594,8 +2602,11 @@ static struct platform_driver acxmem_dri
  		.name = "acx-mem",
  	},
  	.probe = acxmem_probe,
@@ -53,11 +51,9 @@
  #ifdef CONFIG_PM
  	.suspend = acxmem_e_suspend,
  	.resume = acxmem_e_resume
-diff --git a/pci.c b/pci.c
-index 1da31d1..ae07f5a 100644
 --- a/pci.c
 +++ b/pci.c
-@@ -1039,7 +1039,11 @@ int acx100pci_ioctl_set_phy_amp_bias(struct net_device *ndev,
+@@ -1039,7 +1039,11 @@ int acx100pci_ioctl_set_phy_amp_bias(str
   * id	- ptr to the device id entry that matched this device
   */
  #ifdef CONFIG_PCI
@@ -69,7 +65,7 @@
  				const struct pci_device_id *id)
  {
  	unsigned long mem_region1 = 0;
-@@ -1292,7 +1296,11 @@ static int __devinit acxpci_probe(struct pci_dev *pdev,
+@@ -1292,7 +1296,11 @@ static int __devinit acxpci_probe(struct
   *
   * pdev - ptr to PCI device structure containing info about pci configuration
   */
@@ -81,7 +77,7 @@
  {
  	struct ieee80211_hw *hw
  		= (struct ieee80211_hw *) pci_get_drvdata(pdev);
-@@ -1505,7 +1513,11 @@ static struct pci_driver acxpci_driver = {
+@@ -1505,7 +1513,11 @@ static struct pci_driver acxpci_driver =
  	.name		= "acx_pci",
  	.id_table	= acxpci_id_tbl,
  	.probe		= acxpci_probe,
@@ -93,7 +89,7 @@
  #ifdef CONFIG_PM
  	.suspend	= acxpci_e_suspend,
  	.resume		= acxpci_e_resume
-@@ -1603,8 +1615,12 @@ static struct vlynq_device_id acx_vlynq_id[] = {
+@@ -1603,8 +1615,12 @@ static struct vlynq_device_id acx_vlynq_
  };
  
  
@@ -107,7 +103,7 @@
  {
  	int result = -EIO, i;
  	u32 addr;
-@@ -1785,7 +1801,11 @@ static __devinit int vlynq_probe(struct vlynq_device *vdev,
+@@ -1785,7 +1801,11 @@ static __devinit int vlynq_probe(struct
  	return result;
  }
  
@@ -119,7 +115,7 @@
  {
  	struct ieee80211_hw *hw = vlynq_get_drvdata(vdev);
  	acx_device_t *adev = hw2adev(hw);
-@@ -1851,7 +1871,11 @@ static struct vlynq_driver acxvlynq_driver = {
+@@ -1851,7 +1871,11 @@ static struct vlynq_driver acxvlynq_driv
  	.name = "acx_vlynq",
  	.id_table = acx_vlynq_id,
  	.probe = vlynq_probe,
@@ -131,7 +127,4 @@
  };
  #endif /* CONFIG_VLYNQ */
  
--- 
-1.8.4.rc1
 
-

--- a/package/kernel/acx-mac80211/patches/003-Fix-3.10-build.patch
+++ b/package/kernel/acx-mac80211/patches/003-Fix-3.10-build.patch
@@ -9,11 +9,9 @@
  main.c | 7 +++++++
  1 file changed, 7 insertions(+)
 
-diff --git a/main.c b/main.c
-index 3af6cd0..841592f 100644
 --- a/main.c
 +++ b/main.c
-@@ -682,10 +682,17 @@ int acx_op_config(struct ieee80211_hw *hw, u32 changed)
+@@ -682,10 +682,17 @@ int acx_op_config(struct ieee80211_hw *h
  
  	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
  		logf1(L_DEBUG, "IEEE80211_CONF_CHANGE_CHANNEL,"
@@ -31,7 +29,4 @@
  
  		changed_not_done &= ~IEEE80211_CONF_CHANGE_CHANNEL;
  	}
--- 
-1.8.4.rc1
 
-

--- /dev/null
+++ b/package/kernel/acx-mac80211/patches/004-Fix-3.14-build.patch
@@ -1,1 +1,23 @@
+From d17fcac710e629463591f6bd09d76b66ec591583 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Wed, 5 Feb 2014 20:57:07 +0100
+Subject: [PATCH] Fix 3.14 build
 
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ main.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/main.c
++++ b/main.c
+@@ -500,7 +500,9 @@ int acx_init_ieee80211(acx_device_t *ade
+ 	hw->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS;
+ 	hw->queues = 1;
+ 	hw->wiphy->max_scan_ssids = 1;
++#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(3, 14, 0)
+ 	hw->channel_change_time = 10000;
++#endif
+ 
+ 	/* OW TODO Check if RTS/CTS threshold can be included here */
+ 
+

--- a/package/kernel/acx-mac80211/patches/200-initial-macaddr.patch
+++ b/package/kernel/acx-mac80211/patches/200-initial-macaddr.patch
@@ -1,7 +1,7 @@
 --- a/cardsetting.c
 +++ b/cardsetting.c
-@@ -710,10 +710,25 @@ static int acx1xx_get_station_id(acx_dev
- 	u8 *stationID = adev->ie_cmd_buf;;
+@@ -715,10 +715,25 @@ int acx1xx_get_station_id(acx_device_t *
+ 	u8 *stationID = adev->ie_cmd_buf;
  	const u8 *paddr;
  	int i, res;
 +	const char *prom_addr;

--- a/package/kernel/broadcom-diag/src/diag.c
+++ b/package/kernel/broadcom-diag/src/diag.c
@@ -75,55 +75,18 @@
 	WAP54GV3,
 	WRT54GV1,
 	WRT54G,
-	WRTSL54GS,
 	WRT54G3G,
-	WRT54G3GV2_VF,
-	WRT150NV1,
-	WRT150NV11,
-	WRT160NV1,
-	WRT160NV3,
-	WRT300NV11,
-	WRT310NV1,
 	WRT350N,
 	WRT600N,
 	WRT600NV11,
-	WRT610N,
-	WRT610NV2,
-	E1000V1,
-	E1000V21,
-	E2000V1,
-	E3000V1,
-	E3200V1,
-	E4200V1,
 
 	/* ASUS */
-	WLHDD,
-	WL300G,
-	WL320GE,
-	WL330GE,
 	WL500G,
-	WL500GD,
-	WL500GP,
-	WL500GPV2,
-	WL500W,
-	WL520GC,
-	WL520GU,
 	ASUS_4702,
-	WL700GE,
-	RTN12,
-	RTN16,
-	RTN66U,
 
 	/* Buffalo */
 	WBR2_G54,
-	WHR_G54S,
-	WHR_HP_G54,
-	WHR_G125,
-	WHR2_A54G54,
 	WLA2_G54L,
-	WZR_G300N,
-	WZR_RS_G54,
-	WZR_RS_G54HP,
 	BUFFALO_UNKNOWN_4710,
 
 	/* Siemens */
@@ -134,25 +97,14 @@
 	USR5461,
 
 	/* Dell */
-	TM2300,
 	TM2300V2,
 
 	/* Motorola */
-	WE800G,
 	WR850GV1,
-	WR850GV2V3,
-	WR850GP,
-
-	/* Belkin */
-	BELKIN_UNKNOWN,
-	BELKIN_F7D330X, /* covers F7D7302,F7D3302,F7D3301, and F7D7301 */
-	BELKIN_F7D4301,
 
 	/* Netgear */
 	WGT634U,
 	WNR834BV1,
-	WNR834BV2,
-	WNDR3400V1,
 	WNDR3700V3,
 
 	/* Trendware */
@@ -162,9 +114,7 @@
 	STI_NAS,
 
 	/* D-Link */
-	DIR130,
 	DIR320,
-	DIR330,
 	DWL3150,
 
 	/* Sitecom */
@@ -186,7 +136,6 @@
 	PS1208MFG,
 
 	/* Huawei */
-	HUAWEI_E970,
 };
 
 static void __init bcm4780_init(void) {
@@ -218,15 +167,6 @@
 		bcm4780_init();
 }
 
-static void __init bcm57xx_init(void) {
-	int pin = 1 << 2;
-
-	/* FIXME: switch comes up, but port mappings/vlans not right */
-	bcm47xx_gpio_outen(pin, pin);
-	bcm47xx_gpio_control(pin, 0);
-	bcm47xx_gpio_out(pin, pin);
-}
-
 static struct platform_t __initdata platforms[] = {
 	/* Linksys */
 	[WAP54GV1] = {
@@ -285,19 +225,6 @@
 			{ .name = "wlan",	.gpio = 1 << 0, .polarity = REVERSE },
 		},
 	},
-	[WRTSL54GS] = {
-		.name		= "Linksys WRTSL54GS",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "ses",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "dmz",	.gpio = 1 << 0, .polarity = REVERSE },
-			{ .name = "ses_white",	.gpio = 1 << 5, .polarity = REVERSE },
-			{ .name = "ses_orange",	.gpio = 1 << 7, .polarity = REVERSE },
-		},
-	},
 	[WRT54G3G] = {
 		.name		= "Linksys WRT54G3G",
 		.buttons	= {
@@ -312,91 +239,6 @@
 			{ .name = "3g_blink",	.gpio = 1 << 5, .polarity = NORMAL },
 		},
 	},
-	[WRT54G3GV2_VF] = {
-		.name		= "Linksys WRT54G3GV2-VF",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "3g",		.gpio = 1 << 5 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "3g_green",	.gpio = 1 << 2, .polarity = NORMAL },
-			{ .name = "3g_blue",	.gpio = 1 << 3, .polarity = NORMAL },
-		},
-	},
-	[WRT150NV1] = {
-		.name		= "Linksys WRT150N V1",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "ses",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "ses_green",	.gpio = 1 << 5, .polarity = REVERSE },
-			{ .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE },
-		},
-	},
-	[WRT150NV11] = {
-		.name		= "Linksys WRT150N V1.1",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "ses",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "ses_green",	.gpio = 1 << 5, .polarity = REVERSE },
-			{ .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE },
-		},
-	},
-	[WRT160NV1] = {
-		.name		= "Linksys WRT160N v1.x",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "ses",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "ses_blue",	.gpio = 1 << 5, .polarity = REVERSE },
-			{ .name = "ses_orange", .gpio = 1 << 3, .polarity = REVERSE },
-		},
-	},
-	[WRT160NV3] = {
-		.name		= "Linksys WRT160N V3",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "ses",	.gpio = 1 << 5 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "ses_blue",	.gpio = 1 << 4, .polarity = REVERSE },
-			{ .name = "ses_orange", .gpio = 1 << 2, .polarity = REVERSE },
-		},
-	},
-	[WRT300NV11] = {
-		.name           = "Linksys WRT300N V1.1",
-		.buttons        = {
-			{ .name = "reset",     .gpio = 1 << 6 }, // "Reset" on back panel
-			{ .name = "ses",       .gpio = 1 << 4 }, // "Reserved" on top panel
-		},
-		.leds           = {
-			{ .name = "power",     .gpio = 1 << 1, .polarity = NORMAL  }, // "Power"
-			{ .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE }, // "Security" Amber
-			{ .name = "ses_green", .gpio = 1 << 5, .polarity = REVERSE }, // "Security" Green
-		},
-		.platform_init = bcm57xx_init,
-	},
-	[WRT310NV1] = {
-		.name		= "Linksys WRT310N V1",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 }, // "Reset" on back panel
-			{ .name = "ses",	.gpio = 1 << 8 }, // "Reserved" on top panel
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL }, // Power LED
-			{ .name = "ses_amber",	.gpio = 1 << 3, .polarity = REVERSE }, // "Security" Amber
-			{ .name = "ses_blue",	.gpio = 1 << 9, .polarity = REVERSE }, // "Security" Blue
-		},
-	},
 	[WRT350N] = {
 		.name		= "Linksys WRT350N",
 		.buttons	= {
@@ -410,7 +252,6 @@
 			{ .name = "usb_blink",	.gpio = 1 << 10, .polarity = REVERSE },
 			{ .name = "usb",	.gpio = 1 << 11, .polarity = REVERSE },
 		},
-		.platform_init = bcm57xx_init,
 	},
 	[WRT600N] = {
 		.name           = "Linksys WRT600N",
@@ -426,7 +267,6 @@
 			{ .name = "wl1_ses_amber",      .gpio = 1 << 10, .polarity = REVERSE }, // 5.6Ghz LED Amber
 			{ .name = "wl1_ses_green",      .gpio = 1 << 11, .polarity = REVERSE }, // 5.6Ghz LED Green
 		},
-		.platform_init = bcm57xx_init,
 	},
 	[WRT600NV11] = {
 		.name           = "Linksys WRT600N V1.1",
@@ -442,156 +282,8 @@
 			{ .name = "wl1_ses_amber",      .gpio = 1 << 10, .polarity = REVERSE }, // 5.6Ghz LED Amber
 			{ .name = "wl1_ses_green",      .gpio = 1 << 11, .polarity = REVERSE }, // 5.6Ghz LED Green
 		},
-		.platform_init = bcm57xx_init,
-	},
-	[WRT610N] = {
-		.name           = "Linksys WRT610N",
-		.buttons        = {
-			{ .name = "reset",      .gpio = 1 << 6 },
-			{ .name = "ses",        .gpio = 1 << 8 },
-		},
-		.leds           = {
-			{ .name = "power",      .gpio = 1 << 1,  .polarity = NORMAL }, // Power LED
-			{ .name = "usb",        .gpio = 1 << 0,  .polarity = REVERSE }, // USB LED
-			{ .name = "ses_amber",  .gpio = 1 << 3,  .polarity = REVERSE }, // WiFi protected setup LED amber
-			{ .name = "ses_blue",   .gpio = 1 << 9,  .polarity = REVERSE }, // WiFi protected setup LED blue
-		},
-	},
-	[WRT610NV2] = {
-		.name		= "Linksys WRT610N V2",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "ses",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 5,	.polarity = NORMAL },	// Power LED
-			{ .name = "usb",	.gpio = 1 << 7,	.polarity = NORMAL },	// USB LED
-			{ .name = "ses_amber",	.gpio = 1 << 0,	.polarity = REVERSE },	// WiFi protected setup LED amber
-			{ .name = "ses_blue",	.gpio = 1 << 3,	.polarity = REVERSE },	// WiFi protected setup LED blue
-			{ .name = "wlan",	.gpio = 1 << 1,	.polarity = NORMAL },	// Wireless LED
-		},
-	},
-	/* same hardware as WRT160NV3 and Cisco Valet M10V1, but different board detection, combine? */
-	[E1000V1] = {
-		.name           = "Linksys E1000 V1",
-		.buttons        = {
-			{ .name = "reset",      .gpio = 1 << 6 },
-			{ .name = "wps",        .gpio = 1 << 5 }, /* nvram get gpio5=wps_button */
-		},
-		.leds           = {
-			/** turns on leds for all ethernet ports (wan too)
-			 *  this also disconnects some, or maybe all, ethernet ports 
-			 *  1: leds work normally
-			 *  0: all lit all the time */
-			/* nvram get gpio3=robo_reset */
-			{ .name = "wlan",       .gpio = 1 << 0, .polarity = NORMAL },
-			{ .name = "power",      .gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "ses_blue",   .gpio = 1 << 4, .polarity = REVERSE }, /* nvram get gpio4=wps_led */
-			{ .name = "ses_orange", .gpio = 1 << 2, .polarity = REVERSE }, /* nvram get gpio2=wps_status_led */
-		},
-	},
-	[E1000V21] = {
-		.name		= "Linksys E1000 V2.1",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 10 }, /* nvram get reset_gpio=10 */
-			{ .name = "wps",	.gpio = 1 << 9 }, /* nvram get gpio9=wps_button */
-		},
-		.leds		= {
-			{ .name = "power",      .gpio = 1 << 6, .polarity = REVERSE },
-			{ .name = "wlan",       .gpio = 1 << 5, .polarity = NORMAL },
-			{ .name = "ses_blue",	.gpio = 1 << 8, .polarity = NORMAL }, /* nvram get gpio8=wps_led */
-			{ .name = "ses_orange",	.gpio = 1 << 7, .polarity = NORMAL }, /* nvram get gpio7=wps_status_led */
-		},
-	},
-	[E2000V1] = {
-		.name		= "Linksys E2000 V1",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 8 },
-			{ .name = "ses",	.gpio = 1 << 5 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 2, .polarity = NORMAL },
-			{ .name = "ses_amber",	.gpio = 1 << 4, .polarity = REVERSE },
-			{ .name = "ses_blue",	.gpio = 1 << 3, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 1, .polarity = NORMAL },
-		},
-	},
-	[E3000V1] = {
-		.name		= "Linksys E3000 V1",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "ses",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 5,	.polarity = NORMAL },	// Power LED
-			{ .name = "usb",	.gpio = 1 << 7,	.polarity = NORMAL },	// USB LED
-			{ .name = "ses_amber",	.gpio = 1 << 0,	.polarity = REVERSE },	// WiFi protected setup LED amber
-			{ .name = "ses_blue",	.gpio = 1 << 3,	.polarity = REVERSE },	// WiFi protected setup LED blue
-			{ .name = "wlan",	.gpio = 1 << 1,	.polarity = NORMAL },	// Wireless LED
-		},
-	},
-	[E3200V1] = {
-		.name		= "Linksys E3200 V1",
-		.buttons	= {
-			/* { .name = "switch",	.gpio = 1 << 4 },*/	/* nvram get gpio4=robo_reset */
-			{ .name = "reset",	.gpio = 1 << 5 },	/* nvram get reset_gpio=5 */
-			{ .name = "wps",	.gpio = 1 << 8 },	/* nvram get gpio8=wps_button */
-			/* { .name = "wombo",	.gpio = 1 << 23 },*/	/* nvram get gpio23=wombo_reset - wireless on motherboard */
-		},
-		.leds	= {
-			{ .name = "power",	.gpio = 1 << 3, .polarity = REVERSE },	/* Power LED */
-		},
-	},
-	[E4200V1] = {
-		.name		= "Linksys E4200 V1",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "wps",	.gpio = 1 << 4 },
-		},
-		.leds	= {
-			{ .name = "power",	.gpio = 1 << 5, .polarity = REVERSE },
-		},
 	},
 	/* Asus */
-	[WLHDD] = {
-		.name		= "ASUS WL-HDD",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
-			{ .name = "usb",	.gpio = 1 << 2, .polarity = REVERSE },
-		},
-	},
-	[WL300G] = {
-		.name		= "ASUS WL-300g",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
-		},
-	},
-	[WL320GE] = {
-		.name		= "ASUS WL-320gE/WL-320gP",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-		},
-		.leds		= {
-			{ .name = "wlan",	.gpio = 1 << 0, .polarity = REVERSE },
-			{ .name = "power",	.gpio = 1 << 2, .polarity = REVERSE },
-			{ .name = "link",	.gpio = 1 << 11, .polarity = REVERSE },
-		},
-	},
-	[WL330GE] = {
-		.name		= "ASUS WL-330gE",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 2 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
-		},
-	},
 	[WL500G] = {
 		.name		= "ASUS WL-500g",
 		.buttons	= {
@@ -601,68 +293,6 @@
 			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
 		},
 	},
-	[WL500GD] = {
-		.name		= "ASUS WL-500g Deluxe",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
-		},
-	},
-	[WL500GP] = {
-		.name		= "ASUS WL-500g Premium",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 0 },
-			{ .name = "ses",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = REVERSE },
-		},
-	},
-	[WL500GPV2] = {
-		.name		= "ASUS WL-500g Premium V2",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 2 },
-			{ .name = "ses",	.gpio = 1 << 3 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 1, .polarity = REVERSE },
-		},
-	},
-	[WL500W] = {
-		.name		= "ASUS WL-500W",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "ses",	.gpio = 1 << 7 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 5, .polarity = REVERSE },
-		},
-	},
-	[WL520GC] = {
-		.name		= "ASUS WL-520GC",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 2 },
-			{ .name = "ses",	.gpio = 1 << 3 },
-		},
-		.leds		= {
-		{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 1, .polarity = REVERSE },
-		},
-	},
-	[WL520GU] = {
-		.name		= "ASUS WL-520gU",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 2 },
-			{ .name = "ses",	.gpio = 1 << 3 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 1, .polarity = REVERSE },
-		},
-	},
 	[ASUS_4702] = {
 		.name		= "ASUS (unknown, BCM4702)",
 		.buttons	= {
@@ -672,80 +302,7 @@
 			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
 		},
 	},
-	[WL700GE] = {
-		.name		= "ASUS WL-700gE",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 7 }, // on back, hardwired, always resets device regardless OS state
-			{ .name = "ses",	.gpio = 1 << 4 }, // on back, actual name ezsetup
-			{ .name = "power",	.gpio = 1 << 0 }, // on front
-			{ .name = "copy",	.gpio = 1 << 6 }, // on front
-		},
-		.leds		= {
-#if 0
-			// GPIO that controls power led also enables/disables some essential functions
-			// - power to HDD
-			// - switch leds
-			{ .name = "power",	.gpio = 1 << 3, .polarity = NORMAL },  // actual name power
-#endif
-			{ .name = "diag",	.gpio = 1 << 1, .polarity = REVERSE }, // actual name ready
-		},
-		.platform_init = bcm4780_init,
-	},
-	[RTN12] = {
-		.name		= "ASUS RT-N12",
-		.buttons	= {
-			{ .name = "wps",	.gpio = 1 << 0 },
-			{ .name = "reset",	.gpio = 1 << 1 },
-			// this is the router/repeater/ap switch
-			{ .name = "sw1",	.gpio = 1 << 4 },
-			{ .name = "sw2",	.gpio = 1 << 5 },
-			{ .name = "sw3",	.gpio = 1 << 6 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 2, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 7, .polarity = NORMAL },
-			// gpio3 forces WAN and LAN1-4 all on
-			//{ .name = "eth",	.gpio = 1 << 3, .polarity = REVERSE },
-		},
-	},
-	[RTN16] = {
-		.name		= "ASUS RT-N16",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 8 },
-			{ .name = "ses",	.gpio = 1 << 6 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 7, .polarity = NORMAL },
-		},
-	},
-	[RTN66U] = {
-		.name		= "ASUS RT-N66U",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 9 },
-			{ .name = "wps",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 12, .polarity = REVERSE },
-			{ .name = "usb",	.gpio = 1 << 15, .polarity = REVERSE },
-		},
-	},
 	/* Buffalo */
-	[WHR_G54S] = {
-		.name		= "Buffalo WHR-G54S",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 4 },
-			{ .name = "bridge",	.gpio = 1 << 5 },
-			{ .name = "ses",	.gpio = 1 << 0 },
-		},
-		.leds		= {
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-			{ .name = "internal",	.gpio = 1 << 3, .polarity = REVERSE },
-			{ .name = "ses",	.gpio = 1 << 6, .polarity = REVERSE },
-			{ .name = "bridge",	.gpio = 1 << 1, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 2, .polarity = REVERSE },
-		},
-	},
 	[WBR2_G54] = {
 		.name		= "Buffalo WBR2-G54",
 		/* FIXME: verify */
@@ -756,45 +313,6 @@
 			{ .name = "diag",	.gpio = 1 << 1, .polarity = REVERSE },
 		},
 	},
-	[WHR_HP_G54] = {
-		.name		= "Buffalo WHR-HP-G54",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 4 },
-			{ .name = "bridge",	.gpio = 1 << 5 },
-			{ .name = "ses",	.gpio = 1 << 0 },
-		},
-		.leds		= {
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-			{ .name = "internal",	.gpio = 1 << 3, .polarity = REVERSE },
-			{ .name = "bridge",	.gpio = 1 << 1, .polarity = REVERSE },
-			{ .name = "ses",	.gpio = 1 << 6, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 2, .polarity = REVERSE },
-		},
-	},
-	[WHR_G125] = {
-		.name		= "Buffalo WHR-G125",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 4 },
-			{ .name = "bridge",	.gpio = 1 << 5 },
-			{ .name = "ses",	.gpio = 1 << 0 },
-		},
-		.leds		= {
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-			{ .name = "internal",	.gpio = 1 << 3, .polarity = REVERSE },
-			{ .name = "bridge",	.gpio = 1 << 1, .polarity = REVERSE },
-			{ .name = "ses",	.gpio = 1 << 6, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 2, .polarity = REVERSE },
-		},
-	},
-	[WHR2_A54G54] = {
-		.name		= "Buffalo WHR2-A54G54",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-		},
-	},
 	[WLA2_G54L] = {
 		.name		= "Buffalo WLA2-G54L",
 		/* FIXME: verify */
@@ -805,41 +323,6 @@
 			{ .name = "diag",	.gpio = 1 << 1, .polarity = REVERSE },
 		},
 	},
-	[WZR_G300N] = {
-		.name		= "Buffalo WZR-G300N",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-			{ .name = "bridge",	.gpio = 1 << 1, .polarity = REVERSE },
-			{ .name = "ses",	.gpio = 1 << 6, .polarity = REVERSE },
-		},
-	},
-	[WZR_RS_G54] = {
-		.name		= "Buffalo WZR-RS-G54",
-		.buttons	= {
-			{ .name = "ses",	.gpio = 1 << 0 },
-			{ .name = "reset",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-			{ .name = "ses",	.gpio = 1 << 6, .polarity = REVERSE },
-			{ .name = "vpn",	.gpio = 1 << 1, .polarity = REVERSE },
-		},
-	},
-	[WZR_RS_G54HP] = {
-		.name		= "Buffalo WZR-RS-G54HP",
-		.buttons	= {
-			{ .name = "ses",	.gpio = 1 << 0 },
-			{ .name = "reset",	.gpio = 1 << 4 },
-		},
-		.leds		= {
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-			{ .name = "ses",	.gpio = 1 << 6, .polarity = REVERSE },
-			{ .name = "vpn",	.gpio = 1 << 1, .polarity = REVERSE },
-		},
-	},
 	[BUFFALO_UNKNOWN_4710] = {
 		.name		= "Buffalo (unknown, BCM4710)",
 		.buttons	= {
@@ -884,8 +367,8 @@
 		},
 	},
 	/* Dell */
-	[TM2300] = {
-		.name		= "Dell TrueMobile 2300",
+	[TM2300V2] = {
+		.name		= "Dell TrueMobile 2300 v2",
 		.buttons	= {
 			{ .name = "reset",	.gpio = 1 << 0 },
 		},
@@ -894,28 +377,7 @@
 			{ .name = "power",	.gpio = 1 << 7, .polarity = REVERSE },
 		},
 	},
-	[TM2300V2] = {
-		.name		= "Dell TrueMobile 2300 v2",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 0 },
-		},
-		.leds		= {
-			{ .name = "wlan",	.gpio = 1 << 6, .polarity = REVERSE },
-			{ .name = "power",	.gpio = 1 << 7, .polarity = REVERSE },
-		},
-	},
 	/* Motorola */
-	[WE800G] = {
-		.name		= "Motorola WE800G",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 0 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 4, .polarity = NORMAL },
-			{ .name = "diag",	.gpio = 1 << 2, .polarity = REVERSE },
-			{ .name = "wlan_amber",	.gpio = 1 << 1, .polarity = NORMAL },
-		},
-	},
 	[WR850GV1] = {
 		.name		= "Motorola WR850G V1",
 		.buttons	= {
@@ -929,79 +391,7 @@
 			{ .name = "wlan_green",	.gpio = 1 << 7, .polarity = REVERSE },
 		},
 	},
-	[WR850GV2V3] = {
-		.name		= "Motorola WR850G V2/V3",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 5 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "wlan",	.gpio = 1 << 0, .polarity = REVERSE },
-			{ .name = "wan",	.gpio = 1 << 6, .polarity = INPUT },
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-		},
-	},
-	[WR850GP] = {
-		.name		= "Motorola WR850GP",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 5 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 1, .polarity = NORMAL },
-			{ .name = "wlan",	.gpio = 1 << 0, .polarity = REVERSE },
-			{ .name = "dmz",	.gpio = 1 << 6, .polarity = REVERSE },
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = REVERSE },
-		},
-	},
-
-	/* Belkin */
-	[BELKIN_UNKNOWN] = {
-		.name		= "Belkin (unknown)",
-		/* FIXME: verify & add detection */
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 7 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 5, .polarity = NORMAL },
-			{ .name = "wlan",	.gpio = 1 << 3, .polarity = NORMAL },
-			{ .name = "connected",	.gpio = 1 << 0, .polarity = NORMAL },
-		},
-	},
-	[BELKIN_F7D330X] = {
-		.name		= "Belkin F7D330X",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "wps",	.gpio = 1 << 8 },
-		},
-		.leds		= {
-			/* green */
-			{ .name = "power",	.gpio = 1 << 10, .polarity = REVERSE },
-			/* orange power */
-			{ .name = "warn",	.gpio = 1 << 11, .polarity = REVERSE },
-			/* green */
-			{ .name = "wps",	.gpio = 1 << 12, .polarity = REVERSE },
-			/* orange wps */
-			{ .name = "wlan",	.gpio = 1 << 13, .polarity = REVERSE },
-			{ .name = "usb0",	.gpio = 1 << 14, .polarity = REVERSE },
-			/* shipped unconnected in the F7D3302 */
-			{ .name = "usb1",	.gpio = 1 << 15, .polarity = REVERSE },
-		},
-	},
-	[BELKIN_F7D4301] = {
-		.name		= "Belkin PlayMax F7D4301",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-			{ .name = "wps",	.gpio = 1 << 8 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 10, .polarity = REVERSE },
-			{ .name = "warn",	.gpio = 1 << 11, .polarity = REVERSE },
-			{ .name = "wps",	.gpio = 1 << 12, .polarity = REVERSE },
-			{ .name = "wlan",	.gpio = 1 << 13, .polarity = REVERSE },
-			{ .name = "usb0",	.gpio = 1 << 14, .polarity = REVERSE },
-			{ .name = "usb1",	.gpio = 1 << 15, .polarity = REVERSE },
-		},
-	},
+
 	/* Netgear */
 	[WGT634U] = {
 		.name		= "Netgear WGT634U",
@@ -1023,33 +413,6 @@
 		},
 	},
 	/* Netgear */
-	[WNR834BV2] = {
-		.name	 	= "Netgear WNR834B V2",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-		},
-		.leds		= {
-			{ .name = "power",	.gpio = 1 << 2, .polarity = NORMAL },
-			{ .name = "diag",	.gpio = 1 << 3, .polarity = NORMAL },
-			{ .name = "connected",	.gpio = 1 << 7, .polarity = NORMAL },
-		},
-	},
-	[WNDR3400V1] = {
-		.name		= "Netgear WNDR3400 V1",
-		.buttons	= {
-			/* nvram get gpio5=robo_reset */
-			{ .name = "reset",	.gpio = 1 << 4 },
-			{ .name = "wps",	.gpio = 1 << 6 },
-			{ .name = "wlan",	.gpio = 1 << 8 },
-		},
-		.leds		= {
-			{ .name = "wlan",	.gpio = 0 << 0, .polarity = NORMAL },
-			{ .name = "connected",	.gpio = 1 << 0, .polarity = NORMAL },
-			{ .name = "power",	.gpio = 1 << 3, .polarity = NORMAL },
-			{ .name = "diag",	.gpio = 1 << 7, .polarity = NORMAL },
-			{ .name = "usb",	.gpio = 1 << 2, .polarity = REVERSE },
-		},
-	},
 	[WNDR3700V3] = {
 		.name		= "Netgear WNDR3700 V3",
 		.buttons	= {
@@ -1096,17 +459,6 @@
 		.platform_init = bcm4780_init,
 	},
 	/* D-Link */
-	[DIR130] = {
-		.name	  = "D-Link DIR-130",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 3},
-			{ .name = "reserved",	.gpio = 1 << 7},
-		},
-		.leds	   = {
-			{ .name = "diag",	.gpio = 1 << 0},
-			{ .name = "blue",	.gpio = 1 << 6},
-		},
-	},
 	[DIR320] = {
 		.name	  = "D-Link DIR-320",
 		.buttons	= {
@@ -1121,18 +473,6 @@
 			{ .name = "usb",	.gpio = 1 << 5, .polarity = NORMAL },
 		},
 	},
-	[DIR330] = {
-		.name	  = "D-Link DIR-330",
-		.buttons	= {
-			{ .name = "reset",	.gpio = 1 << 3},
-			{ .name = "reserved",	.gpio = 1 << 7},
-		},
-		.leds	   = {
-			{ .name = "diag",	.gpio = 1 << 0},
-			{ .name = "usb",	.gpio = 1 << 4},
-			{ .name = "blue",	.gpio = 1 << 6},
-		},
-	},
 	[DWL3150] = {
 		.name	= "D-Link DWL-3150",
 		.buttons	= {
@@ -1213,15 +553,6 @@
 		},
 	},
 	/* Huawei */
-	[HUAWEI_E970] = {
-		.name	 	= "Huawei E970",
-		.buttons 	= {
-			{ .name = "reset",	.gpio = 1 << 6 },
-		},
-		.leds		= {
-			{ .name = "wlan",	.gpio = 1 << 0, .polarity = NORMAL },
-		},
-	},
 };
 
 static struct platform_t __init *platform_detect_legacy(void)
@@ -1286,8 +617,6 @@
 		if (!strcmp(boardtype,"0x0472") && !strcmp(getvar("cardbus"), "1")) { /* Netgear WNR834B  V1 and V2*/
 			if (!strcmp(boardnum, "08") || !strcmp(boardnum, "8"))
 				return &platforms[WNR834BV1];
-			if (!strcmp(boardnum, "01") || !strcmp(boardnum, "1"))
-				return &platforms[WNR834BV2];
 		}
 
 	} else { /* PMON based - old stuff */
@@ -1334,13 +663,6 @@
 			return &platforms[BUFFALO_UNKNOWN_4710];
 	}
 
-	if (startswith(getvar("CFEver"), "MotoWRv2") ||
-		startswith(getvar("CFEver"), "MotoWRv3") ||
-		!strcmp(getvar("MOTO_BOARD_TYPE"), "WR_FEM1")) {
-
-		return &platforms[WR850GV2V3];
-	}
-
 	if (!strcmp(boardnum, "44") && !strcmp(getvar("boardflags"),"0x0388")) {  /* Trendware TEW-411BRP+ */
 		return &platforms[TEW411BRPP];
 	}
@@ -1367,110 +689,14 @@
 
 	board = bcm47xx_board_get();
 	board_name = bcm47xx_board_get_name();
-	if (board != BCM47XX_BOARD_UNKNOWN && board != BCM47XX_BOARD_NO)
-		printk(MODULE_NAME ": kernel found a \"%s\"\n", board_name);
 
 	switch(board) {
-	case BCM47XX_BOARD_ASUS_RTN12:
-		return &platforms[RTN12];
-	case BCM47XX_BOARD_ASUS_RTN16:
-		return &platforms[RTN16];
-	case BCM47XX_BOARD_ASUS_RTN66U:
-		return &platforms[RTN66U];
-	case BCM47XX_BOARD_ASUS_WL300G:
-		return &platforms[WL300G];
-	case BCM47XX_BOARD_ASUS_WL320GE:
-		return &platforms[WL320GE];
-	case BCM47XX_BOARD_ASUS_WL330GE:
-		return &platforms[WL330GE];
-	case BCM47XX_BOARD_ASUS_WL500GD:
-		return &platforms[WL500GD];
-	case BCM47XX_BOARD_ASUS_WL500GPV1:
-		return &platforms[WL500GP];
-	case BCM47XX_BOARD_ASUS_WL500GPV2:
-		return &platforms[WL500GPV2];
-	case BCM47XX_BOARD_ASUS_WL500W:
-		return &platforms[WL500W];
-	case BCM47XX_BOARD_ASUS_WL520GC:
-		return &platforms[WL520GC];
-	case BCM47XX_BOARD_ASUS_WL520GU:
-		return &platforms[WL520GU];
-	case BCM47XX_BOARD_ASUS_WL700GE:
-		return &platforms[WL700GE];
-	case BCM47XX_BOARD_ASUS_WLHDD:
-		return &platforms[WLHDD];
-	case BCM47XX_BOARD_BELKIN_F7D4301:
-		return &platforms[BELKIN_F7D4301];
-	case BCM47XX_BOARD_BELKIN_F7D330X:
-		return &platforms[BELKIN_F7D330X];
 	case BCM47XX_BOARD_BUFFALO_WBR2_G54:
 		return &platforms[WBR2_G54];
-	case BCM47XX_BOARD_BUFFALO_WHR2_A54G54:
-		return &platforms[WHR2_A54G54];
-	case BCM47XX_BOARD_BUFFALO_WHR_G125:
-		return &platforms[WHR_G125];
-	case BCM47XX_BOARD_BUFFALO_WHR_G54S:
-		return &platforms[WHR_G54S];
-	case BCM47XX_BOARD_BUFFALO_WHR_HP_G54:
-		return &platforms[WHR_HP_G54];
 	case BCM47XX_BOARD_BUFFALO_WLA2_G54L:
 		return &platforms[WLA2_G54L];
-	case BCM47XX_BOARD_BUFFALO_WZR_G300N:
-		return &platforms[WZR_G300N];
-	case BCM47XX_BOARD_BUFFALO_WZR_RS_G54:
-		return &platforms[WZR_RS_G54];
-	case BCM47XX_BOARD_BUFFALO_WZR_RS_G54HP:
-		return &platforms[WZR_RS_G54HP];
-	case BCM47XX_BOARD_DELL_TM2300:
-		return &platforms[TM2300];
-	case BCM47XX_BOARD_DLINK_DIR130:
-		return &platforms[DIR130];
-	case BCM47XX_BOARD_DLINK_DIR330:
-		return &platforms[DIR330];
-	case BCM47XX_BOARD_HUAWEI_E970:
-		return &platforms[HUAWEI_E970];
-	case BCM47XX_BOARD_LINKSYS_E1000V1:
-		return &platforms[E1000V1];
-	case BCM47XX_BOARD_LINKSYS_E1000V21:
-		return &platforms[E1000V21];
-	case BCM47XX_BOARD_LINKSYS_E2000V1:
-		return &platforms[E2000V1];
-	case BCM47XX_BOARD_LINKSYS_E3000V1:
-		return &platforms[E3000V1];
-	case BCM47XX_BOARD_LINKSYS_E3200V1:
-		return &platforms[E3200V1];
-	case BCM47XX_BOARD_LINKSYS_E4200V1:
-		return &platforms[E4200V1];
-	case BCM47XX_BOARD_LINKSYS_WRT150NV1:
-		return &platforms[WRT150NV1];
-	case BCM47XX_BOARD_LINKSYS_WRT150NV11:
-		return &platforms[WRT150NV11];
-	case BCM47XX_BOARD_LINKSYS_WRT160NV1:
-		return &platforms[WRT160NV1];
-	case BCM47XX_BOARD_LINKSYS_WRT160NV3:
-		return &platforms[WRT160NV3];
-	case BCM47XX_BOARD_LINKSYS_WRT300NV11:
-		return &platforms[WRT300NV11];
-	case BCM47XX_BOARD_LINKSYS_WRT310NV1:
-		return &platforms[WRT310NV1];
 	case BCM47XX_BOARD_LINKSYS_WRT54GSV1:
 		return &platforms[WRT54G];
-	case BCM47XX_BOARD_LINKSYS_WRT54G3GV2:
-		return &platforms[WRT54G3GV2_VF];
-	case BCM47XX_BOARD_LINKSYS_WRT610NV1:
-		return &platforms[WRT610N];
-	case BCM47XX_BOARD_LINKSYS_WRT610NV2:
-		return &platforms[WRT610NV2];
-	case BCM47XX_BOARD_LINKSYS_WRTSL54GS:
-		return &platforms[WRTSL54GS];
-	case BCM47XX_BOARD_MOTOROLA_WE800G:
-		return &platforms[WE800G];
-	case BCM47XX_BOARD_MOTOROLA_WR850GP:
-		return &platforms[WR850GP];
-	case BCM47XX_BOARD_MOTOROLA_WR850GV2V3:
-		return &platforms[WR850GV2V3];
-	case BCM47XX_BOARD_NETGEAR_WNDR3400V1:
-		return &platforms[WNDR3400V1];
 	case BCM47XX_BOARD_NETGEAR_WNDR3700V3:
 		return &platforms[WNDR3700V3];
 	case BCM47XX_BOARD_UNKNOWN:
@@ -1479,9 +705,8 @@
 		printk(MODULE_NAME ": please open a ticket at https://dev.openwrt.org and attach the complete nvram\n");
 		return platform_detect_legacy();
 	default:
-		printk(MODULE_NAME ": board was detected as \"%s\", but not gpio configuration available\n", board_name);
-		printk(MODULE_NAME ": now trying legacy detect\n");
-		return platform_detect_legacy();
+		printk(MODULE_NAME ": board was detected as \"%s\", and kernel should handle it\n", board_name);
+		return NULL;
 	}
 }
 

--- a/package/kernel/button-hotplug/src/button-hotplug.c
+++ b/package/kernel/button-hotplug/src/button-hotplug.c
@@ -86,9 +86,8 @@
 	BH_MAP(KEY_RESTART,	"reset"),
 	BH_MAP(KEY_POWER,	"power"),
 	BH_MAP(KEY_RFKILL,	"rfkill"),
-#ifdef KEY_WPS_BUTTON
 	BH_MAP(KEY_WPS_BUTTON,	"wps"),
-#endif /* KEY_WPS_BUTTON */
+	BH_MAP(KEY_WIMAX,	"wwan"),
 };
 
 /* -------------------------------------------------------------------------*/

--- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
+++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
@@ -23,11 +23,12 @@
 #include <linux/netlink.h>
 #include <linux/kobject.h>
 #include <linux/input.h>
+#include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/of_gpio.h>
 #include <linux/gpio_keys.h>
 
-#define DRV_NAME	"gpio-keys-polled"
+#define DRV_NAME	"gpio-keys"
 
 #define BH_SKB_SIZE	2048
 
@@ -69,6 +70,7 @@
 	int count;
 	int threshold;
 	int can_sleep;
+	struct gpio_keys_button *b;
 };
 
 extern u64 uevent_next_seqnum(void);
@@ -94,6 +96,7 @@
 	BH_MAP(KEY_RESTART,	"reset"),
 	BH_MAP(KEY_RFKILL,	"rfkill"),
 	BH_MAP(KEY_WPS_BUTTON,	"wps"),
+	BH_MAP(KEY_WIMAX,	"wwan"),
 };
 
 /* -------------------------------------------------------------------------*/
@@ -129,7 +132,6 @@
 
 static int button_hotplug_fill_event(struct bh_event *event)
 {
-	char *s;
 	int ret;
 
 	ret = bh_event_add_var(event, 0, "HOME=%s", "/");
@@ -235,18 +237,18 @@
 }
 
 static void button_hotplug_event(struct gpio_keys_button_data *data,
-			   unsigned int type, unsigned int code, int value)
+			   unsigned int type, int value)
 {
 	struct bh_priv *priv = &data->bh;
 	unsigned long seen = jiffies;
 	int btn;
 
-	BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
+	BH_DBG("event type=%u, code=%u, value=%d\n", type, data->b->code, value);
 
 	if ((type != EV_KEY) && (type != EV_SW))
 		return;
 
-	btn = button_get_index(code);
+	btn = button_get_index(data->b->code);
 	if (btn < 0)
 		return;
 
@@ -256,12 +258,13 @@
 }
 #else
 static void button_hotplug_event(struct gpio_keys_button_data *data,
-			   unsigned int type, unsigned int code, int value)
+			   unsigned int type, int value)
 {
 }
 #endif	/* CONFIG_HOTPLUG */
 
-struct gpio_keys_polled_dev {
+struct gpio_keys_button_dev {
+	int polled;
 	struct delayed_work work;
 
 	struct device *dev;
@@ -269,26 +272,24 @@
 	struct gpio_keys_button_data data[0];
 };
 
-static int gpio_button_get_value(struct gpio_keys_button *button,
-				 struct gpio_keys_button_data *bdata)
+static int gpio_button_get_value(struct gpio_keys_button_data *bdata)
 {
 	int val;
 
 	if (bdata->can_sleep)
-		val = !!gpio_get_value_cansleep(button->gpio);
+		val = !!gpio_get_value_cansleep(bdata->b->gpio);
 	else
-		val = !!gpio_get_value(button->gpio);
-
-	return val ^ button->active_low;
-}
-
-static void gpio_keys_polled_check_state(struct gpio_keys_button *button,
-					 struct gpio_keys_button_data *bdata)
-{
-	int state = gpio_button_get_value(button, bdata);
+		val = !!gpio_get_value(bdata->b->gpio);
+
+	return val ^ bdata->b->active_low;
+}
+
+static void gpio_keys_polled_check_state(struct gpio_keys_button_data *bdata)
+{
+	int state = gpio_button_get_value(bdata);
 
 	if (state != bdata->last_state) {
-		unsigned int type = button->type ?: EV_KEY;
+		unsigned int type = bdata->b->type ?: EV_KEY;
 
 		if (bdata->count < bdata->threshold) {
 			bdata->count++;
@@ -296,7 +297,7 @@
 		}
 
 		if ((bdata->last_state != -1) || (type == EV_SW))
-			button_hotplug_event(bdata, type, button->code, state);
+			button_hotplug_event(bdata, type, state);
 
 		bdata->last_state = state;
 	}
@@ -304,55 +305,58 @@
 	bdata->count = 0;
 }
 
-static void gpio_keys_polled_queue_work(struct gpio_keys_polled_dev *bdev)
+static void gpio_keys_polled_queue_work(struct gpio_keys_button_dev *bdev)
 {
 	struct gpio_keys_platform_data *pdata = bdev->pdata;
 	unsigned long delay = msecs_to_jiffies(pdata->poll_interval);
 
 	if (delay >= HZ)
-	    delay = round_jiffies_relative(delay);
+		delay = round_jiffies_relative(delay);
 	schedule_delayed_work(&bdev->work, delay);
 }
 
 static void gpio_keys_polled_poll(struct work_struct *work)
 {
-	struct gpio_keys_polled_dev *bdev =
-		container_of(work, struct gpio_keys_polled_dev, work.work);
-	struct gpio_keys_platform_data *pdata = bdev->pdata;
+	struct gpio_keys_button_dev *bdev =
+		container_of(work, struct gpio_keys_button_dev, work.work);
 	int i;
 
 	for (i = 0; i < bdev->pdata->nbuttons; i++) {
 		struct gpio_keys_button_data *bdata = &bdev->data[i];
-		gpio_keys_polled_check_state(&pdata->buttons[i], bdata);
+		gpio_keys_polled_check_state(bdata);
 	}
 	gpio_keys_polled_queue_work(bdev);
 }
 
-static void gpio_keys_polled_open(struct gpio_keys_polled_dev *bdev)
+static void gpio_keys_polled_close(struct gpio_keys_button_dev *bdev)
 {
 	struct gpio_keys_platform_data *pdata = bdev->pdata;
-	int i;
-
-	if (pdata->enable)
-		pdata->enable(bdev->dev);
-
-	/* report initial state of the buttons */
-	for (i = 0; i < pdata->nbuttons; i++)
-		gpio_keys_polled_check_state(&pdata->buttons[i], &bdev->data[i]);
-
-	gpio_keys_polled_queue_work(bdev);
+
+	cancel_delayed_work_sync(&bdev->work);
+
+	if (pdata->disable)
+		pdata->disable(bdev->dev);
+}
+
+static irqreturn_t button_handle_irq(int irq, void *_bdata)
+{
+	struct gpio_keys_button_data *bdata = (struct gpio_keys_button_data *) _bdata;
+
+	button_hotplug_event(bdata, bdata->b->type ?: EV_KEY, gpio_button_get_value(bdata));
+
+	return IRQ_HANDLED;
 }
 
 #ifdef CONFIG_OF
 static struct gpio_keys_platform_data *
-gpio_keys_polled_get_devtree_pdata(struct device *dev)
+gpio_keys_get_devtree_pdata(struct device *dev)
 {
 	struct device_node *node, *pp;
 	struct gpio_keys_platform_data *pdata;
 	struct gpio_keys_button *button;
 	int error;
 	int nbuttons;
-	int i;
+	int i = 0;
 
 	node = dev->of_node;
 	if (!node)
@@ -362,7 +366,7 @@
 	if (nbuttons == 0)
 		return NULL;
 
-	pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
+	pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * (sizeof *button),
 		GFP_KERNEL);
 	if (!pdata) {
 		error = -ENOMEM;
@@ -375,7 +379,6 @@
 	pdata->rep = !!of_get_property(node, "autorepeat", NULL);
 	of_property_read_u32(node, "poll-interval", &pdata->poll_interval);
 
-	i = 0;
 	for_each_child_of_node(node, pp) {
 		enum of_gpio_flags flags;
 
@@ -394,7 +397,7 @@
 			dev_err(dev, "Button without keycode: 0x%x\n",
 				button->gpio);
 			error = -EINVAL;
-			goto err_free_pdata;
+			goto err_out;
 		}
 
 		button->desc = of_get_property(pp, "label", NULL);
@@ -411,16 +414,20 @@
 
 	if (pdata->nbuttons == 0) {
 		error = -EINVAL;
-		goto err_free_pdata;
+		goto err_out;
 	}
 
 	return pdata;
 
-err_free_pdata:
-	kfree(pdata);
 err_out:
 	return ERR_PTR(error);
 }
+
+static struct of_device_id gpio_keys_of_match[] = {
+	{ .compatible = "gpio-keys", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, gpio_keys_of_match);
 
 static struct of_device_id gpio_keys_polled_of_match[] = {
 	{ .compatible = "gpio-keys-polled", },
@@ -431,47 +438,47 @@
 #else
 
 static inline struct gpio_keys_platform_data *
-gpio_keys_polled_get_devtree_pdata(struct device *dev)
+gpio_keys_get_devtree_pdata(struct device *dev)
 {
 	return NULL;
 }
 #endif
 
-static void gpio_keys_polled_close(struct gpio_keys_polled_dev *bdev)
-{
-	struct gpio_keys_platform_data *pdata = bdev->pdata;
-
-	cancel_delayed_work_sync(&bdev->work);
-
-	if (pdata->disable)
-		pdata->disable(bdev->dev);
-}
-
-static int gpio_keys_polled_probe(struct platform_device *pdev)
+static int gpio_keys_button_probe(struct platform_device *pdev,
+		struct gpio_keys_button_dev **_bdev, int polled)
 {
 	struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
 	struct device *dev = &pdev->dev;
-	struct gpio_keys_polled_dev *bdev;
+	struct gpio_keys_button_dev *bdev;
+	struct gpio_keys_button *buttons;
 	int error;
 	int i;
 
 	if (!pdata) {
-		pdata = gpio_keys_polled_get_devtree_pdata(dev);
+		pdata = gpio_keys_get_devtree_pdata(dev);
 		if (IS_ERR(pdata))
 			return PTR_ERR(pdata);
 		if (!pdata) {
 			dev_err(dev, "missing platform data\n");
 			return -EINVAL;
 		}
-	}
-
-	if (!pdata->poll_interval) {
+		pdev->dev.platform_data = pdata;
+	}
+
+	if (polled && !pdata->poll_interval) {
 		dev_err(dev, "missing poll_interval value\n");
-		error = -EINVAL;
-		goto err_free_pdata;
-	}
-
-	bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
+		return -EINVAL;
+	}
+
+	buttons = devm_kzalloc(dev, pdata->nbuttons * sizeof(struct gpio_keys_button),
+		       GFP_KERNEL);
+	if (!buttons) {
+		dev_err(dev, "no memory for button data\n");
+		return -ENOMEM;
+	}
+	memcpy(buttons, pdata->buttons, pdata->nbuttons * sizeof(struct gpio_keys_button));
+
+	bdev = devm_kzalloc(dev, sizeof(struct gpio_keys_button_dev) +
 		       pdata->nbuttons * sizeof(struct gpio_keys_button_data),
 		       GFP_KERNEL);
 	if (!bdev) {
@@ -479,23 +486,24 @@
 		return -ENOMEM;
 	}
 
+	bdev->polled = polled;
+
 	for (i = 0; i < pdata->nbuttons; i++) {
-		struct gpio_keys_button *button = &pdata->buttons[i];
+		struct gpio_keys_button *button = &buttons[i];
 		struct gpio_keys_button_data *bdata = &bdev->data[i];
 		unsigned int gpio = button->gpio;
 
 		if (button->wakeup) {
-			dev_err(dev, DRV_NAME " does not support wakeup\n");
-			error = -EINVAL;
-			goto err_free_gpio;
-		}
-
-		error = gpio_request(gpio,
+			dev_err(dev, DRV_NAME "does not support wakeup\n");
+			return -EINVAL;
+		}
+
+		error = devm_gpio_request(dev, gpio,
 				     button->desc ? button->desc : DRV_NAME);
 		if (error) {
 			dev_err(dev, "unable to claim gpio %u, err=%d\n",
 				gpio, error);
-			goto err_free_gpio;
+			return error;
 		}
 
 		error = gpio_direction_input(gpio);
@@ -503,79 +511,154 @@
 			dev_err(dev,
 				"unable to set direction on gpio %u, err=%d\n",
 				gpio, error);
-			goto err_free_gpio;
+			return error;
 		}
 
 		bdata->can_sleep = gpio_cansleep(gpio);
 		bdata->last_state = -1;
-		bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
+
+		if (bdev->polled)
+			bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
 						pdata->poll_interval);
+		else
+			bdata->threshold = 1;
+
+		bdata->b = &pdata->buttons[i];
 	}
 
 	bdev->dev = &pdev->dev;
 	bdev->pdata = pdata;
 	platform_set_drvdata(pdev, bdev);
 
+	*_bdev = bdev;
+
+	return 0;
+}
+
+static int gpio_keys_probe(struct platform_device *pdev)
+{
+	struct gpio_keys_platform_data *pdata;
+	struct gpio_keys_button_dev *bdev;
+	int ret, i;
+
+
+	ret = gpio_keys_button_probe(pdev, &bdev, 0);
+
+	if (ret)
+		return ret;
+
+	pdata = pdev->dev.platform_data;
+	for (i = 0; i < pdata->nbuttons; i++) {
+		struct gpio_keys_button *button = &pdata->buttons[i];
+		struct gpio_keys_button_data *bdata = &bdev->data[i];
+
+		if (bdata->can_sleep) {
+			dev_err(&pdev->dev, "skipping gpio:%d, it can sleep\n", button->gpio);
+			continue;
+		}
+		if (!button->irq)
+			button->irq = gpio_to_irq(button->gpio);
+		if (button->irq < 0) {
+			dev_err(&pdev->dev, "failed to get irq for gpio:%d\n", button->gpio);
+			continue;
+		}
+		ret = devm_request_irq(&pdev->dev, button->irq, button_handle_irq,
+					IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+					dev_name(&pdev->dev), bdata);
+		if (ret)
+			dev_err(&pdev->dev, "failed to request irq:%d for gpio:%d\n", button->irq, button->gpio);
+		else
+			dev_dbg(&pdev->dev, "gpio:%d has irq:%d\n", button->gpio, button->irq);
+
+		if (bdata->b->type == EV_SW)
+			button_hotplug_event(bdata, EV_SW, gpio_button_get_value(bdata));
+	}
+
+	return 0;
+}
+
+static int gpio_keys_polled_probe(struct platform_device *pdev)
+{
+	struct gpio_keys_platform_data *pdata;
+	struct gpio_keys_button_dev *bdev;
+	int ret;
+	int i;
+
+	ret = gpio_keys_button_probe(pdev, &bdev, 1);
+
+	if (ret)
+		return ret;
+
 	INIT_DELAYED_WORK(&bdev->work, gpio_keys_polled_poll);
 
-	gpio_keys_polled_open(bdev);
+	pdata = bdev->pdata;
+
+	if (pdata->enable)
+		pdata->enable(bdev->dev);
+
+	for (i = 0; i < pdata->nbuttons; i++)
+		gpio_keys_polled_check_state(&bdev->data[i]);
+
+	gpio_keys_polled_queue_work(bdev);
+
+	return ret;
+}
+
+static int gpio_keys_remove(struct platform_device *pdev)
+{
+	struct gpio_keys_button_dev *bdev = platform_get_drvdata(pdev);
+
+	platform_set_drvdata(pdev, NULL);
+
+	if (bdev->polled)
+		gpio_keys_polled_close(bdev);
 
 	return 0;
-
-err_free_gpio:
-	while (--i >= 0)
-		gpio_free(pdata->buttons[i].gpio);
-
-	kfree(bdev);
-	platform_set_drvdata(pdev, NULL);
-
-err_free_pdata:
-	/* If we have no platform_data, we allocated pdata dynamically.  */
-	if (!dev_get_platdata(&pdev->dev))
-		kfree(pdata);
-
-	return error;
-}
-
-static int gpio_keys_polled_remove(struct platform_device *pdev)
-{
-	struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
-	struct gpio_keys_platform_data *pdata = bdev->pdata;
-	int i = pdata->nbuttons;
-
-	gpio_keys_polled_close(bdev);
-
-	while (--i >= 0)
-		gpio_free(pdata->buttons[i].gpio);
-
-	kfree(bdev);
-	platform_set_drvdata(pdev, NULL);
-
-	return 0;
-}
+}
+
+static struct platform_driver gpio_keys_driver = {
+	.probe	= gpio_keys_probe,
+	.remove	= gpio_keys_remove,
+	.driver	= {
+		.name	= "gpio-keys",
+		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(gpio_keys_of_match),
+	},
+};
 
 static struct platform_driver gpio_keys_polled_driver = {
 	.probe	= gpio_keys_polled_probe,
-	.remove	= gpio_keys_polled_remove,
+	.remove	= gpio_keys_remove,
 	.driver	= {
-		.name	= DRV_NAME,
+		.name	= "gpio-keys-polled",
 		.owner	= THIS_MODULE,
 		.of_match_table = of_match_ptr(gpio_keys_polled_of_match),
 	},
 };
 
-static int __init gpio_keys_polled_init(void)
-{
-	return platform_driver_register(&gpio_keys_polled_driver);
-}
-
-static void __exit gpio_keys_polled_exit(void)
-{
+static int __init gpio_button_init(void)
+{
+	int ret;
+
+	ret = platform_driver_register(&gpio_keys_driver);
+	if (ret)
+		return ret;
+
+	ret = platform_driver_register(&gpio_keys_polled_driver);
+	if (ret)
+		platform_driver_unregister(&gpio_keys_driver);
+
+	return ret;
+}
+
+static void __exit gpio_button_exit(void)
+{
+	platform_driver_unregister(&gpio_keys_driver);
 	platform_driver_unregister(&gpio_keys_polled_driver);
 }
 
-module_init(gpio_keys_polled_init);
-module_exit(gpio_keys_polled_exit);
+module_init(gpio_button_init);
+module_exit(gpio_button_exit);
 
 MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
 MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");

--- a/package/kernel/hostap-driver/Makefile
+++ b/package/kernel/hostap-driver/Makefile
@@ -34,7 +34,7 @@
 define KernelPackage/hostap
 $(call KernelPackage/hostap/Default)
   TITLE:=Host AP support for Prism2/2.5/3
-  DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-lib80211 +wireless-tools
+  DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-lib80211 +wireless-tools +hostapd-common-old
   KCONFIG:=CONFIG_HOSTAP CONFIG_HOSTAP_FIRMWARE=y CONFIG_HOSTAP_FIRMWARE_NVRAM=y
   FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap.ko
   AUTOLOAD:=$(call AutoProbe,hostap)

--- a/package/kernel/lantiq/ltq-atm/src/ltq_atm.c
+++ b/package/kernel/lantiq/ltq-atm/src/ltq_atm.c
@@ -885,8 +885,6 @@
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 	nf_conntrack_put(new_skb->nfct);
 	new_skb->nfct = NULL;
-	nf_conntrack_put_reasm(new_skb->nfct_reasm);
-	new_skb->nfct_reasm = NULL;
   #ifdef CONFIG_BRIDGE_NETFILTER
 	nf_bridge_put(new_skb->nf_bridge);
 	new_skb->nf_bridge = NULL;

--- a/package/kernel/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c
+++ b/package/kernel/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c
@@ -43,7 +43,7 @@
 #endif
 
 
-const char* part_type(u_int32_t id)
+const char* part_type(unsigned int id)
 {
 	switch(id) {
 	case MAGIC_ANNEX_B:
@@ -58,8 +58,8 @@
 int main(int argc, char **argv)
 {
 	struct stat s;
-	u_int8_t *buf_orig;
-	u_int32_t *buf;
+	unsigned char *buf_orig;
+	unsigned int *buf;
 	int buflen;
 	int fd;
 	int i;
@@ -83,7 +83,8 @@
 	}
 
 	buf_orig = malloc(s.st_size);
-	if (!buf_orig) {
+	buf = malloc(s.st_size);
+	if (!buf_orig || !buf) {
 		printf("Failed to alloc %d bytes\n", s.st_size);
 		return -1;
 	}
@@ -93,6 +94,7 @@
 		printf("Unable to open %s\n", FW_NAME);
 		return -1;
 	}
+
 
 	buflen = read(fd, buf_orig, s.st_size);
 	close(fd);
@@ -112,22 +114,21 @@
 	}
 	buflen -= 3;
 	memmove(&buf_orig[MAGIC_SZ], &buf_orig[MAGIC_SZ + 3], buflen - MAGIC_SZ);
+	memcpy(buf, buf_orig, s.st_size);
+
 	/* </magic> */
-
-	buf = (u_int32_t*) buf_orig;
-
 	do {
 		if (buf[end] == MAGIC_PART) {
 			end += 2;
 			printf("Found partition at 0x%08X with size %d\n",
-				start * sizeof(u_int32_t),
-				(end - start) * sizeof(u_int32_t));
+				start * sizeof(unsigned int),
+				(end - start) * sizeof(unsigned int));
 			if (buf[start] == MAGIC_LZMA) {
 				int dest_len = 1024 * 1024;
 				int len = buf[end - 3];
-				u_int32_t id = buf[end - 6];
+				unsigned int id = buf[end - 6];
 				const char *type = part_type(id);
-				u_int8_t *dest;
+				unsigned char *dest;
 
 				dest = malloc(dest_len);
 				if (!dest) {
@@ -135,7 +136,7 @@
 					return -1;
 				}
 
-				if (lzma_inflate((u_int8_t*)&buf[start], len, dest, &dest_len)) {
+				if (lzma_inflate((unsigned char*)&buf[start], len, dest, &dest_len)) {
 					printf("Failed to decompress data\n");
 					return -1;
 				}
@@ -158,7 +159,7 @@
 		} else {
 			end++;
 		}
-	} while(end < buflen / sizeof(u_int32_t));
+	} while(end < buflen / sizeof(unsigned int));
 
 	return 0;
 }

--- /dev/null
+++ b/package/kernel/linux/modules/can.mk
@@ -1,1 +1,223 @@
-
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+CAN_MENU:=CAN Support
+
+define KernelPackage/can
+  SUBMENU:=$(CAN_MENU)
+  TITLE:=CAN bus support
+  KCONFIG:=\
+	CONFIG_CAN=y \
+	CONFIG_CAN_DEV \
+	CONFIG_CAN_CALC_BITTIMING=y \
+	CONFIG_CAN_LEDS=y \
+	CONFIG_CAN_AT91=n \
+	CONFIG_CAN_TI_HECC=n \
+	CONFIG_CAN_MCP251X=n \
+	CONFIG_CAN_BFIN=n \
+	CONFIG_CAN_JANZ_ICAN3=n \
+	CONFIG_PCH_CAN=n \
+	CONFIG_CAN_GRCAN=n \
+	CONFIG_CAN_CC770=n \
+	CONFIG_CAN_C_CAN=n \
+	CONFIG_CAN_MSCAN=n \
+	CONFIG_CAN_SJA1000=n \
+	CONFIG_CAN_SOFTING=n \
+	CONFIG_NET_EMATCH_CANID=n \
+	CONFIG_CAN_DEBUG_DEVICES=n
+  FILES:=$(LINUX_DIR)/drivers/net/can/can-dev.ko
+  AUTOLOAD:=$(call AutoProbe,can-dev)
+endef
+
+define KernelPackage/can/description
+ Kernel module for CAN bus support.
+endef
+
+$(eval $(call KernelPackage,can))
+
+
+define AddDepends/can
+  SUBMENU:=$(CAN_MENU)
+  DEPENDS+=kmod-can $(1)
+endef
+
+
+define KernelPackage/can-raw
+  TITLE:=Raw CAN Protcol
+  KCONFIG:=CONFIG_CAN_RAW
+  FILES:=$(LINUX_DIR)/net/can/can-raw.ko
+  AUTOLOAD:=$(call AutoProbe,can-raw)
+  $(call AddDepends/can)
+endef
+
+define KernelPackage/can-raw/description
+ The raw CAN protocol option offers access to the CAN bus via
+ the BSD  socket API.
+endef
+
+$(eval $(call KernelPackage,can-raw))
+
+
+define KernelPackage/can-bcm
+  TITLE:=Broadcast Manager CAN Protcol
+  KCONFIG:=CONFIG_CAN_BCM
+  FILES:=$(LINUX_DIR)/net/can/can-bcm.ko
+  AUTOLOAD:=$(call AutoProbe,can-bcm)
+  $(call AddDepends/can)
+endef
+
+define KernelPackage/can-bcm/description
+ The Broadcast Manager offers content filtering, timeout monitoring,
+ sending of RTR frames, and cyclic CAN messages without permanent user
+ interaction.
+endef
+
+$(eval $(call KernelPackage,can-bcm))
+
+
+define KernelPackage/can-gw
+  TITLE:=CAN Gateway/Router
+  KCONFIG:=CONFIG_CAN_GW
+  FILES:=$(LINUX_DIR)/net/can/can-gw.ko
+  AUTOLOAD:=$(call AutoProbe,can-gw)
+  $(call AddDepends/can)
+endef
+
+define KernelPackage/can-gw/description
+ The CAN Gateway/Router is used to route (and modify) CAN frames.
+endef
+
+$(eval $(call KernelPackage,can-gw))
+
+
+define KernelPackage/can-vcan
+  TITLE:=Virtual Local CAN Interface (vcan)
+  KCONFIG:=CONFIG_CAN_VCAN
+  FILES:=$(LINUX_DIR)/drivers/net/can/vcan.ko
+  AUTOLOAD:=$(call AutoProbe,vcan)
+  $(call AddDepends/can)
+endef
+
+define KernelPackage/can-vcan/description
+ Similar to the network loopback devices, vcan offers a
+ virtual local CAN interface.
+endef
+
+$(eval $(call KernelPackage,can-vcan))
+
+
+define KernelPackage/can-slcan
+  TITLE:=Serial / USB serial CAN Adaptors (slcan)
+  KCONFIG:=CONFIG_CAN_SLCAN
+  FILES:=$(LINUX_DIR)/drivers/net/can/slcan.ko
+  AUTOLOAD:=$(call AutoProbe,slcan)
+  $(call AddDepends/can)
+endef
+
+define KernelPackage/can-slcan/description
+ CAN driver for several 'low cost' CAN interfaces that are attached
+ via serial lines or via USB-to-serial adapters using the LAWICEL
+ ASCII protocol.
+endef
+
+$(eval $(call KernelPackage,can-slcan))
+
+
+define KernelPackage/can-flexcan
+  TITLE:=Support for Freescale FLEXCAN based chips
+  KCONFIG:=CONFIG_CAN_FLEXCAN
+  FILES:=$(LINUX_DIR)/drivers/net/can/flexcan.ko
+  AUTOLOAD:=$(call AutoProbe,flexcan)
+  $(call AddDepends/can,@TARGET_imx6)
+endef
+
+define KernelPackage/can-flexcan/description
+ Freescale FLEXCAN CAN bus controller implementation.
+endef
+
+$(eval $(call KernelPackage,can-flexcan))
+
+
+define KernelPackage/can-usb-ems
+  TITLE:=EMS CPC-USB/ARM7 CAN/USB interface
+  KCONFIG:=CONFIG_CAN_EMS_USB
+  FILES:=$(LINUX_DIR)/drivers/net/can/usb/ems_usb.ko
+  AUTOLOAD:=$(call AutoProbe,ems_usb)
+  $(call AddDepends/can,+kmod-usb-core)
+endef
+
+define KernelPackage/can-usb-ems/description
+ This driver is for the one channel CPC-USB/ARM7 CAN/USB interface
+ from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de).
+endef
+
+$(eval $(call KernelPackage,can-usb-ems))
+
+
+define KernelPackage/can-usb-esd
+  TITLE:=ESD USB/2 CAN/USB interface
+  KCONFIG:=CONFIG_CAN_ESD_USB2
+  FILES:=$(LINUX_DIR)/drivers/net/can/usb/esd_usb2.ko
+  AUTOLOAD:=$(call AutoProbe,esd_usb2)
+  $(call AddDepends/can,+kmod-usb-core)
+endef
+
+define KernelPackage/can-usb-esd/description
+ This driver supports the CAN-USB/2 interface
+ from esd electronic system design gmbh (http://www.esd.eu).
+endef
+
+$(eval $(call KernelPackage,can-usb-esd))
+
+
+define KernelPackage/can-usb-kvaser
+  TITLE:=Kvaser CAN/USB interface
+  KCONFIG:=CONFIG_CAN_KVASER_USB
+  FILES:=$(LINUX_DIR)/drivers/net/can/usb/kvaser_usb.ko
+  AUTOLOAD:=$(call AutoProbe,kvaser_usb)
+  $(call AddDepends/can,+kmod-usb-core)
+endef
+
+define KernelPackage/can-usb-kvaser/description
+ This driver adds support for Kvaser CAN/USB devices like Kvaser
+ Leaf Light.
+endef
+
+$(eval $(call KernelPackage,can-usb-kvaser))
+
+
+define KernelPackage/can-usb-peak
+  TITLE:=PEAK PCAN-USB/USB Pro interfaces
+  KCONFIG:=CONFIG_CAN_PEAK_USB
+  FILES:=$(LINUX_DIR)/drivers/net/can/usb/peak_usb/peak_usb.ko
+  AUTOLOAD:=$(call AutoProbe,peak_usb)
+  $(call AddDepends/can,+kmod-usb-core)
+endef
+
+define KernelPackage/can-usb-peak/description
+ This driver supports the PCAN-USB and PCAN-USB Pro adapters
+ from PEAK-System Technik (http://www.peak-system.com).
+endef
+
+$(eval $(call KernelPackage,can-usb-peak))
+
+
+define KernelPackage/can-usb-8dev
+  TITLE:=8 devices USB2CAN interface
+  KCONFIG:=CONFIG_CAN_8DEV_USB
+  FILES:=$(LINUX_DIR)/drivers/net/can/usb/usb_8dev.ko
+  AUTOLOAD:=$(call AutoProbe,usb_8dev)
+  $(call AddDepends/can,+kmod-usb-core)
+endef
+
+define KernelPackage/can-usb-8dev/description
+ This driver supports the USB2CAN interface
+ from 8 devices (http://www.8devices.com).
+endef
+
+$(eval $(call KernelPackage,can-usb-8dev))
+

--- a/package/kernel/linux/modules/crypto.mk
+++ b/package/kernel/linux/modules/crypto.mk
@@ -7,12 +7,13 @@
 
 CRYPTO_MENU:=Cryptographic API modules
 
-CRYPTO_MODULES = ALGAPI2=crypto_algapi
+CRYPTO_MODULES = \
+	ALGAPI2=crypto_algapi \
+	BLKCIPHER2=crypto_blkcipher
 
 CRYPTOMGR_MODULES = \
 	AEAD2=aead \
 	MANAGER2=cryptomgr \
-	BLKCIPHER2=crypto_blkcipher
 
 crypto_confvar=CONFIG_CRYPTO_$(word 1,$(subst =,$(space),$(1)))
 crypto_file=$(LINUX_DIR)/crypto/$(word 2,$(subst =,$(space),$(1))).ko
@@ -24,6 +25,7 @@
   KCONFIG:= \
 	CONFIG_CRYPTO=y \
 	CONFIG_CRYPTO_HW=y \
+	CONFIG_CRYPTO_BLKCIPHER \
 	CONFIG_CRYPTO_ALGAPI \
 	$(foreach mod,$(CRYPTO_MODULES),$(call crypto_confvar,$(mod)))
   FILES:=$(foreach mod,$(CRYPTO_MODULES),$(call crypto_file,$(mod)))
@@ -53,7 +55,6 @@
   DEPENDS:=+kmod-crypto-hash +kmod-crypto-pcompress
   KCONFIG:= \
 	CONFIG_CRYPTO_AEAD \
-	CONFIG_CRYPTO_BLKCIPHER \
 	CONFIG_CRYPTO_MANAGER \
 	$(foreach mod,$(CRYPTOMGR_MODULES),$(call crypto_confvar,$(mod)))
   FILES:=$(foreach mod,$(CRYPTOMGR_MODULES),$(call crypto_file,$(mod)))
@@ -248,7 +249,7 @@
   KCONFIG:=CONFIG_CRYPTO_ARC4
   FILES:=$(LINUX_DIR)/crypto/arc4.ko
   AUTOLOAD:=$(call AutoLoad,09,arc4)
-  $(call AddDepends/crypto,+!LINUX_3_3:kmod-crypto-manager)
+  $(call AddDepends/crypto)
 endef
 
 $(eval $(call KernelPackage,crypto-arc4))

--- a/package/kernel/linux/modules/fs.mk
+++ b/package/kernel/linux/modules/fs.mk
@@ -25,7 +25,7 @@
 define KernelPackage/fs-btrfs
   SUBMENU:=$(FS_MENU)
   TITLE:=BTRFS filesystem support
-  DEPENDS:=+kmod-lib-crc32c +kmod-lib-lzo +kmod-lib-zlib +(LINUX_3_9||LINUX_3_10):kmod-lib-raid6 +(LINUX_3_9||LINUX_3_10):kmod-lib-xor
+  DEPENDS:=+kmod-lib-crc32c +kmod-lib-lzo +kmod-lib-zlib +(!LINUX_3_3&&!LINUX_3_6&&!LINUX_3_8):kmod-lib-raid6 +(!LINUX_3_3&&!LINUX_3_6&&!LINUX_3_8):kmod-lib-xor
   KCONFIG:=\
 	CONFIG_BTRFS_FS \
 	CONFIG_BTRFS_FS_POSIX_ACL=n \
@@ -225,9 +225,15 @@
 	CONFIG_NFS_FS \
 	CONFIG_NFS_USE_LEGACY_DNS=n \
 	CONFIG_NFS_USE_NEW_IDMAPPER=n
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.6.0)),1)
+  FILES:= \
+	$(LINUX_DIR)/fs/nfs/nfs.ko \
+	$(LINUX_DIR)/fs/nfs/nfsv3.ko
+else
   FILES:= \
 	$(LINUX_DIR)/fs/nfs/nfs.ko
-  AUTOLOAD:=$(call AutoLoad,40,nfs)
+endif
+  AUTOLOAD:=$(call AutoLoad,40,nfs nfsv3)
 endef
 
 define KernelPackage/fs-nfs/description
@@ -372,3 +378,19 @@
 
 $(eval $(call KernelPackage,fs-xfs))
 
+
+define KernelPackage/fs-jfs
+  SUBMENU:=$(FS_MENU)
+  TITLE:=JFS filesystem support
+  KCONFIG:=CONFIG_JFS_FS
+  FILES:=$(LINUX_DIR)/fs/jfs/jfs.ko
+  AUTOLOAD:=$(call AutoLoad,30,jfs,1)
+  $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-jfs/description
+ Kernel module for JFS support
+endef
+
+$(eval $(call KernelPackage,fs-jfs))
+

--- a/package/kernel/linux/modules/netdevices.mk
+++ b/package/kernel/linux/modules/netdevices.mk
@@ -10,7 +10,7 @@
 define KernelPackage/sis190
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=SiS 190 Fast/Gigabit Ethernet support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_SIS190
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis190.ko
   AUTOLOAD:=$(call AutoProbe,sis190)
@@ -48,7 +48,7 @@
 define KernelPackage/atl1
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=Atheros L1 Gigabit Ethernet support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_ATL1
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atlx/atl1.ko
   AUTOLOAD:=$(call AutoProbe,atl1)
@@ -246,7 +246,7 @@
 define KernelPackage/sis900
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=SiS 900 Ethernet support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_SIS900
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis900.ko
   AUTOLOAD:=$(call AutoProbe,sis900)
@@ -284,7 +284,7 @@
 define KernelPackage/via-rhine
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=Via Rhine ethernet support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_VIA_RHINE \
     CONFIG_VIA_RHINE_MMIO=y
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/via/via-rhine.ko
@@ -317,7 +317,7 @@
 define KernelPackage/8139too
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=RealTek RTL-8139 PCI Fast Ethernet Adapter kernel support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_8139TOO \
     CONFIG_8139TOO_PIO=y \
     CONFIG_8139TOO_TUNE_TWISTER=n \
@@ -337,7 +337,7 @@
 define KernelPackage/8139cp
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=RealTek RTL-8139C+ PCI Fast Ethernet Adapter kernel support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_8139CP
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/8139cp.ko
   AUTOLOAD:=$(call AutoProbe,8139cp)
@@ -353,7 +353,7 @@
 define KernelPackage/r8169
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=RealTek RTL-8169 PCI Gigabit Ethernet Adapter kernel support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_R8169 \
     CONFIG_R8169_NAPI=y \
     CONFIG_R8169_VLAN=n
@@ -389,7 +389,7 @@
 define KernelPackage/e100
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=Intel(R) PRO/100+ cards kernel support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_E100
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e100.ko
   AUTOLOAD:=$(call AutoProbe,e100)
@@ -430,7 +430,7 @@
 define KernelPackage/e1000e
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=Intel(R) PRO/1000 PCIe cards kernel support
-  DEPENDS:=@PCIE_SUPPORT +(!LINUX_3_3&&!LINUX_3_6&&!LINUX_3_7):kmod-ptp
+  DEPENDS:=@PCIE_SUPPORT +(!LINUX_3_3&&!LINUX_3_6):kmod-ptp
   KCONFIG:=CONFIG_E1000E
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e1000e/e1000e.ko
   AUTOLOAD:=$(call AutoProbe,e1000e)
@@ -446,7 +446,7 @@
 define KernelPackage/b44
   TITLE:=Broadcom 44xx driver
   KCONFIG:=CONFIG_B44
-  DEPENDS:=@PCI_SUPPORT +!TARGET_brcm47xx:kmod-ssb
+  DEPENDS:=@PCI_SUPPORT +!TARGET_brcm47xx:kmod-ssb +kmod-mii
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/b44.ko
   AUTOLOAD:=$(call AutoLoad,19,b44,1)
@@ -462,7 +462,7 @@
 define KernelPackage/3c59x
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=3Com 3c590/3c900 series (592/595/597) Vortex/Boomerang
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_VORTEX
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/3com/3c59x.ko
   AUTOLOAD:=$(call AutoProbe,3c59x)
@@ -500,7 +500,7 @@
 define KernelPackage/tg3
   TITLE:=Broadcom Tigon3 Gigabit Ethernet
   KCONFIG:=CONFIG_TIGON3
-  DEPENDS:=+!TARGET_brcm47xx:kmod-libphy +!LINUX_3_3:kmod-hwmon-core +(LINUX_3_8||LINUX_3_9||LINUX_3_10||LINUX_3_12):kmod-ptp
+  DEPENDS:=+!TARGET_brcm47xx:kmod-libphy +!LINUX_3_3:kmod-hwmon-core +(!LINUX_3_3&&!LINUX_3_6):kmod-ptp
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/tg3.ko
   AUTOLOAD:=$(call AutoLoad,19,tg3,1)
@@ -595,7 +595,7 @@
 
 define KernelPackage/tulip
   TITLE:=Tulip family network device support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   KCONFIG:= \
     CONFIG_NET_TULIP=y \
@@ -680,7 +680,7 @@
 define KernelPackage/dm9000
   SUBMENU:=$(NETWORK_DEVICES_MENU)
   TITLE:=Davicom 9000 Ethernet support
-  DEPENDS:=@PCI_SUPPORT
+  DEPENDS:=@PCI_SUPPORT +kmod-mii
   KCONFIG:=CONFIG_DM9000 \
     CONFIG_DM9000_DEBUGLEVEL=4 \
     CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL=y
@@ -757,3 +757,19 @@
 
 $(eval $(call KernelPackage,gianfar))
 
+
+define KernelPackage/vmxnet3
+  SUBMENU:=$(NETWORK_DEVICES_MENU)
+  TITLE:=VMware VMXNET3 ethernet driver 
+  DEPENDS:=@PCI_SUPPORT
+  KCONFIG:=CONFIG_VMXNET3
+  FILES:=$(LINUX_DIR)/drivers/net/vmxnet3/vmxnet3.ko
+  AUTOLOAD:=$(call AutoLoad,35,vmxnet3)
+endef
+
+define KernelPackage/vmxnet3/description
+ Kernel modules for VMware VMXNET3 ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,vmxnet3))
+

--- a/package/kernel/linux/modules/netfilter.mk
+++ b/package/kernel/linux/modules/netfilter.mk
@@ -318,7 +318,7 @@
   	CONFIG_NETFILTER_XT_MATCH_SOCKET \
   	CONFIG_NETFILTER_XT_TARGET_TPROXY
   FILES:= \
-  	$(LINUX_DIR)/net/netfilter/nf_tproxy_core.ko \
+	$(if $(call kernel_patchver_lt,3.12),$(LINUX_DIR)/net/netfilter/nf_tproxy_core.ko) \
   	$(foreach mod,$(IPT_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko)
   AUTOLOAD:=$(call AutoProbe,$(notdir nf_tproxy_core $(IPT_TPROXY-m)))
   $(call AddDepends/ipt)

--- a/package/kernel/linux/modules/other.mk
+++ b/package/kernel/linux/modules/other.mk
@@ -485,6 +485,23 @@
 $(eval $(call KernelPackage,pwm-gpio))
 
 
+define KernelPackage/rtc-ds1672
+  SUBMENU:=$(OTHER_MENU)
+  TITLE:=Dallas/Maxim DS1672 RTC support
+  $(call AddDepends/rtc)
+  DEPENDS+=+kmod-i2c-core
+  KCONFIG:=CONFIG_RTC_DRV_DS1672
+  FILES:=$(LINUX_DIR)/drivers/rtc/rtc-ds1672.ko
+  AUTOLOAD:=$(call AutoProbe,rtc-ds1672)
+endef
+
+define KernelPackage/rtc-ds1672/description
+ Kernel module for Dallas/Maxim DS1672 RTC.
+endef
+
+$(eval $(call KernelPackage,rtc-ds1672))
+
+
 define KernelPackage/rtc-isl1208
   SUBMENU:=$(OTHER_MENU)
   TITLE:=Intersil ISL1208 RTC support

--- a/package/kernel/linux/modules/sound.mk
+++ b/package/kernel/linux/modules/sound.mk
@@ -42,10 +42,10 @@
 
 ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.12.0)),1)
 SOUNDCORE_LOAD += \
-	snd-pcm-dmaengine
+	$(if $(CONFIG_SND_DMAENGINE_PCM),snd-pcm-dmaengine)
 
 SOUNDCORE_FILES += \
-	$(LINUX_DIR)/sound/core/snd-pcm-dmaengine.ko
+	$(if $(CONFIG_SND_DMAENGINE_PCM),$(LINUX_DIR)/sound/core/snd-pcm-dmaengine.ko)
 endif
 
 define KernelPackage/sound-core
@@ -190,6 +190,7 @@
 
 define KernelPackage/sound-soc-imx
   TITLE:=IMX SoC support
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),lt,3.12.0)),1)
   KCONFIG:=\
 	CONFIG_SND_IMX_SOC \
 	CONFIG_SND_SOC_IMX_AUDMUX \
@@ -200,6 +201,18 @@
 	$(LINUX_DIR)/sound/soc/fsl/snd-soc-fsl-ssi.ko \
 	$(LINUX_DIR)/sound/soc/fsl/snd-soc-imx-pcm.ko
   AUTOLOAD:=$(call AutoLoad,56,snd-soc-imx-audmux snd-soc-fsl-ssi snd-soc-imx-pcm)
+else
+  KCONFIG:=\
+	CONFIG_SND_IMX_SOC \
+	CONFIG_SND_SOC_IMX_AUDMUX \
+	CONFIG_SND_SOC_FSL_SSI \
+	CONFIG_SND_SOC_IMX_PCM_DMA
+  FILES:= \
+	$(LINUX_DIR)/sound/soc/fsl/snd-soc-imx-audmux.ko \
+	$(LINUX_DIR)/sound/soc/fsl/snd-soc-fsl-ssi.ko \
+	$(LINUX_DIR)/sound/soc/fsl/imx-pcm-dma.ko
+  AUTOLOAD:=$(call AutoLoad,56,snd-soc-imx-audmux snd-soc-fsl-ssi snd-soc-imx-pcm)
+endif
   DEPENDS:=@TARGET_imx6 +kmod-sound-soc-core
   $(call AddDepends/sound)
 endef

--- a/package/kernel/linux/modules/usb.mk
+++ b/package/kernel/linux/modules/usb.mk
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2006-2014 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -36,6 +36,182 @@
 endef
 
 
+define KernelPackage/usb-musb-hdrc
+  TITLE:=Support for Mentor Graphics silicon dual role USB
+  KCONFIG:= \
+	CONFIG_USB_MUSB_HDRC \
+	CONFIG_USB_INVENTRA_DMA=n \
+	CONFIG_USB_TI_CPPI41_DMA=n \
+	CONFIG_MUSB_PIO_ONLY=y \
+	CONFIG_USB_MUSB_DUAL_ROLE=y \
+	CONFIG_USB_MUSB_GADGET=n \
+	CONFIG_USB_MUSB_HOST=n \
+	CONFIG_USB_MUSB_DEBUG=y
+  DEPENDS:= \
+	@(TARGET_omap||TARGET_omap24xx) +kmod-usb-gadget \
+	+TARGET_omap24xx:kmod-usb-musb-tusb6010
+  FILES:=$(LINUX_DIR)/drivers/usb/musb/musb_hdrc.ko
+  AUTOLOAD:=$(call AutoLoad,46,musb_hdrc)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-musb-hdrc/description
+  Kernel support for Mentor Graphics silicon dual role USB device.
+endef
+
+$(eval $(call KernelPackage,usb-musb-hdrc))
+
+
+define KernelPackage/usb-musb-platformglue
+  TITLE:=MUSB platform glue layer
+  KCONFIG:= \
+	CONFIG_USB_MUSB_TUSB6010=n \
+	CONFIG_USB_MUSB_OMAP2PLUS=n \
+	CONFIG_USB_MUSB_AM35X=n \
+	CONFIG_USB_MUSB_DSPS \
+	CONFIG_USB_MUSB_UX500=n
+  DEPENDS:=@TARGET_omap +kmod-usb-phy-nop +kmod-usb-musb-hdrc +kmod-usb-phy-am335x
+  FILES:= \
+	$(LINUX_DIR)/drivers/usb/musb/musb_dsps.ko \
+	$(LINUX_DIR)/drivers/usb/musb/musb_am335x.ko
+  AUTOLOAD:=$(call AutoLoad,45,phy-omap-control musb_dsps musb_am335x)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-musb-platformglue/description
+  MUSB platform glue modules
+endef
+
+$(eval $(call KernelPackage,usb-musb-platformglue))
+
+
+define KernelPackage/usb-musb-tusb6010
+  TITLE:=Support for TUSB 6010
+  KCONFIG:=CONFIG_USB_MUSB_TUSB6010
+  DEPENDS:=@TARGET_omap24xx
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-musb-tusb6010/description
+  TUSB6010 support
+endef
+
+$(eval $(call KernelPackage,usb-musb-tusb6010))
+
+
+define KernelPackage/usb-phy-nop
+  TITLE:=Support for USB NOP transceiver
+  KCONFIG:=CONFIG_NOP_USB_XCEIV
+ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/phy/phy-generic.ko),)
+  FILES:=$(LINUX_DIR)/drivers/usb/phy/phy-generic.ko
+  AUTOLOAD:=$(call AutoLoad,43,phy-generic)
+else
+ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/phy/phy-nop.ko),)
+  FILES:=$(LINUX_DIR)/drivers/usb/phy/phy-nop.ko
+  AUTOLOAD:=$(call AutoLoad,43,phy-nop)
+else
+  FILES:=$(LINUX_DIR)/drivers/usb/otg/nop-usb-xceiv.ko
+  AUTOLOAD:=$(call AutoLoad,43,nop-usb-xceiv)
+endif
+endif
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-phy-nop/description
+  Support for USB NOP transceiver
+endef
+
+$(eval $(call KernelPackage,usb-phy-nop))
+
+
+define KernelPackage/usb-phy-am335x
+  TITLE:=Support for AM335x USB PHY
+  KCONFIG:= \
+	CONFIG_AM335X_PHY_USB \
+	CONFIG_AM335X_CONTROL_USB
+  DEPENDS:=@TARGET_omap +kmod-usb-phy-nop
+  FILES:= \
+	$(LINUX_DIR)/drivers/usb/phy/phy-am335x.ko \
+	$(LINUX_DIR)/drivers/usb/phy/phy-am335x-control.ko
+  AUTOLOAD:=$(call AutoLoad,44,phy-am335x)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-phy-am335x/description
+  Support for AM335x USB PHY
+endef
+
+$(eval $(call KernelPackage,usb-phy-am335x))
+
+
+define KernelPackage/usb-phy-omap-usb2
+  TITLE:=Support for OMAP2 USB PHY
+  KCONFIG:= \
+	CONFIG_OMAP_USB2 \
+	CONFIG_OMAP_CONTROL_USB
+  DEPENDS:=@TARGET_omap
+  FILES:= \
+	$(LINUX_DIR)/drivers/phy/phy-omap-usb2.ko \
+	$(LINUX_DIR)/drivers/usb/phy/phy-omap-control.ko
+  AUTOLOAD:=$(call AutoLoad,45,phy-omap-control phy-omap-usb2)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-phy-omap-usb2/description
+  Support for AM335x USB PHY
+endef
+
+$(eval $(call KernelPackage,usb-phy-omap-usb2))
+
+
+define KernelPackage/usb-phy-omap-usb3
+  TITLE:=Support for OMAP USB3 PHY
+  KCONFIG:=CONFIG_OMAP_USB3
+  DEPENDS:=@TARGET_omap
+  FILES:=$(LINUX_DIR)/drivers/usb/phy/phy-omap-usb3.ko
+  AUTOLOAD:=$(call AutoLoad,45,phy-omap-usb3)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-phy-omap-usb3/description
+  Support for OMAP USB3 PHY
+endef
+
+$(eval $(call KernelPackage,usb-phy-omap-usb3))
+
+
+define KernelPackage/usb-phy-twl4030
+  TITLE:=Support for TWL4030 OTG PHY
+  KCONFIG:=CONFIG_TWL4030_USB
+  DEPENDS:=@TARGET_omap +kmod-usb-phy-omap-usb2 +kmod-usb-musb-hdrc
+  FILES:=$(LINUX_DIR)/drivers/phy/phy-twl4030-usb.ko
+  AUTOLOAD:=$(call AutoLoad,45,phy-twl4030-usb)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-phy-twl4030/description
+  Support for TWL4030/TWL5030/TPS659x0 OTG PHY
+endef
+
+$(eval $(call KernelPackage,usb-phy-twl4030))
+
+
+define KernelPackage/usb-phy-twl6030
+  TITLE:=Support for TWL6030 OTG PHY
+  KCONFIG:=CONFIG_TWL6030_USB
+  DEPENDS:=@TARGET_omap +kmod-usb-phy-omap-usb2 +kmod-usb-musb-hdrc
+  FILES:=$(LINUX_DIR)/drivers/usb/phy/phy-twl6030-usb.ko
+  AUTOLOAD:=$(call AutoLoad,45,phy-twl6030-usb)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-phy-twl6030/description
+  Support for TWL6030 OTG PHY
+endef
+
+$(eval $(call KernelPackage,usb-phy-twl6030))
+
+
 define KernelPackage/usb-gadget
   TITLE:=USB Gadget support
   KCONFIG:=CONFIG_USB_GADGET
@@ -72,10 +248,21 @@
   KCONFIG:= \
 	CONFIG_USB_ETH \
 	CONFIG_USB_ETH_RNDIS=y \
-	CONFIG_USB_ETH_EEM=y
+	CONFIG_USB_ETH_EEM=n
   DEPENDS:=+kmod-usb-gadget +(!LINUX_3_3&&!LINUX_3_6):kmod-usb-lib-composite
+ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/gadget/u_ether.ko),)
+  FILES:= \
+	$(LINUX_DIR)/drivers/usb/gadget/u_ether.ko \
+	$(LINUX_DIR)/drivers/usb/gadget/u_rndis.ko \
+	$(LINUX_DIR)/drivers/usb/gadget/usb_f_ecm.ko \
+	$(LINUX_DIR)/drivers/usb/gadget/usb_f_ecm_subset.ko \
+	$(LINUX_DIR)/drivers/usb/gadget/usb_f_rndis.ko \
+	$(LINUX_DIR)/drivers/usb/gadget/g_ether.ko
+  AUTOLOAD:=$(call AutoLoad,52,usb_f_ecm g_ether)
+else
   FILES:=$(LINUX_DIR)/drivers/usb/gadget/g_ether.ko
   AUTOLOAD:=$(call AutoLoad,52,g_ether)
+endif
   $(call AddDepends/usb)
 endef
 
@@ -144,11 +331,28 @@
 $(eval $(call KernelPackage,usb2-fsl))
 
 
+define KernelPackage/usb2-omap
+  TITLE:=Support for USB2 for OMAP
+  DEPENDS:=@TARGET_omap +kmod-usb-phy-nop +kmod-usb-phy-am335x
+  KCONFIG:=CONFIG_USB_EHCI_HCD_OMAP
+  FILES:=$(LINUX_DIR)/drivers/usb/host/ehci-omap.ko
+  AUTOLOAD:=$(call AutoLoad,39,ehci-omap)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb2-omap/description
+ Kernel support for OMAP USB2 (EHCI) controllers
+endef
+
+$(eval $(call KernelPackage,usb2-omap))
+
+
 define KernelPackage/usb2
   TITLE:=Support for USB2 controllers
   DEPENDS:=\
 	+TARGET_brcm47xx:kmod-usb-brcm47xx \
-	+TARGET_mpc85xx:kmod-usb2-fsl
+	+TARGET_mpc85xx:kmod-usb2-fsl \
+	+TARGET_omap:kmod-usb2-omap
   KCONFIG:=\
 	CONFIG_USB_EHCI_HCD \
 	CONFIG_USB_EHCI_ATH79=y \
@@ -179,7 +383,7 @@
 
 define KernelPackage/usb2-pci
   TITLE:=Support for PCI USB2 controllers
-  DEPENDS:=@PCI_SUPPORT @(LINUX_3_8||LINUX_3_9||LINUX_3_10) +kmod-usb2
+  DEPENDS:=@PCI_SUPPORT @(!LINUX_3_3&&!LINUX_3_6) +kmod-usb2
   KCONFIG:=CONFIG_USB_EHCI_PCI
   FILES:=$(LINUX_DIR)/drivers/usb/host/ehci-pci.ko
   AUTOLOAD:=$(call AutoLoad,42,ehci-pci,1)
@@ -195,7 +399,7 @@
 
 define KernelPackage/usb-dwc2
   TITLE:=DWC2 USB controller driver
-  DEPENDS:=@LINUX_3_10
+  DEPENDS:=@(!LINUX_3_3&&!LINUX_3_6&&!LINUX_3_8&&!LINUX_3_9)
   KCONFIG:= \
 	CONFIG_USB_DWC2 \
 	CONFIG_USB_DWC2_DEBUG=n \
@@ -735,7 +939,8 @@
 
 define KernelPackage/usb-net
   TITLE:=Kernel modules for USB-to-Ethernet convertors
-  KCONFIG:=CONFIG_USB_USBNET CONFIG_MII=y
+  DEPENDS:=+kmod-mii
+  KCONFIG:=CONFIG_USB_USBNET
   AUTOLOAD:=$(call AutoProbe,usbnet)
   FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/usbnet.ko
   $(call AddDepends/usb)
@@ -832,6 +1037,21 @@
 $(eval $(call KernelPackage,usb-net-mcs7830))
 
 
+define KernelPackage/usb-net-smsc95xx
+  TITLE:=SMSC LAN95XX based USB 2.0 10/100 ethernet devices
+  KCONFIG:=CONFIG_USB_NET_SMSC95XX
+  FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/smsc95xx.ko
+  AUTOLOAD:=$(call AutoProbe,smsc95xx)
+  $(call AddDepends/usb-net, +(!LINUX_3_3&&!LINUX_3_6):kmod-lib-crc16)
+endef
+
+define KernelPackage/usb-net-smsc95xx/description
+ Kernel module for SMSC LAN95XX based devices
+endef
+
+$(eval $(call KernelPackage,usb-net-smsc95xx))
+
+
 define KernelPackage/usb-net-dm9601-ether
   TITLE:=Support for DM9601 ethernet connections
   KCONFIG:=CONFIG_USB_NET_DM9601
@@ -953,6 +1173,21 @@
 $(eval $(call KernelPackage,usb-net-ipheth))
 
 
+define KernelPackage/usb-net-kalmia
+  TITLE:=Samsung Kalmia based LTE USB modem
+  KCONFIG:=CONFIG_USB_NET_KALMIA
+  FILES:=$(LINUX_DIR)/drivers/net/usb/kalmia.ko
+  AUTOLOAD:=$(call AutoProbe,kalmia)
+  $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-kalmia/description
+ Kernel support for Samsung Kalmia based LTE USB modem
+endef
+
+$(eval $(call KernelPackage,usb-net-kalmia))
+
+
 define KernelPackage/usb-hid
   TITLE:=Support for USB Human Input Devices
   KCONFIG:=CONFIG_HID_SUPPORT=y CONFIG_USB_HID CONFIG_USB_HIDDEV=y
@@ -1063,11 +1298,19 @@
 	CONFIG_USB_CHIPIDEA_HOST=y \
 	CONFIG_USB_CHIPIDEA_UDC=n \
 	CONFIG_USB_CHIPIDEA_DEBUG=y
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),lt,3.11.0)),1)
   FILES:=\
 	$(LINUX_DIR)/drivers/usb/chipidea/ci_hdrc.ko \
 	$(if $(CONFIG_OF_DEVICE),$(LINUX_DIR)/drivers/usb/chipidea/ci13xxx_imx.ko) \
 	$(if $(CONFIG_OF_DEVICE),$(LINUX_DIR)/drivers/usb/chipidea/usbmisc_imx$(if $(call kernel_patchver_le,3.9),6q).ko)
   AUTOLOAD:=$(call AutoLoad,51,ci_hdrc $(if $(CONFIG_OF_DEVICE),ci13xxx_imx usbmisc_imx$(if $(call kernel_patchver_le,3.9),6q)),1)
+else
+  FILES:=\
+	$(LINUX_DIR)/drivers/usb/chipidea/ci_hdrc.ko \
+	$(if $(CONFIG_OF),$(LINUX_DIR)/drivers/usb/chipidea/ci_hdrc_imx.ko) \
+	$(if $(CONFIG_OF),$(LINUX_DIR)/drivers/usb/chipidea/usbmisc_imx.ko)
+  AUTOLOAD:=$(call AutoLoad,51,ci_hdrc $(if $(CONFIG_OF),ci_hdrc_imx usbmisc_imx),1)
+endif
   $(call AddDepends/usb)
 endef
   
@@ -1109,3 +1352,22 @@
 
 $(eval $(call KernelPackage,usbmon))
 
+
+define KernelPackage/usb3
+  TITLE:=Support for USB3 controllers
+  DEPENDS:=+TARGET_omap:kmod-usb-phy-omap-usb3
+  KCONFIG:= \
+	CONFIG_USB_XHCI_HCD \
+	CONFIG_USB_XHCI_HCD_DEBUGGING=n
+  FILES:= \
+	$(LINUX_DIR)/drivers/usb/host/xhci-hcd.ko
+  AUTOLOAD:=$(call AutoLoad,54,xhci-hcd,1)
+  $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb3/description
+ Kernel support for USB3 (XHCI) controllers
+endef
+
+$(eval $(call KernelPackage,usb3))
+

--- a/package/kernel/linux/modules/virtual.mk
+++ b/package/kernel/linux/modules/virtual.mk
@@ -54,10 +54,27 @@
 
 $(eval $(call KernelPackage,virtio-random))
 
+
+define KernelPackage/xen-privcmd
+  SUBMENU:=$(VIRTUAL_MENU)
+  TITLE:=Xen private commands
+  DEPENDS:=@TARGET_x86_xen_domu
+  KCONFIG:=CONFIG_XEN_PRIVCMD
+  FILES:=$(LINUX_DIR)/drivers/xen/xen-privcmd.ko
+  AUTOLOAD:=$(call AutoLoad,04,xen-privcmd)
+endef
+
+define KernelPackage/xen-privcmd/description
+ Kernel module for Xen private commands
+endef
+
+$(eval $(call KernelPackage,xen-privcmd))
+
+
 define KernelPackage/xen-fs
   SUBMENU:=$(VIRTUAL_MENU)
   TITLE:=Xen filesystem
-  DEPENDS:=@TARGET_x86_xen_domu
+  DEPENDS:=@TARGET_x86_xen_domu +kmod-xen-privcmd
   KCONFIG:= \
   	CONFIG_XENFS \
   	CONFIG_XEN_COMPAT_XENFS=y

--- a/package/kernel/mac80211/Makefile
+++ b/package/kernel/mac80211/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2007-2012 OpenWrt.org
+# Copyright (C) 2007-2013 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -10,11 +10,11 @@
 
 PKG_NAME:=mac80211
 
-PKG_VERSION:=2013-06-27
+PKG_VERSION:=2014-01-23.1
 PKG_RELEASE:=1
 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
-PKG_BACKPORT_VERSION:=.1
-PKG_MD5SUM:=73bd220c64c5c6fdc22b3bb7f180644f
+PKG_BACKPORT_VERSION:=
+PKG_MD5SUM:=8db16edbdaf4abc2e9c2f3b6c86736a6
 
 PKG_SOURCE:=compat-wireless-$(PKG_VERSION)$(PKG_BACKPORT_VERSION).tar.bz2
 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION)
@@ -24,12 +24,12 @@
 
 PKG_DRIVERS = \
 	adm8211 ath5k libertas-usb libertas-sd p54-common p54-pci p54-usb p54-spi \
-	rt2x00-lib rt2x00-pci rt2x00-usb rt2x00-soc rt2800-lib rt2400-pci \
-	rt2500-pci rt2500-usb rt61-pci rt73-usb rt2800-pci rt2800-usb \
+	rt2x00-lib rt2x00-pci rt2x00-usb rt2800-lib rt2400-pci rt2500-pci \
+	rt2500-usb rt61-pci rt73-usb rt2800-mmio rt2800-pci rt2800-usb rt2800-soc \
 	rtl8180 rtl8187 zd1211rw mac80211-hwsim carl9170 b43 b43legacy \
 	ath9k-common ath9k ath9k-htc ath10k ath net-libipw net-ipw2100 net-ipw2200 \
 	mwl8k net-hermes net-hermes-pci net-hermes-plx net-hermes-pcmcia \
-	iwl-legacy iwl3945 iwl4965 iwlagn wl12xx lib80211 \
+	iwl-legacy iwl3945 iwl4965 iwlagn wlcore wl12xx wl18xx lib80211 \
 	rtlwifi rtlwifi-pci rtlwifi-usb rtl8192c-common rtl8192ce rtl8192se \
 	rtl8192de rtl8192cu
 
@@ -72,7 +72,7 @@
 define KernelPackage/mac80211
   $(call KernelPackage/mac80211/Default)
   TITLE:=Linux 802.11 Wireless Networking Stack
-  DEPENDS+= +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-aes +kmod-cfg80211
+  DEPENDS+= +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-aes +kmod-cfg80211 +hostapd-common
   KCONFIG:=\
 	CONFIG_AVERAGE=y
   FILES:= $(PKG_BUILD_DIR)/net/mac80211/mac80211.ko
@@ -103,12 +103,12 @@
 endef
 
 PKG_LINUX_FIRMWARE_NAME:=linux-firmware
-PKG_LINUX_FIRMWARE_VERSION:=6942dba419d2ebf8c15514972e89734fd7a8cebc
+PKG_LINUX_FIRMWARE_VERSION:=7d0c7a8cfd78388d90cc784a185b19dcbdbce824
 PKG_LINUX_FIRMWARE_SOURCE:=$(PKG_LINUX_FIRMWARE_NAME)-$(PKG_LINUX_FIRMWARE_VERSION).tar.bz2
 PKG_LINUX_FIRMWARE_PROTO:=git
 PKG_LINUX_FIRMWARE_SOURCE_URL:=git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
 PKG_LINUX_FIRMWARE_SUBDIR:=$(PKG_LINUX_FIRMWARE_NAME)-$(PKG_LINUX_FIRMWARE_VERSION)
-PKG_LINUX_FIRMWARE_MIRROR_MD5SUM:=a5f8c27af9e43f0ad24d7f821c5a781e
+PKG_LINUX_FIRMWARE_MIRROR_MD5SUM:=837a1a9456c1ec8b428cc0b2b08a331b
 
 define Download/linux-firmware
   FILE:=$(PKG_LINUX_FIRMWARE_SOURCE)
@@ -122,7 +122,7 @@
 $(eval $(call Download,linux-firmware))
 
 PKG_ATH10K_LINUX_FIRMWARE_NAME:=ath10k-firmware
-PKG_ATH10K_LINUX_FIRMWARE_VERSION:=9374d42c01bd84487855af9f9bffc622c50e7331
+PKG_ATH10K_LINUX_FIRMWARE_VERSION:=d86e78e5c6be34329936c8bd73a212700437be2e
 PKG_ATH10K_LINUX_FIRMWARE_SOURCE:=$(PKG_ATH10K_LINUX_FIRMWARE_NAME)-$(PKG_ATH10K_LINUX_FIRMWARE_VERSION).tar.bz2
 PKG_ATH10K_LINUX_FIRMWARE_PROTO:=git
 PKG_ATH10K_LINUX_FIRMWARE_SOURCE_URL:=https://github.com/kvalo/ath10k-firmware.git
@@ -263,15 +263,6 @@
   AUTOLOAD:=$(call AutoProbe,rt2x00usb)
 endef
 
-define KernelPackage/rt2x00-soc
-$(call KernelPackage/rt2x00/Default)
-  DEPENDS+=@TARGET_ramips_rt305x +kmod-rt2x00-mmio +kmod-rt2x00-lib
-  HIDDEN:=1
-  TITLE+= (SoC)
-  FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00soc.ko
-  AUTOLOAD:=$(call AutoProbe,rt2x00soc)
-endef
-
 define KernelPackage/rt2800-lib
 $(call KernelPackage/rt2x00/Default)
   DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +kmod-lib-crc-ccitt +@DRIVER_11N_SUPPORT
@@ -320,9 +311,27 @@
   AUTOLOAD:=$(call AutoProbe,rt73usb)
 endef
 
+define KernelPackage/rt2800-mmio
+$(call KernelPackage/rt2x00/Default)
+  TITLE += (RT28xx/RT3xxx MMIO)
+  DEPENDS += +kmod-rt2800-lib +kmod-rt2x00-mmio
+  HIDDEN:=1
+  FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800mmio.ko
+endef
+
+define KernelPackage/rt2800-soc
+$(call KernelPackage/rt2x00/Default)
+  DEPENDS += @TARGET_ramips_rt305x +kmod-rt2800-mmio +kmod-rt2800-lib
+  TITLE += (RT28xx/RT3xxx SoC)
+  FILES := \
+	$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00soc.ko \
+	$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800soc.ko
+  AUTOLOAD:=$(call AutoProbe,rt2800soc)
+endef
+
 define KernelPackage/rt2800-pci
 $(call KernelPackage/rt2x00/Default)
-  DEPENDS+= @(PCI_SUPPORT||TARGET_ramips_rt305x) +PCI_SUPPORT:kmod-rt2x00-pci +kmod-rt2800-lib +kmod-lib-crc-ccitt +TARGET_ramips_rt305x:kmod-rt2x00-soc
+  DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci +kmod-rt2800-lib +kmod-rt2800-mmio
   TITLE+= (RT2860 PCI)
   FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800pci.ko
   AUTOLOAD:=$(call AutoProbe,rt2800pci)
@@ -632,7 +641,7 @@
 
 define KernelPackage/libertas-sd
   $(call KernelPackage/mac80211/Default)
-  DEPENDS+= +kmod-cfg80211 +kmod-lib80211 +kmod-mmc +@DRIVER_WEXT_SUPPORT
+  DEPENDS+= +kmod-cfg80211 +kmod-lib80211 +kmod-mmc +@DRIVER_WEXT_SUPPORT @!TARGET_uml
   TITLE:=Marvell 88W8686 Wireless Driver
   FILES:= \
 	$(PKG_BUILD_DIR)/drivers/net/wireless/libertas/libertas.ko \
@@ -912,21 +921,46 @@
 endef
 
 
+define KernelPackage/wlcore
+  $(call KernelPackage/mac80211/Default)
+  TITLE:=TI common driver part
+  DEPENDS+= @TARGET_omap +kmod-mac80211 +@DRIVER_11N_SUPPORT
+  FILES:= \
+	$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore.ko \
+	$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore_sdio.ko
+  AUTOLOAD:=$(call AutoProbe,wlcore wlcore_sdio)
+endef
+
+define KernelPackage/wlcore/description
+ This module contains some common parts needed by TI Wireless drivers.
+endef
+
 define KernelPackage/wl12xx
   $(call KernelPackage/mac80211/Default)
   TITLE:=Driver for TI WL12xx
   URL:=http://wireless.kernel.org/en/users/Drivers/wl12xx
-  DEPENDS+= @TARGET_omap +kmod-mac80211
-  FILES:= \
-	$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wl12xx/wl12xx.ko \
-	$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore.ko \
-	$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore_sdio.ko
-  AUTOLOAD:=$(call AutoProbe,wlcore wlcore_sdio wl12xx)
+  DEPENDS+= +kmod-wlcore
+  FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wl12xx/wl12xx.ko
+  AUTOLOAD:=$(call AutoProbe,wl12xx)
 endef
 
 define KernelPackage/wl12xx/description
  Kernel modules for TI WL12xx
 endef
+
+define KernelPackage/wl18xx
+  $(call KernelPackage/mac80211/Default)
+  TITLE:=Driver for TI WL18xx
+  URL:=http://wireless.kernel.org/en/users/Drivers/wl18xx
+  DEPENDS+= +kmod-wlcore
+  FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ti/wl18xx/wl18xx.ko
+  AUTOLOAD:=$(call AutoProbe,wl18xx)
+endef
+
+define KernelPackage/wl18xx/description
+ Kernel modules for TI WL18xx
+endef
+
 
 #Broadcom firmware
 ifneq ($(CONFIG_B43_FW_5_10),)
@@ -1365,7 +1399,6 @@
 config-$(call config_package,rt2x00-pci) += RT2X00_LIB_PCI
 config-$(call config_package,rt2x00-mmio) += RT2X00_LIB_MMIO
 config-$(call config_package,rt2x00-usb) += RT2X00_LIB_USB
-config-$(call config_package,rt2x00-soc) += RT2X00_LIB_SOC
 config-$(CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS) += RT2X00_LIB_DEBUGFS
 config-$(CONFIG_PACKAGE_RT2X00_DEBUG) += RT2X00_DEBUG
 
@@ -1377,6 +1410,7 @@
 
 config-$(call config_package,rt2800-lib) += RT2800_LIB
 
+config-$(call config_package,rt2800-soc) += RT2800SOC
 config-$(call config_package,rt2800-pci) += RT2800PCI
 config-y += RT2800PCI_RT33XX RT2800PCI_RT35XX RT2800PCI_RT53XX RT2800PCI_RT3290
 
@@ -1409,8 +1443,10 @@
 config-$(call config_package,mwl8k) += MWL8K
 config-$(call config_package,rtl8180) += RTL8180
 config-$(call config_package,rtl8187) += RTL8187
-config-$(call config_package,wl12xx) += WLCORE WLCORE_SDIO WL12XX
-config-y += WL_TI
+config-$(call config_package,wlcore) += WLCORE WLCORE_SDIO
+config-$(call config_package,wl12xx) += WL12XX
+config-$(call config_package,wl18xx) += WL18XX
+config-y += WL_TI WILINK_PLATFORM_DATA
 config-$(call config_package,zd1211rw) += ZD1211RW
 
 config-$(call config_package,rtlwifi) += RTL_CARDS RTLWIFI
@@ -1528,8 +1564,9 @@
 endef
 
 define KernelPackage/cfg80211/install
-	$(INSTALL_DIR) $(1)/lib/wifi
+	$(INSTALL_DIR) $(1)/lib/wifi $(1)/lib/netifd/wireless
 	$(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi
+	$(INSTALL_BIN) ./files/lib/netifd/wireless/mac80211.sh $(1)/lib/netifd/wireless
 endef
 
 define KernelPackage/p54-pci/install
@@ -1581,9 +1618,21 @@
 		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl127x-fw-5-plt.bin \
 		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl127x-fw-5-sr.bin \
 		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl1271-nvs.bin \
+		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl128x-fw-5-mr.bin \
+		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl128x-fw-5-plt.bin \
+		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl128x-fw-5-sr.bin \
+		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl128x-nvs.bin \
 		$(1)/lib/firmware/ti-connectivity
 endef
 
+define KernelPackage/wl18xx/install
+	$(INSTALL_DIR) $(1)/lib/firmware/ti-connectivity
+	$(INSTALL_DATA) \
+		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl18xx-conf.bin \
+		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl18xx-fw.bin \
+		$(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl18xx-fw-2.bin \
+		$(1)/lib/firmware/ti-connectivity
+endef
 
 define KernelPackage/zd1211rw/install
 	$(INSTALL_DIR) $(1)/lib/firmware/zd1211
@@ -1607,8 +1656,7 @@
 	$(INSTALL_DIR) $(1)/lib/firmware/ath10k/QCA988X/hw2.0
 	$(INSTALL_DATA) \
 		$(PKG_BUILD_DIR)/$(PKG_ATH10K_LINUX_FIRMWARE_SUBDIR)/ath10k/QCA988X/hw2.0/board.bin \
-		$(PKG_BUILD_DIR)/$(PKG_ATH10K_LINUX_FIRMWARE_SUBDIR)/ath10k/QCA988X/hw2.0/firmware.bin \
-		$(PKG_BUILD_DIR)/$(PKG_ATH10K_LINUX_FIRMWARE_SUBDIR)/ath10k/QCA988X/hw2.0/otp.bin \
+		$(PKG_BUILD_DIR)/$(PKG_ATH10K_LINUX_FIRMWARE_SUBDIR)/ath10k/QCA988X/hw2.0/firmware-2.bin \
 		$(1)/lib/firmware/ath10k/QCA988X/hw2.0/
 endef
 
@@ -1748,13 +1796,14 @@
 $(eval $(call KernelPackage,rt2x00-mmio))
 $(eval $(call KernelPackage,rt2x00-pci))
 $(eval $(call KernelPackage,rt2x00-usb))
-$(eval $(call KernelPackage,rt2x00-soc))
 $(eval $(call KernelPackage,rt2800-lib))
 $(eval $(call KernelPackage,rt2400-pci))
 $(eval $(call KernelPackage,rt2500-pci))
 $(eval $(call KernelPackage,rt2500-usb))
 $(eval $(call KernelPackage,rt61-pci))
 $(eval $(call KernelPackage,rt73-usb))
+$(eval $(call KernelPackage,rt2800-mmio))
+$(eval $(call KernelPackage,rt2800-soc))
 $(eval $(call KernelPackage,rt2800-pci))
 $(eval $(call KernelPackage,rt2800-usb))
 $(eval $(call KernelPackage,rtl8180))
@@ -1792,5 +1841,7 @@
 $(eval $(call KernelPackage,net-hermes-pci))
 $(eval $(call KernelPackage,net-hermes-plx))
 $(eval $(call KernelPackage,net-hermes-pcmcia))
+$(eval $(call KernelPackage,wlcore))
 $(eval $(call KernelPackage,wl12xx))
-
+$(eval $(call KernelPackage,wl18xx))
+

--- /dev/null
+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
@@ -1,1 +1,612 @@
-
+#!/bin/sh
+. /lib/netifd/netifd-wireless.sh
+. /lib/netifd/hostapd.sh
+
+init_wireless_driver "$@"
+
+MP_CONFIG_INT="mesh_retry_timeout mesh_confirm_timeout mesh_holding_timeout mesh_max_peer_links
+	       mesh_max_retries mesh_ttl mesh_element_ttl mesh_hwmp_max_preq_retries
+	       mesh_path_refresh_time mesh_min_discovery_timeout mesh_hwmp_active_path_timeout
+	       mesh_hwmp_preq_min_interval mesh_hwmp_net_diameter_traversal_time mesh_hwmp_rootmode
+	       mesh_hwmp_rann_interval mesh_gate_announcements mesh_sync_offset_max_neighor
+	       mesh_rssi_threshold mesh_hwmp_active_path_to_root_timeout mesh_hwmp_root_interval
+	       mesh_hwmp_confirmation_interval mesh_awake_window mesh_plink_timeout"
+MP_CONFIG_BOOL="mesh_auto_open_plinks mesh_fwding"
+MP_CONFIG_STRING="mesh_power_mode"
+
+drv_mac80211_init_device_config() {
+	hostapd_common_add_device_config
+
+	config_add_string path phy 'macaddr:macaddr'
+	config_add_string hwmode
+	config_add_int beacon_int chanbw frag rts
+	config_add_int rxantenna txantenna antenna_gain txpower distance
+	config_add_boolean noscan
+	config_add_array ht_capab
+	config_add_boolean \
+		rxldpc \
+		short_gi_80 \
+		short_gi_160 \
+		tx_stbc_2by1 \
+		su_beamformer \
+		su_beamformee \
+		mu_beamformer \
+		mu_beamformee \
+		vht_txop_ps \
+		htc_vht \
+		rx_antenna_pattern \
+		tx_antenna_pattern
+	config_add_int vht_max_mpdu vht_max_rx_stbc vht_link_adapt vht160
+}
+
+drv_mac80211_init_iface_config() {
+	hostapd_common_add_bss_config
+
+	config_add_string 'macaddr:macaddr' ifname
+
+	config_add_boolean wds powersave
+	config_add_int maxassoc
+	config_add_int max_listen_int
+	config_add_int dtim_interval
+
+	# mesh
+	config_add_int $MP_CONFIG_INT
+	config_add_boolean $MP_CONFIG_BOOL
+	config_add_string $MP_CONFIG_STRING
+}
+
+mac80211_hostapd_setup_base() {
+	local phy="$1"
+
+	json_select config
+
+	[ "$auto_channel" -gt 0 ] && channel=acs_survey
+
+	[ "$enable_ht" -gt 0 ] && {
+		json_get_vars noscan htmode
+		json_get_values ht_capab_list ht_capab
+
+		append base_cfg "ieee80211n=1" "$N"
+
+		ht_capab=
+		case "$htmode" in
+			HT20|HT40-|HT40+) ht_capab="[$htmode]";;
+			VHT40|VHT80|VHT160)
+				case "$channel" in
+					36|44|52|60|100|108|116|124|132|140|149|157) ht_capab="[HT40+]";;
+					40|48|56|64|104|112|120|128|136|144|153|161) ht_capab="[HT40-]";;
+				esac
+				;;
+		esac
+		for cap in $ht_capab_list; do
+			ht_capab="$ht_capab[$cap]"
+		done
+
+		[ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N"
+
+		# 802.11ac
+		enable_ac=0
+		idx="$channel"
+		case "$htmode" in
+			VHT40)
+				case "$channel" in
+					36|40) idx=38;;
+					44|48) idx=42;;
+					52|56) idx=54;;
+					60|64) idx=58;;
+					100|104) idx=102;;
+					108|112) idx=110;;
+					116|120) idx=118;;
+					124|128) idx=126;;
+					132|136) idx=134;;
+					140|144) idx=142;;
+					149|153) idx=151;;
+					157|161) idx=159;;
+				esac
+				enable_ac=1
+				append base_cfg "vht_oper_chwidth=0" "$N"
+				append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N"
+			;;
+			VHT80)
+				case "$channel" in
+					36|40|44|48) idx=42;;
+					52|56|60|64) idx=58;;
+					100|104|108|112) idx=106;;
+					116|120|124|128) idx=122;;
+					132|136|140|144) idx=138;;
+					149|153|157|161) idx=155;;
+				esac
+				enable_ac=1
+				append base_cfg "vht_oper_chwidth=1" "$N"
+				append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N"
+			;;
+			VHT160)
+				case "$channel" in
+					36|40|44|48|52|56|60|64) idx=50;;
+					100|104|108|112|116|120|124|128) idx=114;;
+				esac
+				enable_ac=1
+				append base_cfg "vht_oper_chwidth=2" "$N"
+				append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N"
+			;;
+		esac
+
+		if [ "$enable_ac" != "0" ]; then
+			json_get_vars \
+				rxldpc:1 \
+				short_gi_80:1 \
+				short_gi_160:1 \
+				tx_stbc_2by1:1 \
+				su_beamformer:1 \
+				su_beamformee:1 \
+				mu_beamformer:1 \
+				mu_beamformee:1 \
+				vht_txop_ps:1 \
+				htc_vht:1 \
+				rx_antenna_pattern:1 \
+				tx_antenna_pattern:1 \
+				vht_max_mpdu:11454 \
+				vht_max_rx_stbc:4 \
+				vht_link_adapt:3 \
+				vht160:2
+
+			append base_cfg "ieee80211ac=1" "$N"
+			vht_capab=""
+			vht_cap=0
+			for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
+				vht_cap="$(($vht_cap | $cap))"
+			done
+
+			# boolean
+			[ "$((($vht_cap & 16) * $rxldpc))" -eq 16 ] && \
+				vht_capab="$vht_capab[RXLDPC]"
+			[ "$((($vht_cap & 32) * $short_gi_80))" -eq 32 ] && \
+				vht_capab="$vht_capab[SHORT-GI-80]"
+			[ "$((($vht_cap & 64) * $short_gi_160))" -eq 64 ] && \
+				vht_capab="$vht_capab[SHORT-GI-160]"
+			[ "$((($vht_cap & 128) * $tx_stbc_2by1))" -eq 128 ] && \
+				vht_capab="$vht_capab[TX-STBC-2BY1]"
+			[ "$((($vht_cap & 2048) * $su_beamformer))" -eq 2048 ] && \
+				vht_capab="$vht_capab[SU-BEAMFORMER]"
+			[ "$((($vht_cap & 4096) * $su_beamformee))" -eq 4096 ] && \
+				vht_capab="$vht_capab[SU-BEAMFORMEE]"
+			[ "$((($vht_cap & 524288) * $mu_beamformer))" -eq 524288 ] && \
+				vht_capab="$vht_capab[MU-BEAMFORMER]"
+			[ "$((($vht_cap & 1048576) * $mu_beamformee))" -eq 1048576 ] && \
+				vht_capab="$vht_capab[MU-BEAMFORMEE]"
+			[ "$((($vht_cap & 2097152) * $vht_txop_ps))" -eq 2097152 ] && \
+				vht_capab="$vht_capab[VHT-TXOP-PS]"
+			[ "$((($vht_cap & 4194304) * $htc_vht))" -eq 4194304 ] && \
+				vht_capab="$vht_capab[HTC-VHT]"
+			[ "$((($vht_cap & 268435456) * $rx_antenna_pattern))" -eq 268435456 ] && \
+				vht_capab="$vht_capab[RX-ANTENNA-PATTERN]"
+			[ "$((($vht_cap & 536870912) * $tx_antenna_pattern))" -eq 536870912 ] && \
+				vht_capab="$vht_capab[TX-ANTENNA-PATTERN]"
+
+			# supported Channel widths
+			vht160_hw=0
+			[ "$(($vht_cap & 12))" -eq 4 -a 1 -le "$vht160" ] && \
+				vht160_hw=1
+			[ "$(($vht_cap & 12))" -eq 8 -a 2 -le "$vht160" ] && \
+				vht160_hw=2
+			[ "$vht160_hw" = 1 ] && vht_capab="$vht_capab[VHT160]"
+			[ "$vht160_hw" = 2 ] && vht_capab="$vht_capab[VHT160-80PLUS80]"
+
+			# maximum MPDU length
+			vht_max_mpdu_hw=3895
+			[ "$(($vht_cap & 3))" -ge 1 -a 7991 -le "$vht_max_mpdu" ] && \
+				vht_max_mpdu_hw=7991
+			[ "$(($vht_cap & 3))" -ge 2 -a 11454 -le "$vht_max_mpdu" ] && \
+				vht_max_mpdu_hw=11454
+			[ "$vht_max_mpdu_hw" != 3895 ] && \
+				vht_capab="$vht_capab[MAX-MPDU-$vht_max_mpdu_hw]"
+
+			# support for the reception of PPDUs using STBC
+			vht_max_rx_stbc_hw=0
+			[ "$(($vht_cap & 1792))" -ge 256 -a 1 -le "$vht_max_rx_stbc" ] && \
+				vht_max_rx_stbc_hw=1
+			[ "$(($vht_cap & 1792))" -ge 512 -a 2 -le "$vht_max_rx_stbc" ] && \
+				vht_max_rx_stbc_hw=2
+			[ "$(($vht_cap & 1792))" -ge 768 -a 3 -le "$vht_max_rx_stbc" ] && \
+				vht_max_rx_stbc_hw=3
+			[ "$(($vht_cap & 1792))" -ge 1024 -a 4 -le "$vht_max_rx_stbc" ] && \
+				vht_max_rx_stbc_hw=4
+			[ "$vht_max_rx_stbc_hw" = 1 ] && vht_capab="$vht_capab[RX-STBC-1]"
+			[ "$vht_max_rx_stbc_hw" = 2 ] && vht_capab="$vht_capab[RX-STBC-12]"
+			[ "$vht_max_rx_stbc_hw" = 3 ] && vht_capab="$vht_capab[RX-STBC-123]"
+			[ "$vht_max_rx_stbc_hw" = 4 ] && vht_capab="$vht_capab[RX-STBC-1234]"
+
+			# whether or not the STA supports link adaptation using VHT variant
+			vht_link_adapt_hw=0
+			[ "$(($vht_cap & 201326592))" -ge 134217728 -a 2 -le "$vht_link_adapt" ] && \
+				vht_link_adapt_hw=2
+			[ "$(($vht_cap & 201326592))" -ge 201326592 -a 3 -le "$vht_link_adapt" ] && \
+				vht_link_adapt_hw=3
+			[ "$vht_link_adapt_hw" != 0 ] && \
+				vht_capab="$vht_capab[VHT-LINK-ADAPT-$vht_link_adapt_hw]"
+
+			[ -n "$vht_capab" ] && append base_cfg "vht_capab=$vht_capab" "$N"
+		fi
+	}
+
+	hostapd_prepare_device_config "$hostapd_conf_file" nl80211
+	cat >> "$hostapd_conf_file" <<EOF
+${channel:+channel=$channel}
+${noscan:+noscan=$noscan}
+$base_cfg
+
+EOF
+	json_select ..
+}
+
+mac80211_hostapd_setup_bss() {
+	local phy="$1"
+	local ifname="$2"
+	local macaddr="$3"
+	local type="$4"
+
+	hostapd_cfg=
+	append hostapd_cfg "$type=$ifname" "$N"
+
+	hostapd_set_bss_options hostapd_cfg "$vif" || return 1
+	json_get_vars wds dtim_period max_listen_int
+
+	set_default wds 0
+
+	[ "$wds" -gt 0 ] && append hostapd_cfg "wds_sta=1" "$N"
+	[ "$staidx" -gt 0 ] && append hostapd_cfg "start_disabled=1" "$N"
+
+	cat >> /var/run/hostapd-$phy.conf <<EOF
+$hostapd_cfg
+bssid=$macaddr
+${dtim_period:+dtim_period=$dtim_period}
+${max_listen_int:+max_listen_interval=$max_listen_int}
+EOF
+}
+
+mac80211_generate_mac() {
+	local phy="$1"
+	local id="${macidx:-0}"
+
+	local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
+	local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)"
+
+	[ "$mask" = "00:00:00:00:00:00" ] && mask="ff:ff:ff:ff:ff:ff";
+	local oIFS="$IFS"; IFS=":"; set -- $mask; IFS="$oIFS"
+
+	local mask1=$1
+	local mask6=$6
+
+	local oIFS="$IFS"; IFS=":"; set -- $ref; IFS="$oIFS"
+
+	macidx=$(($id + 1))
+	[ "$((0x$mask1))" -gt 0 ] && {
+		b1="0x$1"
+		[ "$id" -gt 0 ] && \
+			b1=$(($b1 ^ ((($id - 1) << 2) | 0x2)))
+		printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6
+		return
+	}
+
+	[ "$((0x$mask6))" -lt 255 ] && {
+		printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $(( 0x$6 ^ $id ))
+		return
+	}
+
+	off2=$(( (0x$6 + $id) / 0x100 ))
+	printf "%s:%s:%s:%s:%02x:%02x" \
+		$1 $2 $3 $4 \
+		$(( (0x$5 + $off2) % 0x100 )) \
+		$(( (0x$6 + $id) % 0x100 ))
+}
+
+find_phy() {
+	[ -n "$phy" -a -d /sys/class/ieee80211/$phy ] && return 0
+	[ -n "$path" -a -d "/sys/devices/$path/ieee80211" ] && {
+		phy="$(ls /sys/devices/$path/ieee80211 | grep -m 1 phy)"
+		[ -n "$phy" ] && return 0
+	}
+	[ -n "$macaddr" ] && {
+		for phy in $(ls /sys/class/ieee80211 2>/dev/null); do
+			grep -i -q "$macaddr" "/sys/class/ieee80211/${phy}/macaddress" && return 0
+		done
+	}
+	return 1
+}
+
+mac80211_check_ap() {
+	has_ap=1
+}
+
+mac80211_prepare_vif() {
+	json_select config
+
+	json_get_vars ifname mode ssid wds powersave macaddr
+
+	[ -n "$ifname" ] || ifname="wlan${phy#phy}${if_idx:+-$if_idx}"
+	if_idx=$((${if_idx:-0} + 1))
+
+	set_default wds 0
+	set_default powersave 0
+
+	json_select ..
+
+	[ -n "$macaddr" ] || {
+		macaddr="$(mac80211_generate_mac $phy)"
+		macidx="$(($macidx + 1))"
+	}
+
+	json_add_object data
+	json_add_string ifname "$ifname"
+	json_close_object
+	json_select config
+
+	# It is far easier to delete and create the desired interface
+	case "$mode" in
+		adhoc)
+			iw phy "$phy" interface add "$ifname" type adhoc
+		;;
+		ap)
+			# Hostapd will handle recreating the interface and
+			# subsequent virtual APs belonging to the same PHY
+			if [ -n "$hostapd_ctrl" ]; then
+				type=bss
+			else
+				type=interface
+			fi
+
+			mac80211_hostapd_setup_bss "$phy" "$ifname" "$macaddr" "$type" || return
+
+			[ -n "$hostapd_ctrl" ] || {
+				iw phy "$phy" interface add "$ifname" type managed
+				hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}"
+			}
+		;;
+		mesh)
+			json_get_vars key mesh_id
+			if [ -n "$key" ]; then
+				iw phy "$phy" interface add "$ifname" type mp
+			else
+				iw phy "$phy" interface add "$ifname" type mp mesh_id "$mesh_id"
+			fi
+		;;
+		monitor)
+			iw phy "$phy" interface add "$ifname" type monitor
+		;;
+		sta)
+			local wdsflag=
+			staidx="$(($staidx + 1))"
+			[ "$wds" -gt 0 ] && wdsflag="4addr on"
+			iw phy "$phy" interface add "$ifname" type managed $wdsflag
+			[ "$powersave" -gt 0 ] && powersave="on" || powersave="off"
+			iw "$ifname" set power_save "$powersave"
+		;;
+	esac
+
+	case "$mode" in
+		monitor|mesh)
+			[ "$auto_channel" -gt 0 ] || iw dev "$ifname" set channel "$channel" $htmode
+		;;
+	esac
+
+	if [ "$mode" != "ap" ]; then
+		# ALL ap functionality will be passed to hostapd
+		# All interfaces must have unique mac addresses
+		# which can either be explicitly set in the device
+		# section, or automatically generated
+		ifconfig "$ifname" hw ether "$macaddr"
+	fi
+
+	json_select ..
+}
+
+mac80211_setup_supplicant() {
+	wpa_supplicant_prepare_interface "$ifname" nl80211 || return 1
+	wpa_supplicant_add_network "$ifname"
+	wpa_supplicant_run "$ifname" ${hostapd_ctrl:+-H $hostapd_ctrl}
+}
+
+mac80211_setup_adhoc() {
+	json_get_vars bssid ssid key mcast_rate
+
+	keyspec=
+	[ "$auth_type" == "wep" ] && {
+		set_default key 1
+		case "$key" in
+			[1234])
+				local idx
+				for idx in 1 2 3 4; do
+					json_get_var ikey "key$idx"
+
+					[ -n "$ikey" ] && {
+						ikey="$(($idx - 1)):$(prepare_key_wep "$ikey")"
+						[ $idx -eq $key ] && ikey="d:$ikey"
+						append keyspec "$ikey"
+					}
+				done
+			;;
+			*)
+				append keyspec "d:0:$(prepare_key_wep "$key")"
+			;;
+		esac
+	}
+
+	brstr=
+	for br in $basic_rate_list; do
+		hostapd_add_rate brstr "$br"
+	done
+
+	mcval=
+	[ -n "$mcast_rate" ] && hostapd_add_rate mcval "$mcast_rate"
+
+	iw dev "$ifname" ibss join "$ssid" $freq $htmode fixed-freq $bssid \
+		${beacon_int:+beacon-interval $beacon_int} \
+		${brstr:+basic-rates $brstr} \
+		${mcval:+mcast-rate $mcval} \
+		${keyspec:+keys $keyspec}
+}
+
+mac80211_setup_vif() {
+	local name="$1"
+
+	json_select data
+	json_get_vars ifname
+	json_select ..
+
+	json_select config
+	json_get_vars mode
+	json_get_var vif_txpower txpower
+
+	ifconfig "$ifname" up || {
+		wireless_setup_vif_failed IFUP_ERROR
+		json_select ..
+		return
+	}
+
+	set_default vif_txpower "$txpower"
+	[ -z "$vif_txpower" ] || iw dev "$ifname" set txpower fixed "${vif_txpower%%.*}00"
+
+	case "$mode" in
+		mesh)
+			for var in $MP_CONFIG_INT $MP_CONFIG_BOOL $MP_CONFIG_STRING; do
+				json_get_var mp_val "$var"
+				[ -n "$mp_val" ] && iw dev "$ifname" set mesh_param "$var" "$mp_val"
+			done
+			# todo: authsae
+		;;
+		adhoc)
+			wireless_vif_parse_encryption
+			if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then
+				mac80211_setup_supplicant || failed=1
+			else
+				mac80211_setup_adhoc
+			fi
+		;;
+		sta)
+			mac80211_setup_supplicant || failed=1
+		;;
+	esac
+
+	json_select ..
+	[ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
+}
+
+get_freq() {
+	local phy="$1"
+	local chan="$2"
+	iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
+}
+
+mac80211_interface_cleanup() {
+	local phy="$1"
+
+	for wdev in $(list_phy_interfaces "$phy"); do
+		ifconfig "$wdev" down 2>/dev/null
+		iw dev "$wdev" del
+	done
+}
+
+drv_mac80211_cleanup() {
+	hostapd_common_cleanup
+}
+
+drv_mac80211_setup() {
+	json_select config
+	json_get_vars \
+		phy macaddr path \
+		country chanbw distance \
+		txpower antenna_gain \
+		rxantenna txantenna \
+		frag rts beacon_int
+	json_get_values basic_rate_list basic_rate
+	json_select ..
+
+	find_phy || {
+		echo "Could not find PHY for device '$1'"
+		wireless_set_retry 0
+		return 1
+	}
+
+	wireless_set_data phy="$phy"
+	mac80211_interface_cleanup "$phy"
+
+	# convert channel to frequency
+	[ "$auto_channel" -gt 0 ] || freq="$(get_freq "$phy" "$channel")"
+
+	[ -n "$country" ] && {
+		iw reg get | grep -q "^country $country:" || {
+			iw reg set "$country"
+			sleep 1
+		}
+	}
+
+	hostapd_conf_file="/var/run/hostapd-$phy.conf"
+
+	no_ap=1
+	macidx=0
+	staidx=0
+
+	[ -n "$chanbw" ] && {
+		for file in /sys/kernel/debug/ieee80211/$phy/ath9k/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
+			[ -f "$file" ] && echo "$chanbw" > "$file"
+		done
+	}
+
+	set_default rxantenna all
+	set_default txantenna all
+	set_default distance 0
+	set_default antenna_gain 0
+
+	iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
+	iw phy "$phy" set antenna_gain $antenna_gain
+	iw phy "$phy" set distance "$distance"
+
+	[ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}"
+	[ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}"
+
+	has_ap=
+	hostapd_ctrl=
+	for_each_interface "ap" mac80211_check_ap
+
+	rm -f "$hostapd_conf_file"
+	[ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
+
+	for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
+	for_each_interface "ap" mac80211_prepare_vif
+
+	[ -n "$hostapd_ctrl" ] && {
+		/usr/sbin/hostapd -P /var/run/wifi-$phy.pid -B "$hostapd_conf_file"
+		ret="$?"
+		wireless_add_process "$(cat /var/run/wifi-$phy.pid)" "/usr/sbin/hostapd" 1
+		[ "$ret" != 0 ] && {
+			wireless_setup_failed HOSTAPD_START_FAILED
+			return
+		}
+	}
+
+	for_each_interface "ap sta adhoc mesh monitor" mac80211_setup_vif
+
+	wireless_set_up
+}
+
+list_phy_interfaces() {
+	local phy="$1"
+	if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then
+		ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null;
+	else
+		ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g'
+	fi
+}
+
+drv_mac80211_teardown() {
+	wireless_process_kill_all
+
+	json_select data
+	json_get_vars phy
+	json_select ..
+
+	mac80211_interface_cleanup "$phy"
+}
+
+add_driver mac80211
+

--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
@@ -1,168 +1,5 @@
 #!/bin/sh
 append DRIVERS "mac80211"
-
-mac80211_hostapd_setup_base() {
-	local phy="$1"
-	local ifname="$2"
-
-	cfgfile="/var/run/hostapd-$phy.conf"
-
-	config_get device "$vif" device
-	config_get country "$device" country
-	config_get hwmode "$device" hwmode
-	config_get channel "$device" channel
-	config_get beacon_int "$device" beacon_int
-	config_get basic_rate_list "$device" basic_rate
-	config_get_bool noscan "$device" noscan
-
-	hostapd_set_log_options base_cfg "$device"
-
-	[ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
-
-	[ "$channel" = auto ] && {
-		channel=$(iw phy "$phy" info | \
-			sed -ne '/MHz/ { /disabled\|passive\|radar/d; s/.*\[//; s/\].*//; p; q }')
-		config_set "$device" channel "$channel"
-	}
-
-	[ -n "$hwmode" ] && {
-		config_get hwmode_11n "$device" hwmode_11n
-		[ -n "$hwmode_11n" ] && {
-			hwmode="$hwmode_11n"
-			append base_cfg "ieee80211n=1" "$N"
-			config_get htmode "$device" htmode
-			config_get ht_capab_list "$device" ht_capab
-			case "$htmode" in
-				HT20|HT40+|HT40-) ht_capab="[$htmode]";;
-				*)ht_capab=;;
-			esac
-			for cap in $ht_capab_list; do
-				ht_capab="$ht_capab[$cap]"
-			done
-			[ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N"
-		}
-	}
-
-	local country_ie=0
-	[ -n "$country" ] && country_ie=1
-	config_get_bool country_ie "$device" country_ie "$country_ie"
-	[ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N"
-
-	local br brval brstr
-	[ -n "$basic_rate_list" ] && {
-		for br in $basic_rate_list; do
-			brval="$(($br / 100))"
-			[ -n "$brstr" ] && brstr="$brstr "
-			brstr="$brstr$brval"
-		done
-	}
-
-	cat >> "$cfgfile" <<EOF
-ctrl_interface=/var/run/hostapd-$phy
-driver=nl80211
-wmm_ac_bk_cwmin=4
-wmm_ac_bk_cwmax=10
-wmm_ac_bk_aifs=7
-wmm_ac_bk_txop_limit=0
-wmm_ac_bk_acm=0
-wmm_ac_be_aifs=3
-wmm_ac_be_cwmin=4
-wmm_ac_be_cwmax=10
-wmm_ac_be_txop_limit=0
-wmm_ac_be_acm=0
-wmm_ac_vi_aifs=2
-wmm_ac_vi_cwmin=3
-wmm_ac_vi_cwmax=4
-wmm_ac_vi_txop_limit=94
-wmm_ac_vi_acm=0
-wmm_ac_vo_aifs=2
-wmm_ac_vo_cwmin=2
-wmm_ac_vo_cwmax=3
-wmm_ac_vo_txop_limit=47
-wmm_ac_vo_acm=0
-tx_queue_data3_aifs=7
-tx_queue_data3_cwmin=15
-tx_queue_data3_cwmax=1023
-tx_queue_data3_burst=0
-tx_queue_data2_aifs=3
-tx_queue_data2_cwmin=15
-tx_queue_data2_cwmax=63
-tx_queue_data2_burst=0
-tx_queue_data1_aifs=1
-tx_queue_data1_cwmin=7
-tx_queue_data1_cwmax=15
-tx_queue_data1_burst=3.0
-tx_queue_data0_aifs=1
-tx_queue_data0_cwmin=3
-tx_queue_data0_cwmax=7
-tx_queue_data0_burst=1.5
-${hwmode:+hw_mode=$hwmode}
-${channel:+channel=$channel}
-${beacon_int:+beacon_int=$beacon_int}
-${country:+country_code=$country}
-${noscan:+noscan=$noscan}
-${brstr:+basic_rates=$brstr}
-$base_cfg
-
-EOF
-}
-
-mac80211_hostapd_setup_bss() {
-	local phy="$1"
-	local vif="$2"
-	local staidx="$3"
-
-	hostapd_cfg=
-	cfgfile="/var/run/hostapd-$phy.conf"
-	config_get ifname "$vif" ifname
-
-	if [ -f "$cfgfile" ]; then
-		append hostapd_cfg "bss=$ifname" "$N"
-	else
-		mac80211_hostapd_setup_base "$phy" "$ifname"
-		append hostapd_cfg "interface=$ifname" "$N"
-	fi
-
-	local net_cfg bridge
-	net_cfg="$(find_net_config "$vif")"
-	[ -z "$net_cfg" ] || bridge="$(bridge_interface "$net_cfg")"
-	config_set "$vif" bridge "$bridge"
-
-	hostapd_set_bss_options hostapd_cfg "$vif"
-
-	config_get_bool wds "$vif" wds 0
-	[ "$wds" -gt 0 ] && append hostapd_cfg "wds_sta=1" "$N"
-
-	[ "$staidx" -gt 0 ] && append hostapd_cfg "start_disabled=1" "$N"
-
-	local macaddr hidden maxassoc wmm
-	config_get macaddr "$vif" macaddr
-	config_get maxassoc "$vif" maxassoc
-	config_get dtim_period "$vif" dtim_period
-	config_get max_listen_int "$vif" max_listen_int
-	config_get_bool hidden "$vif" hidden 0
-	config_get_bool wmm "$vif" wmm 1
-	cat >> /var/run/hostapd-$phy.conf <<EOF
-$hostapd_cfg
-wmm_enabled=$wmm
-bssid=$macaddr
-ignore_broadcast_ssid=$hidden
-${dtim_period:+dtim_period=$dtim_period}
-${max_listen_int:+max_listen_interval=$max_listen_int}
-${maxassoc:+max_num_sta=$maxassoc}
-EOF
-}
-
-mac80211_start_vif() {
-	local vif="$1"
-	local ifname="$2"
-
-	local net_cfg
-	net_cfg="$(find_net_config "$vif")"
-	[ -z "$net_cfg" ] || start_net "$ifname" "$net_cfg"
-
-	set_wifi_up "$vif" "$ifname"
-}
 
 lookup_phy() {
 	[ -n "$phy" ] && {
@@ -207,378 +44,6 @@
 	return 0
 }
 
-scan_mac80211() {
-	local device="$1"
-	local adhoc sta ap monitor mesh disabled
-
-	config_get vifs "$device" vifs
-	for vif in $vifs; do
-		config_get_bool disabled "$vif" disabled 0
-		[ $disabled = 0 ] || continue
-
-		config_get mode "$vif" mode
-		case "$mode" in
-			adhoc|sta|ap|monitor|mesh)
-				append $mode "$vif"
-			;;
-			*) echo "$device($vif): Invalid mode, ignored."; continue;;
-		esac
-	done
-
-	config_set "$device" vifs "${ap:+$ap }${adhoc:+$adhoc }${sta:+$sta }${monitor:+$monitor }${mesh:+$mesh}"
-}
-
-list_phy_interfaces() {
-	local phy="$1"
-	if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then
-		ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null;
-	else
-		ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g'
-	fi
-}
-
-disable_mac80211() (
-	local device="$1"
-
-	find_mac80211_phy "$device" || return 0
-	config_get phy "$device" phy
-
-	set_wifi_down "$device"
-	# kill all running hostapd and wpa_supplicant processes that
-	# are running on atheros/mac80211 vifs
-	for pid in `pidof hostapd`; do
-		grep -E "$phy" /proc/$pid/cmdline >/dev/null && \
-			kill $pid
-	done
-
-	include /lib/network
-	for wdev in $(list_phy_interfaces "$phy"); do
-		[ -f "/var/run/$wdev.pid" ] && kill $(cat /var/run/$wdev.pid) >&/dev/null 2>&1
-		for pid in `pidof wpa_supplicant meshd-nl80211`; do
-			grep "$wdev" /proc/$pid/cmdline >/dev/null && \
-				kill $pid
-		done
-		ifconfig "$wdev" down 2>/dev/null
-		unbridge "$dev"
-		iw dev "$wdev" del
-	done
-
-	return 0
-)
-
-get_freq() {
-	local phy="$1"
-	local chan="$2"
-	iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
-}
-
-mac80211_generate_mac() {
-	local id="$1"
-	local ref="$2"
-	local mask="$3"
-
-	[ "$mask" = "00:00:00:00:00:00" ] && mask="ff:ff:ff:ff:ff:ff";
-	local oIFS="$IFS"; IFS=":"; set -- $mask; IFS="$oIFS"
-
-	local mask1=$1
-	local mask6=$6
-
-	local oIFS="$IFS"; IFS=":"; set -- $ref; IFS="$oIFS"
-	[ "$((0x$mask1))" -gt 0 ] && {
-		b1="0x$1"
-		[ "$id" -gt 0 ] && \
-			b1=$(($b1 ^ ((($id - 1) << 2) | 0x2)))
-		printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6
-		return
-	}
-
-	[ "$((0x$mask6))" -lt 255 ] && {
-		printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $(( 0x$6 ^ $id ))
-		return
-	}
-
-	off2=$(( (0x$6 + $id) / 0x100 ))
-	printf "%s:%s:%s:%s:%02x:%02x" \
-		$1 $2 $3 $4 \
-		$(( (0x$5 + $off2) % 0x100 )) \
-		$(( (0x$6 + $id) % 0x100 ))
-}
-
-enable_mac80211() {
-	local device="$1"
-	config_get channel "$device" channel
-	config_get vifs "$device" vifs
-	config_get txpower "$device" txpower
-	config_get country "$device" country
-	config_get distance "$device" distance
-	config_get txantenna "$device" txantenna all
-	config_get rxantenna "$device" rxantenna all
-	config_get antenna_gain "$device" antenna_gain 0
-	config_get frag "$device" frag
-	config_get rts "$device" rts
-	find_mac80211_phy "$device" || return 0
-	config_get phy "$device" phy
-	local i=0
-	local macidx=0
-	local apidx=0
-	local staidx=0
-	fixed=""
-	local hostapd_ctrl=""
-
-	[ -n "$country" ] && {
-		iw reg get | grep -q "^country $country:" || {
-			iw reg set "$country"
-			sleep 1
-		}
-	}
-
-	config_get chanbw "$device" chanbw
-	[ -n "$chanbw" -a -d /sys/kernel/debug/ieee80211/$phy/ath9k ] && echo "$chanbw" > /sys/kernel/debug/ieee80211/$phy/ath9k/chanbw
-	[ -n "$chanbw" -a -d /sys/kernel/debug/ieee80211/$phy/ath5k ] && echo "$chanbw" > /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode
-
-	[ "$channel" = "auto" -o "$channel" = "0" ] || {
-		fixed=1
-	}
-
-	iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
-	iw phy "$phy" set antenna_gain $antenna_gain
-
-	[ -n "$distance" ] && iw phy "$phy" set distance "$distance"
-	[ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}"
-	[ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}"
-
-	export channel fixed
-	# convert channel to frequency
-	local freq="$(get_freq "$phy" "${fixed:+$channel}")"
-
-	wifi_fixup_hwmode "$device" "g"
-	for vif in $vifs; do
-		config_get ifname "$vif" ifname
-		[ -n "$ifname" ] || {
-			[ $i -gt 0 ] && ifname="wlan${phy#phy}-$i" || ifname="wlan${phy#phy}"
-		}
-		config_set "$vif" ifname "$ifname"
-
-		config_get mode "$vif" mode
-		config_get ssid "$vif" ssid
-
-		# It is far easier to delete and create the desired interface
-		case "$mode" in
-			adhoc)
-				iw phy "$phy" interface add "$ifname" type adhoc
-			;;
-			ap)
-				# Hostapd will handle recreating the interface and
-				# it's accompanying monitor
-				apidx="$(($apidx + 1))"
-				[ "$apidx" -gt 1 ] || iw phy "$phy" interface add "$ifname" type managed
-			;;
-			mesh)
-				config_get key "$vif" key ""
-				if [ -n "$key" ]; then
-					iw phy "$phy" interface add "$ifname" type mp
-				else
-					config_get mesh_id "$vif" mesh_id
-					iw phy "$phy" interface add "$ifname" type mp mesh_id "$mesh_id"
-				fi
-			;;
-			monitor)
-				iw phy "$phy" interface add "$ifname" type monitor
-			;;
-			sta)
-				local wdsflag
-				staidx="$(($staidx + 1))"
-				config_get_bool wds "$vif" wds 0
-				[ "$wds" -gt 0 ] && wdsflag="4addr on"
-				iw phy "$phy" interface add "$ifname" type managed $wdsflag
-				config_get_bool powersave "$vif" powersave 0
-				[ "$powersave" -gt 0 ] && powersave="on" || powersave="off"
-				iw "$ifname" set power_save "$powersave"
-			;;
-		esac
-
-		# All interfaces must have unique mac addresses
-		# which can either be explicitly set in the device
-		# section, or automatically generated
-		config_get macaddr "$device" macaddr
-		config_get vif_mac "$vif" macaddr
-		[ -n "$vif_mac" ] || {
-			vif_mac="$(mac80211_generate_mac $macidx $macaddr $(cat /sys/class/ieee80211/${phy}/address_mask))"
-			macidx="$(($macidx + 1))"
-		}
-		[ "$mode" = "ap" ] || ifconfig "$ifname" hw ether "$vif_mac"
-		config_set "$vif" macaddr "$vif_mac"
-
-		# !! ap !!
-		#
-		# ALL ap functionality will be passed to hostapd
-		#
-		# !! station !!
-		#
-		# ALL station functionality will be passed to wpa_supplicant
-		#
-		if [ ! "$mode" = "ap" ]; then
-			# We attempt to set the channel for all interfaces, although
-			# mac80211 may not support it or the driver might not yet
-			# for ap mode this is handled by hostapd
-			config_get htmode "$device" htmode
-			case "$htmode" in
-				HT20|HT40+|HT40-) ;;
-				*) htmode= ;;
-			esac
-			[ -n "$fixed" -a -n "$channel" ] && iw dev "$ifname" set channel "$channel" $htmode
-		fi
-
-		i=$(($i + 1))
-	done
-
-	local start_hostapd=
-	rm -f /var/run/hostapd-$phy.conf
-	for vif in $vifs; do
-		config_get mode "$vif" mode
-		case "$mode" in
-			ap)
-				mac80211_hostapd_setup_bss "$phy" "$vif" "$staidx"
-				start_hostapd=1
-			;;
-			mesh)
-				config_get key "$vif" key ""
-				[ -n "$key" ] && authsae_start_interface "$device" "$vif"
-			;;
-		esac
-	done
-
-	[ -n "$start_hostapd" ] && {
-		hostapd -P /var/run/wifi-$phy.pid -B /var/run/hostapd-$phy.conf || {
-			echo "Failed to start hostapd for $phy"
-			return
-		}
-		sleep 2
-
-		for vif in $vifs; do
-			config_get mode "$vif" mode
-			config_get ifname "$vif" ifname
-			[ "$mode" = "ap" ] || continue
-			hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd-$phy/$ifname}"
-			mac80211_start_vif "$vif" "$ifname"
-		done
-	}
-
-	for vif in $vifs; do
-		config_get mode "$vif" mode
-		config_get ifname "$vif" ifname
-		[ "$mode" = "ap" ] || ifconfig "$ifname" up
-
-		config_get vif_txpower "$vif" txpower
-		# use vif_txpower (from wifi-iface) to override txpower (from
-		# wifi-device) if the latter doesn't exist
-		txpower="${txpower:-$vif_txpower}"
-		[ -z "$txpower" ] || iw dev "$ifname" set txpower fixed "${txpower%%.*}00"
-
-		case "$mode" in
-			adhoc)
-				config_get bssid "$vif" bssid
-				config_get ssid "$vif" ssid
-				config_get beacon_int "$device" beacon_int
-				config_get basic_rate_list "$device" basic_rate
-				config_get encryption "$vif" encryption
-				config_get key "$vif" key 1
-				config_get mcast_rate "$vif" mcast_rate
-				config_get htmode "$device" htmode
-				case "$htmode" in
-					HT20|HT40+|HT40-) ;;
-					*) htmode= ;;
-				esac
-
-
-				local keyspec=""
-				[ "$encryption" == "psk" -o "$encryption" == "psk2" ] && {
-					if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
-						wpa_supplicant_setup_vif "$vif" nl80211 "${hostapd_ctrl:+-H $hostapd_ctrl}" $freq $htmode || {
-							echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
-							# make sure this wifi interface won't accidentally stay open without encryption
-							ifconfig "$ifname" down
-						}
-						mac80211_start_vif "$vif" "$ifname"
-						continue
-					fi
-				}
-
-				[ "$encryption" == "wep" ] && {
-					case "$key" in
-						[1234])
-							local idx
-							for idx in 1 2 3 4; do
-								local ikey
-								config_get ikey "$vif" "key$idx"
-
-								[ -n "$ikey" ] && {
-									ikey="$(($idx - 1)):$(prepare_key_wep "$ikey")"
-									[ $idx -eq $key ] && ikey="d:$ikey"
-									append keyspec "$ikey"
-								}
-							done
-						;;
-						*) append keyspec "d:0:$(prepare_key_wep "$key")" ;;
-					esac
-				}
-
-				local br brval brsub brstr
-				[ -n "$basic_rate_list" ] && {
-					for br in $basic_rate_list; do
-						brval="$(($br / 1000))"
-						brsub="$((($br / 100) % 10))"
-						[ "$brsub" -gt 0 ] && brval="$brval.$brsub"
-						[ -n "$brstr" ] && brstr="$brstr,"
-						brstr="$brstr$brval"
-					done
-				}
-
-				local mcval=""
-				[ -n "$mcast_rate" ] && {
-					mcval="$(($mcast_rate / 1000))"
-					mcsub="$(( ($mcast_rate / 100) % 10 ))"
-					[ "$mcsub" -gt 0 ] && mcval="$mcval.$mcsub"
-				}
-
-				iw dev "$ifname" ibss join "$ssid" $freq $htmode \
-					${fixed:+fixed-freq} $bssid \
-					${beacon_int:+beacon-interval $beacon_int} \
-					${brstr:+basic-rates $brstr} \
-					${mcval:+mcast-rate $mcval} \
-					${keyspec:+keys $keyspec}
-			;;
-			mesh)
-				mp_list="mesh_retry_timeout mesh_confirm_timeout mesh_holding_timeout mesh_max_peer_links
-					mesh_max_retries mesh_ttl mesh_element_ttl mesh_auto_open_plinks mesh_hwmp_max_preq_retries
-					mesh_path_refresh_time mesh_min_discovery_timeout mesh_hwmp_active_path_timeout
-					mesh_hwmp_preq_min_interval mesh_hwmp_net_diameter_traversal_time mesh_hwmp_rootmode
-					mesh_hwmp_rann_interval mesh_gate_announcements mesh_fwding mesh_sync_offset_max_neighor
-					mesh_rssi_threshold mesh_hwmp_active_path_to_root_timeout mesh_hwmp_root_interval
-					mesh_hwmp_confirmation_interval mesh_power_mode mesh_awake_window"
-				for mp in $mp_list
-				do
-					config_get mp_val "$vif" "$mp" ""
-					[ -n "$mp_val" ] && iw dev "$ifname" set mesh_param "$mp" "$mp_val"
-				done
-			;;
-			sta)
-				if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
-					wpa_supplicant_setup_vif "$vif" nl80211 "${hostapd_ctrl:+-H $hostapd_ctrl}" || {
-						echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
-						# make sure this wifi interface won't accidentally stay open without encryption
-						ifconfig "$ifname" down
-						continue
-					}
-				fi
-			;;
-		esac
-		[ "$mode" = "ap" ] || mac80211_start_vif "$vif" "$ifname"
-	done
-
-}
-
-
 check_mac80211_device() {
 	config_get phy "$1" phy
 	[ -z "$phy" ] && {
@@ -604,6 +69,8 @@
 		mode_11n=""
 		mode_band="g"
 		channel="11"
+		htmode=""
+
 		ht_cap=0
 		for cap in $(iw phy "$dev" info | grep 'Capabilities:' | cut -d: -f2); do
 			ht_cap="$(($ht_cap | $cap))"
@@ -611,7 +78,7 @@
 		ht_capab="";
 		[ "$ht_cap" -gt 0 ] && {
 			mode_11n="n"
-			append ht_capab "	option htmode	HT20" "$N"
+			htmode="HT20"
 
 			list="	list ht_capab"
 			[ "$(($ht_cap & 1))" -eq 1 ] && append ht_capab "$list	LDPC" "$N"
@@ -625,6 +92,15 @@
 			[ "$(($ht_cap & 4096))" -eq 4096 ] && append ht_capab "$list	DSSS_CCK-40" "$N"
 		}
 		iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; }
+
+		vht_cap=$(iw phy "$dev" info | grep -c 'VHT Capabilities')
+		[ "$vht_cap" -gt 0 ] && {
+			mode_band="a";
+			channel="36"
+			htmode="VHT80"
+		}
+
+		[ -n $htmode ] && append ht_capab "	option htmode	$htmode" "$N"
 
 		if [ -x /usr/bin/readlink ]; then
 			path="$(readlink -f /sys/class/ieee80211/${dev}/device)"

--- a/package/kernel/mac80211/files/regdb.txt
+++ b/package/kernel/mac80211/files/regdb.txt
@@ -1,22 +1,29 @@
 # This is the world regulatory domain
 country 00:
 	(2402 - 2472 @ 40), (3, 20)
-        # Channel 12 - 13. No HT40 channel fits here
-        (2457 - 2482 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS
-        # Channel 14. Only JP enables this and for 802.11b only
-        (2474 - 2494 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS, NO-OFDM
-        # Channel 36 - 48
-        (5170 - 5250 @ 40), (3, 20)
-        # NB: 5260 MHz - 5700 MHz requies DFS
-        # Channel 149 - 165
-        (5735 - 5835 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS
-
+	# Channel 12 - 13.
+	(2457 - 2482 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS
+	# Channel 14. Only JP enables this and for 802.11b only
+	(2474 - 2494 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS, NO-OFDM
+	# Channel 36 - 48
+	(5170 - 5250 @ 80), (3, 20)
+	# NB: 5260 MHz - 5700 MHz requies DFS
+	# Channel 149 - 165
+	(5735 - 5835 @ 80), (3, 20), PASSIVE-SCAN, NO-IBSS
+	# IEEE 802.11ad (60GHz), channels 1..3
+	(57240 - 63720 @ 2160), (N/A, 0)
+
+
+country AD:
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country AE:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country AL:
 	(2402 - 2482 @ 20), (N/A, 20)
@@ -34,60 +41,69 @@
 
 country AR:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 20), DFS
-	(5490 - 5710 @ 40), (3, 20), DFS
-	(5735 - 5835 @ 40), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country AT: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country AU:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
+
+country AW:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 40), (N/A, 20)
+	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AZ:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 40), (N/A, 18)
+	(5250 - 5330 @ 40), (N/A, 18), DFS
+
+country BA: DFS-ETSI
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 40), (N/A, 20)
+	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+
+country BB:
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (3, 23)
 	(5250 - 5330 @ 40), (3, 23), DFS
 	(5735 - 5835 @ 40), (3, 30)
 
-country AW:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
-
-country AZ:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 18)
-	(5250 - 5330 @ 40), (N/A, 18), DFS
-
-country BA: DFS-ETSI
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
-
-country BB:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (3, 23)
-	(5250 - 5330 @ 40), (3, 23), DFS
-	(5735 - 5835 @ 40), (3, 30)
-
 country BD:
 	(2402 - 2482 @ 40), (N/A, 20)
 
 country BE: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country BG: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (N/A, 23)
 	(5250 - 5290 @ 40), (N/A, 23), DFS
 	(5490 - 5710 @ 40), (N/A, 30), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country BH:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -112,10 +128,10 @@
 
 country BR:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 20), DFS
-	(5490 - 5710 @ 40), (3, 20), DFS
-	(5735 - 5835 @ 40), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country BY:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -129,16 +145,18 @@
 
 country CA:
 	(2402 - 2472 @ 40), (3, 27)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 20), DFS
-	(5490 - 5710 @ 40), (3, 20), DFS
-	(5735 - 5835 @ 40), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country CH: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country CL:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -148,31 +166,34 @@
 
 country CN:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5735 - 5835 @ 40), (N/A, 30)
+	(5735 - 5835 @ 80), (N/A, 30)
+	# 60 gHz band channels 1,4: 28dBm, channels 2,3: 44dBm
+	# ref: http://www.miit.gov.cn/n11293472/n11505629/n11506593/n11960250/n11960606/n11960700/n12330791.files/n12330790.pdf
+	(57240 - 59400 @ 2160), (N/A, 28)
+	(59400 - 63720 @ 2160), (N/A, 44)
+	(63720 - 65880 @ 2160), (N/A, 28)
 
 country CO:
 	(2402 - 2472 @ 40), (3, 27)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 23), DFS
-	(5735 - 5835 @ 40), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country CR:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 20), (3, 17)
-	(5250 - 5330 @ 20), (3, 23), DFS
-	(5735 - 5835 @ 20), (3, 30)
-
-country CS:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country CY: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 # Data from http://www.ctu.eu/164/download/VOR/VOR-12-08-2005-34.pdf
 # and http://www.ctu.eu/164/download/VOR/VOR-12-05-2007-6-AN.pdf
@@ -180,9 +201,11 @@
 # implemented.
 country CZ: DFS-ETSI
 	(2400 - 2483.5 @ 40), (N/A, 100 mW)
-	(5150 - 5250 @ 40), (N/A, 200 mW), NO-OUTDOOR
-	(5250 - 5350 @ 40), (N/A, 100 mW), NO-OUTDOOR, DFS
-	(5470 - 5725 @ 40), (N/A, 500 mW), DFS
+	(5150 - 5250 @ 80), (N/A, 200 mW), NO-OUTDOOR
+	(5250 - 5350 @ 80), (N/A, 100 mW), NO-OUTDOOR, DFS
+	(5470 - 5725 @ 80), (N/A, 500 mW), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 # Data from "Frequenznutzungsplan" (as published in April 2008), downloaded from
 # http://www.bundesnetzagentur.de/cae/servlet/contentblob/38448/publicationFile/2659/Frequenznutzungsplan2008_Id17448pdf.pdf
@@ -200,17 +223,21 @@
 	# entries 279004 and 280006
 	(2400 - 2483.5 @ 40), (N/A, 100 mW)
 	# entry 303005
-	(5150 - 5250 @ 40), (N/A, 100 mW), NO-OUTDOOR
+	(5150 - 5250 @ 80), (N/A, 100 mW), NO-OUTDOOR
 	# entries 304002 and 305002
-	(5250 - 5350 @ 40), (N/A, 100 mW), NO-OUTDOOR, DFS
+	(5250 - 5350 @ 80), (N/A, 100 mW), NO-OUTDOOR, DFS
 	# entries 308002, 309001 and 310003
-	(5470 - 5725 @ 40), (N/A, 500 mW), DFS
+	(5470 - 5725 @ 80), (N/A, 500 mW), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country DK: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country DO:
 	(2402 - 2472 @ 40), (3, 27)
@@ -223,15 +250,18 @@
 
 country EC:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 20), (3, 17)
-	(5250 - 5330 @ 20), (3, 23), DFS
-	(5735 - 5835 @ 20), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country EE: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country EG:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -239,33 +269,43 @@
 	(5250 - 5330 @ 20), (N/A, 20), DFS
 
 country ES: DFS-ETSI
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(2400 - 2483.5 @ 40), (N/A, 100 mW)
+	(5150 - 5250 @ 80), (N/A, 100 mW), NO-OUTDOOR
+	(5250 - 5350 @ 80), (N/A, 100 mW), NO-OUTDOOR, DFS
+	(5470 - 5725 @ 80), (N/A, 500 mW), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country FI: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country FR: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country GE:
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (N/A, 18)
 	(5250 - 5330 @ 40), (N/A, 18), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country GB: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country GD:
 	(2402 - 2472 @ 40), (3, 27)
@@ -276,9 +316,11 @@
 
 country GR: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country GL: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -294,9 +336,10 @@
 
 country GU:
 	(2402 - 2472 @ 40), (3, 27)
-	(5170 - 5250 @ 20), (3, 17)
-	(5250 - 5330 @ 20), (3, 23), DFS
-	(5735 - 5835 @ 20), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country HN:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -307,85 +350,92 @@
 
 country HK:
 	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
+
+country HR: DFS-ETSI
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 40), (N/A, 20)
+	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+
+country HT:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 40), (N/A, 20)
+	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5490 - 5710 @ 40), (N/A, 27), DFS
+
+country HU: DFS-ETSI
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 40), (N/A, 20)
+	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+
+country ID:
+	# ref: http://www.postel.go.id/content/ID/regulasi/standardisasi/kepdir/bwa%205,8%20ghz.pdf
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5735 - 5815 @ 80), (N/A, 20)
+
+country IE: DFS-ETSI
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+
+country IL:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5150 - 5250 @ 80), (N/A, 200 mW), NO-OUTDOOR
+	(5250 - 5350 @ 80), (N/A, 200 mW), NO-OUTDOOR, DFS
+
+country IN:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 40), (N/A, 20)
+	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5735 - 5835 @ 40), (N/A, 20)
+
+country IS: DFS-ETSI
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 40), (N/A, 20)
+	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+
+country IR:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5735 - 5835 @ 40), (N/A, 30)
+
+country IT: DFS-ETSI
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+
+country JM:
+	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (3, 17)
 	(5250 - 5330 @ 40), (3, 20), DFS
 	(5490 - 5710 @ 40), (3, 20), DFS
 	(5735 - 5835 @ 40), (3, 30)
 
-country HR: DFS-ETSI
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
-
-country HT:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
-
-country HU: DFS-ETSI
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
-
-country ID:
-	(2402 - 2482 @ 40), (N/A, 20)
-
-country IE: DFS-ETSI
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
-
-country IL:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5150 - 5250 @ 40), (N/A, 200 mW), NO-OUTDOOR
-	(5250 - 5350 @ 40), (N/A, 200 mW), NO-OUTDOOR, DFS
-
-country IN:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5735 - 5835 @ 40), (N/A, 20)
-
-country IS: DFS-ETSI
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
-
-country IR:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5735 - 5835 @ 40), (N/A, 30)
-
-country IT: DFS-ETSI
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
-
-country JM:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 20), DFS
-	(5490 - 5710 @ 40), (3, 20), DFS
-	(5735 - 5835 @ 40), (3, 30)
-
 country JP:
-	(2402 - 2472 @ 40), (N/A, 20)
-	(2457 - 2482 @ 20), (N/A, 20)
+	(2402 - 2482 @ 40), (N/A, 20)
 	(2474 - 2494 @ 20), (N/A, 20), NO-OFDM
-	(4910 - 4930 @ 10), (N/A, 23)
 	(4910 - 4990 @ 40), (N/A, 23)
-	(4930 - 4950 @ 10), (N/A, 23)
-	(5030 - 5045 @ 10), (N/A, 23)
 	(5030 - 5090 @ 40), (N/A, 23)
-	(5050 - 5060 @ 10), (N/A, 23)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 23), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 160), (N/A, 23), DFS
 
 country JO:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -410,15 +460,15 @@
 
 country KR:
 	(2402 - 2482 @ 20), (N/A, 20)
-	(5170 - 5250 @ 20), (3, 20)
-	(5250 - 5330 @ 20), (3, 20), DFS
-	(5490 - 5630 @ 20), (3, 30), DFS
-	(5735 - 5815 @ 20), (3, 30)
+	(5170 - 5250 @ 80), (3, 20)
+	(5250 - 5330 @ 80), (3, 20), DFS
+	(5490 - 5630 @ 80), (3, 30), DFS
+	(5735 - 5815 @ 80), (3, 30)
 
 country KW:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
 
 country KZ:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -445,18 +495,24 @@
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country LU: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country LV: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country MC: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -465,6 +521,8 @@
 
 country MA:
 	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 80), (N/A, 23)
+	(5735 - 5835 @ 80), (N/A, 23)
 
 country MO:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -477,35 +535,45 @@
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country MT: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country MY:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 30), DFS
-	(5735 - 5835 @ 40), (N/A, 30)
+	(5170 - 5250 @ 80), (N/A, 17)
+	(5250 - 5330 @ 80), (N/A, 23), DFS
+	(5735 - 5835 @ 80), (N/A, 30)
 
 country MX:
 	(2402 - 2472 @ 40), (3, 27)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 23), DFS
-	(5735 - 5835 @ 40), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country NL: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20), NO-OUTDOOR
-	(5250 - 5330 @ 40), (N/A, 20), NO-OUTDOOR, DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20), NO-OUTDOOR
+	(5250 - 5330 @ 80), (N/A, 20), NO-OUTDOOR, DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country NO: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country NP:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -513,9 +581,10 @@
 
 country NZ:
 	(2402 - 2482 @ 40), (N/A, 30)
-	(5170 - 5250 @ 20), (3, 23)
-	(5250 - 5330 @ 20), (3, 23), DFS
-	(5735 - 5835 @ 20), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country OM:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -532,7 +601,10 @@
 
 country PE:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5735 - 5835 @ 40), (N/A, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country PG:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -542,7 +614,10 @@
 
 country PH:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5735 - 5835 @ 40), (N/A, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country PK:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -550,21 +625,26 @@
 
 country PL: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country PT: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country PR:
 	(2402 - 2472 @ 40), (3, 27)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 23), DFS
-	(5735 - 5835 @ 40), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country QA:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -575,40 +655,66 @@
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+
+
+# Source:
+# http://www.ratel.rs/upload/documents/Plan_namene/Plan_namene-sl_glasnik.pdf
+country RS:
+	(2400 - 2483.5 @ 40), (N/A, 100 mW)
+	(5150 - 5350 @ 40), (N/A, 200 mW), NO-OUTDOOR
+	(5470 - 5725 @ 20), (3, 1000 mW), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country RU:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5735 - 5835 @ 20), (N/A, 30)
+	(5170 - 5330 @ 40), (N/A, 20)
+	(5650 - 5710 @ 40), (N/A, 30)
+	(5735 - 5835 @ 40), (N/A, 30)
+
+country RW:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5735 - 5835 @ 40), (N/A, 30)
 
 country SA:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 20), (3, 23)
-	(5250 - 5330 @ 20), (3, 23), DFS
-	(5735 - 5835 @ 20), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country SE: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country SG:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5735 - 5835 @ 40), (N/A, 20)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country SI: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (N/A, 20)
 	(5250 - 5330 @ 40), (N/A, 20), DFS
 	(5490 - 5710 @ 40), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country SK: DFS-ETSI
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
-	(5490 - 5710 @ 40), (N/A, 27), DFS
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
 
 country SV:
 	(2402 - 2482 @ 40), (N/A, 20)
@@ -622,75 +728,95 @@
 country TW:
 	(2402 - 2472 @ 40), (3, 27)
 	(5270 - 5330 @ 40), (3, 17), DFS
-	(5735 - 5815 @ 40), (3, 30)
+	(5490 - 5710 @ 80), (3, 30), DFS
+	(5735 - 5815 @ 80), (3, 30)
 
 country TH:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
+
+country TT:
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (3, 17)
 	(5250 - 5330 @ 40), (3, 20), DFS
 	(5490 - 5710 @ 40), (3, 20), DFS
 	(5735 - 5835 @ 40), (3, 30)
 
-country TT:
+country TN:
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 20), (N/A, 20)
+	(5250 - 5330 @ 20), (N/A, 20), DFS
+
+country TR: DFS-ETSI
+	(2402 - 2482 @ 40), (N/A, 20)
+	(5170 - 5250 @ 80), (N/A, 20)
+	(5250 - 5330 @ 80), (N/A, 20), DFS
+	(5490 - 5710 @ 80), (N/A, 27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+ 
+# Source:
+# #914 / 06 Sep 2007: http://www.ucrf.gov.ua/uk/doc/nkrz/1196068874
+# #1174 / 23 Oct 2008: http://www.nkrz.gov.ua/uk/activities/ruling/1225269361
+# (appendix 8)
+# Listed 5GHz range is a lowest common denominator for all related
+# rules in the referenced laws. Such a range is used because of
+# disputable definitions there.
+country UA:
+	(2400 - 2483.5 @ 40), (N/A, 20), NO-OUTDOOR
+	(5150 - 5350 @ 40), (N/A, 20), NO-OUTDOOR
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
+
+country US: DFS-FCC
+	(2402 - 2472 @ 40), (3, 27)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5600 @ 80), (3, 24), DFS
+	(5650 - 5710 @ 40), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
+	# 60g band
+	# reference: http://cfr.regstoday.com/47cfr15.aspx#47_CFR_15p255
+	# channels 1,2,3, EIRP=40dBm(43dBm peak)
+	(57240 - 63720 @ 2160), (N/A, 40)
+
+country UY:
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5170 - 5250 @ 40), (3, 17)
 	(5250 - 5330 @ 40), (3, 20), DFS
 	(5490 - 5710 @ 40), (3, 20), DFS
 	(5735 - 5835 @ 40), (3, 30)
 
-country TN:
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 20), (N/A, 20)
-	(5250 - 5330 @ 20), (N/A, 20), DFS
-
-country TR: DFS-ETSI
-	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 20), (N/A, 20)
-	(5250 - 5330 @ 20), (N/A, 20), DFS
-
-country UA:
-	(2402 - 2482 @ 40), (N/A, 20)
-
-country US: DFS-FCC
-	(2402 - 2472 @ 40), (3, 27)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 20), DFS
-	(5490 - 5600 @ 40), (3, 20), DFS
-	(5650 - 5710 @ 40), (3, 20), DFS
-	(5735 - 5835 @ 40), (3, 30)
-
-country UY:
-	(2402 - 2482 @ 40), (N/A, 20)
+country UZ:
+	(2402 - 2472 @ 40), (3, 27)
 	(5170 - 5250 @ 40), (3, 17)
 	(5250 - 5330 @ 40), (3, 20), DFS
 	(5490 - 5710 @ 40), (3, 20), DFS
 	(5735 - 5835 @ 40), (3, 30)
 
-country UZ:
-	(2402 - 2472 @ 40), (3, 27)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 20), DFS
-	(5490 - 5710 @ 40), (3, 20), DFS
-	(5735 - 5835 @ 40), (3, 30)
-
 country VE:
 	(2402 - 2482 @ 40), (N/A, 20)
 	(5735 - 5815 @ 40), (N/A, 23)
 
 country VN:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (N/A, 20)
-	(5250 - 5330 @ 40), (N/A, 20), DFS
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country YE:
 	(2402 - 2482 @ 40), (N/A, 20)
 
 country ZA:
 	(2402 - 2482 @ 40), (N/A, 20)
-	(5170 - 5250 @ 40), (3, 17)
-	(5250 - 5330 @ 40), (3, 20), DFS
-	(5490 - 5710 @ 40), (3, 20), DFS
-	(5735 - 5835 @ 40), (3, 30)
+	(5170 - 5250 @ 80), (3, 17)
+	(5250 - 5330 @ 80), (3, 24), DFS
+	(5490 - 5710 @ 80), (3, 24), DFS
+	(5735 - 5835 @ 80), (3, 30)
 
 country ZW:
 	(2402 - 2482 @ 40), (N/A, 20)

--- a/package/kernel/mac80211/patches/001-fix_build.patch
+++ b/package/kernel/mac80211/patches/001-fix_build.patch
@@ -128,7 +128,7 @@
 +	@$(MAKE) Kconfig.versions
  	@$(MAKE) -f Makefile.real "$@"
  
- else
+ .PHONY: defconfig-help
 --- a/Makefile.real
 +++ b/Makefile.real
 @@ -54,7 +54,7 @@ defconfig-%::

--- /dev/null
+++ b/package/kernel/mac80211/patches/004-backports-add-led_trigger_blink-_oneshot.patch
@@ -1,1 +1,41 @@
+From 88e75363ff9c00cc2e7768ca23ded79bf8d6bf08 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Fri, 7 Feb 2014 19:13:11 +0100
+Subject: [PATCH 1/8] backports: add led_trigger_blink{_oneshot}()
 
+When led support is deactivated in the kernel and
+CPTCFG_BACKPORT_BUILD_LEDS is set mac80211 references
+led_trigger_blink_oneshot() but it is not declared anywhere.
+
+This fixes the following build error:
+net/mac80211/led.c: In function 'ieee80211_led_rx':
+net/mac80211/led.c:25:2: error: implicit declaration of function 'led_trigger_blink_oneshot' [-Werror=implicit-function-declaration]
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ backport-include/backport/leds-disabled.h |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- a/backport-include/backport/leds-disabled.h
++++ b/backport-include/backport/leds-disabled.h
+@@ -163,6 +163,19 @@ static inline void led_trigger_event(str
+ 				     enum led_brightness event)
+ {
+ }
++
++static inline void led_trigger_blink(struct led_trigger *trigger,
++				     unsigned long *delay_on,
++				     unsigned long *delay_off)
++{
++}
++
++static inline void led_trigger_blink_oneshot(struct led_trigger *trigger,
++					     unsigned long *delay_on,
++					     unsigned long *delay_off,
++					     int invert)
++{
++}
+ #endif
+ 
+ #endif /* __BACKPORT_LED_DISABLED_SUPPORT */
+

--- a/package/kernel/mac80211/patches/020-disable_tty_set_termios.patch
+++ b/package/kernel/mac80211/patches/020-disable_tty_set_termios.patch
@@ -6,11 +6,11 @@
  
 +#ifdef CONFIG_COMPAT_BLUETOOTH
  #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
+ #ifdef CONFIG_TTY
  /*
-  *		Termios Helper Methods
-@@ -112,4 +113,4 @@ int tty_set_termios(struct tty_struct *t
- }
+@@ -114,4 +115,4 @@ int tty_set_termios(struct tty_struct *t
  EXPORT_SYMBOL_GPL(tty_set_termios);
+ #endif /* CONFIG_TTY */
  #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */
 -
 +#endif

--- a/package/kernel/mac80211/patches/030-rt2x00_options.patch
+++ b/package/kernel/mac80211/patches/030-rt2x00_options.patch
@@ -1,12 +1,19 @@
 --- a/drivers/net/wireless/rt2x00/Kconfig
 +++ b/drivers/net/wireless/rt2x00/Kconfig
-@@ -202,25 +202,28 @@ config RT2800USB_UNKNOWN
- endif
+@@ -225,36 +225,37 @@ config RT2800SOC
+ 
  
  config RT2800_LIB
 -	tristate
 +	tristate "RT2800 USB/PCI support"
  	depends on m
+ 
+ config RT2800_LIB_MMIO
+-	tristate
++	tristate "RT2800 MMIO support"
+ 	depends on m
+ 	select RT2X00_LIB_MMIO
+ 	select RT2800_LIB
  
  config RT2X00_LIB_MMIO
 -	tristate
@@ -16,7 +23,6 @@
  config RT2X00_LIB_PCI
 -	tristate
 +	tristate "RT2x00 PCI support"
-+	depends on PCI
  	depends on m
  	select RT2X00_LIB
  
@@ -30,8 +36,13 @@
  config RT2X00_LIB_USB
 -	tristate
 +	tristate "RT2x00 USB support"
-+	depends on USB
  	depends on m
  	select RT2X00_LIB
  
+ config RT2X00_LIB
+-	tristate
++	tristate "RT2x00 support"
+ 	depends on m
+ 	select BACKPORT_AVERAGE
+ 
 

--- a/package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch
+++ b/package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch
@@ -1,6 +1,6 @@
 --- a/.local-symbols
 +++ b/.local-symbols
-@@ -363,42 +363,6 @@ USB_CDC_PHONET=
+@@ -379,42 +379,6 @@ USB_CDC_PHONET=
  USB_IPHETH=
  USB_SIERRA_NET=
  USB_VL600=
@@ -40,9 +40,9 @@
 -BCMA_DRIVER_GMAC_CMN=
 -BCMA_DRIVER_GPIO=
 -BCMA_DEBUG=
- DRM=
- DRM_USB=
- DRM_KMS_HELPER=
+ NFC=
+ NFC_DIGITAL=
+ NFC_NCI=
 --- a/Kconfig
 +++ b/Kconfig
 @@ -33,9 +33,6 @@ source drivers/net/wireless/Kconfig
@@ -52,12 +52,12 @@
 -source drivers/ssb/Kconfig
 -source drivers/bcma/Kconfig
 -
- source drivers/gpu/drm/Kconfig
+ source net/nfc/Kconfig
  
- source net/nfc/Kconfig
+ source drivers/regulator/Kconfig
 --- a/Makefile.kernel
 +++ b/Makefile.kernel
-@@ -26,8 +26,6 @@ obj-$(CPTCFG_MAC80211) += net/mac80211/
+@@ -25,8 +25,6 @@ obj-$(CPTCFG_MAC80211) += net/mac80211/
  obj-$(CPTCFG_WLAN) += drivers/net/wireless/
  obj-$(CPTCFG_BT) += net/bluetooth/
  obj-$(CPTCFG_BT) += drivers/bluetooth/
@@ -65,10 +65,10 @@
 -obj-$(CPTCFG_BCMA) += drivers/bcma/
  obj-$(CPTCFG_ETHERNET) += drivers/net/ethernet/
  obj-$(CPTCFG_USB_NET_RNDIS_WLAN) += drivers/net/usb/
- obj-$(CPTCFG_DRM) += drivers/gpu/drm/
+ obj-$(CPTCFG_NFC) += net/nfc/
 --- a/drivers/net/wireless/b43/main.c
 +++ b/drivers/net/wireless/b43/main.c
-@@ -2729,7 +2729,7 @@ static struct ssb_device *b43_ssb_gpio_d
+@@ -2734,7 +2734,7 @@ static struct ssb_device *b43_ssb_gpio_d
  {
  	struct ssb_bus *bus = dev->dev->sdev->bus;
  
@@ -77,7 +77,7 @@
  	return (bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev);
  #else
  	return bus->chipco.dev;
-@@ -4735,7 +4735,7 @@ static int b43_wireless_core_init(struct
+@@ -4751,7 +4751,7 @@ static int b43_wireless_core_init(struct
  	}
  	if (sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW)
  		hf |= B43_HF_DSCRQ; /* Disable slowclock requests from ucode. */

--- /dev/null
+++ b/package/kernel/mac80211/patches/100-revert_aes_ccm_port.patch
@@ -1,1 +1,348 @@
+--- a/net/mac80211/Kconfig
++++ b/net/mac80211/Kconfig
+@@ -5,7 +5,6 @@ config MAC80211
+ 	depends on CRYPTO
+ 	depends on CRYPTO_ARC4
+ 	depends on CRYPTO_AES
+-	depends on CRYPTO_CCM
+ 	depends on CRC32
+ 	select BACKPORT_AVERAGE
+ 	---help---
+--- a/net/mac80211/aes_ccm.c
++++ b/net/mac80211/aes_ccm.c
+@@ -2,8 +2,6 @@
+  * Copyright 2003-2004, Instant802 Networks, Inc.
+  * Copyright 2005-2006, Devicescape Software, Inc.
+  *
+- * Rewrite: Copyright (C) 2013 Linaro Ltd <ard.biesheuvel@linaro.org>
+- *
+  * This program is free software; you can redistribute it and/or modify
+  * it under the terms of the GNU General Public License version 2 as
+  * published by the Free Software Foundation.
+@@ -19,75 +17,134 @@
+ #include "key.h"
+ #include "aes_ccm.h"
+ 
+-void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+-			       u8 *data, size_t data_len, u8 *mic)
++static void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *scratch, u8 *a)
+ {
+-	struct scatterlist assoc, pt, ct[2];
+-	struct {
+-		struct aead_request	req;
+-		u8			priv[crypto_aead_reqsize(tfm)];
+-	} aead_req;
+-
+-	memset(&aead_req, 0, sizeof(aead_req));
+-
+-	sg_init_one(&pt, data, data_len);
+-	sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
+-	sg_init_table(ct, 2);
+-	sg_set_buf(&ct[0], data, data_len);
+-	sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN);
+-
+-	aead_request_set_tfm(&aead_req.req, tfm);
+-	aead_request_set_assoc(&aead_req.req, &assoc, assoc.length);
+-	aead_request_set_crypt(&aead_req.req, &pt, ct, data_len, b_0);
++	int i;
++	u8 *b_0, *aad, *b, *s_0;
+ 
+-	crypto_aead_encrypt(&aead_req.req);
++	b_0 = scratch + 3 * AES_BLOCK_SIZE;
++	aad = scratch + 4 * AES_BLOCK_SIZE;
++	b = scratch;
++	s_0 = scratch + AES_BLOCK_SIZE;
++
++	crypto_cipher_encrypt_one(tfm, b, b_0);
++
++	/* Extra Authenticate-only data (always two AES blocks) */
++	for (i = 0; i < AES_BLOCK_SIZE; i++)
++		aad[i] ^= b[i];
++	crypto_cipher_encrypt_one(tfm, b, aad);
++
++	aad += AES_BLOCK_SIZE;
++
++	for (i = 0; i < AES_BLOCK_SIZE; i++)
++		aad[i] ^= b[i];
++	crypto_cipher_encrypt_one(tfm, a, aad);
++
++	/* Mask out bits from auth-only-b_0 */
++	b_0[0] &= 0x07;
++
++	/* S_0 is used to encrypt T (= MIC) */
++	b_0[14] = 0;
++	b_0[15] = 0;
++	crypto_cipher_encrypt_one(tfm, s_0, b_0);
+ }
+ 
+-int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+-			      u8 *data, size_t data_len, u8 *mic)
++
++void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
++			       u8 *data, size_t data_len,
++			       u8 *cdata, u8 *mic)
+ {
+-	struct scatterlist assoc, pt, ct[2];
+-	struct {
+-		struct aead_request	req;
+-		u8			priv[crypto_aead_reqsize(tfm)];
+-	} aead_req;
+-
+-	memset(&aead_req, 0, sizeof(aead_req));
+-
+-	sg_init_one(&pt, data, data_len);
+-	sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
+-	sg_init_table(ct, 2);
+-	sg_set_buf(&ct[0], data, data_len);
+-	sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN);
+-
+-	aead_request_set_tfm(&aead_req.req, tfm);
+-	aead_request_set_assoc(&aead_req.req, &assoc, assoc.length);
+-	aead_request_set_crypt(&aead_req.req, ct, &pt,
+-			       data_len + IEEE80211_CCMP_MIC_LEN, b_0);
++	int i, j, last_len, num_blocks;
++	u8 *pos, *cpos, *b, *s_0, *e, *b_0;
++
++	b = scratch;
++	s_0 = scratch + AES_BLOCK_SIZE;
++	e = scratch + 2 * AES_BLOCK_SIZE;
++	b_0 = scratch + 3 * AES_BLOCK_SIZE;
++
++	num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE);
++	last_len = data_len % AES_BLOCK_SIZE;
++	aes_ccm_prepare(tfm, scratch, b);
++
++	/* Process payload blocks */
++	pos = data;
++	cpos = cdata;
++	for (j = 1; j <= num_blocks; j++) {
++		int blen = (j == num_blocks && last_len) ?
++			last_len : AES_BLOCK_SIZE;
++
++		/* Authentication followed by encryption */
++		for (i = 0; i < blen; i++)
++			b[i] ^= pos[i];
++		crypto_cipher_encrypt_one(tfm, b, b);
++
++		b_0[14] = (j >> 8) & 0xff;
++		b_0[15] = j & 0xff;
++		crypto_cipher_encrypt_one(tfm, e, b_0);
++		for (i = 0; i < blen; i++)
++			*cpos++ = *pos++ ^ e[i];
++	}
+ 
+-	return crypto_aead_decrypt(&aead_req.req);
++	for (i = 0; i < IEEE80211_CCMP_MIC_LEN; i++)
++		mic[i] = b[i] ^ s_0[i];
+ }
+ 
+-struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[])
++
++int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch,
++			      u8 *cdata, size_t data_len, u8 *mic, u8 *data)
+ {
+-	struct crypto_aead *tfm;
+-	int err;
++	int i, j, last_len, num_blocks;
++	u8 *pos, *cpos, *b, *s_0, *a, *b_0;
+ 
+-	tfm = crypto_alloc_aead("ccm(aes)", 0, CRYPTO_ALG_ASYNC);
+-	if (IS_ERR(tfm))
+-		return tfm;
+-
+-	err = crypto_aead_setkey(tfm, key, WLAN_KEY_LEN_CCMP);
+-	if (!err)
+-		err = crypto_aead_setauthsize(tfm, IEEE80211_CCMP_MIC_LEN);
+-	if (!err)
+-		return tfm;
++	b = scratch;
++	s_0 = scratch + AES_BLOCK_SIZE;
++	a = scratch + 2 * AES_BLOCK_SIZE;
++	b_0 = scratch + 3 * AES_BLOCK_SIZE;
++
++	num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE);
++	last_len = data_len % AES_BLOCK_SIZE;
++	aes_ccm_prepare(tfm, scratch, a);
++
++	/* Process payload blocks */
++	cpos = cdata;
++	pos = data;
++	for (j = 1; j <= num_blocks; j++) {
++		int blen = (j == num_blocks && last_len) ?
++			last_len : AES_BLOCK_SIZE;
++
++		/* Decryption followed by authentication */
++		b_0[14] = (j >> 8) & 0xff;
++		b_0[15] = j & 0xff;
++		crypto_cipher_encrypt_one(tfm, b, b_0);
++		for (i = 0; i < blen; i++) {
++			*pos = *cpos++ ^ b[i];
++			a[i] ^= *pos++;
++		}
++		crypto_cipher_encrypt_one(tfm, a, a);
++	}
++
++	for (i = 0; i < IEEE80211_CCMP_MIC_LEN; i++) {
++		if ((mic[i] ^ s_0[i]) != a[i])
++			return -1;
++	}
+ 
+-	crypto_free_aead(tfm);
+-	return ERR_PTR(err);
++	return 0;
+ }
+ 
+-void ieee80211_aes_key_free(struct crypto_aead *tfm)
++
++struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[])
++{
++	struct crypto_cipher *tfm;
++
++	tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
++	if (!IS_ERR(tfm))
++		crypto_cipher_setkey(tfm, key, WLAN_KEY_LEN_CCMP);
++
++	return tfm;
++}
++
++
++void ieee80211_aes_key_free(struct crypto_cipher *tfm)
+ {
+-	crypto_free_aead(tfm);
++	crypto_free_cipher(tfm);
+ }
+--- a/net/mac80211/aes_ccm.h
++++ b/net/mac80211/aes_ccm.h
+@@ -12,11 +12,13 @@
+ 
+ #include <linux/crypto.h>
+ 
+-struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[]);
+-void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+-			       u8 *data, size_t data_len, u8 *mic);
+-int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+-			      u8 *data, size_t data_len, u8 *mic);
+-void ieee80211_aes_key_free(struct crypto_aead *tfm);
++struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[]);
++void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
++			       u8 *data, size_t data_len,
++			       u8 *cdata, u8 *mic);
++int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch,
++			      u8 *cdata, size_t data_len,
++			      u8 *mic, u8 *data);
++void ieee80211_aes_key_free(struct crypto_cipher *tfm);
+ 
+ #endif /* AES_CCM_H */
+--- a/net/mac80211/key.h
++++ b/net/mac80211/key.h
+@@ -84,7 +84,7 @@ struct ieee80211_key {
+ 			 * Management frames.
+ 			 */
+ 			u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_CCMP_PN_LEN];
+-			struct crypto_aead *tfm;
++			struct crypto_cipher *tfm;
+ 			u32 replays; /* dot11RSNAStatsCCMPReplays */
+ 		} ccmp;
+ 		struct {
+--- a/net/mac80211/wpa.c
++++ b/net/mac80211/wpa.c
+@@ -301,16 +301,22 @@ ieee80211_crypto_tkip_decrypt(struct iee
+ }
+ 
+ 
+-static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad,
++static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *scratch,
+ 				int encrypted)
+ {
+ 	__le16 mask_fc;
+ 	int a4_included, mgmt;
+ 	u8 qos_tid;
+-	u16 len_a;
++	u8 *b_0, *aad;
++	u16 data_len, len_a;
+ 	unsigned int hdrlen;
+ 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ 
++	memset(scratch, 0, 6 * AES_BLOCK_SIZE);
++
++	b_0 = scratch + 3 * AES_BLOCK_SIZE;
++	aad = scratch + 4 * AES_BLOCK_SIZE;
++
+ 	/*
+ 	 * Mask FC: zero subtype b4 b5 b6 (if not mgmt)
+ 	 * Retry, PwrMgt, MoreData; set Protected
+@@ -332,21 +338,20 @@ static void ccmp_special_blocks(struct s
+ 	else
+ 		qos_tid = 0;
+ 
+-	/* In CCM, the initial vectors (IV) used for CTR mode encryption and CBC
+-	 * mode authentication are not allowed to collide, yet both are derived
+-	 * from this vector b_0. We only set L := 1 here to indicate that the
+-	 * data size can be represented in (L+1) bytes. The CCM layer will take
+-	 * care of storing the data length in the top (L+1) bytes and setting
+-	 * and clearing the other bits as is required to derive the two IVs.
+-	 */
+-	b_0[0] = 0x1;
++	data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN;
++	if (encrypted)
++		data_len -= IEEE80211_CCMP_MIC_LEN;
+ 
++	/* First block, b_0 */
++	b_0[0] = 0x59; /* flags: Adata: 1, M: 011, L: 001 */
+ 	/* Nonce: Nonce Flags | A2 | PN
+ 	 * Nonce Flags: Priority (b0..b3) | Management (b4) | Reserved (b5..b7)
+ 	 */
+ 	b_0[1] = qos_tid | (mgmt << 4);
+ 	memcpy(&b_0[2], hdr->addr2, ETH_ALEN);
+ 	memcpy(&b_0[8], pn, IEEE80211_CCMP_PN_LEN);
++	/* l(m) */
++	put_unaligned_be16(data_len, &b_0[14]);
+ 
+ 	/* AAD (extra authenticate-only data) / masked 802.11 header
+ 	 * FC | A1 | A2 | A3 | SC | [A4] | [QC] */
+@@ -402,8 +407,7 @@ static int ccmp_encrypt_skb(struct ieee8
+ 	u8 *pos;
+ 	u8 pn[6];
+ 	u64 pn64;
+-	u8 aad[2 * AES_BLOCK_SIZE];
+-	u8 b_0[AES_BLOCK_SIZE];
++	u8 scratch[6 * AES_BLOCK_SIZE];
+ 
+ 	if (info->control.hw_key &&
+ 	    !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
+@@ -456,9 +460,9 @@ static int ccmp_encrypt_skb(struct ieee8
+ 		return 0;
+ 
+ 	pos += IEEE80211_CCMP_HDR_LEN;
+-	ccmp_special_blocks(skb, pn, b_0, aad, 0);
+-	ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
+-				  skb_put(skb, IEEE80211_CCMP_MIC_LEN));
++	ccmp_special_blocks(skb, pn, scratch, 0);
++	ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, scratch, pos, len,
++				  pos, skb_put(skb, IEEE80211_CCMP_MIC_LEN));
+ 
+ 	return 0;
+ }
+@@ -521,16 +525,16 @@ ieee80211_crypto_ccmp_decrypt(struct iee
+ 	}
+ 
+ 	if (!(status->flag & RX_FLAG_DECRYPTED)) {
+-		u8 aad[2 * AES_BLOCK_SIZE];
+-		u8 b_0[AES_BLOCK_SIZE];
++		u8 scratch[6 * AES_BLOCK_SIZE];
+ 		/* hardware didn't decrypt/verify MIC */
+-		ccmp_special_blocks(skb, pn, b_0, aad, 1);
++		ccmp_special_blocks(skb, pn, scratch, 1);
+ 
+ 		if (ieee80211_aes_ccm_decrypt(
+-			    key->u.ccmp.tfm, b_0, aad,
++			    key->u.ccmp.tfm, scratch,
+ 			    skb->data + hdrlen + IEEE80211_CCMP_HDR_LEN,
+ 			    data_len,
+-			    skb->data + skb->len - IEEE80211_CCMP_MIC_LEN))
++			    skb->data + skb->len - IEEE80211_CCMP_MIC_LEN,
++			    skb->data + hdrlen + IEEE80211_CCMP_HDR_LEN))
+ 			return RX_DROP_UNUSABLE;
+ 	}
+ 
 

--- a/package/kernel/mac80211/patches/150-disable_addr_notifier.patch
+++ b/package/kernel/mac80211/patches/150-disable_addr_notifier.patch
@@ -1,6 +1,6 @@
 --- a/net/mac80211/main.c
 +++ b/net/mac80211/main.c
-@@ -300,7 +300,7 @@ void ieee80211_restart_hw(struct ieee802
+@@ -287,7 +287,7 @@ void ieee80211_restart_hw(struct ieee802
  }
  EXPORT_SYMBOL(ieee80211_restart_hw);
  
@@ -9,7 +9,7 @@
  static int ieee80211_ifa_changed(struct notifier_block *nb,
  				 unsigned long data, void *arg)
  {
-@@ -359,7 +359,7 @@ static int ieee80211_ifa_changed(struct 
+@@ -346,7 +346,7 @@ static int ieee80211_ifa_changed(struct 
  }
  #endif
  
@@ -18,7 +18,7 @@
  static int ieee80211_ifa6_changed(struct notifier_block *nb,
  				  unsigned long data, void *arg)
  {
-@@ -990,14 +990,14 @@ int ieee80211_register_hw(struct ieee802
+@@ -1031,14 +1031,14 @@ int ieee80211_register_hw(struct ieee802
  		goto fail_pm_qos;
  	}
  
@@ -35,7 +35,7 @@
  	local->ifa6_notifier.notifier_call = ieee80211_ifa6_changed;
  	result = register_inet6addr_notifier(&local->ifa6_notifier);
  	if (result)
-@@ -1006,13 +1006,13 @@ int ieee80211_register_hw(struct ieee802
+@@ -1047,13 +1047,13 @@ int ieee80211_register_hw(struct ieee802
  
  	return 0;
  
@@ -52,7 +52,7 @@
   fail_ifa:
  	pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
  			       &local->network_latency_notifier);
-@@ -1045,10 +1045,10 @@ void ieee80211_unregister_hw(struct ieee
+@@ -1086,10 +1086,10 @@ void ieee80211_unregister_hw(struct ieee
  
  	pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
  			       &local->network_latency_notifier);

--- a/package/kernel/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch
+++ b/package/kernel/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch
@@ -17,7 +17,7 @@
  	{ AR5K_RXNOFRM,		8 },
 --- a/drivers/net/wireless/ath/ath5k/dma.c
 +++ b/drivers/net/wireless/ath/ath5k/dma.c
-@@ -860,10 +860,18 @@ ath5k_hw_dma_init(struct ath5k_hw *ah)
+@@ -869,10 +869,18 @@ ath5k_hw_dma_init(struct ath5k_hw *ah)
  	 * guess we can tweak it and see how it goes ;-)
  	 */
  	if (ah->ah_version != AR5K_AR5210) {

--- a/package/kernel/mac80211/patches/300-pending_work.patch
+++ b/package/kernel/mac80211/patches/300-pending_work.patch
@@ -1,9373 +1,3390 @@
---- a/net/mac80211/agg-rx.c
-+++ b/net/mac80211/agg-rx.c
-@@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
- 		memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
- 	else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
- 		memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
-+	else if (sdata->vif.type == NL80211_IFTYPE_WDS)
-+		memcpy(mgmt->bssid, da, ETH_ALEN);
- 
- 	mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
- 					  IEEE80211_STYPE_ACTION);
+commit 118945bb12082e9d4edddc868d88143164e0f440
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Sat Feb 22 14:55:23 2014 +0100
+
+    ath5k: set SURVEY_INFO_IN_USE on get_survey
+    
+    Only one channel is returned - the one currently being used.
+    
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+commit ee41f72476e1ea44283dfe1cbf75b9543a1e15c8
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Sat Feb 22 14:44:52 2014 +0100
+
+    ath9k: make some hardware reset log messages debug-only
+    
+    On some chips, baseband watchdog hangs are more common than others, and
+    the driver has support for handling them.
+    Interrupts even after a watchdog hang are also quite common, so there's
+    not much point in spamming the user's logfiles.
+    
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+commit b14fbb554fc65a2e0b5c41a319269b0350f187e7
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Sat Feb 22 14:35:25 2014 +0100
+
+    ath9k: do not set half/quarter channel flags in AR_PHY_MODE
+    
+    5/10 MHz channel bandwidth is configured via the PLL clock, instead of
+    the AR_PHY_MODE register. Using that register is AR93xx specific, and
+    makes the mode incompatible with earlier chipsets.
+    
+    In some early versions, these flags were apparently applied at the wrong
+    point in time and thus did not cause connectivity issues, however now
+    they are causing problems, as pointed out in this OpenWrt ticket:
+    
+    https://dev.openwrt.org/ticket/14916
+    
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+commit 0f1cb7be2551b30b02cd54c897e0e29e483cfda5
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Sat Feb 22 13:43:29 2014 +0100
+
+    ath9k: fix ps-poll responses under a-mpdu sessions
+    
+    When passing tx frames to the U-APSD queue for powersave poll responses,
+    the ath_atx_tid pointer needs to be passed to ath_tx_setup_buffer for
+    proper sequence number accounting.
+    
+    This fixes high latency and connection stability issues with ath9k
+    running as AP and a few kinds of mobile phones as client, when PS-Poll
+    is heavily used
+    
+    Cc: stable@vger.kernel.org
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+commit d5d87a37bbd6066b2c3c5d0bd0fe2a6e2ea45cc5
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Fri Feb 21 11:39:59 2014 +0100
+
+    ath9k: list more reset causes in debugfs
+    
+    Number of MAC hangs and stuck beacons were missing
+    
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+commit d84856012e0f10fe598a5ad3b7b869397a089e07
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Thu Feb 20 11:19:58 2014 +0100
+
+    mac80211: fix station wakeup powersave race
+    
+    Consider the following (relatively unlikely) scenario:
+     1) station goes to sleep while frames are buffered in driver
+     2) driver blocks wakeup (until no more frames are buffered)
+     3) station wakes up again
+     4) driver unblocks wakeup
+    
+    In this case, the current mac80211 code will do the following:
+     1) WLAN_STA_PS_STA set
+     2) WLAN_STA_PS_DRIVER set
+     3) - nothing -
+     4) WLAN_STA_PS_DRIVER cleared
+    
+    As a result, no frames will be delivered to the client, even
+    though it is awake, until it sends another frame to us that
+    triggers ieee80211_sta_ps_deliver_wakeup() in sta_ps_end().
+    
+    Since we now take the PS spinlock, we can fix this while at
+    the same time removing the complexity with the pending skb
+    queue function. This was broken since my commit 50a9432daeec
+    ("mac80211: fix powersaving clients races") due to removing
+    the clearing of WLAN_STA_PS_STA in the RX path.
+    
+    While at it, fix a cleanup path issue when a station is
+    removed while the driver is still blocking its wakeup.
+    
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 798f2786602cbe93e6b928299614aa36ebf50692
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Mon Feb 17 20:49:03 2014 +0100
+
+    mac80211: insert stations before adding to driver
+    
+    There's a race condition in mac80211 because we add stations
+    to the internal lists after adding them to the driver, which
+    means that (for example) the following can happen:
+     1. a station connects and is added
+     2. first, it is added to the driver
+     3. then, it is added to the mac80211 lists
+    
+    If the station goes to sleep between steps 2 and 3, and the
+    firmware/hardware records it as being asleep, mac80211 will
+    never instruct the driver to wake it up again as it never
+    realized it went to sleep since the RX path discarded the
+    frame as a "spurious class 3 frame", no station entry was
+    present yet.
+    
+    Fix this by adding the station in software first, and only
+    then adding it to the driver. That way, any state that the
+    driver changes will be reflected properly in mac80211's
+    station state. The problematic part is the roll-back if the
+    driver fails to add the station, in that case a bit more is
+    needed. To not make that overly complex prevent starting BA
+    sessions in the meantime.
+    
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit b9ba6a520cb07ab3aa7aaaf9ce4a0bc7a6bc06fe
+Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+Date:   Thu Feb 20 09:22:11 2014 +0200
+
+    mac80211: fix AP powersave TX vs. wakeup race
+    
+    There is a race between the TX path and the STA wakeup: while
+    a station is sleeping, mac80211 buffers frames until it wakes
+    up, then the frames are transmitted. However, the RX and TX
+    path are concurrent, so the packet indicating wakeup can be
+    processed while a packet is being transmitted.
+    
+    This can lead to a situation where the buffered frames list
+    is emptied on the one side, while a frame is being added on
+    the other side, as the station is still seen as sleeping in
+    the TX path.
+    
+    As a result, the newly added frame will not be send anytime
+    soon. It might be sent much later (and out of order) when the
+    station goes to sleep and wakes up the next time.
+    
+    Additionally, it can lead to the crash below.
+    
+    Fix all this by synchronising both paths with a new lock.
+    Both path are not fastpath since they handle PS situations.
+    
+    In a later patch we'll remove the extra skb queue locks to
+    reduce locking overhead.
+    
+    BUG: unable to handle kernel
+    NULL pointer dereference at 000000b0
+    IP: [<ff6f1791>] ieee80211_report_used_skb+0x11/0x3e0 [mac80211]
+    *pde = 00000000
+    Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
+    EIP: 0060:[<ff6f1791>] EFLAGS: 00210282 CPU: 1
+    EIP is at ieee80211_report_used_skb+0x11/0x3e0 [mac80211]
+    EAX: e5900da0 EBX: 00000000 ECX: 00000001 EDX: 00000000
+    ESI: e41d00c0 EDI: e5900da0 EBP: ebe458e4 ESP: ebe458b0
+     DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
+    CR0: 8005003b CR2: 000000b0 CR3: 25a78000 CR4: 000407d0
+    DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
+    DR6: ffff0ff0 DR7: 00000400
+    Process iperf (pid: 3934, ti=ebe44000 task=e757c0b0 task.ti=ebe44000)
+    iwlwifi 0000:02:00.0: I iwl_pcie_enqueue_hcmd Sending command LQ_CMD (#4e), seq: 0x0903, 92 bytes at 3[3]:9
+    Stack:
+     e403b32c ebe458c4 00200002 00200286 e403b338 ebe458cc c10960bb e5900da0
+     ff76a6ec ebe458d8 00000000 e41d00c0 e5900da0 ebe458f0 ff6f1b75 e403b210
+     ebe4598c ff723dc1 00000000 ff76a6ec e597c978 e403b758 00000002 00000002
+    Call Trace:
+     [<ff6f1b75>] ieee80211_free_txskb+0x15/0x20 [mac80211]
+     [<ff723dc1>] invoke_tx_handlers+0x1661/0x1780 [mac80211]
+     [<ff7248a5>] ieee80211_tx+0x75/0x100 [mac80211]
+     [<ff7249bf>] ieee80211_xmit+0x8f/0xc0 [mac80211]
+     [<ff72550e>] ieee80211_subif_start_xmit+0x4fe/0xe20 [mac80211]
+     [<c149ef70>] dev_hard_start_xmit+0x450/0x950
+     [<c14b9aa9>] sch_direct_xmit+0xa9/0x250
+     [<c14b9c9b>] __qdisc_run+0x4b/0x150
+     [<c149f732>] dev_queue_xmit+0x2c2/0xca0
+    
+    Cc: stable@vger.kernel.org
+    Reported-by: Yaara Rozenblum <yaara.rozenblum@intel.com>
+    Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+    Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
+    [reword commit log, use a separate lock]
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 80e419de0dff38436b30d363311c625766193f86
+Author: Inbal Hacohen <Inbal.Hacohen@intel.com>
+Date:   Wed Feb 12 09:32:27 2014 +0200
+
+    cfg80211: bugfix in regulatory user hint process
+    
+    After processing hint_user, we would want to schedule the
+    timeout work only if we are actually waiting to CRDA. This happens
+    when the status is not "IGNORE" nor "ALREADY_SET".
+    
+    Signed-off-by: Inbal Hacohen <Inbal.Hacohen@intel.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 6514c93afede55284e2cb63359aadedb85884c80
+Author: Jouni Malinen <jouni@qca.qualcomm.com>
+Date:   Tue Feb 18 20:41:08 2014 +0200
+
+    ath9k: Enable U-APSD AP mode support
+    
+    mac80211 handles the actual operations, so ath9k can just indicate
+    support for this. Based on initial tests, this combination seems to
+    work fine.
+    
+    Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
+
+commit a63caf0a357ad5c1f08d6b7827dc76c451445017
+Author: Stanislaw Gruszka <sgruszka@redhat.com>
+Date:   Wed Feb 19 13:15:17 2014 +0100
+
+    ath9k: protect tid->sched check
+    
+    We check tid->sched without a lock taken on ath_tx_aggr_sleep(). That
+    is race condition which can result of doing list_del(&tid->list) twice
+    (second time with poisoned list node) and cause crash like shown below:
+    
+    [424271.637220] BUG: unable to handle kernel paging request at 00100104
+    [424271.637328] IP: [<f90fc072>] ath_tx_aggr_sleep+0x62/0xe0 [ath9k]
+    ...
+    [424271.639953] Call Trace:
+    [424271.639998]  [<f90f6900>] ? ath9k_get_survey+0x110/0x110 [ath9k]
+    [424271.640083]  [<f90f6942>] ath9k_sta_notify+0x42/0x50 [ath9k]
+    [424271.640177]  [<f809cfef>] sta_ps_start+0x8f/0x1c0 [mac80211]
+    [424271.640258]  [<c10f730e>] ? free_compound_page+0x2e/0x40
+    [424271.640346]  [<f809e915>] ieee80211_rx_handlers+0x9d5/0x2340 [mac80211]
+    [424271.640437]  [<c112f048>] ? kmem_cache_free+0x1d8/0x1f0
+    [424271.640510]  [<c1345a84>] ? kfree_skbmem+0x34/0x90
+    [424271.640578]  [<c10fc23c>] ? put_page+0x2c/0x40
+    [424271.640640]  [<c1345a84>] ? kfree_skbmem+0x34/0x90
+    [424271.640706]  [<c1345a84>] ? kfree_skbmem+0x34/0x90
+    [424271.640787]  [<f809dde3>] ? ieee80211_rx_handlers_result+0x73/0x1d0 [mac80211]
+    [424271.640897]  [<f80a07a0>] ieee80211_prepare_and_rx_handle+0x520/0xad0 [mac80211]
+    [424271.641009]  [<f809e22d>] ? ieee80211_rx_handlers+0x2ed/0x2340 [mac80211]
+    [424271.641104]  [<c13846ce>] ? ip_output+0x7e/0xd0
+    [424271.641182]  [<f80a1057>] ieee80211_rx+0x307/0x7c0 [mac80211]
+    [424271.641266]  [<f90fa6ee>] ath_rx_tasklet+0x88e/0xf70 [ath9k]
+    [424271.641358]  [<f80a0f2c>] ? ieee80211_rx+0x1dc/0x7c0 [mac80211]
+    [424271.641445]  [<f90f82db>] ath9k_tasklet+0xcb/0x130 [ath9k]
+    
+    Bug report:
+    https://bugzilla.kernel.org/show_bug.cgi?id=70551
+    
+    Reported-and-tested-by: Max Sydorenko <maxim.stargazer@gmail.com>
+    Cc: stable@vger.kernel.org
+    Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+
+commit 82ed9e3ccc02797df2ffe4b78127c4cd5f799a41
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Tue Feb 11 15:54:13 2014 +0100
+
+    mac80211: send control port protocol frames to the VO queue
+    
+    Improves reliability of wifi connections with WPA, since authentication
+    frames are prioritized over normal traffic and also typically exempt
+    from aggregation.
+    
+    Cc: stable@vger.kernel.org
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+commit d4426800f71e972feaa33e04c5801fc730627bdd
+Author: Stanislaw Gruszka <stf_xl@wp.pl>
+Date:   Mon Feb 10 22:38:28 2014 +0100
+
+    rtl8187: fix regression on MIPS without coherent DMA
+    
+    This patch fixes regression caused by commit a16dad77634 "MIPS: Fix
+    potencial corruption". That commit fixes one corruption scenario in
+    cost of adding another one, which actually start to cause crashes
+    on Yeeloong laptop when rtl8187 driver is used.
+    
+    For correct DMA read operation on machines without DMA coherence, kernel
+    have to invalidate cache, such it will refill later with new data that
+    device wrote to memory, when that data is needed to process. We can only
+    invalidate full cache line. Hence when cache line includes both dma
+    buffer and some other data (written in cache, but not yet in main
+    memory), the other data can not hit memory due to invalidation. That
+    happen on rtl8187 where struct rtl8187_priv fields are located just
+    before and after small buffers that are passed to USB layer and DMA
+    is performed on them.
+    
+    To fix the problem we align buffers and reserve space after them to make
+    them match cache line.
+    
+    This patch does not resolve all possible MIPS problems entirely, for
+    that we have to assure that we always map cache aligned buffers for DMA,
+    what can be complex or even not possible. But patch fixes visible and
+    reproducible regression and seems other possible corruptions do not
+    happen in practice, since Yeeloong laptop works stable without rtl8187
+    driver.
+    
+    Bug report:
+    https://bugzilla.kernel.org/show_bug.cgi?id=54391
+    
+    Reported-by: Petr Pisar <petr.pisar@atlas.cz>
+    Bisected-by: Tom Li <biergaizi2009@gmail.com>
+    Reported-and-tested-by: Tom Li <biergaizi2009@gmail.com>
+    Cc: stable@vger.kernel.org
+    Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
+
+commit e2f141d67ad1e7fe10aaab61811e8a409dfb2442
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Fri Feb 7 10:29:55 2014 +0530
+
+    ath9k: Calculate IQ-CAL median
+    
+    This patch adds a routine to calculate the median IQ correction
+    values for AR955x, which is used for outlier detection.
+    The normal method which is used for all other chips is
+    bypassed for AR955x.
+    
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit c52a6fce0820c8d0687443ab86058ae03b478c8f
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Fri Feb 7 10:29:54 2014 +0530
+
+    ath9k: Expand the IQ coefficient array
+    
+    This will be used for storing data for mutiple
+    IQ calibration runs, for AR955x.
+    
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit 034969ff5c2b6431d10e07c1938f0b916da85cc3
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Fri Feb 7 10:29:53 2014 +0530
+
+    ath9k: Modify IQ calibration for AR955x
+    
+    IQ calibration post-processing for AR955x is different
+    from other chips - instead of just doing it as part
+    of AGC calibration once, it is triggered 3 times and
+    a median is determined. This patch adds initial support
+    for changing the calibration behavior for AR955x.
+    
+    Also, to simplify things, a helper routine to issue/poll
+    AGC calibration is used.
+    
+    For non-AR955x chips, the iqcal_idx (which will be used
+    in subsequent patches) is set to zero.
+    
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit 9b1ed6454e6f3511f24266be99b4e403f243f6a8
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Fri Feb 7 10:29:52 2014 +0530
+
+    ath9k: Fix magnitude/phase calculation
+    
+    Incorrect values are programmed in the registers
+    containing the IQ correction coefficients by the IQ-CAL
+    post-processing code. Fix this.
+    
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit 36f93484f96f79171dcecb67c5ef0c3de22531a6
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Fri Feb 7 10:29:51 2014 +0530
+
+    ath9k: Rename ar9003_hw_tx_iqcal_load_avg_2_passes
+    
+    Use ar9003_hw_tx_iq_cal_outlier_detection instead.
+    
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit 3af09a7f5d21dd5fd15b973ce6a91a575da30417
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Fri Feb 7 10:29:50 2014 +0530
+
+    ath9k: Check explicitly for IQ calibration
+    
+    In chips like AR955x, the initvals contain the information
+    whether IQ calibration is to be done in the HW when an
+    AGC calibration is triggered. Check if IQ-CAL is enabled
+    in the initvals before flagging 'txiqcal_done' as true.
+    
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit cb4969634b93c4643a32cc3fbd27d2b288b25771
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Fri Feb 7 10:29:49 2014 +0530
+
+    ath9k: Fix IQ cal post processing for SoC
+    
+    Calibration data is not reused for SoC chips, so
+    call ar9003_hw_tx_iq_cal_post_proc() with the correct
+    argument. The 'is_reusable' flag is currently used
+    only for PC-OEM chips, but it makes things clearer to
+    specify it explicity.
+    
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit e138e0ef9560c46ce93dbb22a728a57888e94d1c
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Mon Feb 3 13:31:37 2014 +0530
+
+    ath9k: Fix TX power calculation
+    
+    The commit, "ath9k_hw: Fix incorrect Tx control power in AR9003 template"
+    fixed the incorrect values in the eeprom templates, but if
+    boards have already been calibrated with incorrect values,
+    they would still be using the wrong TX power. Fix this by assigning
+    a default value in such cases.
+    
+    Cc: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit b9f268b5b01331c3c82179abca551429450e9417
+Author: Michal Kazior <michal.kazior@tieto.com>
+Date:   Wed Jan 29 14:22:27 2014 +0100
+
+    cfg80211: consider existing DFS interfaces
+    
+    It was possible to break interface combinations in
+    the following way:
+    
+     combo 1: iftype = AP, num_ifaces = 2, num_chans = 2,
+     combo 2: iftype = AP, num_ifaces = 1, num_chans = 1, radar = HT20
+    
+    With the above interface combinations it was
+    possible to:
+    
+     step 1. start AP on DFS channel by matching combo 2
+     step 2. start AP on non-DFS channel by matching combo 1
+    
+    This was possible beacuse (step 2) did not consider
+    if other interfaces require radar detection.
+    
+    The patch changes how cfg80211 tracks channels -
+    instead of channel itself now a complete chandef
+    is stored.
+    
+    Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit bc9c62f5f511cc395c62dbf4cdd437f23db53b28
+Author: Antonio Quartulli <antonio@open-mesh.com>
+Date:   Wed Jan 29 17:53:43 2014 +0100
+
+    cfg80211: fix channel configuration in IBSS join
+    
+    When receiving an IBSS_JOINED event select the BSS object
+    based on the {bssid, channel} couple rather than the bssid
+    only.
+    With the current approach if another cell having the same
+    BSSID (but using a different channel) exists then cfg80211
+    picks up the wrong BSS object.
+    The result is a mismatching channel configuration between
+    cfg80211 and the driver, that can lead to any sort of
+    problem.
+    
+    The issue can be triggered by having an IBSS sitting on
+    given channel and then asking the driver to create a new
+    cell using the same BSSID but with a different frequency.
+    By passing the channel to cfg80211_get_bss() we can solve
+    this ambiguity and retrieve/create the correct BSS object.
+    All the users of cfg80211_ibss_joined() have been changed
+    accordingly.
+    
+    Moreover WARN when cfg80211_ibss_joined() gets a NULL
+    channel as argument and remove a bogus call of the same
+    function in ath6kl (it does not make sense to call
+    cfg80211_ibss_joined() with a zero BSSID on ibss-leave).
+    
+    Cc: Kalle Valo <kvalo@qca.qualcomm.com>
+    Cc: Arend van Spriel <arend@broadcom.com>
+    Cc: Bing Zhao <bzhao@marvell.com>
+    Cc: Jussi Kivilinna <jussi.kivilinna@iki.fi>
+    Cc: libertas-dev@lists.infradead.org
+    Acked-by: Kalle Valo <kvalo@qca.qualcomm.com>
+    Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
+    [minor code cleanup in ath6kl]
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 7e0c41cb41f215aba2c39b1c237bb4d42ec49a85
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Fri Jan 24 14:41:44 2014 +0100
+
+    mac80211: fix bufferable MMPDU RX handling
+    
+    Action, disassoc and deauth frames are bufferable, and as such don't
+    have the PM bit in the frame control field reserved which means we
+    need to react to the bit when receiving in such a frame.
+    
+    Fix this by introducing a new helper ieee80211_is_bufferable_mmpdu()
+    and using it for the RX path that currently ignores the PM bit in
+    any non-data frames for doze->wake transitions, but listens to it in
+    all frames for wake->doze transitions, both of which are wrong.
+    
+    Also use the new helper in the TX path to clean up the code.
+    
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit fc0df6d2343636e3f48a069330d5b972e3d8659d
+Author: Janusz Dziedzic <janusz.dziedzic@tieto.com>
+Date:   Fri Jan 24 14:29:21 2014 +0100
+
+    cfg80211: set preset_chandef after channel switch
+    
+    Set preset_chandef in channel switch notification.
+    In other case we will have old preset_chandef.
+    
+    Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit cdec895e2344987ff171cece96e25d7407a3ebf6
+Author: Simon Wunderlich <simon@open-mesh.com>
+Date:   Fri Jan 24 23:48:29 2014 +0100
+
+    mac80211: send ibss probe responses with noack flag
+    
+    Responding to probe requests for scanning clients will often create
+    excessive retries, as it happens quite often that the scanning client
+    already left the channel. Therefore do it like hostapd and send probe
+    responses for wildcard SSID only once by using the noack flag.
+    
+    Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
+    [fix typo & 'wildcard SSID' in commit log]
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 0b865d1e6b9c05052adae9315df7cb195dc60c3b
+Author: Luciano Coelho <luciano.coelho@intel.com>
+Date:   Tue Jan 28 17:09:08 2014 +0200
+
+    mac80211: ibss: remove unnecessary call to release channel
+    
+    The ieee80211_vif_use_channel() function calls
+    ieee80211_vif_release_channel(), so there's no need to call it
+    explicitly in __ieee80211_sta_join_ibss().
+    
+    Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit e1b6c17e971f0a51ff86c2dac2584c63cd999cd7
+Author: Michal Kazior <michal.kazior@tieto.com>
+Date:   Wed Jan 29 07:56:21 2014 +0100
+
+    mac80211: add missing CSA locking
+    
+    The patch adds a missing sdata lock and adds a few
+    lockdeps for easier maintenance.
+    
+    Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit ad17ba7d14d225b109b73c177cd446afb8050598
+Author: Michal Kazior <michal.kazior@tieto.com>
+Date:   Wed Jan 29 07:56:20 2014 +0100
+
+    mac80211: fix sdata->radar_required locking
+    
+    radar_required setting wasn't protected by
+    local->mtx in some places. This should prevent
+    from scanning/radar detection/roc colliding.
+    
+    Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 5fcd5f1808813a3d9e502fd756e01bee8a79c85d
+Author: Michal Kazior <michal.kazior@tieto.com>
+Date:   Wed Jan 29 07:56:19 2014 +0100
+
+    mac80211: move csa_active setting in STA CSA
+    
+    The sdata->vif.csa_active could be left set after,
+    e.g. channel context constraints check fail in STA
+    mode leaving the interface in a strange state for
+    a brief period of time until it is disconnected.
+    This was harmless but ugly.
+    
+    Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
+    Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit e486da4b7eed71821c6b4c1bb9ac62ffd3ab13e9
+Author: Michal Kazior <michal.kazior@tieto.com>
+Date:   Wed Jan 29 07:56:18 2014 +0100
+
+    mac80211: fix possible memory leak on AP CSA failure
+    
+    If CSA for AP interface failed and the interface
+    was not stopped afterwards another CSA request
+    would leak sdata->u.ap.next_beacon.
+    
+    Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
+    Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 3a77ba08940682bf3d52cf14f980337324af9d4a
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Sat Feb 1 00:33:29 2014 +0100
+
+    mac80211: fix fragmentation code, particularly for encryption
+    
+    The "new" fragmentation code (since my rewrite almost 5 years ago)
+    erroneously sets skb->len rather than using skb_trim() to adjust
+    the length of the first fragment after copying out all the others.
+    This leaves the skb tail pointer pointing to after where the data
+    originally ended, and thus causes the encryption MIC to be written
+    at that point, rather than where it belongs: immediately after the
+    data.
+    
+    The impact of this is that if software encryption is done, then
+     a) encryption doesn't work for the first fragment, the connection
+        becomes unusable as the first fragment will never be properly
+        verified at the receiver, the MIC is practically guaranteed to
+        be wrong
+     b) we leak up to 8 bytes of plaintext (!) of the packet out into
+        the air
+    
+    This is only mitigated by the fact that many devices are capable
+    of doing encryption in hardware, in which case this can't happen
+    as the tail pointer is irrelevant in that case. Additionally,
+    fragmentation is not used very frequently and would normally have
+    to be configured manually.
+    
+    Fix this by using skb_trim() properly.
+    
+    Cc: stable@vger.kernel.org
+    Fixes: 2de8e0d999b8 ("mac80211: rewrite fragmentation")
+    Reported-by: Jouni Malinen <j@w1.fi>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit de5f242e0c10e841017e37eb8c38974a642dbca8
+Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+Date:   Tue Jan 28 06:21:59 2014 +0530
+
+    ath9k: Fix build error on ARM
+    
+    Use mdelay instead of udelay to fix this error:
+    
+    ERROR: "__bad_udelay" [drivers/net/wireless/ath/ath9k/ath9k_hw.ko] undefined!
+    make[1]: *** [__modpost] Error 1
+    make: *** [modules] Error 2
+    
+    Reported-by: Josh Boyer <jwboyer@fedoraproject.org>
+    Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
+
+commit 8e3ea7a51dfc61810fcefd947f6edcf61125252a
+Author: Geert Uytterhoeven <geert@linux-m68k.org>
+Date:   Sun Jan 26 11:53:21 2014 +0100
+
+    ath9k: Fix uninitialized variable in ath9k_has_tx_pending()
+    
+    drivers/net/wireless/ath/ath9k/main.c: In function ‘ath9k_has_tx_pending’:
+    drivers/net/wireless/ath/ath9k/main.c:1869: warning: ‘npend’ may be used uninitialized in this function
+    
+    Introduced by commit 10e2318103f5941aa70c318afe34bc41f1b98529 ("ath9k:
+    optimize ath9k_flush").
+    
+    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
+
+commit a4a634a6937ebdd827fa58e8fcdb8ca49a3769f6
+Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+Date:   Mon Jan 27 11:07:42 2014 +0200
+
+    mac80211: release the channel in error path in start_ap
+    
+    When the driver cannot start the AP or when the assignement
+    of the beacon goes wrong, we need to unassign the vif.
+    
+    Cc: stable@vger.kernel.org
+    Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit dfb6889a75c601aedb7450b7e606668e77da6679
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Wed Jan 22 11:14:19 2014 +0200
+
+    cfg80211: send scan results from work queue
+    
+    Due to the previous commit, when a scan finishes, it is in theory
+    possible to hit the following sequence:
+     1. interface starts being removed
+     2. scan is cancelled by driver and cfg80211 is notified
+     3. scan done work is scheduled
+     4. interface is removed completely, rdev->scan_req is freed,
+        event sent to userspace but scan done work remains pending
+     5. new scan is requested on another virtual interface
+     6. scan done work runs, freeing the still-running scan
+    
+    To fix this situation, hang on to the scan done message and block
+    new scans while that is the case, and only send the message from
+    the work function, regardless of whether the scan_req is already
+    freed from interface removal. This makes step 5 above impossible
+    and changes step 6 to be
+     5. scan done work runs, sending the scan done message
+    
+    As this can't work for wext, so we send the message immediately,
+    but this shouldn't be an issue since we still return -EBUSY.
+    
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 45b7ab41fc08627d9a8428cb413d5d84662a9707
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Wed Jan 22 11:14:18 2014 +0200
+
+    cfg80211: fix scan done race
+    
+    When an interface/wdev is removed, any ongoing scan should be
+    cancelled by the driver. This will make it call cfg80211, which
+    only queues a work struct. If interface/wdev removal is quick
+    enough, this can leave the scan request pending and processed
+    only after the interface is gone, causing a use-after-free.
+    
+    Fix this by making sure the scan request is not pending after
+    the interface is destroyed. We can't flush or cancel the work
+    item due to locking concerns, but when it'll run it shouldn't
+    find anything to do. This leaves a potential issue, if a new
+    scan gets requested before the work runs, it prematurely stops
+    the running scan, potentially causing another crash. I'll fix
+    that in the next patch.
+    
+    This was particularly observed with P2P_DEVICE wdevs, likely
+    because freeing them is quicker than freeing netdevs.
+    
+    Reported-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
+    Fixes: 4a58e7c38443 ("cfg80211: don't "leak" uncompleted scans")
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit ae04fa489ab31b5a10d3cc8399f52761175d4321
+Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+Date:   Thu Jan 23 14:28:16 2014 +0200
+
+    mac80211: avoid deadlock revealed by lockdep
+    
+    sdata->u.ap.request_smps_work can’t be flushed synchronously
+    under wdev_lock(wdev) since ieee80211_request_smps_ap_work
+    itself locks the same lock.
+    While at it, reset the driver_smps_mode when the ap is
+    stopped to its default: OFF.
+    
+    This solves:
+    
+    ======================================================
+    [ INFO: possible circular locking dependency detected ]
+    3.12.0-ipeer+ #2 Tainted: G           O
+    -------------------------------------------------------
+    rmmod/2867 is trying to acquire lock:
+      ((&sdata->u.ap.request_smps_work)){+.+...}, at: [<c105b8d0>] flush_work+0x0/0x90
+    
+    but task is already holding lock:
+      (&wdev->mtx){+.+.+.}, at: [<f9b32626>] cfg80211_stop_ap+0x26/0x230 [cfg80211]
+    
+    which lock already depends on the new lock.
+    
+    the existing dependency chain (in reverse order) is:
+    
+    -> #1 (&wdev->mtx){+.+.+.}:
+            [<c10aefa9>] lock_acquire+0x79/0xe0
+            [<c1607a1a>] mutex_lock_nested+0x4a/0x360
+            [<fb06288b>] ieee80211_request_smps_ap_work+0x2b/0x50 [mac80211]
+            [<c105cdd8>] process_one_work+0x198/0x450
+            [<c105d469>] worker_thread+0xf9/0x320
+            [<c10669ff>] kthread+0x9f/0xb0
+            [<c1613397>] ret_from_kernel_thread+0x1b/0x28
+    
+    -> #0 ((&sdata->u.ap.request_smps_work)){+.+...}:
+            [<c10ae9df>] __lock_acquire+0x183f/0x1910
+            [<c10aefa9>] lock_acquire+0x79/0xe0
+            [<c105b917>] flush_work+0x47/0x90
+            [<c105d867>] __cancel_work_timer+0x67/0xe0
+            [<c105d90f>] cancel_work_sync+0xf/0x20
+            [<fb0765cc>] ieee80211_stop_ap+0x8c/0x340 [mac80211]
+            [<f9b3268c>] cfg80211_stop_ap+0x8c/0x230 [cfg80211]
+            [<f9b0d8f9>] cfg80211_leave+0x79/0x100 [cfg80211]
+            [<f9b0da72>] cfg80211_netdev_notifier_call+0xf2/0x4f0 [cfg80211]
+            [<c160f2c9>] notifier_call_chain+0x59/0x130
+            [<c106c6de>] __raw_notifier_call_chain+0x1e/0x30
+            [<c106c70f>] raw_notifier_call_chain+0x1f/0x30
+            [<c14f8213>] call_netdevice_notifiers_info+0x33/0x70
+            [<c14f8263>] call_netdevice_notifiers+0x13/0x20
+            [<c14f82a4>] __dev_close_many+0x34/0xb0
+            [<c14f83fe>] dev_close_many+0x6e/0xc0
+            [<c14f9c77>] rollback_registered_many+0xa7/0x1f0
+            [<c14f9dd4>] unregister_netdevice_many+0x14/0x60
+            [<fb06f4d9>] ieee80211_remove_interfaces+0xe9/0x170 [mac80211]
+            [<fb055116>] ieee80211_unregister_hw+0x56/0x110 [mac80211]
+            [<fa3e9396>] iwl_op_mode_mvm_stop+0x26/0xe0 [iwlmvm]
+            [<f9b9d8ca>] _iwl_op_mode_stop+0x3a/0x70 [iwlwifi]
+            [<f9b9d96f>] iwl_opmode_deregister+0x6f/0x90 [iwlwifi]
+            [<fa405179>] __exit_compat+0xd/0x19 [iwlmvm]
+            [<c10b8bf9>] SyS_delete_module+0x179/0x2b0
+            [<c1613421>] sysenter_do_call+0x12/0x32
+    
+    Fixes: 687da132234f ("mac80211: implement SMPS for AP")
+    Cc: <stable@vger.kernel.org> [3.13]
+    Reported-by: Ilan Peer <ilan.peer@intel.com>
+    Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 178b205e96217164fd7c30113464250d0b6f5eca
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Thu Jan 23 16:32:29 2014 +0100
+
+    cfg80211: re-enable 5/10 MHz support
+    
+    Unfortunately I forgot this during the merge window, but the
+    patch seems small enough to go in as a fix. The userspace API
+    bug that was the reason for disabling it has long been fixed.
+    
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 110a1c79acda14edc83b7c8dc5af9c7ddd23eb61
+Author: Pontus Fuchs <pontus.fuchs@gmail.com>
+Date:   Thu Jan 16 15:00:40 2014 +0100
+
+    nl80211: Reset split_start when netlink skb is exhausted
+    
+    When the netlink skb is exhausted split_start is left set. In the
+    subsequent retry, with a larger buffer, the dump is continued from the
+    failing point instead of from the beginning.
+    
+    This was causing my rt28xx based USB dongle to now show up when
+    running "iw list" with an old iw version without split dump support.
+    
+    Cc: stable@vger.kernel.org
+    Fixes: 3713b4e364ef ("nl80211: allow splitting wiphy information in dumps")
+    Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>
+    [avoid the entire workaround when state->split is set]
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit b4c31b45ffc7ef110fa9ecc34d7878fe7c5b9da4
+Author: Eliad Peller <eliad@wizery.com>
+Date:   Sun Jan 12 11:06:37 2014 +0200
+
+    mac80211: move roc cookie assignment earlier
+    
+    ieee80211_start_roc_work() might add a new roc
+    to existing roc, and tell cfg80211 it has already
+    started.
+    
+    However, this might happen before the roc cookie
+    was set, resulting in REMAIN_ON_CHANNEL (started)
+    event with null cookie. Consequently, it can make
+    wpa_supplicant go out of sync.
+    
+    Fix it by setting the roc cookie earlier.
+    
+    Cc: stable@vger.kernel.org
+    Signed-off-by: Eliad Peller <eliad@wizery.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit cfdc9157bfd7bcf88ab4dae08873a9907eba984c
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Fri Jan 24 14:06:29 2014 +0100
+
+    nl80211: send event when AP operation is stopped
+    
+    There are a few cases, e.g. suspend, where an AP interface is
+    stopped by the kernel rather than by userspace request, most
+    commonly when suspending. To let userspace know about this,
+    send the NL80211_CMD_STOP_AP command as an event every time
+    an AP interface is stopped. This also happens when userspace
+    did in fact request the AP stop, but that's not a problem.
+    
+    For full-MAC drivers this may need to be extended to also
+    cover cases where the device stopped the AP operation for
+    some reason, this a bit more complicated because then all
+    cfg80211 state also needs to be reset; such API is not part
+    of this patch.
+    
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit d5d567eda7704f190379ca852a8f9a4112e3eee3
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Thu Jan 23 16:20:29 2014 +0100
+
+    mac80211: add length check in ieee80211_is_robust_mgmt_frame()
+    
+    A few places weren't checking that the frame passed to the
+    function actually has enough data even though the function
+    clearly documents it must have a payload byte. Make this
+    safer by changing the function to take an skb and checking
+    the length inside. The old version is preserved for now as
+    the rtl* drivers use it and don't have a correct skb.
+    
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit f8f6d212a047fc65c7d3442dfc038f65517236fc
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Fri Jan 24 10:53:53 2014 +0100
+
+    nl80211: fix scheduled scan RSSI matchset attribute confusion
+    
+    The scheduled scan matchsets were intended to be a list of filters,
+    with the found BSS having to pass at least one of them to be passed
+    to the host. When the RSSI attribute was added, however, this was
+    broken and currently wpa_supplicant adds that attribute in its own
+    matchset; however, it doesn't intend that to mean that anything
+    that passes the RSSI filter should be passed to the host, instead
+    it wants it to mean that everything needs to also have higher RSSI.
+    
+    This is semantically problematic because we have a list of filters
+    like [ SSID1, SSID2, SSID3, RSSI ] with no real indication which
+    one should be OR'ed and which one AND'ed.
+    
+    To fix this, move the RSSI filter attribute into each matchset. As
+    we need to stay backward compatible, treat a matchset with only the
+    RSSI attribute as a "default RSSI filter" for all other matchsets,
+    but only if there are other matchsets (an RSSI-only matchset by
+    itself is still desirable.)
+    
+    To make driver implementation easier, keep a global min_rssi_thold
+    for the entire request as well. The only affected driver is ath6kl.
+    
+    I found this when I looked into the code after Raja Mani submitted
+    a patch fixing the n_match_sets calculation to disregard the RSSI,
+    but that patch didn't address the semantic issue.
+    
+    Reported-by: Raja Mani <rmani@qti.qualcomm.com>
+    Acked-by: Luciano Coelho <luciano.coelho@intel.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit de553e8545e65a6dc4e45f43df7e1443d4291922
+Author: Johannes Berg <johannes.berg@intel.com>
+Date:   Fri Jan 24 10:17:47 2014 +0100
+
+    nl80211: check nla_parse() return values
+    
+    If there's a policy, then nla_parse() return values must be
+    checked, otherwise the policy is useless and there's nothing
+    that ensures the attributes are actually what we expect them
+    to be.
+    
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+
+commit 652204a0733e9e1c54661d6f9d36e2e1e3b22bb1
+Author: Karl Beldan <karl.beldan@rivierawaves.com>
+Date:   Thu Jan 23 20:06:34 2014 +0100
+
+    mac80211: send {ADD,DEL}BA on AC_VO like other mgmt frames, as per spec
+    
+    ATM, {ADD,DEL}BA and BAR frames are sent on the AC matching the TID of
+    the BA parameters. In the discussion [1] about this patch, Johannes
+    recalled that it fixed some races with the DELBA and indeed this
+    behavior was introduced in [2].
+    While [2] is right for the BARs, the part queueing the {ADD,DEL}BAs on
+    their BA params TID AC violates the spec and is more a workaround for
+    some drivers. Helmut expressed some concerns wrt such drivers, in
+    particular DELBAs in rt2x00.
+    
+    ATM, DELBAs are sent after a driver has called (hence "purposely")
+    ieee80211_start_tx_ba_cb_irqsafe and Johannes and Emmanuel gave some
+    details wrt intentions behind the split of the IEEE80211_AMPDU_TX_STOP_*
+    given to the driver ampdu_action supposed to call this function, which
+    could prove handy to people trying to do the right thing in faulty
+    drivers (if their fw/hw don't get in their way).
+    
+    [1] http://mid.gmane.org/1390391564-18481-1-git-send-email-karl.beldan@gmail.com
+    [2] Commit: cf6bb79ad828 ("mac80211: Use appropriate TID for sending BAR, ADDBA and DELBA frames")
+    
+    Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
+    Cc: Helmut Schaa <helmut.schaa@googlemail.com>
+    Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
+    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
++++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
+@@ -790,7 +790,7 @@ void ath6kl_cfg80211_connect_event(struc
+ 	if (nw_type & ADHOC_NETWORK) {
+ 		ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "ad-hoc %s selected\n",
+ 			   nw_type & ADHOC_CREATOR ? "creator" : "joiner");
+-		cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL);
++		cfg80211_ibss_joined(vif->ndev, bssid, chan, GFP_KERNEL);
+ 		cfg80211_put_bss(ar->wiphy, bss);
+ 		return;
+ 	}
+@@ -861,13 +861,9 @@ void ath6kl_cfg80211_disconnect_event(st
+ 	}
+ 
+ 	if (vif->nw_type & ADHOC_NETWORK) {
+-		if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC) {
++		if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC)
+ 			ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
+ 				   "%s: ath6k not in ibss mode\n", __func__);
+-			return;
+-		}
+-		memset(bssid, 0, ETH_ALEN);
+-		cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL);
+ 		return;
+ 	}
+ 
+@@ -3256,6 +3252,15 @@ static int ath6kl_cfg80211_sscan_start(s
+ 	struct ath6kl_vif *vif = netdev_priv(dev);
+ 	u16 interval;
+ 	int ret, rssi_thold;
++	int n_match_sets = request->n_match_sets;
++
++	/*
++	 * If there's a matchset w/o an SSID, then assume it's just for
++	 * the RSSI (nothing else is currently supported) and ignore it.
++	 * The device only supports a global RSSI filter that we set below.
++	 */
++	if (n_match_sets == 1 && !request->match_sets[0].ssid.ssid_len)
++		n_match_sets = 0;
+ 
+ 	if (ar->state != ATH6KL_STATE_ON)
+ 		return -EIO;
+@@ -3268,11 +3273,11 @@ static int ath6kl_cfg80211_sscan_start(s
+ 	ret = ath6kl_set_probed_ssids(ar, vif, request->ssids,
+ 				      request->n_ssids,
+ 				      request->match_sets,
+-				      request->n_match_sets);
++				      n_match_sets);
+ 	if (ret < 0)
+ 		return ret;
+ 
+-	if (!request->n_match_sets) {
++	if (!n_match_sets) {
+ 		ret = ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
+ 					       ALL_BSS_FILTER, 0);
+ 		if (ret < 0)
+@@ -3286,12 +3291,12 @@ static int ath6kl_cfg80211_sscan_start(s
+ 
+ 	if (test_bit(ATH6KL_FW_CAPABILITY_RSSI_SCAN_THOLD,
+ 		     ar->fw_capabilities)) {
+-		if (request->rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
++		if (request->min_rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
+ 			rssi_thold = 0;
+-		else if (request->rssi_thold < -127)
++		else if (request->min_rssi_thold < -127)
+ 			rssi_thold = -127;
+ 		else
+-			rssi_thold = request->rssi_thold;
++			rssi_thold = request->min_rssi_thold;
+ 
+ 		ret = ath6kl_wmi_set_rssi_filter_cmd(ar->wmi, vif->fw_vif_idx,
+ 						     rssi_thold);
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1316,7 +1316,7 @@ static bool ath9k_hw_set_reset(struct at
+ 	if (AR_SREV_9300_20_OR_LATER(ah))
+ 		udelay(50);
+ 	else if (AR_SREV_9100(ah))
+-		udelay(10000);
++		mdelay(10);
+ 	else
+ 		udelay(100);
+ 
+@@ -2051,9 +2051,8 @@ static bool ath9k_hw_set_power_awake(str
+ 
+ 	REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
+ 		    AR_RTC_FORCE_WAKE_EN);
+-
+ 	if (AR_SREV_9100(ah))
+-		udelay(10000);
++		mdelay(10);
+ 	else
+ 		udelay(50);
+ 
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -451,7 +451,7 @@ void ath9k_tasklet(unsigned long data)
+ 		 * interrupts are enabled in the reset routine.
+ 		 */
+ 		atomic_inc(&ah->intr_ref_cnt);
+-		ath_dbg(common, ANY, "FATAL: Skipping interrupts\n");
++		ath_dbg(common, RESET, "FATAL: Skipping interrupts\n");
+ 		goto out;
+ 	}
+ 
+@@ -471,7 +471,7 @@ void ath9k_tasklet(unsigned long data)
+ 			 * interrupts are enabled in the reset routine.
+ 			 */
+ 			atomic_inc(&ah->intr_ref_cnt);
+-			ath_dbg(common, ANY,
++			ath_dbg(common, RESET,
+ 				"BB_WATCHDOG: Skipping interrupts\n");
+ 			goto out;
+ 		}
+@@ -484,7 +484,7 @@ void ath9k_tasklet(unsigned long data)
+ 			type = RESET_TYPE_TX_GTT;
+ 			ath9k_queue_reset(sc, type);
+ 			atomic_inc(&ah->intr_ref_cnt);
+-			ath_dbg(common, ANY,
++			ath_dbg(common, RESET,
+ 				"GTT: Skipping interrupts\n");
+ 			goto out;
+ 		}
+@@ -1866,7 +1866,7 @@ static void ath9k_set_coverage_class(str
+ 
+ static bool ath9k_has_tx_pending(struct ath_softc *sc)
+ {
+-	int i, npend;
++	int i, npend = 0;
+ 
+ 	for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
+ 		if (!ATH_TXQ_SETUP(sc, i))
+--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
++++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
+@@ -595,6 +595,9 @@ static void iwl_scan_offload_build_ssid(
+ 	 * config match list.
+ 	 */
+ 	for (i = 0; i < req->n_match_sets && i < PROBE_OPTION_MAX; i++) {
++		/* skip empty SSID matchsets */
++		if (!req->match_sets[i].ssid.ssid_len)
++			continue;
+ 		scan->direct_scan[i].id = WLAN_EID_SSID;
+ 		scan->direct_scan[i].len = req->match_sets[i].ssid.ssid_len;
+ 		memcpy(scan->direct_scan[i].ssid, req->match_sets[i].ssid.ssid,
+--- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
+@@ -452,7 +452,7 @@ bool rtl88ee_rx_query_desc(struct ieee80
+ 			/* During testing, hdr was NULL */
+ 			return false;
+ 		}
+-		if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
++		if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
+ 		    (ieee80211_has_protected(hdr->frame_control)))
+ 			rx_status->flag &= ~RX_FLAG_DECRYPTED;
+ 		else
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+@@ -393,7 +393,7 @@ bool rtl92ce_rx_query_desc(struct ieee80
+ 			/* In testing, hdr was NULL here */
+ 			return false;
+ 		}
+-		if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
++		if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
+ 		    (ieee80211_has_protected(hdr->frame_control)))
+ 			rx_status->flag &= ~RX_FLAG_DECRYPTED;
+ 		else
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+@@ -310,7 +310,7 @@ bool rtl92se_rx_query_desc(struct ieee80
+ 			/* during testing, hdr was NULL here */
+ 			return false;
+ 		}
+-		if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
++		if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
+ 			(ieee80211_has_protected(hdr->frame_control)))
+ 			rx_status->flag &= ~RX_FLAG_DECRYPTED;
+ 		else
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
+@@ -334,7 +334,7 @@ bool rtl8723ae_rx_query_desc(struct ieee
+ 			/* during testing, hdr could be NULL here */
+ 			return false;
+ 		}
+-		if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
++		if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
+ 			(ieee80211_has_protected(hdr->frame_control)))
+ 			rx_status->flag &= ~RX_FLAG_DECRYPTED;
+ 		else
+--- a/include/linux/ieee80211.h
++++ b/include/linux/ieee80211.h
+@@ -597,6 +597,20 @@ static inline int ieee80211_is_qos_nullf
+ }
+ 
+ /**
++ * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
++ * @fc: frame control field in little-endian byteorder
++ */
++static inline bool ieee80211_is_bufferable_mmpdu(__le16 fc)
++{
++	/* IEEE 802.11-2012, definition of "bufferable management frame";
++	 * note that this ignores the IBSS special case. */
++	return ieee80211_is_mgmt(fc) &&
++	       (ieee80211_is_action(fc) ||
++		ieee80211_is_disassoc(fc) ||
++		ieee80211_is_deauth(fc));
++}
++
++/**
+  * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
+  * @seq_ctrl: frame sequence control bytes in little-endian byteorder
+  */
+@@ -2192,10 +2206,10 @@ static inline u8 *ieee80211_get_DA(struc
+ }
+ 
+ /**
+- * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
++ * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
+  * @hdr: the frame (buffer must include at least the first octet of payload)
+  */
+-static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
++static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
+ {
+ 	if (ieee80211_is_disassoc(hdr->frame_control) ||
+ 	    ieee80211_is_deauth(hdr->frame_control))
+@@ -2224,6 +2238,17 @@ static inline bool ieee80211_is_robust_m
+ }
+ 
+ /**
++ * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
++ * @skb: the skb containing the frame, length will be checked
++ */
++static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
++{
++	if (skb->len < 25)
++		return false;
++	return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
++}
++
++/**
+  * ieee80211_is_public_action - check if frame is a public action frame
+  * @hdr: the frame
+  * @len: length of the frame
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -1395,9 +1395,11 @@ struct cfg80211_scan_request {
+  * struct cfg80211_match_set - sets of attributes to match
+  *
+  * @ssid: SSID to be matched
++ * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
+  */
+ struct cfg80211_match_set {
+ 	struct cfg80211_ssid ssid;
++	s32 rssi_thold;
+ };
+ 
+ /**
+@@ -1420,7 +1422,8 @@ struct cfg80211_match_set {
+  * @dev: the interface
+  * @scan_start: start time of the scheduled scan
+  * @channels: channels to scan
+- * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
++ * @min_rssi_thold: for drivers only supporting a single threshold, this
++ *	contains the minimum over all matchsets
+  */
+ struct cfg80211_sched_scan_request {
+ 	struct cfg80211_ssid *ssids;
+@@ -1433,7 +1436,7 @@ struct cfg80211_sched_scan_request {
+ 	u32 flags;
+ 	struct cfg80211_match_set *match_sets;
+ 	int n_match_sets;
+-	s32 rssi_thold;
++	s32 min_rssi_thold;
+ 
+ 	/* internal */
+ 	struct wiphy *wiphy;
+@@ -3130,8 +3133,8 @@ struct cfg80211_cached_keys;
+  * @identifier: (private) Identifier used in nl80211 to identify this
+  *	wireless device if it has no netdev
+  * @current_bss: (private) Used by the internal configuration code
+- * @channel: (private) Used by the internal configuration code to track
+- *	the user-set AP, monitor and WDS channel
++ * @chandef: (private) Used by the internal configuration code to track
++ *	the user-set channel definition.
+  * @preset_chandef: (private) Used by the internal configuration code to
+  *	track the channel to be used for AP later
+  * @bssid: (private) Used by the internal configuration code
+@@ -3195,9 +3198,7 @@ struct wireless_dev {
+ 
+ 	struct cfg80211_internal_bss *current_bss; /* associated / joined */
+ 	struct cfg80211_chan_def preset_chandef;
+-
+-	/* for AP and mesh channel tracking */
+-	struct ieee80211_channel *channel;
++	struct cfg80211_chan_def chandef;
+ 
+ 	bool ibss_fixed;
+ 	bool ibss_dfs_possible;
+@@ -3879,6 +3880,7 @@ void cfg80211_michael_mic_failure(struct
+  *
+  * @dev: network device
+  * @bssid: the BSSID of the IBSS joined
++ * @channel: the channel of the IBSS joined
+  * @gfp: allocation flags
+  *
+  * This function notifies cfg80211 that the device joined an IBSS or
+@@ -3888,7 +3890,8 @@ void cfg80211_michael_mic_failure(struct
+  * with the locally generated beacon -- this guarantees that there is
+  * always a scan result for this IBSS. cfg80211 will handle the rest.
+  */
+-void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp);
++void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
++			  struct ieee80211_channel *channel, gfp_t gfp);
+ 
+ /**
+  * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
+--- a/include/uapi/linux/nl80211.h
++++ b/include/uapi/linux/nl80211.h
+@@ -2442,9 +2442,15 @@ enum nl80211_reg_rule_attr {
+  * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
+  * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
+  * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
+- * only report BSS with matching SSID.
++ *	only report BSS with matching SSID.
+  * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
+- *	BSS in scan results. Filtering is turned off if not specified.
++ *	BSS in scan results. Filtering is turned off if not specified. Note that
++ *	if this attribute is in a match set of its own, then it is treated as
++ *	the default value for all matchsets with an SSID, rather than being a
++ *	matchset of its own without an RSSI filter. This is due to problems with
++ *	how this API was implemented in the past. Also, due to the same problem,
++ *	the only way to create a matchset with only an RSSI filter (with this
++ *	attribute) is if there's only a single matchset with the RSSI attribute.
+  * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
+  *	attribute number currently defined
+  * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
 --- a/net/mac80211/agg-tx.c
 +++ b/net/mac80211/agg-tx.c
-@@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
- 	memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
- 	if (sdata->vif.type == NL80211_IFTYPE_AP ||
- 	    sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
--	    sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
-+	    sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
-+	    sdata->vif.type == NL80211_IFTYPE_WDS)
- 		memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
- 	else if (sdata->vif.type == NL80211_IFTYPE_STATION)
- 		memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
-@@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
- 	    sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
- 	    sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
- 	    sdata->vif.type != NL80211_IFTYPE_AP &&
-+	    sdata->vif.type != NL80211_IFTYPE_WDS &&
- 	    sdata->vif.type != NL80211_IFTYPE_ADHOC)
- 		return -EINVAL;
- 
---- a/net/mac80211/debugfs_sta.c
-+++ b/net/mac80211/debugfs_sta.c
-@@ -66,11 +66,11 @@ static ssize_t sta_flags_read(struct fil
- 	test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
- 
- 	int res = scnprintf(buf, sizeof(buf),
--			    "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
-+			    "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
- 			    TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
- 			    TEST(PS_DRIVER), TEST(AUTHORIZED),
- 			    TEST(SHORT_PREAMBLE),
--			    TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
-+			    TEST(WME), TEST(CLEAR_PS_FILT),
- 			    TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
- 			    TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
- 			    TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
-@@ -455,6 +455,15 @@ void ieee80211_sta_debugfs_add(struct st
- 	DEBUGFS_ADD_COUNTER(tx_retry_count, tx_retry_count);
- 	DEBUGFS_ADD_COUNTER(wep_weak_iv_count, wep_weak_iv_count);
- 
-+	if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
-+		debugfs_create_x32("driver_buffered_tids", 0400,
-+				   sta->debugfs.dir,
-+				   (u32 *)&sta->driver_buffered_tids);
-+	else
-+		debugfs_create_x64("driver_buffered_tids", 0400,
-+				   sta->debugfs.dir,
-+				   (u64 *)&sta->driver_buffered_tids);
-+
- 	drv_sta_add_debugfs(local, sdata, &sta->sta, sta->debugfs.dir);
+@@ -107,7 +107,7 @@ static void ieee80211_send_addba_request
+ 	mgmt->u.action.u.addba_req.start_seq_num =
+ 					cpu_to_le16(start_seq_num << 4);
+ 
+-	ieee80211_tx_skb_tid(sdata, skb, tid);
++	ieee80211_tx_skb(sdata, skb);
  }
  
---- a/net/mac80211/iface.c
-+++ b/net/mac80211/iface.c
-@@ -274,6 +274,12 @@ static int ieee80211_check_concurrent_if
- 			if (iftype == NL80211_IFTYPE_ADHOC &&
- 			    nsdata->vif.type == NL80211_IFTYPE_ADHOC)
- 				return -EBUSY;
-+			/*
-+			 * will not add another interface while any channel
-+			 * switch is active.
-+			 */
-+			if (nsdata->vif.csa_active)
-+				return -EBUSY;
- 
- 			/*
- 			 * The remaining checks are only performed for interfaces
-@@ -463,7 +469,6 @@ int ieee80211_do_open(struct wireless_de
- 	struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
- 	struct net_device *dev = wdev->netdev;
- 	struct ieee80211_local *local = sdata->local;
--	struct sta_info *sta;
- 	u32 changed = 0;
- 	int res;
- 	u32 hw_reconf_flags = 0;
-@@ -629,30 +634,8 @@ int ieee80211_do_open(struct wireless_de
- 
- 	set_bit(SDATA_STATE_RUNNING, &sdata->state);
- 
--	if (sdata->vif.type == NL80211_IFTYPE_WDS) {
--		/* Create STA entry for the WDS peer */
--		sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
--				     GFP_KERNEL);
--		if (!sta) {
--			res = -ENOMEM;
--			goto err_del_interface;
+ void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn)
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -970,9 +970,9 @@ static int ieee80211_start_ap(struct wip
+ 	/* TODO: make hostapd tell us what it wants */
+ 	sdata->smps_mode = IEEE80211_SMPS_OFF;
+ 	sdata->needed_rx_chains = sdata->local->rx_chains;
+-	sdata->radar_required = params->radar_required;
+ 
+ 	mutex_lock(&local->mtx);
++	sdata->radar_required = params->radar_required;
+ 	err = ieee80211_vif_use_channel(sdata, &params->chandef,
+ 					IEEE80211_CHANCTX_SHARED);
+ 	mutex_unlock(&local->mtx);
+@@ -1021,8 +1021,10 @@ static int ieee80211_start_ap(struct wip
+ 					IEEE80211_P2P_OPPPS_ENABLE_BIT;
+ 
+ 	err = ieee80211_assign_beacon(sdata, &params->beacon);
+-	if (err < 0)
++	if (err < 0) {
++		ieee80211_vif_release_channel(sdata);
+ 		return err;
++	}
+ 	changed |= err;
+ 
+ 	err = drv_start_ap(sdata->local, sdata);
+@@ -1032,6 +1034,7 @@ static int ieee80211_start_ap(struct wip
+ 		if (old)
+ 			kfree_rcu(old, rcu_head);
+ 		RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
++		ieee80211_vif_release_channel(sdata);
+ 		return err;
+ 	}
+ 
+@@ -1053,6 +1056,7 @@ static int ieee80211_change_beacon(struc
+ 	int err;
+ 
+ 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
++	sdata_assert_lock(sdata);
+ 
+ 	/* don't allow changing the beacon while CSA is in place - offset
+ 	 * of channel switch counter may change
+@@ -1080,6 +1084,8 @@ static int ieee80211_stop_ap(struct wiph
+ 	struct probe_resp *old_probe_resp;
+ 	struct cfg80211_chan_def chandef;
+ 
++	sdata_assert_lock(sdata);
++
+ 	old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
+ 	if (!old_beacon)
+ 		return -ENOENT;
+@@ -1090,8 +1096,6 @@ static int ieee80211_stop_ap(struct wiph
+ 	kfree(sdata->u.ap.next_beacon);
+ 	sdata->u.ap.next_beacon = NULL;
+ 
+-	cancel_work_sync(&sdata->u.ap.request_smps_work);
+-
+ 	/* turn off carrier for this interface and dependent VLANs */
+ 	list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
+ 		netif_carrier_off(vlan->dev);
+@@ -1103,6 +1107,7 @@ static int ieee80211_stop_ap(struct wiph
+ 	kfree_rcu(old_beacon, rcu_head);
+ 	if (old_probe_resp)
+ 		kfree_rcu(old_probe_resp, rcu_head);
++	sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
+ 
+ 	__sta_info_flush(sdata, true);
+ 	ieee80211_free_keys(sdata, true);
+@@ -2638,6 +2643,24 @@ static int ieee80211_start_roc_work(stru
+ 	INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
+ 	INIT_LIST_HEAD(&roc->dependents);
+ 
++	/*
++	 * cookie is either the roc cookie (for normal roc)
++	 * or the SKB (for mgmt TX)
++	 */
++	if (!txskb) {
++		/* local->mtx protects this */
++		local->roc_cookie_counter++;
++		roc->cookie = local->roc_cookie_counter;
++		/* wow, you wrapped 64 bits ... more likely a bug */
++		if (WARN_ON(roc->cookie == 0)) {
++			roc->cookie = 1;
++			local->roc_cookie_counter++;
++		}
++		*cookie = roc->cookie;
++	} else {
++		*cookie = (unsigned long)txskb;
++	}
++
+ 	/* if there's one pending or we're scanning, queue this one */
+ 	if (!list_empty(&local->roc_list) ||
+ 	    local->scanning || local->radar_detect_enabled)
+@@ -2772,24 +2795,6 @@ static int ieee80211_start_roc_work(stru
+ 	if (!queued)
+ 		list_add_tail(&roc->list, &local->roc_list);
+ 
+-	/*
+-	 * cookie is either the roc cookie (for normal roc)
+-	 * or the SKB (for mgmt TX)
+-	 */
+-	if (!txskb) {
+-		/* local->mtx protects this */
+-		local->roc_cookie_counter++;
+-		roc->cookie = local->roc_cookie_counter;
+-		/* wow, you wrapped 64 bits ... more likely a bug */
+-		if (WARN_ON(roc->cookie == 0)) {
+-			roc->cookie = 1;
+-			local->roc_cookie_counter++;
 -		}
--
--		sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
--		sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
--		sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
--
--		res = sta_info_insert(sta);
--		if (res) {
--			/* STA has been freed */
--			goto err_del_interface;
--		}
--
--		rate_control_rate_init(sta);
--		netif_carrier_on(dev);
--	} else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
-+	if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
- 		rcu_assign_pointer(local->p2p_sdata, sdata);
--	}
- 
- 	/*
- 	 * set_multicast_list will be invoked by the networking core
-@@ -809,6 +792,8 @@ static void ieee80211_do_stop(struct iee
- 	cancel_work_sync(&local->dynamic_ps_enable_work);
- 
- 	cancel_work_sync(&sdata->recalc_smps);
-+	sdata->vif.csa_active = false;
-+	cancel_work_sync(&sdata->csa_finalize_work);
- 
- 	cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
- 
-@@ -1116,6 +1101,74 @@ static void ieee80211_if_setup(struct ne
- 	dev->destructor = free_netdev;
- }
- 
-+static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
-+					 struct sk_buff *skb)
-+{
-+	struct ieee80211_local *local = sdata->local;
-+	struct ieee80211_rx_status *rx_status;
-+	struct ieee802_11_elems elems;
-+	struct ieee80211_mgmt *mgmt;
-+	struct sta_info *sta;
-+	size_t baselen;
-+	u32 rates = 0;
-+	u16 stype;
-+	bool new = false;
-+	enum ieee80211_band band;
-+	struct ieee80211_supported_band *sband;
-+
-+	rx_status = IEEE80211_SKB_RXCB(skb);
-+	band = rx_status->band;
-+	sband = local->hw.wiphy->bands[band];
-+	mgmt = (struct ieee80211_mgmt *) skb->data;
-+	stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
-+
-+	if (stype != IEEE80211_STYPE_BEACON)
-+		return;
-+
-+	baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
-+	if (baselen > skb->len)
-+		return;
-+
-+	ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
-+			       skb->len - baselen, false, &elems);
-+
-+	rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
-+
-+	rcu_read_lock();
-+
-+	sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
-+
-+	if (!sta) {
-+		rcu_read_unlock();
-+		sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
-+				     GFP_KERNEL);
-+		if (!sta)
-+			return;
-+
-+		new = true;
-+	}
-+
-+	sta->last_rx = jiffies;
-+	sta->sta.supp_rates[band] = rates;
-+
-+	if (elems.ht_cap_elem)
-+		ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
-+				elems.ht_cap_elem, sta);
-+
-+	if (elems.wmm_param)
-+		set_sta_flag(sta, WLAN_STA_WME);
-+
-+	if (new) {
-+		sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
-+		sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
-+		sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
-+		rate_control_rate_init(sta);
-+		sta_info_insert_rcu(sta);
-+	}
-+
-+	rcu_read_unlock();
-+}
-+
- static void ieee80211_iface_work(struct work_struct *work)
- {
- 	struct ieee80211_sub_if_data *sdata =
-@@ -1220,6 +1273,9 @@ static void ieee80211_iface_work(struct 
- 				break;
- 			ieee80211_mesh_rx_queued_mgmt(sdata, skb);
- 			break;
-+		case NL80211_IFTYPE_WDS:
-+			ieee80211_wds_rx_queued_mgmt(sdata, skb);
-+			break;
- 		default:
- 			WARN(1, "frame for unexpected interface type");
- 			break;
-@@ -1282,6 +1338,7 @@ static void ieee80211_setup_sdata(struct
- 	skb_queue_head_init(&sdata->skb_queue);
- 	INIT_WORK(&sdata->work, ieee80211_iface_work);
- 	INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work);
-+	INIT_WORK(&sdata->csa_finalize_work, ieee80211_csa_finalize_work);
- 
- 	switch (type) {
- 	case NL80211_IFTYPE_P2P_GO:
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -365,6 +365,14 @@ minstrel_ht_update_stats(struct minstrel
- 		}
- 	}
- 
-+#ifdef CPTCFG_MAC80211_DEBUGFS
-+	/* use fixed index if set */
-+	if (mp->fixed_rate_idx != -1) {
-+		mi->max_tp_rate = mp->fixed_rate_idx;
-+		mi->max_tp_rate2 = mp->fixed_rate_idx;
-+		mi->max_prob_rate = mp->fixed_rate_idx;
-+	}
-+#endif
- 
- 	mi->stats_update = jiffies;
- }
-@@ -774,6 +782,11 @@ minstrel_ht_get_rate(void *priv, struct 
- 	info->flags |= mi->tx_flags;
- 	minstrel_ht_check_cck_shortpreamble(mp, mi, txrc->short_preamble);
- 
-+#ifdef CPTCFG_MAC80211_DEBUGFS
-+	if (mp->fixed_rate_idx != -1)
-+		return;
-+#endif
-+
- 	/* Don't use EAPOL frames for sampling on non-mrr hw */
- 	if (mp->hw->max_rates == 1 &&
- 	    txrc->skb->protocol == cpu_to_be16(ETH_P_PAE))
-@@ -781,16 +794,6 @@ minstrel_ht_get_rate(void *priv, struct 
- 	else
- 		sample_idx = minstrel_get_sample_rate(mp, mi);
- 
--#ifdef CPTCFG_MAC80211_DEBUGFS
--	/* use fixed index if set */
--	if (mp->fixed_rate_idx != -1) {
--		mi->max_tp_rate = mp->fixed_rate_idx;
--		mi->max_tp_rate2 = mp->fixed_rate_idx;
--		mi->max_prob_rate = mp->fixed_rate_idx;
--		sample_idx = -1;
--	}
--#endif
--
- 	mi->total_packets++;
- 
- 	/* wraparound */
-@@ -804,10 +807,18 @@ minstrel_ht_get_rate(void *priv, struct 
- 
- 	sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
- 	info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
-+	rate->count = 1;
-+
-+	if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
-+		int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
-+		rate->idx = mp->cck_rates[idx];
-+		rate->flags = 0;
-+		return;
-+	}
-+
- 	rate->idx = sample_idx % MCS_GROUP_RATES +
- 		    (sample_group->streams - 1) * MCS_GROUP_RATES;
- 	rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
--	rate->count = 1;
- }
- 
- static void
-@@ -820,6 +831,9 @@ minstrel_ht_update_cck(struct minstrel_p
- 	if (sband->band != IEEE80211_BAND_2GHZ)
- 		return;
- 
-+	if (!(mp->hw->flags & IEEE80211_HW_SUPPORTS_HT_CCK_RATES))
-+		return;
-+
- 	mi->cck_supported = 0;
- 	mi->cck_supported_short = 0;
- 	for (i = 0; i < 4; i++) {
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -936,8 +936,14 @@ ieee80211_rx_h_check(struct ieee80211_rx
- 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
- 	struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
- 
--	/* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
--	if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
-+	/*
-+	 * Drop duplicate 802.11 retransmissions
-+	 * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
-+	 */
-+	if (rx->skb->len >= 24 && rx->sta &&
-+	    !ieee80211_is_ctl(hdr->frame_control) &&
-+	    !ieee80211_is_qos_nullfunc(hdr->frame_control) &&
-+	    !is_multicast_ether_addr(hdr->addr1)) {
- 		if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
- 			     rx->sta->last_seq_ctrl[rx->seqno_idx] ==
- 			     hdr->seq_ctrl)) {
-@@ -2369,6 +2375,7 @@ ieee80211_rx_h_action(struct ieee80211_r
- 		    sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
- 		    sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
- 		    sdata->vif.type != NL80211_IFTYPE_AP &&
-+		    sdata->vif.type != NL80211_IFTYPE_WDS &&
- 		    sdata->vif.type != NL80211_IFTYPE_ADHOC)
- 			break;
- 
-@@ -2720,14 +2727,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
- 
- 	if (!ieee80211_vif_is_mesh(&sdata->vif) &&
- 	    sdata->vif.type != NL80211_IFTYPE_ADHOC &&
--	    sdata->vif.type != NL80211_IFTYPE_STATION)
-+	    sdata->vif.type != NL80211_IFTYPE_STATION &&
-+	    sdata->vif.type != NL80211_IFTYPE_WDS)
- 		return RX_DROP_MONITOR;
- 
- 	switch (stype) {
- 	case cpu_to_le16(IEEE80211_STYPE_AUTH):
- 	case cpu_to_le16(IEEE80211_STYPE_BEACON):
- 	case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
--		/* process for all: mesh, mlme, ibss */
-+		/* process for all: mesh, mlme, ibss, wds */
- 		break;
- 	case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
- 	case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
-@@ -3008,6 +3016,9 @@ static int prepare_for_handlers(struct i
- 	case NL80211_IFTYPE_ADHOC:
- 		if (!bssid)
- 			return 0;
-+		if (ether_addr_equal(sdata->vif.addr, hdr->addr2) ||
-+		    ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2))
-+			return 0;
- 		if (ieee80211_is_beacon(hdr->frame_control)) {
- 			return 1;
- 		} else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) {
-@@ -3059,10 +3070,16 @@ static int prepare_for_handlers(struct i
- 		}
- 		break;
- 	case NL80211_IFTYPE_WDS:
--		if (bssid || !ieee80211_is_data(hdr->frame_control))
--			return 0;
- 		if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
- 			return 0;
-+
-+		if (ieee80211_is_data(hdr->frame_control) ||
-+		    ieee80211_is_action(hdr->frame_control)) {
-+			if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
-+				return 0;
-+		} else if (!ieee80211_is_beacon(hdr->frame_control))
-+			return 0;
-+
- 		break;
- 	case NL80211_IFTYPE_P2P_DEVICE:
- 		if (!ieee80211_is_public_action(hdr, skb->len) &&
---- a/net/mac80211/sta_info.h
-+++ b/net/mac80211/sta_info.h
-@@ -32,7 +32,6 @@
-  * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
-  *	frames.
-  * @WLAN_STA_WME: Station is a QoS-STA.
-- * @WLAN_STA_WDS: Station is one of our WDS peers.
-  * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
-  *	IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
-  *	frame to this station is transmitted.
-@@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
- 	WLAN_STA_AUTHORIZED,
- 	WLAN_STA_SHORT_PREAMBLE,
- 	WLAN_STA_WME,
--	WLAN_STA_WDS,
- 	WLAN_STA_CLEAR_PS_FILT,
- 	WLAN_STA_MFP,
- 	WLAN_STA_BLOCK_BA,
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -135,6 +135,9 @@ static struct ath_frame_info *get_frame_
- 
- static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno)
- {
-+	if (!tid->an->sta)
-+		return;
-+
- 	ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno,
- 			   seqno << IEEE80211_SEQ_SEQ_SHIFT);
- }
-@@ -146,6 +149,93 @@ static void ath_set_rates(struct ieee802
- 			       ARRAY_SIZE(bf->rates));
- }
- 
-+static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
-+			     struct sk_buff *skb)
-+{
-+	int q;
-+
-+	q = skb_get_queue_mapping(skb);
-+	if (txq == sc->tx.uapsdq)
-+		txq = sc->tx.txq_map[q];
-+
-+	if (txq != sc->tx.txq_map[q])
-+		return;
-+
-+	if (WARN_ON(--txq->pending_frames < 0))
-+		txq->pending_frames = 0;
-+
-+	if (txq->stopped &&
-+	    txq->pending_frames < sc->tx.txq_max_pending[q]) {
-+		ieee80211_wake_queue(sc->hw, q);
-+		txq->stopped = false;
-+	}
-+}
-+
-+static struct ath_atx_tid *
-+ath_get_skb_tid(struct ath_softc *sc, struct ath_node *an, struct sk_buff *skb)
-+{
-+	struct ieee80211_hdr *hdr;
-+	u8 tidno = 0;
-+
-+	hdr = (struct ieee80211_hdr *) skb->data;
-+	if (ieee80211_is_data_qos(hdr->frame_control))
-+		tidno = ieee80211_get_qos_ctl(hdr)[0];
-+
-+	tidno &= IEEE80211_QOS_CTL_TID_MASK;
-+	return ATH_AN_2_TID(an, tidno);
-+}
-+
-+static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
-+{
-+	return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
-+}
-+
-+static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
-+{
-+	struct sk_buff *skb;
-+
-+	skb = __skb_dequeue(&tid->retry_q);
-+	if (!skb)
-+		skb = __skb_dequeue(&tid->buf_q);
-+
-+	return skb;
-+}
-+
-+/*
-+ * ath_tx_tid_change_state:
-+ * - clears a-mpdu flag of previous session
-+ * - force sequence number allocation to fix next BlockAck Window
-+ */
-+static void
-+ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
-+{
-+	struct ath_txq *txq = tid->ac->txq;
-+	struct ieee80211_tx_info *tx_info;
-+	struct sk_buff *skb, *tskb;
-+	struct ath_buf *bf;
-+	struct ath_frame_info *fi;
-+
-+	skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
-+		fi = get_frame_info(skb);
-+		bf = fi->bf;
-+
-+		tx_info = IEEE80211_SKB_CB(skb);
-+		tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
-+
-+		if (bf)
-+			continue;
-+
-+		bf = ath_tx_setup_buffer(sc, txq, tid, skb);
-+		if (!bf) {
-+			__skb_unlink(skb, &tid->buf_q);
-+			ath_txq_skb_done(sc, txq, skb);
-+			ieee80211_free_txskb(sc->hw, skb);
-+			continue;
-+		}
-+	}
-+
-+}
-+
- static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
- {
- 	struct ath_txq *txq = tid->ac->txq;
-@@ -160,27 +250,22 @@ static void ath_tx_flush_tid(struct ath_
- 
- 	memset(&ts, 0, sizeof(ts));
- 
--	while ((skb = __skb_dequeue(&tid->buf_q))) {
-+	while ((skb = __skb_dequeue(&tid->retry_q))) {
- 		fi = get_frame_info(skb);
- 		bf = fi->bf;
--
- 		if (!bf) {
--			bf = ath_tx_setup_buffer(sc, txq, tid, skb);
--			if (!bf) {
--				ieee80211_free_txskb(sc->hw, skb);
--				continue;
--			}
-+			ath_txq_skb_done(sc, txq, skb);
-+			ieee80211_free_txskb(sc->hw, skb);
-+			continue;
- 		}
- 
--		if (fi->retries) {
--			list_add_tail(&bf->list, &bf_head);
-+		if (fi->baw_tracked) {
- 			ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
--			ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
- 			sendbar = true;
--		} else {
--			ath_set_rates(tid->an->vif, tid->an->sta, bf);
--			ath_tx_send_normal(sc, txq, NULL, skb);
- 		}
-+
-+		list_add_tail(&bf->list, &bf_head);
-+		ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
- 	}
- 
- 	if (sendbar) {
-@@ -209,13 +294,16 @@ static void ath_tx_update_baw(struct ath
- }
- 
- static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
--			     u16 seqno)
-+			     struct ath_buf *bf)
- {
-+	struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
-+	u16 seqno = bf->bf_state.seqno;
- 	int index, cindex;
- 
- 	index  = ATH_BA_INDEX(tid->seq_start, seqno);
- 	cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
- 	__set_bit(cindex, tid->tx_buf);
-+	fi->baw_tracked = 1;
- 
- 	if (index >= ((tid->baw_tail - tid->baw_head) &
- 		(ATH_TID_MAX_BUFS - 1))) {
-@@ -224,12 +312,6 @@ static void ath_tx_addto_baw(struct ath_
- 	}
- }
- 
--/*
-- * TODO: For frame(s) that are in the retry state, we will reuse the
-- * sequence number(s) without setting the retry bit. The
-- * alternative is to give up on these and BAR the receiver's window
-- * forward.
-- */
- static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq,
- 			  struct ath_atx_tid *tid)
- 
-@@ -243,7 +325,7 @@ static void ath_tid_drain(struct ath_sof
- 	memset(&ts, 0, sizeof(ts));
- 	INIT_LIST_HEAD(&bf_head);
- 
--	while ((skb = __skb_dequeue(&tid->buf_q))) {
-+	while ((skb = ath_tid_dequeue(tid))) {
- 		fi = get_frame_info(skb);
- 		bf = fi->bf;
- 
-@@ -253,14 +335,8 @@ static void ath_tid_drain(struct ath_sof
- 		}
- 
- 		list_add_tail(&bf->list, &bf_head);
--
--		ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
- 		ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
- 	}
--
--	tid->seq_next = tid->seq_start;
--	tid->baw_tail = tid->baw_head;
--	tid->bar_index = -1;
- }
- 
- static void ath_tx_set_retry(struct ath_softc *sc, struct ath_txq *txq,
-@@ -323,6 +399,7 @@ static struct ath_buf* ath_clone_txbuf(s
- 	tbf->bf_buf_addr = bf->bf_buf_addr;
- 	memcpy(tbf->bf_desc, bf->bf_desc, sc->sc_ah->caps.tx_desc_len);
- 	tbf->bf_state = bf->bf_state;
-+	tbf->bf_state.stale = false;
- 
- 	return tbf;
- }
-@@ -380,7 +457,6 @@ static void ath_tx_complete_aggr(struct 
- 	struct ieee80211_tx_rate rates[4];
- 	struct ath_frame_info *fi;
- 	int nframes;
--	u8 tidno;
- 	bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH);
- 	int i, retries;
- 	int bar_index = -1;
-@@ -406,7 +482,7 @@ static void ath_tx_complete_aggr(struct 
- 		while (bf) {
- 			bf_next = bf->bf_next;
- 
--			if (!bf->bf_stale || bf_next != NULL)
-+			if (!bf->bf_state.stale || bf_next != NULL)
- 				list_move_tail(&bf->list, &bf_head);
- 
- 			ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0);
-@@ -417,8 +493,7 @@ static void ath_tx_complete_aggr(struct 
- 	}
- 
- 	an = (struct ath_node *)sta->drv_priv;
--	tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
--	tid = ATH_AN_2_TID(an, tidno);
-+	tid = ath_get_skb_tid(sc, an, skb);
- 	seq_first = tid->seq_start;
- 	isba = ts->ts_flags & ATH9K_TX_BA;
- 
-@@ -430,7 +505,7 @@ static void ath_tx_complete_aggr(struct 
- 	 * Only BlockAcks have a TID and therefore normal Acks cannot be
- 	 * checked
- 	 */
--	if (isba && tidno != ts->tid)
-+	if (isba && tid->tidno != ts->tid)
- 		txok = false;
- 
- 	isaggr = bf_isaggr(bf);
-@@ -466,7 +541,8 @@ static void ath_tx_complete_aggr(struct 
- 		tx_info = IEEE80211_SKB_CB(skb);
- 		fi = get_frame_info(skb);
- 
--		if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
-+		if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) ||
-+		    !tid->active) {
- 			/*
- 			 * Outside of the current BlockAck window,
- 			 * maybe part of a previous session
-@@ -499,7 +575,7 @@ static void ath_tx_complete_aggr(struct 
- 		 * not a holding desc.
- 		 */
- 		INIT_LIST_HEAD(&bf_head);
--		if (bf_next != NULL || !bf_last->bf_stale)
-+		if (bf_next != NULL || !bf_last->bf_state.stale)
- 			list_move_tail(&bf->list, &bf_head);
- 
- 		if (!txpending) {
-@@ -523,7 +599,7 @@ static void ath_tx_complete_aggr(struct 
- 				ieee80211_sta_eosp(sta);
- 			}
- 			/* retry the un-acked ones */
--			if (bf->bf_next == NULL && bf_last->bf_stale) {
-+			if (bf->bf_next == NULL && bf_last->bf_state.stale) {
- 				struct ath_buf *tbf;
- 
- 				tbf = ath_clone_txbuf(sc, bf_last);
-@@ -560,7 +636,7 @@ static void ath_tx_complete_aggr(struct 
- 		if (an->sleeping)
- 			ieee80211_sta_set_buffered(sta, tid->tidno, true);
- 
--		skb_queue_splice(&bf_pending, &tid->buf_q);
-+		skb_queue_splice_tail(&bf_pending, &tid->retry_q);
- 		if (!an->sleeping) {
- 			ath_tx_queue_tid(txq, tid);
- 
-@@ -618,7 +694,7 @@ static void ath_tx_process_buffer(struct
- 	} else
- 		ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok);
- 
--	if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !flush)
-+	if (!flush)
- 		ath_txq_schedule(sc, txq);
- }
- 
-@@ -792,15 +868,20 @@ static int ath_compute_num_delims(struct
- 
- static struct ath_buf *
- ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
--			struct ath_atx_tid *tid)
-+			struct ath_atx_tid *tid, struct sk_buff_head **q)
- {
-+	struct ieee80211_tx_info *tx_info;
- 	struct ath_frame_info *fi;
- 	struct sk_buff *skb;
- 	struct ath_buf *bf;
- 	u16 seqno;
- 
- 	while (1) {
--		skb = skb_peek(&tid->buf_q);
-+		*q = &tid->retry_q;
-+		if (skb_queue_empty(*q))
-+			*q = &tid->buf_q;
-+
-+		skb = skb_peek(*q);
- 		if (!skb)
- 			break;
- 
-@@ -808,13 +889,26 @@ ath_tx_get_tid_subframe(struct ath_softc
- 		bf = fi->bf;
- 		if (!fi->bf)
- 			bf = ath_tx_setup_buffer(sc, txq, tid, skb);
-+		else
-+			bf->bf_state.stale = false;
- 
- 		if (!bf) {
--			__skb_unlink(skb, &tid->buf_q);
-+			__skb_unlink(skb, *q);
-+			ath_txq_skb_done(sc, txq, skb);
- 			ieee80211_free_txskb(sc->hw, skb);
- 			continue;
- 		}
- 
-+		bf->bf_next = NULL;
-+		bf->bf_lastbf = bf;
-+
-+		tx_info = IEEE80211_SKB_CB(skb);
-+		tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
-+		if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
-+			bf->bf_state.bf_type = 0;
-+			return bf;
-+		}
-+
- 		bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR;
- 		seqno = bf->bf_state.seqno;
- 
-@@ -828,73 +922,52 @@ ath_tx_get_tid_subframe(struct ath_softc
- 
- 			INIT_LIST_HEAD(&bf_head);
- 			list_add(&bf->list, &bf_head);
--			__skb_unlink(skb, &tid->buf_q);
-+			__skb_unlink(skb, *q);
- 			ath_tx_update_baw(sc, tid, seqno);
- 			ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
- 			continue;
- 		}
- 
--		bf->bf_next = NULL;
--		bf->bf_lastbf = bf;
- 		return bf;
- 	}
- 
- 	return NULL;
- }
- 
--static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
--					     struct ath_txq *txq,
--					     struct ath_atx_tid *tid,
--					     struct list_head *bf_q,
--					     int *aggr_len)
-+static bool
-+ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
-+		 struct ath_atx_tid *tid, struct list_head *bf_q,
-+		 struct ath_buf *bf_first, struct sk_buff_head *tid_q,
-+		 int *aggr_len)
- {
- #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
--	struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL;
--	int rl = 0, nframes = 0, ndelim, prev_al = 0;
-+	struct ath_buf *bf = bf_first, *bf_prev = NULL;
-+	int nframes = 0, ndelim;
- 	u16 aggr_limit = 0, al = 0, bpad = 0,
--		al_delta, h_baw = tid->baw_size / 2;
--	enum ATH_AGGR_STATUS status = ATH_AGGR_DONE;
-+	    al_delta, h_baw = tid->baw_size / 2;
- 	struct ieee80211_tx_info *tx_info;
- 	struct ath_frame_info *fi;
- 	struct sk_buff *skb;
-+	bool closed = false;
- 
--	do {
--		bf = ath_tx_get_tid_subframe(sc, txq, tid);
--		if (!bf) {
--			status = ATH_AGGR_BAW_CLOSED;
--			break;
--		}
-+	bf = bf_first;
-+	aggr_limit = ath_lookup_rate(sc, bf, tid);
- 
-+	do {
- 		skb = bf->bf_mpdu;
- 		fi = get_frame_info(skb);
- 
--		if (!bf_first)
--			bf_first = bf;
--
--		if (!rl) {
--			ath_set_rates(tid->an->vif, tid->an->sta, bf);
--			aggr_limit = ath_lookup_rate(sc, bf, tid);
--			rl = 1;
--		}
--
- 		/* do not exceed aggregation limit */
- 		al_delta = ATH_AGGR_DELIM_SZ + fi->framelen;
-+		if (nframes) {
-+			if (aggr_limit < al + bpad + al_delta ||
-+			    ath_lookup_legacy(bf) || nframes >= h_baw)
-+				break;
- 
--		if (nframes &&
--		    ((aggr_limit < (al + bpad + al_delta + prev_al)) ||
--		     ath_lookup_legacy(bf))) {
--			status = ATH_AGGR_LIMITED;
--			break;
--		}
--
--		tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
--		if (nframes && (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE))
--			break;
--
--		/* do not exceed subframe limit */
--		if (nframes >= min((int)h_baw, ATH_AMPDU_SUBFRAME_DEFAULT)) {
--			status = ATH_AGGR_LIMITED;
--			break;
-+			tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
-+			if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
-+			    !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
-+				break;
- 		}
- 
- 		/* add padding for previous frame to aggregation length */
-@@ -912,22 +985,37 @@ static enum ATH_AGGR_STATUS ath_tx_form_
- 		bf->bf_next = NULL;
- 
- 		/* link buffers of this frame to the aggregate */
--		if (!fi->retries)
--			ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
-+		if (!fi->baw_tracked)
-+			ath_tx_addto_baw(sc, tid, bf);
- 		bf->bf_state.ndelim = ndelim;
- 
--		__skb_unlink(skb, &tid->buf_q);
-+		__skb_unlink(skb, tid_q);
- 		list_add_tail(&bf->list, bf_q);
- 		if (bf_prev)
- 			bf_prev->bf_next = bf;
- 
- 		bf_prev = bf;
- 
--	} while (!skb_queue_empty(&tid->buf_q));
-+		bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
-+		if (!bf) {
-+			closed = true;
-+			break;
-+		}
-+	} while (ath_tid_has_buffered(tid));
-+
-+	bf = bf_first;
-+	bf->bf_lastbf = bf_prev;
-+
-+	if (bf == bf_prev) {
-+		al = get_frame_info(bf->bf_mpdu)->framelen;
-+		bf->bf_state.bf_type = BUF_AMPDU;
-+	} else {
-+		TX_STAT_INC(txq->axq_qnum, a_aggr);
-+	}
- 
- 	*aggr_len = al;
- 
--	return status;
-+	return closed;
- #undef PADBYTES
- }
- 
-@@ -999,7 +1087,7 @@ void ath_update_max_aggr_framelen(struct
- }
- 
- static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
--			     struct ath_tx_info *info, int len)
-+			     struct ath_tx_info *info, int len, bool rts)
- {
- 	struct ath_hw *ah = sc->sc_ah;
- 	struct sk_buff *skb;
-@@ -1008,6 +1096,7 @@ static void ath_buf_set_rate(struct ath_
- 	const struct ieee80211_rate *rate;
- 	struct ieee80211_hdr *hdr;
- 	struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
-+	u32 rts_thresh = sc->hw->wiphy->rts_threshold;
- 	int i;
- 	u8 rix = 0;
- 
-@@ -1030,7 +1119,17 @@ static void ath_buf_set_rate(struct ath_
- 		rix = rates[i].idx;
- 		info->rates[i].Tries = rates[i].count;
- 
--		    if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
-+		/*
-+		 * Handle RTS threshold for unaggregated HT frames.
-+		 */
-+		if (bf_isampdu(bf) && !bf_isaggr(bf) &&
-+		    (rates[i].flags & IEEE80211_TX_RC_MCS) &&
-+		    unlikely(rts_thresh != (u32) -1)) {
-+			if (!rts_thresh || (len > rts_thresh))
-+				rts = true;
-+		}
-+
-+		if (rts || rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
- 			info->rates[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
- 			info->flags |= ATH9K_TXDESC_RTSENA;
- 		} else if (rates[i].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
-@@ -1123,6 +1222,8 @@ static void ath_tx_fill_desc(struct ath_
- 	struct ath_hw *ah = sc->sc_ah;
- 	struct ath_buf *bf_first = NULL;
- 	struct ath_tx_info info;
-+	u32 rts_thresh = sc->hw->wiphy->rts_threshold;
-+	bool rts = false;
- 
- 	memset(&info, 0, sizeof(info));
- 	info.is_first = true;
-@@ -1159,7 +1260,22 @@ static void ath_tx_fill_desc(struct ath_
- 				info.flags |= (u32) bf->bf_state.bfs_paprd <<
- 					      ATH9K_TXDESC_PAPRD_S;
- 
--			ath_buf_set_rate(sc, bf, &info, len);
-+			/*
-+			 * mac80211 doesn't handle RTS threshold for HT because
-+			 * the decision has to be taken based on AMPDU length
-+			 * and aggregation is done entirely inside ath9k.
-+			 * Set the RTS/CTS flag for the first subframe based
-+			 * on the threshold.
-+			 */
-+			if (aggr && (bf == bf_first) &&
-+			    unlikely(rts_thresh != (u32) -1)) {
-+				/*
-+				 * "len" is the size of the entire AMPDU.
-+				 */
-+				if (!rts_thresh || (len > rts_thresh))
-+					rts = true;
-+			}
-+			ath_buf_set_rate(sc, bf, &info, len, rts);
- 		}
- 
- 		info.buf_addr[0] = bf->bf_buf_addr;
-@@ -1188,64 +1304,101 @@ static void ath_tx_fill_desc(struct ath_
- 	}
- }
- 
--static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
--			      struct ath_atx_tid *tid)
-+static void
-+ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
-+		  struct ath_atx_tid *tid, struct list_head *bf_q,
-+		  struct ath_buf *bf_first, struct sk_buff_head *tid_q)
- {
--	struct ath_buf *bf;
--	enum ATH_AGGR_STATUS status;
--	struct ieee80211_tx_info *tx_info;
--	struct list_head bf_q;
--	int aggr_len;
-+	struct ath_buf *bf = bf_first, *bf_prev = NULL;
-+	struct sk_buff *skb;
-+	int nframes = 0;
- 
- 	do {
--		if (skb_queue_empty(&tid->buf_q))
--			return;
-+		struct ieee80211_tx_info *tx_info;
-+		skb = bf->bf_mpdu;
- 
--		INIT_LIST_HEAD(&bf_q);
-+		nframes++;
-+		__skb_unlink(skb, tid_q);
-+		list_add_tail(&bf->list, bf_q);
-+		if (bf_prev)
-+			bf_prev->bf_next = bf;
-+		bf_prev = bf;
- 
--		status = ath_tx_form_aggr(sc, txq, tid, &bf_q, &aggr_len);
-+		if (nframes >= 2)
-+			break;
- 
--		/*
--		 * no frames picked up to be aggregated;
--		 * block-ack window is not open.
--		 */
--		if (list_empty(&bf_q))
-+		bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
-+		if (!bf)
- 			break;
- 
--		bf = list_first_entry(&bf_q, struct ath_buf, list);
--		bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
- 		tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
-+		if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
-+			break;
- 
--		if (tid->ac->clear_ps_filter) {
--			tid->ac->clear_ps_filter = false;
--			tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
--		} else {
--			tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
--		}
-+		ath_set_rates(tid->an->vif, tid->an->sta, bf);
-+	} while (1);
-+}
- 
--		/* if only one frame, send as non-aggregate */
--		if (bf == bf->bf_lastbf) {
--			aggr_len = get_frame_info(bf->bf_mpdu)->framelen;
--			bf->bf_state.bf_type = BUF_AMPDU;
--		} else {
--			TX_STAT_INC(txq->axq_qnum, a_aggr);
--		}
-+static bool ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
-+			      struct ath_atx_tid *tid, bool *stop)
-+{
-+	struct ath_buf *bf;
-+	struct ieee80211_tx_info *tx_info;
-+	struct sk_buff_head *tid_q;
-+	struct list_head bf_q;
-+	int aggr_len = 0;
-+	bool aggr, last = true;
-+
-+	if (!ath_tid_has_buffered(tid))
-+		return false;
- 
--		ath_tx_fill_desc(sc, bf, txq, aggr_len);
--		ath_tx_txqaddbuf(sc, txq, &bf_q, false);
--	} while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH &&
--		 status != ATH_AGGR_BAW_CLOSED);
-+	INIT_LIST_HEAD(&bf_q);
-+
-+	bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
-+	if (!bf)
-+		return false;
-+
-+	tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
-+	aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
-+	if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
-+		(!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
-+		*stop = true;
-+		return false;
-+	}
-+
-+	ath_set_rates(tid->an->vif, tid->an->sta, bf);
-+	if (aggr)
-+		last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
-+					tid_q, &aggr_len);
-+	else
-+		ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
-+
-+	if (list_empty(&bf_q))
-+		return false;
-+
-+	if (tid->ac->clear_ps_filter || tid->an->no_ps_filter) {
-+		tid->ac->clear_ps_filter = false;
-+		tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
-+	}
-+
-+	ath_tx_fill_desc(sc, bf, txq, aggr_len);
-+	ath_tx_txqaddbuf(sc, txq, &bf_q, false);
-+	return true;
- }
- 
- int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
- 		      u16 tid, u16 *ssn)
- {
- 	struct ath_atx_tid *txtid;
-+	struct ath_txq *txq;
- 	struct ath_node *an;
- 	u8 density;
- 
- 	an = (struct ath_node *)sta->drv_priv;
- 	txtid = ATH_AN_2_TID(an, tid);
-+	txq = txtid->ac->txq;
-+
-+	ath_txq_lock(sc, txq);
- 
- 	/* update ampdu factor/density, they may have changed. This may happen
- 	 * in HT IBSS when a beacon with HT-info is received after the station
-@@ -1258,6 +1411,9 @@ int ath_tx_aggr_start(struct ath_softc *
- 		an->mpdudensity = density;
- 	}
- 
-+	/* force sequence number allocation for pending frames */
-+	ath_tx_tid_change_state(sc, txtid);
-+
- 	txtid->active = true;
- 	txtid->paused = true;
- 	*ssn = txtid->seq_start = txtid->seq_next;
-@@ -1266,6 +1422,8 @@ int ath_tx_aggr_start(struct ath_softc *
- 	memset(txtid->tx_buf, 0, sizeof(txtid->tx_buf));
- 	txtid->baw_head = txtid->baw_tail = 0;
- 
-+	ath_txq_unlock_complete(sc, txq);
-+
- 	return 0;
- }
- 
-@@ -1277,8 +1435,9 @@ void ath_tx_aggr_stop(struct ath_softc *
- 
- 	ath_txq_lock(sc, txq);
- 	txtid->active = false;
--	txtid->paused = true;
-+	txtid->paused = false;
- 	ath_tx_flush_tid(sc, txtid);
-+	ath_tx_tid_change_state(sc, txtid);
- 	ath_txq_unlock_complete(sc, txq);
- }
- 
-@@ -1302,7 +1461,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
- 
- 		ath_txq_lock(sc, txq);
- 
--		buffered = !skb_queue_empty(&tid->buf_q);
-+		buffered = ath_tid_has_buffered(tid);
- 
- 		tid->sched = false;
- 		list_del(&tid->list);
-@@ -1334,7 +1493,7 @@ void ath_tx_aggr_wakeup(struct ath_softc
- 		ath_txq_lock(sc, txq);
- 		ac->clear_ps_filter = true;
- 
--		if (!skb_queue_empty(&tid->buf_q) && !tid->paused) {
-+		if (!tid->paused && ath_tid_has_buffered(tid)) {
- 			ath_tx_queue_tid(txq, tid);
- 			ath_txq_schedule(sc, txq);
- 		}
-@@ -1359,7 +1518,7 @@ void ath_tx_aggr_resume(struct ath_softc
- 	tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
- 	tid->paused = false;
- 
--	if (!skb_queue_empty(&tid->buf_q)) {
-+	if (ath_tid_has_buffered(tid)) {
- 		ath_tx_queue_tid(txq, tid);
- 		ath_txq_schedule(sc, txq);
- 	}
-@@ -1379,6 +1538,7 @@ void ath9k_release_buffered_frames(struc
- 	struct ieee80211_tx_info *info;
- 	struct list_head bf_q;
- 	struct ath_buf *bf_tail = NULL, *bf;
-+	struct sk_buff_head *tid_q;
- 	int sent = 0;
- 	int i;
- 
-@@ -1394,16 +1554,18 @@ void ath9k_release_buffered_frames(struc
- 			continue;
- 
- 		ath_txq_lock(sc, tid->ac->txq);
--		while (!skb_queue_empty(&tid->buf_q) && nframes > 0) {
--			bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid);
-+		while (nframes > 0) {
-+			bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
- 			if (!bf)
- 				break;
- 
--			__skb_unlink(bf->bf_mpdu, &tid->buf_q);
-+			__skb_unlink(bf->bf_mpdu, tid_q);
- 			list_add_tail(&bf->list, &bf_q);
- 			ath_set_rates(tid->an->vif, tid->an->sta, bf);
--			ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
--			bf->bf_state.bf_type &= ~BUF_AGGR;
-+			if (bf_isampdu(bf)) {
-+				ath_tx_addto_baw(sc, tid, bf);
-+				bf->bf_state.bf_type &= ~BUF_AGGR;
-+			}
- 			if (bf_tail)
- 				bf_tail->bf_next = bf;
- 
-@@ -1412,7 +1574,7 @@ void ath9k_release_buffered_frames(struc
- 			sent++;
- 			TX_STAT_INC(txq->axq_qnum, a_queued_hw);
- 
--			if (skb_queue_empty(&tid->buf_q))
-+			if (an->sta && !ath_tid_has_buffered(tid))
- 				ieee80211_sta_set_buffered(an->sta, i, false);
- 		}
- 		ath_txq_unlock_complete(sc, tid->ac->txq);
-@@ -1542,16 +1704,9 @@ int ath_cabq_update(struct ath_softc *sc
- 	int qnum = sc->beacon.cabq->axq_qnum;
- 
- 	ath9k_hw_get_txq_props(sc->sc_ah, qnum, &qi);
--	/*
--	 * Ensure the readytime % is within the bounds.
--	 */
--	if (sc->config.cabqReadytime < ATH9K_READY_TIME_LO_BOUND)
--		sc->config.cabqReadytime = ATH9K_READY_TIME_LO_BOUND;
--	else if (sc->config.cabqReadytime > ATH9K_READY_TIME_HI_BOUND)
--		sc->config.cabqReadytime = ATH9K_READY_TIME_HI_BOUND;
- 
- 	qi.tqi_readyTime = (cur_conf->beacon_interval *
--			    sc->config.cabqReadytime) / 100;
-+			    ATH_CABQ_READY_TIME) / 100;
- 	ath_txq_update(sc, qnum, &qi);
- 
- 	return 0;
-@@ -1571,7 +1726,7 @@ static void ath_drain_txq_list(struct at
- 	while (!list_empty(list)) {
- 		bf = list_first_entry(list, struct ath_buf, list);
- 
--		if (bf->bf_stale) {
-+		if (bf->bf_state.stale) {
- 			list_del(&bf->list);
- 
- 			ath_tx_return_buffer(sc, bf);
-@@ -1630,6 +1785,9 @@ bool ath_drain_all_txq(struct ath_softc 
- 		if (!ATH_TXQ_SETUP(sc, i))
- 			continue;
- 
-+		if (!sc->tx.txq[i].axq_depth)
-+			continue;
-+
- 		if (ath9k_hw_numtxpending(ah, sc->tx.txq[i].axq_qnum))
- 			npend |= BIT(i);
- 	}
-@@ -1665,25 +1823,27 @@ void ath_tx_cleanupq(struct ath_softc *s
-  */
- void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
- {
--	struct ath_atx_ac *ac, *ac_tmp, *last_ac;
-+	struct ath_atx_ac *ac, *last_ac;
- 	struct ath_atx_tid *tid, *last_tid;
-+	bool sent = false;
- 
- 	if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) ||
--	    list_empty(&txq->axq_acq) ||
--	    txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
-+	    list_empty(&txq->axq_acq))
- 		return;
- 
- 	rcu_read_lock();
- 
--	ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
- 	last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list);
-+	while (!list_empty(&txq->axq_acq)) {
-+		bool stop = false;
- 
--	list_for_each_entry_safe(ac, ac_tmp, &txq->axq_acq, list) {
-+		ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
- 		last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
- 		list_del(&ac->list);
- 		ac->sched = false;
- 
- 		while (!list_empty(&ac->tid_q)) {
-+
- 			tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
- 					       list);
- 			list_del(&tid->list);
-@@ -1692,17 +1852,17 @@ void ath_txq_schedule(struct ath_softc *
- 			if (tid->paused)
- 				continue;
- 
--			ath_tx_sched_aggr(sc, txq, tid);
-+			if (ath_tx_sched_aggr(sc, txq, tid, &stop))
-+				sent = true;
- 
- 			/*
- 			 * add tid to round-robin queue if more frames
- 			 * are pending for the tid
- 			 */
--			if (!skb_queue_empty(&tid->buf_q))
-+			if (ath_tid_has_buffered(tid))
- 				ath_tx_queue_tid(txq, tid);
- 
--			if (tid == last_tid ||
--			    txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
-+			if (stop || tid == last_tid)
- 				break;
- 		}
- 
-@@ -1711,9 +1871,17 @@ void ath_txq_schedule(struct ath_softc *
- 			list_add_tail(&ac->list, &txq->axq_acq);
- 		}
- 
--		if (ac == last_ac ||
--		    txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
-+		if (stop)
- 			break;
-+
-+		if (ac == last_ac) {
-+			if (!sent)
-+				break;
-+
-+			sent = false;
-+			last_ac = list_entry(txq->axq_acq.prev,
-+					     struct ath_atx_ac, list);
-+		}
- 	}
- 
- 	rcu_read_unlock();
-@@ -1787,74 +1955,28 @@ static void ath_tx_txqaddbuf(struct ath_
- 			if (bf_is_ampdu_not_probing(bf))
- 				txq->axq_ampdu_depth++;
- 
--			bf = bf->bf_lastbf->bf_next;
-+			bf_last = bf->bf_lastbf;
-+			bf = bf_last->bf_next;
-+			bf_last->bf_next = NULL;
- 		}
- 	}
- }
- 
--static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_txq *txq,
--			      struct ath_atx_tid *tid, struct sk_buff *skb,
--			      struct ath_tx_control *txctl)
--{
--	struct ath_frame_info *fi = get_frame_info(skb);
--	struct list_head bf_head;
--	struct ath_buf *bf;
--
--	/*
--	 * Do not queue to h/w when any of the following conditions is true:
--	 * - there are pending frames in software queue
--	 * - the TID is currently paused for ADDBA/BAR request
--	 * - seqno is not within block-ack window
--	 * - h/w queue depth exceeds low water mark
--	 */
--	if ((!skb_queue_empty(&tid->buf_q) || tid->paused ||
--	     !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) ||
--	     txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) &&
--	    txq != sc->tx.uapsdq) {
--		/*
--		 * Add this frame to software queue for scheduling later
--		 * for aggregation.
--		 */
--		TX_STAT_INC(txq->axq_qnum, a_queued_sw);
--		__skb_queue_tail(&tid->buf_q, skb);
--		if (!txctl->an || !txctl->an->sleeping)
--			ath_tx_queue_tid(txq, tid);
--		return;
--	}
--
--	bf = ath_tx_setup_buffer(sc, txq, tid, skb);
--	if (!bf) {
--		ieee80211_free_txskb(sc->hw, skb);
--		return;
--	}
--
--	ath_set_rates(tid->an->vif, tid->an->sta, bf);
--	bf->bf_state.bf_type = BUF_AMPDU;
--	INIT_LIST_HEAD(&bf_head);
--	list_add(&bf->list, &bf_head);
--
--	/* Add sub-frame to BAW */
--	ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
--
--	/* Queue to h/w without aggregation */
--	TX_STAT_INC(txq->axq_qnum, a_queued_hw);
--	bf->bf_lastbf = bf;
--	ath_tx_fill_desc(sc, bf, txq, fi->framelen);
--	ath_tx_txqaddbuf(sc, txq, &bf_head, false);
--}
--
- static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
- 			       struct ath_atx_tid *tid, struct sk_buff *skb)
- {
-+	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
- 	struct ath_frame_info *fi = get_frame_info(skb);
- 	struct list_head bf_head;
--	struct ath_buf *bf;
--
--	bf = fi->bf;
-+	struct ath_buf *bf = fi->bf;
- 
- 	INIT_LIST_HEAD(&bf_head);
- 	list_add_tail(&bf->list, &bf_head);
- 	bf->bf_state.bf_type = 0;
-+	if (tid && (tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
-+		bf->bf_state.bf_type = BUF_AMPDU;
-+		ath_tx_addto_baw(sc, tid, bf);
-+	}
- 
- 	bf->bf_next = NULL;
- 	bf->bf_lastbf = bf;
-@@ -1911,8 +2033,7 @@ u8 ath_txchainmask_reduction(struct ath_
- 	struct ath_hw *ah = sc->sc_ah;
- 	struct ath9k_channel *curchan = ah->curchan;
- 
--	if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) &&
--	    (curchan->channelFlags & CHANNEL_5GHZ) &&
-+	if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && IS_CHAN_5GHZ(curchan) &&
- 	    (chainmask == 0x7) && (rate < 0x90))
- 		return 0x3;
- 	else if (AR_SREV_9462(ah) && ath9k_hw_btcoex_is_enabled(ah) &&
-@@ -1985,6 +2106,7 @@ static int ath_tx_prepare(struct ieee802
- 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- 	struct ieee80211_sta *sta = txctl->sta;
- 	struct ieee80211_vif *vif = info->control.vif;
-+	struct ath_vif *avp;
- 	struct ath_softc *sc = hw->priv;
- 	int frmlen = skb->len + FCS_LEN;
- 	int padpos, padsize;
-@@ -1992,6 +2114,10 @@ static int ath_tx_prepare(struct ieee802
- 	/* NOTE:  sta can be NULL according to net/mac80211.h */
- 	if (sta)
- 		txctl->an = (struct ath_node *)sta->drv_priv;
-+	else if (vif && ieee80211_is_data(hdr->frame_control)) {
-+		avp = (void *)vif->drv_priv;
-+		txctl->an = &avp->mcast_node;
-+	}
- 
- 	if (info->control.hw_key)
- 		frmlen += info->control.hw_key->icv_len;
-@@ -2041,7 +2167,6 @@ int ath_tx_start(struct ieee80211_hw *hw
- 	struct ath_txq *txq = txctl->txq;
- 	struct ath_atx_tid *tid = NULL;
- 	struct ath_buf *bf;
--	u8 tidno;
- 	int q;
- 	int ret;
- 
-@@ -2069,27 +2194,31 @@ int ath_tx_start(struct ieee80211_hw *hw
- 		ath_txq_unlock(sc, txq);
- 		txq = sc->tx.uapsdq;
- 		ath_txq_lock(sc, txq);
--	}
--
--	if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
--		tidno = ieee80211_get_qos_ctl(hdr)[0] &
--			IEEE80211_QOS_CTL_TID_MASK;
--		tid = ATH_AN_2_TID(txctl->an, tidno);
-+	} else if (txctl->an &&
-+		   ieee80211_is_data_present(hdr->frame_control)) {
-+		tid = ath_get_skb_tid(sc, txctl->an, skb);
- 
- 		WARN_ON(tid->ac->txq != txctl->txq);
--	}
- 
--	if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
-+		if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
-+			tid->ac->clear_ps_filter = true;
-+
- 		/*
--		 * Try aggregation if it's a unicast data frame
--		 * and the destination is HT capable.
-+		 * Add this frame to software queue for scheduling later
-+		 * for aggregation.
- 		 */
--		ath_tx_send_ampdu(sc, txq, tid, skb, txctl);
-+		TX_STAT_INC(txq->axq_qnum, a_queued_sw);
-+		__skb_queue_tail(&tid->buf_q, skb);
-+		if (!txctl->an->sleeping)
-+			ath_tx_queue_tid(txq, tid);
-+
-+		ath_txq_schedule(sc, txq);
- 		goto out;
- 	}
- 
- 	bf = ath_tx_setup_buffer(sc, txq, tid, skb);
- 	if (!bf) {
-+		ath_txq_skb_done(sc, txq, skb);
- 		if (txctl->paprd)
- 			dev_kfree_skb_any(skb);
- 		else
-@@ -2142,7 +2271,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
- 
- 		bf->bf_lastbf = bf;
- 		ath_set_rates(vif, NULL, bf);
--		ath_buf_set_rate(sc, bf, &info, fi->framelen);
-+		ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
- 		duration += info.rates[0].PktDuration;
- 		if (bf_tail)
- 			bf_tail->bf_next = bf;
-@@ -2189,7 +2318,7 @@ static void ath_tx_complete(struct ath_s
- 	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
- 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
- 	struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
--	int q, padpos, padsize;
-+	int padpos, padsize;
- 	unsigned long flags;
- 
- 	ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
-@@ -2225,21 +2354,7 @@ static void ath_tx_complete(struct ath_s
- 	spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
- 
- 	__skb_queue_tail(&txq->complete_q, skb);
--
--	q = skb_get_queue_mapping(skb);
--	if (txq == sc->tx.uapsdq)
--		txq = sc->tx.txq_map[q];
--
--	if (txq == sc->tx.txq_map[q]) {
--		if (WARN_ON(--txq->pending_frames < 0))
--			txq->pending_frames = 0;
--
--		if (txq->stopped &&
--		    txq->pending_frames < sc->tx.txq_max_pending[q]) {
--			ieee80211_wake_queue(sc->hw, q);
--			txq->stopped = false;
--		}
--	}
-+	ath_txq_skb_done(sc, txq, skb);
- }
- 
- static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
-@@ -2360,8 +2475,7 @@ static void ath_tx_processq(struct ath_s
- 
- 		if (list_empty(&txq->axq_q)) {
- 			txq->axq_link = NULL;
--			if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
--				ath_txq_schedule(sc, txq);
-+			ath_txq_schedule(sc, txq);
- 			break;
- 		}
- 		bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
-@@ -2375,7 +2489,7 @@ static void ath_tx_processq(struct ath_s
- 		 * it with the STALE flag.
- 		 */
- 		bf_held = NULL;
--		if (bf->bf_stale) {
-+		if (bf->bf_state.stale) {
- 			bf_held = bf;
- 			if (list_is_last(&bf_held->list, &txq->axq_q))
- 				break;
-@@ -2399,7 +2513,7 @@ static void ath_tx_processq(struct ath_s
- 		 * however leave the last descriptor back as the holding
- 		 * descriptor for hw.
- 		 */
--		lastbf->bf_stale = true;
-+		lastbf->bf_state.stale = true;
- 		INIT_LIST_HEAD(&bf_head);
- 		if (!list_is_singular(&lastbf->list))
- 			list_cut_position(&bf_head,
-@@ -2470,7 +2584,7 @@ void ath_tx_edma_tasklet(struct ath_soft
- 		}
- 
- 		bf = list_first_entry(fifo_list, struct ath_buf, list);
--		if (bf->bf_stale) {
-+		if (bf->bf_state.stale) {
- 			list_del(&bf->list);
- 			ath_tx_return_buffer(sc, bf);
- 			bf = list_first_entry(fifo_list, struct ath_buf, list);
-@@ -2492,7 +2606,7 @@ void ath_tx_edma_tasklet(struct ath_soft
- 				ath_tx_txqaddbuf(sc, txq, &bf_q, true);
- 			}
- 		} else {
--			lastbf->bf_stale = true;
-+			lastbf->bf_state.stale = true;
- 			if (bf != lastbf)
- 				list_cut_position(&bf_head, fifo_list,
- 						  lastbf->list.prev);
-@@ -2583,6 +2697,7 @@ void ath_tx_node_init(struct ath_softc *
- 		tid->paused    = false;
- 		tid->active	   = false;
- 		__skb_queue_head_init(&tid->buf_q);
-+		__skb_queue_head_init(&tid->retry_q);
- 		acno = TID_TO_WME_AC(tidno);
- 		tid->ac = &an->ac[acno];
- 	}
-@@ -2590,6 +2705,7 @@ void ath_tx_node_init(struct ath_softc *
- 	for (acno = 0, ac = &an->ac[acno];
- 	     acno < IEEE80211_NUM_ACS; acno++, ac++) {
- 		ac->sched    = false;
-+		ac->clear_ps_filter = true;
- 		ac->txq = sc->tx.txq_map[acno];
- 		INIT_LIST_HEAD(&ac->tid_q);
- 	}
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -82,6 +82,22 @@ static bool ath9k_setpower(struct ath_so
- 	return ret;
- }
- 
-+void ath_ps_full_sleep(unsigned long data)
-+{
-+	struct ath_softc *sc = (struct ath_softc *) data;
-+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-+	bool reset;
-+
-+	spin_lock(&common->cc_lock);
-+	ath_hw_cycle_counters_update(common);
-+	spin_unlock(&common->cc_lock);
-+
-+	ath9k_hw_setrxabort(sc->sc_ah, 1);
-+	ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
-+
-+	ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
-+}
-+
- void ath9k_ps_wakeup(struct ath_softc *sc)
- {
- 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-@@ -92,6 +108,7 @@ void ath9k_ps_wakeup(struct ath_softc *s
- 	if (++sc->ps_usecount != 1)
- 		goto unlock;
- 
-+	del_timer_sync(&sc->sleep_timer);
- 	power_mode = sc->sc_ah->power_mode;
- 	ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
- 
-@@ -117,17 +134,17 @@ void ath9k_ps_restore(struct ath_softc *
- 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
- 	enum ath9k_power_mode mode;
- 	unsigned long flags;
--	bool reset;
- 
- 	spin_lock_irqsave(&sc->sc_pm_lock, flags);
- 	if (--sc->ps_usecount != 0)
- 		goto unlock;
- 
- 	if (sc->ps_idle) {
--		ath9k_hw_setrxabort(sc->sc_ah, 1);
--		ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
--		mode = ATH9K_PM_FULL_SLEEP;
--	} else if (sc->ps_enabled &&
-+		mod_timer(&sc->sleep_timer, jiffies + HZ / 10);
-+		goto unlock;
-+	}
-+
-+	if (sc->ps_enabled &&
- 		   !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
- 				     PS_WAIT_FOR_CAB |
- 				     PS_WAIT_FOR_PSPOLL_DATA |
-@@ -173,8 +190,7 @@ static void ath_restart_work(struct ath_
- {
- 	ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
- 
--	if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9485(sc->sc_ah) ||
--	    AR_SREV_9550(sc->sc_ah))
-+	if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah))
- 		ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
- 				     msecs_to_jiffies(ATH_PLL_WORK_INTERVAL));
- 
-@@ -209,6 +225,7 @@ static bool ath_complete_reset(struct at
- 	struct ath_hw *ah = sc->sc_ah;
- 	struct ath_common *common = ath9k_hw_common(ah);
- 	unsigned long flags;
-+	int i;
- 
- 	if (ath_startrecv(sc) != 0) {
- 		ath_err(common, "Unable to restart recv logic\n");
-@@ -236,10 +253,16 @@ static bool ath_complete_reset(struct at
- 		}
- 	work:
- 		ath_restart_work(sc);
--	}
- 
--	if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3)
--		ath_ant_comb_update(sc);
-+		for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
-+			if (!ATH_TXQ_SETUP(sc, i))
-+				continue;
-+
-+			spin_lock_bh(&sc->tx.txq[i].axq_lock);
-+			ath_txq_schedule(sc, &sc->tx.txq[i]);
-+			spin_unlock_bh(&sc->tx.txq[i].axq_lock);
-+		}
-+	}
- 
- 	ieee80211_wake_queues(sc->hw);
- 
-@@ -306,17 +329,91 @@ out:
-  * by reseting the chip.  To accomplish this we must first cleanup any pending
-  * DMA, then restart stuff.
- */
--static int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
--		    struct ath9k_channel *hchan)
-+static int ath_set_channel(struct ath_softc *sc, struct cfg80211_chan_def *chandef)
- {
-+	struct ath_hw *ah = sc->sc_ah;
-+	struct ath_common *common = ath9k_hw_common(ah);
-+	struct ieee80211_hw *hw = sc->hw;
-+	struct ath9k_channel *hchan;
-+	struct ieee80211_channel *chan = chandef->chan;
-+	unsigned long flags;
-+	bool offchannel;
-+	int pos = chan->hw_value;
-+	int old_pos = -1;
- 	int r;
- 
- 	if (test_bit(SC_OP_INVALID, &sc->sc_flags))
- 		return -EIO;
- 
-+	offchannel = !!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL);
-+
-+	if (ah->curchan)
-+		old_pos = ah->curchan - &ah->channels[0];
-+
-+	ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
-+		chan->center_freq, chandef->width);
-+
-+	/* update survey stats for the old channel before switching */
-+	spin_lock_irqsave(&common->cc_lock, flags);
-+	ath_update_survey_stats(sc);
-+	spin_unlock_irqrestore(&common->cc_lock, flags);
-+
-+	ath9k_cmn_get_channel(hw, ah, chandef);
-+
-+	/*
-+	 * If the operating channel changes, change the survey in-use flags
-+	 * along with it.
-+	 * Reset the survey data for the new channel, unless we're switching
-+	 * back to the operating channel from an off-channel operation.
-+	 */
-+	if (!offchannel && sc->cur_survey != &sc->survey[pos]) {
-+		if (sc->cur_survey)
-+			sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
-+
-+		sc->cur_survey = &sc->survey[pos];
-+
-+		memset(sc->cur_survey, 0, sizeof(struct survey_info));
-+		sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
-+	} else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
-+		memset(&sc->survey[pos], 0, sizeof(struct survey_info));
-+	}
-+
-+	hchan = &sc->sc_ah->channels[pos];
- 	r = ath_reset_internal(sc, hchan);
-+	if (r)
-+		return r;
- 
--	return r;
-+	/*
-+	 * The most recent snapshot of channel->noisefloor for the old
-+	 * channel is only available after the hardware reset. Copy it to
-+	 * the survey stats now.
-+	 */
-+	if (old_pos >= 0)
-+		ath_update_survey_nf(sc, old_pos);
-+
-+	/*
-+	 * Enable radar pulse detection if on a DFS channel. Spectral
-+	 * scanning and radar detection can not be used concurrently.
-+	 */
-+	if (hw->conf.radar_enabled) {
-+		u32 rxfilter;
-+
-+		/* set HW specific DFS configuration */
-+		ath9k_hw_set_radar_params(ah);
-+		rxfilter = ath9k_hw_getrxfilter(ah);
-+		rxfilter |= ATH9K_RX_FILTER_PHYRADAR |
-+				ATH9K_RX_FILTER_PHYERR;
-+		ath9k_hw_setrxfilter(ah, rxfilter);
-+		ath_dbg(common, DFS, "DFS enabled at freq %d\n",
-+			chan->center_freq);
-+	} else {
-+		/* perform spectral scan if requested. */
-+		if (test_bit(SC_OP_SCANNING, &sc->sc_flags) &&
-+			sc->spectral_mode == SPECTRAL_CHANSCAN)
-+			ath9k_spectral_scan_trigger(hw);
-+	}
-+
-+	return 0;
- }
- 
- static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
-@@ -400,6 +497,8 @@ void ath9k_tasklet(unsigned long data)
- 			ath_tx_edma_tasklet(sc);
- 		else
- 			ath_tx_tasklet(sc);
-+
-+		wake_up(&sc->tx_wait);
- 	}
- 
- 	ath9k_btcoex_handle_interrupt(sc, status);
-@@ -543,21 +642,10 @@ chip_reset:
- 
- static int ath_reset(struct ath_softc *sc)
- {
--	int i, r;
-+	int r;
- 
- 	ath9k_ps_wakeup(sc);
--
- 	r = ath_reset_internal(sc, NULL);
--
--	for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
--		if (!ATH_TXQ_SETUP(sc, i))
--			continue;
--
--		spin_lock_bh(&sc->tx.txq[i].axq_lock);
--		ath_txq_schedule(sc, &sc->tx.txq[i]);
--		spin_unlock_bh(&sc->tx.txq[i].axq_lock);
--	}
--
- 	ath9k_ps_restore(sc);
- 
- 	return r;
-@@ -599,7 +687,7 @@ static int ath9k_start(struct ieee80211_
- 	ath9k_ps_wakeup(sc);
- 	mutex_lock(&sc->mutex);
- 
--	init_channel = ath9k_cmn_get_curchannel(hw, ah);
-+	init_channel = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
- 
- 	/* Reset SERDES registers */
- 	ath9k_hw_configpcipowersave(ah, false);
-@@ -802,7 +890,7 @@ static void ath9k_stop(struct ieee80211_
- 	}
- 
- 	if (!ah->curchan)
--		ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
-+		ah->curchan = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
- 
- 	ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
- 	ath9k_hw_phy_disable(ah);
-@@ -821,7 +909,7 @@ static void ath9k_stop(struct ieee80211_
- 	ath_dbg(common, CONFIG, "Driver halt\n");
- }
- 
--bool ath9k_uses_beacons(int type)
-+static bool ath9k_uses_beacons(int type)
- {
- 	switch (type) {
- 	case NL80211_IFTYPE_AP:
-@@ -966,6 +1054,8 @@ static int ath9k_add_interface(struct ie
- 	struct ath_softc *sc = hw->priv;
- 	struct ath_hw *ah = sc->sc_ah;
- 	struct ath_common *common = ath9k_hw_common(ah);
-+	struct ath_vif *avp = (void *)vif->drv_priv;
-+	struct ath_node *an = &avp->mcast_node;
- 
- 	mutex_lock(&sc->mutex);
- 
-@@ -979,6 +1069,12 @@ static int ath9k_add_interface(struct ie
- 	if (ath9k_uses_beacons(vif->type))
- 		ath9k_beacon_assign_slot(sc, vif);
- 
-+	an->sc = sc;
-+	an->sta = NULL;
-+	an->vif = vif;
-+	an->no_ps_filter = true;
-+	ath_tx_node_init(sc, an);
-+
- 	mutex_unlock(&sc->mutex);
- 	return 0;
- }
-@@ -1016,6 +1112,7 @@ static void ath9k_remove_interface(struc
- {
- 	struct ath_softc *sc = hw->priv;
- 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-+	struct ath_vif *avp = (void *)vif->drv_priv;
- 
- 	ath_dbg(common, CONFIG, "Detach Interface\n");
- 
-@@ -1030,6 +1127,8 @@ static void ath9k_remove_interface(struc
- 	ath9k_calculate_summary_state(hw, NULL);
- 	ath9k_ps_restore(sc);
- 
-+	ath_tx_node_cleanup(sc, &avp->mcast_node);
-+
- 	mutex_unlock(&sc->mutex);
- }
- 
-@@ -1192,83 +1291,12 @@ static int ath9k_config(struct ieee80211
- 	}
- 
- 	if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
--		struct ieee80211_channel *curchan = hw->conf.chandef.chan;
--		enum nl80211_channel_type channel_type =
--			cfg80211_get_chandef_type(&conf->chandef);
--		int pos = curchan->hw_value;
--		int old_pos = -1;
--		unsigned long flags;
--
--		if (ah->curchan)
--			old_pos = ah->curchan - &ah->channels[0];
--
--		ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n",
--			curchan->center_freq, channel_type);
--
--		/* update survey stats for the old channel before switching */
--		spin_lock_irqsave(&common->cc_lock, flags);
--		ath_update_survey_stats(sc);
--		spin_unlock_irqrestore(&common->cc_lock, flags);
--
--		ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
--					  curchan, channel_type);
--
--		/*
--		 * If the operating channel changes, change the survey in-use flags
--		 * along with it.
--		 * Reset the survey data for the new channel, unless we're switching
--		 * back to the operating channel from an off-channel operation.
--		 */
--		if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) &&
--		    sc->cur_survey != &sc->survey[pos]) {
--
--			if (sc->cur_survey)
--				sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
--
--			sc->cur_survey = &sc->survey[pos];
--
--			memset(sc->cur_survey, 0, sizeof(struct survey_info));
--			sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
--		} else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
--			memset(&sc->survey[pos], 0, sizeof(struct survey_info));
--		}
--
--		if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
-+		if (ath_set_channel(sc, &hw->conf.chandef) < 0) {
- 			ath_err(common, "Unable to set channel\n");
- 			mutex_unlock(&sc->mutex);
- 			ath9k_ps_restore(sc);
- 			return -EINVAL;
- 		}
--
--		/*
--		 * The most recent snapshot of channel->noisefloor for the old
--		 * channel is only available after the hardware reset. Copy it to
--		 * the survey stats now.
--		 */
--		if (old_pos >= 0)
--			ath_update_survey_nf(sc, old_pos);
--
--		/*
--		 * Enable radar pulse detection if on a DFS channel. Spectral
--		 * scanning and radar detection can not be used concurrently.
--		 */
--		if (hw->conf.radar_enabled) {
--			u32 rxfilter;
--
--			/* set HW specific DFS configuration */
--			ath9k_hw_set_radar_params(ah);
--			rxfilter = ath9k_hw_getrxfilter(ah);
--			rxfilter |= ATH9K_RX_FILTER_PHYRADAR |
--				    ATH9K_RX_FILTER_PHYERR;
--			ath9k_hw_setrxfilter(ah, rxfilter);
--			ath_dbg(common, DFS, "DFS enabled at freq %d\n",
--				curchan->center_freq);
--		} else {
--			/* perform spectral scan if requested. */
--			if (test_bit(SC_OP_SCANNING, &sc->sc_flags) &&
--			    sc->spectral_mode == SPECTRAL_CHANSCAN)
--				ath9k_spectral_scan_trigger(hw);
--		}
- 	}
- 
- 	if (changed & IEEE80211_CONF_CHANGE_POWER) {
-@@ -1374,9 +1402,6 @@ static void ath9k_sta_notify(struct ieee
- 	struct ath_softc *sc = hw->priv;
- 	struct ath_node *an = (struct ath_node *) sta->drv_priv;
- 
--	if (!sta->ht_cap.ht_supported)
--		return;
--
- 	switch (cmd) {
- 	case STA_NOTIFY_SLEEP:
- 		an->sleeping = true;
-@@ -1772,13 +1797,31 @@ static void ath9k_set_coverage_class(str
- 	mutex_unlock(&sc->mutex);
- }
- 
-+static bool ath9k_has_tx_pending(struct ath_softc *sc)
-+{
-+	int i, npend;
-+
-+	for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
-+		if (!ATH_TXQ_SETUP(sc, i))
-+			continue;
-+
-+		if (!sc->tx.txq[i].axq_depth)
-+			continue;
-+
-+		npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
-+		if (npend)
-+			break;
-+	}
-+
-+	return !!npend;
-+}
-+
- static void ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
- {
- 	struct ath_softc *sc = hw->priv;
- 	struct ath_hw *ah = sc->sc_ah;
- 	struct ath_common *common = ath9k_hw_common(ah);
--	int timeout = 200; /* ms */
--	int i, j;
-+	int timeout = HZ / 5; /* 200 ms */
- 	bool drain_txq;
- 
- 	mutex_lock(&sc->mutex);
-@@ -1796,25 +1839,9 @@ static void ath9k_flush(struct ieee80211
- 		return;
- 	}
- 
--	for (j = 0; j < timeout; j++) {
--		bool npend = false;
--
--		if (j)
--			usleep_range(1000, 2000);
--
--		for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
--			if (!ATH_TXQ_SETUP(sc, i))
--				continue;
--
--			npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
--
--			if (npend)
--				break;
--		}
--
--		if (!npend)
--		    break;
--	}
-+	if (wait_event_timeout(sc->tx_wait, !ath9k_has_tx_pending(sc),
-+			       timeout) > 0)
-+		drop = false;
- 
- 	if (drop) {
- 		ath9k_ps_wakeup(sc);
-@@ -2094,7 +2121,7 @@ static void ath9k_wow_add_pattern(struct
- {
- 	struct ath_hw *ah = sc->sc_ah;
- 	struct ath9k_wow_pattern *wow_pattern = NULL;
--	struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
-+	struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
- 	int mask_len;
- 	s8 i = 0;
- 
---- a/drivers/net/wireless/mwifiex/cfg80211.c
-+++ b/drivers/net/wireless/mwifiex/cfg80211.c
-@@ -2298,8 +2298,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_in
- 
- #ifdef CONFIG_PM
- static bool
--mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
--			     s8 *byte_seq)
-+mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
- {
- 	int j, k, valid_byte_cnt = 0;
- 	bool dont_care_byte = false;
---- a/drivers/net/wireless/ti/wlcore/main.c
-+++ b/drivers/net/wireless/ti/wlcore/main.c
-@@ -1315,7 +1315,7 @@ static struct sk_buff *wl12xx_alloc_dumm
- 
- #ifdef CONFIG_PM
- static int
--wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
-+wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
- {
- 	int num_fields = 0, in_field = 0, fields_size = 0;
- 	int i, pattern_len = 0;
-@@ -1458,9 +1458,9 @@ void wl1271_rx_filter_flatten_fields(str
-  * Allocates an RX filter returned through f
-  * which needs to be freed using rx_filter_free()
-  */
--static int wl1271_convert_wowlan_pattern_to_rx_filter(
--	struct cfg80211_wowlan_trig_pkt_pattern *p,
--	struct wl12xx_rx_filter **f)
-+static int
-+wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
-+					   struct wl12xx_rx_filter **f)
- {
- 	int i, j, ret = 0;
- 	struct wl12xx_rx_filter *filter;
-@@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
- 
- 	/* Translate WoWLAN patterns into filters */
- 	for (i = 0; i < wow->n_patterns; i++) {
--		struct cfg80211_wowlan_trig_pkt_pattern *p;
-+		struct cfg80211_pkt_pattern *p;
- 		struct wl12xx_rx_filter *filter = NULL;
- 
- 		p = &wow->patterns[i];
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -639,6 +639,30 @@ struct cfg80211_ap_settings {
- };
- 
- /**
-+ * struct cfg80211_csa_settings - channel switch settings
-+ *
-+ * Used for channel switch
-+ *
-+ * @chandef: defines the channel to use after the switch
-+ * @beacon_csa: beacon data while performing the switch
-+ * @counter_offset_beacon: offset for the counter within the beacon (tail)
-+ * @counter_offset_presp: offset for the counter within the probe response
-+ * @beacon_after: beacon data to be used on the new channel
-+ * @radar_required: whether radar detection is required on the new channel
-+ * @block_tx: whether transmissions should be blocked while changing
-+ * @count: number of beacons until switch
-+ */
-+struct cfg80211_csa_settings {
-+	struct cfg80211_chan_def chandef;
-+	struct cfg80211_beacon_data beacon_csa;
-+	u16 counter_offset_beacon, counter_offset_presp;
-+	struct cfg80211_beacon_data beacon_after;
-+	bool radar_required;
-+	bool block_tx;
-+	u8 count;
-+};
-+
-+/**
-  * enum station_parameters_apply_mask - station parameter values to apply
-  * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
-  * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
-@@ -1698,7 +1722,7 @@ struct cfg80211_pmksa {
- };
- 
- /**
-- * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
-+ * struct cfg80211_pkt_pattern - packet pattern
-  * @mask: bitmask where to match pattern and where to ignore bytes,
-  *	one bit per byte, in same format as nl80211
-  * @pattern: bytes to match where bitmask is 1
-@@ -1708,7 +1732,7 @@ struct cfg80211_pmksa {
-  * Internal note: @mask and @pattern are allocated in one chunk of
-  * memory, free @mask only!
-  */
--struct cfg80211_wowlan_trig_pkt_pattern {
-+struct cfg80211_pkt_pattern {
- 	u8 *mask, *pattern;
- 	int pattern_len;
- 	int pkt_offset;
-@@ -1770,7 +1794,7 @@ struct cfg80211_wowlan {
- 	bool any, disconnect, magic_pkt, gtk_rekey_failure,
- 	     eap_identity_req, four_way_handshake,
- 	     rfkill_release;
--	struct cfg80211_wowlan_trig_pkt_pattern *patterns;
-+	struct cfg80211_pkt_pattern *patterns;
- 	struct cfg80211_wowlan_tcp *tcp;
- 	int n_patterns;
- };
-@@ -2071,6 +2095,8 @@ struct cfg80211_update_ft_ies_params {
-  *	driver can take the most appropriate actions.
-  * @crit_proto_stop: Indicates critical protocol no longer needs increased link
-  *	reliability. This operation can not fail.
-+ *
-+ * @channel_switch: initiate channel-switch procedure (with CSA)
-  */
- struct cfg80211_ops {
- 	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
-@@ -2306,6 +2332,10 @@ struct cfg80211_ops {
- 				    u16 duration);
- 	void	(*crit_proto_stop)(struct wiphy *wiphy,
- 				   struct wireless_dev *wdev);
-+
-+	int	(*channel_switch)(struct wiphy *wiphy,
-+				  struct net_device *dev,
-+				  struct cfg80211_csa_settings *params);
- };
- 
- /*
-@@ -2371,6 +2401,8 @@ struct cfg80211_ops {
-  * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
-  * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
-  * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
-+ * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
-+ *	beaconing mode (AP, IBSS, Mesh, ...).
-  */
- enum wiphy_flags {
- 	WIPHY_FLAG_CUSTOM_REGULATORY		= BIT(0),
-@@ -2395,6 +2427,7 @@ enum wiphy_flags {
- 	WIPHY_FLAG_OFFCHAN_TX			= BIT(20),
- 	WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL	= BIT(21),
- 	WIPHY_FLAG_SUPPORTS_5_10_MHZ		= BIT(22),
-+	WIPHY_FLAG_HAS_CHANNEL_SWITCH		= BIT(23),
- };
- 
- /**
---- a/include/uapi/linux/nl80211.h
-+++ b/include/uapi/linux/nl80211.h
-@@ -648,6 +648,16 @@
-  * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
-  *	return back to normal.
-  *
-+ * @NL80211_CMD_CHANNEL_SWITCH: Perform a channel switch by announcing the
-+ *	the new channel information (Channel Switch Announcement - CSA)
-+ *	in the beacon for some time (as defined in the
-+ *	%NL80211_ATTR_CH_SWITCH_COUNT parameter) and then change to the
-+ *	new channel. Userspace provides the new channel information (using
-+ *	%NL80211_ATTR_WIPHY_FREQ and the attributes determining channel
-+ *	width). %NL80211_ATTR_CH_SWITCH_BLOCK_TX may be supplied to inform
-+ *	other station that transmission must be blocked until the channel
-+ *	switch is complete.
-+ *
-  * @NL80211_CMD_MAX: highest used command number
-  * @__NL80211_CMD_AFTER_LAST: internal use
-  */
-@@ -810,6 +820,8 @@ enum nl80211_commands {
- 	NL80211_CMD_CRIT_PROTOCOL_START,
- 	NL80211_CMD_CRIT_PROTOCOL_STOP,
- 
-+	NL80211_CMD_CHANNEL_SWITCH,
-+
- 	/* add new commands above here */
- 
- 	/* used to define NL80211_CMD_MAX below */
-@@ -1436,6 +1448,18 @@ enum nl80211_commands {
-  *	allowed to be used with the first @NL80211_CMD_SET_STATION command to
-  *	update a TDLS peer STA entry.
-  *
-+ * @NL80211_ATTR_CH_SWITCH_COUNT: u32 attribute specifying the number of TBTT's
-+ *	until the channel switch event.
-+ * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission
-+ *	must be blocked on the current channel (before the channel switch
-+ *	operation).
-+ * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
-+ *	for the time while performing a channel switch.
-+ * @NL80211_ATTR_CSA_C_OFF_BEACON: Offset of the channel switch counter
-+ *	field in the beacons tail (%NL80211_ATTR_BEACON_TAIL).
-+ * @NL80211_ATTR_CSA_C_OFF_PRESP: Offset of the channel switch counter
-+ *	field in the probe response (%NL80211_ATTR_PROBE_RESP).
-+ *
-  * @NL80211_ATTR_MAX: highest attribute number currently defined
-  * @__NL80211_ATTR_AFTER_LAST: internal use
-  */
-@@ -1736,6 +1760,12 @@ enum nl80211_attrs {
- 
- 	NL80211_ATTR_PEER_AID,
- 
-+	NL80211_ATTR_CH_SWITCH_COUNT,
-+	NL80211_ATTR_CH_SWITCH_BLOCK_TX,
-+	NL80211_ATTR_CSA_IES,
-+	NL80211_ATTR_CSA_C_OFF_BEACON,
-+	NL80211_ATTR_CSA_C_OFF_PRESP,
-+
- 	/* add attributes here, update the policy in nl80211.c */
- 
- 	__NL80211_ATTR_AFTER_LAST,
-@@ -3060,11 +3090,11 @@ enum nl80211_tx_power_setting {
- };
- 
- /**
-- * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
-- * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
-- * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
-+ * enum nl80211_packet_pattern_attr - packet pattern attribute
-+ * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
-+ * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
-  *	a zero bit are ignored
-- * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
-+ * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
-  *	a bit for each byte in the pattern. The lowest-order bit corresponds
-  *	to the first byte of the pattern, but the bytes of the pattern are
-  *	in a little-endian-like format, i.e. the 9th byte of the pattern
-@@ -3075,23 +3105,23 @@ enum nl80211_tx_power_setting {
-  *	Note that the pattern matching is done as though frames were not
-  *	802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
-  *	first (including SNAP header unpacking) and then matched.
-- * @NL80211_WOWLAN_PKTPAT_OFFSET: packet offset, pattern is matched after
-+ * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
-  *	these fixed number of bytes of received packet
-- * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
-- * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
-+ * @NUM_NL80211_PKTPAT: number of attributes
-+ * @MAX_NL80211_PKTPAT: max attribute number
-  */
--enum nl80211_wowlan_packet_pattern_attr {
--	__NL80211_WOWLAN_PKTPAT_INVALID,
--	NL80211_WOWLAN_PKTPAT_MASK,
--	NL80211_WOWLAN_PKTPAT_PATTERN,
--	NL80211_WOWLAN_PKTPAT_OFFSET,
-+enum nl80211_packet_pattern_attr {
-+	__NL80211_PKTPAT_INVALID,
-+	NL80211_PKTPAT_MASK,
-+	NL80211_PKTPAT_PATTERN,
-+	NL80211_PKTPAT_OFFSET,
- 
--	NUM_NL80211_WOWLAN_PKTPAT,
--	MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
-+	NUM_NL80211_PKTPAT,
-+	MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
- };
- 
- /**
-- * struct nl80211_wowlan_pattern_support - pattern support information
-+ * struct nl80211_pattern_support - packet pattern support information
-  * @max_patterns: maximum number of patterns supported
-  * @min_pattern_len: minimum length of each pattern
-  * @max_pattern_len: maximum length of each pattern
-@@ -3101,13 +3131,22 @@ enum nl80211_wowlan_packet_pattern_attr 
-  * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
-  * capability information given by the kernel to userspace.
-  */
--struct nl80211_wowlan_pattern_support {
-+struct nl80211_pattern_support {
- 	__u32 max_patterns;
- 	__u32 min_pattern_len;
- 	__u32 max_pattern_len;
- 	__u32 max_pkt_offset;
- } __attribute__((packed));
- 
-+/* only for backward compatibility */
-+#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
-+#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
-+#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
-+#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
-+#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
-+#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
-+#define nl80211_wowlan_pattern_support nl80211_pattern_support
-+
- /**
-  * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
-  * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
-@@ -3127,7 +3166,7 @@ struct nl80211_wowlan_pattern_support {
-  *	pattern matching is done after the packet is converted to the MSDU.
-  *
-  *	In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
-- *	carrying a &struct nl80211_wowlan_pattern_support.
-+ *	carrying a &struct nl80211_pattern_support.
-  *
-  *	When reporting wakeup. it is a u32 attribute containing the 0-based
-  *	index of the pattern that caused the wakeup, in the patterns passed
-@@ -3284,7 +3323,7 @@ struct nl80211_wowlan_tcp_data_token_fea
-  * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
-  *	u32 attribute holding the maximum length
-  * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
-- *	feature advertising. The mask works like @NL80211_WOWLAN_PKTPAT_MASK
-+ *	feature advertising. The mask works like @NL80211_PKTPAT_MASK
-  *	but on the TCP payload only.
-  * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
-  * @MAX_NL80211_WOWLAN_TCP: highest attribute number
---- a/net/mac80211/mesh_ps.c
-+++ b/net/mac80211/mesh_ps.c
-@@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(str
- 	enum nl80211_mesh_power_mode pm;
- 	bool do_buffer;
- 
-+	/* For non-assoc STA, prevent buffering or frame transmission */
-+	if (sta->sta_state < IEEE80211_STA_ASSOC)
-+		return;
-+
- 	/*
- 	 * use peer-specific power mode if peering is established and the
- 	 * peer's power mode is known
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -349,6 +349,11 @@ static const struct nla_policy nl80211_p
- 	[NL80211_ATTR_IE_RIC] = { .type = NLA_BINARY,
- 				  .len = IEEE80211_MAX_DATA_LEN },
- 	[NL80211_ATTR_PEER_AID] = { .type = NLA_U16 },
-+	[NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 },
-+	[NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG },
-+	[NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED },
-+	[NL80211_ATTR_CSA_C_OFF_BEACON] = { .type = NLA_U16 },
-+	[NL80211_ATTR_CSA_C_OFF_PRESP] = { .type = NLA_U16 },
- };
- 
- /* policy for the key attributes */
-@@ -441,10 +446,12 @@ static int nl80211_prepare_wdev_dump(str
- 			goto out_unlock;
- 		}
- 		*rdev = wiphy_to_dev((*wdev)->wiphy);
--		cb->args[0] = (*rdev)->wiphy_idx;
-+		/* 0 is the first index - add 1 to parse only once */
-+		cb->args[0] = (*rdev)->wiphy_idx + 1;
- 		cb->args[1] = (*wdev)->identifier;
- 	} else {
--		struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]);
-+		/* subtract the 1 again here */
-+		struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
- 		struct wireless_dev *tmp;
- 
- 		if (!wiphy) {
-@@ -974,7 +981,7 @@ static int nl80211_send_wowlan(struct sk
- 		return -ENOBUFS;
- 
- 	if (dev->wiphy.wowlan->n_patterns) {
--		struct nl80211_wowlan_pattern_support pat = {
-+		struct nl80211_pattern_support pat = {
- 			.max_patterns = dev->wiphy.wowlan->n_patterns,
- 			.min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
- 			.max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
-@@ -1393,6 +1400,8 @@ static int nl80211_send_wiphy(struct cfg
- 		if (state->split) {
- 			CMD(crit_proto_start, CRIT_PROTOCOL_START);
- 			CMD(crit_proto_stop, CRIT_PROTOCOL_STOP);
-+			if (dev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)
-+				CMD(channel_switch, CHANNEL_SWITCH);
- 		}
- 
- #ifdef CPTCFG_NL80211_TESTMODE
-@@ -1568,8 +1577,10 @@ static int nl80211_dump_wiphy(struct sk_
- 	rtnl_lock();
- 	if (!state) {
- 		state = kzalloc(sizeof(*state), GFP_KERNEL);
--		if (!state)
-+		if (!state) {
-+			rtnl_unlock();
- 			return -ENOMEM;
-+		}
- 		state->filter_wiphy = -1;
- 		ret = nl80211_dump_wiphy_parse(skb, cb, state);
- 		if (ret) {
-@@ -2620,8 +2631,8 @@ static int nl80211_get_key(struct sk_buf
- 
- 	hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
- 			     NL80211_CMD_NEW_KEY);
--	if (IS_ERR(hdr))
--		return PTR_ERR(hdr);
-+	if (!hdr)
-+		return -ENOBUFS;
- 
- 	cookie.msg = msg;
- 	cookie.idx = key_idx;
-@@ -4770,9 +4781,9 @@ do {									    \
- 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, 0, 1,
- 				  mask, NL80211_MESHCONF_FORWARDING,
- 				  nla_get_u8);
--	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, 1, 255,
-+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0,
- 				  mask, NL80211_MESHCONF_RSSI_THRESHOLD,
--				  nla_get_u32);
-+				  nla_get_s32);
- 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16,
- 				  mask, NL80211_MESHCONF_HT_OPMODE,
- 				  nla_get_u16);
-@@ -5578,6 +5589,111 @@ static int nl80211_start_radar_detection
- 	return err;
- }
- 
-+static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
-+{
-+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
-+	struct net_device *dev = info->user_ptr[1];
-+	struct wireless_dev *wdev = dev->ieee80211_ptr;
-+	struct cfg80211_csa_settings params;
-+	/* csa_attrs is defined static to avoid waste of stack size - this
-+	 * function is called under RTNL lock, so this should not be a problem.
-+	 */
-+	static struct nlattr *csa_attrs[NL80211_ATTR_MAX+1];
-+	u8 radar_detect_width = 0;
-+	int err;
-+
-+	if (!rdev->ops->channel_switch ||
-+	    !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
-+		return -EOPNOTSUPP;
-+
-+	/* may add IBSS support later */
-+	if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
-+	    dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
-+		return -EOPNOTSUPP;
-+
-+	memset(&params, 0, sizeof(params));
-+
-+	if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] ||
-+	    !info->attrs[NL80211_ATTR_CH_SWITCH_COUNT])
-+		return -EINVAL;
-+
-+	/* only important for AP, IBSS and mesh create IEs internally */
-+	if (!info->attrs[NL80211_ATTR_CSA_IES])
-+		return -EINVAL;
-+
-+	/* useless if AP is not running */
-+	if (!wdev->beacon_interval)
-+		return -EINVAL;
-+
-+	params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
-+
-+	err = nl80211_parse_beacon(info->attrs, &params.beacon_after);
-+	if (err)
-+		return err;
-+
-+	err = nla_parse_nested(csa_attrs, NL80211_ATTR_MAX,
-+			       info->attrs[NL80211_ATTR_CSA_IES],
-+			       nl80211_policy);
-+	if (err)
-+		return err;
-+
-+	err = nl80211_parse_beacon(csa_attrs, &params.beacon_csa);
-+	if (err)
-+		return err;
-+
-+	if (!csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON])
-+		return -EINVAL;
-+
-+	params.counter_offset_beacon =
-+		nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]);
-+	if (params.counter_offset_beacon >= params.beacon_csa.tail_len)
-+		return -EINVAL;
-+
-+	/* sanity check - counters should be the same */
-+	if (params.beacon_csa.tail[params.counter_offset_beacon] !=
-+	    params.count)
-+		return -EINVAL;
-+
-+	if (csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]) {
-+		params.counter_offset_presp =
-+			nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]);
-+		if (params.counter_offset_presp >=
-+		    params.beacon_csa.probe_resp_len)
-+			return -EINVAL;
-+
-+		if (params.beacon_csa.probe_resp[params.counter_offset_presp] !=
-+		    params.count)
-+			return -EINVAL;
-+	}
-+
-+	err = nl80211_parse_chandef(rdev, info, &params.chandef);
-+	if (err)
-+		return err;
-+
-+	if (!cfg80211_reg_can_beacon(&rdev->wiphy, &params.chandef))
-+		return -EINVAL;
-+
-+	err = cfg80211_chandef_dfs_required(wdev->wiphy, &params.chandef);
-+	if (err < 0) {
-+		return err;
-+	} else if (err) {
-+		radar_detect_width = BIT(params.chandef.width);
-+		params.radar_required = true;
-+	}
-+
-+	err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype,
-+					   params.chandef.chan,
-+					   CHAN_MODE_SHARED,
-+					   radar_detect_width);
-+	if (err)
-+		return err;
-+
-+	if (info->attrs[NL80211_ATTR_CH_SWITCH_BLOCK_TX])
-+		params.block_tx = true;
-+
-+	return rdev_channel_switch(rdev, dev, &params);
-+}
-+
- static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
- 			    u32 seq, int flags,
- 			    struct cfg80211_registered_device *rdev,
-@@ -6507,6 +6623,9 @@ static int nl80211_testmode_dump(struct 
- 					   NL80211_CMD_TESTMODE);
- 		struct nlattr *tmdata;
- 
-+		if (!hdr)
-+			break;
-+
- 		if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
- 			genlmsg_cancel(skb, hdr);
- 			break;
-@@ -6615,12 +6734,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
- 
- void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
- {
-+	struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
- 	void *hdr = ((void **)skb->cb)[1];
- 	struct nlattr *data = ((void **)skb->cb)[2];
- 
- 	nla_nest_end(skb, data);
- 	genlmsg_end(skb, hdr);
--	genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
-+	genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
-+				nl80211_testmode_mcgrp.id, gfp);
- }
- EXPORT_SYMBOL(cfg80211_testmode_event);
- #endif
-@@ -6949,9 +7070,8 @@ static int nl80211_remain_on_channel(str
- 
- 	hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
- 			     NL80211_CMD_REMAIN_ON_CHANNEL);
--
--	if (IS_ERR(hdr)) {
--		err = PTR_ERR(hdr);
-+	if (!hdr) {
-+		err = -ENOBUFS;
- 		goto free_msg;
- 	}
- 
-@@ -7249,9 +7369,8 @@ static int nl80211_tx_mgmt(struct sk_buf
- 
- 		hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
- 				     NL80211_CMD_FRAME);
--
--		if (IS_ERR(hdr)) {
--			err = PTR_ERR(hdr);
-+		if (!hdr) {
-+			err = -ENOBUFS;
- 			goto free_msg;
- 		}
- 	}
-@@ -7593,12 +7712,11 @@ static int nl80211_send_wowlan_patterns(
- 		if (!nl_pat)
- 			return -ENOBUFS;
- 		pat_len = wowlan->patterns[i].pattern_len;
--		if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
--			    DIV_ROUND_UP(pat_len, 8),
-+		if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
- 			    wowlan->patterns[i].mask) ||
--		    nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
--			    pat_len, wowlan->patterns[i].pattern) ||
--		    nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
-+		    nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
-+			    wowlan->patterns[i].pattern) ||
-+		    nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
- 				wowlan->patterns[i].pkt_offset))
- 			return -ENOBUFS;
- 		nla_nest_end(msg, nl_pat);
-@@ -7939,7 +8057,7 @@ static int nl80211_set_wowlan(struct sk_
- 		struct nlattr *pat;
- 		int n_patterns = 0;
- 		int rem, pat_len, mask_len, pkt_offset;
--		struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
-+		struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
- 
- 		nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
- 				    rem)
-@@ -7958,26 +8076,25 @@ static int nl80211_set_wowlan(struct sk_
- 
- 		nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
- 				    rem) {
--			nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
--				  nla_data(pat), nla_len(pat), NULL);
-+			nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
-+				  nla_len(pat), NULL);
- 			err = -EINVAL;
--			if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
--			    !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
-+			if (!pat_tb[NL80211_PKTPAT_MASK] ||
-+			    !pat_tb[NL80211_PKTPAT_PATTERN])
- 				goto error;
--			pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
-+			pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
- 			mask_len = DIV_ROUND_UP(pat_len, 8);
--			if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
--			    mask_len)
-+			if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
- 				goto error;
- 			if (pat_len > wowlan->pattern_max_len ||
- 			    pat_len < wowlan->pattern_min_len)
- 				goto error;
- 
--			if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
-+			if (!pat_tb[NL80211_PKTPAT_OFFSET])
- 				pkt_offset = 0;
- 			else
- 				pkt_offset = nla_get_u32(
--					pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
-+					pat_tb[NL80211_PKTPAT_OFFSET]);
- 			if (pkt_offset > wowlan->max_pkt_offset)
- 				goto error;
- 			new_triggers.patterns[i].pkt_offset = pkt_offset;
-@@ -7991,11 +8108,11 @@ static int nl80211_set_wowlan(struct sk_
- 			new_triggers.patterns[i].pattern =
- 				new_triggers.patterns[i].mask + mask_len;
- 			memcpy(new_triggers.patterns[i].mask,
--			       nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
-+			       nla_data(pat_tb[NL80211_PKTPAT_MASK]),
- 			       mask_len);
- 			new_triggers.patterns[i].pattern_len = pat_len;
- 			memcpy(new_triggers.patterns[i].pattern,
--			       nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
-+			       nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
- 			       pat_len);
- 			i++;
- 		}
-@@ -8130,9 +8247,8 @@ static int nl80211_probe_client(struct s
- 
- 	hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
- 			     NL80211_CMD_PROBE_CLIENT);
--
--	if (IS_ERR(hdr)) {
--		err = PTR_ERR(hdr);
-+	if (!hdr) {
-+		err = -ENOBUFS;
- 		goto free_msg;
- 	}
- 
-@@ -9041,7 +9157,15 @@ static struct genl_ops nl80211_ops[] = {
- 		.flags = GENL_ADMIN_PERM,
- 		.internal_flags = NL80211_FLAG_NEED_WDEV_UP |
- 				  NL80211_FLAG_NEED_RTNL,
--	}
-+	},
-+	{
-+		.cmd = NL80211_CMD_CHANNEL_SWITCH,
-+		.doit = nl80211_channel_switch,
-+		.policy = nl80211_policy,
-+		.flags = GENL_ADMIN_PERM,
-+		.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
-+				  NL80211_FLAG_NEED_RTNL,
-+	},
- };
- 
- static struct genl_multicast_group nl80211_mlme_mcgrp = {
-@@ -10066,7 +10190,8 @@ void cfg80211_mgmt_tx_status(struct wire
- 
- 	genlmsg_end(msg, hdr);
- 
--	genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
-+	genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
-+				nl80211_mlme_mcgrp.id, gfp);
- 	return;
- 
-  nla_put_failure:
---- a/net/wireless/reg.c
-+++ b/net/wireless/reg.c
-@@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev
- 
- void wiphy_regulatory_register(struct wiphy *wiphy)
- {
-+	struct regulatory_request *lr;
-+
- 	if (!reg_dev_ignore_cell_hint(wiphy))
- 		reg_num_devs_support_basehint++;
- 
--	wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
-+	lr = get_last_request();
-+	wiphy_update_regulatory(wiphy, lr->initiator);
- }
- 
- void wiphy_regulatory_deregister(struct wiphy *wiphy)
-@@ -2279,7 +2282,9 @@ void wiphy_regulatory_deregister(struct 
- static void reg_timeout_work(struct work_struct *work)
- {
- 	REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
-+	rtnl_lock();
- 	restore_regulatory_settings(true);
-+	rtnl_unlock();
- }
- 
- int __init regulatory_init(void)
---- a/net/wireless/sme.c
-+++ b/net/wireless/sme.c
-@@ -34,8 +34,10 @@ struct cfg80211_conn {
- 		CFG80211_CONN_SCAN_AGAIN,
- 		CFG80211_CONN_AUTHENTICATE_NEXT,
- 		CFG80211_CONN_AUTHENTICATING,
-+		CFG80211_CONN_AUTH_FAILED,
- 		CFG80211_CONN_ASSOCIATE_NEXT,
- 		CFG80211_CONN_ASSOCIATING,
-+		CFG80211_CONN_ASSOC_FAILED,
- 		CFG80211_CONN_DEAUTH,
- 		CFG80211_CONN_CONNECTED,
- 	} state;
-@@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct 
- 					  NULL, 0,
- 					  params->key, params->key_len,
- 					  params->key_idx, NULL, 0);
-+	case CFG80211_CONN_AUTH_FAILED:
-+		return -ENOTCONN;
- 	case CFG80211_CONN_ASSOCIATE_NEXT:
- 		BUG_ON(!rdev->ops->assoc);
- 		wdev->conn->state = CFG80211_CONN_ASSOCIATING;
-@@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct 
- 					     WLAN_REASON_DEAUTH_LEAVING,
- 					     false);
- 		return err;
-+	case CFG80211_CONN_ASSOC_FAILED:
-+		cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
-+				     NULL, 0,
-+				     WLAN_REASON_DEAUTH_LEAVING, false);
-+		return -ENOTCONN;
- 	case CFG80211_CONN_DEAUTH:
- 		cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
- 				     NULL, 0,
- 				     WLAN_REASON_DEAUTH_LEAVING, false);
-+		/* free directly, disconnected event already sent */
-+		cfg80211_sme_free(wdev);
- 		return 0;
- 	default:
- 		return 0;
-@@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
- 		return true;
- 	}
- 
--	wdev->conn->state = CFG80211_CONN_DEAUTH;
-+	wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
- 	schedule_work(&rdev->conn_work);
- 	return false;
- }
-@@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
- 
- void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
- {
--	cfg80211_sme_free(wdev);
-+	struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
-+
-+	if (!wdev->conn)
-+		return;
-+
-+	wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
-+	schedule_work(&rdev->conn_work);
- }
- 
- void cfg80211_sme_disassoc(struct wireless_dev *wdev)
-@@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
- 
- void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
- {
--	cfg80211_sme_disassoc(wdev);
-+	struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
-+
-+	if (!wdev->conn)
-+		return;
-+
-+	wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
-+	schedule_work(&rdev->conn_work);
- }
- 
- static int cfg80211_sme_connect(struct wireless_dev *wdev,
-@@ -953,21 +976,19 @@ int cfg80211_disconnect(struct cfg80211_
- 			struct net_device *dev, u16 reason, bool wextev)
- {
- 	struct wireless_dev *wdev = dev->ieee80211_ptr;
--	int err;
-+	int err = 0;
- 
- 	ASSERT_WDEV_LOCK(wdev);
- 
- 	kfree(wdev->connect_keys);
- 	wdev->connect_keys = NULL;
- 
--	if (wdev->conn) {
-+	if (wdev->conn)
- 		err = cfg80211_sme_disconnect(wdev, reason);
--	} else if (!rdev->ops->disconnect) {
-+	else if (!rdev->ops->disconnect)
- 		cfg80211_mlme_down(rdev, dev);
--		err = 0;
+-		*cookie = roc->cookie;
 -	} else {
-+	else if (wdev->current_bss)
- 		err = rdev_disconnect(rdev, dev, reason);
--	}
- 
- 	return err;
- }
---- a/net/mac80211/rc80211_minstrel.c
-+++ b/net/mac80211/rc80211_minstrel.c
-@@ -203,6 +203,15 @@ minstrel_update_stats(struct minstrel_pr
- 	memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate));
- 	mi->max_prob_rate = tmp_prob_rate;
- 
-+#ifdef CPTCFG_MAC80211_DEBUGFS
-+	/* use fixed index if set */
-+	if (mp->fixed_rate_idx != -1) {
-+		mi->max_tp_rate[0] = mp->fixed_rate_idx;
-+		mi->max_tp_rate[1] = mp->fixed_rate_idx;
-+		mi->max_prob_rate = mp->fixed_rate_idx;
-+	}
-+#endif
-+
- 	/* Reset update timer */
- 	mi->stats_update = jiffies;
- 
-@@ -290,7 +299,7 @@ minstrel_get_rate(void *priv, struct iee
- 	struct minstrel_rate *msr, *mr;
- 	unsigned int ndx;
- 	bool mrr_capable;
--	bool prev_sample = mi->prev_sample;
-+	bool prev_sample;
- 	int delta;
- 	int sampling_ratio;
- 
-@@ -310,10 +319,16 @@ minstrel_get_rate(void *priv, struct iee
- 	/* increase sum packet counter */
- 	mi->packet_count++;
- 
-+#ifdef CPTCFG_MAC80211_DEBUGFS
-+	if (mp->fixed_rate_idx != -1)
-+		return;
-+#endif
-+
- 	delta = (mi->packet_count * sampling_ratio / 100) -
- 			(mi->sample_count + mi->sample_deferred / 2);
- 
- 	/* delta < 0: no sampling required */
-+	prev_sample = mi->prev_sample;
- 	mi->prev_sample = false;
- 	if (delta < 0 || (!mrr_capable && prev_sample))
- 		return;
---- a/drivers/net/wireless/rt2x00/rt2x00queue.c
-+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
-@@ -936,13 +936,8 @@ void rt2x00queue_index_inc(struct queue_
- 	spin_unlock_irqrestore(&queue->index_lock, irqflags);
- }
- 
--void rt2x00queue_pause_queue(struct data_queue *queue)
-+void rt2x00queue_pause_queue_nocheck(struct data_queue *queue)
- {
--	if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
--	    !test_bit(QUEUE_STARTED, &queue->flags) ||
--	    test_and_set_bit(QUEUE_PAUSED, &queue->flags))
--		return;
--
- 	switch (queue->qid) {
- 	case QID_AC_VO:
- 	case QID_AC_VI:
-@@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data
- 		break;
- 	}
- }
-+void rt2x00queue_pause_queue(struct data_queue *queue)
-+{
-+	if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
-+	    !test_bit(QUEUE_STARTED, &queue->flags) ||
-+	    test_and_set_bit(QUEUE_PAUSED, &queue->flags))
-+		return;
-+
-+	rt2x00queue_pause_queue_nocheck(queue);
-+}
- EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
- 
- void rt2x00queue_unpause_queue(struct data_queue *queue)
-@@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_
- 		return;
- 	}
- 
--	rt2x00queue_pause_queue(queue);
-+	rt2x00queue_pause_queue_nocheck(queue);
- 
- 	queue->rt2x00dev->ops->lib->stop_queue(queue);
- 
---- a/net/mac80211/mlme.c
-+++ b/net/mac80211/mlme.c
-@@ -31,10 +31,12 @@
- #include "led.h"
- 
- #define IEEE80211_AUTH_TIMEOUT		(HZ / 5)
-+#define IEEE80211_AUTH_TIMEOUT_LONG	(HZ / 2)
- #define IEEE80211_AUTH_TIMEOUT_SHORT	(HZ / 10)
- #define IEEE80211_AUTH_MAX_TRIES	3
- #define IEEE80211_AUTH_WAIT_ASSOC	(HZ * 5)
- #define IEEE80211_ASSOC_TIMEOUT		(HZ / 5)
-+#define IEEE80211_ASSOC_TIMEOUT_LONG	(HZ / 2)
- #define IEEE80211_ASSOC_TIMEOUT_SHORT	(HZ / 10)
- #define IEEE80211_ASSOC_MAX_TRIES	3
- 
-@@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee
- 			     struct ieee80211_channel *channel,
- 			     const struct ieee80211_ht_operation *ht_oper,
- 			     const struct ieee80211_vht_operation *vht_oper,
--			     struct cfg80211_chan_def *chandef, bool verbose)
-+			     struct cfg80211_chan_def *chandef, bool tracking)
- {
-+	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
- 	struct cfg80211_chan_def vht_chandef;
- 	u32 ht_cfreq, ret;
- 
-@@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee
- 	ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
- 						  channel->band);
- 	/* check that channel matches the right operating channel */
--	if (channel->center_freq != ht_cfreq) {
-+	if (!tracking && channel->center_freq != ht_cfreq) {
- 		/*
- 		 * It's possible that some APs are confused here;
- 		 * Netgear WNDR3700 sometimes reports 4 higher than
-@@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee
- 		 * since we look at probe response/beacon data here
- 		 * it should be OK.
- 		 */
--		if (verbose)
--			sdata_info(sdata,
--				   "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
--				   channel->center_freq, ht_cfreq,
--				   ht_oper->primary_chan, channel->band);
-+		sdata_info(sdata,
-+			   "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
-+			   channel->center_freq, ht_cfreq,
-+			   ht_oper->primary_chan, channel->band);
- 		ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
- 		goto out;
- 	}
-@@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee
- 				channel->band);
- 		break;
- 	default:
--		if (verbose)
-+		if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
- 			sdata_info(sdata,
- 				   "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
- 				   vht_oper->chan_width);
-@@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee
- 	}
- 
- 	if (!cfg80211_chandef_valid(&vht_chandef)) {
--		if (verbose)
-+		if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
- 			sdata_info(sdata,
- 				   "AP VHT information is invalid, disable VHT\n");
- 		ret = IEEE80211_STA_DISABLE_VHT;
-@@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee
- 	}
- 
- 	if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
--		if (verbose)
-+		if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
- 			sdata_info(sdata,
- 				   "AP VHT information doesn't match HT, disable VHT\n");
- 		ret = IEEE80211_STA_DISABLE_VHT;
-@@ -333,18 +335,27 @@ out:
- 	if (ret & IEEE80211_STA_DISABLE_VHT)
- 		vht_chandef = *chandef;
- 
-+	/*
-+	 * Ignore the DISABLED flag when we're already connected and only
-+	 * tracking the APs beacon for bandwidth changes - otherwise we
-+	 * might get disconnected here if we connect to an AP, update our
-+	 * regulatory information based on the AP's country IE and the
-+	 * information we have is wrong/outdated and disables the channel
-+	 * that we're actually using for the connection to the AP.
-+	 */
- 	while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
--					IEEE80211_CHAN_DISABLED)) {
-+					tracking ? 0 :
-+						   IEEE80211_CHAN_DISABLED)) {
- 		if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
- 			ret = IEEE80211_STA_DISABLE_HT |
- 			      IEEE80211_STA_DISABLE_VHT;
--			goto out;
-+			break;
- 		}
- 
- 		ret |= chandef_downgrade(chandef);
- 	}
- 
--	if (chandef->width != vht_chandef.width && verbose)
-+	if (chandef->width != vht_chandef.width && !tracking)
- 		sdata_info(sdata,
- 			   "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
- 
-@@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ie
- 
- 	/* calculate new channel (type) based on HT/VHT operation IEs */
- 	flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper,
--					     vht_oper, &chandef, false);
-+					     vht_oper, &chandef, true);
- 
- 	/*
- 	 * Downgrade the new channel if we associated with restricted
-@@ -1043,6 +1054,13 @@ ieee80211_sta_process_chanswitch(struct 
- 		if (!ieee80211_operating_class_to_band(
- 				elems->ext_chansw_ie->new_operating_class,
- 				&new_band)) {
-+			/*
-+			 * Some APs send invalid ECSA IEs in probe response
-+			 * frames, so check for these and ignore them.
-+			 */
-+			if (beacon && elems->ext_chansw_ie->new_ch_num == 0 &&
-+			    elems->ext_chansw_ie->new_operating_class == 0)
-+				return;
- 			sdata_info(sdata,
- 				   "cannot understand ECSA IE operating class %d, disconnecting\n",
- 				   elems->ext_chansw_ie->new_operating_class);
-@@ -1110,6 +1128,15 @@ ieee80211_sta_process_chanswitch(struct 
- 	case -1:
- 		cfg80211_chandef_create(&new_chandef, new_chan,
- 					NL80211_CHAN_NO_HT);
-+		/* keep width for 5/10 MHz channels */
-+		switch (sdata->vif.bss_conf.chandef.width) {
-+		case NL80211_CHAN_WIDTH_5:
-+		case NL80211_CHAN_WIDTH_10:
-+			new_chandef.width = sdata->vif.bss_conf.chandef.width;
-+			break;
-+		default:
-+			break;
-+		}
- 		break;
- 	}
- 
-@@ -3394,10 +3421,13 @@ static int ieee80211_probe_auth(struct i
- 
- 	if (tx_flags == 0) {
- 		auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
--		ifmgd->auth_data->timeout_started = true;
-+		auth_data->timeout_started = true;
- 		run_again(sdata, auth_data->timeout);
- 	} else {
--		auth_data->timeout_started = false;
-+		auth_data->timeout =
-+			round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
-+		auth_data->timeout_started = true;
-+		run_again(sdata, auth_data->timeout);
- 	}
- 
- 	return 0;
-@@ -3434,7 +3464,11 @@ static int ieee80211_do_assoc(struct iee
- 		assoc_data->timeout_started = true;
- 		run_again(sdata, assoc_data->timeout);
- 	} else {
--		assoc_data->timeout_started = false;
-+		assoc_data->timeout =
-+			round_jiffies_up(jiffies +
-+					 IEEE80211_ASSOC_TIMEOUT_LONG);
-+		assoc_data->timeout_started = true;
-+		run_again(sdata, assoc_data->timeout);
- 	}
- 
- 	return 0;
-@@ -3829,7 +3863,7 @@ static int ieee80211_prep_channel(struct
- 	ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
- 						     cbss->channel,
- 						     ht_oper, vht_oper,
--						     &chandef, true);
-+						     &chandef, false);
- 
- 	sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
- 				      local->rx_chains);
---- a/net/wireless/core.c
-+++ b/net/wireless/core.c
-@@ -772,6 +772,7 @@ void cfg80211_leave(struct cfg80211_regi
- 		cfg80211_leave_mesh(rdev, dev);
- 		break;
- 	case NL80211_IFTYPE_AP:
-+	case NL80211_IFTYPE_P2P_GO:
- 		cfg80211_stop_ap(rdev, dev);
- 		break;
- 	default:
---- a/drivers/net/wireless/rtlwifi/Kconfig
-+++ b/drivers/net/wireless/rtlwifi/Kconfig
-@@ -1,29 +1,22 @@
--config RTLWIFI
--	tristate "Realtek wireless card support"
-+menuconfig RTL_CARDS
-+	tristate "Realtek rtlwifi family of devices"
- 	depends on m
--	depends on MAC80211
--	select BACKPORT_FW_LOADER
--	---help---
--	  This is common code for RTL8192CE/RTL8192CU/RTL8192SE/RTL8723AE
--	  drivers.  This module does nothing by itself - the various front-end
--	  drivers need to be enabled to support any desired devices.
--
--	  If you choose to build as a module, it'll be called rtlwifi.
--
--config RTLWIFI_DEBUG
--	bool "Debugging output for rtlwifi driver family"
--	depends on RTLWIFI
-+	depends on MAC80211 && (PCI || USB)
- 	default y
- 	---help---
--	To use the module option that sets the dynamic-debugging level for,
--	the front-end driver, this parameter must be "Y". For memory-limited
--	systems, choose "N". If in doubt, choose "Y".
-+	  This option will enable support for the Realtek mac80211-based
-+	  wireless drivers. Drivers rtl8192ce, rtl8192cu, rtl8192se, rtl8192de,
-+	  rtl8723eu, and rtl8188eu share some common code.
-+
-+if RTL_CARDS
- 
- config RTL8192CE
- 	tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter"
- 	depends on m
--	depends on RTLWIFI && PCI
-+	depends on PCI
- 	select RTL8192C_COMMON
-+	select RTLWIFI
-+	select RTLWIFI_PCI
- 	---help---
- 	This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe
- 	wireless network adapters.
-@@ -33,7 +26,9 @@ config RTL8192CE
- config RTL8192SE
- 	tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter"
- 	depends on m
--	depends on RTLWIFI && PCI
-+	depends on PCI
-+	select RTLWIFI
-+	select RTLWIFI_PCI
- 	---help---
- 	This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe
- 	wireless network adapters.
-@@ -43,7 +38,9 @@ config RTL8192SE
- config RTL8192DE
- 	tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter"
- 	depends on m
--	depends on RTLWIFI && PCI
-+	depends on PCI
-+	select RTLWIFI
-+	select RTLWIFI_PCI
- 	---help---
- 	This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe
- 	wireless network adapters.
-@@ -53,7 +50,9 @@ config RTL8192DE
- config RTL8723AE
- 	tristate "Realtek RTL8723AE PCIe Wireless Network Adapter"
- 	depends on m
--	depends on RTLWIFI && PCI
-+	depends on PCI
-+	select RTLWIFI
-+	select RTLWIFI_PCI
- 	---help---
- 	This is the driver for Realtek RTL8723AE 802.11n PCIe
- 	wireless network adapters.
-@@ -63,7 +62,9 @@ config RTL8723AE
- config RTL8188EE
- 	tristate "Realtek RTL8188EE Wireless Network Adapter"
- 	depends on m
--	depends on RTLWIFI && PCI
-+	depends on PCI
-+	select RTLWIFI
-+	select RTLWIFI_PCI
- 	---help---
- 	This is the driver for Realtek RTL8188EE 802.11n PCIe
- 	wireless network adapters.
-@@ -73,7 +74,9 @@ config RTL8188EE
- config RTL8192CU
- 	tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter"
- 	depends on m
--	depends on RTLWIFI && USB
-+	depends on USB
-+	select RTLWIFI
-+	select RTLWIFI_USB
- 	select RTL8192C_COMMON
- 	---help---
- 	This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB
-@@ -81,8 +84,32 @@ config RTL8192CU
- 
- 	If you choose to build it as a module, it will be called rtl8192cu
- 
-+config RTLWIFI
-+	tristate
-+	depends on m
-+	select BACKPORT_FW_LOADER
-+
-+config RTLWIFI_PCI
-+	tristate
-+	depends on m
-+
-+config RTLWIFI_USB
-+	tristate
-+	depends on m
-+
-+config RTLWIFI_DEBUG
-+	bool "Debugging output for rtlwifi driver family"
-+	depends on RTLWIFI
-+	default y
-+	---help---
-+	To use the module option that sets the dynamic-debugging level for,
-+	the front-end driver, this parameter must be "Y". For memory-limited
-+	systems, choose "N". If in doubt, choose "Y".
-+
- config RTL8192C_COMMON
- 	tristate
- 	depends on m
- 	depends on RTL8192CE || RTL8192CU
--	default m
-+	default y
-+
-+endif
---- a/drivers/net/wireless/rtlwifi/Makefile
-+++ b/drivers/net/wireless/rtlwifi/Makefile
-@@ -12,13 +12,11 @@ rtlwifi-objs	:=		\
- 
- rtl8192c_common-objs +=		\
- 
--ifneq ($(CONFIG_PCI),)
--rtlwifi-objs	+= pci.o
--endif
-+obj-$(CPTCFG_RTLWIFI_PCI)	+= rtl_pci.o
-+rtl_pci-objs	:=		pci.o
- 
--ifneq ($(CONFIG_USB),)
--rtlwifi-objs	+= usb.o
--endif
-+obj-$(CPTCFG_RTLWIFI_USB)	+= rtl_usb.o
-+rtl_usb-objs	:=		usb.o
- 
- obj-$(CPTCFG_RTL8192C_COMMON)	+= rtl8192c/
- obj-$(CPTCFG_RTL8192CE)		+= rtl8192ce/
---- a/drivers/net/wireless/rtlwifi/ps.h
-+++ b/drivers/net/wireless/rtlwifi/ps.h
-@@ -49,5 +49,6 @@ void rtl_swlps_rf_awake(struct ieee80211
- void rtl_swlps_rf_sleep(struct ieee80211_hw *hw);
- void rtl_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
- void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len);
-+void rtl_lps_change_work_callback(struct work_struct *work);
- 
- #endif
---- a/drivers/net/wireless/rtlwifi/base.c
-+++ b/drivers/net/wireless/rtlwifi/base.c
-@@ -173,6 +173,7 @@ u8 rtl_tid_to_ac(u8 tid)
- {
- 	return tid_to_ac[tid];
- }
-+EXPORT_SYMBOL_GPL(rtl_tid_to_ac);
- 
- static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
- 				  struct ieee80211_sta_ht_cap *ht_cap)
-@@ -407,6 +408,7 @@ void rtl_deinit_deferred_work(struct iee
- 	cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
- 	cancel_delayed_work(&rtlpriv->works.fwevt_wq);
- }
-+EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
- 
- void rtl_init_rfkill(struct ieee80211_hw *hw)
- {
-@@ -440,6 +442,7 @@ void rtl_deinit_rfkill(struct ieee80211_
- {
- 	wiphy_rfkill_stop_polling(hw->wiphy);
- }
-+EXPORT_SYMBOL_GPL(rtl_deinit_rfkill);
- 
- int rtl_init_core(struct ieee80211_hw *hw)
- {
-@@ -490,10 +493,12 @@ int rtl_init_core(struct ieee80211_hw *h
- 
- 	return 0;
- }
-+EXPORT_SYMBOL_GPL(rtl_init_core);
- 
- void rtl_deinit_core(struct ieee80211_hw *hw)
- {
- }
-+EXPORT_SYMBOL_GPL(rtl_deinit_core);
- 
- void rtl_init_rx_config(struct ieee80211_hw *hw)
- {
-@@ -502,6 +507,7 @@ void rtl_init_rx_config(struct ieee80211
- 
- 	rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf));
- }
-+EXPORT_SYMBOL_GPL(rtl_init_rx_config);
- 
- /*********************************************************
-  *
-@@ -880,6 +886,7 @@ bool rtl_tx_mgmt_proc(struct ieee80211_h
- 
- 	return true;
- }
-+EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc);
- 
- void rtl_get_tcb_desc(struct ieee80211_hw *hw,
- 		      struct ieee80211_tx_info *info,
-@@ -1053,6 +1060,7 @@ bool rtl_action_proc(struct ieee80211_hw
- 
- 	return true;
- }
-+EXPORT_SYMBOL_GPL(rtl_action_proc);
- 
- /*should call before software enc*/
- u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
-@@ -1126,6 +1134,7 @@ u8 rtl_is_special_data(struct ieee80211_
- 
- 	return false;
- }
-+EXPORT_SYMBOL_GPL(rtl_is_special_data);
- 
- /*********************************************************
-  *
-@@ -1301,6 +1310,7 @@ void rtl_beacon_statistic(struct ieee802
- 
- 	rtlpriv->link_info.bcn_rx_inperiod++;
- }
-+EXPORT_SYMBOL_GPL(rtl_beacon_statistic);
- 
- void rtl_watchdog_wq_callback(void *data)
- {
-@@ -1794,6 +1804,7 @@ void rtl_recognize_peer(struct ieee80211
- 
- 	mac->vendor = vendor;
- }
-+EXPORT_SYMBOL_GPL(rtl_recognize_peer);
- 
- /*********************************************************
-  *
-@@ -1850,6 +1861,7 @@ struct attribute_group rtl_attribute_gro
- 	.name = "rtlsysfs",
- 	.attrs = rtl_sysfs_entries,
- };
-+EXPORT_SYMBOL_GPL(rtl_attribute_group);
- 
- MODULE_AUTHOR("lizhaoming	<chaoming_li@realsil.com.cn>");
- MODULE_AUTHOR("Realtek WlanFAE	<wlanfae@realtek.com>");
-@@ -1857,7 +1869,8 @@ MODULE_AUTHOR("Larry Finger	<Larry.FInge
- MODULE_LICENSE("GPL");
- MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
- 
--struct rtl_global_var global_var = {};
-+struct rtl_global_var rtl_global_var = {};
-+EXPORT_SYMBOL_GPL(rtl_global_var);
- 
- static int __init rtl_core_module_init(void)
- {
-@@ -1865,8 +1878,8 @@ static int __init rtl_core_module_init(v
- 		pr_err("Unable to register rtl_rc, use default RC !!\n");
- 
- 	/* init some global vars */
--	INIT_LIST_HEAD(&global_var.glb_priv_list);
--	spin_lock_init(&global_var.glb_list_lock);
-+	INIT_LIST_HEAD(&rtl_global_var.glb_priv_list);
-+	spin_lock_init(&rtl_global_var.glb_list_lock);
- 
- 	return 0;
- }
---- a/drivers/net/wireless/rtlwifi/base.h
-+++ b/drivers/net/wireless/rtlwifi/base.h
-@@ -147,7 +147,7 @@ void rtl_recognize_peer(struct ieee80211
- u8 rtl_tid_to_ac(u8 tid);
- extern struct attribute_group rtl_attribute_group;
- void rtl_easy_concurrent_retrytimer_callback(unsigned long data);
--extern struct rtl_global_var global_var;
-+extern struct rtl_global_var rtl_global_var;
- int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
- 			 bool isht, u8 desc_rate, bool first_ampdu);
- bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
---- a/drivers/net/wireless/rtlwifi/core.c
-+++ b/drivers/net/wireless/rtlwifi/core.c
-@@ -1330,3 +1330,4 @@ const struct ieee80211_ops rtl_ops = {
- 	.rfkill_poll = rtl_op_rfkill_poll,
- 	.flush = rtl_op_flush,
- };
-+EXPORT_SYMBOL_GPL(rtl_ops);
---- a/drivers/net/wireless/rtlwifi/debug.c
-+++ b/drivers/net/wireless/rtlwifi/debug.c
-@@ -51,3 +51,4 @@ void rtl_dbgp_flag_init(struct ieee80211
- 
- 	/*Init Debug flag enable condition */
- }
-+EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
---- a/drivers/net/wireless/rtlwifi/efuse.c
-+++ b/drivers/net/wireless/rtlwifi/efuse.c
-@@ -229,6 +229,7 @@ void read_efuse_byte(struct ieee80211_hw
- 
- 	*pbuf = (u8) (value32 & 0xff);
- }
-+EXPORT_SYMBOL_GPL(read_efuse_byte);
- 
- void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
- {
---- a/drivers/net/wireless/rtlwifi/pci.c
-+++ b/drivers/net/wireless/rtlwifi/pci.c
-@@ -35,6 +35,13 @@
- #include "efuse.h"
- #include <linux/export.h>
- #include <linux/kmemleak.h>
-+#include <linux/module.h>
-+
-+MODULE_AUTHOR("lizhaoming	<chaoming_li@realsil.com.cn>");
-+MODULE_AUTHOR("Realtek WlanFAE	<wlanfae@realtek.com>");
-+MODULE_AUTHOR("Larry Finger	<Larry.FInger@lwfinger.net>");
-+MODULE_LICENSE("GPL");
-+MODULE_DESCRIPTION("PCI basic driver for rtlwifi");
- 
- static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = {
- 	PCI_VENDOR_ID_INTEL,
-@@ -1008,19 +1015,6 @@ static void _rtl_pci_prepare_bcn_tasklet
- 	return;
- }
- 
--static void rtl_lps_change_work_callback(struct work_struct *work)
--{
--	struct rtl_works *rtlworks =
--	    container_of(work, struct rtl_works, lps_change_work);
--	struct ieee80211_hw *hw = rtlworks->hw;
--	struct rtl_priv *rtlpriv = rtl_priv(hw);
--
--	if (rtlpriv->enter_ps)
--		rtl_lps_enter(hw);
--	else
--		rtl_lps_leave(hw);
--}
--
- static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
- {
- 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
-@@ -1899,7 +1893,7 @@ int rtl_pci_probe(struct pci_dev *pdev,
- 	rtlpriv->rtlhal.interface = INTF_PCI;
- 	rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data);
- 	rtlpriv->intf_ops = &rtl_pci_ops;
--	rtlpriv->glb_var = &global_var;
-+	rtlpriv->glb_var = &rtl_global_var;
- 
- 	/*
- 	 *init dbgp flags before all
---- a/drivers/net/wireless/rtlwifi/ps.c
-+++ b/drivers/net/wireless/rtlwifi/ps.c
-@@ -269,6 +269,7 @@ void rtl_ips_nic_on(struct ieee80211_hw 
- 
- 	spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags);
- }
-+EXPORT_SYMBOL_GPL(rtl_ips_nic_on);
- 
- /*for FW LPS*/
- 
-@@ -518,6 +519,7 @@ void rtl_swlps_beacon(struct ieee80211_h
- 			 "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed);
- 	}
- }
-+EXPORT_SYMBOL_GPL(rtl_swlps_beacon);
- 
- void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
- {
-@@ -611,6 +613,19 @@ void rtl_swlps_rf_sleep(struct ieee80211
- 			MSECS(sleep_intv * mac->vif->bss_conf.beacon_int - 40));
- }
- 
-+void rtl_lps_change_work_callback(struct work_struct *work)
-+{
-+	struct rtl_works *rtlworks =
-+	    container_of(work, struct rtl_works, lps_change_work);
-+	struct ieee80211_hw *hw = rtlworks->hw;
-+	struct rtl_priv *rtlpriv = rtl_priv(hw);
-+
-+	if (rtlpriv->enter_ps)
-+		rtl_lps_enter(hw);
-+	else
-+		rtl_lps_leave(hw);
-+}
-+EXPORT_SYMBOL_GPL(rtl_lps_change_work_callback);
- 
- void rtl_swlps_wq_callback(void *data)
- {
-@@ -922,3 +937,4 @@ void rtl_p2p_info(struct ieee80211_hw *h
- 	else
- 		rtl_p2p_noa_ie(hw, data, len - FCS_LEN);
- }
-+EXPORT_SYMBOL_GPL(rtl_p2p_info);
---- a/drivers/net/wireless/rtlwifi/usb.c
-+++ b/drivers/net/wireless/rtlwifi/usb.c
-@@ -32,6 +32,13 @@
- #include "ps.h"
- #include "rtl8192c/fw_common.h"
- #include <linux/export.h>
-+#include <linux/module.h>
-+
-+MODULE_AUTHOR("lizhaoming	<chaoming_li@realsil.com.cn>");
-+MODULE_AUTHOR("Realtek WlanFAE	<wlanfae@realtek.com>");
-+MODULE_AUTHOR("Larry Finger	<Larry.FInger@lwfinger.net>");
-+MODULE_LICENSE("GPL");
-+MODULE_DESCRIPTION("USB basic driver for rtlwifi");
- 
- #define	REALTEK_USB_VENQT_READ			0xC0
- #define	REALTEK_USB_VENQT_WRITE			0x40
-@@ -1070,6 +1077,8 @@ int rtl_usb_probe(struct usb_interface *
- 	spin_lock_init(&rtlpriv->locks.usb_lock);
- 	INIT_WORK(&rtlpriv->works.fill_h2c_cmd,
- 		  rtl_fill_h2c_cmd_work_callback);
-+	INIT_WORK(&rtlpriv->works.lps_change_work,
-+		  rtl_lps_change_work_callback);
- 
- 	rtlpriv->usb_data_index = 0;
- 	init_completion(&rtlpriv->firmware_loading_complete);
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -64,7 +64,6 @@ struct ath_node;
- 
- struct ath_config {
- 	u16 txpowlimit;
--	u8 cabqReadytime;
- };
- 
- /*************************/
-@@ -72,17 +71,12 @@ struct ath_config {
- /*************************/
- 
- #define ATH_TXBUF_RESET(_bf) do {				\
--		(_bf)->bf_stale = false;			\
- 		(_bf)->bf_lastbf = NULL;			\
- 		(_bf)->bf_next = NULL;				\
- 		memset(&((_bf)->bf_state), 0,			\
- 		       sizeof(struct ath_buf_state));		\
- 	} while (0)
- 
--#define ATH_RXBUF_RESET(_bf) do {		\
--		(_bf)->bf_stale = false;	\
--	} while (0)
--
- /**
-  * enum buffer_type - Buffer type flags
-  *
-@@ -137,7 +131,8 @@ int ath_descdma_setup(struct ath_softc *
- #define ATH_AGGR_ENCRYPTDELIM      10
- /* minimum h/w qdepth to be sustained to maximize aggregation */
- #define ATH_AGGR_MIN_QDEPTH        2
--#define ATH_AMPDU_SUBFRAME_DEFAULT 32
-+/* minimum h/w qdepth for non-aggregated traffic */
-+#define ATH_NON_AGGR_MIN_QDEPTH    8
- 
- #define IEEE80211_SEQ_SEQ_SHIFT    4
- #define IEEE80211_SEQ_MAX          4096
-@@ -174,12 +169,6 @@ int ath_descdma_setup(struct ath_softc *
- 
- #define ATH_TX_COMPLETE_POLL_INT	1000
- 
--enum ATH_AGGR_STATUS {
--	ATH_AGGR_DONE,
--	ATH_AGGR_BAW_CLOSED,
--	ATH_AGGR_LIMITED,
--};
--
- #define ATH_TXFIFO_DEPTH 8
- struct ath_txq {
- 	int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */
-@@ -201,10 +190,10 @@ struct ath_txq {
- 
- struct ath_atx_ac {
- 	struct ath_txq *txq;
--	int sched;
- 	struct list_head list;
- 	struct list_head tid_q;
- 	bool clear_ps_filter;
-+	bool sched;
- };
- 
- struct ath_frame_info {
-@@ -212,14 +201,24 @@ struct ath_frame_info {
- 	int framelen;
- 	enum ath9k_key_type keytype;
- 	u8 keyix;
--	u8 retries;
- 	u8 rtscts_rate;
-+	u8 retries : 7;
-+	u8 baw_tracked : 1;
-+};
-+
-+struct ath_rxbuf {
-+	struct list_head list;
-+	struct sk_buff *bf_mpdu;
-+	void *bf_desc;
-+	dma_addr_t bf_daddr;
-+	dma_addr_t bf_buf_addr;
- };
- 
- struct ath_buf_state {
- 	u8 bf_type;
- 	u8 bfs_paprd;
- 	u8 ndelim;
-+	bool stale;
- 	u16 seqno;
- 	unsigned long bfs_paprd_timestamp;
- };
-@@ -233,7 +232,6 @@ struct ath_buf {
- 	void *bf_desc;			/* virtual addr of desc */
- 	dma_addr_t bf_daddr;		/* physical addr of desc */
- 	dma_addr_t bf_buf_addr;	/* physical addr of data buffer, for DMA */
--	bool bf_stale;
- 	struct ieee80211_tx_rate rates[4];
- 	struct ath_buf_state bf_state;
- };
-@@ -241,16 +239,18 @@ struct ath_buf {
- struct ath_atx_tid {
- 	struct list_head list;
- 	struct sk_buff_head buf_q;
-+	struct sk_buff_head retry_q;
- 	struct ath_node *an;
- 	struct ath_atx_ac *ac;
- 	unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
--	int bar_index;
- 	u16 seq_start;
- 	u16 seq_next;
- 	u16 baw_size;
--	int tidno;
-+	u8 tidno;
- 	int baw_head;   /* first un-acked tx buffer */
- 	int baw_tail;   /* next unused tx buffer slot */
-+
-+	s8 bar_index;
- 	bool sched;
- 	bool paused;
- 	bool active;
-@@ -262,12 +262,13 @@ struct ath_node {
- 	struct ieee80211_vif *vif; /* interface with which we're associated */
- 	struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
- 	struct ath_atx_ac ac[IEEE80211_NUM_ACS];
--	int ps_key;
- 
- 	u16 maxampdu;
- 	u8 mpdudensity;
-+	s8 ps_key;
- 
- 	bool sleeping;
-+	bool no_ps_filter;
- 
- #if defined(CPTCFG_MAC80211_DEBUGFS) && defined(CPTCFG_ATH9K_DEBUGFS)
- 	struct dentry *node_stat;
-@@ -317,6 +318,7 @@ struct ath_rx {
- 	struct ath_descdma rxdma;
- 	struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX];
- 
-+	struct ath_rxbuf *buf_hold;
- 	struct sk_buff *frag;
- 
- 	u32 ampdu_ref;
-@@ -367,6 +369,7 @@ void ath9k_release_buffered_frames(struc
- /********/
- 
- struct ath_vif {
-+	struct ath_node mcast_node;
- 	int av_bslot;
- 	bool primary_sta_vif;
- 	__le64 tsf_adjust; /* TSF adjustment for staggered beacons */
-@@ -459,6 +462,7 @@ void ath_check_ani(struct ath_softc *sc)
- int ath_update_survey_stats(struct ath_softc *sc);
- void ath_update_survey_nf(struct ath_softc *sc, int channel);
- void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type);
-+void ath_ps_full_sleep(unsigned long data);
- 
- /**********/
- /* BTCOEX */
-@@ -585,19 +589,14 @@ static inline void ath_fill_led_pin(stru
- #define ATH_ANT_DIV_COMB_MAX_COUNT 100
- #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30
- #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20
-+#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50
-+#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50
- 
- #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1
- #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4
- #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2
- #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2
- 
--enum ath9k_ant_div_comb_lna_conf {
--	ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2,
--	ATH_ANT_DIV_COMB_LNA2,
--	ATH_ANT_DIV_COMB_LNA1,
--	ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2,
--};
--
- struct ath_ant_comb {
- 	u16 count;
- 	u16 total_pkt_count;
-@@ -614,27 +613,36 @@ struct ath_ant_comb {
- 	int rssi_first;
- 	int rssi_second;
- 	int rssi_third;
-+	int ant_ratio;
-+	int ant_ratio2;
- 	bool alt_good;
- 	int quick_scan_cnt;
--	int main_conf;
-+	enum ath9k_ant_div_comb_lna_conf main_conf;
- 	enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf;
- 	enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf;
- 	bool first_ratio;
- 	bool second_ratio;
- 	unsigned long scan_start_time;
-+
-+	/*
-+	 * Card-specific config values.
-+	 */
-+	int low_rssi_thresh;
-+	int fast_div_bias;
- };
- 
- void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
--void ath_ant_comb_update(struct ath_softc *sc);
- 
- /********************/
- /* Main driver core */
- /********************/
- 
--#define ATH9K_PCI_CUS198 0x0001
--#define ATH9K_PCI_CUS230 0x0002
--#define ATH9K_PCI_CUS217 0x0004
--#define ATH9K_PCI_WOW    0x0008
-+#define ATH9K_PCI_CUS198     0x0001
-+#define ATH9K_PCI_CUS230     0x0002
-+#define ATH9K_PCI_CUS217     0x0004
-+#define ATH9K_PCI_WOW        0x0008
-+#define ATH9K_PCI_BT_ANT_DIV 0x0010
-+#define ATH9K_PCI_D3_L1_WAR  0x0020
- 
- /*
-  * Default cache line size, in bytes.
-@@ -717,6 +725,7 @@ struct ath_softc {
- 	struct work_struct hw_check_work;
- 	struct work_struct hw_reset_work;
- 	struct completion paprd_complete;
-+	wait_queue_head_t tx_wait;
- 
- 	unsigned int hw_busy_count;
- 	unsigned long sc_flags;
-@@ -753,6 +762,7 @@ struct ath_softc {
- 	struct delayed_work tx_complete_work;
- 	struct delayed_work hw_pll_work;
- 	struct timer_list rx_poll_timer;
-+	struct timer_list sleep_timer;
- 
- #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
- 	struct ath_btcoex btcoex;
-@@ -926,7 +936,6 @@ void ath9k_deinit_device(struct ath_soft
- void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw);
- void ath9k_reload_chainmask_settings(struct ath_softc *sc);
- 
--bool ath9k_uses_beacons(int type);
- void ath9k_spectral_scan_trigger(struct ieee80211_hw *hw);
- int ath9k_spectral_scan_config(struct ieee80211_hw *hw,
- 			       enum spectral_mode spectral_mode);
---- a/drivers/net/wireless/ath/ath9k/debug.c
-+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -270,25 +270,29 @@ static const struct file_operations fops
- 	.llseek = default_llseek,
- };
- 
--static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
--				       size_t count, loff_t *ppos)
-+#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
-+
-+static ssize_t read_file_bt_ant_diversity(struct file *file,
-+					  char __user *user_buf,
-+					  size_t count, loff_t *ppos)
- {
- 	struct ath_softc *sc = file->private_data;
- 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
- 	char buf[32];
- 	unsigned int len;
- 
--	len = sprintf(buf, "%d\n", common->antenna_diversity);
-+	len = sprintf(buf, "%d\n", common->bt_ant_diversity);
- 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
- }
- 
--static ssize_t write_file_ant_diversity(struct file *file,
--					const char __user *user_buf,
--					size_t count, loff_t *ppos)
-+static ssize_t write_file_bt_ant_diversity(struct file *file,
-+					   const char __user *user_buf,
-+					   size_t count, loff_t *ppos)
- {
- 	struct ath_softc *sc = file->private_data;
- 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
--	unsigned long antenna_diversity;
-+	struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps;
-+	unsigned long bt_ant_diversity;
- 	char buf[32];
- 	ssize_t len;
-