]> git.karo-electronics.de Git - linux-beck.git/commit
serial: sh-sci: Improve bit rate error calculation for HSCIF
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 16 Nov 2015 14:54:47 +0000 (15:54 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 17 Dec 2015 10:18:32 +0000 (11:18 +0100)
commit881a7489f463e59a44417ad89ecb4ea21b2b86cd
tree28847d3b4ae05aacdda7dadc1cc235665b91ebec
parentde01e6cd0b100bac088b1d59a7040ebe2af64f1c
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>
drivers/tty/serial/sh-sci.c