staging: vc04_services: Use macro DIV_ROUND_UP
Subsystems (2)
PATCH 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_2835_arm.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +1 -1
@@ -400,7 +400,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,dma_addr_t dma_addr; offset = ((unsigned int )(unsigned long )buf & (PAGE_SIZE -1 )); - num_pages = (count + offset +PAGE_SIZE -1 ) /PAGE_SIZE ; + num_pages =DIV_ROUND_UP (count + offset,PAGE_SIZE ); pagelist_size =sizeof (PAGELIST_T ) + (num_pages * sizeof(u32)) +
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1 -1
@@ -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
Quoted 2 lines · Gargi Sharma
The macro
DIV_ROUND_UPperforms the computation (((n) + (d) - 1) /(d)). It clarifies the divisor calculations.
I already have these changes.
julia
Quoted 56 lines
Coccinelle script:
@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+DIV_ROUND_UP(e1,e2)
)Signed-off-by Gargi Sharma <[email protected]>--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +1
-1@@ -400,7 +400,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,dma_addr_t dma_addr; offset = ((unsigned int )(unsigned long )buf & (PAGE_SIZE -1 )); - num_pages = (count + offset +PAGE_SIZE -1 ) /PAGE_SIZE ; + num_pages =DIV_ROUND_UP (count + offset,PAGE_SIZE ); pagelist_size =sizeof (PAGELIST_T ) + (num_pages * sizeof(u32)) +drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1
-2@@ -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/1489264063-3553-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Greg KH
maintainerQuoted 16 lines · Gargi Sharma
The macro
DIV_ROUND_UPperforms 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)
)
Quoted 5 lines
Signed-off-by Gargi Sharma <[email protected]>--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Did not apply to my tree at all :(
Please rebase and resend.
thanks,
greg k-h