The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] staging: most: dim2: convert ROUND_UP_TO macro to static inline function
@ 2026-03-05  2:30 Mark Adamenko
  2026-03-05  6:33 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Adamenko @ 2026-03-05  2:30 UTC (permalink / raw)
  To: linux-staging
  Cc: parthiban.veerasooran, christian.gromm, gregkh, linux-kernel,
	Mark Adamenko

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

Signed-off-by: Mark Adamenko <marusik.adamenko@gmail.com>
---
 drivers/staging/most/dim2/hal.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/most/dim2/hal.c b/drivers/staging/most/dim2/hal.c
index 6abe3ab2b2cf..53a3af9e9fbb 100644
--- a/drivers/staging/most/dim2/hal.c
+++ b/drivers/staging/most/dim2/hal.c
@@ -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;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: most: dim2: convert ROUND_UP_TO macro to static inline function
  2026-03-05  2:30 [PATCH] staging: most: dim2: convert ROUND_UP_TO macro to static inline function Mark Adamenko
@ 2026-03-05  6:33 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-03-05  6:33 UTC (permalink / raw)
  To: Mark Adamenko
  Cc: linux-staging, parthiban.veerasooran, christian.gromm, gregkh,
	linux-kernel

On Wed, Mar 04, 2026 at 06:30:00PM -0800, Mark Adamenko wrote:
> @@ -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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-05  6:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05  2:30 [PATCH] staging: most: dim2: convert ROUND_UP_TO macro to static inline function Mark Adamenko
2026-03-05  6:33 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox