[PATCH v2] staging: rtl8723bs: refactor halbtc8723b1ant_CoexTableWithType() to remove duplication
From: Bera Yüzlü
Date: Thu Feb 26 2026 - 08:04:40 EST
Replace the verbose switch-case block with a constant 2D array lookup.
This makes the function much more concise and easier to read without
changing the underlying behavior.
Signed-off-by: Bera Yüzlü <b9788213@xxxxxxxxx>
---
V2: Removed '-1 < type' control
V2: Wrapped line correctly
V1 link: https://lore.kernel.org/linux-staging/aYiMi-X5r4aUEC32@BERA.localdomain/
.../staging/rtl8723bs/hal/HalBtc8723b1Ant.c | 58 +++++--------------
1 file changed, 14 insertions(+), 44 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
index 1af101ba9..b3e34f97c 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
@@ -684,52 +684,22 @@ static void halbtc8723b1ant_CoexTableWithType(
struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
)
{
+ static const u32 table[8][2] = {
+ {0x55555555, 0x55555555},
+ {0x55555555, 0x5a5a5a5a},
+ {0x5a5a5a5a, 0x5a5a5a5a},
+ {0xaaaa5555, 0xaaaa5a5a},
+ {0x55555555, 0xaaaa5a5a},
+ {0x5a5a5a5a, 0xaaaa5a5a},
+ {0x55555555, 0xaaaaaaaa},
+ {0xaaaaaaaa, 0xaaaaaaaa}
+ };
+
pCoexSta->nCoexTableType = type;
- switch (type) {
- case 0:
- halbtc8723b1ant_CoexTable(
- pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3
- );
- break;
- case 1:
- halbtc8723b1ant_CoexTable(
- pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3
- );
- break;
- case 2:
- halbtc8723b1ant_CoexTable(
- pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3
- );
- break;
- case 3:
- halbtc8723b1ant_CoexTable(
- pBtCoexist, bForceExec, 0xaaaa5555, 0xaaaa5a5a, 0xffffff, 0x3
- );
- break;
- case 4:
- halbtc8723b1ant_CoexTable(
- pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3
- );
- break;
- case 5:
- halbtc8723b1ant_CoexTable(
- pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaa5a5a, 0xffffff, 0x3
- );
- break;
- case 6:
- halbtc8723b1ant_CoexTable(
- pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3
- );
- break;
- case 7:
- halbtc8723b1ant_CoexTable(
- pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3
- );
- break;
- default:
- break;
- }
+ if (type < 8)
+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, table[type][0],
+ table[type][1], 0xffffff, 0x3);
}
static void halbtc8723b1ant_SetFwIgnoreWlanAct(
--
2.43.0