From 94439c2b5d797a1e18ae9ff81a76a8e53ce2fa09 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Sun, 21 Jul 2013 11:55:30 +0000
Subject: [PATCH] kernel: add a new global config symbol for enabling rfkill
 support (can be enabled by default via target feature flag)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37491
---
 Config.in                                   | 4 ++++
 package/kernel/linux/modules/001-depends.mk | 7 +------
 package/kernel/linux/modules/other.mk       | 2 +-
 scripts/metadata.pl                         | 1 +
 target/Config.in                            | 3 +++
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Config.in b/Config.in
index 11f14d6a3b..db3094d729 100644
--- a/Config.in
+++ b/Config.in
@@ -325,6 +325,10 @@ menu "Global build settings"
 	config KERNEL_KEXEC
 		bool "Enable kexec support"
 
+	config USE_RFKILL
+		bool "Enable rfkill support"
+		default RFKILL_SUPPORT
+
 	#
 	# CGROUP support symbols
 	#
diff --git a/package/kernel/linux/modules/001-depends.mk b/package/kernel/linux/modules/001-depends.mk
index ed894311cc..d0ad083662 100644
--- a/package/kernel/linux/modules/001-depends.mk
+++ b/package/kernel/linux/modules/001-depends.mk
@@ -22,13 +22,8 @@ define AddDepends/nls
   DEPENDS+= +kmod-nls-base $(foreach cp,$(1),+kmod-nls-$(cp))
 endef
 
-
-define SetDepends/rfkill
-  DEPENDS:= @(TARGET_ar71xx||TARGET_brcm47xx||TARGET_s3c24xx||TARGET_x86||TARGET_gemini||TARGET_cns3xxx||TARGET_ixp4xx) $(1)
-endef
-
 define AddDepends/rfkill
-  DEPENDS+= +(TARGET_ar71xx||TARGET_brcm47xx||TARGET_s3c24xx||TARGET_x86||TARGET_cns3xxx||TARGET_ixp4xx):kmod-rfkill $(1)
+  DEPENDS+= +USE_RFKILL:kmod-rfkill $(1)
 endef
 
 
diff --git a/package/kernel/linux/modules/other.mk b/package/kernel/linux/modules/other.mk
index 44bc870b88..b9ffaa0e42 100644
--- a/package/kernel/linux/modules/other.mk
+++ b/package/kernel/linux/modules/other.mk
@@ -239,6 +239,7 @@ $(eval $(call KernelPackage,oprofile))
 define KernelPackage/rfkill
   SUBMENU:=$(OTHER_MENU)
   TITLE:=RF switch subsystem support
+  DEPENDS:=@USE_RFKILL +kmod-input-core
   KCONFIG:= \
     CONFIG_RFKILL \
     CONFIG_RFKILL_INPUT=y \
@@ -247,7 +248,6 @@ define KernelPackage/rfkill
   FILES:= \
     $(LINUX_DIR)/net/rfkill/rfkill.ko
   AUTOLOAD:=$(call AutoLoad,20,rfkill)
-  $(call SetDepends/rfkill,+kmod-input-core)
 endef
 
 define KernelPackage/rfkill/description
diff --git a/scripts/metadata.pl b/scripts/metadata.pl
index bcc3700d42..5625b8b5be 100755
--- a/scripts/metadata.pl
+++ b/scripts/metadata.pl
@@ -177,6 +177,7 @@ sub target_config_features(@) {
 		/powerpc64/ and $ret .= "\tselect powerpc64\n";
 		/nommu/ and $ret .= "\tselect NOMMU\n";
 		/mips16/ and $ret .= "\tselect HAS_MIPS16\n";
+		/rfkill/ and $ret .= "\tselect RFKILL_SUPPORT\n";
 	}
 	return $ret;
 }
diff --git a/target/Config.in b/target/Config.in
index a7951aaf3b..7f694e4c8b 100644
--- a/target/Config.in
+++ b/target/Config.in
@@ -73,6 +73,9 @@ config HAS_MIPS16
 	depends on (mips || mipsel || mips64 || mips64el)
 	bool
 
+config RFKILL_SUPPORT
+	bool
+
 config ARCH_64BIT
 	bool
 
-- 
2.30.2