staging: r8188eu: some _FAIL, _SUCCESS removals
cover staging: r8188eu: some _FAIL, _SUCCESS removals
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(-)
Signature · 1 line
2.38.1
PATCH 1/4 staging: r8188eu: convert aes_cipher() to void
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.
--- drivers/staging/r8188eu/core/rtw_security.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_security.c +1 -3
@@ -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)
Signature · 1 line
2.38.1
PATCH 2/4 staging: r8188eu: convert rtw_xmit_resource_alloc() to common error logic
In reply to Michael StraubeConvert 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.
--- drivers/staging/r8188eu/core/rtw_xmit.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/staging/r8188eu/core/rtw_xmit.c +8 -9
@@ -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; }
Signature · 1 line
2.38.1
PATCH 3/4 staging: r8188eu: convert _rtw_init_xmit_priv() to common error logic
In reply to Michael StraubeConvert 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.
--- 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(-)
drivers/staging/r8188eu/core/rtw_xmit.c +8 -20
@@ -59,12 +59,11 @@ static void rtw_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxkfree (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)
drivers/staging/r8188eu/include/rtw_xmit.h +1 -1
@@ -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);
drivers/staging/r8188eu/os_dep/os_intfs.c +1 -1
@@ -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; }
Signature · 1 line
2.38.1
PATCH 4/4 staging: r8188eu: binstallGrpkey is set to _FAIL
In reply to Michael StraubeThe 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.
--- drivers/staging/r8188eu/os_dep/os_intfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/os_dep/os_intfs.c +1 -1
@@ -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 */
Signature · 1 line
2.38.1
Quoted 10 lines · Michael Straube
This series removes some more uses of
_FAILand_SUCCESS. Tested onx86_64with Inter-Tech DMG-02.Michael Straube (4):
staging: r8188eu: convertaes_cipher()to void
staging: r8188eu: convertrtw_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
Quoted 6 lines
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(-)