diff mbox series

cfg80211: expose the rfkill device to the low level driver

Message ID 20210609161520.109824-1-emmanuel.grumbach@intel.com (mailing list archive)
State Superseded
Delegated to: Johannes Berg
Headers show
Series cfg80211: expose the rfkill device to the low level driver | expand

Commit Message

Emmanuel Grumbach June 9, 2021, 4:15 p.m. UTC
This will allow the low level driver to query the rfkill
state.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 include/net/cfg80211.h     |  8 +++++++-
 net/wireless/core.c        | 34 +++++++++++++---------------------
 net/wireless/core.h        |  3 +--
 net/wireless/nl80211.c     |  4 ++--
 net/wireless/wext-compat.c |  6 +++---
 5 files changed, 26 insertions(+), 29 deletions(-)

Comments

kernel test robot June 16, 2021, 5:11 p.m. UTC | #1
Hi Emmanuel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mac80211-next/master]
[also build test WARNING on mac80211/master v5.13-rc6 next-20210616]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Emmanuel-Grumbach/cfg80211-expose-the-rfkill-device-to-the-low-level-driver/20210616-211511
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: arm-imx_v6_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/8b25a459eed15aebc25c2ce0a5bf20fea8eab638
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Emmanuel-Grumbach/cfg80211-expose-the-rfkill-device-to-the-low-level-driver/20210616-211511
        git checkout 8b25a459eed15aebc25c2ce0a5bf20fea8eab638
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from net/wireless/core.c:26:
   include/net/cfg80211.h: In function 'wiphy_rfkill_stop_polling':
   include/net/cfg80211.h:6669:2: error: implicit declaration of function 'rfkill_pause_polling' [-Werror=implicit-function-declaration]
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   In file included from net/wireless/core.h:14,
                    from net/wireless/nl80211.h:9,
                    from net/wireless/core.c:27:
   include/linux/rfkill.h: At top level:
>> include/linux/rfkill.h:110:6: warning: conflicting types for 'rfkill_pause_polling'
     110 | void rfkill_pause_polling(struct rfkill *rfkill);
         |      ^~~~~~~~~~~~~~~~~~~~
   In file included from net/wireless/core.c:26:
   include/net/cfg80211.h:6669:2: note: previous implicit declaration of 'rfkill_pause_polling' was here
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/rfkill_pause_polling +110 include/linux/rfkill.h

135900c182c321 Michael Buesch 2007-09-27  101  
19d337dff95cbf Johannes Berg  2009-06-02  102  /**
19d337dff95cbf Johannes Berg  2009-06-02  103   * rfkill_pause_polling(struct rfkill *rfkill)
19d337dff95cbf Johannes Berg  2009-06-02  104   *
19d337dff95cbf Johannes Berg  2009-06-02  105   * Pause polling -- say transmitter is off for other reasons.
19d337dff95cbf Johannes Berg  2009-06-02  106   * NOTE: not necessary for suspend/resume -- in that case the
dd21dfc645d5dc Johannes Berg  2016-01-20  107   * core stops polling anyway (but will also correctly handle
dd21dfc645d5dc Johannes Berg  2016-01-20  108   * the case of polling having been paused before suspend.)
19d337dff95cbf Johannes Berg  2009-06-02  109   */
19d337dff95cbf Johannes Berg  2009-06-02 @110  void rfkill_pause_polling(struct rfkill *rfkill);
cf4328cd949c20 Ivo van Doorn  2007-05-07  111  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot June 16, 2021, 7:47 p.m. UTC | #2
Hi Emmanuel,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mac80211-next/master]
[also build test ERROR on mac80211/master v5.13-rc6 next-20210616]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Emmanuel-Grumbach/cfg80211-expose-the-rfkill-device-to-the-low-level-driver/20210616-211511
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: ia64-randconfig-r015-20210615 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/8b25a459eed15aebc25c2ce0a5bf20fea8eab638
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Emmanuel-Grumbach/cfg80211-expose-the-rfkill-device-to-the-low-level-driver/20210616-211511
        git checkout 8b25a459eed15aebc25c2ce0a5bf20fea8eab638
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from drivers/net/wireless/intel/ipw2x00/libipw.h:30,
                    from drivers/net/wireless/intel/ipw2x00/ipw2100.h:35,
                    from drivers/net/wireless/intel/ipw2x00/ipw2100.c:154:
   include/net/cfg80211.h: In function 'wiphy_rfkill_stop_polling':
>> include/net/cfg80211.h:6669:2: error: implicit declaration of function 'rfkill_pause_polling' [-Werror=implicit-function-declaration]
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/intel/ipw2x00/ipw2100.c: In function 'isr_indicate_associated':
   drivers/net/wireless/intel/ipw2x00/ipw2100.c:1992:8: warning: variable 'txratename' set but not used [-Wunused-but-set-variable]
    1992 |  char *txratename;
         |        ^~~~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from drivers/net/wireless/intel/ipw2x00/libipw.h:30,
                    from drivers/net/wireless/intel/ipw2x00/ipw2200.h:42,
                    from drivers/net/wireless/intel/ipw2x00/ipw2200.c:22:
   include/net/cfg80211.h: In function 'wiphy_rfkill_stop_polling':
>> include/net/cfg80211.h:6669:2: error: implicit declaration of function 'rfkill_pause_polling' [-Werror=implicit-function-declaration]
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   drivers/net/wireless/intel/ipw2x00/ipw2200.c: In function 'ipw_fw_dma_dump_command_block':
   drivers/net/wireless/intel/ipw2x00/ipw2200.c:2822:6: warning: variable 'register_value' set but not used [-Wunused-but-set-variable]
    2822 |  u32 register_value = 0;
         |      ^~~~~~~~~~~~~~
   drivers/net/wireless/intel/ipw2x00/ipw2200.c: In function 'ipw_is_qos_active':
   drivers/net/wireless/intel/ipw2x00/ipw2200.c:7154:14: warning: variable 'supported' set but not used [-Wunused-but-set-variable]
    7154 |  int active, supported;
         |              ^~~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from drivers/net/wireless/intel/ipw2x00/libipw.h:30,
                    from drivers/net/wireless/intel/ipw2x00/libipw_module.c:39:
   include/net/cfg80211.h: In function 'wiphy_rfkill_stop_polling':
>> include/net/cfg80211.h:6669:2: error: implicit declaration of function 'rfkill_pause_polling' [-Werror=implicit-function-declaration]
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   At top level:
   drivers/net/wireless/intel/ipw2x00/libipw_module.c:243:30: warning: 'debug_level_proc_ops' defined but not used [-Wunused-const-variable=]
     243 | static const struct proc_ops debug_level_proc_ops = {
         |                              ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from drivers/net/wireless/intel/ipw2x00/libipw.h:30,
                    from drivers/net/wireless/intel/ipw2x00/libipw_tx.c:30:
   include/net/cfg80211.h: In function 'wiphy_rfkill_stop_polling':
>> include/net/cfg80211.h:6669:2: error: implicit declaration of function 'rfkill_pause_polling' [-Werror=implicit-function-declaration]
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from net/wireless/core.c:26:
   include/net/cfg80211.h: In function 'wiphy_rfkill_stop_polling':
>> include/net/cfg80211.h:6669:2: error: implicit declaration of function 'rfkill_pause_polling' [-Werror=implicit-function-declaration]
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   In file included from net/wireless/core.h:14,
                    from net/wireless/nl80211.h:9,
                    from net/wireless/core.c:27:
   include/linux/rfkill.h: At top level:
>> include/linux/rfkill.h:110:6: warning: conflicting types for 'rfkill_pause_polling'
     110 | void rfkill_pause_polling(struct rfkill *rfkill);
         |      ^~~~~~~~~~~~~~~~~~~~
   In file included from net/wireless/core.c:26:
   include/net/cfg80211.h:6669:2: note: previous implicit declaration of 'rfkill_pause_polling' was here
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   In file included from net/wireless/trace.h:12,
                    from net/wireless/trace.c:5:
   include/net/cfg80211.h: In function 'wiphy_rfkill_stop_polling':
>> include/net/cfg80211.h:6669:2: error: implicit declaration of function 'rfkill_pause_polling' [-Werror=implicit-function-declaration]
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   In file included from net/wireless/core.h:14,
                    from net/wireless/trace.h:13,
                    from net/wireless/trace.c:5:
   include/linux/rfkill.h: At top level:
>> include/linux/rfkill.h:110:6: warning: conflicting types for 'rfkill_pause_polling'
     110 | void rfkill_pause_polling(struct rfkill *rfkill);
         |      ^~~~~~~~~~~~~~~~~~~~
   In file included from net/wireless/trace.h:12,
                    from net/wireless/trace.c:5:
   include/net/cfg80211.h:6669:2: note: previous implicit declaration of 'rfkill_pause_polling' was here
    6669 |  rfkill_pause_polling(wiphy->rfkill);
         |  ^~~~~~~~~~~~~~~~~~~~
   In file included from net/wireless/trace.h:3574,
                    from net/wireless/trace.c:5:
   include/trace/define_trace.h:95:42: fatal error: ./trace.h: No such file or directory
      95 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
         |                                          ^
   cc1: some warnings being treated as errors
   compilation terminated.


vim +/rfkill_pause_polling +6669 include/net/cfg80211.h

  6662	
  6663	/**
  6664	 * wiphy_rfkill_stop_polling - stop polling rfkill
  6665	 * @wiphy: the wiphy
  6666	 */
  6667	static inline void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
  6668	{
> 6669		rfkill_pause_polling(wiphy->rfkill);
  6670	}
  6671	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 5224f885a99a..57c8cbbd7598 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4945,6 +4945,7 @@  struct wiphy_iftype_akm_suites {
  *	configuration through the %NL80211_TID_CONFIG_ATTR_RETRY_SHORT and
  *	%NL80211_TID_CONFIG_ATTR_RETRY_LONG attributes
  * @sar_capa: SAR control capabilities
+ * @rfkill: a pointer to the rfkill structure
  */
 struct wiphy {
 	struct mutex mtx;
@@ -5087,6 +5088,8 @@  struct wiphy {
 
 	const struct cfg80211_sar_capa *sar_capa;
 
+	struct rfkill *rfkill;
+
 	char priv[] __aligned(NETDEV_ALIGN);
 };
 
@@ -6661,7 +6664,10 @@  void wiphy_rfkill_start_polling(struct wiphy *wiphy);
  * wiphy_rfkill_stop_polling - stop polling rfkill
  * @wiphy: the wiphy
  */
-void wiphy_rfkill_stop_polling(struct wiphy *wiphy);
+static inline void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
+{
+	rfkill_pause_polling(wiphy->rfkill);
+}
 
 /**
  * DOC: Vendor commands
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 6fbf7537faf5..bd1edec19cfa 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -532,11 +532,11 @@  struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
 	wiphy_net_set(&rdev->wiphy, &init_net);
 
 	rdev->rfkill_ops.set_block = cfg80211_rfkill_set_block;
-	rdev->rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev),
-				   &rdev->wiphy.dev, RFKILL_TYPE_WLAN,
-				   &rdev->rfkill_ops, rdev);
+	rdev->wiphy.rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev),
+					  &rdev->wiphy.dev, RFKILL_TYPE_WLAN,
+					  &rdev->rfkill_ops, rdev);
 
-	if (!rdev->rfkill) {
+	if (!rdev->wiphy.rfkill) {
 		wiphy_free(&rdev->wiphy);
 		return NULL;
 	}
@@ -993,10 +993,10 @@  int wiphy_register(struct wiphy *wiphy)
 	rdev->wiphy.registered = true;
 	rtnl_unlock();
 
-	res = rfkill_register(rdev->rfkill);
+	res = rfkill_register(rdev->wiphy.rfkill);
 	if (res) {
-		rfkill_destroy(rdev->rfkill);
-		rdev->rfkill = NULL;
+		rfkill_destroy(rdev->wiphy.rfkill);
+		rdev->wiphy.rfkill = NULL;
 		wiphy_unregister(&rdev->wiphy);
 		return res;
 	}
@@ -1012,18 +1012,10 @@  void wiphy_rfkill_start_polling(struct wiphy *wiphy)
 	if (!rdev->ops->rfkill_poll)
 		return;
 	rdev->rfkill_ops.poll = cfg80211_rfkill_poll;
-	rfkill_resume_polling(rdev->rfkill);
+	rfkill_resume_polling(wiphy->rfkill);
 }
 EXPORT_SYMBOL(wiphy_rfkill_start_polling);
 
-void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
-{
-	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
-
-	rfkill_pause_polling(rdev->rfkill);
-}
-EXPORT_SYMBOL(wiphy_rfkill_stop_polling);
-
 void wiphy_unregister(struct wiphy *wiphy)
 {
 	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
@@ -1035,8 +1027,8 @@  void wiphy_unregister(struct wiphy *wiphy)
 		wiphy_unlock(&rdev->wiphy);
 		__count == 0; }));
 
-	if (rdev->rfkill)
-		rfkill_unregister(rdev->rfkill);
+	if (rdev->wiphy.rfkill)
+		rfkill_unregister(rdev->wiphy.rfkill);
 
 	rtnl_lock();
 	wiphy_lock(&rdev->wiphy);
@@ -1088,7 +1080,7 @@  void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
 {
 	struct cfg80211_internal_bss *scan, *tmp;
 	struct cfg80211_beacon_registration *reg, *treg;
-	rfkill_destroy(rdev->rfkill);
+	rfkill_destroy(rdev->wiphy.rfkill);
 	list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) {
 		list_del(&reg->list);
 		kfree(reg);
@@ -1110,7 +1102,7 @@  void wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
 {
 	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
 
-	if (rfkill_set_hw_state_reason(rdev->rfkill, blocked, reason))
+	if (rfkill_set_hw_state_reason(wiphy->rfkill, blocked, reason))
 		schedule_work(&rdev->rfkill_block);
 }
 EXPORT_SYMBOL(wiphy_rfkill_set_hw_state_reason);
@@ -1506,7 +1498,7 @@  static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
 					     wdev->use_4addr, 0))
 			return notifier_from_errno(-EOPNOTSUPP);
 
-		if (rfkill_blocked(rdev->rfkill))
+		if (rfkill_blocked(rdev->wiphy.rfkill))
 			return notifier_from_errno(-ERFKILL);
 		break;
 	default:
diff --git a/net/wireless/core.h b/net/wireless/core.h
index a7d19b4b40ac..b35d0db12f1d 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -3,7 +3,7 @@ 
  * Wireless configuration interface internals.
  *
  * Copyright 2006-2010	Johannes Berg <johannes@sipsolutions.net>
- * Copyright (C) 2018-2020 Intel Corporation
+ * Copyright (C) 2018-2021 Intel Corporation
  */
 #ifndef __NET_WIRELESS_CORE_H
 #define __NET_WIRELESS_CORE_H
@@ -27,7 +27,6 @@  struct cfg80211_registered_device {
 
 	/* rfkill support */
 	struct rfkill_ops rfkill_ops;
-	struct rfkill *rfkill;
 	struct work_struct rfkill_block;
 
 	/* ISO / IEC 3166 alpha2 for which this device is receiving
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index fc9286afe3c9..e006d26d5c2a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -13042,7 +13042,7 @@  static int nl80211_start_p2p_device(struct sk_buff *skb, struct genl_info *info)
 	if (wdev_running(wdev))
 		return 0;
 
-	if (rfkill_blocked(rdev->rfkill))
+	if (rfkill_blocked(rdev->wiphy.rfkill))
 		return -ERFKILL;
 
 	err = rdev_start_p2p_device(rdev, wdev);
@@ -13084,7 +13084,7 @@  static int nl80211_start_nan(struct sk_buff *skb, struct genl_info *info)
 	if (wdev_running(wdev))
 		return -EEXIST;
 
-	if (rfkill_blocked(rdev->rfkill))
+	if (rfkill_blocked(rdev->wiphy.rfkill))
 		return -ERFKILL;
 
 	if (!info->attrs[NL80211_ATTR_NAN_MASTER_PREF])
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index a8320dc59af7..35c6c705a073 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -902,7 +902,7 @@  static int cfg80211_wext_siwtxpower(struct net_device *dev,
 
 	/* only change when not disabling */
 	if (!data->txpower.disabled) {
-		rfkill_set_sw_state(rdev->rfkill, false);
+		rfkill_set_sw_state(rdev->wiphy.rfkill, false);
 
 		if (data->txpower.fixed) {
 			/*
@@ -927,7 +927,7 @@  static int cfg80211_wext_siwtxpower(struct net_device *dev,
 			}
 		}
 	} else {
-		if (rfkill_set_sw_state(rdev->rfkill, true))
+		if (rfkill_set_sw_state(rdev->wiphy.rfkill, true))
 			schedule_work(&rdev->rfkill_block);
 		return 0;
 	}
@@ -963,7 +963,7 @@  static int cfg80211_wext_giwtxpower(struct net_device *dev,
 
 	/* well... oh well */
 	data->txpower.fixed = 1;
-	data->txpower.disabled = rfkill_blocked(rdev->rfkill);
+	data->txpower.disabled = rfkill_blocked(rdev->wiphy.rfkill);
 	data->txpower.value = val;
 	data->txpower.flags = IW_TXPOW_DBM;