From 8d40a15da2c2b7d7cf9468a0daacdcfbb06538b0 Mon Sep 17 00:00:00 2001 From: wadesong Date: Sat, 18 Sep 2021 09:48:20 +0800 Subject: [PATCH] cfg80211: Make core regdb optional On kernel startup, the cfg80211 core hint code will try to load regulatory.db unconditionally, which can increase kernel boot time on some platforms where no regulatory.db is available. Enclose all the related code for regulatory.db manipulation with a macro CONFIG_CORE_REGDB so any platform with no regulatory.db will not be affected by this. NOTE: it is expected that any platform with no regulatory.db should have self-managed regulatory database supported by wlan module. Change-Id: I9fd96012a4c47c26be8c223fc4ee545dac8f640b Signed-off-by: wadesong --- net/wireless/Kconfig | 11 +++++++++++ net/wireless/reg.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index f620acd2a0f5..920914ca60af 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig @@ -235,3 +235,14 @@ config LIB80211_DEBUG from lib80211. If unsure, say N. + +config CORE_REGDB + bool "kernel support for regulatory database" + default y + help + Enable this if the kernel is supposed to have regulatory.db + available for core hint. + + Once this is disabled, kernel will not probe for regulatory.db + on startup, and any programs using NL80211_CMD_RELOAD_REGDB + will be unable to get regulatory.db reloaded. diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 5da1a641ef17..2267963d48f0 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -477,6 +477,7 @@ struct reg_regdb_apply_request { const struct ieee80211_regdomain *regdom; }; +#ifdef CONFIG_CORE_REGDB static LIST_HEAD(reg_regdb_apply_list); static DEFINE_MUTEX(reg_regdb_apply_mutex); @@ -522,6 +523,7 @@ static int reg_schedule_apply(const struct ieee80211_regdomain *regdom) schedule_work(®_regdb_work); return 0; } +#endif #ifdef CONFIG_CFG80211_CRDA_SUPPORT /* Max number of consecutive attempts to communicate with CRDA */ @@ -601,6 +603,7 @@ static inline int call_crda(const char *alpha2) /* code to directly load a firmware database through request_firmware */ static const struct fwdb_header *regdb; +#ifdef CONFIG_CORE_REGDB struct fwdb_country { u8 alpha2[2]; __be16 coll_ptr; @@ -958,7 +961,6 @@ int reg_query_regdb_wmm(char *alpha2, int freq, struct ieee80211_reg_rule *rule) return -ENODATA; } -EXPORT_SYMBOL(reg_query_regdb_wmm); static int regdb_query_country(const struct fwdb_header *db, const struct fwdb_country *country) @@ -1156,6 +1158,33 @@ int reg_reload_regdb(void) return err; } +#else +static int query_regdb_file(const char *alpha2) +{ + return -ENODATA; +} + +int reg_reload_regdb(void) +{ + return -ENOENT; +} + +static int __init load_builtin_regdb_keys(void) +{ + return 0; +} + +static void free_regdb_keyring(void) +{ +} + +int reg_query_regdb_wmm(char *alpha2, int freq, struct ieee80211_reg_rule *rule) +{ + return -ENODATA; +} +#endif /* CONFIG_CORE_REGDB */ +EXPORT_SYMBOL(reg_query_regdb_wmm); + static bool reg_query_database(struct regulatory_request *request) { if (query_regdb_file(request->alpha2) == 0)