Move the code that programs the divisor latch out of ns8250_param()
into ns8250_set_baudrate(), and the code that computes the rate from
it out of the UART_IOCTL_BAUD handler into ns8250_get_baudrate().
ns8250_get_divisor() now returns the input clock cycles per bit,
prescaler included, in units of 1 / NS8250_DIVISOR_SCALE, and the
rate, the delays and the rclk guess are derived from it. This leaves
room for other prescalers and for fractional dividers.
ns8250_delay() is now computed in 64 bits with one formula. The old
code split at a divisor of 134 to keep 16000000 * divisor within an int
(ebecffe93038), and above 134 divided by rclk / 1000 rounded down. With
a clock that is not a multiple of 1 kHz this made the delay longer by
(rclk % 1000) / (rclk - rclk % 1000): 0.011% with a 1.8432 MHz clock,
e.g. 20002 instead of 20000 us at 50 baud. Up to a divisor of 134 the
result is the same. The delay is only a polling interval for
ns8250_drain() and the FIFO size probe.
No other functional change intended.
Sponsored by: Alchemilla Ventures Private Limited