git: 57b839612b7a - main - rtw89: cleanup static_assert() calls

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Tue, 10 Feb 2026 10:16:55 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=57b839612b7abb891057f1efe380c509664f868b

commit 57b839612b7abb891057f1efe380c509664f868b
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-01-20 22:51:28 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-02-10 10:16:34 +0000

    rtw89: cleanup static_assert() calls
    
    These days we can use static_assert() without trouble so remove the
    FreeBSD-specific rtw89_static_assert implementation.  This reduces
    the diff to upstream and will ease future driver updates.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/contrib/dev/rtw89/core.h         |  6 ------
 sys/contrib/dev/rtw89/debug.c        | 12 ------------
 sys/contrib/dev/rtw89/fw.h           |  8 --------
 sys/contrib/dev/rtw89/phy.c          |  8 --------
 sys/contrib/dev/rtw89/rtw8851b.c     |  6 ------
 sys/contrib/dev/rtw89/rtw8852c.c     |  6 ------
 sys/contrib/dev/rtw89/rtw8852c_rfk.c |  4 ----
 sys/contrib/dev/rtw89/sar.c          |  4 ----
 sys/contrib/dev/rtw89/ser.c          |  4 ----
 9 files changed, 58 deletions(-)

diff --git a/sys/contrib/dev/rtw89/core.h b/sys/contrib/dev/rtw89/core.h
index a8bfa538515e..b6b810567a35 100644
--- a/sys/contrib/dev/rtw89/core.h
+++ b/sys/contrib/dev/rtw89/core.h
@@ -7703,10 +7703,4 @@ void rtw89_core_ntfy_btc_event(struct rtw89_dev *rtwdev, enum rtw89_btc_hmsg eve
 int rtw89_core_mlsr_switch(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
 			   unsigned int link_id);
 
-#if defined(__linux__)
-#define	rtw89_static_assert(_x)		static_assert(_x)
-#elif defined(__FreeBSD__)
-#define	rtw89_static_assert(_x)		_Static_assert(_x, "bad array size")
-#endif
-
 #endif
diff --git a/sys/contrib/dev/rtw89/debug.c b/sys/contrib/dev/rtw89/debug.c
index ad11256fffb7..0db142ba6d89 100644
--- a/sys/contrib/dev/rtw89/debug.c
+++ b/sys/contrib/dev/rtw89/debug.c
@@ -505,11 +505,7 @@ static const struct txpwr_ent __txpwr_ent_byr_ax[] = {
 	__GEN_TXPWR_ENT4("HEDCM_2NSS", "MCS0 ", "MCS1 ", "MCS3 ", "MCS4 "),
 };
 
-#if defined(__linux__)
 static_assert((ARRAY_SIZE(__txpwr_ent_byr_ax) * 4) ==
-#elif defined(__FreeBSD__)
-rtw89_static_assert((ARRAY_SIZE(__txpwr_ent_byr_ax) * 4) ==
-#endif
 	(R_AX_PWR_BY_RATE_MAX - R_AX_PWR_BY_RATE + 4));
 
 static const struct txpwr_map __txpwr_map_byr_ax = {
@@ -565,11 +561,7 @@ static const struct txpwr_ent __txpwr_ent_lmt_ax[] = {
 	__GEN_TXPWR_ENT2("MCS_2TX_40M_2p5", "NON_BF", "BF"),
 };
 
-#if defined(__linux__)
 static_assert((ARRAY_SIZE(__txpwr_ent_lmt_ax) * 2) ==
-#elif defined(__FreeBSD__)
-rtw89_static_assert((ARRAY_SIZE(__txpwr_ent_lmt_ax) * 2) ==
-#endif
 	(R_AX_PWR_LMT_MAX - R_AX_PWR_LMT + 4));
 
 static const struct txpwr_map __txpwr_map_lmt_ax = {
@@ -597,11 +589,7 @@ static const struct txpwr_ent __txpwr_ent_lmt_ru_ax[] = {
 			 "RU106_4", "RU106_5", "RU106_6", "RU106_7"),
 };
 
-#if defined(__linux__)
 static_assert((ARRAY_SIZE(__txpwr_ent_lmt_ru_ax) * 8) ==
-#elif defined(__FreeBSD__)
-rtw89_static_assert((ARRAY_SIZE(__txpwr_ent_lmt_ru_ax) * 8) ==
-#endif
 	(R_AX_PWR_RU_LMT_MAX - R_AX_PWR_RU_LMT + 4));
 
 static const struct txpwr_map __txpwr_map_lmt_ru_ax = {
diff --git a/sys/contrib/dev/rtw89/fw.h b/sys/contrib/dev/rtw89/fw.h
index 940a7b39bee1..cedb4a47a769 100644
--- a/sys/contrib/dev/rtw89/fw.h
+++ b/sys/contrib/dev/rtw89/fw.h
@@ -3608,11 +3608,7 @@ struct rtw89_fw_c2h_attr {
 
 static inline struct rtw89_fw_c2h_attr *RTW89_SKB_C2H_CB(struct sk_buff *skb)
 {
-#if defined(__linux__)
 	static_assert(sizeof(skb->cb) >= sizeof(struct rtw89_fw_c2h_attr));
-#elif defined(__FreeBSD__)
-	rtw89_static_assert(sizeof(skb->cb) >= sizeof(struct rtw89_fw_c2h_attr));
-#endif
 
 	return (struct rtw89_fw_c2h_attr *)skb->cb;
 }
@@ -3818,11 +3814,7 @@ struct rtw89_mac_mcc_tsf_rpt {
 	u32 tsf_y_high;
 };
 
-#if defined(__linux__)
 static_assert(sizeof(struct rtw89_mac_mcc_tsf_rpt) <= RTW89_COMPLETION_BUF_SIZE);
-#elif defined(__FreeBSD__)
-rtw89_static_assert(sizeof(struct rtw89_mac_mcc_tsf_rpt) <= RTW89_COMPLETION_BUF_SIZE);
-#endif
 
 #define RTW89_GET_MAC_C2H_MCC_TSF_RPT_MACID_X(c2h) \
 	le32_get_bits(*((const __le32 *)(c2h) + 2), GENMASK(7, 0))
diff --git a/sys/contrib/dev/rtw89/phy.c b/sys/contrib/dev/rtw89/phy.c
index bbd4e3d7d360..f60753369516 100644
--- a/sys/contrib/dev/rtw89/phy.c
+++ b/sys/contrib/dev/rtw89/phy.c
@@ -2856,11 +2856,7 @@ rtw89_phy_fill_txpwr_limit_ru_160m_ax(struct rtw89_dev *rtwdev,
 	static const int ofst[] = { -14, -10, -6, -2, 2, 6, 10, 14 };
 	int i;
 
-#if defined(__linux__)
 	static_assert(ARRAY_SIZE(ofst) == RTW89_RU_SEC_NUM_AX);
-#elif defined(__FreeBSD__)
-	rtw89_static_assert(ARRAY_SIZE(ofst) == RTW89_RU_SEC_NUM_AX);
-#endif
 	for (i = 0; i < RTW89_RU_SEC_NUM_AX; i++) {
 		lmt_ru->ru26[i] = rtw89_phy_read_txpwr_limit_ru(rtwdev, band,
 								RTW89_RU26,
@@ -7556,11 +7552,7 @@ static void
 	[RTW89_RFK_F_DELAY] = _rfk_delay,
 };
 
-#if defined(__linux__)
 static_assert(ARRAY_SIZE(_rfk_handler) == RTW89_RFK_F_NUM);
-#elif defined(__FreeBSD__)
-rtw89_static_assert(ARRAY_SIZE(_rfk_handler) == RTW89_RFK_F_NUM);
-#endif
 
 void
 rtw89_rfk_parser(struct rtw89_dev *rtwdev, const struct rtw89_rfk_tbl *tbl)
diff --git a/sys/contrib/dev/rtw89/rtw8851b.c b/sys/contrib/dev/rtw89/rtw8851b.c
index 04246a31cc0e..84b628d23882 100644
--- a/sys/contrib/dev/rtw89/rtw8851b.c
+++ b/sys/contrib/dev/rtw89/rtw8851b.c
@@ -1825,15 +1825,9 @@ static void rtw8851b_bb_set_tx_shape_dfir(struct rtw89_dev *rtwdev,
 #define __DFIR_CFG_ADDR(i) (R_TXFIR0 + ((i) << 2))
 #define __DFIR_CFG_MASK 0xffffffff
 #define __DFIR_CFG_NR 8
-#if defined(__linux__)
 #define __DECL_DFIR_PARAM(_name, _val...) \
 	static const u32 param_ ## _name[] = {_val}; \
 	static_assert(ARRAY_SIZE(param_ ## _name) == __DFIR_CFG_NR)
-#elif defined(__FreeBSD__)
-#define __DECL_DFIR_PARAM(_name, _val...) \
-	static const u32 param_ ## _name[] = {_val}; \
-	rtw89_static_assert(ARRAY_SIZE(param_ ## _name) == __DFIR_CFG_NR)
-#endif
 
 	__DECL_DFIR_PARAM(flat,
 			  0x023D23FF, 0x0029B354, 0x000FC1C8, 0x00FDB053,
diff --git a/sys/contrib/dev/rtw89/rtw8852c.c b/sys/contrib/dev/rtw89/rtw8852c.c
index 6f272aab48a5..db99450e9158 100644
--- a/sys/contrib/dev/rtw89/rtw8852c.c
+++ b/sys/contrib/dev/rtw89/rtw8852c.c
@@ -2085,15 +2085,9 @@ static void rtw8852c_bb_set_tx_shape_dfir(struct rtw89_dev *rtwdev,
 {
 #define __DFIR_CFG_MASK 0xffffff
 #define __DFIR_CFG_NR 8
-#if defined(__linux__)
 #define __DECL_DFIR_VAR(_prefix, _name, _val...) \
 	static const u32 _prefix ## _ ## _name[] = {_val}; \
 	static_assert(ARRAY_SIZE(_prefix ## _ ## _name) == __DFIR_CFG_NR)
-#elif defined(__FreeBSD__)
-#define __DECL_DFIR_VAR(_prefix, _name, _val...) \
-	static const u32 _prefix ## _ ## _name[] = {_val}; \
-	rtw89_static_assert(ARRAY_SIZE(_prefix ## _ ## _name) == __DFIR_CFG_NR)
-#endif
 #define __DECL_DFIR_PARAM(_name, _val...) __DECL_DFIR_VAR(param, _name, _val)
 #define __DECL_DFIR_ADDR(_name, _val...) __DECL_DFIR_VAR(addr, _name, _val)
 
diff --git a/sys/contrib/dev/rtw89/rtw8852c_rfk.c b/sys/contrib/dev/rtw89/rtw8852c_rfk.c
index 129b940da62a..cbee484dee30 100644
--- a/sys/contrib/dev/rtw89/rtw8852c_rfk.c
+++ b/sys/contrib/dev/rtw89/rtw8852c_rfk.c
@@ -2704,11 +2704,7 @@ static void _dpk_cal_select(struct rtw89_dev *rtwdev, bool force,
 	u8 path;
 	bool is_fail = true, reloaded[RTW8852C_DPK_RF_PATH] = {false};
 
-#if defined(__linux__)
 	static_assert(ARRAY_SIZE(kip_reg) == RTW8852C_DPK_KIP_REG_NUM);
-#elif defined(__FreeBSD__)
-	rtw89_static_assert(ARRAY_SIZE(kip_reg) == RTW8852C_DPK_KIP_REG_NUM);
-#endif
 
 	if (dpk->is_dpk_reload_en) {
 		for (path = 0; path < RTW8852C_DPK_RF_PATH; path++) {
diff --git a/sys/contrib/dev/rtw89/sar.c b/sys/contrib/dev/rtw89/sar.c
index ed3fa4e6b0a5..ef7feccccd5e 100644
--- a/sys/contrib/dev/rtw89/sar.c
+++ b/sys/contrib/dev/rtw89/sar.c
@@ -406,11 +406,7 @@ static const struct cfg80211_sar_freq_ranges rtw89_common_sar_freq_ranges[] = {
 	{ .start_freq = 6875, .end_freq = 7115, },
 };
 
-#if defined(__linux__)
 static_assert(RTW89_SAR_SUBBAND_NR ==
-#elif defined(__FreeBSD__)
-rtw89_static_assert(RTW89_SAR_SUBBAND_NR ==
-#endif
 	      ARRAY_SIZE(rtw89_common_sar_freq_ranges));
 
 const struct cfg80211_sar_capa rtw89_sar_capa = {
diff --git a/sys/contrib/dev/rtw89/ser.c b/sys/contrib/dev/rtw89/ser.c
index 03f56b03875a..f99e179f7ff9 100644
--- a/sys/contrib/dev/rtw89/ser.c
+++ b/sys/contrib/dev/rtw89/ser.c
@@ -620,11 +620,7 @@ struct __fw_backtrace_info {
 	u32 sp;
 } __packed;
 
-#if defined(__linux__)
 static_assert(RTW89_FW_BACKTRACE_INFO_SIZE ==
-#elif defined(__FreeBSD__)
-rtw89_static_assert(RTW89_FW_BACKTRACE_INFO_SIZE ==
-#endif
 	      sizeof(struct __fw_backtrace_info));
 
 static u32 convert_addr_from_wcpu(u32 wcpu_addr)