Skip to content

Commit 9577f3b

Browse files
Jminugregkh
authored andcommitted
staging: rtl8723bs: replace rtw_malloc() with kmalloc()
Replace the wrapper function rtw_malloc() with standard kmalloc(). Call sites were reviewed to use appropriate GFP flags (GFP_KERNEL or GFP_ATOMIC) based on the execution context. About GFP Flags: - GFP_ATOMIC is used for allocations in atomic contexts such as spinlock-protected sections, tasklets, and timer handlers. - GFP_KERNEL is used for process contexts where sleeping is allowed. Also, convert error return codes from -1 to -ENOMEM where appropriate. Signed-off-by: Minu Jin <s9430939@naver.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Link: https://patch.msgid.link/20260204131347.3515949-3-s9430939@naver.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5ed9ef2 commit 9577f3b

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

drivers/staging/rtl8723bs/core/rtw_cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ static void c2h_wk_callback(struct work_struct *work)
16951695
/* This C2H event is read, clear it */
16961696
c2h_evt_clear(adapter);
16971697
} else {
1698-
c2h_evt = rtw_malloc(16);
1698+
c2h_evt = kmalloc(16, GFP_ATOMIC);
16991699
if (c2h_evt) {
17001700
/* This C2H event is not read, read & clear now */
17011701
if (c2h_evt_read_88xx(adapter, c2h_evt) != _SUCCESS) {

drivers/staging/rtl8723bs/core/rtw_mlme_ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
586586
if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) {
587587
if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
588588
/* we should update current network before auth, or some IE is wrong */
589-
pbss = rtw_malloc(sizeof(struct wlan_bssid_ex));
589+
pbss = kmalloc(sizeof(*pbss), GFP_ATOMIC);
590590
if (pbss) {
591591
if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) {
592592
update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true);

drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ static void hal_ReadEFuse_WiFi(
640640
if ((_offset + _size_byte) > EFUSE_MAX_MAP_LEN)
641641
return;
642642

643-
efuseTbl = rtw_malloc(EFUSE_MAX_MAP_LEN);
643+
efuseTbl = kmalloc(EFUSE_MAX_MAP_LEN, GFP_ATOMIC);
644644
if (!efuseTbl)
645645
return;
646646

@@ -728,7 +728,7 @@ static void hal_ReadEFuse_BT(
728728
if ((_offset + _size_byte) > EFUSE_BT_MAP_LEN)
729729
return;
730730

731-
efuseTbl = rtw_malloc(EFUSE_BT_MAP_LEN);
731+
efuseTbl = kmalloc(EFUSE_BT_MAP_LEN, GFP_ATOMIC);
732732
if (!efuseTbl)
733733
return;
734734

drivers/staging/rtl8723bs/hal/sdio_ops.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
181181
} else {
182182
u8 *tmpbuf;
183183

184-
tmpbuf = rtw_malloc(8);
184+
tmpbuf = kmalloc(8, GFP_ATOMIC);
185185
if (!tmpbuf)
186186
return SDIO_ERR_VAL32;
187187

@@ -228,9 +228,9 @@ static s32 sdio_readN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf)
228228

229229
ftaddr &= ~(u16)0x3;
230230
n = cnt + shift;
231-
tmpbuf = rtw_malloc(n);
231+
tmpbuf = kmalloc(n, GFP_ATOMIC);
232232
if (!tmpbuf)
233-
return -1;
233+
return -ENOMEM;
234234

235235
err = sd_read(intfhdl, ftaddr, n, tmpbuf);
236236
if (!err)
@@ -331,9 +331,9 @@ static s32 sdio_writeN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf)
331331

332332
ftaddr &= ~(u16)0x3;
333333
n = cnt + shift;
334-
tmpbuf = rtw_malloc(n);
334+
tmpbuf = kmalloc(n, GFP_ATOMIC);
335335
if (!tmpbuf)
336-
return -1;
336+
return -ENOMEM;
337337
err = sd_read(intfhdl, ftaddr, 4, tmpbuf);
338338
if (err) {
339339
kfree(tmpbuf);
@@ -503,9 +503,9 @@ static s32 _sdio_local_read(
503503
return _sd_cmd52_read(intfhdl, addr, cnt, buf);
504504

505505
n = round_up(cnt, 4);
506-
tmpbuf = rtw_malloc(n);
506+
tmpbuf = kmalloc(n, GFP_ATOMIC);
507507
if (!tmpbuf)
508-
return -1;
508+
return -ENOMEM;
509509

510510
err = _sd_read(intfhdl, addr, n, tmpbuf);
511511
if (!err)
@@ -544,9 +544,9 @@ s32 sdio_local_read(
544544
return sd_cmd52_read(intfhdl, addr, cnt, buf);
545545

546546
n = round_up(cnt, 4);
547-
tmpbuf = rtw_malloc(n);
547+
tmpbuf = kmalloc(n, GFP_ATOMIC);
548548
if (!tmpbuf)
549-
return -1;
549+
return -ENOMEM;
550550

551551
err = sd_read(intfhdl, addr, n, tmpbuf);
552552
if (!err)
@@ -583,9 +583,9 @@ s32 sdio_local_write(
583583
)
584584
return sd_cmd52_write(intfhdl, addr, cnt, buf);
585585

586-
tmpbuf = rtw_malloc(cnt);
586+
tmpbuf = kmalloc(cnt, GFP_ATOMIC);
587587
if (!tmpbuf)
588-
return -1;
588+
return -ENOMEM;
589589

590590
memcpy(tmpbuf, buf, cnt);
591591

@@ -883,7 +883,7 @@ void sd_int_dpc(struct adapter *adapter)
883883
u8 *status;
884884
u32 addr;
885885

886-
status = rtw_malloc(4);
886+
status = kmalloc(4, GFP_ATOMIC);
887887
if (status) {
888888
addr = REG_TXDMA_STATUS;
889889
hal_sdio_get_cmd_addr_8723b(adapter, WLAN_IOREG_DEVICE_ID, addr, &addr);

0 commit comments

Comments
 (0)