From nobody Sat Feb 7 18:21:12 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E44E23F26A for ; Thu, 29 Jan 2026 08:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769674020; cv=none; b=Y7+/mjJauG0fzTvBoc9sCliCZMr18wk8BZop+2TBxdAe6PJ12yqm0PgbHkcNuU5TKmpmLeC1EpYiS7YB+ElIiLLQQxLSgtZrHDwAmmEcjRquU9iWFXnx9Ldb9PWpTjpri4DVdmcJN7yapf3FKeT1zDdTzoh7nyc/forS94h0kf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769674020; c=relaxed/simple; bh=4naTu1i37tuBzAwWmiqQ+8T7e2n7EUQU0Pl5QJ1hgVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tjmCTpVy4Kpr62CaX7t4RfmkeUK6s718wHN+/RdhX2M3SSdQtgPvYwB/lrNGikMUTaoMhGtvhM3PY4tWOhz7VODaEKbg1SeRWTW4e29lmgjHKaMQjZRToUQS0uHANKbemBHOw1F1NVQHq9OERPTEmPJyqzMSHGR2rVkCrR+xb3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nbocyOEP; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nbocyOEP" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2a77c1d5c3bso2993445ad.0 for ; Thu, 29 Jan 2026 00:06:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769674019; x=1770278819; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YFwht3Bh53ospZEdeEaFl61TP1c0Tumxe4gtDU8Xkzs=; b=nbocyOEPxxttdV0wx7BuTpPqPgEmdmD7nvzybAiAAhqpE3r8BsirNIsBVKE8Bc0LeV IuSKnw7CCq0Vtj7Blc8qRplbdV/jq8Sn+FigGtNBt6ikNokzzurqoQzJj0Yp0KvJ78/w hwcPk7qk2GBjTmsBD8e0wkfvXlxeOxF7AGgESVotTqiXDGhXAeE0x0/IsoiP4c8r2u1l ljUlwSXPYltS6BhwYvr6jptnLllEuAAuyj7Jv+StpC2q4Ur+15eptliLTEjrgnpbg/pk ITw0Iq0+dFykIvGcDckGJEFEUVAU2Ut4OinJQ6h46Wd4+PXpIroC8RtZSN4JA0+loXGG nOZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769674019; x=1770278819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YFwht3Bh53ospZEdeEaFl61TP1c0Tumxe4gtDU8Xkzs=; b=RsKs0Fde9BcGdFxu07HQe2Bfb0oWdKudWPIgZLo+hdR9/PArE1KIvMr5AAtyjiaH/E Ebx06sTFu5sPMYbH0LMWM5SMWSNvqwcFPf6IwFO6PpHisYXvk/0UdnS+Iq90jkp26rrm pZobLLa5uMdGQsdJdIFuxRcaMydm0csFCf440kZ9SwgNAnJ4BAYh5iVKbhTwXod6kAvK h5bJHED7y/rPZNtWSqD0I6j3RzQPjdPE5Wks2h4qMNmyU2pjvJhE5HsHGrEyLRRjjamP 2nPrWCSyuVaIkJ5pD7MzkQiF+32wVFUmjmGFw0ymlD4OdS50YZmJeMVXetCXcZ6BZ+FX /7Xw== X-Forwarded-Encrypted: i=1; AJvYcCUZtU+cOsS82mNv2cAlDz2x/UmSh9Zd8lSm1ih6rNOkw3txlQR0Xk2DOiwvxieVWkBSr0WzW4mz32di/8s=@vger.kernel.org X-Gm-Message-State: AOJu0YxLPiO4zDCrDTwJbpO0ynWZWeuzVCnTRHweH839FvH+fEAFcATS wRi2xynKCmJ3t05m63pHqeVZh7Ashid2AKHaGt7muGvCBbW2/FOqEfrOYJx61F8v X-Gm-Gg: AZuq6aKG27am5K1URrXTJYqZZbiKbhXtpY7e6xc8NKbkvRZ+Fv6Rg8oXBfkJoZL3gxg kexOKH8d13qzBrAWBEISa2v8v8/B8xQEEhmw453ytnCmhtnnZyAhq43IstTht0Ub7Bn8wXpClgq bVbG4YhIwbzr+84W8TN7lb9EA+hd+W7D+vaaCooBY3vq9j4sVwP9VDqPalxEoJeJ9K25y3t/1SU 17XHzDaRjU65dUdPU/1duLHBvasf/oZ/hA1/lnvz7Wcy279640bqcTK7Un2akoUiRdtNUPjnYQ7 fuxE9qc7iK4Kin2uww9J6G1+yUlAJzcXKc/Gy7sXkqe7JRO9yuyAFzuE48aM6xooGagdmrYSIpC Eo6TsLJoGR90nYyXUSFaK8JsqS/dG6Dta9/9ZIeeHx8YLqXSQ29DHvjjHnWREcALS87ZFC/sb9p TlCAUnf0a4p7y+HRotDeawJEb58jve9wOi X-Received: by 2002:a17:903:1b08:b0:2a0:81c1:6194 with SMTP id d9443c01a7336-2a870dd80b9mr76696405ad.47.1769674018747; Thu, 29 Jan 2026 00:06:58 -0800 (PST) Received: from tehuang-Alienware-m16-R2.. ([50.47.240.160]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a8a039812dsm29394555ad.100.2026.01.29.00.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 00:06:58 -0800 (PST) From: Michael Huang To: Dan Carpenter , Joe Perches , Greg Kroah-Hartman Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Michael Huang Subject: [PATCH v2] staging: rtl8723bs: refactor BSS Coexistence channel report logic Date: Thu, 29 Jan 2026 00:01:10 -0800 Message-ID: <20260129080110.73884-1-tehsiu.huang@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor the 'ICS' array in issue_action_BSSCoexistPacket() to improve readability and maintainability. This addresses technical debt related to magic numbers and ambiguous array usage. The original implementation used a multi-purpose 2D array (ICS[8][15]) where magic numbers were prevalent and the first element of each row was overloaded as a status flag. This patch: - Introduces descriptive macros: BSS_COEX_MAX_CLASSES, BSS_COEX_MAX_CHANNELS, and BSS_COEX_MAX_INFO_LEN. - Splits the overloaded array into two distinct boolean arrays: 'class_active' (for group status) and 'ch_present' (for channel data). - Converts the logic to use 'bool' types and 0-indexed loops, conforming to standard C programming practices. - Adds defensive boundary checks (ch > 0 && ch < MAX) to ensure robustness against unexpected channel data. This refactoring maintains the current 2.4GHz reporting behavior while providing a structured and extensible foundation for future Operating Class support according to IEEE 802.11 specifications. Signed-off-by: Michael Huang --- v2: - Use kernel-style =3D {} for array initialization per Dan Carpenter. - Separate flags from data using bool arrays per Joe Perches. - Fix magic numbers with proper defines. - Retained the 2D structure for 'ch_present' despite only using class 0 for now. This aligns with the IEEE 802.11 Regulatory Class/Channel=20 List hierarchy, making the code easier to map to the specification=20 and extensible for future operating class support. v1: - Initial refactoring of the ICS array logic. drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 41 +++++++------------ .../staging/rtl8723bs/include/rtw_mlme_ext.h | 3 ++ 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/stagin= g/rtl8723bs/core/rtw_mlme_ext.c index 884fcce50d9c..dc2677275e0f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3587,8 +3587,9 @@ static void issue_action_BSSCoexistPacket(struct adap= ter *padapter) struct mlme_ext_priv *pmlmeext =3D &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo =3D &pmlmeext->mlmext_info; struct __queue *queue =3D &(pmlmepriv->scanned_queue); - u8 InfoContent[16] =3D {0}; - u8 ICS[8][15]; + u8 InfoContent[BSS_COEX_MAX_INFO_LEN] =3D {}; + bool class_active[BSS_COEX_MAX_CLASSES] =3D {}; + bool ch_present[BSS_COEX_MAX_CLASSES][BSS_COEX_MAX_CHANNELS] =3D {}; =20 if ((pmlmepriv->num_FortyMHzIntolerant =3D=3D 0) || (pmlmepriv->num_sta_n= o_ht =3D=3D 0)) return; @@ -3642,7 +3643,6 @@ static void issue_action_BSSCoexistPacket(struct adap= ter *padapter) =20 =20 /* */ - memset(ICS, 0, sizeof(ICS)); if (pmlmepriv->num_sta_no_ht > 0) { int i; =20 @@ -3667,46 +3667,35 @@ static void issue_action_BSSCoexistPacket(struct ad= apter *padapter) =20 p =3D rtw_get_ie(pbss_network->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAP= ABILITY, &len, pbss_network->ie_length - _FIXED_IE_LENGTH_); if (!p || len =3D=3D 0) {/* non-HT */ + u8 ch =3D pbss_network->configuration.ds_config; =20 - if (pbss_network->configuration.ds_config <=3D 0) - continue; - - ICS[0][pbss_network->configuration.ds_config] =3D 1; - - if (ICS[0][0] =3D=3D 0) - ICS[0][0] =3D 1; + if (ch > 0 && ch < BSS_COEX_MAX_CHANNELS) { + ch_present[0][ch] =3D true; + class_active[0] =3D true; + } } =20 } =20 spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); =20 - - for (i =3D 0; i < 8; i++) { + for (i =3D 0; i < BSS_COEX_MAX_CLASSES; i++) { int j, k =3D 0; =20 - if (ICS[i][0] !=3D 1) + if (!class_active[i]) continue; =20 - InfoContent[k] =3D i; + InfoContent[k++] =3D i; /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ - k++; =20 - for (j =3D 1; j <=3D 14; j++) { - if (ICS[i][j] !=3D 1) - continue; - - if (k < 16) { - InfoContent[k] =3D j; /* channel number */ - /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ - k++; + for (j =3D 0; j < BSS_COEX_MAX_CHANNELS; j++) { + if (ch_present[i][j]) { + if (k < BSS_COEX_MAX_INFO_LEN) + InfoContent[k++] =3D j; /* channel number */ } } - pframe =3D rtw_set_ie(pframe, WLAN_EID_BSS_INTOLERANT_CHL_REPORT, k, In= foContent, &(pattrib->pktlen)); - } - } =20 =20 diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/sta= ging/rtl8723bs/include/rtw_mlme_ext.h index dd5080056e58..3a1067d6f164 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h @@ -41,6 +41,9 @@ #define _HW_STATE_STATION_ 0x02 #define _HW_STATE_AP_ 0x03 =20 +#define BSS_COEX_MAX_CLASSES 8 +#define BSS_COEX_MAX_CHANNELS 15 +#define BSS_COEX_MAX_INFO_LEN 16 =20 #define _1M_RATE_ 0 #define _2M_RATE_ 1 --=20 2.43.0