From 61b38d571442951e4a7d79a3698a1be68c8367d1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 29 May 2013 14:26:48 -0500 Subject: [PATCH] rtl8188eu: More sparse cleanups Signed-off-by: Larry Finger --- core/rtw_io.c | 11 ++-- core/rtw_led.c | 15 ++--- core/rtw_mlme_ext.c | 7 ++- core/rtw_security.c | 12 ++-- hal/rtl8188eu_xmit.c | 127 +++++++++++++++---------------------------- include/rtw_xmit.h | 44 +++------------ os_dep/rtw_android.c | 25 ++++----- 7 files changed, 88 insertions(+), 153 deletions(-) diff --git a/core/rtw_io.c b/core/rtw_io.c index 82891fd..4a18add 100644 --- a/core/rtw_io.c +++ b/core/rtw_io.c @@ -148,6 +148,7 @@ int _rtw_write8(_adapter *adapter, u32 addr, u8 val) return RTW_STATUS_CODE(ret); } + int _rtw_write16(_adapter *adapter, u32 addr, u16 val) { //struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; @@ -155,11 +156,12 @@ int _rtw_write16(_adapter *adapter, u32 addr, u16 val) struct intf_hdl *pintfhdl = &(pio_priv->intf); int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); int ret; + __le16 ival; _func_enter_; _write16 = pintfhdl->io_ops._write16; - val = rtw_cpu_to_le16(val); - ret = _write16(pintfhdl, addr, val); + ival = rtw_cpu_to_le16(val); + ret = _write16(pintfhdl, addr, ival); _func_exit_; return RTW_STATUS_CODE(ret); @@ -171,11 +173,12 @@ int _rtw_write32(_adapter *adapter, u32 addr, u32 val) struct intf_hdl *pintfhdl = &(pio_priv->intf); int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); int ret; + __le32 ival; _func_enter_; _write32 = pintfhdl->io_ops._write32; - val = rtw_cpu_to_le32(val); - ret = _write32(pintfhdl, addr, val); + ival = rtw_cpu_to_le32(val); + ret = _write32(pintfhdl, addr, ival); _func_exit_; return RTW_STATUS_CODE(ret); diff --git a/core/rtw_led.c b/core/rtw_led.c index 6b31bc6..d9e48e1 100644 --- a/core/rtw_led.c +++ b/core/rtw_led.c @@ -19,6 +19,7 @@ ******************************************************************************/ #include +#include "rtw_led.h" // // Description: @@ -139,7 +140,7 @@ void SwLedOff(_adapter *padapter, PLED_871x pLed); #define CONFIG_LED_REMOVE_HAL -void +static void SwLedBlink( PLED_871x pLed ) @@ -257,7 +258,7 @@ SwLedBlink( } } -void +static void SwLedBlink1( PLED_871x pLed ) @@ -469,7 +470,7 @@ SwLedBlink1( } -void +static void SwLedBlink2( PLED_871x pLed ) @@ -591,7 +592,7 @@ SwLedBlink2( } -void +static void SwLedBlink3( PLED_871x pLed ) @@ -762,7 +763,7 @@ SwLedBlink3( } -void +static void SwLedBlink4( PLED_871x pLed ) @@ -961,7 +962,7 @@ SwLedBlink4( } -void +static void SwLedBlink5( PLED_871x pLed ) @@ -1079,7 +1080,7 @@ SwLedBlink5( } -void +static void SwLedBlink6( PLED_871x pLed ) diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index c2d3cf2..c4cdcbc 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -1122,9 +1122,10 @@ unsigned int OnAuth(_adapter *padapter, union recv_frame *precv_frame) { #ifdef CONFIG_AP_MODE _irqL irqL; - unsigned int auth_mode, seq, ie_len; + unsigned int auth_mode, ie_len; + __le16 seq; unsigned char *sa, *p; - u16 algorithm; + __le16 algorithm; int status; static struct sta_info stat; struct sta_info *pstat=NULL; @@ -2240,7 +2241,7 @@ unsigned int OnDeAuth(_adapter *padapter, union recv_frame *precv_frame) unsigned int OnDisassoc(_adapter *padapter, union recv_frame *precv_frame) { - unsigned short reason; + __le16 reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); diff --git a/core/rtw_security.c b/core/rtw_security.c index 4049494..475865c 100644 --- a/core/rtw_security.c +++ b/core/rtw_security.c @@ -212,7 +212,7 @@ _func_enter_; length=pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len; - *((unsigned long *)crc)=cpu_to_le32(getcrc32(payload,length)); + *((__le32 *)crc)=cpu_to_le32(getcrc32(payload,length)); arcfour_init(&mycontext, wepkey,3+keylength); arcfour_encrypt(&mycontext, payload, payload, length); @@ -222,7 +222,7 @@ _func_enter_; else { length=pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; - *((unsigned long *)crc)=cpu_to_le32(getcrc32(payload,length)); + *((__le32 *)crc)=cpu_to_le32(getcrc32(payload,length)); arcfour_init(&mycontext, wepkey,3+keylength); arcfour_encrypt(&mycontext, payload, payload, length); arcfour_encrypt(&mycontext, payload+length, crc, 4); @@ -725,8 +725,10 @@ _func_enter_; if ((curfragnum+1)==pattrib->nr_frags){ //4 the last fragment length=pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len; - RT_TRACE(_module_rtl871x_security_c_,_drv_info_,("pattrib->iv_len =%x, pattrib->icv_len =%x\n", pattrib->iv_len,pattrib->icv_len)); - *((u32 *)crc)=cpu_to_le32(getcrc32(payload,length));/* modified by Amy*/ + RT_TRACE(_module_rtl871x_security_c_, _drv_info_, + ("pattrib->iv_len =%x, pattrib->icv_len =%x\n", + pattrib->iv_len,pattrib->icv_len)); + *((__le32 *)crc)=cpu_to_le32(getcrc32(payload,length));/* modified by Amy*/ arcfour_init(&mycontext, rc4key,16); arcfour_encrypt(&mycontext, payload, payload, length); @@ -735,7 +737,7 @@ _func_enter_; } else{ length=pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; - *((u32 *)crc)=cpu_to_le32(getcrc32(payload,length));/* modified by Amy*/ + *((__le32 *)crc)=cpu_to_le32(getcrc32(payload,length));/* modified by Amy*/ arcfour_init(&mycontext,rc4key,16); arcfour_encrypt(&mycontext, payload, payload, length); arcfour_encrypt(&mycontext, payload+length, crc, 4); diff --git a/hal/rtl8188eu_xmit.c b/hal/rtl8188eu_xmit.c index a750b42..f6cc7b9 100644 --- a/hal/rtl8188eu_xmit.c +++ b/hal/rtl8188eu_xmit.c @@ -52,38 +52,16 @@ void rtl8188eu_free_xmit_priv(_adapter *padapter) { } -u8 urb_zero_packet_chk(_adapter *padapter, int sz) +static u8 urb_zero_packet_chk(_adapter *padapter, int sz) { -#if 1 u8 blnSetTxDescOffset; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); blnSetTxDescOffset = (((sz + TXDESC_SIZE) % pHalData->UsbBulkOutSize) ==0)?1:0; -#else - - struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); - if ( pdvobj->ishighspeed ) - { - if ( ( (sz + TXDESC_SIZE) % 512 ) == 0 ) { - blnSetTxDescOffset = 1; - } else { - blnSetTxDescOffset = 0; - } - } - else - { - if ( ( (sz + TXDESC_SIZE) % 64 ) == 0 ) { - blnSetTxDescOffset = 1; - } else { - blnSetTxDescOffset = 0; - } - } -#endif return blnSetTxDescOffset; - } -void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) +static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) { u16 *usPtr = (u16*)ptxdesc; u32 count = 16; // (32 bytes / 2 bytes per XOR) => 16 times @@ -93,12 +71,9 @@ void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) //Clear first ptxdesc->txdw7 &= cpu_to_le32(0xffff0000); - for (index = 0 ; index < count ; index++){ + for (index = 0; index < count; index++) checksum = checksum ^ le16_to_cpu(*(usPtr + index)); - } - ptxdesc->txdw7 |= cpu_to_le32(0x0000ffff&checksum); - } // // Description: In normal chip, we should send some packet to Hw which will be used by Fw @@ -155,66 +130,55 @@ void rtl8188e_fill_fake_txdesc( #endif } -void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxdesc) +static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxdesc) { - if ((pattrib->encrypt > 0) && !pattrib->bswenc) - { - switch (pattrib->encrypt) - { - //SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES - case _WEP40_: - case _WEP104_: - ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); - break; - case _TKIP_: - case _TKIP_WTMIC_: - ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); - break; + if ((pattrib->encrypt > 0) && !pattrib->bswenc) { + switch (pattrib->encrypt) { + //SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES + case _WEP40_: + case _WEP104_: + ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; + case _TKIP_: + case _TKIP_WTMIC_: + ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; #ifdef CONFIG_WAPI_SUPPORT - case _SMS4_: - ptxdesc->txdw1 |= cpu_to_le32((0x02<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); - break; + case _SMS4_: + ptxdesc->txdw1 |= cpu_to_le32((0x02<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; #endif - case _AES_: - ptxdesc->txdw1 |= cpu_to_le32((0x03<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); - break; - case _NO_PRIVACY_: - default: - break; - - } - - } - -} - -void fill_txdesc_vcs(struct pkt_attrib *pattrib, u32 *pdw) -{ - //DBG_88E("cvs_mode=%d\n", pattrib->vcs_mode); - - switch (pattrib->vcs_mode) - { - case RTS_CTS: - *pdw |= cpu_to_le32(RTS_EN); + case _AES_: + ptxdesc->txdw1 |= cpu_to_le32((0x03<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; - case CTS_TO_SELF: - *pdw |= cpu_to_le32(CTS_2_SELF); - break; - case NONE_VCS: + case _NO_PRIVACY_: default: break; + } } +} +static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) +{ + switch (pattrib->vcs_mode) { + case RTS_CTS: + *pdw |= cpu_to_le32(RTS_EN); + break; + case CTS_TO_SELF: + *pdw |= cpu_to_le32(CTS_2_SELF); + break; + case NONE_VCS: + default: + break; + } if (pattrib->vcs_mode) { *pdw |= cpu_to_le32(HW_RTS_EN); - // Set RTS BW - if (pattrib->ht_en) - { + if (pattrib->ht_en) { *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40)? cpu_to_le32(BIT(27)):0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) @@ -229,12 +193,9 @@ void fill_txdesc_vcs(struct pkt_attrib *pattrib, u32 *pdw) } } -void fill_txdesc_phy(struct pkt_attrib *pattrib, u32 *pdw) +static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) { - //DBG_88E("bwmode=%d, ch_off=%d\n", pattrib->bwmode, pattrib->ch_offset); - - if (pattrib->ht_en) - { + if (pattrib->ht_en) { *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40)? cpu_to_le32(BIT(25)):0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) @@ -347,7 +308,7 @@ if (padapter->registrypriv.mp_mode == 0) //SET_TX_DESC_MCSG2_MAX_LEN_88E(pDesc, 0x6); //SET_TX_DESC_MCSG3_MAX_LEN_88E(pDesc, 0x6); //SET_TX_DESC_MCS7_SGI_MAX_LEN_88E(pDesc, 0x6); - ptxdesc->txdw6 = 0x6666f800; + ptxdesc->txdw6 = cpu_to_le32(0x6666f800); } else{ ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);//AGG BK diff --git a/include/rtw_xmit.h b/include/rtw_xmit.h index 98f54aa..73a7cc5 100644 --- a/include/rtw_xmit.h +++ b/include/rtw_xmit.h @@ -168,42 +168,14 @@ do{\ struct tx_desc{ //DWORD 0 - unsigned int txdw0; - - unsigned int txdw1; - - unsigned int txdw2; - - unsigned int txdw3; - - unsigned int txdw4; - - unsigned int txdw5; - - unsigned int txdw6; - - unsigned int txdw7; -#ifdef CONFIG_PCI_HCI - unsigned int txdw8; - - unsigned int txdw9; - - unsigned int txdw10; - - unsigned int txdw11; - - // 2008/05/15 MH Because PCIE HW memory R/W 4K limit. And now, our descriptor - // size is 40 bytes. If you use more than 102 descriptor( 103*40>4096), HW will execute - // memoryR/W CRC error. And then all DMA fetch will fail. We must decrease descriptor - // number or enlarge descriptor size as 64 bytes. - unsigned int txdw12; - - unsigned int txdw13; - - unsigned int txdw14; - - unsigned int txdw15; -#endif + __le32 txdw0; + __le32 txdw1; + __le32 txdw2; + __le32 txdw3; + __le32 txdw4; + __le32 txdw5; + __le32 txdw6; + __le32 txdw7; }; diff --git a/os_dep/rtw_android.c b/os_dep/rtw_android.c index 5ad3419..9c16399 100644 --- a/os_dep/rtw_android.c +++ b/os_dep/rtw_android.c @@ -37,7 +37,7 @@ #endif #endif /* defined(RTW_ENABLE_WIFI_CONTROL_FUNC) */ -const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = { +static const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = { "START", "STOP", "SCAN-ACTIVE", @@ -237,7 +237,7 @@ int rtw_android_cmdstr_to_num(char *cmdstr) return cmd_num; } -int rtw_android_get_rssi(struct net_device *net, char *command, int total_len) +static int rtw_android_get_rssi(struct net_device *net, char *command, int total_len) { _adapter *padapter = (_adapter *)rtw_netdev_priv(net); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -252,7 +252,7 @@ int rtw_android_get_rssi(struct net_device *net, char *command, int total_len) return bytes_written; } -int rtw_android_get_link_speed(struct net_device *net, char *command, int total_len) +static int rtw_android_get_link_speed(struct net_device *net, char *command, int total_len) { _adapter *padapter = (_adapter *)rtw_netdev_priv(net); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -266,7 +266,7 @@ int rtw_android_get_link_speed(struct net_device *net, char *command, int total_ return bytes_written; } -int rtw_android_get_macaddr(struct net_device *net, char *command, int total_len) +static int rtw_android_get_macaddr(struct net_device *net, char *command, int total_len) { _adapter *adapter = (_adapter *)rtw_netdev_priv(net); int bytes_written = 0; @@ -275,7 +275,7 @@ int rtw_android_get_macaddr(struct net_device *net, char *command, int total_len return bytes_written; } -int rtw_android_set_country(struct net_device *net, char *command, int total_len) +static int rtw_android_set_country(struct net_device *net, char *command, int total_len) { _adapter *adapter = (_adapter *)rtw_netdev_priv(net); char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1; @@ -286,7 +286,7 @@ int rtw_android_set_country(struct net_device *net, char *command, int total_len return (ret==_SUCCESS)?0:-1; } -int rtw_android_get_p2p_dev_addr(struct net_device *net, char *command, int total_len) +static int rtw_android_get_p2p_dev_addr(struct net_device *net, char *command, int total_len) { int ret; int bytes_written = 0; @@ -298,7 +298,7 @@ int rtw_android_get_p2p_dev_addr(struct net_device *net, char *command, int tota return bytes_written; } -int rtw_android_set_block(struct net_device *net, char *command, int total_len) +static int rtw_android_set_block(struct net_device *net, char *command, int total_len) { int ret; _adapter *adapter = (_adapter *)rtw_netdev_priv(net); @@ -311,7 +311,7 @@ int rtw_android_set_block(struct net_device *net, char *command, int total_len) return 0; } -int get_int_from_command( char* pcmd ) +static int get_int_from_command( char* pcmd ) { int i = 0; @@ -346,7 +346,6 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) goto exit; } - //DBG_88E("%s priv_cmd.buf=%p priv_cmd.total_len=%d priv_cmd.used_len=%d\n",__func__,priv_cmd.buf,priv_cmd.total_len,priv_cmd.used_len); command = kmalloc(priv_cmd.total_len, GFP_KERNEL); if (!command) { @@ -568,17 +567,13 @@ response: DBG_88E("%s: failed to copy data to user buffer\n", __func__); ret = -EFAULT; } - } - else { + } else { ret = bytes_written; } - exit: rtw_unlock_suspend(); - if (command) { + if (command) kfree(command); - } - return ret; }