From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> To: linux-sh@vger.kernel.org Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org, horms+renesas@verge.net.au, magnus.damm@gmail.com, Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> Subject: [PATCH 2/3] serial: sh-sci: Fix range check of bit-rate for HSCIF Date: Mon, 14 Jul 2014 07:09:59 +0000 [thread overview] Message-ID: <1405321800-18114-2-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> (raw) In-Reply-To: <1405321800-18114-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> If bit-rate calculation result of HSCIF is expect 255 from 0, driver does not calculate error bit. However, we need to round the value to calculate error bit in the case of negative value. This rounds the value of bit-rate using clamp(), and bit-rate is the case of negative value, it enables the calculation of the error bit. Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> --- drivers/tty/serial/sh-sci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index ce80137..7f571a8 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1798,8 +1798,7 @@ static void sci_baud_calc_hscif(unsigned int bps, unsigned long freq, /* integerized formulas from HSCIF documentation */ br = DIV_ROUND_CLOSEST(freq, (sr * (1 << (2 * c + 1)) * bps)) - 1; - if (br < 0 || br > 255) - continue; + br = clamp(br, 0, 255); err = DIV_ROUND_CLOSEST(freq, ((br + 1) * bps * sr * (1 << (2 * c + 1)) / 1000)) - 1000; -- 2.0.0
WARNING: multiple messages have this Message-ID (diff)
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> To: linux-sh@vger.kernel.org Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org, horms+renesas@verge.net.au, magnus.damm@gmail.com, Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> Subject: [PATCH 2/3] serial: sh-sci: Fix range check of bit-rate for HSCIF Date: Mon, 14 Jul 2014 16:09:59 +0900 [thread overview] Message-ID: <1405321800-18114-2-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> (raw) In-Reply-To: <1405321800-18114-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> If bit-rate calculation result of HSCIF is expect 255 from 0, driver does not calculate error bit. However, we need to round the value to calculate error bit in the case of negative value. This rounds the value of bit-rate using clamp(), and bit-rate is the case of negative value, it enables the calculation of the error bit. Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> --- drivers/tty/serial/sh-sci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index ce80137..7f571a8 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1798,8 +1798,7 @@ static void sci_baud_calc_hscif(unsigned int bps, unsigned long freq, /* integerized formulas from HSCIF documentation */ br = DIV_ROUND_CLOSEST(freq, (sr * (1 << (2 * c + 1)) * bps)) - 1; - if (br < 0 || br > 255) - continue; + br = clamp(br, 0, 255); err = DIV_ROUND_CLOSEST(freq, ((br + 1) * bps * sr * (1 << (2 * c + 1)) / 1000)) - 1000; -- 2.0.0
next prev parent reply other threads:[~2014-07-14 7:09 UTC|newest] Thread overview: 10+ 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 ` Nobuhiro Iwamatsu 2014-07-14 7:09 ` Nobuhiro Iwamatsu [this message] 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 2014-07-14 7:10 ` Nobuhiro Iwamatsu 2015-11-02 13:56 ` Geert Uytterhoeven 2015-11-02 13:56 ` Geert Uytterhoeven 2014-07-22 1:37 ` [PATCH 1/3] serial: sh-sci: Updated calculation of bit error rate and bit rate Simon Horman 2014-07-22 1:37 ` Simon Horman
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=1405321800-18114-2-git-send-email-nobuhiro.iwamatsu.yj@renesas.com \ --to=nobuhiro.iwamatsu.yj@renesas.com \ --cc=gregkh@linuxfoundation.org \ --cc=horms+renesas@verge.net.au \ --cc=linux-serial@vger.kernel.org \ --cc=linux-sh@vger.kernel.org \ --cc=magnus.damm@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.