cfg80211: allow specifying a reason for hw_rfkill
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Mon, 22 Mar 2021 20:46:31 +0000 (22:46 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 8 Apr 2021 11:05:56 +0000 (13:05 +0200)
rfkill now allows to report a reason for the hw_rfkill state.
Allow cfg80211 drivers to specify this reason.
Keep the current API to use the default reason
(RFKILL_HARD_BLOCK_SIGNAL).

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Link: https://lore.kernel.org/r/20210322204633.102581-4-emmanuel.grumbach@intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
net/wireless/core.c

index 911fae42b0c0efc4980edd3c674d1e779b4323c7..3b296f2b7a2c81f292a2ec46bb9f48ef21f860d5 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/ethtool.h>
+#include <uapi/linux/rfkill.h>
 #include <linux/netdevice.h>
 #include <linux/debugfs.h>
 #include <linux/list.h>
@@ -6636,8 +6637,16 @@ void cfg80211_notify_new_peer_candidate(struct net_device *dev,
  * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state
  * @wiphy: the wiphy
  * @blocked: block status
+ * @reason: one of reasons in &enum rfkill_hard_block_reasons
  */
-void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked);
+void wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
+                                     enum rfkill_hard_block_reasons reason);
+
+static inline void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
+{
+       wiphy_rfkill_set_hw_state_reason(wiphy, blocked,
+                                        RFKILL_HARD_BLOCK_SIGNAL);
+}
 
 /**
  * wiphy_rfkill_start_polling - start polling rfkill
index a2785379df6e58d43d6b642412c5de113e510d24..adfbcb33fb8fd3df686049294a02b6572afc886b 100644 (file)
@@ -1092,14 +1092,15 @@ void wiphy_free(struct wiphy *wiphy)
 }
 EXPORT_SYMBOL(wiphy_free);
 
-void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
+void wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
+                                     enum rfkill_hard_block_reasons reason)
 {
        struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
 
-       if (rfkill_set_hw_state(rdev->rfkill, blocked))
+       if (rfkill_set_hw_state_reason(rdev->rfkill, blocked, reason))
                schedule_work(&rdev->rfkill_block);
 }
-EXPORT_SYMBOL(wiphy_rfkill_set_hw_state);
+EXPORT_SYMBOL(wiphy_rfkill_set_hw_state_reason);
 
 void cfg80211_cqm_config_free(struct wireless_dev *wdev)
 {