Skip to contentSkip to conversation

staging: lustre: ptlrpc: Use macro DIV_ROUND_UP

PATCH Superseded Bhaktipriya Shridhar 2 participants 3 messages Feb 27, 2016 – Mar 2, 2016 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: lustre: ptlrpc: 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)
)

---
Changes in v2:
-Fixed typo "lusture" to "lustre" in the subject

 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +1 -1
index 72d5b9b..0d58d8e 100644
@@ -274,7 +274,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s,
 static inline
 int npages_to_npools(unsigned long npages)
 {
-	return (int) ((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL);
+	return (int) (DIV_ROUND_UP(npages, PAGES_PER_POOL));
 }
 
 /*

--
2.1.4

maintainer
#1 lore raw
Quoted 15 lines · Bhaktipriya Shridhar

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

Quoted 4 lines

---
Changes in v2:
-Fixed typo "lusture" to "lustre" in the subject

Please pick better subjects, you use pretty much the same thing twice here :(

maintainer
#2 lore raw
In reply to Bhaktipriya Shridhar
Quoted 15 lines · Bhaktipriya Shridhar

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

Quoted 4 lines

---
Changes in v2:
-Fixed typo "lusture" to "lustre" in the subject

Please pick better subjects, you use pretty much the same thing twice here :(