* [PATCH v2 4/4] staging: most: hdm-dim2: Use macro DIV_ROUND_UP
@ 2016-02-22 12:29 Bhaktipriya Shridhar
2016-02-26 6:35 ` [Outreachy kernel] " Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Bhaktipriya Shridhar @ 2016-02-22 12:29 UTC (permalink / raw)
To: outreachy-kernel
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)
)
Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
---
Changes in v2:
- None for this file.
drivers/staging/most/hdm-dim2/dim2_hal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/most/hdm-dim2/dim2_hal.c b/drivers/staging/most/hdm-dim2/dim2_hal.c
index 3c52450..03da89e 100644
--- a/drivers/staging/most/hdm-dim2/dim2_hal.c
+++ b/drivers/staging/most/hdm-dim2/dim2_hal.c
@@ -120,7 +120,7 @@ static int alloc_dbr(u16 size)
return DBR_SIZE; /* out of memory */
for (i = 0; i < DBR_MAP_SIZE; i++) {
- u32 const blocks = (size + DBR_BLOCK_SIZE - 1) / DBR_BLOCK_SIZE;
+ u32 const blocks = DIV_ROUND_UP(size, DBR_BLOCK_SIZE);
u32 mask = ~((~(u32)0) << blocks);
do {
@@ -140,7 +140,7 @@ static int alloc_dbr(u16 size)
static void free_dbr(int offs, int size)
{
int block_idx = offs / DBR_BLOCK_SIZE;
- u32 const blocks = (size + DBR_BLOCK_SIZE - 1) / DBR_BLOCK_SIZE;
+ u32 const blocks = DIV_ROUND_UP(size, DBR_BLOCK_SIZE);
u32 mask = ~((~(u32)0) << blocks);
mask <<= block_idx % 32;
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Outreachy kernel] [PATCH v2 4/4] staging: most: hdm-dim2: Use macro DIV_ROUND_UP
2016-02-22 12:29 [PATCH v2 4/4] staging: most: hdm-dim2: Use macro DIV_ROUND_UP Bhaktipriya Shridhar
@ 2016-02-26 6:35 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2016-02-26 6:35 UTC (permalink / raw)
To: Bhaktipriya Shridhar; +Cc: outreachy-kernel
On Mon, Feb 22, 2016 at 05:59:06PM +0530, Bhaktipriya Shridhar wrote:
> 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)
> )
>
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> ---
> Changes in v2:
> - None for this file.
> drivers/staging/most/hdm-dim2/dim2_hal.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/most/hdm-dim2/dim2_hal.c b/drivers/staging/most/hdm-dim2/dim2_hal.c
> index 3c52450..03da89e 100644
> --- a/drivers/staging/most/hdm-dim2/dim2_hal.c
> +++ b/drivers/staging/most/hdm-dim2/dim2_hal.c
> @@ -120,7 +120,7 @@ static int alloc_dbr(u16 size)
> return DBR_SIZE; /* out of memory */
>
> for (i = 0; i < DBR_MAP_SIZE; i++) {
> - u32 const blocks = (size + DBR_BLOCK_SIZE - 1) / DBR_BLOCK_SIZE;
> + u32 const blocks = DIV_ROUND_UP(size, DBR_BLOCK_SIZE);
> u32 mask = ~((~(u32)0) << blocks);
>
> do {
> @@ -140,7 +140,7 @@ static int alloc_dbr(u16 size)
> static void free_dbr(int offs, int size)
> {
> int block_idx = offs / DBR_BLOCK_SIZE;
> - u32 const blocks = (size + DBR_BLOCK_SIZE - 1) / DBR_BLOCK_SIZE;
> + u32 const blocks = DIV_ROUND_UP(size, DBR_BLOCK_SIZE);
> u32 mask = ~((~(u32)0) << blocks);
>
> mask <<= block_idx % 32;
This patch breaks the build :(
ALWAYS test-build your patches.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-26 6:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22 12:29 [PATCH v2 4/4] staging: most: hdm-dim2: Use macro DIV_ROUND_UP Bhaktipriya Shridhar
2016-02-26 6:35 ` [Outreachy kernel] " Greg KH
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.