staging: r8188eu: remove HW_VAR_INITIAL_GAIN
authorMichael Straube <straube.linux@gmail.com>
Sat, 9 Apr 2022 12:06:24 +0000 (14:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Apr 2022 13:49:04 +0000 (15:49 +0200)
Remove the HW_VAR_INITIAL_GAIN case from SetHwReg8188EU() and move its
functionality to a new static function in rtw_mlme_ext.c. This is part
of the ongoing effort to get rid of the unwanted hal layer.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220409120627.10633-2-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_mlme_ext.c
drivers/staging/r8188eu/hal/usb_halinit.c
drivers/staging/r8188eu/include/hal_intf.h

index 474391b..e7fffd5 100644 (file)
@@ -5794,13 +5794,27 @@ Following are some utitity fuctions for WiFi MLME
 
 *****************************************************************************/
 
+static void rtw_set_initial_gain(struct adapter *adapter, u8 gain)
+{
+       struct hal_data_8188e *haldata = &adapter->haldata;
+       struct odm_dm_struct *odmpriv = &haldata->odmpriv;
+       struct rtw_dig *digtable = &odmpriv->DM_DigTable;
+
+       if (gain == 0xff) {
+               /* restore rx gain */
+               ODM_Write_DIG(odmpriv, digtable->BackupIGValue);
+       } else {
+               digtable->BackupIGValue = digtable->CurIGValue;
+               ODM_Write_DIG(odmpriv, gain);
+       }
+}
+
 void site_survey(struct adapter *padapter)
 {
        unsigned char           survey_channel = 0, val8;
        enum rt_scan_type ScanType = SCAN_PASSIVE;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
-       u32 initialgain = 0;
        struct wifidirect_info *pwdinfo = &padapter->wdinfo;
 
        if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) {
@@ -5878,8 +5892,8 @@ void site_survey(struct adapter *padapter)
                        rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN);
                        pmlmeext->sitesurvey_res.state = SCAN_DISABLE;
 
-                       initialgain = 0xff; /* restore RX GAIN */
-                       SetHwReg8188EU(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain));
+                       /* restore RX GAIN */
+                       rtw_set_initial_gain(padapter, 0xff);
                        /* turn on dynamic functions */
                        Restore_DM_Func_Flag(padapter);
                        /* Switch_DM_Func(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */
@@ -5912,8 +5926,8 @@ void site_survey(struct adapter *padapter)
                        /* config MSR */
                        Set_MSR(padapter, (pmlmeinfo->state & 0x3));
 
-                       initialgain = 0xff; /* restore RX GAIN */
-                       SetHwReg8188EU(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain));
+                       /* restore RX GAIN */
+                       rtw_set_initial_gain(padapter, 0xff);
                        /* turn on dynamic functions */
                        Restore_DM_Func_Flag(padapter);
                        /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */
@@ -7369,7 +7383,6 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)
        struct sitesurvey_parm  *pparm = (struct sitesurvey_parm *)pbuf;
        u8 bdelayscan = false;
        u8 val8;
-       u32     initialgain;
        u32     i;
        struct wifidirect_info *pwdinfo = &padapter->wdinfo;
 
@@ -7418,11 +7431,10 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)
 
                /* config the initial gain under scanning, need to write the BB registers */
                if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
-                       initialgain = 0x1E;
+                       rtw_set_initial_gain(padapter, 0x1e);
                else
-                       initialgain = 0x28;
+                       rtw_set_initial_gain(padapter, 0x28);
 
-               SetHwReg8188EU(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain));
 
                /* set MSR to no link state */
                Set_MSR(padapter, _HW_STATE_NOLINK_);
index 5cbb982..d8aea49 100644 (file)
@@ -1146,19 +1146,6 @@ void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val)
                        rtl8188e_set_FwPwrMode_cmd(Adapter, psmode);
                }
                break;
-       case HW_VAR_INITIAL_GAIN:
-               {
-                       struct rtw_dig *pDigTable = &podmpriv->DM_DigTable;
-                       u32 rx_gain = ((u32 *)(val))[0];
-
-                       if (rx_gain == 0xff) {/* restore rx gain */
-                               ODM_Write_DIG(podmpriv, pDigTable->BackupIGValue);
-                       } else {
-                               pDigTable->BackupIGValue = pDigTable->CurIGValue;
-                               ODM_Write_DIG(podmpriv, rx_gain);
-                       }
-               }
-               break;
        case HW_VAR_FIFO_CLEARN_UP:
                {
                        struct pwrctrl_priv *pwrpriv = &Adapter->pwrctrlpriv;
index 532d02b..342587e 100644 (file)
@@ -22,7 +22,6 @@ enum hw_variables {
        HW_VAR_AC_PARAM_BE,
        HW_VAR_AMPDU_FACTOR,
        HW_VAR_H2C_FW_PWRMODE,
-       HW_VAR_INITIAL_GAIN,
        HW_VAR_FIFO_CLEARN_UP,
        HW_VAR_H2C_MEDIA_STATUS_RPT,
 };