Skip to content

Commit

Permalink
staging: rtl8188eu:Remove rtw_zmalloc(), wrapper for kzalloc()
Browse files Browse the repository at this point in the history
Signed-off-by: navin patidar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
navin-patidar authored and gregkh committed Jun 27, 2014
1 parent a733e46 commit fadbe0c
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 119 deletions.
124 changes: 62 additions & 62 deletions drivers/staging/rtl8188eu/core/rtw_cmd.c

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions drivers/staging/rtl8188eu/core/rtw_efuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf)
u16 efuse_utilized = 0;
u8 u1temp = 0;

efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E);
efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
if (efuseTbl == NULL) {
DBG_88E("%s: alloc efuseTbl fail!\n", __func__);
goto exit;
Expand Down Expand Up @@ -1083,7 +1083,7 @@ u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data)
if ((addr + cnts) > mapLen)
return _FAIL;

map = rtw_zmalloc(mapLen);
map = kzalloc(mapLen, GFP_KERNEL);
if (map == NULL)
return _FAIL;

Expand Down
8 changes: 4 additions & 4 deletions drivers/staging/rtl8188eu/core/rtw_mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,13 +1666,13 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
struct cmd_priv *pcmdpriv = &(adapter->cmdpriv);
int res = _SUCCESS;

pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd == NULL) {
res = _FAIL; /* try again */
goto exit;
}

psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm));
psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL);
if (psetauthparm == NULL) {
kfree(pcmd);
res = _FAIL;
Expand Down Expand Up @@ -1703,11 +1703,11 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
int res = _SUCCESS;

pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd == NULL)
return _FAIL; /* try again */

psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm));
psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
if (psetkeyparm == NULL) {
res = _FAIL;
goto err_free_cmd;
Expand Down
28 changes: 14 additions & 14 deletions drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -7055,12 +7055,12 @@ void report_survey_event(struct adapter *padapter,
pcmdpriv = &padapter->cmdpriv;


pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd_obj == NULL)
return;

cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz);
pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (pevtcmd == NULL) {
kfree(pcmd_obj);
return;
Expand Down Expand Up @@ -7107,12 +7107,12 @@ void report_surveydone_event(struct adapter *padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;

pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd_obj == NULL)
return;

cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz);
pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (pevtcmd == NULL) {
kfree(pcmd_obj);
return;
Expand Down Expand Up @@ -7153,12 +7153,12 @@ void report_join_res(struct adapter *padapter, int res)
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;

pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd_obj == NULL)
return;

cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz);
pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (pevtcmd == NULL) {
kfree(pcmd_obj);
return;
Expand Down Expand Up @@ -7206,12 +7206,12 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;

pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd_obj == NULL)
return;

cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz);
pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (pevtcmd == NULL) {
kfree(pcmd_obj);
return;
Expand Down Expand Up @@ -7261,12 +7261,12 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;

pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd_obj == NULL)
return;

cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
pevtcmd = (u8 *)rtw_zmalloc(cmdsz);
pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (pevtcmd == NULL) {
kfree(pcmd_obj);
return;
Expand Down Expand Up @@ -7686,11 +7686,11 @@ void survey_timer_hdl(struct adapter *padapter)
pmlmeext->scan_abort = false;/* reset */
}

ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (ph2c == NULL)
goto exit_survey_timer_hdl;

psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm));
psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_KERNEL);
if (psurveyPara == NULL) {
kfree(ph2c);
goto exit_survey_timer_hdl;
Expand Down Expand Up @@ -8268,13 +8268,13 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
int len_diff = 0;


ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (ph2c == NULL) {
res = _FAIL;
goto exit;
}

ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param));
ptxBeacon_parm = kzalloc(sizeof(struct Tx_Beacon_param), GFP_KERNEL);
if (ptxBeacon_parm == NULL) {
kfree(ph2c);
res = _FAIL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/rtl8188eu/core/rtw_mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ void SetPacketTx(struct adapter *padapter)
kfree(pmp_priv->tx.pallocated_buf);
pmp_priv->tx.write_size = pkt_size;
pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ;
pmp_priv->tx.pallocated_buf = rtw_zmalloc(pmp_priv->tx.buf_size);
pmp_priv->tx.pallocated_buf = kzalloc(pmp_priv->tx.buf_size, GFP_KERNEL);
if (pmp_priv->tx.pallocated_buf == NULL) {
DBG_88E("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size);
return;
Expand Down
8 changes: 4 additions & 4 deletions drivers/staging/rtl8188eu/core/rtw_p2p.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)

DBG_88E("%s\n", __func__);

pdata_attr = rtw_zmalloc(MAX_P2P_IE_LEN);
pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_KERNEL);

pstart = pdata_attr;
pcur = pdata_attr;
Expand Down Expand Up @@ -891,7 +891,7 @@ u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l
/* Check P2P Device Info ATTR */
if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint *)&attr_contentlen)) {
DBG_88E("[%s] Got P2P DEVICE INFO Attr!!\n", __func__);
pattr_content = rtw_zmalloc(attr_contentlen);
pattr_content = kzalloc(attr_contentlen, GFP_KERNEL);
pbuf = pattr_content;
if (pattr_content) {
u8 num_of_secdev_type;
Expand Down Expand Up @@ -1738,13 +1738,13 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue)
return res;

if (enqueue) {
ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (ph2c == NULL) {
res = _FAIL;
goto exit;
}

pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
if (pdrvextra_cmd_parm == NULL) {
kfree(ph2c);
res = _FAIL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/rtl8188eu/core/rtw_wlan_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
return true;
}

bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex));
bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_KERNEL);

subtype = GetFrameSubType(pframe) >> 4;

Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/rtl8188eu/core/rtw_xmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter)

pxmitpriv->hwxmit_entry = HWXMIT_ENTRY;

pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry);
pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL);

hwxmits = pxmitpriv->hwxmits;

Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished)
struct rsvdpage_loc RsvdPageLoc;

DBG_88E("%s\n", __func__);
ReservedPagePacket = (u8 *)rtw_zmalloc(1000);
ReservedPagePacket = kzalloc(1000, GFP_KERNEL);
if (ReservedPagePacket == NULL) {
DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__);
return;
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter)
/* init recv_buf */
_rtw_init_queue(&precvpriv->free_recv_buf_queue);

precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4);
precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, GFP_KERNEL);
if (precvpriv->pallocated_recv_buf == NULL) {
res = _FAIL;
RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n"));
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/rtl8188eu/hal/usb_halinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ void rtl8188eu_set_hal_ops(struct adapter *adapt)
struct hal_ops *halfunc = &adapt->HalFunc;


adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e));
adapt->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL);
if (adapt->HalData == NULL)
DBG_88E("cant not alloc memory for HAL DATA\n");

Expand Down
2 changes: 0 additions & 2 deletions drivers/staging/rtl8188eu/include/osdep_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,9 @@ extern unsigned char WPA_TKIP_CIPHER[4];
extern unsigned char RSN_TKIP_CIPHER[4];

#define rtw_update_mem_stat(flag, sz) do {} while (0)
u8 *_rtw_zmalloc(u32 sz);
u8 *_rtw_malloc(u32 sz);
void _rtw_mfree(u8 *pbuf, u32 sz);
#define rtw_malloc(sz) _rtw_malloc((sz))
#define rtw_zmalloc(sz) _rtw_zmalloc((sz))
#define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz))

void *rtw_malloc2d(int h, int w, int size);
Expand Down
24 changes: 12 additions & 12 deletions drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
}

if (ielen) {
buf = rtw_zmalloc(ielen);
buf = kzalloc(ielen, GFP_KERNEL);
if (buf == NULL) {
ret = -ENOMEM;
goto exit;
Expand Down Expand Up @@ -4721,13 +4721,13 @@ static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta)
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
u8 res = _SUCCESS;

ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (ph2c == NULL) {
res = _FAIL;
goto exit;
}

psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm));
psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL);
if (psetstakey_para == NULL) {
kfree(ph2c);
res = _FAIL;
Expand Down Expand Up @@ -4759,12 +4759,12 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid)

DBG_88E("%s\n", __func__);

pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd == NULL) {
res = _FAIL;
goto exit;
}
psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm));
psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
if (psetkeyparm == NULL) {
kfree(pcmd);
res = _FAIL;
Expand Down Expand Up @@ -5672,12 +5672,12 @@ static int rtw_mp_efuse_get(struct net_device *dev,
pEfuseHal = &haldata->EfuseHal;

err = 0;
data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN);
data = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL);
if (data == NULL) {
err = -ENOMEM;
goto exit;
}
rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN);
rawdata = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL);
if (rawdata == NULL) {
err = -ENOMEM;
goto exit;
Expand Down Expand Up @@ -5916,7 +5916,7 @@ static int rtw_mp_efuse_set(struct net_device *dev,
haldata = GET_HAL_DATA(padapter);
pEfuseHal = &haldata->EfuseHal;
err = 0;
setdata = _rtw_zmalloc(1024);
setdata = kzalloc(1024, GFP_KERNEL);
if (setdata == NULL) {
err = -ENOMEM;
goto exit;
Expand Down Expand Up @@ -7438,7 +7438,7 @@ static int rtw_test(
DBG_88E("+%s\n", __func__);
len = wrqu->data.length;

pbuf = (u8 *)rtw_zmalloc(len);
pbuf = kzalloc(len, GFP_KERNEL);
if (pbuf == NULL) {
DBG_88E("%s: no memory!\n", __func__);
return -ENOMEM;
Expand Down Expand Up @@ -7783,7 +7783,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
memcpy(&wdata, wrq_data, sizeof(wdata));

input_len = wdata.data.length;
input = rtw_zmalloc(input_len);
input = kzalloc(input_len, GFP_KERNEL);
if (NULL == input)
return -ENOMEM;
if (copy_from_user(input, wdata.data.pointer, input_len)) {
Expand Down Expand Up @@ -7850,7 +7850,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
k = j;
}

buffer = rtw_zmalloc(4096);
buffer = kzalloc(4096, GFP_KERNEL);
if (NULL == buffer) {
err = -ENOMEM;
goto exit;
Expand Down Expand Up @@ -7999,7 +7999,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
else
n = wdata.data.length;

output = rtw_zmalloc(4096);
output = kzalloc(4096, GFP_KERNEL);
if (NULL == output) {
err = -ENOMEM;
goto exit;
Expand Down
11 changes: 1 addition & 10 deletions drivers/staging/rtl8188eu/os_dep/osdep_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,11 @@ u8 *_rtw_malloc(u32 sz)
return pbuf;
}

u8 *_rtw_zmalloc(u32 sz)
{
u8 *pbuf = _rtw_malloc(sz);

if (pbuf != NULL)
memset(pbuf, 0, sz);
return pbuf;
}

void *rtw_malloc2d(int h, int w, int size)
{
int j;

void **a = (void **)rtw_zmalloc(h*sizeof(void *) + h*w*size);
void **a = (void **)kzalloc(h*sizeof(void *) + h*w*size, GFP_KERNEL);
if (a == NULL) {
pr_info("%s: alloc memory fail!\n", __func__);
return NULL;
Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/rtl8188eu/os_dep/usb_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
struct usb_device *pusbd;


pdvobjpriv = (struct dvobj_priv *)rtw_zmalloc(sizeof(*pdvobjpriv));
pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL);
if (pdvobjpriv == NULL)
goto exit;

Expand Down Expand Up @@ -116,7 +116,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
pdvobjpriv->ishighspeed = false;

mutex_init(&pdvobjpriv->usb_vendor_req_mutex);
pdvobjpriv->usb_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE);
pdvobjpriv->usb_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, GFP_KERNEL);

if (!pdvobjpriv->usb_vendor_req_buf)
goto free_dvobj;
Expand Down
Loading

0 comments on commit fadbe0c

Please sign in to comment.