[PATCH v2 wireless 1/3] wifi: carl9170: replace open-coded IE search with cfg80211_find_ie()
From: Tristan Madani
Date: Mon Oct 26 2026 - 18:32:48 EST
carl9170_find_ie() open-codes the IE search that cfg80211_find_ie()
already provides. Replace the hand-rolled function with
cfg80211_find_ie() at the single call site.
Fixes: a84fab3cbfdc4 ("carl9170: 802.11 rx/tx processing and usb backend")
Signed-off-by: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
---
drivers/net/wireless/ath/carl9170/rx.c | 27 ++++++--------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/drivers/net/wireless/ath/carl9170/rx.c b/drivers/net/wireless/ath/carl9170/rx.c
index fbe46a5e4e415..9db6ac9d6d3c0 100644
--- a/drivers/net/wireless/ath/carl9170/rx.c
+++ b/drivers/net/wireless/ath/carl9170/rx.c
@@ -490,25 +490,6 @@ static struct sk_buff *carl9170_rx_copy_data(u8 *buf, int len)
return skb;
}
-static u8 *carl9170_find_ie(u8 *data, unsigned int len, u8 ie)
-{
- struct ieee80211_mgmt *mgmt = (void *)data;
- u8 *pos, *end;
-
- pos = (u8 *)mgmt->u.beacon.variable;
- end = data + len;
- while (pos < end) {
- if (pos + 2 + pos[1] > end)
- return NULL;
-
- if (pos[0] == ie)
- return pos;
-
- pos += 2 + pos[1];
- }
- return NULL;
-}
-
/*
* NOTE:
*
@@ -521,9 +502,10 @@ static u8 *carl9170_find_ie(u8 *data, unsigned int len, u8 ie)
static void carl9170_ps_beacon(struct ar9170 *ar, void *data, unsigned int len)
{
struct ieee80211_hdr *hdr = data;
+ struct ieee80211_mgmt *mgmt = data;
struct ieee80211_tim_ie *tim_ie;
struct ath_common *common = &ar->common;
- u8 *tim;
+ const u8 *tim;
u8 tim_len;
bool cam;
@@ -541,7 +523,10 @@ static void carl9170_ps_beacon(struct ar9170 *ar, void *data, unsigned int len)
ar->ps.last_beacon = jiffies;
- tim = carl9170_find_ie(data, len - FCS_LEN, WLAN_EID_TIM);
+ tim = cfg80211_find_ie(WLAN_EID_TIM, mgmt->u.beacon.variable,
+ (len - FCS_LEN) -
+ offsetof(struct ieee80211_mgmt,
+ u.beacon.variable));
if (!tim)
return;
--
2.47.3