staging: rtl8723bs: use DIV_ROUND_UP helper macro
PATCH 1/1 staging: rtl8723bs: use DIV_ROUND_UP helper macro
Use the DIV_ROUND_UP macro to replace open-coded divisor calculation to improve readability.
Issue found using coccinelle:
@@
expression n,d;
@@
(
- ((n + d - 1) / d)
+ DIV_ROUND_UP(n,d)
|
- ((n + (d - 1)) / d)
+ DIV_ROUND_UP(n,d)
)
--- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2 -1
@@ -4158,7 +4158,8 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)/* The value of ((usNavUpper + HAL_NAV_UPPER_UNIT_8723B - 1) / HAL_NAV_UPPER_UNIT_8723B) */ /* is getting the upper integer. */ - usNavUpper = (usNavUpper +HAL_NAV_UPPER_UNIT_8723B -1 ) /HAL_NAV_UPPER_UNIT_8723B ; + usNavUpper =DIV_ROUND_UP (usNavUpper, +HAL_NAV_UPPER_UNIT_8723B );rtw_write8 (padapter,REG_NAV_UPPER , (u8 )usNavUpper); }break ;
Signature · 1 line
2.23.0
Quoted 24 lines · Wambui Karuga
Use the
DIV_ROUND_UPmacro to replace open-coded divisor calculation to improve readability.
Issue found using coccinelle:
@@
expression n,d;
@@
(
- ((n + d - 1) / d)
+DIV_ROUND_UP(n,d)
|
- ((n + (d - 1)) / d)
+DIV_ROUND_UP(n,d)
)Signed-off-by Wambui Karuga <[email protected]>--- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +0
-0
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) · line 4160
Quoted 3 lines
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +0
-0@@ -4158,7 +4158,8 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)/* The value of ((usNavUpper + HAL_NAV_UPPER_UNIT_8723B - 1) / HAL_NAV_UPPER_UNIT_8723B) */ /* is getting the upper integer. */
It's a nice change. Maybe the above comment could also be dropped, since the code is more understandable now.
julia
Quoted 14 lines
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2
-2- usNavUpper = (usNavUpper +HAL_NAV_UPPER_UNIT_8723B -1 ) /HAL_NAV_UPPER_UNIT_8723B ; + usNavUpper =DIV_ROUND_UP (usNavUpper, +HAL_NAV_UPPER_UNIT_8723B );rtw_write8 (padapter,REG_NAV_UPPER , (u8 )usNavUpper); }break ; --2.23.0
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20191013180033.31882-1-wambui.karugax%40gmail.com.
Quoted 29 lines · Julia Lawall
Quoted 25 lines · Wambui Karuga
Use the
DIV_ROUND_UPmacro to replace open-coded divisor calculation to improve readability.
Issue found using coccinelle:
@@
expression n,d;
@@
(
- ((n + d - 1) / d)
+DIV_ROUND_UP(n,d)
|
- ((n + (d - 1)) / d)
+DIV_ROUND_UP(n,d)
)Signed-off-by Wambui Karuga <[email protected]>--- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +0
-0@@ -4158,7 +4158,8 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
Quoted 8 lines
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) · line 4160
Quoted 2 lines
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +0
-0/* The value of ((usNavUpper + HAL_NAV_UPPER_UNIT_8723B - 1) / HAL_NAV_UPPER_UNIT_8723B) */ /* is getting the upper integer. */ It's a nice change. Maybe the above comment could also be dropped, since the code is more understandable now.
julia
Ok, I agree. Will update this.
wambui karuga