Skip to contentSkip to conversation

staging: rtl8723bs: use DIV_ROUND_UP helper macro

PATCH In review Wambui Karuga 2 participants 2 messages Oct 13, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 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)
)

---
Changes in v2:
- Remove comment that explained previously used calculation.

---
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2 -3
index 87535a4c2e14..22931ab3a5fc 100644
@@ -4156,9 +4156,8 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
 				break;
 			}
 
-			/*  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
Acked-by on v2 1/1
#1 lore raw
Quoted 14 lines · Wambui Karuga

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)
)

Quoted 1 line
Quoted 3 lines

---
Changes in v2:
- Remove comment that explained previously used calculation.

Maybe it is not very important for a comment, but remember that what is below the --- will disappear in the history. So when actual code changes, it may be necessary to integrate the extended change in the commit log as well as putting it in the v2 changes.

julia

Quoted 28 lines
---
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2 -4
index 87535a4c2e14..22931ab3a5fc 100644
@@ -4156,9 +4156,8 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
 				break;
 			}
 
-			/*  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;
--

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/20191013191027.6470-1-wambui.karugax%40gmail.com.