hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
....@@ -1581,7 +1581,7 @@
15811581 }
15821582
15831583 /* string is in decimal */
1584
-static bool _rtl8812ae_get_integer_from_string(char *str, u8 *pint)
1584
+static bool _rtl8812ae_get_integer_from_string(const char *str, u8 *pint)
15851585 {
15861586 u16 i = 0;
15871587 *pint = 0;
....@@ -1596,18 +1596,6 @@
15961596 ++i;
15971597 }
15981598
1599
- return true;
1600
-}
1601
-
1602
-static bool _rtl8812ae_eq_n_byte(u8 *str1, u8 *str2, u32 num)
1603
-{
1604
- if (num == 0)
1605
- return false;
1606
- while (num > 0) {
1607
- num--;
1608
- if (str1[num] != str2[num])
1609
- return false;
1610
- }
16111599 return true;
16121600 }
16131601
....@@ -1637,10 +1625,11 @@
16371625 return channel_index;
16381626 }
16391627
1640
-static void _rtl8812ae_phy_set_txpower_limit(struct ieee80211_hw *hw, u8 *pregulation,
1641
- u8 *pband, u8 *pbandwidth,
1642
- u8 *prate_section, u8 *prf_path,
1643
- u8 *pchannel, u8 *ppower_limit)
1628
+static void _rtl8812ae_phy_set_txpower_limit(struct ieee80211_hw *hw,
1629
+ const char *pregulation,
1630
+ const char *pband, const char *pbandwidth,
1631
+ const char *prate_section, const char *prf_path,
1632
+ const char *pchannel, const char *ppower_limit)
16441633 {
16451634 struct rtl_priv *rtlpriv = rtl_priv(hw);
16461635 struct rtl_phy *rtlphy = &rtlpriv->phy;
....@@ -1648,8 +1637,8 @@
16481637 u8 channel_index;
16491638 s8 power_limit = 0, prev_power_limit, ret;
16501639
1651
- if (!_rtl8812ae_get_integer_from_string((char *)pchannel, &channel) ||
1652
- !_rtl8812ae_get_integer_from_string((char *)ppower_limit,
1640
+ if (!_rtl8812ae_get_integer_from_string(pchannel, &channel) ||
1641
+ !_rtl8812ae_get_integer_from_string(ppower_limit,
16531642 &power_limit)) {
16541643 rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE,
16551644 "Illegal index of pwr_lmt table [chnl %d][val %d]\n",
....@@ -1659,42 +1648,42 @@
16591648 power_limit = power_limit > MAX_POWER_INDEX ?
16601649 MAX_POWER_INDEX : power_limit;
16611650
1662
- if (_rtl8812ae_eq_n_byte(pregulation, (u8 *)("FCC"), 3))
1651
+ if (strcmp(pregulation, "FCC") == 0)
16631652 regulation = 0;
1664
- else if (_rtl8812ae_eq_n_byte(pregulation, (u8 *)("MKK"), 3))
1653
+ else if (strcmp(pregulation, "MKK") == 0)
16651654 regulation = 1;
1666
- else if (_rtl8812ae_eq_n_byte(pregulation, (u8 *)("ETSI"), 4))
1655
+ else if (strcmp(pregulation, "ETSI") == 0)
16671656 regulation = 2;
1668
- else if (_rtl8812ae_eq_n_byte(pregulation, (u8 *)("WW13"), 4))
1657
+ else if (strcmp(pregulation, "WW13") == 0)
16691658 regulation = 3;
16701659
1671
- if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("CCK"), 3))
1660
+ if (strcmp(prate_section, "CCK") == 0)
16721661 rate_section = 0;
1673
- else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("OFDM"), 4))
1662
+ else if (strcmp(prate_section, "OFDM") == 0)
16741663 rate_section = 1;
1675
- else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("HT"), 2) &&
1676
- _rtl8812ae_eq_n_byte(prf_path, (u8 *)("1T"), 2))
1664
+ else if (strcmp(prate_section, "HT") == 0 &&
1665
+ strcmp(prf_path, "1T") == 0)
16771666 rate_section = 2;
1678
- else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("HT"), 2) &&
1679
- _rtl8812ae_eq_n_byte(prf_path, (u8 *)("2T"), 2))
1667
+ else if (strcmp(prate_section, "HT") == 0 &&
1668
+ strcmp(prf_path, "2T") == 0)
16801669 rate_section = 3;
1681
- else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("VHT"), 3) &&
1682
- _rtl8812ae_eq_n_byte(prf_path, (u8 *)("1T"), 2))
1670
+ else if (strcmp(prate_section, "VHT") == 0 &&
1671
+ strcmp(prf_path, "1T") == 0)
16831672 rate_section = 4;
1684
- else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("VHT"), 3) &&
1685
- _rtl8812ae_eq_n_byte(prf_path, (u8 *)("2T"), 2))
1673
+ else if (strcmp(prate_section, "VHT") == 0 &&
1674
+ strcmp(prf_path, "2T") == 0)
16861675 rate_section = 5;
16871676
1688
- if (_rtl8812ae_eq_n_byte(pbandwidth, (u8 *)("20M"), 3))
1677
+ if (strcmp(pbandwidth, "20M") == 0)
16891678 bandwidth = 0;
1690
- else if (_rtl8812ae_eq_n_byte(pbandwidth, (u8 *)("40M"), 3))
1679
+ else if (strcmp(pbandwidth, "40M") == 0)
16911680 bandwidth = 1;
1692
- else if (_rtl8812ae_eq_n_byte(pbandwidth, (u8 *)("80M"), 3))
1681
+ else if (strcmp(pbandwidth, "80M") == 0)
16931682 bandwidth = 2;
1694
- else if (_rtl8812ae_eq_n_byte(pbandwidth, (u8 *)("160M"), 4))
1683
+ else if (strcmp(pbandwidth, "160M") == 0)
16951684 bandwidth = 3;
16961685
1697
- if (_rtl8812ae_eq_n_byte(pband, (u8 *)("2.4G"), 4)) {
1686
+ if (strcmp(pband, "2.4G") == 0) {
16981687 ret = _rtl8812ae_phy_get_chnl_idx_of_txpwr_lmt(hw,
16991688 BAND_ON_2_4G,
17001689 channel);
....@@ -1718,7 +1707,7 @@
17181707 regulation, bandwidth, rate_section, channel_index,
17191708 rtlphy->txpwr_limit_2_4g[regulation][bandwidth]
17201709 [rate_section][channel_index][RF90_PATH_A]);
1721
- } else if (_rtl8812ae_eq_n_byte(pband, (u8 *)("5G"), 2)) {
1710
+ } else if (strcmp(pband, "5G") == 0) {
17221711 ret = _rtl8812ae_phy_get_chnl_idx_of_txpwr_lmt(hw,
17231712 BAND_ON_5G,
17241713 channel);
....@@ -1749,10 +1738,10 @@
17491738 }
17501739
17511740 static void _rtl8812ae_phy_config_bb_txpwr_lmt(struct ieee80211_hw *hw,
1752
- u8 *regulation, u8 *band,
1753
- u8 *bandwidth, u8 *rate_section,
1754
- u8 *rf_path, u8 *channel,
1755
- u8 *power_limit)
1741
+ const char *regulation, const char *band,
1742
+ const char *bandwidth, const char *rate_section,
1743
+ const char *rf_path, const char *channel,
1744
+ const char *power_limit)
17561745 {
17571746 _rtl8812ae_phy_set_txpower_limit(hw, regulation, band, bandwidth,
17581747 rate_section, rf_path, channel,
....@@ -1765,7 +1754,7 @@
17651754 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
17661755 u32 i = 0;
17671756 u32 array_len;
1768
- u8 **array;
1757
+ const char **array;
17691758
17701759 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) {
17711760 array_len = RTL8812AE_TXPWR_LMT_ARRAY_LEN;
....@@ -1778,13 +1767,13 @@
17781767 rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE, "\n");
17791768
17801769 for (i = 0; i < array_len; i += 7) {
1781
- u8 *regulation = array[i];
1782
- u8 *band = array[i+1];
1783
- u8 *bandwidth = array[i+2];
1784
- u8 *rate = array[i+3];
1785
- u8 *rf_path = array[i+4];
1786
- u8 *chnl = array[i+5];
1787
- u8 *val = array[i+6];
1770
+ const char *regulation = array[i];
1771
+ const char *band = array[i+1];
1772
+ const char *bandwidth = array[i+2];
1773
+ const char *rate = array[i+3];
1774
+ const char *rf_path = array[i+4];
1775
+ const char *chnl = array[i+5];
1776
+ const char *val = array[i+6];
17881777
17891778 _rtl8812ae_phy_config_bb_txpwr_lmt(hw, regulation, band,
17901779 bandwidth, rate, rf_path,