--- a/compat/Makefile
+++ b/compat/Makefile
@@ -6,31 +6,31 @@ obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += c
 compat-y += main.o
 
 # Compat kernel compatibility code
-compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o
-compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o
-compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o
-compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o
-compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o
-compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o
-compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o
-compat-$(CONFIG_COMPAT_KERNEL_25) += \
+compat-$(CONFIG_COMPAT_KERNEL_2_6_14) += compat-2.6.14.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_18) += compat-2.6.18.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_19) += compat-2.6.19.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_21) += compat-2.6.21.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_22) += compat-2.6.22.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_23) += compat-2.6.23.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_24) += compat-2.6.24.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_25) += \
 	compat-2.6.25.o \
 	pm_qos_params.o
 
-compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o
-compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o
-compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o
-compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o
-compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o
-compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o
-compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o
-compat-$(CONFIG_COMPAT_KERNEL_36) += \
+compat-$(CONFIG_COMPAT_KERNEL_2_6_26) += compat-2.6.26.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_27) += compat-2.6.27.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_28) += compat-2.6.28.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_29) += compat-2.6.29.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_32) += compat-2.6.32.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_33) += compat-2.6.33.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_35) += compat-2.6.35.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_36) += \
 	compat-2.6.36.o \
 	kfifo.o
 
-compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o
-compat-$(CONFIG_COMPAT_KERNEL_38) += compat-2.6.38.o
-compat-$(CONFIG_COMPAT_KERNEL_39) += \
+compat-$(CONFIG_COMPAT_KERNEL_2_6_37) += compat-2.6.37.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_38) += compat-2.6.38.o
+compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \
 	compat-2.6.39.o \
 	kstrtox.o
 
--- a/include/linux/compat-2.6.34.h
+++ b/include/linux/compat-2.6.34.h
@@ -251,6 +251,8 @@ static inline int usb_disable_autosuspen
 
 #define rcu_dereference_raw(p)	rcu_dereference(p)
 
+#define KEY_WPS_BUTTON		0x211	/* WiFi Protected Setup key */
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */
 
 #endif /* LINUX_26_34_COMPAT_H */
--- a/include/linux/compat-2.6.40.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef LINUX_26_40_COMPAT_H
-#define LINUX_26_40_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40))
-
-#include <linux/rcupdate.h>
-
-/*
- * This is not part of The 2.6.37 kernel yet but we
- * we use it to optimize the backport code we
- * need to implement. Instead of using ifdefs
- * to check what version of the check we use
- * we just replace all checks on current code
- * with this. I'll submit this upstream too, that
- * way all we'd have to do is to implement this
- * for older kernels, then we would not have to
- * edit the upstrema code for backport efforts.
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
-#define br_port_exists(dev)	(dev->priv_flags & IFF_BRIDGE_PORT)
-#else
-#define br_port_exists(dev)	(dev->br_port)
-#endif
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) */
-
-#endif /* LINUX_26_40_COMPAT_H */
--- a/include/linux/compat-2.6.h
+++ b/include/linux/compat-2.6.h
@@ -32,6 +32,7 @@
 #include <linux/compat-2.6.37.h>
 #include <linux/compat-2.6.38.h>
 #include <linux/compat-2.6.39.h>
-#include <linux/compat-2.6.40.h>
+#include <linux/compat-3.0.h>
+#include <linux/compat-3.1.h>
 
 #endif /* LINUX_26_COMPAT_H */
--- /dev/null
+++ b/include/linux/compat-3.0.h
@@ -0,0 +1,31 @@
+#ifndef LINUX_3_0_COMPAT_H
+#define LINUX_3_0_COMPAT_H
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0))
+
+/*
+ * since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171
+ * "net: call dev_alloc_name from register_netdevice" dev_alloc_name is
+ * called automatically. This is not implemented in older kernel
+ * versions so it will result in device wrong names.
+ */
+static inline int register_netdevice_name(struct net_device *dev)
+{
+	int err;
+
+	if (strchr(dev->name, '%')) {
+		err = dev_alloc_name(dev, dev->name);
+		if (err < 0)
+			return err;
+	}
+
+	return register_netdevice(dev);
+}
+
+#define register_netdevice(dev) register_netdevice_name(dev)
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */
+
+#endif /* LINUX_3_0_COMPAT_H */
--- /dev/null
+++ b/include/linux/compat-3.1.h
@@ -0,0 +1,27 @@
+#ifndef LINUX_3_1_COMPAT_H
+#define LINUX_3_1_COMPAT_H
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+
+/*
+ * This is not part of The 2.6.37 kernel yet but we
+ * we use it to optimize the backport code we
+ * need to implement. Instead of using ifdefs
+ * to check what version of the check we use
+ * we just replace all checks on current code
+ * with this. I'll submit this upstream too, that
+ * way all we'd have to do is to implement this
+ * for older kernels, then we would not have to
+ * edit the upstrema code for backport efforts.
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+#define br_port_exists(dev)	(dev->priv_flags & IFF_BRIDGE_PORT)
+#else
+#define br_port_exists(dev)	(dev->br_port)
+#endif
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */
+
+#endif /* LINUX_3_1_COMPAT_H */
--- a/config.mk
+++ b/config.mk
@@ -14,20 +14,28 @@ else
 include $(KLIB_BUILD)/.config
 endif
 
-# We will warn when you don't have MQ support or NET_SCHED enabled.
-#
-# We could consider just quiting if MQ and NET_SCHED is disabled
-# as I suspect all users of this package want 802.11e (WME) and
-# 802.11n (HT) support.
 ifneq ($(wildcard $(KLIB_BUILD)/Makefile),)
-COMPAT_LATEST_VERSION = 39
-KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p')
+
+COMPAT_LATEST_VERSION = 1
+
+KERNEL_VERSION := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p')
+
+ifneq ($(KERNEL_VERSION),2)
+KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^3\.\([0-9]\+\).*/\1/p')
+else
+COMPAT_26LATEST_VERSION = 39
+KERNEL_26SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p')
+COMPAT_26VERSIONS := $(shell I=$(COMPAT_26LATEST_VERSION); while [ "$$I" -gt $(KERNEL_26SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done)
+$(foreach ver,$(COMPAT_26VERSIONS),$(eval CONFIG_COMPAT_KERNEL_2_6_$(ver)=y))
+KERNEL_SUBLEVEL := -1
+endif
+
 COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNEL_SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done)
-$(foreach ver,$(COMPAT_VERSIONS),$(eval CONFIG_COMPAT_KERNEL_$(ver)=y))
+$(foreach ver,$(COMPAT_VERSIONS),$(eval CONFIG_COMPAT_KERNEL_3_$(ver)=y))
 
-ifdef CONFIG_COMPAT_KERNEL_24
+ifdef CONFIG_COMPAT_KERNEL_2_6_24
 $(error "ERROR: compat-wireless by default supports kernels >= 2.6.24, try enabling only one driver though")
-endif #CONFIG_COMPAT_KERNEL_24
+endif #CONFIG_COMPAT_KERNEL_2_6_24
 
 ifeq ($(CONFIG_CFG80211),y)
 $(error "ERROR: your kernel has CONFIG_CFG80211=y, you should have it CONFIG_CFG80211=m if you want to use this thing.")
@@ -37,7 +45,7 @@ endif
 # 2.6.27 has FTRACE_DYNAMIC borked, so we will complain if
 # you have it enabled, otherwise you will very likely run into
 # a kernel panic.
-ifeq ($(KERNEL_SUBLEVEL),27)
+ifeq ($(shell test $(KERNEL_VERSION) -eq 2 -a $(KERNEL_SUBLEVEL) -eq 27 && echo yes),yes)
 ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
 $(error "ERROR: Your 2.6.27 kernel has CONFIG_DYNAMIC_FTRACE, please upgrade your distribution kernel as newer ones should not have this enabled (and if so report a bug) or remove this warning if you know what you are doing")
 endif
@@ -54,7 +62,7 @@ endif
 #
 # In kernel 2.6.32 both attributes were removed.
 #
-ifeq ($(shell test $(KERNEL_SUBLEVEL) -ge 27 -a $(KERNEL_SUBLEVEL) -le 31 && echo yes),yes)
+ifeq ($(shell test $(KERNEL_VERSION) -eq 2 -a $(KERNEL_SUBLEVEL) -ge 27 -a $(KERNEL_SUBLEVEL) -le 31 && echo yes),yes)
 ifeq ($(CONFIG_MAC80211),)
 $(error "ERROR: Your >=2.6.27 and <= 2.6.31 kernel has CONFIG_MAC80211 disabled, you should have it CONFIG_MAC80211=m if you want to use this thing.")
 endif
@@ -62,6 +70,11 @@ endif
 
 ifneq ($(KERNELRELEASE),) # This prevents a warning
 
+# We will warn when you don't have MQ support or NET_SCHED enabled.
+#
+# We could consider just quiting if MQ and NET_SCHED is disabled
+# as I suspect all users of this package want 802.11e (WME) and
+# 802.11n (HT) support.
 ifeq ($(CONFIG_NET_SCHED),)
  QOS_REQS_MISSING+=CONFIG_NET_SCHED
 endif
@@ -92,20 +105,20 @@ else
 endif
 
 # The Bluetooth compatibility only builds on kernels >= 2.6.27 for now
-ifndef CONFIG_COMPAT_KERNEL_27
+ifndef CONFIG_COMPAT_KERNEL_2_6_27
 ifeq ($(CONFIG_BT),y)
 # we'll ignore compiling bluetooth
 else
  CONFIG_COMPAT_BLUETOOTH=y
  CONFIG_COMPAT_BLUETOOTH_MODULES=m
 endif
-endif #CONFIG_COMPAT_KERNEL_27
+endif #CONFIG_COMPAT_KERNEL_2_6_27
 
-ifdef CONFIG_COMPAT_KERNEL_33
+ifdef CONFIG_COMPAT_KERNEL_2_6_33
 ifdef CONFIG_FW_LOADER
  CONFIG_COMPAT_FIRMWARE_CLASS=m
 endif #CONFIG_FW_LOADER
-endif #CONFIG_COMPAT_KERNEL_33
+endif #CONFIG_COMPAT_KERNEL_2_6_33
 
 # Wireless subsystem stuff
 CONFIG_MAC80211=m
@@ -165,9 +178,9 @@ CONFIG_BT_BNEP_PROTO_FILTER=y
 ifdef CONFIG_ISDN_CAPI
 CONFIG_BT_CMTP=m
 endif #CONFIG_ISDN_CAPI
-ifndef CONFIG_COMPAT_KERNEL_28
+ifndef CONFIG_COMPAT_KERNEL_2_6_28
 CONFIG_COMPAT_BT_HIDP=m
-endif #CONFIG_COMPAT_KERNEL_28
+endif #CONFIG_COMPAT_KERNEL_2_6_28
 
 CONFIG_BT_HCIUART=M
 CONFIG_BT_HCIUART_H4=y
@@ -345,11 +358,11 @@ CONFIG_MWL8K=m
 CONFIG_ATL1=m
 CONFIG_ATL2=m
 CONFIG_ATL1E=m
-ifdef CONFIG_COMPAT_KERNEL_27
+ifdef CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_ATL1C=n
-else #CONFIG_COMPAT_KERNEL_27
+else #CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_ATL1C=m
-endif #CONFIG_COMPAT_KERNEL_27
+endif #CONFIG_COMPAT_KERNEL_2_6_27
 
 ifdef CONFIG_WIRELESS_EXT
 CONFIG_HERMES=m
@@ -379,13 +392,13 @@ endif #CONFIG_PCI
 
 ifdef CONFIG_PCMCIA
 
-ifdef CONFIG_COMPAT_KERNEL_27
+ifdef CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS=n
 CONFIG_LIBERTAS_CS=n
-else #CONFIG_COMPAT_KERNEL_27
+else #CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS_CS=m
 NEED_LIBERTAS=y
-endif #CONFIG_COMPAT_KERNEL_27
+endif #CONFIG_COMPAT_KERNEL_2_6_27
 
 endif #CONFIG_PCMCIA
 ## end of PCMCIA
@@ -395,10 +408,10 @@ CONFIG_EEPROM_93CX6=m
 
 # USB Drivers
 ifdef CONFIG_USB
-ifndef CONFIG_COMPAT_KERNEL_29
+ifndef CONFIG_COMPAT_KERNEL_2_6_29
 CONFIG_COMPAT_ZD1211RW=m
 # CONFIG_ZD1211RW_DEBUG=y
-endif #CONFIG_COMPAT_KERNEL_29
+endif #CONFIG_COMPAT_KERNEL_2_6_29
 
 # Sorry, rndis_wlan uses cancel_work_sync which is new and can't be done in compat...
 
@@ -407,12 +420,12 @@ endif #CONFIG_COMPAT_KERNEL_29
 # is only wireless RNDIS chip known to date.
 # Note: this depends on CONFIG_USB_NET_RNDIS_HOST and CONFIG_USB_NET_CDCETHER
 # it also requires new RNDIS_HOST and CDC_ETHER modules which we add
-ifdef CONFIG_COMPAT_KERNEL_29
+ifdef CONFIG_COMPAT_KERNEL_2_6_29
 CONFIG_USB_COMPAT_USBNET=n
 CONFIG_USB_NET_COMPAT_RNDIS_HOST=n
 CONFIG_USB_NET_COMPAT_RNDIS_WLAN=n
 CONFIG_USB_NET_COMPAT_CDCETHER=n
-else #CONFIG_COMPAT_KERNEL_29
+else #CONFIG_COMPAT_KERNEL_2_6_29
 CONFIG_USB_COMPAT_USBNET=m
 ifdef CONFIG_USB_NET_CDCETHER
 CONFIG_USB_NET_COMPAT_RNDIS_HOST=m
@@ -423,7 +436,7 @@ CONFIG_USB_NET_COMPAT_RNDIS_HOST=m
 CONFIG_USB_NET_COMPAT_RNDIS_WLAN=m
 endif #CONFIG_USB_NET_CDCETHER
 CONFIG_USB_NET_COMPAT_CDCETHER=m
-endif #CONFIG_COMPAT_KERNEL_29
+endif #CONFIG_COMPAT_KERNEL_2_6_29
 
 
 CONFIG_P54_USB=m
@@ -434,14 +447,14 @@ endif #CONFIG_MAC80211_LEDS
 
 CONFIG_AT76C50X_USB=m
 
-ifndef CONFIG_COMPAT_KERNEL_29
+ifndef CONFIG_COMPAT_KERNEL_2_6_29
 CONFIG_CARL9170=m
 ifdef CONFIG_MAC80211_LEDS
 CONFIG_CARL9170_LEDS=y
 endif #CONFIG_MAC80211_LEDS
 # CONFIG_CARL9170_DEBUGFS=y
 # CONFIG_CARL9170_WPC=y
-endif #CONFIG_COMPAT_KERNEL_29
+endif #CONFIG_COMPAT_KERNEL_2_6_29
 
 # This activates a threading fix for usb urb.
 # this is mainline commit: b3e670443b7fb8a2d29831b62b44a039c283e351
@@ -467,15 +480,15 @@ ifdef CONFIG_CRC_ITU_T
 CONFIG_RT73USB=m
 endif #CONFIG_CRC_ITU_T
 
-ifdef CONFIG_COMPAT_KERNEL_27
+ifdef CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS_THINFIRM_USB=n
 CONFIG_LIBERTAS_USB=n
 NEED_LIBERTAS=n
-else #CONFIG_COMPAT_KERNEL_27
+else #CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS_THINFIRM_USB=m
 CONFIG_LIBERTAS_USB=m
 NEED_LIBERTAS=y
-endif #CONFIG_COMPAT_KERNEL_27
+endif #CONFIG_COMPAT_KERNEL_2_6_27
 
 CONFIG_ORINOCO_USB=m
 
@@ -490,7 +503,7 @@ CONFIG_RTL8192CU=m
 endif #CONFIG_USB end of USB driver list
 
 ifdef CONFIG_SPI_MASTER
-ifndef CONFIG_COMPAT_KERNEL_25
+ifndef CONFIG_COMPAT_KERNEL_2_6_25
 
 ifdef CONFIG_CRC7
 CONFIG_WL1251_SPI=m
@@ -498,15 +511,15 @@ CONFIG_WL12XX_SPI=m
 endif #CONFIG_CRC7
 CONFIG_P54_SPI=m
 
-ifdef CONFIG_COMPAT_KERNEL_27
+ifdef CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS_SPI=n
 NEED_LIBERTAS=n
-else #CONFIG_COMPAT_KERNEL_27
+else #CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS_SPI=m
 NEED_LIBERTAS=y
-endif #CONFIG_COMPAT_KERNEL_27
+endif #CONFIG_COMPAT_KERNEL_2_6_27
 
-endif #CONFIG_COMPAT_KERNEL_25
+endif #CONFIG_COMPAT_KERNEL_2_6_25
 endif #CONFIG_SPI_MASTER end of SPI driver list
 
 ifdef CONFIG_MMC
@@ -519,23 +532,23 @@ ifdef CONFIG_WL12XX_PLATFORM_DATA
 CONFIG_COMPAT_WL1251_SDIO=m
 endif #CONFIG_WL12XX_PLATFORM_DATA
 
-ifndef CONFIG_COMPAT_KERNEL_32
+ifndef CONFIG_COMPAT_KERNEL_2_6_32
 ifdef CONFIG_WL12XX_PLATFORM_DATA
 CONFIG_COMPAT_WL12XX_SDIO=m
 endif #CONFIG_WL12XX_PLATFORM_DATA
-endif #CONFIG_COMPAT_KERNEL_32
+endif #CONFIG_COMPAT_KERNEL_2_6_32
 
 endif #CONFIG_CRC7
 
 CONFIG_MWIFIEX_SDIO=m
 
-ifdef CONFIG_COMPAT_KERNEL_27
+ifdef CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS_SDIO=n
 NEED_LIBERTAS=n
-else #CONFIG_COMPAT_KERNEL_27
+else #CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS_SDIO=m
 NEED_LIBERTAS=y
-endif #CONFIG_COMPAT_KERNEL_27
+endif #CONFIG_COMPAT_KERNEL_2_6_27
 
 CONFIG_IWM=m
 # CONFIG_IWM_DEBUG=y
@@ -574,13 +587,13 @@ CONFIG_RT2800_LIB=m
 CONFIG_RT2X00_LIB_FIRMWARE=y
 CONFIG_RT2X00_LIB_CRYPTO=y
 # CONFIG_RT2X00_LIB_SOC=y
-ifdef CONFIG_COMPAT_KERNEL_25
+ifdef CONFIG_COMPAT_KERNEL_2_6_25
 CONFIG_RT2X00_LIB_LEDS=n
-else #CONFIG_COMPAT_KERNEL_25
+else #CONFIG_COMPAT_KERNEL_2_6_25
 ifdef CONFIG_LEDS_CLASS
 CONFIG_RT2X00_LIB_LEDS=y
 endif #CONFIG_LEDS_CLASS
-endif #CONFIG_COMPAT_KERNEL_25
+endif #CONFIG_COMPAT_KERNEL_2_6_25
 # CONFIG_RT2X00_DEBUG=y
 # CONFIG_RT2X00_LIB_DEBUGFS
 endif
@@ -608,24 +621,24 @@ endif #CONFIG_CRC7
 
 CONFIG_MWIFIEX=m
 
-ifdef CONFIG_COMPAT_KERNEL_27
+ifdef CONFIG_COMPAT_KERNEL_2_6_27
 CONFIG_LIBERTAS=n
-else #CONFIG_COMPAT_KERNEL_27
+else #CONFIG_COMPAT_KERNEL_2_6_27
 ifeq ($(NEED_LIBERTAS),y)
 CONFIG_LIBERTAS_THINFIRM=m
 CONFIG_LIBERTAS=m
 CONFIG_LIBERTAS_MESH=y
 # CONFIG_LIBERTAS_DEBUG=y
 endif
-endif #CONFIG_COMPAT_KERNEL_27
+endif #CONFIG_COMPAT_KERNEL_2_6_27
 
 # We need the backported rfkill module on kernel < 2.6.31.
 # In more recent kernel versions use the in kernel rfkill module.
-ifdef CONFIG_COMPAT_KERNEL_31
+ifdef CONFIG_COMPAT_KERNEL_2_6_31
 CONFIG_RFKILL_BACKPORT=m
 ifdef CONFIG_LEDS_TRIGGERS
 CONFIG_RFKILL_BACKPORT_LEDS=y
 endif #CONFIG_LEDS_TRIGGERS
 CONFIG_RFKILL_BACKPORT_INPUT=y
-endif #CONFIG_COMPAT_KERNEL_31
+endif #CONFIG_COMPAT_KERNEL_2_6_31
 
--- a/scripts/admin-update.sh
+++ b/scripts/admin-update.sh
@@ -18,7 +18,7 @@
 GIT_URL="git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git"
 GIT_COMPAT_URL="git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/compat.git"
 
-INCLUDE_NET_BT="hci_core.h l2cap.h bluetooth.h rfcomm.h hci.h mgmt.h"
+INCLUDE_NET_BT="hci_core.h l2cap.h bluetooth.h rfcomm.h hci.h mgmt.h smp.h"
 NET_BT_DIRS="bluetooth bluetooth/bnep bluetooth/cmtp bluetooth/rfcomm bluetooth/hidp"
 
 INCLUDE_LINUX="ieee80211.h nl80211.h"
@@ -259,7 +259,7 @@ DRIVERS_BT="drivers/bluetooth"
 # Drivers that belong the the wireless directory
 DRIVER_FILES="adm8211.c  adm8211.h"
 DRIVER_FILES="$DRIVER_FILES rndis_wlan.c"
-DRIVER_FILES="$DRIVER_FILES mac80211_hwsim.c"
+DRIVER_FILES="$DRIVER_FILES mac80211_hwsim.c mac80211_hwsim.h"
 DRIVER_FILES="$DRIVER_FILES at76c50x-usb.c at76c50x-usb.h"
 DRIVER_FILES="$DRIVER_FILES mwl8k.c"
 
--- a/scripts/gen-compat-autoconf.sh
+++ b/scripts/gen-compat-autoconf.sh
@@ -148,11 +148,11 @@ kernel_version_req $OLDEST_KERNEL_SUPPOR
 for i in $(egrep '^CONFIG_|^ifdef CONFIG_|^ifndef CONFIG_|^endif #CONFIG_|^else #CONFIG_' $COMPAT_CONFIG | sed 's/ /+/'); do
 	case $i in
 	'ifdef+CONFIG_'* )
-		echo "#$i" | sed -e 's/+/ /' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,\2))/' -e 's/\(#ifdef \)\(CONFIG_[^:space:]*\)/#if defined(\2) || defined(\2_MODULE)/'
+		echo "#$i" | sed -e 's/+/ /' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_3_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(3,\2,0))/' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_2_6_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,\2))/' -e 's/\(#ifdef \)\(CONFIG_[^:space:]*\)/#if defined(\2) || defined(\2_MODULE)/'
 		continue
 		;;
 	'ifndef+CONFIG_'* )
-		echo "#$i" | sed -e 's/+/ /' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,\2))/' -e 's/\(#ifndef \)\(CONFIG_[^:space:]*\)/#if !defined(\2) && !defined(\2_MODULE)/'
+		echo "#$i" | sed -e 's/+/ /' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_3_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,\2,0))/' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_2_6_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,\2))/' -e 's/\(#ifndef \)\(CONFIG_[^:space:]*\)/#if !defined(\2) && !defined(\2_MODULE)/'
 		continue
 		;;
 	'else+#CONFIG_'* | 'endif+#CONFIG_'* )
@@ -184,8 +184,9 @@ done
 # Deal with special cases. CONFIG_MAC80211_QOS is such a case.
 # We handle this specially for different kernels we support.
 if [ -f $KLIB_BUILD/Makefile ]; then
-	SUBLEVEL=$(make -C $KLIB_BUILD kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p')
-	if [ $SUBLEVEL -le 22 ]; then
+	MAJORLEVEL=$(make -C $KLIB_BUILD kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p')
+	SUBLEVEL=$(make -C $KLIB_BUILD kernelversion | sed -n 's/^\(2\.6\|[3-9]\)\.\([0-9]\+\).*/\2/p')
+	if [ $MAJORLEVEL -eq 2 -a $SUBLEVEL -le 22 ]; then
 		define_config CONFIG_MAC80211_QOS y
 	else # kernel >= 2.6.23
 		# CONFIG_MAC80211_QOS on these kernels requires