2019-10-22 10:14:41

by Tony Chuang

[permalink] [raw]
Subject: [PATCH v3 2/2] rtw88: support dynamic user regulatory setting

From: Tzu-En Huang <[email protected]>

Add support for regulatory set by NL80211_REGDOM_SET_BY_USER.
This should only be enabled for distributions that need set
Realtek's card regulatory from userspace.

Signed-off-by: Tzu-En Huang <[email protected]>
Signed-off-by: Yan-Hsuan Chuang <[email protected]>
---
drivers/net/wireless/realtek/rtw88/Kconfig | 10 ++++++++++
drivers/net/wireless/realtek/rtw88/regd.c | 3 ++-
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
index 33bd7ed797ff..04b84ec1dfc1 100644
--- a/drivers/net/wireless/realtek/rtw88/Kconfig
+++ b/drivers/net/wireless/realtek/rtw88/Kconfig
@@ -52,4 +52,14 @@ config RTW88_DEBUGFS

If unsure, say Y to simplify debug problems

+config RTW88_REGD_USER_REG_HINTS
+ bool "Realtek rtw88 user regulatory hints"
+ depends on RTW88_CORE
+ default n
+ help
+ Enable regulatoy user hints
+
+ If unsure, say N. This should only be allowed on distributions
+ that need this to correct the regulatory.
+
endif
diff --git a/drivers/net/wireless/realtek/rtw88/regd.c b/drivers/net/wireless/realtek/rtw88/regd.c
index 718a147697cc..500a02b97a9c 100644
--- a/drivers/net/wireless/realtek/rtw88/regd.c
+++ b/drivers/net/wireless/realtek/rtw88/regd.c
@@ -364,7 +364,8 @@ static int rtw_regd_notifier_apply(struct rtw_dev *rtwdev,
{
if (request->initiator == NL80211_REGDOM_SET_BY_DRIVER)
return -EINVAL;
- if (request->initiator == NL80211_REGDOM_SET_BY_USER)
+ if (request->initiator == NL80211_REGDOM_SET_BY_USER &&
+ !IS_ENABLED(CONFIG_RTW88_REGD_USER_REG_HINTS))
return -EINVAL;
if (request->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE &&
!rtw_regd_is_ww(&rtwdev->regd))
--
2.17.1