From: Adrian Bunk <bunk@stusta.de>
To: Rolf Eike Beer <eike-kernel@sf-tec.de>
Cc: Rogier Wolff <R.E.Wolff@bitwizard.nl>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
linux-kernel@vger.kernel.org
Subject: [2.6.19 patch] drivers/char/specialix.c: fix the baud conversion
Date: Wed, 11 Oct 2006 06:48:38 +0200 [thread overview]
Message-ID: <20061011044838.GG721@stusta.de> (raw)
In-Reply-To: <200610101401.20295.eike-kernel@sf-tec.de>
On Tue, Oct 10, 2006 at 02:01:19PM +0200, Rolf Eike Beer wrote:
> Adrian Bunk wrote:
> > On Mon, Oct 09, 2006 at 08:37:45AM +0200, Rogier Wolff wrote:
> > > On Mon, Oct 09, 2006 at 12:18:19AM +0200, Adrian Bunk wrote:
> > > > + if (baud == 38400) {
> > > > if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
> > > > baud ++;
> > > > if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
> > > > baud += 2;
> > > > }
> > > >
> > > > Increasing the index for baud_table[] by 1 or 2 is quite different from
> > > > increasing baud by 1 or 2.
> > >
> > > In that range,
> > > baud <<= 1;
> > > and
> > > baud <<= 2;
> > >
> > > should work.
> >
> > Thanks for the hint.
> >
> > What about the patch below?
>
> > @@ -1090,9 +1085,9 @@
> >
> > if (baud == 38400) {
> > if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
> > - baud ++;
> > + baud <<= 1;
> > if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
> > - baud += 2;
> > + baud <<= 2;
> > }
> >
> > if (!baud) {
>
> Neither is 38400 <<= 1 == 57600 nor is 38400 <<= 2 == 115200. You should just
> set baud to the value you want instead of doing tricks here.
Damn, I should have checked the numbers myself... :-(
Thanks for the correction, an updated patch is below.
> Eike
cu
Adrian
<-- snip -->
This patch corrects the following bugs introduced by
commit 67cc0161ecc9ebee6eba4af6cbfdba028090b1b9:
- remove one remaining and now incorrect baud_table[] usage
- "baud +=" is no longer correct
The former bug was spotted by the Coverity checker.
Rolf Eike Beer spotted a bug in the initial version of my patch.
Signed-off-by: Adrian Bunk <bunk@stusta.de>
---
drivers/char/specialix.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
--- linux-2.6/drivers/char/specialix.c.old 2006-10-11 06:35:44.000000000 +0200
+++ linux-2.6/drivers/char/specialix.c 2006-10-11 06:36:52.000000000 +0200
@@ -183,11 +183,6 @@
static struct tty_driver *specialix_driver;
-static unsigned long baud_table[] = {
- 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
- 9600, 19200, 38400, 57600, 115200, 0,
-};
-
static struct specialix_board sx_board[SX_NBOARD] = {
{ 0, SX_IOBASE1, 9, },
{ 0, SX_IOBASE2, 11, },
@@ -1090,9 +1085,9 @@
if (baud == 38400) {
if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- baud ++;
+ baud = 57600;
if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- baud += 2;
+ baud = 115200;
}
if (!baud) {
@@ -1150,11 +1145,9 @@
sx_out(bp, CD186x_RBPRL, tmp & 0xff);
sx_out(bp, CD186x_TBPRL, tmp & 0xff);
spin_unlock_irqrestore(&bp->lock, flags);
- if (port->custom_divisor) {
+ if (port->custom_divisor)
baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor;
- baud = ( baud + 5 ) / 10;
- } else
- baud = (baud_table[baud] + 5) / 10; /* Estimated CPS */
+ baud = (baud + 5) / 10; /* Estimated CPS */
/* Two timer ticks seems enough to wakeup something like SLIP driver */
tmp = ((baud + HZ/2) / HZ) * 2 - CD186x_NFIFO;
prev parent reply other threads:[~2006-10-11 4:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-08 22:18 drivers/char/specialix.c: broken baud conversion Adrian Bunk
2006-10-09 6:37 ` Rogier Wolff
2006-10-10 6:17 ` [2.6.19 patch] drivers/char/specialix.c: fix the " Adrian Bunk
2006-10-10 12:01 ` Rolf Eike Beer
2006-10-11 4:48 ` Adrian Bunk [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=20061011044838.GG721@stusta.de \
--to=bunk@stusta.de \
--cc=R.E.Wolff@bitwizard.nl \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=eike-kernel@sf-tec.de \
--cc=linux-kernel@vger.kernel.org \
/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 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.