linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Cc: linux-sh@vger.kernel.org, gregkh@linuxfoundation.org,
	linux-serial@vger.kernel.org, magnus.damm@gmail.com
Subject: Re: [PATCH 1/3] serial: sh-sci: Updated calculation of bit error rate and bit rate
Date: Tue, 22 Jul 2014 10:37:29 +0900	[thread overview]
Message-ID: <20140722013726.GA31649@verge.net.au> (raw)
In-Reply-To: <1405321800-18114-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com>

On Mon, Jul 14, 2014 at 04:09:58PM +0900, Nobuhiro Iwamatsu wrote:
> Currently, the decimal point is discarded calculation of BRR.
> Therefore, it can not calculate a value close to the correct value.
> This patch fixes this problem by using DIV_ROUND_CLOSEST.
> 
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>

All three patches:

Acked-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/tty/serial/sh-sci.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 88236da..ce80137 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1796,11 +1796,13 @@ static void sci_baud_calc_hscif(unsigned int bps, unsigned long freq,
>  	for (sr = 8; sr <= 32; sr++) {
>  		for (c = 0; c <= 3; c++) {
>  			/* integerized formulas from HSCIF documentation */
> -			br = freq / (sr * (1 << (2 * c + 1)) * bps) - 1;
> +			br = DIV_ROUND_CLOSEST(freq, (sr *
> +					      (1 << (2 * c + 1)) * bps)) - 1;
>  			if (br < 0 || br > 255)
>  				continue;
> -			err = freq / ((br + 1) * bps * sr *
> -			      (1 << (2 * c + 1)) / 1000) - 1000;
> +			err = DIV_ROUND_CLOSEST(freq, ((br + 1) * bps * sr *
> +					       (1 << (2 * c + 1)) / 1000)) -
> +					       1000;
>  			if (min_err > err) {
>  				min_err = err;
>  				*brr = br;
> -- 
> 2.0.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

      parent reply	other threads:[~2014-07-22  1:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14  7:09 [PATCH 1/3] serial: sh-sci: Updated calculation of bit error rate and bit rate Nobuhiro Iwamatsu
2014-07-14  7:09 ` [PATCH 2/3] serial: sh-sci: Fix range check of bit-rate for HSCIF Nobuhiro Iwamatsu
2014-07-14  7:10 ` [PATCH 3/3] serial: sh-sci: Add calculation recive margin " Nobuhiro Iwamatsu
2015-11-02 13:56   ` Geert Uytterhoeven
2014-07-22  1:37 ` Simon Horman [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=20140722013726.GA31649@verge.net.au \
    --to=horms@verge.net.au \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=nobuhiro.iwamatsu.yj@renesas.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).