staging: most: hdm-dim2: Use macro DIV_ROUND_UP
Subsystems (2)
PATCH v2 4/4 staging: most: hdm-dim2: 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:
- None for this file.
drivers/staging/most/hdm-dim2/dim2_hal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/hdm-dim2/dim2_hal.c +2 -2
@@ -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
Greg KH
maintainerQuoted 36 lines · Bhaktipriya Shridhar
The macro
DIV_ROUND_UPperforms 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 <[email protected]>---
Changes in v2:
- None for this file.drivers/staging/most/hdm-dim2/dim2_hal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/most/hdm-dim2/dim2_hal.c +1
-1@@ -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 {
drivers/staging/most/hdm-dim2/dim2_hal.c static int alloc_dbr(u16 size) · line 146
Quoted 8 lines
drivers/staging/most/hdm-dim2/dim2_hal.c +1
-1@@ -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