All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals
@ 2022-11-11  8:37 Michael Straube
  2022-11-11  8:37 ` [PATCH 1/4] staging: r8188eu: convert aes_cipher() to void Michael Straube
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Michael Straube @ 2022-11-11  8:37 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

This series removes some more uses of _FAIL and _SUCCESS.
Tested on x86_64 with Inter-Tech DMG-02.

Michael Straube (4):
  staging: r8188eu: convert aes_cipher() to void
  staging: r8188eu: convert rtw_xmit_resource_alloc() to common error
    logic
  staging: r8188eu: convert _rtw_init_xmit_priv() to common error logic
  staging: r8188eu: binstallGrpkey is set to _FAIL

 drivers/staging/r8188eu/core/rtw_security.c |  4 +--
 drivers/staging/r8188eu/core/rtw_xmit.c     | 37 +++++++--------------
 drivers/staging/r8188eu/include/rtw_xmit.h  |  2 +-
 drivers/staging/r8188eu/os_dep/os_intfs.c   |  4 +--
 4 files changed, 16 insertions(+), 31 deletions(-)

-- 
2.38.1


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

* [PATCH 1/4] staging: r8188eu: convert aes_cipher() to void
  2022-11-11  8:37 [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Michael Straube
@ 2022-11-11  8:37 ` Michael Straube
  2022-11-11  8:37 ` [PATCH 2/4] staging: r8188eu: convert rtw_xmit_resource_alloc() to common error logic Michael Straube
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-11-11  8:37 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

The function aes_cipher() returns always _SUCCESS and its callers
do not use the return value. So we can convert the return type to
void and get rid of another use of _SUCCESS.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/core/rtw_security.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c
index 5bba57d18b5f..780019ce1b98 100644
--- a/drivers/staging/r8188eu/core/rtw_security.c
+++ b/drivers/staging/r8188eu/core/rtw_security.c
@@ -954,7 +954,7 @@ static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
 
 }
 
-static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
+static void aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
 {
 	uint	qc_exists, a4_exists, i, j, payload_remainder,
 		num_blocks, payload_index;
@@ -1083,8 +1083,6 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
 	bitwise_xor(aes_out, padded_buffer, chain_buffer);
 	for (j = 0; j < 8; j++)
 		pframe[payload_index++] = chain_buffer[j];
-
-	return _SUCCESS;
 }
 
 u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
-- 
2.38.1


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

* [PATCH 2/4] staging: r8188eu: convert rtw_xmit_resource_alloc() to common error logic
  2022-11-11  8:37 [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Michael Straube
  2022-11-11  8:37 ` [PATCH 1/4] staging: r8188eu: convert aes_cipher() to void Michael Straube
@ 2022-11-11  8:37 ` Michael Straube
  2022-11-11  8:37 ` [PATCH 3/4] staging: r8188eu: convert _rtw_init_xmit_priv() " Michael Straube
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-11-11  8:37 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Convert the function rtw_xmit_resource_alloc() away from returning
_FAIL or _SUCCESS which uses inverted error logic. Use the common
error logic instead. Return 0 for success and negative values for
failure.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/core/rtw_xmit.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
index bd6c1a401c59..c0fda6ce7c56 100644
--- a/drivers/staging/r8188eu/core/rtw_xmit.c
+++ b/drivers/staging/r8188eu/core/rtw_xmit.c
@@ -38,7 +38,7 @@ static int rtw_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *px
 {
 	pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL);
 	if (!pxmitbuf->pallocated_buf)
-		return _FAIL;
+		return -ENOMEM;
 
 	pxmitbuf->pbuf = (u8 *)ALIGN((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
 	pxmitbuf->dma_transfer_addr = 0;
@@ -46,10 +46,10 @@ static int rtw_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *px
 	pxmitbuf->pxmit_urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!pxmitbuf->pxmit_urb) {
 		kfree(pxmitbuf->pallocated_buf);
-		return _FAIL;
+		return -ENOMEM;
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static void rtw_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf,
@@ -151,12 +151,12 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 		pxmitbuf->ext_tag = false;
 
 		/* Tx buf allocation may fail sometimes, so sleep and retry. */
-		res = rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
-		if (res == _FAIL) {
+		if (rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ))) {
 			msleep(10);
-			res = rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
-			if (res == _FAIL)
+			if (rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ))) {
+				res = _FAIL;
 				goto free_xmitbuf;
+			}
 		}
 
 		pxmitbuf->flags = XMIT_VO_QUEUE;
@@ -188,8 +188,7 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 		pxmitbuf->padapter = padapter;
 		pxmitbuf->ext_tag = true;
 
-		res = rtw_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ);
-		if (res == _FAIL) {
+		if (rtw_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)) {
 			res = _FAIL;
 			goto free_xmit_extbuf;
 		}
-- 
2.38.1


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

* [PATCH 3/4] staging: r8188eu: convert _rtw_init_xmit_priv() to common error logic
  2022-11-11  8:37 [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Michael Straube
  2022-11-11  8:37 ` [PATCH 1/4] staging: r8188eu: convert aes_cipher() to void Michael Straube
  2022-11-11  8:37 ` [PATCH 2/4] staging: r8188eu: convert rtw_xmit_resource_alloc() to common error logic Michael Straube
@ 2022-11-11  8:37 ` Michael Straube
  2022-11-11  8:37 ` [PATCH 4/4] staging: r8188eu: binstallGrpkey is set to _FAIL Michael Straube
  2022-11-11 18:53 ` [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Philipp Hortmann
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-11-11  8:37 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Convert the function _rtw_init_xmit_priv() away from returning _FAIL
or _SUCCESS which uses inverted error logic. Use the common error
logic instead. Return 0 for success and negative values for failure.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/core/rtw_xmit.c    | 28 +++++++---------------
 drivers/staging/r8188eu/include/rtw_xmit.h |  2 +-
 drivers/staging/r8188eu/os_dep/os_intfs.c  |  2 +-
 3 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
index c0fda6ce7c56..34494f08c0cd 100644
--- a/drivers/staging/r8188eu/core/rtw_xmit.c
+++ b/drivers/staging/r8188eu/core/rtw_xmit.c
@@ -59,12 +59,11 @@ static void rtw_xmit_resource_free(struct adapter *padapter, struct xmit_buf *px
 	kfree(pxmitbuf->pallocated_buf);
 }
 
-s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
+int _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 {
 	int i;
 	struct xmit_buf *pxmitbuf;
 	struct xmit_frame *pxframe;
-	int	res = _SUCCESS;
 	u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
 	u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
 
@@ -97,7 +96,6 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 
 	if (!pxmitpriv->pallocated_frame_buf) {
 		pxmitpriv->pxmit_frame_buf = NULL;
-		res = _FAIL;
 		goto exit;
 	}
 	pxmitpriv->pxmit_frame_buf = (u8 *)ALIGN((size_t)(pxmitpriv->pallocated_frame_buf), 4);
@@ -132,10 +130,8 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 
 	pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
 
-	if (!pxmitpriv->pallocated_xmitbuf) {
-		res = _FAIL;
+	if (!pxmitpriv->pallocated_xmitbuf)
 		goto free_frame_buf;
-	}
 
 	pxmitpriv->pxmitbuf = (u8 *)ALIGN((size_t)(pxmitpriv->pallocated_xmitbuf), 4);
 	/* pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - */
@@ -153,10 +149,8 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 		/* Tx buf allocation may fail sometimes, so sleep and retry. */
 		if (rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ))) {
 			msleep(10);
-			if (rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ))) {
-				res = _FAIL;
+			if (rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)))
 				goto free_xmitbuf;
-			}
 		}
 
 		pxmitbuf->flags = XMIT_VO_QUEUE;
@@ -172,10 +166,8 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 
 	pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
 
-	if (!pxmitpriv->pallocated_xmit_extbuf) {
-		res = _FAIL;
+	if (!pxmitpriv->pallocated_xmit_extbuf)
 		goto free_xmitbuf;
-	}
 
 	pxmitpriv->pxmit_extbuf = (u8 *)ALIGN((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4);
 
@@ -188,10 +180,8 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 		pxmitbuf->padapter = padapter;
 		pxmitbuf->ext_tag = true;
 
-		if (rtw_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)) {
-			res = _FAIL;
+		if (rtw_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ))
 			goto free_xmit_extbuf;
-		}
 
 		list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue);
 		pxmitbuf++;
@@ -199,10 +189,8 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 
 	pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf;
 
-	if (rtw_alloc_hwxmits(padapter)) {
-		res = _FAIL;
+	if (rtw_alloc_hwxmits(padapter))
 		goto free_xmit_extbuf;
-	}
 
 	rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
 
@@ -225,7 +213,7 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 
 	rtl8188eu_init_xmit_priv(padapter);
 
-	return _SUCCESS;
+	return 0;
 
 free_xmit_extbuf:
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
@@ -245,7 +233,7 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
 free_frame_buf:
 	vfree(pxmitpriv->pallocated_frame_buf);
 exit:
-	return res;
+	return -ENOMEM;
 }
 
 static void rtw_pkt_complete(struct adapter *padapter, struct sk_buff *pkt)
diff --git a/drivers/staging/r8188eu/include/rtw_xmit.h b/drivers/staging/r8188eu/include/rtw_xmit.h
index cff065554608..6e7ebea5362d 100644
--- a/drivers/staging/r8188eu/include/rtw_xmit.h
+++ b/drivers/staging/r8188eu/include/rtw_xmit.h
@@ -351,7 +351,7 @@ s32 rtw_txframes_pending(struct adapter *padapter);
 s32 rtw_txframes_sta_ac_pending(struct adapter *padapter,
 				struct pkt_attrib *pattrib);
 void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry);
-s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
+int _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
 void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv);
 int rtw_alloc_hwxmits(struct adapter *padapter);
 void rtw_free_hwxmits(struct adapter *padapter);
diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
index 66556e07ed93..44eb95a7682c 100644
--- a/drivers/staging/r8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
@@ -480,7 +480,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
 
 	init_mlme_ext_priv(padapter);
 
-	if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) {
+	if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter)) {
 		dev_err(dvobj_to_dev(padapter->dvobj), "_rtw_init_xmit_priv failed\n");
 		goto free_mlme_ext;
 	}
-- 
2.38.1


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

* [PATCH 4/4] staging: r8188eu: binstallGrpkey is set to _FAIL
  2022-11-11  8:37 [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Michael Straube
                   ` (2 preceding siblings ...)
  2022-11-11  8:37 ` [PATCH 3/4] staging: r8188eu: convert _rtw_init_xmit_priv() " Michael Straube
@ 2022-11-11  8:37 ` Michael Straube
  2022-11-11 18:53 ` [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Philipp Hortmann
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-11-11  8:37 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

The variable binstallGrpkey is set to _FAIL which is defined as 0.
Use false to set the variable to get rid of another use of _FAIL.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/os_dep/os_intfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
index 44eb95a7682c..2f59bb994796 100644
--- a/drivers/staging/r8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
@@ -405,7 +405,7 @@ static void rtw_init_default_value(struct adapter *padapter)
 	pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */
 
 	/* security_priv */
-	psecuritypriv->binstallGrpkey = _FAIL;
+	psecuritypriv->binstallGrpkey = false;
 	psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
 	psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
 	psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
-- 
2.38.1


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

* Re: [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals
  2022-11-11  8:37 [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Michael Straube
                   ` (3 preceding siblings ...)
  2022-11-11  8:37 ` [PATCH 4/4] staging: r8188eu: binstallGrpkey is set to _FAIL Michael Straube
@ 2022-11-11 18:53 ` Philipp Hortmann
  4 siblings, 0 replies; 6+ messages in thread
From: Philipp Hortmann @ 2022-11-11 18:53 UTC (permalink / raw)
  To: Michael Straube, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel

On 11/11/22 09:37, Michael Straube wrote:
> This series removes some more uses of _FAIL and _SUCCESS.
> Tested on x86_64 with Inter-Tech DMG-02.
> 
> Michael Straube (4):
>    staging: r8188eu: convert aes_cipher() to void
>    staging: r8188eu: convert rtw_xmit_resource_alloc() to common error
>      logic
>    staging: r8188eu: convert _rtw_init_xmit_priv() to common error logic
>    staging: r8188eu: binstallGrpkey is set to _FAIL
> 
>   drivers/staging/r8188eu/core/rtw_security.c |  4 +--
>   drivers/staging/r8188eu/core/rtw_xmit.c     | 37 +++++++--------------
>   drivers/staging/r8188eu/include/rtw_xmit.h  |  2 +-
>   drivers/staging/r8188eu/os_dep/os_intfs.c   |  4 +--
>   4 files changed, 16 insertions(+), 31 deletions(-)
> 

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

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

end of thread, other threads:[~2022-11-11 18:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11  8:37 [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Michael Straube
2022-11-11  8:37 ` [PATCH 1/4] staging: r8188eu: convert aes_cipher() to void Michael Straube
2022-11-11  8:37 ` [PATCH 2/4] staging: r8188eu: convert rtw_xmit_resource_alloc() to common error logic Michael Straube
2022-11-11  8:37 ` [PATCH 3/4] staging: r8188eu: convert _rtw_init_xmit_priv() " Michael Straube
2022-11-11  8:37 ` [PATCH 4/4] staging: r8188eu: binstallGrpkey is set to _FAIL Michael Straube
2022-11-11 18:53 ` [PATCH 0/4] staging: r8188eu: some _FAIL, _SUCCESS removals Philipp Hortmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.