[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250812-fix_scan_ap_flag_requirement_during_mlo-v4-2-383ffb6da213@oss.qualcomm.com>
Date: Tue, 12 Aug 2025 12:53:29 +0530
From: Aditya Kumar Singh <aditya.kumar.singh@....qualcomm.com>
To: Johannes Berg <johannes@...solutions.net>,
Aditya Kumar Singh <aditya.kumar.singh@....qualcomm.com>
Cc: Johannes Berg <johannes.berg@...el.com>, linux-wireless@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH wireless-next v4 2/3] wifi: mac80211: simplify return value
handling of cfg80211_get_radio_idx_by_chan()
In several instances where cfg80211_get_radio_idx_by_chan() is called,
redundant checks are performed across function — such as verifying if
wiphy->n_radio < 2 or if the returned index is negative. These checks are
unnecessary, as the return value can be directly compared. Moreover, the
function can be safely called even when radio-level properties are not
explicitly advertised since in such case in each call it is going to get
same error value.
Therefore, simplify the usage of this function across all such cases by
removing redundant conditions and relying on the return value directly.
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@....qualcomm.com>
---
net/mac80211/cfg.c | 13 -------------
net/mac80211/chan.c | 11 -----------
net/mac80211/util.c | 15 ++++++---------
3 files changed, 6 insertions(+), 33 deletions(-)
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 2ed07fa121ab73d3afd2f841eb53e6cdc0be91a3..d4100d046442a51a0baf42d6ab3b921302d307f7 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3677,12 +3677,7 @@ static bool ieee80211_is_scan_ongoing(struct wiphy *wiphy,
if (list_empty(&local->roc_list) && !local->scanning)
return false;
- if (wiphy->n_radio < 2)
- return true;
-
req_radio_idx = cfg80211_get_radio_idx_by_chan(wiphy, chandef->chan);
- if (req_radio_idx < 0)
- return true;
if (local->scanning) {
scan_req = wiphy_dereference(wiphy, local->scan_req);
@@ -3701,14 +3696,6 @@ static bool ieee80211_is_scan_ongoing(struct wiphy *wiphy,
list_for_each_entry(roc, &local->roc_list, list) {
chan_radio_idx = cfg80211_get_radio_idx_by_chan(wiphy,
roc->chan);
- /*
- * The roc work is added but chan_radio_idx is invalid.
- * Should not happen but if it does, let's not take
- * risk and return true.
- */
- if (chan_radio_idx < 0)
- return true;
-
if (chan_radio_idx == req_radio_idx)
return true;
}
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index c9cea0e7ac169839f883f73186b575eacfe55db5..57065714cf8ceb5e612705ddc913b90c1f296e2a 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -659,19 +659,8 @@ bool ieee80211_is_radar_required(struct ieee80211_local *local,
for_each_sdata_link(local, link) {
if (link->radar_required) {
- if (wiphy->n_radio < 2)
- return true;
-
chan = link->conf->chanreq.oper.chan;
radio_idx = cfg80211_get_radio_idx_by_chan(wiphy, chan);
- /*
- * The radio index (radio_idx) is expected to be valid,
- * as it's derived from a channel tied to a link. If
- * it's invalid (i.e., negative), return true to avoid
- * potential issues with radar-sensitive operations.
- */
- if (radio_idx < 0)
- return true;
if (ieee80211_is_radio_idx_in_scan_req(wiphy, req,
radio_idx))
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 32f1bc5908c571416df905bdda1ba54dd7b41f33..51e3e3c913f7f9faa4a0283c0aa9509efc805391 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -4022,16 +4022,13 @@ bool ieee80211_is_radio_idx_in_scan_req(struct wiphy *wiphy,
for (i = 0; i < scan_req->n_channels; i++) {
chan = scan_req->channels[i];
chan_radio_idx = cfg80211_get_radio_idx_by_chan(wiphy, chan);
- /*
- * The chan_radio_idx should be valid since it's taken from a
- * valid scan request.
- * However, if chan_radio_idx is unexpectedly invalid (negative),
- * we take a conservative approach and assume the scan request
- * might use the specified radio_idx. Hence, return true.
- */
- if (WARN_ON(chan_radio_idx < 0))
- return true;
+ /* The radio index either matched successfully, or an error
+ * occurred. For example, if radio-level information is
+ * missing, the same error value is returned. This
+ * typically implies a single-radio setup, in which case
+ * the operation should not be allowed.
+ */
if (chan_radio_idx == radio_idx)
return true;
}
--
2.34.1
Powered by blists - more mailing lists