Skip to contentSkip to conversation

staging: most: hdm-dim2: Use macro DIV_ROUND_UP

PATCH Superseded Bhaktipriya Shridhar 1 participant 1 message Feb 21, 2016

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 staging: most: hdm-dim2: Use macro DIV_ROUND_UP

The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)). It clarifies the divisor calculations. This was done using the coccinelle script:
@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)

---
 drivers/staging/most/hdm-dim2/dim2_hal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/hdm-dim2/dim2_hal.c +2 -2
index 3c52450..03da89e 100644
@@ -120,7 +120,7 @@ static int alloc_dbr(u16 size)
 		return DBR_SIZE; /* out of memory */
 
 	for (i = 0; i < DBR_MAP_SIZE; i++) {
-		u32 const blocks = (size + DBR_BLOCK_SIZE - 1) / DBR_BLOCK_SIZE;
+		u32 const blocks = DIV_ROUND_UP(size, DBR_BLOCK_SIZE);
 		u32 mask = ~((~(u32)0) << blocks);
 
 		do {
@@ -140,7 +140,7 @@ static int alloc_dbr(u16 size)
 static void free_dbr(int offs, int size)
 {
 	int block_idx = offs / DBR_BLOCK_SIZE;
-	u32 const blocks = (size + DBR_BLOCK_SIZE - 1) / DBR_BLOCK_SIZE;
+	u32 const blocks = DIV_ROUND_UP(size, DBR_BLOCK_SIZE);
 	u32 mask = ~((~(u32)0) << blocks);
 
 	mask <<= block_idx % 32;

--
2.1.4