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 <wadesong@codeaurora.org>
This commit is contained in:
wadesong 2021-09-18 09:48:20 +08:00 committed by j7b3y
parent cd12e6ec55
commit 8d40a15da2
2 changed files with 41 additions and 1 deletions

View File

@ -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.

View File

@ -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(&reg_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)