Skip to contentSkip to conversation

staging: vc04_services: Use macro DIV_ROUND_UP

PATCH RESEND In review Gargi Sharma 2 participants 3 messages Mar 15, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 staging: vc04_services: Use macro DIV_ROUND_UP

The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)). It clarifies the divisor calculations.
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/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1 -1
index 03e1a13..eddff5f 100644
@@ -1569,7 +1569,7 @@ dump_phys_mem(void *virt_addr, u32 num_bytes)
 	offset = (int)(long)virt_addr & (PAGE_SIZE - 1);
 	end_offset = (int)(long)end_virt_addr & (PAGE_SIZE - 1);
 
-	num_pages = (offset + num_bytes + PAGE_SIZE - 1) / PAGE_SIZE;
+	num_pages = DIV_ROUND_UP(offset + num_bytes, PAGE_SIZE);
 
 	pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
 	if (pages == NULL) {
Signature · 1 line
2.7.4
#1 lore raw
Quoted 3 lines · Gargi Sharma

The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)). It clarifies the divisor calculations.
Coccinelle script:

As far as I can see, the patch is hugely out of date - the relevant code is now 500 lines later in the file, and the change has already been made on February 22 by Simran.

julia

Quoted 41 lines

@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1 -2
index 03e1a13..eddff5f 100644
@@ -1569,7 +1569,7 @@ dump_phys_mem(void *virt_addr, u32 num_bytes)
 	offset = (int)(long)virt_addr & (PAGE_SIZE - 1);
 	end_offset = (int)(long)end_virt_addr & (PAGE_SIZE - 1);
 
-	num_pages = (offset + num_bytes + PAGE_SIZE - 1) / PAGE_SIZE;
+	num_pages = DIV_ROUND_UP(offset + num_bytes, PAGE_SIZE);
 
 	pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
 	if (pages == NULL) {
--

2.7.4

--
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 post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1489583788-16458-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 4 lines · Julia Lawall

On Wed, 15 Mar 2017, Gargi Sharma wrote:

Quoted 8 lines
Quoted 3 lines

The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)). It clarifies the divisor calculations.
Coccinelle script:

As far as I can see, the patch is hugely out of date - the relevant code is now 500 lines later in the file, and the change has already been made on February 22 by Simran.

Oh, I'm so sorry. I rebased against staging-next and my commits were buried deep, after that. So I did a git reflog and reset and I think I lost all the patches.

Gargi

Quoted 43 lines

julia

Quoted 41 lines

@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1 -2
index 03e1a13..eddff5f 100644
@@ -1569,7 +1569,7 @@ dump_phys_mem(void *virt_addr, u32 num_bytes)
      offset = (int)(long)virt_addr & (PAGE_SIZE - 1);
      end_offset = (int)(long)end_virt_addr & (PAGE_SIZE - 1);
 
-     num_pages = (offset + num_bytes + PAGE_SIZE - 1) / PAGE_SIZE;
+     num_pages = DIV_ROUND_UP(offset + num_bytes, PAGE_SIZE);
 
      pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
      if (pages == NULL) {
--

2.7.4

--
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 post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1489583788-16458-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.