mirror of
https://github.com/Mange/rtl8192eu-linux-driver
synced 2024-11-01 03:05:34 +00:00
convert all rtw_zvmalloc calls to vzalloc calls
Convert all rtw_zvmalloc calls within the driver to use the existing kernel vzalloc function, which has the same semantics. Also rewrite the two places where it is mentioned in comments to say vzalloc, and remove the redundant cast to struct adapter * in ./os_dep/usb_intf.c as vzalloc returns void *. The reason for the conversion is that rtw_zvmalloc is just a preprocessor definition for _rtw_zvmalloc which itself is just an inline wrapper around vmalloc which then zeroes the memory out. As vzalloc does the same thing via usage of __GFP_ZERO, this code is redundant and can subsequently be removed. Link: https://lore.kernel.org/r/20210818234853.208448-5-phil@philpotter.co.uk
This commit is contained in:
parent
1f0cf855dc
commit
2a467a7923
@ -1077,7 +1077,7 @@ void dump_mesh_networks(void *sel, _adapter *adapter)
|
||||
u8 mesh_network_cnt = 0;
|
||||
int i;
|
||||
|
||||
mesh_networks = rtw_zvmalloc(mlme->max_bss_cnt * sizeof(struct wlan_network *));
|
||||
mesh_networks = vzalloc(mlme->max_bss_cnt * sizeof(struct wlan_network *));
|
||||
if (!mesh_networks)
|
||||
return;
|
||||
|
||||
|
@ -47,7 +47,7 @@ sint _rtw_init_mlme_priv(_adapter *padapter)
|
||||
sint res = _SUCCESS;
|
||||
|
||||
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
|
||||
/* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ sint _rtw_init_mlme_priv(_adapter *padapter)
|
||||
pmlmepriv->max_bss_cnt = MAX_BSS_CNT + MAX_BSS_CNT;
|
||||
|
||||
|
||||
pbuf = rtw_zvmalloc(pmlmepriv->max_bss_cnt * (sizeof(struct wlan_network)));
|
||||
pbuf = vzalloc(pmlmepriv->max_bss_cnt * (sizeof(struct wlan_network)));
|
||||
|
||||
if (pbuf == NULL) {
|
||||
res = _FAIL;
|
||||
|
@ -1130,7 +1130,7 @@ int init_mlme_ext_priv(_adapter *padapter)
|
||||
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
||||
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
||||
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
|
||||
/* memset((u8 *)pmlmeext, 0, sizeof(struct mlme_ext_priv)); */
|
||||
|
||||
pmlmeext->padapter = padapter;
|
||||
|
@ -2505,7 +2505,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv)
|
||||
/* Init xmit extension buff */
|
||||
_rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue);
|
||||
|
||||
pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
|
||||
pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
|
||||
|
||||
if (pxmitpriv->pallocated_xmit_extbuf == NULL) {
|
||||
res = _FAIL;
|
||||
|
@ -80,7 +80,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, _adapter *padapter)
|
||||
sint res = _SUCCESS;
|
||||
|
||||
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
|
||||
/* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */
|
||||
|
||||
_rtw_spinlock_init(&precvpriv->lock);
|
||||
@ -110,7 +110,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, _adapter *padapter)
|
||||
|
||||
rtw_os_recv_resource_init(precvpriv, padapter);
|
||||
|
||||
precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ);
|
||||
precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ);
|
||||
|
||||
if (precvpriv->pallocated_frame_buf == NULL) {
|
||||
res = _FAIL;
|
||||
|
@ -1056,7 +1056,7 @@ void rtw_txpwr_lmt_add_with_nlen(struct rf_ctl_t *rfctl, const char *regd_name,
|
||||
}
|
||||
|
||||
/* alloc new one */
|
||||
ent = (struct txpwr_lmt_ent *)rtw_zvmalloc(sizeof(struct txpwr_lmt_ent) + nlen + 1);
|
||||
ent = (struct txpwr_lmt_ent *)vzalloc(sizeof(struct txpwr_lmt_ent) + nlen + 1);
|
||||
if (!ent)
|
||||
goto release_lock;
|
||||
|
||||
|
@ -237,7 +237,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv)
|
||||
|
||||
pstapriv->padapter = adapter;
|
||||
|
||||
pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA + 4);
|
||||
pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4);
|
||||
if (!pstapriv->pallocated_stainfo_buf)
|
||||
goto exit;
|
||||
|
||||
|
@ -71,7 +71,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter)
|
||||
sint res = _SUCCESS;
|
||||
|
||||
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
|
||||
/* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */
|
||||
|
||||
_rtw_spinlock_init(&pxmitpriv->lock);
|
||||
@ -104,7 +104,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter)
|
||||
Please also apply free_txobj to link_up all the xmit_frames...
|
||||
*/
|
||||
|
||||
pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
|
||||
pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
|
||||
|
||||
if (pxmitpriv->pallocated_frame_buf == NULL) {
|
||||
pxmitpriv->pxmit_frame_buf = NULL;
|
||||
@ -142,7 +142,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter)
|
||||
_rtw_init_queue(&pxmitpriv->free_xmitbuf_queue);
|
||||
_rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue);
|
||||
|
||||
pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
|
||||
pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
|
||||
|
||||
if (pxmitpriv->pallocated_xmitbuf == NULL) {
|
||||
res = _FAIL;
|
||||
@ -194,7 +194,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter)
|
||||
/* init xframe_ext queue, the same count as extbuf */
|
||||
_rtw_init_queue(&pxmitpriv->free_xframe_ext_queue);
|
||||
|
||||
pxmitpriv->xframe_ext_alloc_addr = rtw_zvmalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_frame) + 4);
|
||||
pxmitpriv->xframe_ext_alloc_addr = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_frame) + 4);
|
||||
|
||||
if (pxmitpriv->xframe_ext_alloc_addr == NULL) {
|
||||
pxmitpriv->xframe_ext = NULL;
|
||||
@ -226,7 +226,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter)
|
||||
/* Init xmit extension buff */
|
||||
_rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue);
|
||||
|
||||
pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4);
|
||||
pxmitpriv->pallocated_xmit_extbuf = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4);
|
||||
|
||||
if (pxmitpriv->pallocated_xmit_extbuf == NULL) {
|
||||
res = _FAIL;
|
||||
|
@ -4696,7 +4696,7 @@ void rtw_dump_rsvd_page(void *sel, _adapter *adapter, u8 page_offset, u8 page_nu
|
||||
rtw_hal_get_def_var(adapter, HAL_DEF_TX_PAGE_SIZE, &page_size);
|
||||
if (page_size) {
|
||||
buf_size = page_size * page_num;
|
||||
buffer = rtw_zvmalloc(buf_size);
|
||||
buffer = vzalloc(buf_size);
|
||||
|
||||
if (buffer) {
|
||||
rtw_hal_get_rsvd_page(adapter, page_offset, page_num, buffer, buf_size);
|
||||
@ -4729,7 +4729,7 @@ void rtw_dump_fifo(void *sel, _adapter *adapter, u8 fifo_sel, u32 fifo_addr, u32
|
||||
|
||||
if (fifo_size) {
|
||||
buff_size = RND4(fifo_size);
|
||||
buffer = rtw_zvmalloc(buff_size);
|
||||
buffer = vzalloc(buff_size);
|
||||
if (buffer == NULL)
|
||||
buff_size = 0;
|
||||
}
|
||||
@ -5190,7 +5190,7 @@ static void rtw_hal_get_aoac_rpt(_adapter *adapter)
|
||||
rtw_hal_get_def_var(adapter, HAL_DEF_TX_PAGE_SIZE, &page_size);
|
||||
buf_size = page_size * page_number;
|
||||
|
||||
buffer = rtw_zvmalloc(buf_size);
|
||||
buffer = vzalloc(buf_size);
|
||||
|
||||
if (buffer == NULL) {
|
||||
RTW_ERR("%s buffer allocate failed size(%d)\n",
|
||||
|
@ -4092,7 +4092,7 @@ phy_ConfigMACWithParaFile(
|
||||
rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
|
||||
if (rlen > 0) {
|
||||
rtStatus = _SUCCESS;
|
||||
pHalData->mac_reg = rtw_zvmalloc(rlen);
|
||||
pHalData->mac_reg = vzalloc(rlen);
|
||||
if (pHalData->mac_reg) {
|
||||
_rtw_memcpy(pHalData->mac_reg, pHalData->para_file_buf, rlen);
|
||||
pHalData->mac_reg_len = rlen;
|
||||
@ -4171,7 +4171,7 @@ phy_ConfigBBWithParaFile(
|
||||
rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
|
||||
if (rlen > 0) {
|
||||
rtStatus = _SUCCESS;
|
||||
pBuf = rtw_zvmalloc(rlen);
|
||||
pBuf = vzalloc(rlen);
|
||||
if (pBuf) {
|
||||
_rtw_memcpy(pBuf, pHalData->para_file_buf, rlen);
|
||||
*pBufLen = rlen;
|
||||
@ -4477,7 +4477,7 @@ phy_ConfigBBWithPgParaFile(
|
||||
rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
|
||||
if (rlen > 0) {
|
||||
rtStatus = _SUCCESS;
|
||||
pHalData->bb_phy_reg_pg = rtw_zvmalloc(rlen);
|
||||
pHalData->bb_phy_reg_pg = vzalloc(rlen);
|
||||
if (pHalData->bb_phy_reg_pg) {
|
||||
_rtw_memcpy(pHalData->bb_phy_reg_pg, pHalData->para_file_buf, rlen);
|
||||
pHalData->bb_phy_reg_pg_len = rlen;
|
||||
@ -4526,7 +4526,7 @@ phy_ConfigBBWithMpParaFile(
|
||||
rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
|
||||
if (rlen > 0) {
|
||||
rtStatus = _SUCCESS;
|
||||
pHalData->bb_phy_reg_mp = rtw_zvmalloc(rlen);
|
||||
pHalData->bb_phy_reg_mp = vzalloc(rlen);
|
||||
if (pHalData->bb_phy_reg_mp) {
|
||||
_rtw_memcpy(pHalData->bb_phy_reg_mp, pHalData->para_file_buf, rlen);
|
||||
pHalData->bb_phy_reg_mp_len = rlen;
|
||||
@ -4630,7 +4630,7 @@ PHY_ConfigRFWithParaFile(
|
||||
rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
|
||||
if (rlen > 0) {
|
||||
rtStatus = _SUCCESS;
|
||||
pBuf = rtw_zvmalloc(rlen);
|
||||
pBuf = vzalloc(rlen);
|
||||
if (pBuf) {
|
||||
_rtw_memcpy(pBuf, pHalData->para_file_buf, rlen);
|
||||
*pBufLen = rlen;
|
||||
@ -4829,7 +4829,7 @@ PHY_ConfigRFWithTxPwrTrackParaFile(
|
||||
rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
|
||||
if (rlen > 0) {
|
||||
rtStatus = _SUCCESS;
|
||||
pHalData->rf_tx_pwr_track = rtw_zvmalloc(rlen);
|
||||
pHalData->rf_tx_pwr_track = vzalloc(rlen);
|
||||
if (pHalData->rf_tx_pwr_track) {
|
||||
_rtw_memcpy(pHalData->rf_tx_pwr_track, pHalData->para_file_buf, rlen);
|
||||
pHalData->rf_tx_pwr_track_len = rlen;
|
||||
@ -5328,7 +5328,7 @@ PHY_ConfigRFWithPowerLimitTableParaFile(
|
||||
rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
|
||||
if (rlen > 0) {
|
||||
rtStatus = _SUCCESS;
|
||||
pHalData->rf_tx_pwr_lmt = rtw_zvmalloc(rlen);
|
||||
pHalData->rf_tx_pwr_lmt = vzalloc(rlen);
|
||||
if (pHalData->rf_tx_pwr_lmt) {
|
||||
_rtw_memcpy(pHalData->rf_tx_pwr_lmt, pHalData->para_file_buf, rlen);
|
||||
pHalData->rf_tx_pwr_lmt_len = rlen;
|
||||
|
@ -4388,7 +4388,7 @@ int rtw_halmac_dump_fifo(struct dvobj_priv *d, u8 fifo_sel, u32 addr, u32 size,
|
||||
fifo_size = api->halmac_get_fifo_size(mac, halmac_fifo_sel);
|
||||
|
||||
if (fifo_size)
|
||||
pfifo_map = rtw_zvmalloc(fifo_size);
|
||||
pfifo_map = vzalloc(fifo_size);
|
||||
if (pfifo_map == NULL)
|
||||
return -1;
|
||||
mem_created = _TRUE;
|
||||
|
@ -147,7 +147,7 @@ u8 rtw_hal_data_init(_adapter *padapter)
|
||||
{
|
||||
if (is_primary_adapter(padapter)) {
|
||||
padapter->hal_data_sz = sizeof(HAL_DATA_TYPE);
|
||||
padapter->HalData = rtw_zvmalloc(padapter->hal_data_sz);
|
||||
padapter->HalData = vzalloc(padapter->hal_data_sz);
|
||||
if (padapter->HalData == NULL) {
|
||||
RTW_INFO("cant not alloc memory for HAL DATA\n");
|
||||
return _FAIL;
|
||||
|
@ -370,12 +370,12 @@ void odm_allocate_memory(struct dm_struct *dm, void **ptr, u32 length)
|
||||
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
|
||||
*ptr = kmalloc(length, GFP_ATOMIC);
|
||||
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
|
||||
*ptr = rtw_zvmalloc(length);
|
||||
*ptr = vzalloc(length);
|
||||
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
|
||||
void *adapter = dm->adapter;
|
||||
PlatformAllocateMemory(adapter, ptr, length);
|
||||
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
|
||||
*ptr = rtw_zvmalloc(length);
|
||||
*ptr = vzalloc(length);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2396,7 +2396,7 @@ u8 rtw_init_drv_sw(_adapter *padapter)
|
||||
/* add for CONFIG_IEEE80211W, none 11w also can use */
|
||||
_rtw_spinlock_init(&padapter->security_key_mutex);
|
||||
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */
|
||||
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
|
||||
/* memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv)); */
|
||||
|
||||
if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) {
|
||||
@ -2805,7 +2805,7 @@ _adapter *rtw_drv_add_vir_if(_adapter *primary_padapter,
|
||||
u8 mac[ETH_ALEN];
|
||||
|
||||
/****** init adapter ******/
|
||||
padapter = (_adapter *)rtw_zvmalloc(sizeof(*padapter));
|
||||
padapter = (_adapter *)vzalloc(sizeof(*padapter));
|
||||
if (padapter == NULL)
|
||||
goto exit;
|
||||
|
||||
|
@ -1270,7 +1270,7 @@ _adapter *rtw_usb_primary_adapter_init(struct dvobj_priv *dvobj,
|
||||
_adapter *padapter = NULL;
|
||||
int status = _FAIL;
|
||||
|
||||
padapter = (_adapter *)rtw_zvmalloc(sizeof(*padapter));
|
||||
padapter = (_adapter *)vzalloc(sizeof(*padapter));
|
||||
if (padapter == NULL)
|
||||
goto exit;
|
||||
|
||||
|
@ -2028,7 +2028,7 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv)
|
||||
|
||||
pnpi = netdev_priv(pnetdev);
|
||||
|
||||
pnpi->priv = rtw_zvmalloc(sizeof_priv);
|
||||
pnpi->priv = vzalloc(sizeof_priv);
|
||||
if (!pnpi->priv) {
|
||||
free_netdev(pnetdev);
|
||||
pnetdev = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user