Skip to contentSkip to conversation

staging: lustre: ptlrpc: niobuf: Prefer using macro DIV_ROUND_UP

PATCH New Bhaktipriya Shridhar 1 participant 1 message Mar 8, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 staging: lustre: ptlrpc: niobuf: Prefer using 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)
)

---
Changes in v3:
-Changed subject to avoid conflict with other patches.

 drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/niobuf.c +1 -1
index 10b8fe8..96eaf3c 100644
@@ -162,7 +162,7 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req)
 		 "registered: %d  rq_xid: %llu bd_last_xid: %llu\n",
 		 desc->bd_registered, xid, desc->bd_last_xid);
 
-	total_md = (desc->bd_iov_count + LNET_MAX_IOV - 1) / LNET_MAX_IOV;
+	total_md = DIV_ROUND_UP(desc->bd_iov_count, LNET_MAX_IOV);
 	desc->bd_registered = 1;
 	desc->bd_last_xid = xid;
 	desc->bd_md_count = total_md;

--
2.1.4