On Mon, Apr 11, 2022 at 11:33:10AM +0300, Ilpo Järvinen wrote: > Struct uart_port currently stores FIFO timeout. Having character > timing information readily available is useful. Even serial core > itself determines char_time from port->timeout using inverse > calculation. > > Store frame_time directly into uart_port. Character time is stored > in nanoseconds to have reasonable precision with high rates. > To avoid overflow, 64-bit math is necessary. > > It might be possible to determine timeout from frame_time by > multiplying it with fifosize as needed but only part of the > users seem to be protected by a lock. Thus, this patch does > not pursue storing only frame_time in uart_port. ... > - char_time = (port->timeout - HZ/50) / port->fifosize; > - char_time = char_time / 5; > - if (char_time == 0) > - char_time = 1; > + char_time = max(nsecs_to_jiffies(port->frame_time / 5), 1UL); > + > if (timeout && timeout < char_time) > char_time = timeout; Seems it can be packed to something like char_time = min_not_zero(nsecs_to_jiffies(port->frame_time / 5), timeout); ? -- With Best Regards, Andy Shevchenko