LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/7] staging: r8188eu: memory allocation cleanup series
@ 2021-08-18 23:48 Phillip Potter
  2021-08-18 23:48 ` [PATCH 1/7] staging: r8188eu: convert only rtw_vmalloc call to vmalloc Phillip Potter
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Phillip Potter @ 2021-08-18 23:48 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, martin, straube.linux, Larry.Finger

This series does some cleanup on the memory allocation paths within the
driver, by converting all callers of rtw_vmalloc and rtw_zvmalloc to use
vmalloc and vzalloc respectively, and then removing the functions and
associated declarations and macro definitions. It also removes an unused
macro (rtw_update_mem_stat) and its associated flags.

Phillip Potter (7):
  staging: r8188eu: convert only rtw_vmalloc call to vmalloc
  staging: r8188eu: remove rtw_vmalloc preprocessor definition
  staging: r8188eu: remove function _rtw_vmalloc
  staging: r8188eu: convert all rtw_zvmalloc calls to vzalloc calls
  staging: r8188eu: remove rtw_zvmalloc preprocessor definition
  staging: r8188eu: remove function _rtw_zvmalloc
  staging: r8188eu: remove rtw_update_mem_stat macro and associated
    flags

 drivers/staging/r8188eu/core/rtw_mlme.c       |  4 ++--
 drivers/staging/r8188eu/core/rtw_mp.c         |  2 +-
 drivers/staging/r8188eu/core/rtw_recv.c       |  2 +-
 drivers/staging/r8188eu/core/rtw_sta_mgt.c    |  2 +-
 drivers/staging/r8188eu/core/rtw_xmit.c       |  8 +++----
 drivers/staging/r8188eu/hal/odm_interface.c   |  2 +-
 .../staging/r8188eu/hal/rtl8188e_hal_init.c   |  2 +-
 .../staging/r8188eu/include/osdep_service.h   | 24 -------------------
 drivers/staging/r8188eu/os_dep/ioctl_linux.c  |  2 +-
 .../staging/r8188eu/os_dep/osdep_service.c    | 18 +-------------
 drivers/staging/r8188eu/os_dep/usb_intf.c     |  2 +-
 11 files changed, 14 insertions(+), 54 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] staging: r8188eu: convert only rtw_vmalloc call to vmalloc
  2021-08-18 23:48 [PATCH 0/7] staging: r8188eu: memory allocation cleanup series Phillip Potter
@ 2021-08-18 23:48 ` Phillip Potter
  2021-08-18 23:48 ` [PATCH 2/7] staging: r8188eu: remove rtw_vmalloc preprocessor definition Phillip Potter
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Phillip Potter @ 2021-08-18 23:48 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, martin, straube.linux, Larry.Finger

Convert the only call to rtw_vmalloc in os_dep/ioctl_linux.c to the
kernel's existing vmalloc function, as rtw_malloc is just a preprocessor
definition for _rtw_vmalloc. The _rtw_vmalloc function is defined inline
and returns a u8, wrapping standard vmalloc. This behaviour is not necessary.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index c0e66c194952..ab4a9200f079 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -4481,7 +4481,7 @@ static int rtw_wx_set_priv(struct net_device *dev,
 		return -EFAULT;
 
 	len = dwrq->length;
-	ext = rtw_vmalloc(len);
+	ext = vmalloc(len);
 	if (!ext)
 		return -ENOMEM;
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/7] staging: r8188eu: remove rtw_vmalloc preprocessor definition
  2021-08-18 23:48 [PATCH 0/7] staging: r8188eu: memory allocation cleanup series Phillip Potter
  2021-08-18 23:48 ` [PATCH 1/7] staging: r8188eu: convert only rtw_vmalloc call to vmalloc Phillip Potter
@ 2021-08-18 23:48 ` Phillip Potter
  2021-08-18 23:48 ` [PATCH 3/7] staging: r8188eu: remove function _rtw_vmalloc Phillip Potter
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Phillip Potter @ 2021-08-18 23:48 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, martin, straube.linux, Larry.Finger

Remove rtw_vmalloc preprocessor definition from include/osdep_service.h
as it now has no callers.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/r8188eu/include/osdep_service.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index 157ffe46c3d2..a9f147cd42fe 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -173,7 +173,6 @@ extern unsigned char RSN_TKIP_CIPHER[4];
 #define rtw_update_mem_stat(flag, sz) do {} while (0)
 u8 *_rtw_vmalloc(u32 sz);
 u8 *_rtw_zvmalloc(u32 sz);
-#define rtw_vmalloc(sz)			_rtw_vmalloc((sz))
 #define rtw_zvmalloc(sz)			_rtw_zvmalloc((sz))
 
 void *rtw_malloc2d(int h, int w, int size);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/7] staging: r8188eu: remove function _rtw_vmalloc
  2021-08-18 23:48 [PATCH 0/7] staging: r8188eu: memory allocation cleanup series Phillip Potter
  2021-08-18 23:48 ` [PATCH 1/7] staging: r8188eu: convert only rtw_vmalloc call to vmalloc Phillip Potter
  2021-08-18 23:48 ` [PATCH 2/7] staging: r8188eu: remove rtw_vmalloc preprocessor definition Phillip Potter
@ 2021-08-18 23:48 ` Phillip Potter
  2021-08-18 23:48 ` [PATCH 4/7] staging: r8188eu: convert all rtw_zvmalloc calls to vzalloc calls Phillip Potter
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Phillip Potter @ 2021-08-18 23:48 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, martin, straube.linux, Larry.Finger

Remove the function _rtw_vmalloc from os_dep/osdep_service.c, converting
its only user (also in os_dep/osdep_service.c) to use plain vmalloc.
This function is just an inline wrapper around vmalloc which returns a u8
pointer, which isn't needed. Also remove the declaration from
include/osdep_service.h.

It is considered generally bad practice to declare functions as inline in
the majority of cases, as not only can this qualifier be ignored by the
compiler but the compiler generally makes good decisions about inlining
anyway.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/r8188eu/include/osdep_service.h | 1 -
 drivers/staging/r8188eu/os_dep/osdep_service.c  | 9 +--------
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index a9f147cd42fe..4c00adeb72ee 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -171,7 +171,6 @@ 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_vmalloc(u32 sz);
 u8 *_rtw_zvmalloc(u32 sz);
 #define rtw_zvmalloc(sz)			_rtw_zvmalloc((sz))
 
diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c
index 6218a9052ee9..800f493f1000 100644
--- a/drivers/staging/r8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/r8188eu/os_dep/osdep_service.c
@@ -36,17 +36,10 @@ u32 rtw_atoi(u8 *s)
 	return num;
 }
 
-inline u8 *_rtw_vmalloc(u32 sz)
-{
-	u8	*pbuf;
-	pbuf = vmalloc(sz);
-	return pbuf;
-}
-
 inline u8 *_rtw_zvmalloc(u32 sz)
 {
 	u8	*pbuf;
-	pbuf = _rtw_vmalloc(sz);
+	pbuf = vmalloc(sz);
 	if (pbuf)
 		memset(pbuf, 0, sz);
 	return pbuf;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/7] staging: r8188eu: convert all rtw_zvmalloc calls to vzalloc calls
  2021-08-18 23:48 [PATCH 0/7] staging: r8188eu: memory allocation cleanup series Phillip Potter
                   ` (2 preceding siblings ...)
  2021-08-18 23:48 ` [PATCH 3/7] staging: r8188eu: remove function _rtw_vmalloc Phillip Potter
@ 2021-08-18 23:48 ` Phillip Potter
  2021-08-18 23:48 ` [PATCH 5/7] staging: r8188eu: remove rtw_zvmalloc preprocessor definition Phillip Potter
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Phillip Potter @ 2021-08-18 23:48 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, martin, straube.linux, Larry.Finger

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.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/r8188eu/core/rtw_mlme.c         | 4 ++--
 drivers/staging/r8188eu/core/rtw_mp.c           | 2 +-
 drivers/staging/r8188eu/core/rtw_recv.c         | 2 +-
 drivers/staging/r8188eu/core/rtw_sta_mgt.c      | 2 +-
 drivers/staging/r8188eu/core/rtw_xmit.c         | 8 ++++----
 drivers/staging/r8188eu/hal/odm_interface.c     | 2 +-
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
 drivers/staging/r8188eu/os_dep/osdep_service.c  | 2 +-
 drivers/staging/r8188eu/os_dep/usb_intf.c       | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c
index 858a582e674f..c41312660054 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme.c
@@ -38,7 +38,7 @@ int _rtw_init_mlme_priv(struct adapter *padapter)
 	struct mlme_priv		*pmlmepriv = &padapter->mlmepriv;
 	int	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(). */
 
 	pmlmepriv->nic_hdl = (u8 *)padapter;
 
@@ -55,7 +55,7 @@ int _rtw_init_mlme_priv(struct adapter *padapter)
 
 	memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
 
-	pbuf = rtw_zvmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
+	pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
 
 	if (!pbuf) {
 		res = _FAIL;
diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c
index 07d9245fa05f..93bb683b628f 100644
--- a/drivers/staging/r8188eu/core/rtw_mp.c
+++ b/drivers/staging/r8188eu/core/rtw_mp.c
@@ -930,7 +930,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) {
 		res = _FAIL;
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 0e137aee0aa4..52236bae8693 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -58,7 +58,7 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
 
 	rtw_os_recv_resource_init(precvpriv, padapter);
 
-	precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ);
+	precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ);
 
 	if (!precvpriv->pallocated_frame_buf) {
 		res = _FAIL;
diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c
index 9628d095a487..f6dffed53a60 100644
--- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c
@@ -60,7 +60,7 @@ u32	_rtw_init_sta_priv(struct	sta_priv *pstapriv)
 	struct sta_info *psta;
 	s32 i;
 
-	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)
 		return _FAIL;
diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
index 69f997f44c07..e1de7448771c 100644
--- a/drivers/staging/r8188eu/core/rtw_xmit.c
+++ b/drivers/staging/r8188eu/core/rtw_xmit.c
@@ -46,7 +46,7 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 	u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
 	u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
 
-	/*  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(). */
 
 	spin_lock_init(&pxmitpriv->lock);
 	sema_init(&pxmitpriv->xmit_sema, 0);
@@ -72,7 +72,7 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct 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) {
 		pxmitpriv->pxmit_frame_buf = NULL;
@@ -109,7 +109,7 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct 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) {
 		res = _FAIL;
@@ -150,7 +150,7 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 	/*  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) {
 		res = _FAIL;
diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c
index 239a9703bb34..5a01495d74bc 100644
--- a/drivers/staging/r8188eu/hal/odm_interface.c
+++ b/drivers/staging/r8188eu/hal/odm_interface.c
@@ -79,7 +79,7 @@ u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path	eRFPath, u32
 /*  ODM Memory relative API. */
 void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length)
 {
-	*pPtr = rtw_zvmalloc(length);
+	*pPtr = vzalloc(length);
 }
 
 /*  length could be ignored, used to detect memory leakage. */
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index 78e58f9150f3..393969f51206 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -341,7 +341,7 @@ void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len)
 	u32 fifo_data, reg_140;
 	u32 addr, rstatus, loop = 0;
 	u16 data_cnts = (data_len / 8) + 1;
-	u8 *pbuf = rtw_zvmalloc(data_len + 10);
+	u8 *pbuf = vzalloc(data_len + 10);
 	DBG_88E("###### %s ######\n", __func__);
 
 	rtw_write8(Adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT);
diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c
index 800f493f1000..8a797bfcb7f5 100644
--- a/drivers/staging/r8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/r8188eu/os_dep/osdep_service.c
@@ -152,7 +152,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;
diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
index 0f28ed77ef65..e002070f7fba 100644
--- a/drivers/staging/r8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
@@ -569,7 +569,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 	struct net_device *pnetdev = NULL;
 	int status = _FAIL;
 
-	padapter = (struct adapter *)rtw_zvmalloc(sizeof(*padapter));
+	padapter = vzalloc(sizeof(*padapter));
 	if (!padapter)
 		goto exit;
 	padapter->dvobj = dvobj;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/7] staging: r8188eu: remove rtw_zvmalloc preprocessor definition
  2021-08-18 23:48 [PATCH 0/7] staging: r8188eu: memory allocation cleanup series Phillip Potter
                   ` (3 preceding siblings ...)
  2021-08-18 23:48 ` [PATCH 4/7] staging: r8188eu: convert all rtw_zvmalloc calls to vzalloc calls Phillip Potter
@ 2021-08-18 23:48 ` Phillip Potter
  2021-08-18 23:48 ` [PATCH 6/7] staging: r8188eu: remove function _rtw_zvmalloc Phillip Potter
  2021-08-18 23:48 ` [PATCH 7/7] staging: r8188eu: remove rtw_update_mem_stat macro and associated flags Phillip Potter
  6 siblings, 0 replies; 8+ messages in thread
From: Phillip Potter @ 2021-08-18 23:48 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, martin, straube.linux, Larry.Finger

Remove rtw_zvmalloc preprocessor definition from include/osdep_service.h
as it now has no callers.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/r8188eu/include/osdep_service.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index 4c00adeb72ee..dba7a7bec9d1 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -172,7 +172,6 @@ extern unsigned char RSN_TKIP_CIPHER[4];
 
 #define rtw_update_mem_stat(flag, sz) do {} while (0)
 u8 *_rtw_zvmalloc(u32 sz);
-#define rtw_zvmalloc(sz)			_rtw_zvmalloc((sz))
 
 void *rtw_malloc2d(int h, int w, int size);
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/7] staging: r8188eu: remove function _rtw_zvmalloc
  2021-08-18 23:48 [PATCH 0/7] staging: r8188eu: memory allocation cleanup series Phillip Potter
                   ` (4 preceding siblings ...)
  2021-08-18 23:48 ` [PATCH 5/7] staging: r8188eu: remove rtw_zvmalloc preprocessor definition Phillip Potter
@ 2021-08-18 23:48 ` Phillip Potter
  2021-08-18 23:48 ` [PATCH 7/7] staging: r8188eu: remove rtw_update_mem_stat macro and associated flags Phillip Potter
  6 siblings, 0 replies; 8+ messages in thread
From: Phillip Potter @ 2021-08-18 23:48 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, martin, straube.linux, Larry.Finger

Remove the function _rtw_zvmalloc from os_dep/osdep_service.c, as this
function is now unused and is just an inline wrapper around vmalloc
which zeroes out the memory. All previous callers have been converted to
use vzalloc. Also remove the declaration from include/osdep_service.h.

It is considered generally bad practice to declare functions as inline in
the majority of cases, as not only can this qualifier be ignored by the
compiler but the compiler generally makes good decisions about inlining
anyway.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/r8188eu/include/osdep_service.h | 1 -
 drivers/staging/r8188eu/os_dep/osdep_service.c  | 9 ---------
 2 files changed, 10 deletions(-)

diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index dba7a7bec9d1..bda435ca9d08 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -171,7 +171,6 @@ 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_zvmalloc(u32 sz);
 
 void *rtw_malloc2d(int h, int w, int size);
 
diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c
index 8a797bfcb7f5..95ac6086370b 100644
--- a/drivers/staging/r8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/r8188eu/os_dep/osdep_service.c
@@ -36,15 +36,6 @@ u32 rtw_atoi(u8 *s)
 	return num;
 }
 
-inline u8 *_rtw_zvmalloc(u32 sz)
-{
-	u8	*pbuf;
-	pbuf = vmalloc(sz);
-	if (pbuf)
-		memset(pbuf, 0, sz);
-	return pbuf;
-}
-
 void *rtw_malloc2d(int h, int w, int size)
 {
 	int j;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 7/7] staging: r8188eu: remove rtw_update_mem_stat macro and associated flags
  2021-08-18 23:48 [PATCH 0/7] staging: r8188eu: memory allocation cleanup series Phillip Potter
                   ` (5 preceding siblings ...)
  2021-08-18 23:48 ` [PATCH 6/7] staging: r8188eu: remove function _rtw_zvmalloc Phillip Potter
@ 2021-08-18 23:48 ` Phillip Potter
  6 siblings, 0 replies; 8+ messages in thread
From: Phillip Potter @ 2021-08-18 23:48 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, martin, straube.linux, Larry.Finger

Remove the unused rtw_update_mem_stat macro and the associated flags
from include/osdep_service.h as this is all dead code.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 .../staging/r8188eu/include/osdep_service.h   | 20 -------------------
 1 file changed, 20 deletions(-)

diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index bda435ca9d08..029aa4e92c9b 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -146,32 +146,12 @@ static inline void rtw_netif_stop_queue(struct net_device *pnetdev)
 
 extern int RTW_STATUS_CODE(int error_code);
 
-/* flags used for rtw_update_mem_stat() */
-enum {
-	MEM_STAT_VIR_ALLOC_SUCCESS,
-	MEM_STAT_VIR_ALLOC_FAIL,
-	MEM_STAT_VIR_FREE,
-	MEM_STAT_PHY_ALLOC_SUCCESS,
-	MEM_STAT_PHY_ALLOC_FAIL,
-	MEM_STAT_PHY_FREE,
-	MEM_STAT_TX, /* used to distinguish TX/RX, asigned from caller */
-	MEM_STAT_TX_ALLOC_SUCCESS,
-	MEM_STAT_TX_ALLOC_FAIL,
-	MEM_STAT_TX_FREE,
-	MEM_STAT_RX, /* used to distinguish TX/RX, asigned from caller */
-	MEM_STAT_RX_ALLOC_SUCCESS,
-	MEM_STAT_RX_ALLOC_FAIL,
-	MEM_STAT_RX_FREE
-};
-
 extern unsigned char MCS_rate_2R[16];
 extern unsigned char MCS_rate_1R[16];
 extern unsigned char RTW_WPA_OUI[];
 extern unsigned char WPA_TKIP_CIPHER[4];
 extern unsigned char RSN_TKIP_CIPHER[4];
 
-#define rtw_update_mem_stat(flag, sz) do {} while (0)
-
 void *rtw_malloc2d(int h, int w, int size);
 
 u32  _rtw_down_sema(struct semaphore *sema);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-08-18 23:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 23:48 [PATCH 0/7] staging: r8188eu: memory allocation cleanup series Phillip Potter
2021-08-18 23:48 ` [PATCH 1/7] staging: r8188eu: convert only rtw_vmalloc call to vmalloc Phillip Potter
2021-08-18 23:48 ` [PATCH 2/7] staging: r8188eu: remove rtw_vmalloc preprocessor definition Phillip Potter
2021-08-18 23:48 ` [PATCH 3/7] staging: r8188eu: remove function _rtw_vmalloc Phillip Potter
2021-08-18 23:48 ` [PATCH 4/7] staging: r8188eu: convert all rtw_zvmalloc calls to vzalloc calls Phillip Potter
2021-08-18 23:48 ` [PATCH 5/7] staging: r8188eu: remove rtw_zvmalloc preprocessor definition Phillip Potter
2021-08-18 23:48 ` [PATCH 6/7] staging: r8188eu: remove function _rtw_zvmalloc Phillip Potter
2021-08-18 23:48 ` [PATCH 7/7] staging: r8188eu: remove rtw_update_mem_stat macro and associated flags Phillip Potter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).