summaryrefslogtreecommitdiffstats
path: root/drivers/char/mxser.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-02-07 00:16:41 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 08:42:34 -0800
commitf29e37c076cd08004e31297d205d54ac38cf7a20 (patch)
tree896c74c058c443507a1cf99241449eb87099e96f /drivers/char/mxser.c
parentb98e70de7836cf0ea49b6714b2455381865b1260 (diff)
downloadlinux-f29e37c076cd08004e31297d205d54ac38cf7a20.tar.gz
linux-f29e37c076cd08004e31297d205d54ac38cf7a20.tar.bz2
linux-f29e37c076cd08004e31297d205d54ac38cf7a20.zip
mxser/mxser_new: first pass over termios reporting for the mxser cards
Signed-off-by: Alan Cox <alan@redhat.com> Cc: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/mxser.c')
-rw-r--r--drivers/char/mxser.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 5d7901096048..35ff7a245540 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -1391,7 +1391,8 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
long baud;
if (get_user(baud, (long __user *)argp))
return -EFAULT;
- mxser_set_baud(info, baud);
+ if (mxser_set_baud(info, baud) == -1)
+ return -1;
return 0;
}
case MOXA_ASPP_GETBAUD:
@@ -2517,7 +2518,13 @@ static int mxser_change_speed(struct mxser_struct *info, struct ktermios *old_te
#endif
if (mxser_set_baud_method[info->port] == 0) {
baud = tty_get_baud_rate(info->tty);
- mxser_set_baud(info, baud);
+ if (mxser_set_baud(info, baud) == -1) {
+ /* Use previous rate on a failure */
+ if (old_termios) {
+ baud = tty_termios_baud_rate(old_termios);
+ tty_encode_baud_rate(info->tty, baud, baud);
+ }
+ }
}
/* byte size and parity */
@@ -2691,27 +2698,31 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
{
int quot = 0;
unsigned char cval;
- int ret = 0;
unsigned long flags;
+ unsigned int baud;
if (!info->tty || !info->tty->termios)
- return ret;
+ return -1;
if (!(info->base))
- return ret;
+ return -1;
if (newspd > info->MaxCanSetBaudRate)
- return 0;
+ return -1;
info->realbaud = newspd;
if (newspd == 134) {
quot = (2 * info->baud_base / 269);
+ tty_encode_baud_rate(info->tty, 134, 134);
} else if (newspd) {
quot = info->baud_base / newspd;
if (quot == 0)
quot = 1;
+ baud = info->baud_base / quot;
+ tty_encode_baud_rate(info->tty, baud, baud);
} else {
quot = 0;
+ tty_encode_baud_rate(info->tty, 0, 0);
}
info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
@@ -2727,7 +2738,7 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
info->MCR &= ~UART_MCR_DTR;
outb(info->MCR, info->base + UART_MCR);
spin_unlock_irqrestore(&info->slock, flags);
- return ret;
+ return 0;
}
cval = inb(info->base + UART_LCR);
@@ -2739,7 +2750,7 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
outb(cval, info->base + UART_LCR); /* reset DLAB */
- return ret;
+ return 0;
}
/*