aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/mxser.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-02-07 03:16:41 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:34 -0500
commitf29e37c076cd08004e31297d205d54ac38cf7a20 (patch)
tree896c74c058c443507a1cf99241449eb87099e96f /drivers/char/mxser.c
parentb98e70de7836cf0ea49b6714b2455381865b1260 (diff)
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
1391 long baud; 1391 long baud;
1392 if (get_user(baud, (long __user *)argp)) 1392 if (get_user(baud, (long __user *)argp))
1393 return -EFAULT; 1393 return -EFAULT;
1394 mxser_set_baud(info, baud); 1394 if (mxser_set_baud(info, baud) == -1)
1395 return -1;
1395 return 0; 1396 return 0;
1396 } 1397 }
1397 case MOXA_ASPP_GETBAUD: 1398 case MOXA_ASPP_GETBAUD:
@@ -2517,7 +2518,13 @@ static int mxser_change_speed(struct mxser_struct *info, struct ktermios *old_te
2517#endif 2518#endif
2518 if (mxser_set_baud_method[info->port] == 0) { 2519 if (mxser_set_baud_method[info->port] == 0) {
2519 baud = tty_get_baud_rate(info->tty); 2520 baud = tty_get_baud_rate(info->tty);
2520 mxser_set_baud(info, baud); 2521 if (mxser_set_baud(info, baud) == -1) {
2522 /* Use previous rate on a failure */
2523 if (old_termios) {
2524 baud = tty_termios_baud_rate(old_termios);
2525 tty_encode_baud_rate(info->tty, baud, baud);
2526 }
2527 }
2521 } 2528 }
2522 2529
2523 /* byte size and parity */ 2530 /* byte size and parity */
@@ -2691,27 +2698,31 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2691{ 2698{
2692 int quot = 0; 2699 int quot = 0;
2693 unsigned char cval; 2700 unsigned char cval;
2694 int ret = 0;
2695 unsigned long flags; 2701 unsigned long flags;
2702 unsigned int baud;
2696 2703
2697 if (!info->tty || !info->tty->termios) 2704 if (!info->tty || !info->tty->termios)
2698 return ret; 2705 return -1;
2699 2706
2700 if (!(info->base)) 2707 if (!(info->base))
2701 return ret; 2708 return -1;
2702 2709
2703 if (newspd > info->MaxCanSetBaudRate) 2710 if (newspd > info->MaxCanSetBaudRate)
2704 return 0; 2711 return -1;
2705 2712
2706 info->realbaud = newspd; 2713 info->realbaud = newspd;
2707 if (newspd == 134) { 2714 if (newspd == 134) {
2708 quot = (2 * info->baud_base / 269); 2715 quot = (2 * info->baud_base / 269);
2716 tty_encode_baud_rate(info->tty, 134, 134);
2709 } else if (newspd) { 2717 } else if (newspd) {
2710 quot = info->baud_base / newspd; 2718 quot = info->baud_base / newspd;
2711 if (quot == 0) 2719 if (quot == 0)
2712 quot = 1; 2720 quot = 1;
2721 baud = info->baud_base / quot;
2722 tty_encode_baud_rate(info->tty, baud, baud);
2713 } else { 2723 } else {
2714 quot = 0; 2724 quot = 0;
2725 tty_encode_baud_rate(info->tty, 0, 0);
2715 } 2726 }
2716 2727
2717 info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base); 2728 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)
2727 info->MCR &= ~UART_MCR_DTR; 2738 info->MCR &= ~UART_MCR_DTR;
2728 outb(info->MCR, info->base + UART_MCR); 2739 outb(info->MCR, info->base + UART_MCR);
2729 spin_unlock_irqrestore(&info->slock, flags); 2740 spin_unlock_irqrestore(&info->slock, flags);
2730 return ret; 2741 return 0;
2731 } 2742 }
2732 2743
2733 cval = inb(info->base + UART_LCR); 2744 cval = inb(info->base + UART_LCR);
@@ -2739,7 +2750,7 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2739 outb(cval, info->base + UART_LCR); /* reset DLAB */ 2750 outb(cval, info->base + UART_LCR); /* reset DLAB */
2740 2751
2741 2752
2742 return ret; 2753 return 0;
2743} 2754}
2744 2755
2745/* 2756/*