* [PATCH 0/4] staging: r8188eu: refactor two small functions
@ 2022-03-29 10:37 Michael Straube
2022-03-29 10:37 ` [PATCH 1/4] staging: r8188eu: refactor rtw_usb_bulk_size_boundary() Michael Straube
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Michael Straube @ 2022-03-29 10:37 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
This series refactors two small functions to improve readability.
Tested on x86_64 with Inter-Tech DMG-02.
Michael Straube (4):
staging: r8188eu: refactor rtw_usb_bulk_size_boundary()
staging: r8188eu: refactor rtw_inc_and_chk_continual_urb_error()
staging: r8188eu: convert rtw_usb_bulk_size_boundary() to bool
staging: r8188eu: convert rtw_inc_and_chk_continual_urb_error() to
bool
drivers/staging/r8188eu/include/usb_ops.h | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
--
2.35.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] staging: r8188eu: refactor rtw_usb_bulk_size_boundary()
2022-03-29 10:37 [PATCH 0/4] staging: r8188eu: refactor two small functions Michael Straube
@ 2022-03-29 10:37 ` Michael Straube
2022-03-29 10:37 ` [PATCH 2/4] staging: r8188eu: refactor rtw_inc_and_chk_continual_urb_error() Michael Straube
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Michael Straube @ 2022-03-29 10:37 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Using ternary operator to set a variable to true or false is not
needed. Convert two such uses of ternary operator in
rtw_usb_bulk_size_boundary() to just use the condition and return the
value directly instead of using a return variable. This shortens the
code and improves readability. While at it, remove an unneeded line
break from the function head.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/include/usb_ops.h | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h
index 14526fcff4ae..3416c8baceb6 100644
--- a/drivers/staging/r8188eu/include/usb_ops.h
+++ b/drivers/staging/r8188eu/include/usb_ops.h
@@ -47,19 +47,14 @@ static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj)
#define USB_HIGH_SPEED_BULK_SIZE 512
#define USB_FULL_SPEED_BULK_SIZE 64
-static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter,
- int buf_len)
+static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter, int buf_len)
{
- u8 rst = true;
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
if (pdvobjpriv->pusbdev->speed == USB_SPEED_HIGH)
- rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ?
- true : false;
+ return buf_len % USB_HIGH_SPEED_BULK_SIZE == 0;
else
- rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ?
- true : false;
- return rst;
+ return buf_len % USB_FULL_SPEED_BULK_SIZE == 0;
}
#endif /* __USB_OPS_H_ */
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] staging: r8188eu: refactor rtw_inc_and_chk_continual_urb_error()
2022-03-29 10:37 [PATCH 0/4] staging: r8188eu: refactor two small functions Michael Straube
2022-03-29 10:37 ` [PATCH 1/4] staging: r8188eu: refactor rtw_usb_bulk_size_boundary() Michael Straube
@ 2022-03-29 10:37 ` Michael Straube
2022-03-29 10:37 ` [PATCH 3/4] staging: r8188eu: convert rtw_usb_bulk_size_boundary() to bool Michael Straube
2022-03-29 10:37 ` [PATCH 4/4] staging: r8188eu: convert rtw_inc_and_chk_continual_urb_error() " Michael Straube
3 siblings, 0 replies; 5+ messages in thread
From: Michael Straube @ 2022-03-29 10:37 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Refactor rtw_inc_and_chk_continual_urb_error(). Return directly
instead of using a return variable and initialize the variable 'value'
at declaration. This shortens the code and improves readability.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/include/usb_ops.h | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h
index 3416c8baceb6..cfcf6f84d2cf 100644
--- a/drivers/staging/r8188eu/include/usb_ops.h
+++ b/drivers/staging/r8188eu/include/usb_ops.h
@@ -27,13 +27,12 @@
*/
static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
{
- int ret = false;
- int value;
- value = atomic_inc_return(&dvobj->continual_urb_error);
+ int value = atomic_inc_return(&dvobj->continual_urb_error);
+
if (value > MAX_CONTINUAL_URB_ERR)
- ret = true;
+ return true;
- return ret;
+ return false;
}
/*
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] staging: r8188eu: convert rtw_usb_bulk_size_boundary() to bool
2022-03-29 10:37 [PATCH 0/4] staging: r8188eu: refactor two small functions Michael Straube
2022-03-29 10:37 ` [PATCH 1/4] staging: r8188eu: refactor rtw_usb_bulk_size_boundary() Michael Straube
2022-03-29 10:37 ` [PATCH 2/4] staging: r8188eu: refactor rtw_inc_and_chk_continual_urb_error() Michael Straube
@ 2022-03-29 10:37 ` Michael Straube
2022-03-29 10:37 ` [PATCH 4/4] staging: r8188eu: convert rtw_inc_and_chk_continual_urb_error() " Michael Straube
3 siblings, 0 replies; 5+ messages in thread
From: Michael Straube @ 2022-03-29 10:37 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Function rtw_usb_bulk_size_boundary() returns boolean values.
Change its return type from u8 to bool.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/include/usb_ops.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h
index cfcf6f84d2cf..5ee1c8c7940d 100644
--- a/drivers/staging/r8188eu/include/usb_ops.h
+++ b/drivers/staging/r8188eu/include/usb_ops.h
@@ -46,7 +46,7 @@ static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj)
#define USB_HIGH_SPEED_BULK_SIZE 512
#define USB_FULL_SPEED_BULK_SIZE 64
-static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter, int buf_len)
+static inline bool rtw_usb_bulk_size_boundary(struct adapter *padapter, int buf_len)
{
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] staging: r8188eu: convert rtw_inc_and_chk_continual_urb_error() to bool
2022-03-29 10:37 [PATCH 0/4] staging: r8188eu: refactor two small functions Michael Straube
` (2 preceding siblings ...)
2022-03-29 10:37 ` [PATCH 3/4] staging: r8188eu: convert rtw_usb_bulk_size_boundary() to bool Michael Straube
@ 2022-03-29 10:37 ` Michael Straube
3 siblings, 0 replies; 5+ messages in thread
From: Michael Straube @ 2022-03-29 10:37 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Function rtw_inc_and_chk_continual_urb_error() returns boolean values.
Change its return type from int to bool.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/include/usb_ops.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h
index 5ee1c8c7940d..ddc46cb44358 100644
--- a/drivers/staging/r8188eu/include/usb_ops.h
+++ b/drivers/staging/r8188eu/include/usb_ops.h
@@ -25,7 +25,7 @@
* @return true:
* @return false:
*/
-static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
+static inline bool rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
{
int value = atomic_inc_return(&dvobj->continual_urb_error);
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-29 10:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 10:37 [PATCH 0/4] staging: r8188eu: refactor two small functions Michael Straube
2022-03-29 10:37 ` [PATCH 1/4] staging: r8188eu: refactor rtw_usb_bulk_size_boundary() Michael Straube
2022-03-29 10:37 ` [PATCH 2/4] staging: r8188eu: refactor rtw_inc_and_chk_continual_urb_error() Michael Straube
2022-03-29 10:37 ` [PATCH 3/4] staging: r8188eu: convert rtw_usb_bulk_size_boundary() to bool Michael Straube
2022-03-29 10:37 ` [PATCH 4/4] staging: r8188eu: convert rtw_inc_and_chk_continual_urb_error() " Michael Straube
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).