* [RESEND PATCH] staging: vc04_services: Use macro DIV_ROUND_UP
@ 2017-03-15 13:16 Gargi Sharma
2017-03-15 13:37 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Gargi Sharma @ 2017-03-15 13:16 UTC (permalink / raw)
To: outreachy-kernel; +Cc: gregkh, Gargi Sharma
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)
)
Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 03e1a13..eddff5f 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [RESEND PATCH] staging: vc04_services: Use macro DIV_ROUND_UP
2017-03-15 13:16 [RESEND PATCH] staging: vc04_services: Use macro DIV_ROUND_UP Gargi Sharma
@ 2017-03-15 13:37 ` Julia Lawall
2017-03-15 14:46 ` Gargi Sharma
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2017-03-15 13:37 UTC (permalink / raw)
To: Gargi Sharma; +Cc: outreachy-kernel, gregkh
On Wed, 15 Mar 2017, Gargi Sharma wrote:
> 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
>
> @@
> 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 <gs051095@gmail.com>
> ---
> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> index 03e1a13..eddff5f 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [RESEND PATCH] staging: vc04_services: Use macro DIV_ROUND_UP
2017-03-15 13:37 ` [Outreachy kernel] " Julia Lawall
@ 2017-03-15 14:46 ` Gargi Sharma
0 siblings, 0 replies; 3+ messages in thread
From: Gargi Sharma @ 2017-03-15 14:46 UTC (permalink / raw)
To: Julia Lawall; +Cc: outreachy-kernel, Greg KH
On Wed, Mar 15, 2017 at 7:07 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Wed, 15 Mar 2017, Gargi Sharma wrote:
>
>> 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
> julia
>
>>
>> @@
>> 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 <gs051095@gmail.com>
>> ---
>> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> index 03e1a13..eddff5f 100644
>> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
>> @@ -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 outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> 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.
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-15 14:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15 13:16 [RESEND PATCH] staging: vc04_services: Use macro DIV_ROUND_UP Gargi Sharma
2017-03-15 13:37 ` [Outreachy kernel] " Julia Lawall
2017-03-15 14:46 ` Gargi Sharma
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.