serial: sh-sci: Improve bit rate error calculation for HSCIF
The algorithm to find the best parameters for the requested bit rate
calculates the relative bit rate error, using "(br * scrate) / 1000".
For small "br * scrate", this has two problems:
- The quotient may be zero, leading to a division by zero error,
- This may introduce a large rounding error.
Switch from relative to absolute bit rate error calculation to fix this.
The default baud rate generator values can be removed, as there will
always be one set of values that gives the smallest absolute error.
Print the best set of values when debugging.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 file changed