Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: rtl8723bs: refactor to reduce indents

Reduce the number of indents in rtw_wlan_util.c file by refactoring the
code.

Moved the part of code that rearranged ac paramaters in the function
WMMOnAssocResp to a separate function named sort_wmm_ac_params. It takes
both the array of ac params and their indexes as arguments and sorts them.
Has return type void.

Moved the part of code that checked IE for realtek vendor in the
function check_assoc_AP to a separate function named
get_realtek_assoc_AP_vender. It takes a struct ndis_80211_var_ie * as an
argument and returns u32 realtek vendor.

Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
Link: https://lore.kernel.org/r/20210524135105.5550-2-chouhan.shreyansh630@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Shreyansh Chouhan and committed by
Greg Kroah-Hartman
3c8c577f f57e6d91

+56 -52
+56 -52
drivers/staging/rtl8723bs/core/rtw_wlan_util.c
··· 777 777 return true; 778 778 } 779 779 780 + static void sort_wmm_ac_params(u32 *inx, u32 *edca) 781 + { 782 + u32 i, j, change_inx = false; 783 + 784 + /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ 785 + for (i = 0; i < 4; i++) { 786 + for (j = i + 1; j < 4; j++) { 787 + /* compare CW and AIFS */ 788 + if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { 789 + change_inx = true; 790 + } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) { 791 + /* compare TXOP */ 792 + if ((edca[j] >> 16) > (edca[i] >> 16)) 793 + change_inx = true; 794 + } 795 + 796 + if (change_inx) { 797 + swap(edca[i], edca[j]); 798 + swap(inx[i], inx[j]); 799 + 800 + change_inx = false; 801 + } 802 + } 803 + } 804 + } 805 + 780 806 void WMMOnAssocRsp(struct adapter *padapter) 781 807 { 782 808 u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; ··· 899 873 900 874 inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; 901 875 902 - if (pregpriv->wifi_spec == 1) { 903 - u32 j, tmp, change_inx = false; 904 - 905 - /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ 906 - for (i = 0; i < 4; i++) { 907 - for (j = i+1; j < 4; j++) { 908 - /* compare CW and AIFS */ 909 - if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { 910 - change_inx = true; 911 - } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) { 912 - /* compare TXOP */ 913 - if ((edca[j] >> 16) > (edca[i] >> 16)) 914 - change_inx = true; 915 - } 916 - 917 - if (change_inx) { 918 - tmp = edca[i]; 919 - edca[i] = edca[j]; 920 - edca[j] = tmp; 921 - 922 - tmp = inx[i]; 923 - inx[i] = inx[j]; 924 - inx[j] = tmp; 925 - 926 - change_inx = false; 927 - } 928 - } 929 - } 930 - } 876 + if (pregpriv->wifi_spec == 1) 877 + sort_wmm_ac_params(inx, edca); 931 878 932 879 for (i = 0; i < 4; i++) 933 880 pxmitpriv->wmm_para_seq[i] = inx[i]; ··· 1495 1496 Update_RA_Entry(padapter, psta); 1496 1497 } 1497 1498 1499 + static u32 get_realtek_assoc_AP_vender(struct ndis_80211_var_ie *pIE) 1500 + { 1501 + u32 Vender = HT_IOT_PEER_REALTEK; 1502 + 1503 + if (pIE->Length >= 5) { 1504 + if (pIE->data[4] == 1) 1505 + /* if (pIE->data[5] & RT_HT_CAP_USE_LONG_PREAMBLE) */ 1506 + /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */ 1507 + if (pIE->data[5] & RT_HT_CAP_USE_92SE) 1508 + /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; */ 1509 + Vender = HT_IOT_PEER_REALTEK_92SE; 1510 + 1511 + if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP) 1512 + Vender = HT_IOT_PEER_REALTEK_SOFTAP; 1513 + 1514 + if (pIE->data[4] == 2) { 1515 + if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) 1516 + Vender = HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP; 1517 + 1518 + if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT) 1519 + Vender = HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP; 1520 + } 1521 + } 1522 + 1523 + return Vender; 1524 + } 1525 + 1498 1526 unsigned char check_assoc_AP(u8 *pframe, uint len) 1499 1527 { 1500 1528 unsigned int i; ··· 1545 1519 } else if (!memcmp(pIE->data, CISCO_OUI, 3)) { 1546 1520 return HT_IOT_PEER_CISCO; 1547 1521 } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) { 1548 - u32 Vender = HT_IOT_PEER_REALTEK; 1549 - 1550 - if (pIE->Length >= 5) { 1551 - if (pIE->data[4] == 1) 1552 - /* if (pIE->data[5] & RT_HT_CAP_USE_LONG_PREAMBLE) */ 1553 - /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */ 1554 - if (pIE->data[5] & RT_HT_CAP_USE_92SE) 1555 - /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; */ 1556 - Vender = HT_IOT_PEER_REALTEK_92SE; 1557 - 1558 - if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP) 1559 - Vender = HT_IOT_PEER_REALTEK_SOFTAP; 1560 - 1561 - if (pIE->data[4] == 2) { 1562 - if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) 1563 - Vender = HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP; 1564 - 1565 - if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT) 1566 - Vender = HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP; 1567 - } 1568 - } 1569 - 1570 - return Vender; 1522 + return get_realtek_assoc_AP_vender(pIE); 1571 1523 } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) { 1572 1524 return HT_IOT_PEER_AIRGO; 1573 1525 } else {