Hi Andy, Thanks for the quick review. On 10/05/24 20:31, Andy Shevchenko wrote: > On Fri, May 10, 2024 at 12:09:52AM +0530, Devarsh Thakkar wrote: >> Add macros to round to nearest specified power of 2. > > This is not what they are doing. For the above we already have macros defined. > Sorry I did not understand this comment, if you are talking about existing macros round_up & round_down they either round "up" and round "down" to specified power of 2 as specified here [1]. whereas the macros introduced in this patch round to "nearest" specified power of 2. >> Two macros are added : > > (Yes, after I wrapped to comment this line looks better on its own, > so whatever will be the first sentence, this line should be separated > from.) > Agreed. >> round_closest_up and round_closest_down which round up to nearest multiple > > round_closest_up() and round_closest_down() > > >> of 2 with a preference to round up or round down respectively if there are >> two possible nearest values to the given number. > > You should reformulate, because AFAICS there is the crucial difference > from these and existing round_*_pow_of_two(). > In math.h, we already have round_up/round_down macros which rounded up/down to next specified power of 2. Then we had the DIV_ROUND_CLOSEST which used the suffix _CLOSEST to imply the meaning that divided value will be rounded to nearest/closest int value either by rounding up or rounding down. So inspired from naming convention of this macros given developers are already familiar with them, I used round_closest for specifying the rounded value to nearest/closest value which can be achieved either by rounding up/down. And I also wanted user to have finer control for the scenarios where there are two possible nearest values : For e.g round(160, 64) can be either 192 and 128 and both are 32 away from 160. And that's the reason I went ahead with two macros instead i.e round_closest_up, round_closest_down so that developers can choose exactly what they want. Regards Devarsh