@@ -12824,6 +12824,10 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
1282412824 int i, n, low_index;
1282512825 int err;
1282612826
12827+ /* RSSI reporting disabled? */
12828+ if (!cqm_config)
12829+ return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
12830+
1282712831 /*
1282812832 * Obtain current RSSI value if possible, if not and no RSSI threshold
1282912833 * event has been received yet, we should receive an event after a
@@ -12898,27 +12902,25 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
1289812902 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
1289912903 return -EOPNOTSUPP;
1290012904
12905+ if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) {
12906+ if (n_thresholds == 0 || thresholds[0] == 0) /* Disabling */
12907+ return rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
12908+
12909+ return rdev_set_cqm_rssi_config(rdev, dev,
12910+ thresholds[0], hysteresis);
12911+ }
12912+
12913+ if (!wiphy_ext_feature_isset(&rdev->wiphy,
12914+ NL80211_EXT_FEATURE_CQM_RSSI_LIST))
12915+ return -EOPNOTSUPP;
12916+
1290112917 if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */
1290212918 n_thresholds = 0;
1290312919
1290412920 wdev_lock(wdev);
1290512921 old = rcu_dereference_protected(wdev->cqm_config,
1290612922 lockdep_is_held(&wdev->mtx));
1290712923
12908- /* if already disabled just succeed */
12909- if (!n_thresholds && !old)
12910- return 0;
12911-
12912- if (n_thresholds > 1) {
12913- if (!wiphy_ext_feature_isset(&rdev->wiphy,
12914- NL80211_EXT_FEATURE_CQM_RSSI_LIST) ||
12915- !rdev->ops->set_cqm_rssi_range_config)
12916- return -EOPNOTSUPP;
12917- } else {
12918- if (!rdev->ops->set_cqm_rssi_config)
12919- return -EOPNOTSUPP;
12920- }
12921-
1292212924 if (n_thresholds) {
1292312925 cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
1292412926 n_thresholds),
@@ -12933,26 +12935,13 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
1293312935 memcpy(cqm_config->rssi_thresholds, thresholds,
1293412936 flex_array_size(cqm_config, rssi_thresholds,
1293512937 n_thresholds));
12936- cqm_config->use_range_api = n_thresholds > 1 ||
12937- !rdev->ops->set_cqm_rssi_config;
1293812938
1293912939 rcu_assign_pointer(wdev->cqm_config, cqm_config);
12940-
12941- if (cqm_config->use_range_api)
12942- err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
12943- else
12944- err = rdev_set_cqm_rssi_config(rdev, dev,
12945- thresholds[0],
12946- hysteresis);
1294712940 } else {
1294812941 RCU_INIT_POINTER(wdev->cqm_config, NULL);
12949- /* if enabled as range also disable via range */
12950- if (old->use_range_api)
12951- err = rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
12952- else
12953- err = rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
1295412942 }
1295512943
12944+ err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
1295612945 if (err) {
1295712946 rcu_assign_pointer(wdev->cqm_config, old);
1295812947 kfree_rcu(cqm_config, rcu_head);
@@ -19142,11 +19131,10 @@ void cfg80211_cqm_rssi_notify_work(struct wiphy *wiphy, struct wiphy_work *work)
1914219131 wdev_lock(wdev);
1914319132 cqm_config = rcu_dereference_protected(wdev->cqm_config,
1914419133 lockdep_is_held(&wdev->mtx));
19145- if (!cqm_config)
19134+ if (!wdev-> cqm_config)
1914619135 goto unlock;
1914719136
19148- if (cqm_config->use_range_api)
19149- cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
19137+ cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
1915019138
1915119139 rssi_level = cqm_config->last_rssi_event_value;
1915219140 rssi_event = cqm_config->last_rssi_event_type;
0 commit comments