staging: rtl8723bs: refactor halbtc8723b1ant_CoexTableWithType() to remove duplication
PATCH 1/1 staging: rtl8723bs: refactor halbtc8723b1ant_CoexTableWithType() to remove duplication
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.
--- .../staging/rtl8723bs/hal/HalBtc8723b1Ant.c | 55 +++++-------------- 1 file changed, 13 insertions(+), 42 deletions(-)
drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c +13 -42
@@ -684,52 +684,23 @@ 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 : +if (-1 < type && type <8 )halbtc8723b1ant_CoexTable ( - pBtCoexist, bForceExec,0x55555555 ,0xaaaa5a5a ,0xffffff ,0x3 + pBtCoexist, bForceExec, table[type][0 ], table[type][1 ],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 ; - } } static void halbtc8723b1ant_SetFwIgnoreWlanAct(
Signature · 1 line
2.43.0
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Bera,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/Bera-Y-zl/staging-rtl8723bs-refactor-halbtc8723b1ant_CoexTableWithType-to-remove-duplication/20260208-211800 base: staging/staging-testing patch link: https://lore.kernel.org/r/aYiMi-X5r4aUEC32%40BERA.localdomain patch subject: [PATCH] staging: rtl8723bs: refactor halbtc8723b1ant_CoexTableWithType() to remove duplication config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20260209/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260209/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c:700:9: warning: result of comparison of constant -1 with expression of type 'u8' (aka 'unsigned char') is always true [-Wtautological-constant-out-of-range-compare]
700 | if (-1 < type && type < 8)
| ~~ ^ ~~~~1 warning generated.
vim +700 drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
682
683 static void halbtc8723b1ant_CoexTableWithType(
684 struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
685 )
686 {
687 static const u32 table[8][2] = {
688 {0x55555555, 0x55555555},
689 {0x55555555, 0x5a5a5a5a},
690 {0x5a5a5a5a, 0x5a5a5a5a},
691 {0xaaaa5555, 0xaaaa5a5a},
692 {0x55555555, 0xaaaa5a5a},
693 {0x5a5a5a5a, 0xaaaa5a5a},
694 {0x55555555, 0xaaaaaaaa},
695 {0xaaaaaaaa, 0xaaaaaaaa}
696 };
697
698 pCoexSta->nCoexTableType = type;
699
> 700 if (-1 < type && type < 8)
701 halbtc8723b1ant_CoexTable(
702 pBtCoexist, bForceExec, table[type][0], table[type][1], 0xffffff, 0x3
703 );
704 }
705
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki