Skip to contentSkip to conversation

staging: most: dim2: convert ROUND_UP_TO macro to static inline function

PATCH In review Mark Adamenko 2 participants 2 messages Mar 5

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

PATCH 1/1 staging: most: dim2: convert ROUND_UP_TO macro to static inline function

The ROUND_UP_TO macro reuses argument 'd', which can cause unintended side effects. Replace it with a static inline function.

---
 drivers/staging/most/dim2/hal.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/staging/most/dim2/hal.c +5 -2
index 6abe3ab2b2cf..53a3af9e9fbb 100644
@@ -45,7 +45,10 @@
 #define DBR_SIZE  (16 * 1024) /* specified by IP */
 #define DBR_BLOCK_SIZE  (DBR_SIZE / 32 / DBR_MAP_SIZE)
 
-#define ROUND_UP_TO(x, d)  (DIV_ROUND_UP(x, (d)) * (d))
+static inline u16 round_up_to(u16 x, u16 d)
+{
+	return DIV_ROUND_UP(x, d) * d;
+}
 
 /* -------------------------------------------------------------------------- */
 /* generic helper functions and macros */
@@ -758,7 +761,7 @@ static u8 init_ctrl_async(struct dim_channel *ch, u8 type, u8 is_tx,
 		return DIM_INIT_ERR_CHANNEL_ADDRESS;
 
 	if (!ch->dbr_size)
-		ch->dbr_size = ROUND_UP_TO(hw_buffer_size, DBR_BLOCK_SIZE);
+		ch->dbr_size = round_up_to(hw_buffer_size, DBR_BLOCK_SIZE);
 	ch->dbr_addr = alloc_dbr(ch->dbr_size);
 	if (ch->dbr_addr >= DBR_SIZE)
 		return DIM_INIT_ERR_OUT_OF_MEMORY;
Signature · 1 line
2.53.0
#1 lore raw

drivers/staging/most/dim2/hal.c static u8 init_ctrl_async(struct dim_channel *ch, u8 type, u8 is_tx, · line 764

Quoted 6 lines · Mark Adamenko
drivers/staging/most/dim2/hal.c +1 -1
@@ -758,7 +761,7 @@ static u8 init_ctrl_async(struct dim_channel *ch, u8 type, u8 is_tx,
 		return DIM_INIT_ERR_CHANNEL_ADDRESS;
 
 	if (!ch->dbr_size)
-		ch->dbr_size = ROUND_UP_TO(hw_buffer_size, DBR_BLOCK_SIZE);
+		ch->dbr_size = round_up_to(hw_buffer_size, DBR_BLOCK_SIZE);

We already have roundup() and round_up(). Use one of those.

regards,
dan carpenter