linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: aystarik@gmail.com,
	Ludovic Desroches <ludovic.desroches@atmel.com>,
	Boris BREZILLON <boris.brezillon@free-electrons.com>,
	richard.genoud@gmail.com, linux-serial@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] tty/serial: atmel: fix fractional baud rate computation
Date: Mon, 26 Sep 2016 08:17:50 +0200	[thread overview]
Message-ID: <20160926061750.4jjgpbttdesdyrae@pengutronix.de> (raw)
In-Reply-To: <20160921104414.16241-1-nicolas.ferre@atmel.com>

[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]

Hello,

On Wed, Sep 21, 2016 at 12:44:14PM +0200, Nicolas Ferre wrote:
> From: Alexey Starikovskiy <aystarik@gmail.com>
> 
> The problem with previous code was it rounded values in wrong
> place and produced wrong baud rate in some cases.
> 
> Signed-off-by: Alexey Starikovskiy <aystarik@gmail.com>
> [nicolas.ferre@atmel.com: port to newer kernel and add commit log]
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>

I first thought this patch results in not always picking the optimal
divider in some cases. But given the right error function (i.e.
error(r) = abs(1/r_target - 1/r_actual) which minimizes the error in the
time domain and so guarantees the maximal count of matched samples) it
can be proved to result in the right values (assuming no overflow etc.).

As writing formulas in email is cumbersome, see the attachment for a
prove.

Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: baudrate.pdf --]
[-- Type: application/pdf, Size: 69704 bytes --]

      parent reply	other threads:[~2016-09-26  6:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21 10:44 [PATCH] tty/serial: atmel: fix fractional baud rate computation Nicolas Ferre
2016-09-22  7:07 ` Uwe Kleine-König
2016-09-22  7:39   ` Boris Brezillon
2016-09-22  9:43     ` Boris Brezillon
2016-09-25 12:13       ` Boris Brezillon
2016-09-25 12:14 ` Boris Brezillon
2016-09-26  6:17 ` Uwe Kleine-König [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160926061750.4jjgpbttdesdyrae@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=aystarik@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=ludovic.desroches@atmel.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=richard.genoud@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).